Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
09e22977
Commit
09e22977
authored
Aug 1, 2012
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1490418
by tim.plunkett: Convert node/add/TYPE to use %node_type().
parent
00175843
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/node/node.module
+43
-20
43 additions, 20 deletions
core/modules/node/node.module
core/modules/node/node.pages.inc
+5
-5
5 additions, 5 deletions
core/modules/node/node.pages.inc
with
48 additions
and
25 deletions
core/modules/node/node.module
+
43
−
20
View file @
09e22977
...
...
@@ -471,6 +471,32 @@ function node_type_get_name($node) {
return
isset
(
$types
[
$type
])
?
$types
[
$type
]
:
FALSE
;
}
/**
* Title callback: Returns the sanitized node type name.
*
* @param $node_type
* The node type object.
*
* @return
* The node type name that is safe for printing.
*/
function
node_type_get_clean_name
(
$node_type
)
{
return
check_plain
(
$node_type
->
name
);
}
/**
* Description callback: Returns the node type description.
*
* @param $node_type
* The node type object.
*
* @return
* The node type description.
*/
function
node_type_get_description
(
$node_type
)
{
return
$node_type
->
description
;
}
/**
* Updates the database cache of node types.
*
...
...
@@ -1940,19 +1966,17 @@ function node_menu() {
'access arguments'
=>
array
(
'access content'
),
'type'
=>
MENU_CALLBACK
,
);
// @todo Remove this loop when we have a 'description callback' property.
foreach
(
node_type_get_types
()
as
$type
)
{
$items
[
'node/add/'
.
$type
->
type
]
=
array
(
'title'
=>
$type
->
name
,
'title callback'
=>
'check_plain'
,
$items
[
'node/add/%node_type'
]
=
array
(
'title callback'
=>
'node_type_get_clean_name'
,
'title arguments'
=>
array
(
2
),
'page callback'
=>
'node_add'
,
'page arguments'
=>
array
(
$type
->
type
),
'page arguments'
=>
array
(
2
),
'access callback'
=>
'node_access'
,
'access arguments'
=>
array
(
'create'
,
$type
->
type
),
'description'
=>
$type
->
description
,
'access arguments'
=>
array
(
'create'
,
2
),
'description callback'
=>
'node_type_get_description'
,
'description arguments'
=>
array
(
2
),
'file'
=>
'node.pages.inc'
,
);
}
$items
[
'node/%node'
]
=
array
(
'title callback'
=>
'node_page_title'
,
'title arguments'
=>
array
(
1
),
...
...
@@ -2890,9 +2914,9 @@ function node_form_system_themes_admin_form_submit($form, &$form_state) {
* - "update"
* - "delete"
* - "create"
* @param Drupal\node\Node|string $node
* @param Drupal\node\Node|string
|stdClass
$node
* The node entity on which the operation is to be performed, or the node type
* (e.g., 'forum') for the 'create' operation.
*
object, or node type string
(e.g., 'forum') for the 'create' operation.
* @param $account
* (optional) A user object representing the user for whom the operation is to
* be performed. Determines access for a user other than the current user.
...
...
@@ -2923,16 +2947,15 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) {
$account
=
$GLOBALS
[
'user'
];
}
// $node may be either an object or a node type. Since node types cannot be
// an integer, use either nid or type as the static cache id.
$cid
=
is_object
(
$node
)
?
$node
->
nid
:
$node
;
// $node may be a node object, a node type object, or a node type string.
// Use the node ID as the primary cache ID, or the node type name otherwise.
$cid
=
is_object
(
$node
)
?
(
isset
(
$node
->
nid
)
?
$node
->
nid
:
$node
->
type
)
:
$node
;
// If no language code was provided, default to the node's langcode or
// to an empty langcode if a node type was requested. The latter is purely
// for caching purposes.
if
(
empty
(
$langcode
))
{
$langcode
=
is_object
(
$node
)
?
$node
->
langcode
:
''
;
$langcode
=
(
is_object
(
$node
)
&&
isset
(
$node
->
nid
))
?
$node
->
langcode
:
''
;
}
// If we've already checked access for this node, user and op, return from
...
...
This diff is collapsed.
Click to expand it.
core/modules/node/node.pages.inc
+
5
−
5
View file @
09e22977
...
...
@@ -77,25 +77,25 @@ function theme_node_add_list($variables) {
/**
* Page callback: Provides the node submission form.
*
* @param $type
* The node type for the submitted node.
* @param $
node_
type
* The node type
object
for the submitted node.
*
* @return
* Returns a node submission form.
*
* @see node_menu()
*/
function
node_add
(
$type
)
{
function
node_add
(
$
node_
type
)
{
global
$user
;
$type
s
=
node_type
_get_
type
s
()
;
$type
=
$
node_type
->
type
;
$node
=
entity_create
(
'node'
,
array
(
'uid'
=>
$user
->
uid
,
'name'
=>
(
isset
(
$user
->
name
)
?
$user
->
name
:
''
),
'type'
=>
$type
,
'langcode'
=>
node_type_get_default_langcode
(
$type
)
));
drupal_set_title
(
t
(
'Create @name'
,
array
(
'@name'
=>
$
types
[
$
type
]
->
name
)),
PASS_THROUGH
);
drupal_set_title
(
t
(
'Create @name'
,
array
(
'@name'
=>
$
node_
type
->
name
)),
PASS_THROUGH
);
$output
=
drupal_get_form
(
$type
.
'_node_form'
,
$node
);
return
$output
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment