You are here

function viewport_help in Viewport 8

Same name and namespace in other branches
  1. 7 viewport.module \viewport_help()

Implements hook_help().

File

./viewport.module, line 17
Viewport module.

Code

function viewport_help($route_name, RouteMatchInterface $route_match) {
  $help_text = '';
  switch ($route_name) {

    // Help page.
    case 'help.page.viewport':
      $link_options = array(
        'attributes' => array(
          'target' => '_blank',
        ),
      );
      $module_settings_page = Link::createFromRoute(t("Viewport configuration page"), 'viewport.settings', array(), $link_options)
        ->toString();
      $link_options['fragment'] = 'module-viewport';
      $viewport_permissions = Link::createFromRoute(t('Administer Viewport settings'), 'user.admin_permissions', array(), $link_options)
        ->toString();
      $help_text = '<h3>' . t('About') . '</h3>';
      $help_text .= '<p>' . t('The Viewport module is a simple module that allows
        administrators, or users with the <em>"!viewport_permissions"</em> permission,
        to set a Viewport HTML metatag with the desired properties for one or several
        pages that can be configured from the \'!settings_page\'.', array(
        '!settings_page' => $module_settings_page,
        '!viewport_permissions' => $viewport_permissions,
      )) . '</p>';
      $help_text .= '<h3>' . t('Uses') . '</h3>';
      $help_text .= '<p>' . t('The aim of the module is to provide an easy way to debug or test websites or
        apps, as well as responsive designs on smartphones and tablets.') . '</p>';
      $help_text .= '<p>' . t('Sometimes, one may need to set specific viewport values
        for a specific page on the site (e.g when embedding a game for smartphones / tablets).
        This tool helps to solve easily situations like that.') . '</p>';
      $help_text .= '<strong>' . t('For more information on
        the viewport metatag and its properties, refer to the following resources:') . '</strong>';
      $resource_links = array(
        Link::fromTextAndUrl(t('Safari developer docs'), Url::fromUri('https://developer.apple.com/library/safari/#documentation/appleapplications/reference/SafariHTMLRef/Articles/MetaTags.html#//apple_ref/doc/uid/TP40008193-SW7', array(
          'attributes' => array(
            'target' => '_blank',
          ),
        ))),
        Link::fromTextAndUrl(t('Non-browser-specific information on viewport metatag'), Url::fromUri('http://www.html-5.com/metatags/index.html#viewport-meta-tag', array(
          'attributes' => array(
            'target' => '_blank',
          ),
        ))),
        Link::fromTextAndUrl(t('Detailed browser comparison of the viewport properties'), Url::fromUri('http://www.quirksmode.org/mobile/tableViewport.html', array(
          'attributes' => array(
            'target' => '_blank',
          ),
        ))),
      );
      $item_list = array(
        '#theme' => 'item_list',
        '#items' => $resource_links,
      );
      $help_text .= \Drupal::service('renderer')
        ->render($item_list);
      break;

    // Settings page.
    case 'viewport.settings':
      $help_page_url = Link::createFromRoute(t("Viewport's help page"), 'help.page', [
        'name' => 'viewport',
      ], array(
        'attributes' => array(
          'target' => '_blank',
        ),
      ))
        ->toString();
      $help_text = t('The values for the viewport metatag will be output in the same way as entered here
      for the pages selected below. <br/>
      For numeric values with decimal digits, use the decimal point "." instead of a comma ",". <br/>
      For detailed information about what these values are for, visit the \'!help_page\'.', array(
        '!help_page' => $help_page_url,
      ));
      break;
  }
  return $help_text;
}