' . t('This guide provides context sensitive help on the use and configuration of Drupal and its modules, and is a supplement to the more extensive online Drupal handbook. The online handbook may contain more up-to-date information, is annotated with helpful user-contributed comments, and serves as the definitive reference point for all Drupal documentation.', array('@drupal' => 'http://drupal.org', '@handbook' => 'http://drupal.org/handbook')) . '
' . t('The help module provides context sensitive help on the use and configuration of Drupal and its modules, and is a supplement to the more extensive online Drupal handbook. The online handbook may contain more up-to-date information, is annotated with helpful user-contributed comments, and serves as the definitive reference point for all Drupal documentation.', array('@drupal' => 'http://drupal.org', '@handbook' => 'http://drupal.org/handbook')) . '
';
- $output .= '
' . t('For more information, see the online handbook entry for Help module.', array('@help' => 'http://drupal.org/handbook/modules/help/')) . '
';
- return $output;
+ return '
' . t('This guide provides context sensitive help on the use and configuration of Drupal and its modules, and is a supplement to the more extensive online Drupal handbook. The online handbook may contain more up-to-date information, is annotated with helpful user-contributed comments, and serves as the definitive reference point for all Drupal documentation.', array('@drupal' => 'http://drupal.org', '@handbook' => 'http://drupal.org/handbook')) . '
';
}
}
+
+/**
+ * Return code that emits a link to view a topic in a popup.
+ *
+ * @param $module
+ * The module that owns this help topic.
+ * @param $topic
+ * Optional identifier for the topic. NULL value displays all available topics.
+ * @param $title
+ * Optional title or label for the link. Default is "More help".
+ * @param $popup
+ * Optional boolean value to open the link in a popup.
+ * @param $attributes
+ * An array of attributes to include in hyperlink.
+ */
+function theme_help_link($module, $topic = NULL, $title = NULL, $popup = TRUE, $attributes = array()) {
+ static $js_added = FALSE;
+
+ if (!isset($title)) {
+ $title = t('More help');
+ }
+
+ if ($popup) {
+ // Set class for links to be opened in popup.
+ $popup_class = !empty($attributes['class']) ? $attributes['class'] . ' help-link-popup' : 'help-link-popup';
+ $attributes += array('class' => $popup_class);
+ }
+
+ // Check for the function existence and include help.admin.inc.
+ drupal_function_exists('help_get_topic_info');
+ // Fetch the information on the module/topic.
+ $info = help_get_topic_info($module, $topic);
+
+ if (isset($topic) && !$info) {
+ // Return if the explicitly specified topic doesn't exist.
+ return;
+ }
+
+ // Set the topic title as the hyperlink's title attribute.
+ $attributes += array('title' => $info['title']);
+
+ if (!$js_added) {
+ // Include JavaScript for opening topics in a popup for hyperlinks with the class 'help-link-popup'.
+ drupal_add_js('modules/help/help.js');
+ $js_added = TRUE;
+ }
+
+ // Trim the trailing slash if no topic is specified.
+ $output = l($title, trim("admin/help/$module/$topic", '/'), array('attributes' => $attributes));
+
+ return '
' . $output . '
';
+}
Index: modules/help/help.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/help/help.test,v
retrieving revision 1.4
diff -u -p -r1.4 help.test
--- modules/help/help.test 11 Dec 2008 20:35:37 -0000 1.4
+++ modules/help/help.test 20 Feb 2009 23:53:28 -0000
@@ -8,77 +8,46 @@ class HelpTestCase extends DrupalWebTest
function getInfo() {
return array(
'name' => t('Help functionality'),
- 'description' => t('Verify help display and user access to help based on persmissions.'),
+ 'description' => t('Verify help display and user access to help based on permissions.'),
'group' => t('Help'),
);
}
/**
- * Enable modules and create users with specific permissions.
- */
- function setUp() {
- parent::setUp();
-
- // Loading these (and other?) modules will result in failures?
-// $this->drupalModuleEnable('blog');
-// $this->drupalModuleEnable('poll');
- $this->getModuleList();
-
- // Create users.
- $this->big_user = $this->drupalCreateUser(array('access administration pages')); // 'administer blocks', 'administer site configuration',
- $this->any_user = $this->drupalCreateUser(array());
- }
-
- /**
* Login users, create dblog events, and test dblog functionality through the admin and user interfaces.
*/
function testHelp() {
// Login the admin user.
- $this->drupalLogin($this->big_user);
- $this->verifyHelp();
-
- // Login the regular user.
- $this->drupalLogin($this->any_user);
- $this->verifyHelp(403);
- }
-
- /**
- * Verify the logged in user has the desired access to the various help nodes and the nodes display help.
- *
- * @param integer $response HTTP response code.
- */
- private function verifyHelp($response = 200) {
- $crumb = '›';
-
- foreach ($this->modules as $module => $name) {
- // View module help node.
- $this->drupalGet('admin/help/' . $module);
- $this->assertResponse($response);
- if ($response == 200) {
- // NOTE: The asserts fail on blog and poll because the get returns the 'admin/help' node instead of the indicated node???
-// if ($module == 'blog' || $module == 'poll') {
-// continue;
-// }
- $this->assertTitle($name . ' | Drupal', t('[' . $module . '] Title was displayed'));
- $this->assertRaw('
' . t($name) . '
', t('[' . $module . '] Heading was displayed'));
- $this->assertText(t('Home ' . $crumb . ' Administer ' . $crumb . ' Help'), t('[' . $module . '] Breadcrumbs were displayed'));
- }
+ $account = $this->drupalCreateUser(array('access administration pages', 'access help', 'administer blocks'));
+ $this->drupalLogin($account);
+ $sections = parse_ini_file('modules/help/help/help.help', TRUE);
+ foreach ($sections as $section => $data) {
+ $links[url("admin/help/help/$section")] = $data['title'];
}
- }
-
- /**
- * Get list of enabled modules.
- *
- * @return array Enabled modules.
- */
- private function getModuleList() {
- $this->modules = array();
- $result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
- while ($module = db_fetch_object($result)) {
- if (file_exists($module->filename)) {
- $fullname = unserialize($module->info);
- $this->modules[$module->name] = $fullname['name'];
+ foreach ($sections as $section => $data) {
+ $this->drupalGet("admin/help/help/$section");
+ $this->assertTitle($data['title'] .' | Drupal', t('title matched'));
+ $help = file_get_contents("modules/help/help/$section.html");
+ if (!empty($data['line break'])) {
+ $help = preg_replace('/^\n/', '', $help);
+ $help = _filter_autop($help);
+ }
+ // There are various replaces done on the help text. We do not test
+ // these now, but skip text inside [].
+ $help_pieces = preg_split('/\[[^\]]+\]/', $help);
+ foreach ($help_pieces as $piece) {
+ $this->assertRaw($piece, t('help text found'));
+ }
+ // Check the links in the table of contents.
+ foreach ($links as $href => $title) {
+ $this->assertTrue($this->xpath('//a[text()="'. $title .'" and @href="'. $href .'"]'), t('Link @href, @title found', array('@href' => $href, '@title' => $title)));
}
}
+ $this->drupalGet('admin/build/block');
+ $this->clickLink('More help');
+ $this->assertLink('About Block', 0, t('About Block link found'));
+ $this->drupalGet('admin/help/block', array('query' => 'popup'));
+ $this->assertRaw('modules/help/help-popup.css', t('Popup displayed'));
+ $this->assertLink('About Block', 0, t('About Block link found'));
}
}
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.127
diff -u -p -r1.127 system.admin.inc
--- modules/system/system.admin.inc 18 Feb 2009 15:19:56 -0000 1.127
+++ modules/system/system.admin.inc 20 Feb 2009 23:53:29 -0000
@@ -85,10 +85,8 @@ function system_admin_menu_block_page()
* Menu callback; prints a listing of admin tasks for each installed module.
*/
function system_admin_by_module() {
-
$modules = module_rebuild_cache();
$menu_items = array();
- $help_arg = module_exists('help') ? drupal_help_arg() : FALSE;
foreach ($modules as $file) {
$module = $file->name;
@@ -101,8 +99,8 @@ function system_admin_by_module() {
// Only display a section if there are any available tasks.
if (count($admin_tasks)) {
- // Check for help links.
- if ($help_arg && module_invoke($module, 'help', "admin/help#$module", $help_arg)) {
+ // Check for help topics.
+ if (help_exists($module)) {
$admin_tasks[100] = l(t('Get help'), "admin/help/$module");
}
@@ -598,9 +596,6 @@ function system_modules($form_state = ar
$modules = array();
$form['modules'] = array('#tree' => TRUE);
- // Used when checking if module implements a help page.
- $help_arg = module_exists('help') ? drupal_help_arg() : FALSE;
-
// Iterate through each of the modules.
foreach ($files as $filename => $module) {
$extra = array();
@@ -618,12 +613,10 @@ function system_modules($form_state = ar
$extra['requires'][$requires] = t('@module (enabled)', array('@module' => $files[$requires]->info['name']));
}
}
- // Generate link for module's help page, if there is one.
- if ($help_arg && $module->status && in_array($filename, module_implements('help'))) {
- if (module_invoke($filename, 'help', "admin/help#$filename", $help_arg)) {
- // Module has a help page.
- $extra['help'] = theme('more_help_link', url("admin/help/$filename"));
- }
+ // Generate link for module's help topics, if there are any .
+ if (help_exists($filename)) {
+ // Module has help topics.
+ $extra['help'] = theme('help_link', $filename, NULL, t('Get help'));
}
// Mark dependents disabled so the user cannot remove required modules.
$dependents = array();
@@ -744,7 +737,7 @@ function _system_modules_build_row($info
$form['description']['#markup'] .= theme('system_modules_incompatible', $status_long);
}
- // Show a "more help" link for modules that have them.
+ // Show a help link for modules that have them.
if ($extra['help']) {
$form['help'] = array(
'#markup' => $extra['help'],