~ubuntu-branches/ubuntu/jaunty/drupal5/jaunty-updates

« back to all changes in this revision

Viewing changes to modules/help/help.module

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2007-03-10 20:04:24 UTC
  • Revision ID: james.westby@ubuntu.com-20070310200424-w6v3crmyowlx2zsq
Tags: upstream-5.1
ImportĀ upstreamĀ versionĀ 5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
// $Id: help.module,v 1.69 2006/12/23 22:06:05 dries Exp $
 
3
 
 
4
/**
 
5
 * @file
 
6
 * Manages displaying online help.
 
7
 */
 
8
 
 
9
/**
 
10
 * Implementation of hook_menu().
 
11
 */
 
12
function help_menu($may_cache) {
 
13
  $items = array();
 
14
 
 
15
  if ($may_cache) {
 
16
    $admin_access = user_access('access administration pages');
 
17
 
 
18
    $items[] = array('path' => 'admin/help', 'title' => t('Help'),
 
19
      'callback' => 'help_main',
 
20
      'access' => $admin_access,
 
21
      'weight' => 9);
 
22
 
 
23
    foreach (module_implements('help', TRUE) as $module) {
 
24
      $items[] = array('path' => 'admin/help/' . $module,
 
25
        'title' => t($module),
 
26
        'callback' => 'help_page',
 
27
        'type' => MENU_CALLBACK,
 
28
        'access' => $admin_access);
 
29
    }
 
30
  }
 
31
 
 
32
  return $items;
 
33
}
 
34
 
 
35
/**
 
36
 * Menu callback; prints a page listing a glossary of Drupal terminology.
 
37
 */
 
38
function help_main() {
 
39
  // Add CSS
 
40
  drupal_add_css(drupal_get_path('module', 'help') .'/help.css', 'module', 'all', FALSE);
 
41
 
 
42
  $output = t('
 
43
  <h2>Help topics</h2>
 
44
  <p>Help is available on the following items:</p>
 
45
  !help_pages
 
46
  <h2>Glossary of Drupal terminology</h2>
 
47
  <dl>
 
48
   <dt>Block</dt><dd>A small box containing information or content placed in a region of a web page (e.g. in a sidebar, below or above the content, or in any other region the current theme allows).</dd>
 
49
   <dt>Comment</dt><dd>Text attached to a post intended to clarify, explain, criticize, or express an opinion on the original post.</dd>
 
50
   <dt>Node</dt><dd>The basic unit of content in Drupal, often referred to as a "post". All content that can be created using the "create content" menu is a node. Keep in mind that comments, blocks, and users are <em>not</em> nodes.</dd>
 
51
   <dt>Published</dt><dd>A post that is viewable by every visitor of the site, regardless of whether he is logged in (see also "Unpublished").</dd>
 
52
   <dt>Role</dt><dd>A classification users are placed into for the purpose of setting users\' permissions. A user receives the combined permissions of all roles to which he or she is subscribed.</dd>
 
53
   <dt>Taxonomy</dt><dd>A categorization system that allows the building of complex hierarchial or relational structures and tagging of content (see <a href="@taxonomy">taxonomy help</a>).</dd>
 
54
   <dt>Unpublished</dt><dd>A post that is only viewable by administrators and moderators.</dd>
 
55
   <dt>User</dt><dd>A person who has an account at your Drupal site, and is currently logged in with that account.</dd>
 
56
   <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 <em>not</em> currently logged in with that account. A visitor is also called an "anonymous user".</dd>
 
57
  </dl>', array('!help_pages' => help_links_as_list(), '@taxonomy' => url('admin/help/taxonomy')));
 
58
 
 
59
  return $output;
 
60
}
 
61
 
 
62
function help_links_as_list() {
 
63
  $module_info = module_rebuild_cache();
 
64
 
 
65
  $modules = array();
 
66
  foreach (module_implements('help', TRUE) as $module) {
 
67
    if (module_invoke($module, 'help', "admin/help#$module")) {
 
68
      $modules[] = $module;
 
69
    }
 
70
  }
 
71
  sort($modules);
 
72
 
 
73
  // Output pretty four-column list
 
74
  $break = ceil(count($modules) / 4);
 
75
  $output = '<div class="clear-block"><div class="help-items"><ul>';
 
76
  foreach ($modules as $i => $module) {
 
77
    $output .= '<li>'. l($module_info[$module]->info['name'], 'admin/help/'. $module) .'</li>';
 
78
    if (($i + 1) % $break == 0) {
 
79
      $output .= '</ul></div><div class="help-items'. ($i + 1 == $break * 3 ? ' help-items-last' : '') .'"><ul>';
 
80
    }
 
81
  }
 
82
  $output .= '</ul></div></div>';
 
83
 
 
84
  return $output;
 
85
}
 
86
 
 
87
/**
 
88
 * Implementation of hook_help().
 
89
 */
 
90
function help_help($section) {
 
91
  switch ($section) {
 
92
    case 'admin/help':
 
93
      $output = t('<p>This guide explains what the various modules in <a href="@Drupal">Drupal</a> do and how to configure them. Additionally, you will find a glossary of basic Drupal terminology to help get you started.</p>
 
94
<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>
 
95
', array('@Drupal' => 'http://drupal.org', '@handbook' => 'http://drupal.org/handbook'));
 
96
      return $output;
 
97
    case 'admin/help#help':
 
98
      $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>';
 
99
      $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>
 
100
<ul>
 
101
<li>The module's help text, displayed on the <a href=\"@help\">help page</a> and through the module's individual help link.</li>
 
102
<li>More elaborate help text on sites a module defines.</li>
 
103
<li>The help for a distributed authorization module (if applicable).</li>
 
104
</ul>
 
105
", array('@help' => url('admin/help')));
 
106
      $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>';
 
107
      return $output;
 
108
  }
 
109
}
 
110
 
 
111
/**
 
112
 * Menu callback; prints a page listing general help for all modules.
 
113
 */
 
114
function help_page() {
 
115
  $name = arg(2);
 
116
  $output = '';
 
117
  if (module_hook($name, 'help')) {
 
118
    $module = _module_parse_info_file(drupal_get_path('module', $name).'/'. $name .'.info');
 
119
    drupal_set_title($module['name']);
 
120
 
 
121
    $temp = module_invoke($name, 'help', "admin/help#$name");
 
122
    if (empty($temp)) {
 
123
      $output .= t("No help is available for module %module.", array('%module' => $module['name']));
 
124
    }
 
125
    else {
 
126
      $output .= $temp;
 
127
    }
 
128
 
 
129
    $admin_tasks = system_get_module_admin_tasks($name);
 
130
    ksort($admin_tasks);
 
131
    $output .= theme('item_list', $admin_tasks, t('@module administration pages', array('@module' => $module['name'])));
 
132
  }
 
133
  return $output;
 
134
}