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