diff --git a/core/modules/help/help.css b/core/modules/help/help.css index 5d074c8..77d828f 100644 --- a/core/modules/help/help.css +++ b/core/modules/help/help.css @@ -2,10 +2,6 @@ .help-items { float: left; /* LTR */ width: 22%; - margin-right: 3%; /* LTR */ -} -.help-items-last { - margin-right: 0; /* LTR */ } /** diff --git a/core/modules/help/help.module b/core/modules/help/help.module index be57134..f1ecaed 100644 --- a/core/modules/help/help.module +++ b/core/modules/help/help.module @@ -73,3 +73,35 @@ function help_preprocess_block(&$variables) { $variables['attributes']['role'] = 'complementary'; } } + +/** + * Implements hook_theme(). + */ +function help_theme() { + return array( + 'help_list' => array( + 'variables' => array('links' => array()), + ), + ); +} + +/** + * Returns HTML for a list of help items. + * + * @param $variables + * An associative array containing: + * - links: A list of links to render. + */ +function theme_help_list($variables) { + $links = $variables['links']; + drupal_add_css(drupal_get_path('module', 'help') . '/help.css'); + $output = '

' . t('Help topics') . '

' . t('Help is available on the following items:') . '

'; + // Output pretty four-column list. + $count = count($links); + $limit = ceil($count / 4); + $chunk = array_chunk($links, $limit, TRUE); + foreach ($chunk as $item => $list) { + $output .= theme('item_list', array('items' => $list, 'attributes' => array('class' => 'help-items'))); + } + return $output; +} diff --git a/core/modules/help/lib/Drupal/help/Controller/HelpController.php b/core/modules/help/lib/Drupal/help/Controller/HelpController.php index 118f1bc..0683f2f 100644 --- a/core/modules/help/lib/Drupal/help/Controller/HelpController.php +++ b/core/modules/help/lib/Drupal/help/Controller/HelpController.php @@ -42,49 +42,25 @@ public static function create(ContainerInterface $container) { /** * Prints a page listing a glossary of Drupal terminology. * - * @return string - * An HTML string representing the contents of help page. + * @return array + * An array as expected by drupal_render(). */ public function helpMain() { - // Add CSS. - drupal_add_css(drupal_get_path('module', 'help') . '/help.css'); - $output = '

' . t('Help topics') . '

' . t('Help is available on the following items:') . '

' . $this->helpLinksAsList(); - return $output; - } - - /** - * Provides a formatted list of available help topics. - * - * @return string - * A string containing the formatted list. - */ - protected function helpLinksAsList() { $empty_arg = drupal_help_arg(); $module_info = system_rebuild_module_data(); $modules = array(); foreach ($this->moduleHandler->getImplementations('help') as $module) { if ($this->moduleHandler->invoke($module, 'help', array("admin/help#$module", $empty_arg))) { - $modules[$module] = $module_info[$module]->info['name']; + $modules[$module] = l($module_info[$module]->info['name'], 'admin/help/' . $module); } } asort($modules); - // Output pretty four-column list. - $count = count($modules); - $break = ceil($count / 4); - $output = '
'; - - return $output; + return array( + '#theme' => 'help_list', + '#links' => $modules, + ); } }