' . 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 23 Jan 2009 23:38:08 -0000
@@ -8,7 +8,7 @@ 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'),
);
}
@@ -19,13 +19,10 @@ class HelpTestCase extends DrupalWebTest
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->big_user = $this->drupalCreateUser(array('access administration pages', 'access help')); // 'administer blocks', 'administer site configuration',
$this->any_user = $this->drupalCreateUser(array());
}
@@ -35,15 +32,38 @@ class HelpTestCase extends DrupalWebTest
function testHelp() {
// Login the admin user.
$this->drupalLogin($this->big_user);
+ $this->verifyHelpPopup();
$this->verifyHelp();
// Login the regular user.
$this->drupalLogin($this->any_user);
+ $this->verifyHelpPopup(403);
$this->verifyHelp(403);
}
/**
- * Verify the logged in user has the desired access to the various help nodes and the nodes display help.
+ * Verify the logged in user has the desired access to the help popup and the popup displays help.
+ *
+ * @param integer $response HTTP response code.
+ */
+ private function verifyHelpPopup($response = 200) {
+ $crumb = '›';
+
+ foreach ($this->modules as $module => $name) {
+ // View module help node.
+ $this->drupalGet('admin/help/' . $module, array('query' => array('popup' => TRUE)));
+ $this->assertResponse($response);
+ if ($response == 200) {
+ drupal_set_message('
' . print_r($this, true) . '
');
+ $this->assertTitle('About ' . $name, t('[' . $module . '] Popup title was displayed'));
+ $this->assertRaw('
About ' . t($name) . '
', t('[' . $module . '] Popup heading was displayed'));
+ $this->assertText(t('Help ' . $crumb . ' ' . $name), t('[' . $module . '] Popup breadcrumbs were displayed'));
+ }
+ }
+ }
+
+ /**
+ * Verify the logged in user has the desired access to the various help pages and the pages display help.
*
* @param integer $response HTTP response code.
*/
@@ -55,13 +75,9 @@ class HelpTestCase extends DrupalWebTest
$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'));
+ $this->assertTitle('About ' . $name . ' | Drupal', t('[' . $module . '] Title was displayed'));
+ $this->assertRaw('
About ' . t($name) . '
', t('[' . $module . '] Heading was displayed'));
+ $this->assertText(t('Home ' . $crumb . ' Administer ' . $crumb . ' Help ' . $crumb . ' ' . $name), t('[' . $module . '] Breadcrumbs were displayed'));
}
}
}
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.122
diff -u -p -r1.122 system.admin.inc
--- modules/system/system.admin.inc 22 Jan 2009 12:46:07 -0000 1.122
+++ modules/system/system.admin.inc 23 Jan 2009 23:38:08 -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'],