help.module 4.54 KB
Newer Older
Dries's avatar
Dries committed
1 2
<?php

3 4 5 6 7
/**
 * @file
 * Manages displaying online help.
 */

8
use Drupal\Core\Routing\RouteMatchInterface;
9
use Drupal\Core\Block\BlockPluginInterface;
10

11
/**
12
 * Implements hook_help().
13
 */
14
function help_help($route_name, RouteMatchInterface $route_match) {
15 16
  switch ($route_name) {
    case 'help.main':
17 18
      $output = '<h2>' . t('Getting Started') . '</h2>';
      $output .= '<p>' . t('Follow these steps to set up and start using your website:') . '</p>';
19
      $output .= '<ol>';
20 21 22
      $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.', array('!admin' => \Drupal::url('system.admin'), '!config' => \Drupal::url('system.admin_config'))) . '</li>';
      $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>.', array('!modules' => \Drupal::url('system.modules_list'), '!download_modules' => 'https://drupal.org/project/modules')) . '</li>';
      $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>.', array('!themes' => \Drupal::url('system.themes_page'), '!download_themes' => 'https://drupal.org/project/themes')) . '</li>';
23
      // Display a link to the create content page if Node module is enabled.
24
      if (\Drupal::moduleHandler()->moduleExists('node')) {
25
        $output .= '<li>' . t('<strong>Start posting content</strong> Finally, you may <a href="!content">add new content</a> to your website.', array('!content' => \Drupal::url('node.add_page'))) . '</li>';
26
      }
27
      $output .= '</ol>';
28
      $output .= '<p>' . t('For more information, refer to the subjects listed in the Help Topics section or to the <a href="!docs">online documentation</a> and <a href="!support">support</a> pages at <a href="!drupal">drupal.org</a>.', array('!docs' => 'https://drupal.org/documentation', '!support' => 'https://drupal.org/support', '!drupal' => 'https://drupal.org')) . '</p>';
29
      return $output;
30 31

    case 'help.page.help':
32 33
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
34
      $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>.', array('!help' => 'https://drupal.org/documentation/modules/help/', '!handbook' => 'https://drupal.org/documentation', '!help-page' => \Drupal::url('help.main'))) . '</p>';
35 36 37
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Providing a help reference') . '</dt>';
38
      $output .= '<dd>' . t('The Help module displays explanations for using each module listed on the main <a href="!help">Help reference page</a>.', array('!help' => \Drupal::url('help.main'))) . '</dd>';
39 40
      $output .= '<dt>' . t('Providing page-specific help') . '</dt>';
      $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>.', array('!blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
41
      $output .= '</dl>';
42
      return $output;
43
  }
Dries's avatar
Dries committed
44
}
45 46

/**
47
 * Implements hook_preprocess_HOOK() for block templates.
48 49
 */
function help_preprocess_block(&$variables) {
50
  if ($variables['plugin_id'] == 'help_block') {
51
    $variables['attributes']['role'] = 'complementary';
52 53
  }
}
54 55 56 57 58 59 60 61 62

/**
 * Implements hook_block_view_BASE_BLOCK_ID_alter().
 */
function help_block_view_help_block_alter(array &$build, BlockPluginInterface $block) {
  // Assume that most users do not need or want to perform contextual actions on
  // the help block, so don't needlessly draw attention to it.
  unset($build['#contextual_links']);
}