Commit 3123d7e6 authored by Dries's avatar Dries
Browse files

- Patch #18045 by JonBob: the node type admin page uses an unclear callback...

- Patch #18045 by JonBob: the node type admin page uses an unclear callback name, and uses arg() where it is not necessary. The attached patch cleans this up by unifying node_types() with node_types_configure().
parent a4befbb6
...@@ -669,7 +669,7 @@ function node_menu($may_cache) { ...@@ -669,7 +669,7 @@ function node_menu($may_cache) {
$items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'), $items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'admin/node/configure/types', 'title' => t('content types'), $items[] = array('path' => 'admin/node/configure/types', 'title' => t('content types'),
'callback' => 'node_types', 'callback' => 'node_types_configure',
'access' => user_access('administer nodes'), 'access' => user_access('administer nodes'),
'type' => MENU_LOCAL_TASK); 'type' => MENU_LOCAL_TASK);
if (module_exist('search')) { if (module_exist('search')) {
...@@ -717,8 +717,6 @@ function node_menu($may_cache) { ...@@ -717,8 +717,6 @@ function node_menu($may_cache) {
else if (arg(0) == 'admin' && arg(1) == 'node' && arg(2) == 'configure' && arg(3) == 'types' && is_string(arg(4))) { else if (arg(0) == 'admin' && arg(1) == 'node' && arg(2) == 'configure' && arg(3) == 'types' && is_string(arg(4))) {
$items[] = array('path' => 'admin/node/configure/types/'. arg(4), $items[] = array('path' => 'admin/node/configure/types/'. arg(4),
'title' => t("'%name' content type", array('%name' => node_invoke(arg(4), 'node_name'))), 'title' => t("'%name' content type", array('%name' => node_invoke(arg(4), 'node_name'))),
'callback' => 'node_types_configure',
'access' => user_access('administer nodes'),
'type' => MENU_CALLBACK); 'type' => MENU_CALLBACK);
} }
} }
...@@ -942,32 +940,34 @@ function node_admin_nodes() { ...@@ -942,32 +940,34 @@ function node_admin_nodes() {
return form($output, 'post', url('admin/node/action')); return form($output, 'post', url('admin/node/action'));
} }
function node_types() { /**
$header = array(t('Type'), t('Operations')); * Menu callback; presents each node type configuration page.
*/
$rows = array(); function node_types_configure($type = NULL) {
foreach (node_list() as $type) { if (isset($type)) {
$rows[] = array(node_invoke($type, 'node_name'), l(t('configure'), 'admin/node/configure/types/'. $type)); // Go to the listing page when we submit this form, system_settings_save() calls drupal_goto().
} if ($_POST['op']) {
$_GET['q'] = 'admin/node/configure/types';
}
system_settings_save();
print theme('page', theme('table', $header, $rows)); $group = form_textarea(t('Explanation or submission guidelines'), $type .'_help', variable_get($type .'_help', ''), 70, 5, t('This text will be displayed at the top of the %type submission form. It is useful for helping or instructing your users.', array('%type' => node_invoke($type, 'node_name'))));
} $group .= form_select(t('Minimum number of words'), 'minimum_'. $type .'_size', variable_get('minimum_'. $type .'_size', 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t('The minimum number of words a %type must be to be considered valid. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.', array('%type' => node_invoke($type, 'node_name'))));
$output = form_group(t('Submission form'), $group);
$output .= form_group(t('Workflow'), implode('', node_invoke_nodeapi($type, 'settings')));
function node_types_configure() { print theme('page', system_settings_form($output));
// Go to the listing page when we submit this form, system_settings_save() calls drupal_goto().
if ($_POST['op']) {
$_GET['q'] = 'admin/node/configure/types';
} }
system_settings_save(); else {
$header = array(t('Type'), t('Operations'));
$type = arg(4);
$group = form_textarea(t('Explanation or submission guidelines'), $type .'_help', variable_get($type .'_help', ''), 70, 5, t('This text will be displayed at the top of the %type submission form. It is useful for helping or instructing your users.', array('%type' => node_invoke($type, 'node_name')))); $rows = array();
$group .= form_select(t('Minimum number of words'), 'minimum_'. $type .'_size', variable_get('minimum_'. $type .'_size', 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t('The minimum number of words a %type must be to be considered valid. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.', array('%type' => node_invoke($type, 'node_name')))); foreach (node_list() as $type) {
$output = form_group(t('Submission form'), $group); $rows[] = array(node_invoke($type, 'node_name'), l(t('configure'), 'admin/node/configure/types/'. $type));
$output .= form_group(t('Workflow'), implode('', node_invoke_nodeapi($type, 'settings'))); }
print theme('page', system_settings_form($output)); print theme('page', theme('table', $header, $rows));
}
} }
/** /**
......
...@@ -669,7 +669,7 @@ function node_menu($may_cache) { ...@@ -669,7 +669,7 @@ function node_menu($may_cache) {
$items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'), $items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'admin/node/configure/types', 'title' => t('content types'), $items[] = array('path' => 'admin/node/configure/types', 'title' => t('content types'),
'callback' => 'node_types', 'callback' => 'node_types_configure',
'access' => user_access('administer nodes'), 'access' => user_access('administer nodes'),
'type' => MENU_LOCAL_TASK); 'type' => MENU_LOCAL_TASK);
if (module_exist('search')) { if (module_exist('search')) {
...@@ -717,8 +717,6 @@ function node_menu($may_cache) { ...@@ -717,8 +717,6 @@ function node_menu($may_cache) {
else if (arg(0) == 'admin' && arg(1) == 'node' && arg(2) == 'configure' && arg(3) == 'types' && is_string(arg(4))) { else if (arg(0) == 'admin' && arg(1) == 'node' && arg(2) == 'configure' && arg(3) == 'types' && is_string(arg(4))) {
$items[] = array('path' => 'admin/node/configure/types/'. arg(4), $items[] = array('path' => 'admin/node/configure/types/'. arg(4),
'title' => t("'%name' content type", array('%name' => node_invoke(arg(4), 'node_name'))), 'title' => t("'%name' content type", array('%name' => node_invoke(arg(4), 'node_name'))),
'callback' => 'node_types_configure',
'access' => user_access('administer nodes'),
'type' => MENU_CALLBACK); 'type' => MENU_CALLBACK);
} }
} }
...@@ -942,32 +940,34 @@ function node_admin_nodes() { ...@@ -942,32 +940,34 @@ function node_admin_nodes() {
return form($output, 'post', url('admin/node/action')); return form($output, 'post', url('admin/node/action'));
} }
function node_types() { /**
$header = array(t('Type'), t('Operations')); * Menu callback; presents each node type configuration page.
*/
$rows = array(); function node_types_configure($type = NULL) {
foreach (node_list() as $type) { if (isset($type)) {
$rows[] = array(node_invoke($type, 'node_name'), l(t('configure'), 'admin/node/configure/types/'. $type)); // Go to the listing page when we submit this form, system_settings_save() calls drupal_goto().
} if ($_POST['op']) {
$_GET['q'] = 'admin/node/configure/types';
}
system_settings_save();
print theme('page', theme('table', $header, $rows)); $group = form_textarea(t('Explanation or submission guidelines'), $type .'_help', variable_get($type .'_help', ''), 70, 5, t('This text will be displayed at the top of the %type submission form. It is useful for helping or instructing your users.', array('%type' => node_invoke($type, 'node_name'))));
} $group .= form_select(t('Minimum number of words'), 'minimum_'. $type .'_size', variable_get('minimum_'. $type .'_size', 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t('The minimum number of words a %type must be to be considered valid. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.', array('%type' => node_invoke($type, 'node_name'))));
$output = form_group(t('Submission form'), $group);
$output .= form_group(t('Workflow'), implode('', node_invoke_nodeapi($type, 'settings')));
function node_types_configure() { print theme('page', system_settings_form($output));
// Go to the listing page when we submit this form, system_settings_save() calls drupal_goto().
if ($_POST['op']) {
$_GET['q'] = 'admin/node/configure/types';
} }
system_settings_save(); else {
$header = array(t('Type'), t('Operations'));
$type = arg(4);
$group = form_textarea(t('Explanation or submission guidelines'), $type .'_help', variable_get($type .'_help', ''), 70, 5, t('This text will be displayed at the top of the %type submission form. It is useful for helping or instructing your users.', array('%type' => node_invoke($type, 'node_name')))); $rows = array();
$group .= form_select(t('Minimum number of words'), 'minimum_'. $type .'_size', variable_get('minimum_'. $type .'_size', 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t('The minimum number of words a %type must be to be considered valid. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.', array('%type' => node_invoke($type, 'node_name')))); foreach (node_list() as $type) {
$output = form_group(t('Submission form'), $group); $rows[] = array(node_invoke($type, 'node_name'), l(t('configure'), 'admin/node/configure/types/'. $type));
$output .= form_group(t('Workflow'), implode('', node_invoke_nodeapi($type, 'settings'))); }
print theme('page', system_settings_form($output)); print theme('page', theme('table', $header, $rows));
}
} }
/** /**
......
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