Commit 9f99a903 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#204415 by Lynn, traxer, pwolanin: migrate node type URLs to a path model...

#204415 by Lynn, traxer, pwolanin: migrate node type URLs to a path model based on menu paths, so conflicts between action and node type names are not a problem
parent 8eb3ba59
......@@ -20,16 +20,16 @@ function node_overview_types() {
if (node_hook($type, 'form')) {
$type_url_str = str_replace('_', '-', $type->type);
$row = array(
l($name, 'admin/content/types/'. $type_url_str),
l($name, 'admin/content/node-type/'. $type_url_str),
check_plain($type->type),
filter_xss_admin($type->description),
);
// Set the edit column.
$row[] = array('data' => l(t('edit'), 'admin/content/types/'. $type_url_str));
$row[] = array('data' => l(t('edit'), 'admin/content/node-type/'. $type_url_str));
// Set the delete column.
if ($type->custom) {
$row[] = array('data' => l(t('delete'), 'admin/content/types/'. $type_url_str .'/delete'));
$row[] = array('data' => l(t('delete'), 'admin/content/node-type/'. $type_url_str .'/delete'));
}
else {
$row[] = array('data' => '');
......@@ -72,7 +72,7 @@ function node_type_form(&$form_state, $type = NULL) {
'#title' => t('Name'),
'#type' => 'textfield',
'#default_value' => $type->name,
'#description' => t('The human-readable name of this content type. This text will be displayed as part of the list on the <em>create content</em> page. This name must begin with a capital letter and contain only letters, numbers, and <strong>spaces</strong>. This name must be unique.'),
'#description' => t('The human-readable name of this content type. This text will be displayed as part of the list on the <em>create content</em> page. It is recommended that this name begin with a capital letter and contain only letters, numbers, and <strong>spaces</strong>. This name must be unique.'),
'#required' => TRUE,
);
......@@ -233,9 +233,10 @@ function node_type_form_validate($form, &$form_state) {
if (!preg_match('!^[a-z0-9_]+$!', $type->type)) {
form_set_error('type', t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
}
// The type cannot be just the character '0', since elsewhere we check it using empty().
if ($type->type === '0') {
form_set_error('type', t("Invalid type. Please enter a type name other than '0' (the character zero)."));
// 'theme' conflicts with theme_node_form().
// '0' is invalid, since elsewhere we check it using empty().
if (in_array($type->type, array('0', 'theme'))) {
form_set_error('type', t("Invalid machine-readable name. Please enter a name other than %invalid.", array('%invalid' => $type->type)));
}
}
......@@ -279,7 +280,7 @@ function node_type_form_submit($form, &$form_state) {
node_type_reset($type);
}
elseif ($op == t('Delete content type')) {
$form_state['redirect'] = 'admin/content/types/'. str_replace('_', '-', $type->old_type) .'/delete';
$form_state['redirect'] = 'admin/content/node-type/'. str_replace('_', '-', $type->old_type) .'/delete';
return;
}
......
......@@ -1479,14 +1479,18 @@ function node_menu() {
'description' => $type->description,
'file' => 'node.pages.inc',
);
$items['admin/content/types/'. $type_url_str] = array(
$items['admin/content/node-type/'. $type_url_str] = array(
'title' => $type->name,
'page callback' => 'drupal_get_form',
'page arguments' => array('node_type_form', $type),
'file' => 'content_types.inc',
'type' => MENU_CALLBACK,
);
$items['admin/content/types/'. $type_url_str .'/delete'] = array(
$items['admin/content/node-type/'. $type_url_str .'/edit'] = array(
'title' => 'Edit',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/content/node-type/'. $type_url_str .'/delete'] = array(
'title' => 'Delete',
'page arguments' => array('node_type_delete_confirm', $type),
'file' => 'content_types.inc',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment