Skip to content
Snippets Groups Projects
Commit 823e8a6d authored by Steven Wittens's avatar Steven Wittens
Browse files

#84414: Admin usability improvement! List what each module can do in a common place.

parent 92de1f90
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -32,6 +32,8 @@ function system_help($section) { ...@@ -32,6 +32,8 @@ function system_help($section) {
return $output; return $output;
case 'admin': case 'admin':
return t('<p>Welcome to the administration section. Here you may control how your site functions.</p>'); return t('<p>Welcome to the administration section. Here you may control how your site functions.</p>');
case 'admin/by-module':
return t('<p>This page shows you all available administration tasks for each module.</p>');
case 'admin/settings/page-caching': case 'admin/settings/page-caching':
return t('Enabling the cache will offer a sufficient performance boost. Drupal can store and send compressed cached pages requested by "anonymous" users. By caching a web page, Drupal does not have to create the page each time someone wants to view it.'); return t('Enabling the cache will offer a sufficient performance boost. Drupal can store and send compressed cached pages requested by "anonymous" users. By caching a web page, Drupal does not have to create the page each time someone wants to view it.');
case 'admin/build/themes': case 'admin/build/themes':
...@@ -42,10 +44,10 @@ function system_help($section) { ...@@ -42,10 +44,10 @@ function system_help($section) {
$reference = explode('.', arg(3), 2); $reference = explode('.', arg(3), 2);
$theme = array_pop($reference); $theme = array_pop($reference);
return t('<p>These options control the display settings for the <code>%template</code> theme. When your site is displayed using this theme, these settings will be used. By clicking "Reset to defaults," you can choose to use the <a href="@global">global settings</a> for this theme.</p>', array('%template' => $theme, '@global' => url('admin/build/themes/settings'))); return t('<p>These options control the display settings for the <code>%template</code> theme. When your site is displayed using this theme, these settings will be used. By clicking "Reset to defaults," you can choose to use the <a href="@global">global settings</a> for this theme.</p>', array('%template' => $theme, '@global' => url('admin/build/themes/settings')));
case 'admin/settings/modules': case 'admin/build/modules':
if (empty($_POST) || $_POST['op'] != t('Save configuration')) { if (empty($_POST) || $_POST['op'] != t('Save configuration')) {
return t('<p>Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. Click on the name of the module in the navigation menu for their individual configuration pages. Once a module is enabled, new <a href="@permissions">permissions</a> might be made available. Modules can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by enabling the throttle.module and checking throttle. The auto-throttle functionality must be enabled on the <a href="@throttle">throttle configuration page</a> after having enabled the throttle module.</p> return t('<p>Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. Click on the name of the module in the navigation menu for their individual configuration pages. Once a module is enabled, new <a href="@permissions">permissions</a> might be made available. Modules can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by enabling the throttle.module and checking throttle. The auto-throttle functionality must be enabled on the <a href="@throttle">throttle configuration page</a> after having enabled the throttle module.</p>
<p>It is important that <a href="@update-php">update.php</a> is run every time a module is updated to a newer version.</p>', array('@permissions' => url('admin/user/access'), '@throttle' => url('admin/settings/throttle'), '@update-php' => $base_url .'/update.php')); <p>It is important that <a href="@update-php">update.php</a> is run every time a module is updated to a newer version.</p><p>You can find all administration tasks belonging to a particular module on the <a href="@by-module">administration by module page</a>.', array('@permissions' => url('admin/user/access'), '@throttle' => url('admin/settings/throttle'), '@update-php' => $base_url .'/update.php', '@by-module' => url('admin/by-module')));
} }
break; break;
case 'admin/logs/status': case 'admin/logs/status':
...@@ -114,6 +116,13 @@ function system_menu($may_cache) { ...@@ -114,6 +116,13 @@ function system_menu($may_cache) {
'access' => user_access('access administration pages'), 'access' => user_access('access administration pages'),
'callback' => 'system_admin_compact_page', 'callback' => 'system_admin_compact_page',
'type' => MENU_CALLBACK); 'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/by-task', 'title' => t('by task'),
'callback' => 'system_main_admin_page',
'type' => MENU_DEFAULT_LOCAL_TASK);
$items[] = array('path' => 'admin/by-module', 'title' => t('by module'),
'callback' => 'system_admin_by_module',
'type' => MENU_LOCAL_TASK,
'weight' => 2);
// menu items that are basically just menu blocks // menu items that are basically just menu blocks
$items[] = array( $items[] = array(
...@@ -186,10 +195,9 @@ function system_menu($may_cache) { ...@@ -186,10 +195,9 @@ function system_menu($may_cache) {
} }
// Modules: // Modules:
$items[] = array('path' => 'admin/settings/modules', $items[] = array('path' => 'admin/build/modules',
'title' => t('modules'), 'title' => t('modules'),
'description' => t('Enable or disable add-on modules for your site.'), 'description' => t('Enable or disable add-on modules for your site.'),
'weight' => -10,
'callback' => 'drupal_get_form', 'callback' => 'drupal_get_form',
'callback arguments' => array('system_modules'), 'callback arguments' => array('system_modules'),
'access' => $access); 'access' => $access);
...@@ -330,7 +338,7 @@ function system_main_admin_page($arg = NULL) { ...@@ -330,7 +338,7 @@ function system_main_admin_page($arg = NULL) {
// If we received an argument, they probably meant some other page. // If we received an argument, they probably meant some other page.
// Let's 404 them since the menu system cannot be told we do not // Let's 404 them since the menu system cannot be told we do not
// accept arguments. // accept arguments.
if ($arg !== NULL) { if (isset($arg) && substr($arg, 0, 3) != 'by-') {
return drupal_not_found(); return drupal_not_found();
} }
...@@ -1409,7 +1417,7 @@ function system_modules_confirm_form($modules, $form_values = array()) { ...@@ -1409,7 +1417,7 @@ function system_modules_confirm_form($modules, $form_values = array()) {
$form = confirm_form( $form = confirm_form(
$form, $form,
t('Some required modules must be enabled'), t('Some required modules must be enabled'),
'admin/settings/modules', 'admin/build/modules',
t('Would you like to continue with enabling the above?'), t('Would you like to continue with enabling the above?'),
t('Continue'), t('Continue'),
t('Cancel')); t('Cancel'));
...@@ -1500,7 +1508,7 @@ function system_modules_submit($form_id, $form_values) { ...@@ -1500,7 +1508,7 @@ function system_modules_submit($form_id, $form_values) {
if ($dependencies && !isset($form_values['confirm'])) { if ($dependencies && !isset($form_values['confirm'])) {
return FALSE; return FALSE;
} }
return 'admin/settings/modules'; return 'admin/build/modules';
} }
/** /**
...@@ -2026,3 +2034,86 @@ function theme_admin_block_content($content) { ...@@ -2026,3 +2034,86 @@ function theme_admin_block_content($content) {
} }
return $output; return $output;
} }
/**
* Menu callback; prints a listing of admin tasks for each installed module.
*/
function system_admin_by_module() {
$modules = module_rebuild_cache();
$menu_items = array();
foreach ($modules as $file) {
$module = $file->name;
if ($module == 'help') {
continue;
}
$admin_tasks = array();
// Check for permissions.
if (module_hook($module, 'perm')) {
$admin_tasks[-1] = l(t('configure permissions'), 'admin/user/access');
}
// Check for menu items that are admin links.
if ($items = module_invoke($module, 'menu', TRUE)) {
foreach ($items as $item) {
$parts = explode('/', $item['path']);
$n = count($parts);
if ((!isset($item['type']) || ($item['type'] & MENU_VISIBLE_IN_TREE)) && ($parts[0] == 'admin') && ($n >= 3)) {
$admin_tasks[$item['title']] = l($item['title'], $item['path']);
}
}
}
// Check for help links.
if (module_invoke($module, 'help', "admin/help#$module")) {
$admin_tasks[100] = l(t('get help'), "admin/help/$module");
}
// Sort
ksort($admin_tasks);
$menu_items[$file->info['name']] = array($file->info['description'], $admin_tasks);
}
return theme('system_admin_by_module', $menu_items);
}
/**
* Theme output of the dashboard page.
*/
function theme_system_admin_by_module($menu_items) {
$stripe = 0;
$output = '';
$container = array();
// Iterate over all modules
foreach ($menu_items as $module => $block) {
list($description, $items) = $block;
// Output links
if (count($items)) {
$block = array();
$block['title'] = $module;
$block['content'] = theme('item_list', $items);
$block['description'] = $description;
if ($block_output = theme('admin_block', $block)) {
if (!$block['position']) {
// Perform automatic striping.
$block['position'] = $stripe++ % 2 ? 'left' : 'right';
}
$container[$block['position']] .= $block_output;
}
}
}
$output = '<div class="admin">';
foreach ($container as $id => $data) {
$output .= '<div class="'. $id .' clear-block">';
$output .= $data;
$output .= '</div>';
}
$output .= '</div>';
$output .= '</div>';
return $output;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment