Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /**
|
Chris@0
|
4 * @file
|
Chris@0
|
5 * Manages displaying online help.
|
Chris@0
|
6 */
|
Chris@0
|
7
|
Chris@18
|
8 use Drupal\Core\Url;
|
Chris@0
|
9 use Drupal\Core\Block\BlockPluginInterface;
|
Chris@0
|
10 use Drupal\Core\Routing\RouteMatchInterface;
|
Chris@0
|
11
|
Chris@0
|
12 /**
|
Chris@0
|
13 * Implements hook_help().
|
Chris@0
|
14 */
|
Chris@0
|
15 function help_help($route_name, RouteMatchInterface $route_match) {
|
Chris@0
|
16 switch ($route_name) {
|
Chris@0
|
17 case 'help.main':
|
Chris@0
|
18 $output = '<h2>' . t('Getting Started') . '</h2>';
|
Chris@0
|
19 $output .= '<p>' . t('Follow these steps to set up and start using your website:') . '</p>';
|
Chris@0
|
20 $output .= '<ol>';
|
Chris@18
|
21 $output .= '<li>' . t('<strong>Configure your website</strong> Once logged in, visit the <a href=":admin">Administration page</a>, where you may <a href=":config">customize and configure</a> all aspects of your website.', [':admin' => Url::fromRoute('system.admin')->toString(), ':config' => Url::fromRoute('system.admin_config')->toString()]) . '</li>';
|
Chris@18
|
22 $output .= '<li>' . t('<strong>Enable additional functionality</strong> Next, visit the <a href=":modules">Extend page</a> and enable modules that suit your specific needs. You can find additional modules at the <a href=":download_modules">Drupal.org modules page</a>.', [':modules' => Url::fromRoute('system.modules_list')->toString(), ':download_modules' => 'https://www.drupal.org/project/modules']) . '</li>';
|
Chris@18
|
23 $output .= '<li>' . t('<strong>Customize your website design</strong> To change the "look and feel" of your website, visit the <a href=":themes">Appearance page</a>. You may choose from one of the included themes or download additional themes from the <a href=":download_themes">Drupal.org themes page</a>.', [':themes' => Url::fromRoute('system.themes_page')->toString(), ':download_themes' => 'https://www.drupal.org/project/themes']) . '</li>';
|
Chris@0
|
24 // Display a link to the create content page if Node module is enabled.
|
Chris@0
|
25 if (\Drupal::moduleHandler()->moduleExists('node')) {
|
Chris@18
|
26 $output .= '<li>' . t('<strong>Start posting content</strong> Finally, you may <a href=":content">add new content</a> to your website.', [':content' => Url::fromRoute('node.add_page')->toString()]) . '</li>';
|
Chris@0
|
27 }
|
Chris@0
|
28 $output .= '</ol>';
|
Chris@0
|
29 $output .= '<p>' . t('For more information, refer to the help listed on this page or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', [':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org']) . '</p>';
|
Chris@0
|
30 return ['#markup' => $output];
|
Chris@0
|
31
|
Chris@0
|
32 case 'help.page.help':
|
Chris@0
|
33 $output = '';
|
Chris@0
|
34 $output .= '<h3>' . t('About') . '</h3>';
|
Chris@18
|
35 $output .= '<p>' . t('The Help module generates <a href=":help-page">Help reference pages</a> to guide you through the use and configuration of modules, and provides a Help block with page-level help. The reference pages are a starting point for <a href=":handbook">Drupal.org online documentation</a> 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 <a href=":help">online documentation for the Help module</a>.', [':help' => 'https://www.drupal.org/documentation/modules/help/', ':handbook' => 'https://www.drupal.org/documentation', ':help-page' => Url::fromRoute('help.main')->toString()]) . '</p>';
|
Chris@0
|
36 $output .= '<h3>' . t('Uses') . '</h3>';
|
Chris@0
|
37 $output .= '<dl>';
|
Chris@0
|
38 $output .= '<dt>' . t('Providing a help reference') . '</dt>';
|
Chris@18
|
39 $output .= '<dd>' . t('The Help module displays explanations for using each module listed on the main <a href=":help">Help reference page</a>.', [':help' => Url::fromRoute('help.main')->toString()]) . '</dd>';
|
Chris@0
|
40 $output .= '<dt>' . t('Providing page-specific help') . '</dt>';
|
Chris@18
|
41 $output .= '<dd>' . t('Page-specific help text provided by modules is displayed in the Help block. This block can be placed and configured on the <a href=":blocks">Block layout page</a>.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? Url::fromRoute('block.admin_display')->toString() : '#']) . '</dd>';
|
Chris@0
|
42 $output .= '</dl>';
|
Chris@0
|
43 return ['#markup' => $output];
|
Chris@0
|
44 }
|
Chris@0
|
45 }
|
Chris@0
|
46
|
Chris@0
|
47 /**
|
Chris@0
|
48 * Implements hook_theme().
|
Chris@0
|
49 */
|
Chris@0
|
50 function help_theme($existing, $type, $theme, $path) {
|
Chris@0
|
51 return [
|
Chris@0
|
52 'help_section' => [
|
Chris@0
|
53 'variables' => [
|
Chris@0
|
54 'title' => NULL,
|
Chris@0
|
55 'description' => NULL,
|
Chris@0
|
56 'links' => NULL,
|
Chris@0
|
57 'empty' => NULL,
|
Chris@0
|
58 ],
|
Chris@0
|
59 ],
|
Chris@0
|
60 ];
|
Chris@0
|
61 }
|
Chris@0
|
62
|
Chris@0
|
63 /**
|
Chris@0
|
64 * Implements hook_preprocess_HOOK() for block templates.
|
Chris@0
|
65 */
|
Chris@0
|
66 function help_preprocess_block(&$variables) {
|
Chris@0
|
67 if ($variables['plugin_id'] == 'help_block') {
|
Chris@0
|
68 $variables['attributes']['role'] = 'complementary';
|
Chris@0
|
69 }
|
Chris@0
|
70 }
|
Chris@0
|
71
|
Chris@0
|
72 /**
|
Chris@0
|
73 * Implements hook_block_view_BASE_BLOCK_ID_alter().
|
Chris@0
|
74 */
|
Chris@0
|
75 function help_block_view_help_block_alter(array &$build, BlockPluginInterface $block) {
|
Chris@0
|
76 // Assume that most users do not need or want to perform contextual actions on
|
Chris@0
|
77 // the help block, so don't needlessly draw attention to it.
|
Chris@0
|
78 unset($build['#contextual_links']);
|
Chris@0
|
79 }
|