summaryrefslogtreecommitdiff
path: root/modules/help.module
blob: 4f52411a68843c6efdcd41c0660ec1cf88d82ae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
// $Id$

/**
 * @file
 * Manages displaying online help.
 */

/**
 * Implementation of hook_menu().
 */
function help_menu($may_cache) {
  $items = array();

  if ($may_cache) {
    $admin_access = user_access('access administration pages');

    $items[] = array('path' => 'admin/help', 'title' => t('help'),
      'callback' => 'help_main',
      'access' => $admin_access,
      'weight' => 9);

    foreach (module_implements('help', TRUE) as $module) {
      $items[] = array('path' => 'admin/help/' . $module,
        'title' => t($module),
        'callback' => 'help_page',
        'type' => MENU_CALLBACK,
        'access' => $admin_access);
    }
  }

  return $items;
}

/**
 * Menu callback; prints a page listing a glossary of Drupal terminology.
 */
function help_main() {
  $output = t("
  <h2>Help topics</h2>
  <p>Help is available on the following items:</p>
  %help_pages
  <h2>Glossary of Drupal terminology</h2>
  <dl>
   <dt>Block</dt><dd>A small box containing information or content placed in the left-hand or right-hand sidebar of a web page.</dd>
   <dt>Comment</dt><dd>A note attached to a node. Usually intended to clarify, explain, criticize, or express an opinion on the original material.</dd>
   <dt>Moderation</dt>
   <dd>The activity of making sure a post to a Drupal site fits in with what is expected for that Drupal site.
    <dl>
     <dt>Approved</dt><dd>A moderated post which has been accepted by the moderators for publication. (See published).</dd>
     <dt>Waiting</dt><dd>A moderated post which is still being voted on to be accepted for publication. (See published.)</dd>
    </dl>
   </dd>
   <dt>Node</dt><dd>The basic data unit in Drupal. Everything is a node or an extension of a node.</dd>
   <dt>Public</dt><dd>See published.</dd>
   <dt>Published</dt><dd>A node that is viewable by everyone. (See unpublished.)</dd>
   <dt>Role</dt><dd>A classification users are placed into for the purpose of setting users' permissions.</dd>
   <dt>Taxonomy</dt><dd>A division of a collection of things into ordered, classified groups. (See <a href=\"%taxonomy\">taxonomy help</a>.)</dd>
   <dt>Unpublished</dt><dd>A node that is only viewable by administrators and moderators.</dd>
   <dt>User</dt><dd>A person who has an account at your Drupal site, and is logged in with that account.</dd>
   <dt>Visitor</dt><dd>A person who does not have an account at your Drupal site or a person who has an account at your Drupal site but is <strong>not</strong> logged in with that account. Also termed \"anonymous user\".</dd>
  </dl>", array('%help_pages' => help_links_as_list(), '%taxonomy' => url('admin/help/taxonomy')));

  return $output;
}

function help_links_as_list() {
  $modules = array();
  foreach (module_implements('help', TRUE) as $module) {
    if (module_invoke($module, 'help', "admin/help#$module")) {
      $modules[] = $module;
    }
  }
  sort($modules);

  // Output pretty four-column list
  $break = ceil(count($modules) / 4);
  $output = '<div class="help-items"><ul>';
  foreach ($modules as $i => $module) {
    $output .= '<li>'. l(t($module), 'admin/help/'. $module) .'</li>';
    if (($i + 1) % $break == 0) {
      $output .= '</ul></div><div class="help-items'. ($i + 1 == $break * 3 ? ' help-items-last' : '') .'"><ul>';
    }
  }
  $output .= '</ul></div><br class="clear" />';

  return $output;
}

/**
 * Implementation of hook_help().
 */
function help_help($section) {
  switch ($section) {
    case 'admin/help':
      $output = t('<p>This guide explains what the various modules in <a href="%Drupal">Drupal</a> do and how to configure them.</p>
<p>It is not a substitute for the <a href="%handbook">Drupal handbook</a> available online and should be used in conjunction with it. The online reference handbook might be more up-to-date and has helpful user-contributed comments. It is your definitive reference point for all Drupal documentation.</p>
', array('%Drupal' => 'http://drupal.org', '%handbook' => 'http://drupal.org/handbook'));
      return $output;
    case 'admin/help#help':
      $output = '<p>'. t('The help module displays context sensitive help information. Users can learn how to use modules and accomplish tasks quicker with less errors by clicking on links in provided by the help module.') .'</p>';
      $output .= t('<p>Modules can make documentation available to other modules with this module. All user help should be presented using this module.  Some examples of help: </p>
<ul>
<li>The name of a module (unused, but there).</li>
<li>The description found on the admin/system/modules page.</li>
<li>The module\'s help text, displayed on the admin/help page and through the module\'s individual help link.</li>
<li>The help for a distributed authorization module (if applicable).</li>
<li>The description of a post type (if applicable).</li>
</ul>
');
      $output .= '<p>'. t('You can not administer the help system.') .'</p>';
      $output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="%help">Help page</a>.', array('%help' => 'http://drupal.org/handbook/modules/help/')) .'</p>';
      return $output;
    case 'admin/modules#description':
      return t('Manages the display of online help.');
  }
}

/**
 * Menu callback; prints a page listing general help for all modules.
 */
function help_page() {
  $name = arg(2);
  $output = '';
  if (module_hook($name, 'help')) {
    $temp = module_invoke($name, 'help', "admin/help#$name");
    if (empty($temp)) {
      $output .= t("No help is available for module %module.", array('%module' => $name));
    }
    else {
      $output .= $temp;
    }
  }
  return $output;
}