diff --git a/core/modules/help/css/help.module.css b/core/modules/help/css/help.module.css index 444e0cd..1994f96 100644 --- a/core/modules/help/css/help.module.css +++ b/core/modules/help/css/help.module.css @@ -2,20 +2,12 @@ .help-items { float: left; /* LTR */ width: 22%; - margin-right: 3%; /* LTR */ } [dir="rtl"] .help-items { float: right; margin-right: 0; margin-left: 3%; } -.help-items-last { - margin-right: 0; /* LTR */ -} -[dir="rtl"] .help-items-last { - margin-right: 0; - margin-left: 0; -} /** diff --git a/core/modules/help/help.module b/core/modules/help/help.module index 6d07405..0339bd9 100644 --- a/core/modules/help/help.module +++ b/core/modules/help/help.module @@ -81,3 +81,37 @@ function help_preprocess_block(&$variables) { $variables['attributes']['role'] = 'complementary'; } } + +/** + * Implements hook_theme(). + */ +function help_theme() { + return array( + 'help_list' => array( + 'template' => 'help-list', + 'variables' => array('links' => NULL), + ), + ); +} + +/** + * Preprocess function for help-list template + * + * @param $variables + * An associative array containing: + * - links: A list of links to render. + */ +function template_preprocess_help_list(&$variables) { + $links = $variables['links']; + $count = count($links); + // Four-column list. + $limit = ceil($count / 4); + $chunk = array_chunk($links, $limit, TRUE); + $variables['rows'] = array(); + foreach ($chunk as $item => $list) { + $variables['rows'][] = theme('item_list', array( + 'items' => $list, + 'attributes' => array('class' => 'help-items'), + )); + } +} diff --git a/core/modules/help/lib/Drupal/help/Controller/HelpController.php b/core/modules/help/lib/Drupal/help/Controller/HelpController.php index 7aac826..a21cdb1 100644 --- a/core/modules/help/lib/Drupal/help/Controller/HelpController.php +++ b/core/modules/help/lib/Drupal/help/Controller/HelpController.php @@ -44,52 +44,28 @@ 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() { - $output = array( - '#attached' => array( - 'css' => array(drupal_get_path('module', 'help') . '/css/help.module.css'), - ), - '#markup' => '

' . 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, + '#attached' => array( + 'css' => array(drupal_get_path('module', 'help') . '/css/help.module.css'), + ), + ); } /** diff --git a/core/modules/help/templates/help-list.html.twig b/core/modules/help/templates/help-list.html.twig new file mode 100644 index 0000000..b3b8a22 --- /dev/null +++ b/core/modules/help/templates/help-list.html.twig @@ -0,0 +1,18 @@ +{# +/** + * @file + * Default theme implementation to present a list of help items. + * + * Available variables: + * - rows: An array containing list of links to render. + * + * @ingroup themeable + */ +#} +

{{ 'Help topics'|t }}

+

{{ 'Help is available on the following items:'|t }}

+{% if rows %} + {% for list in rows %} + {{ list }} + {% endfor %} +{% endif %} \ No newline at end of file