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-6.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', 'module', 'all', FALSE);
  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. function help_page($name) {
  19. $output = '';
  20. if (module_hook($name, 'help')) {
  21. $module = drupal_parse_info_file(drupal_get_path('module', $name) .'/'. $name .'.info');
  22. drupal_set_title($module['name']);
  23. $temp = module_invoke($name, 'help', "admin/help#$name", drupal_help_arg());
  24. if (empty($temp)) {
  25. $output .= t("No help is available for module %module.", array('%module' => $module['name']));
  26. }
  27. else {
  28. $output .= $temp;
  29. }
  30. // Only print list of administration pages if the module in question has
  31. // any such pages associated to it.
  32. $admin_tasks = system_get_module_admin_tasks($name);
  33. if (!empty($admin_tasks)) {
  34. ksort($admin_tasks);
  35. $output .= theme('item_list', $admin_tasks, t('@module administration pages', array('@module' => $module['name'])));
  36. }
  37. }
  38. return $output;
  39. }
  40. function help_links_as_list() {
  41. $empty_arg = drupal_help_arg();
  42. $module_info = module_rebuild_cache();
  43. $modules = array();
  44. foreach (module_implements('help', TRUE) as $module) {
  45. if (module_invoke($module, 'help', "admin/help#$module", $empty_arg)) {
  46. $modules[$module] = $module_info[$module]->info['name'];
  47. }
  48. }
  49. asort($modules);
  50. // Output pretty four-column list
  51. $count = count($modules);
  52. $break = ceil($count / 4);
  53. $output = '<div class="clear-block"><div class="help-items"><ul>';
  54. $i = 0;
  55. foreach ($modules as $module => $name) {
  56. $output .= '<li>'. l($name, 'admin/help/'. $module) .'</li>';
  57. if (($i + 1) % $break == 0 && ($i + 1) != $count) {
  58. $output .= '</ul></div><div class="help-items'. ($i + 1 == $break * 3 ? ' help-items-last' : '') .'"><ul>';
  59. }
  60. $i++;
  61. }
  62. $output .= '</ul></div></div>';
  63. return $output;
  64. }