reverted: --- b/core/modules/help_topics/help_topics/config_basic.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: config_basic -label: 'Changing basic site settings' -top_level: true -related: - - security_account_settings reverted: --- b/core/modules/help_topics/help_topics/config_error.yml +++ /dev/null @@ -1,6 +0,0 @@ -id: config_error -label: 'Configuring error responses, including 403/404 pages' -top_level: false -related: - - config_basic - - maintenance reverted: --- b/core/modules/help_topics/help_topics/help_topic_writing.yml +++ /dev/null @@ -1,3 +0,0 @@ -id: help_topic_writing -label: 'Writing good help' -top_level: true reverted: --- b/core/modules/help_topics/help_topics/maintenance.yml +++ /dev/null @@ -1,3 +0,0 @@ -id: maintenance -label: 'Maintaining and troubleshooting your site' -top_level: true reverted: --- b/core/modules/help_topics/help_topics/menu_overview.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: menu_overview -label: 'Defining navigation and URLs' -top_level: true -related: - - menu_overview reverted: --- b/core/modules/help_topics/help_topics/security.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: security -label: 'Making your site secure' -top_level: true -related: - - menu_overview reverted: --- b/core/modules/help_topics/help_topics/security_account_settings.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: security_account_settings -label: 'Defining how user accounts are created' -top_level: false -related: - - security reverted: --- b/core/modules/help_topics/help_topics/templates/help-topic-config-basic.html.twig +++ /dev/null @@ -1,12 +0,0 @@ -{% set regional_url = render_var(url('system.regional_settings')) %} -{% set information_url = render_var(url('system.site_information_settings')) %} -{% set datetime_url = render_var(url('entity.date_format.collection')) %} -
{% trans %}The settings for your site are configured on various administrative pages, as follows:{% endtrans %}
-{% trans %}The core software provides default responses for 403 response (Not Authorized: when someone tries to visit a page they do not have permission to see) and 404 response (Not Found: when someone tries to visit a page that does not exist). You can change what page is displayed for these responses on the Basic site settings page, which you can reach in the main Manage administrative menu, by navigating to Configuration > System > Basic site settings. Note that the pages you want to use must already exist as either system-provided pages or content that you have created.{% endtrans %}
-{% trans %}Software errors on your site are logged, if you have a logging module installed (such as the core Database Logging module or the core Syslog module). You can configure whether or not error messages are also shown (to both administrators and other site visitors) on the Logging and errors configuration page, which you can reach in the main Manage administrative menu, by navigating to Configuration > Development > Logging and errors.{% endtrans %}
-{% trans %}If you have the core Database Logging module installed, you can view recent error and informational messages by navigating in the main Manage administrative menu to Reports > Recent log messages. If you are using the core Syslog module for logging, error messages will be logged in your web server''s log files.{% endtrans %}
reverted: --- b/core/modules/help_topics/help_topics/templates/help-topic-help-topic-writing.html.twig +++ /dev/null @@ -1,7 +0,0 @@ -{% trans %}Here are some suggestions for how to make your help topics as useful as possible for readers:{% endtrans %}
-{% trans %}The related topics listed here will help you keep your site running and troubleshoot problems.{% endtrans %}
reverted: --- b/core/modules/help_topics/help_topics/templates/help-topic-menu-overview.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% trans %}The related topics listed here describe how to set up various aspects of site navigation and URLs.{% endtrans %}
reverted: --- b/core/modules/help_topics/help_topics/templates/help-topic-security-account-settings.html.twig +++ /dev/null @@ -1,8 +0,0 @@ -{% set account_settings_url = render_var(url('entity.user.admin_form')) %} -{% trans %}On the Account settings page, which you can reach from the Manage administrative menu, by navigating to Configuration > People > Account settings (requires the Administer account settings permission), you can configure several settings related to how user accounts are created:{% endtrans %}
-{% trans %}The topics listed here will help you make and keep your site secure.{% endtrans %}
reverted: --- b/core/modules/help_topics/help_topics/templates/help-topic-ui-accessibility.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -{% trans %}The following features of the administrative user interface may help administrative users with disabilities access your site:{% endtrans %}
-{% trans %}The related topics listed here describe various aspects of the administrative interface, and tell how to use them.{% endtrans %}
reverted: --- b/core/modules/help_topics/help_topics/templates/help-topic-ui-contextual.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -{% trans %}Contextual links give users with the Use contextual links permission quick access to administrative tasks related to areas of non-administrative pages. For example, if a page on your site displays a block, the block would have a contextual link that would allow users with permission to configure the block. If the block contains a menu or a view, it would also have a contextual link for editing the menu links or the view. Clicking a contextual link takes you to the related administrative page directly, without needing to navigate through the administrative menu system.{% endtrans %}
-{% trans %}If you have the core Contextual Links module installed, the contextual links related to an area on a page can be displayed by clicking the contextual links button in that area of the page. In most themes, this button looks like a pencil and is placed in the upper right corner of the page area (upper left for right-to-left languages); however, contextual links buttons are normally hidden. Here are two ways to make contextual links buttons visible:{% endtrans %}
-{% trans %}While the contextual links button for the area of interest is visible, click the button to display the list of links for that area. Click a link in the list to perform the task.{% endtrans %}
reverted: --- b/core/modules/help_topics/help_topics/templates/help-topic-ui-shortcuts.html.twig +++ /dev/null @@ -1,6 +0,0 @@ -{% trans %}Shortcuts are quick links to administrative pages; they are managed by the core Shortcut module. A site can have one or more shortcut sets, which can be shared by one or more users; each set contains one or more shortcuts. Users need Use shortcuts permission to view shortcuts; Edit current shortcut set permission to add, delete, or edit the shortcuts in the set assigned to them; and Select any shortcut set permission to select a different shortcut set when editing their user profile. There is also an Administer shortcuts permission, which allows an administrator to do any of these actions, and also permits assigning shortcut sets to other users.{% endtrans %}
-{% trans %}When viewing certain administrative pages, you will see a link that allows you to add the page to your current shortcut set. In the core Seven administrative theme, the link looks like a star, and is displayed next to the page title. If the page is already in your shortcut set, you will instead see a link that allows you to remove it.{% endtrans %}
-{% trans %}If you have the core Toolbar module installed, click Shortcuts in the toolbar to display your shortcuts. Once they are displayed, click any link in the shortcut bar to go directly to the administrative page. If you are not using the Toolbar module, you can display shortcuts by placing the Shortcuts block in a region of your theme.{% endtrans %}
reverted: --- b/core/modules/help_topics/help_topics/templates/help-topic-ui-tours.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{% trans %}The core Tour module provides users with tours, which are guided tours of the administrative interface. Each tour starts on a particular administrative page, and consists of one or more tips that highlight elements of the page, guide you through a workflow, or explain key concepts. Users need Access tour permission to view tours, and JavaScript must be enabled in their browsers.{% endtrans %}
-{% trans %}If a tour is available on a page, and you have the core Toolbar module installed, a Tour button will appear on the right end of the toolbar (left end for right-to-left languages). Click this button to view the first tip of the tour; click the Next button to advance to the next tip, and End tour at the end to close the tour.{% endtrans %}
reverted: --- b/core/modules/help_topics/help_topics/ui_accessibility.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: ui_accessibility -label: 'Accessibility features' -top_level: false -related: - - ui_components reverted: --- b/core/modules/help_topics/help_topics/ui_components.yml +++ /dev/null @@ -1,4 +0,0 @@ -id: ui_components -label: 'Using the administrative interface' -top_level: true -related: { } reverted: --- b/core/modules/help_topics/help_topics/ui_contextual.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: ui_contextual -label: 'Contextual links' -top_level: false -related: - - ui_components reverted: --- b/core/modules/help_topics/help_topics/ui_shortcuts.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: ui_shortcuts -label: Shortcuts -top_level: false -related: - - ui_components reverted: --- b/core/modules/help_topics/help_topics/ui_tours.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: ui_tours -label: Tours -top_level: false -related: - - ui_components diff -u b/core/modules/help_topics/src/HelpTopicPluginManager.php b/core/modules/help_topics/src/HelpTopicPluginManager.php --- b/core/modules/help_topics/src/HelpTopicPluginManager.php +++ b/core/modules/help_topics/src/HelpTopicPluginManager.php @@ -3,7 +3,6 @@ namespace Drupal\help_topics; use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Plugin\Discovery\YamlDirectoryDiscovery; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; @@ -79,10 +78,7 @@ return [$dir . '/help_topics']; }, $directories); - $file_cache_key_suffix = 'help_topic'; - $id_key = 'id'; - $this->discovery = new YamlDirectoryDiscovery($directories, $file_cache_key_suffix, $id_key); - $this->discovery->addTranslatableProperty('label'); + $this->discovery = new HelpTopicDiscovery($directories); } return $this->discovery; } @@ -101,7 +97,14 @@ parent::alterDefinitions($definitions); foreach ($definitions as $plugin_id => $plugin_definition) { - foreach ($plugin_definition['related'] as $related_id) { + foreach ($plugin_definition['related'] as $key => $related_id) { + // If the related help topic does not exist it might be for a module + // that is not installed. Remove it. This silent removal is a bit + // worrying but how else do we support optional relations? + if (!isset($definitions[$related_id])) { + unset($definitions[$plugin_id]['related'][$key]); + continue; + } // Ensure that the other plugin is related to this ID. if (isset($definitions[$related_id]) && !in_array($plugin_id, $definitions[$related_id]['related'], TRUE)) { $definitions[$related_id]['related'][] = $plugin_id; @@ -135,8 +138,8 @@ } $return[$hook] = [ 'variables' => [], - 'path' => $provider_path . '/help_topics/templates', - 'template' => $hook, + 'path' => $provider_path . '/help_topics', + 'template' => $pluginId, ]; } return $return; reverted: --- b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/help_test.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: help_test -label: 'ABC Help Test module' -top_level: true -related: - - help_test_linked reverted: --- b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/help_test_additional.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: help_test_additional -label: 'Additional topic' -top_level: false -related: - - help_test reverted: --- b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/help_test_linked.yml +++ /dev/null @@ -1,3 +0,0 @@ -id: help_test_linked -label: 'Linked topic' -top_level: false reverted: --- b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/templates/help-topic-help-test-additional.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% trans %}This topic should get listed automatically on the Help test topic.{% endtrans %}
reverted: --- b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/templates/help-topic-help-test-linked.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% trans %}This topic is not supposed to be top-level.{% endtrans %}
reverted: --- b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/templates/help-topic-help-test.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -{% set help_topic_url = render_var(url('help_topics.help_topic', {id: 'help_topic_writing'})) %} -{% trans %}This is a test. It should link to the writing good help topic. Also there should be a related topic link below to the Help module topic page and the linked topic.{% endtrans %}
diff -u b/core/modules/help_topics/tests/src/Functional/HelpTopicTest.php b/core/modules/help_topics/tests/src/Functional/HelpTopicTest.php --- b/core/modules/help_topics/tests/src/Functional/HelpTopicTest.php +++ b/core/modules/help_topics/tests/src/Functional/HelpTopicTest.php @@ -154,7 +154,7 @@ protected function verifyHelpLinks() { $session = $this->assertSession(); // Verify links on the test top-level page. - $page = 'admin/help/topic/help_test'; + $page = 'admin/help/topic/help-test'; $links = [ 'link to the writing good help topic' => 'Writing good help', 'Linked topic' => 'This topic is not supposed to be top-level', @@ -167,7 +167,7 @@ } // Verify theme provided help topics work and can be related. - $this->drupalGet('admin/help/topic/help_test_theme'); + $this->drupalGet('admin/help/topic/help-test-theme'); $session->pageTextContains('This is a theme provided topic.'); $this->clickLink('Additional topic'); $this->assertLink('XYZ Help Test theme'); @@ -190,10 +190,10 @@ */ protected function getTopicList() { return [ - 'help_test' => [ + 'help-test' => [ 'name' => 'ABC Help Test module', ], - 'help_topic_writing' => [ + 'help-topic-writing' => [ 'name' => 'Writing good help', ], ]; @@ -207,14 +207,14 @@ $home = ['' => 'Home']; $admin = $home + ['admin' => t('Administration')]; - $page = 'admin/help/topic/help_test'; + $page = 'admin/help/topic/help-test'; $this->drupalGet($page); // Verify Help Topics administration breadcrumbs. $trail = $admin + [ 'admin/help' => t('Help'), ]; - $this->assertBreadcrumb('admin/help/topic/help_test', $trail); + $this->assertBreadcrumb('admin/help/topic/help-test', $trail); } reverted: --- b/core/modules/help_topics/tests/themes/help_topic_test_theme/help_topics/help_test_theme.yml +++ /dev/null @@ -1,5 +0,0 @@ -id: help_test_theme -label: 'XYZ Help Test theme' -top_level: true -related: - - help_test_additional reverted: --- b/core/modules/help_topics/tests/themes/help_topic_test_theme/help_topics/templates/help-topic-help-test-theme.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% trans %}This is a theme provided topic.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/help_topics/config-basic.html.twig @@ -0,0 +1,15 @@ + + + +{% set regional_url = render_var(url('system.regional_settings')) %} +{% set information_url = render_var(url('system.site_information_settings')) %} +{% set datetime_url = render_var(url('entity.date_format.collection')) %} +{% trans %}The settings for your site are configured on various administrative pages, as follows:{% endtrans %}
+{% trans %}The core software provides default responses for 403 response (Not Authorized: when someone tries to visit a page they do not have permission to see) and 404 response (Not Found: when someone tries to visit a page that does not exist). You can change what page is displayed for these responses on the Basic site settings page, which you can reach in the main Manage administrative menu, by navigating to Configuration > System > Basic site settings. Note that the pages you want to use must already exist as either system-provided pages or content that you have created.{% endtrans %}
+{% trans %}Software errors on your site are logged, if you have a logging module installed (such as the core Database Logging module or the core Syslog module). You can configure whether or not error messages are also shown (to both administrators and other site visitors) on the Logging and errors configuration page, which you can reach in the main Manage administrative menu, by navigating to Configuration > Development > Logging and errors.{% endtrans %}
+{% trans %}If you have the core Database Logging module installed, you can view recent error and informational messages by navigating in the main Manage administrative menu to Reports > Recent log messages. If you are using the core Syslog module for logging, error messages will be logged in your web server''s log files.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/help_topics/help-topic-writing.html.twig @@ -0,0 +1,9 @@ + + +{% trans %}Here are some suggestions for how to make your help topics as useful as possible for readers:{% endtrans %}
+{% trans %}The related topics listed here will help you keep your site running and troubleshoot problems.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/help_topics/menu-overview.html.twig @@ -0,0 +1,3 @@ + + +{% trans %}The related topics listed here describe how to set up various aspects of site navigation and URLs.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/help_topics/security-account-settings.html.twig @@ -0,0 +1,10 @@ + + +{% set account_settings_url = render_var(url('entity.user.admin_form')) %} +{% trans %}On the Account settings page, which you can reach from the Manage administrative menu, by navigating to Configuration > People > Account settings (requires the Administer account settings permission), you can configure several settings related to how user accounts are created:{% endtrans %}
+{% trans %}The topics listed here will help you make and keep your site secure.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/help_topics/ui-accessibility.html.twig @@ -0,0 +1,7 @@ + + +{% trans %}The following features of the administrative user interface may help administrative users with disabilities access your site:{% endtrans %}
+{% trans %}The related topics listed here describe various aspects of the administrative interface, and tell how to use them.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/help_topics/ui-contextual.html.twig @@ -0,0 +1,11 @@ + + +{% trans %}Contextual links give users with the Use contextual links permission quick access to administrative tasks related to areas of non-administrative pages. For example, if a page on your site displays a block, the block would have a contextual link that would allow users with permission to configure the block. If the block contains a menu or a view, it would also have a contextual link for editing the menu links or the view. Clicking a contextual link takes you to the related administrative page directly, without needing to navigate through the administrative menu system.{% endtrans %}
+{% trans %}If you have the core Contextual Links module installed, the contextual links related to an area on a page can be displayed by clicking the contextual links button in that area of the page. In most themes, this button looks like a pencil and is placed in the upper right corner of the page area (upper left for right-to-left languages); however, contextual links buttons are normally hidden. Here are two ways to make contextual links buttons visible:{% endtrans %}
+{% trans %}While the contextual links button for the area of interest is visible, click the button to display the list of links for that area. Click a link in the list to perform the task.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/help_topics/ui-shortcuts.html.twig @@ -0,0 +1,8 @@ + + +{% trans %}Shortcuts are quick links to administrative pages; they are managed by the core Shortcut module. A site can have one or more shortcut sets, which can be shared by one or more users; each set contains one or more shortcuts. Users need Use shortcuts permission to view shortcuts; Edit current shortcut set permission to add, delete, or edit the shortcuts in the set assigned to them; and Select any shortcut set permission to select a different shortcut set when editing their user profile. There is also an Administer shortcuts permission, which allows an administrator to do any of these actions, and also permits assigning shortcut sets to other users.{% endtrans %}
+{% trans %}When viewing certain administrative pages, you will see a link that allows you to add the page to your current shortcut set. In the core Seven administrative theme, the link looks like a star, and is displayed next to the page title. If the page is already in your shortcut set, you will instead see a link that allows you to remove it.{% endtrans %}
+{% trans %}If you have the core Toolbar module installed, click Shortcuts in the toolbar to display your shortcuts. Once they are displayed, click any link in the shortcut bar to go directly to the administrative page. If you are not using the Toolbar module, you can display shortcuts by placing the Shortcuts block in a region of your theme.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/help_topics/ui-tours.html.twig @@ -0,0 +1,6 @@ + + +{% trans %}The core Tour module provides users with tours, which are guided tours of the administrative interface. Each tour starts on a particular administrative page, and consists of one or more tips that highlight elements of the page, guide you through a workflow, or explain key concepts. Users need Access tour permission to view tours, and JavaScript must be enabled in their browsers.{% endtrans %}
+{% trans %}If a tour is available on a page, and you have the core Toolbar module installed, a Tour button will appear on the right end of the toolbar (left end for right-to-left languages). Click this button to view the first tip of the tour; click the Next button to advance to the next tip, and End tour at the end to close the tour.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/src/HelpTopicDiscovery.php @@ -0,0 +1,147 @@ +directories = $directories; + } + + /** + * {@inheritdoc} + */ + public function getDefinitions() { + $plugins = $this->findAll(); + + // Flatten definitions into what's expected from plugins. + $definitions = []; + foreach ($plugins as $list) { + foreach ($list as $id => $definition) { + $definitions[$id] = $definition; + } + } + + return $definitions; + } + + /** + * Returns an array of discoverable items. + * + * @return array + * An array of discovered data keyed by provider. + * + * @throws \Drupal\Component\Discovery\DiscoveryException + * Exception thrown if there is a problem during discovery. + */ + public function findAll() { + $all = []; + + $files = $this->findFiles(); + + $file_cache = FileCacheFactory::get('help_topic_discovery:help_topics'); + + // Try to load from the file cache first. + foreach ($file_cache->getMultiple(array_keys($files)) as $file => $data) { + $all[$files[$file]][$data['id']] = $data; + unset($files[$file]); + } + + // If there are files left that were not returned from the cache, load and + // parse them now. This list was flipped above and is keyed by filename. + if ($files) { + foreach ($files as $file => $provider) { + $data = [ + // The plugin ID is derived from the filename. The extension + // '.html.twig' is removed + 'id' => substr(basename($file), 0, -10), + 'provider' => $provider, + static::FILE_KEY => $file, + ]; + + // Get the rest of the plugin definition from meta tags contained in the + // help topic twig template. + foreach (get_meta_tags($file) as $key => $value) { + $key = substr($key, 11); + switch ($key) { + case 'related': + $data[$key] = explode(',', $value); + break; + case 'top_level': + $data[$key] = strtolower($value) === 'true' ? TRUE : FALSE; + break; + case 'label': + $data[$key] = new TranslatableMarkup($value); + break; + default: + throw new DiscoveryException("The $file contains invalid meta tag with name='$key'"); + } + } + + $all[$provider][$data['id']] = $data; + $file_cache->set($file, $data); + } + } + + return $all; + } + + /** + * Returns an array of providers keyed by file path. + * + * @return array + * An array of providers keyed by file path. + */ + protected function findFiles() { + $file_list = []; + foreach ($this->directories as $provider => $directories) { + $directories = (array) $directories; + foreach ($directories as $directory) { + if (is_dir($directory)) { + /** @var \SplFileInfo $fileInfo */ + $iterator = new RegexDirectoryIterator($directory, '/\.html\.twig$/i'); + foreach ($iterator as $fileInfo) { + $file_list[$fileInfo->getPathname()] = $provider; + } + } + } + } + return $file_list; + } + +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/help-test-additional.html.twig @@ -0,0 +1,3 @@ + + +{% trans %}This topic should get listed automatically on the Help test topic.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/help-test-linked.html.twig @@ -0,0 +1,2 @@ + +{% trans %}This topic is not supposed to be top-level.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/help-test.html.twig @@ -0,0 +1,5 @@ + + + +{% set help_topic_url = render_var(url('help_topics.help_topic', {id: 'help-topic-writing'})) %} +{% trans %}This is a test. It should link to the writing good help topic. Also there should be a related topic link below to the Help module topic page and the linked topic.{% endtrans %}
only in patch2: unchanged: --- /dev/null +++ b/core/modules/help_topics/tests/themes/help_topic_test_theme/help_topics/help-test-theme.html.twig @@ -0,0 +1,4 @@ + + + +{% trans %}This is a theme provided topic.{% endtrans %}