diff --git a/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php b/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php index 89c5914..3f3e9a7 100644 --- a/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php +++ b/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php @@ -18,7 +18,9 @@ * Converts entity route arguments to unmodified entities as opposed to * converting to entities with overrides, such as the negotiated language. * - * This converter applies only if the path is an admin path. + * This converter applies only if the path is an admin path, the entity is + * a config entity, and the "use_current_language" element is not set to TRUE + * on the parameter definition. * * Due to this converter having a higher weight than the default * EntityConverter, every time this applies, it takes over the conversion duty @@ -88,6 +90,10 @@ public function convert($value, $definition, $name, array $defaults) { * {@inheritdoc} */ public function applies($definition, $name, Route $route) { + if (isset($definition['use_current_language']) && $definition['use_current_language']) { + return FALSE; + } + if (parent::applies($definition, $name, $route)) { $entity_type_id = substr($definition['type'], strlen('entity:')); // If the entity type is dynamic, defer checking to self::convert(). diff --git a/core/modules/help/config/install/filter.format.help.yml b/core/modules/help/config/install/filter.format.help.yml new file mode 100644 index 0000000..7f87b2e --- /dev/null +++ b/core/modules/help/config/install/filter.format.help.yml @@ -0,0 +1,15 @@ +langcode: en +status: true +name: Help +format: help +weight: 0 +filters: + filter_html: + id: filter_html + provider: filter + status: true + weight: -10 + settings: + allowed_html: '
    1. ' + filter_html_help: true + filter_html_nofollow: false diff --git a/core/modules/help/config/install/help.topic.help.yml b/core/modules/help/config/install/help.topic.help.yml new file mode 100644 index 0000000..b898631 --- /dev/null +++ b/core/modules/help/config/install/help.topic.help.yml @@ -0,0 +1,11 @@ +langcode: en +status: true +dependencies: { } +id: help +label: 'Help module' +body: + value: "

      About

      \r\n

      The Help module provides Help reference pages to guide you through the use and configuration of modules. It is a starting point for Drupal.org online documentation pages that contain more extensive and up-to-date information, are annotated with user-contributed comments, and serve as the definitive reference point for all Drupal documentation. For more information, see the online documentation for the Help module.

      \r\n

      Uses

      \r\n
      \r\n
      Providing a help reference
      \r\n
      The Help module displays both static module-provided help and configured help topics on the main Help page.
      \r\n
      Configuring help topics
      \r\n
      You can add, edit, delete, and translate configure help topics on the Help topics administration page. The help topics that are listed in the Module help section of the main Help page cannot be edited or deleted.
      \r\n
      \r\n" + format: help +top_level: true +related: { } +list_on: { } diff --git a/core/modules/help/config/schema/help.schema.yml b/core/modules/help/config/schema/help.schema.yml new file mode 100644 index 0000000..4922897 --- /dev/null +++ b/core/modules/help/config/schema/help.schema.yml @@ -0,0 +1,33 @@ +help.topic.*: + type: config_entity + label: 'Help topic' + mapping: + id: + type: string + label: 'Machine-readable name' + label: + type: label + label: 'Title' + body: + label: 'Body' + type: mapping + mapping: + value: + type: text + label: 'Body' + format: + type: string + label: 'Text format' + top_level: + type: boolean + label: 'Top-level topic' + related: + type: sequence + label: 'Related topics' + sequence: + - type: string + list_on: + type: sequence + label: 'List on topics' + sequence: + - type: string diff --git a/core/modules/help/help.links.action.yml b/core/modules/help/help.links.action.yml new file mode 100644 index 0000000..3b452f0 --- /dev/null +++ b/core/modules/help/help.links.action.yml @@ -0,0 +1,5 @@ +entity.help_topic.add_form: + route_name: entity.help_topic.add_form + title: 'Add new help topic' + appears_on: + - help.topic_admin diff --git a/core/modules/help/help.links.menu.yml b/core/modules/help/help.links.menu.yml index aa85add..aa9c469 100644 --- a/core/modules/help/help.links.menu.yml +++ b/core/modules/help/help.links.menu.yml @@ -4,3 +4,9 @@ help.main: route_name: help.main weight: 9 parent: system.admin + +help.topic_admin: + title: Help topics + description: Add, delete, and edit help topics. + route_name: help.topic_admin + parent: system.admin_config_development diff --git a/core/modules/help/help.links.task.yml b/core/modules/help/help.links.task.yml new file mode 100644 index 0000000..3ce34f1 --- /dev/null +++ b/core/modules/help/help.links.task.yml @@ -0,0 +1,9 @@ +entity.help_topic.canonical: + title: 'View' + route_name: entity.help_topic.canonical + base_route: entity.help_topic.edit_form + +entity.help_topic.edit_form: + title: 'Edit' + route_name: entity.help_topic.edit_form + base_route: entity.help_topic.edit_form diff --git a/core/modules/help/help.module b/core/modules/help/help.module index 3539660..81dfdad 100644 --- a/core/modules/help/help.module +++ b/core/modules/help/help.module @@ -26,17 +26,6 @@ function help_help($route_name, RouteMatchInterface $route_match) { $output .= '
    '; $output .= '

    ' . t('For more information, refer to the subjects listed in the Help Topics section or to the online documentation and support pages at drupal.org.', array('!docs' => 'https://drupal.org/documentation', '!support' => 'https://drupal.org/support', '!drupal' => 'https://drupal.org')) . '

    '; return $output; - - case 'help.page.help': - $output = ''; - $output .= '

    ' . t('About') . '

    '; - $output .= '

    ' . t('The Help module provides Help reference pages to guide you through the use and configuration of modules. It is a starting point for Drupal.org online documentation pages that contain more extensive and up-to-date information, are annotated with user-contributed comments, and serve as the definitive reference point for all Drupal documentation. For more information, see the online documentation for the Help module.', array('!help' => 'https://drupal.org/documentation/modules/help/', '!handbook' => 'https://drupal.org/documentation', '!help-page' => \Drupal::url('help.main'))) . '

    '; - $output .= '

    ' . t('Uses') . '

    '; - $output .= '
    '; - $output .= '
    ' . t('Providing a help reference') . '
    '; - $output .= '
    ' . t('The Help module displays explanations for using each module listed on the main Help reference page.', array('!help' => \Drupal::url('help.main'))) . '
    '; - $output .= '
    '; - return $output; } } diff --git a/core/modules/help/help.permissions.yml b/core/modules/help/help.permissions.yml new file mode 100644 index 0000000..c1bc85a --- /dev/null +++ b/core/modules/help/help.permissions.yml @@ -0,0 +1,3 @@ +administer help topics: + title: 'Administer help topics' + description: 'Create, edit, and delete help topics.' diff --git a/core/modules/help/help.routing.yml b/core/modules/help/help.routing.yml index a393eb8..22079ae 100644 --- a/core/modules/help/help.routing.yml +++ b/core/modules/help/help.routing.yml @@ -13,3 +13,49 @@ help.page: _title: 'Help' requirements: _permission: 'access administration pages' + +entity.help_topic.canonical: + path: '/admin/help-topic/{help_topic}' + defaults: + _entity_view: 'help_topic.full' + _title: 'Help' + requirements: + _entity_access: 'help_topic.view' + options: + parameters: + help_topic: + type: entity:help_topic + # Force load in current interface language. + use_current_language: true + +help.topic_admin: + path: '/admin/config/development/help' + defaults: + _entity_list: 'help_topic' + _title: 'Help topics' + requirements: + _permission: 'administer help topics' + +entity.help_topic.add_form: + path: '/admin/config/development/help/add' + defaults: + _entity_form: 'help_topic.add' + _title: 'Add help topic' + requirements: + _entity_create_access: 'help_topic' + +entity.help_topic.edit_form: + path: '/admin/config/development/help/{help_topic}' + defaults: + _entity_form: 'help_topic.edit' + _title: 'Edit help topic' + requirements: + _entity_access: 'help_topic.edit' + +entity.help_topic.delete_form: + path: '/admin/config/development/help/{help_topic}/delete' + defaults: + _entity_form: 'help_topic.delete' + _title: 'Delete help topic' + requirements: + _entity_access: 'help_topic.delete' diff --git a/core/modules/help/help.services.yml b/core/modules/help/help.services.yml new file mode 100644 index 0000000..5a43fbf --- /dev/null +++ b/core/modules/help/help.services.yml @@ -0,0 +1,6 @@ +services: + help.breadcrumb: + class: Drupal\help\HelpBreadcrumbBuilder + arguments: ['@string_translation'] + tags: + - { name: breadcrumb_builder, priority: 900 } diff --git a/core/modules/help/help.tokens.inc b/core/modules/help/help.tokens.inc new file mode 100644 index 0000000..9854c62 --- /dev/null +++ b/core/modules/help/help.tokens.inc @@ -0,0 +1,53 @@ + t("Help Topics"), + 'description' => t("Provides tokens for help topics."), + ); + + $topics = array(); + /* @var \Drupal\help\HelpTopicInterface $help_topic */ + foreach (HelpTopic::loadMultiple() as $help_topic_id => $help_topic) { + $topics[$help_topic_id] = array( + 'name' => $help_topic->label(), + 'description' => t('URL to the @label help topic', array('@label' => $help_topic->label())), + ); + } + + return array( + 'types' => $types, + 'tokens' => array( + 'help_topic' => $topics, + ), + ); +} + +/** + * Implements hook_tokens(). + */ +function help_tokens($type, $tokens, array $data = array(), array $options = array()) { + $replacements = array(); + + if ($type == 'help_topic') { + foreach ($tokens as $name => $original) { + if ($topic = HelpTopic::load($name)) { + $replacements[$original] = $topic->url('canonical'); + } + } + } + + return $replacements; +} diff --git a/core/modules/help/src/Controller/HelpController.php b/core/modules/help/src/Controller/HelpController.php index 2de0a53..525da70 100644 --- a/core/modules/help/src/Controller/HelpController.php +++ b/core/modules/help/src/Controller/HelpController.php @@ -8,11 +8,12 @@ namespace Drupal\help\Controller; use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; +use Drupal\Component\Utility\String; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Drupal\Component\Utility\String; /** * Controller routines for help routes. @@ -27,13 +28,23 @@ class HelpController extends ControllerBase { protected $routeMatch; /** + * The help topic entity storage. + * + * @var \Drupal\Core\Entity\EntityStorageInterface + */ + protected $helpStorage; + + /** * Creates a new HelpController. * * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * The current route match. + * @param \Drupal\Core\Entity\EntityStorageInterface $help_storage + * The entity storage for help topic entities. */ - public function __construct(RouteMatchInterface $route_match) { + public function __construct(RouteMatchInterface $route_match, EntityStorageInterface $help_storage) { $this->routeMatch = $route_match; + $this->helpStorage = $help_storage; } /** @@ -41,50 +52,91 @@ public function __construct(RouteMatchInterface $route_match) { */ public static function create(ContainerInterface $container) { return new static( - $container->get('current_route_match') + $container->get('current_route_match'), + $container->get('entity.manager')->getStorage('help_topic') ); } /** - * Prints a page listing a glossary of Drupal terminology. + * Prints a page listing help topics. * - * @return string - * An HTML string representing the contents of help page. + * @return array + * Render array for the help topics list. */ public function helpMain() { $output = array( '#attached' => array( 'css' => array(drupal_get_path('module', 'help') . '/css/help.module.css'), ), - '#markup' => '

    ' . $this->t('Help topics') . '

    ' . $this->t('Help is available on the following items:') . '

    ' . $this->helpLinksAsList(), ); + + $template = '

    {{ title }}

    {{ header }}

    {{ links }}'; + + $output['modules'] = array( + '#type' => 'inline_template', + '#template' => $template, + '#context' => array( + 'title' => $this->t('Module help'), + 'header' => $this->t('Help pages are available for the following modules:'), + 'links' => array('#markup' => $this->moduleHelpLinksAsList()), + ), + ); + + $output['topics'] = array( + '#type' => 'inline_template', + '#template' => $template, + '#context' => array( + 'title' => $this->t('Configured topics'), + 'header' => $this->t('Additional help topics configured on your site:'), + 'links' => array('#markup' => $this->helpTopicsList()), + ), + ); + return $output; } /** - * Provides a formatted list of available help topics. + * Provides a formatted list of available module help topics from hook_help(). * * @return string * A string containing the formatted list. */ - protected function helpLinksAsList() { + protected function moduleHelpLinksAsList() { $module_info = system_rebuild_module_data(); $modules = array(); foreach ($this->moduleHandler()->getImplementations('help') as $module) { if ($this->moduleHandler()->invoke($module, 'help', array("help.page.$module", $this->routeMatch))) { - $modules[$module] = $module_info[$module]->info['name']; + $modules[$module] = array( + 'title' => $module_info[$module]->info['name'], + 'url' => new Url('help.page', array('name' => $module)), + ); } } asort($modules); + return $this->fourColumnList($modules); + } + + /** + * Makes a four-column list of links. + * + * @param array $links + * Array whose elements are arrays with: + * - title: Link title. + * - url: URL object. + * + * @return string + * Markup for a four-column UL list of links. + */ + protected function fourColumnList($links) { // Output pretty four-column list. - $count = count($modules); + $count = count($links); $break = ceil($count / 4); $output = '
      '; $i = 0; - foreach ($modules as $module => $name) { - $output .= '
    • ' . $this->l($name, new Url('help.page', array('name' => $module))) . '
    • '; + foreach ($links as $info) { + $output .= '
    • ' . $this->l($info['title'], $info['url']) . '
    • '; if (($i + 1) % $break == 0 && ($i + 1) != $count) { $output .= '