help.admin.inc

  1. 7.x drupal-7.x/modules/help/help.admin.inc
  2. 6.x drupal-6.x/modules/help/help.admin.inc

Admin page callbacks for the help module.

File

drupal-7.x/modules/help/help.admin.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Admin page callbacks for the help module.
  5. */
  6. /**
  7. * Menu callback; prints a page listing a glossary of Drupal terminology.
  8. */
  9. function help_main() {
  10. // Add CSS
  11. drupal_add_css(drupal_get_path('module', 'help') . '/help.css');
  12. $output = '<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>' . help_links_as_list();
  13. return $output;
  14. }
  15. /**
  16. * Menu callback; prints a page listing general help for a module.
  17. *
  18. * @param $name
  19. * A module name to display a help page for.
  20. */
  21. function help_page($name) {
  22. $output = '';
  23. if (module_hook($name, 'help')) {
  24. $info = system_get_info('module');
  25. drupal_set_title($info[$name]['name']);
  26. $temp = module_invoke($name, 'help', "admin/help#$name", drupal_help_arg());
  27. if (empty($temp)) {
  28. $output .= t("No help is available for module %module.", array('%module' => $info[$name]['name']));
  29. }
  30. else {
  31. $output .= $temp;
  32. }
  33. // Only print list of administration pages if the module in question has
  34. // any such pages associated to it.
  35. $admin_tasks = system_get_module_admin_tasks($name, $info[$name]);
  36. if (!empty($admin_tasks)) {
  37. $links = array();
  38. foreach ($admin_tasks as $task) {
  39. $links[] = l($task['title'], $task['link_path'], $task['localized_options']);
  40. }
  41. $output .= theme('item_list', array('items' => $links, 'title' => t('@module administration pages', array('@module' => $info[$name]['name']))));
  42. }
  43. }
  44. return $output;
  45. }
  46. /**
  47. * Provides a formatted list of available help topics.
  48. *
  49. * @return
  50. * A string containing the formatted list.
  51. */
  52. function help_links_as_list() {
  53. $empty_arg = drupal_help_arg();
  54. $module_info = system_rebuild_module_data();
  55. $modules = array();
  56. foreach (module_implements('help', TRUE) as $module) {
  57. if (module_invoke($module, 'help', "admin/help#$module", $empty_arg)) {
  58. $modules[$module] = $module_info[$module]->info['name'];
  59. }
  60. }
  61. asort($modules);
  62. // Output pretty four-column list.
  63. $count = count($modules);
  64. $break = ceil($count / 4);
  65. $output = '<div class="clearfix"><div class="help-items"><ul>';
  66. $i = 0;
  67. foreach ($modules as $module => $name) {
  68. $output .= '<li>' . l($name, 'admin/help/' . $module) . '</li>';
  69. if (($i + 1) % $break == 0 && ($i + 1) != $count) {
  70. $output .= '</ul></div><div class="help-items' . ($i + 1 == $break * 3 ? ' help-items-last' : '') . '"><ul>';
  71. }
  72. $i++;
  73. }
  74. $output .= '</ul></div></div>';
  75. return $output;
  76. }