[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/system/skipto/ -> skipto.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  System.skipto
   6   *
   7   * @copyright   (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9  
  10   * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
  11   */
  12  
  13  use Joomla\CMS\Application\CMSApplicationInterface;
  14  use Joomla\CMS\Language\Text;
  15  use Joomla\CMS\Plugin\CMSPlugin;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Skipto plugin to add accessible keyboard navigation to the site and administrator templates.
  23   *
  24   * @since  4.0.0
  25   */
  26  class PlgSystemSkipto extends CMSPlugin
  27  {
  28      /**
  29       * Application object.
  30       *
  31       * @var    CMSApplicationInterface
  32       * @since  4.0.0
  33       */
  34      protected $app;
  35  
  36      /**
  37       * Add the skipto navigation menu.
  38       *
  39       * @return  void
  40       *
  41       * @since   4.0.0
  42       */
  43      public function onAfterDispatch()
  44      {
  45          $section = $this->params->get('section', 'administrator');
  46  
  47          if ($section !== 'both' && $this->app->isClient($section) !== true) {
  48              return;
  49          }
  50  
  51          // Get the document object.
  52          $document = $this->app->getDocument();
  53  
  54          if ($document->getType() !== 'html') {
  55              return;
  56          }
  57  
  58          // Are we in a modal?
  59          if ($this->app->input->get('tmpl', '', 'cmd') === 'component') {
  60              return;
  61          }
  62  
  63          // Load language file.
  64          $this->loadLanguage();
  65  
  66          // Add plugin settings and strings for translations in JavaScript.
  67          $document->addScriptOptions(
  68              'skipto-settings',
  69              [
  70                  'settings' => [
  71                      'skipTo' => [
  72                          // Feature switches
  73                          'enableActions'               => false,
  74                          'enableHeadingLevelShortcuts' => false,
  75  
  76                          // Customization of button and menu
  77                          'accesskey'     => '9',
  78                          'displayOption' => 'popup',
  79  
  80                          // Button labels and messages
  81                          'buttonLabel'            => Text::_('PLG_SYSTEM_SKIPTO_TITLE'),
  82                          'buttonTooltipAccesskey' => Text::_('PLG_SYSTEM_SKIPTO_ACCESS_KEY'),
  83  
  84                          // Menu labels and messages
  85                          'landmarkGroupLabel'  => Text::_('PLG_SYSTEM_SKIPTO_LANDMARK'),
  86                          'headingGroupLabel'   => Text::_('PLG_SYSTEM_SKIPTO_HEADING'),
  87                          'mofnGroupLabel'      => Text::_('PLG_SYSTEM_SKIPTO_HEADING_MOFN'),
  88                          'headingLevelLabel'   => Text::_('PLG_SYSTEM_SKIPTO_HEADING_LEVEL'),
  89                          'mainLabel'           => Text::_('PLG_SYSTEM_SKIPTO_LANDMARK_MAIN'),
  90                          'searchLabel'         => Text::_('PLG_SYSTEM_SKIPTO_LANDMARK_SEARCH'),
  91                          'navLabel'            => Text::_('PLG_SYSTEM_SKIPTO_LANDMARK_NAV'),
  92                          'regionLabel'         => Text::_('PLG_SYSTEM_SKIPTO_LANDMARK_REGION'),
  93                          'asideLabel'          => Text::_('PLG_SYSTEM_SKIPTO_LANDMARK_ASIDE'),
  94                          'footerLabel'         => Text::_('PLG_SYSTEM_SKIPTO_LANDMARK_FOOTER'),
  95                          'headerLabel'         => Text::_('PLG_SYSTEM_SKIPTO_LANDMARK_HEADER'),
  96                          'formLabel'           => Text::_('PLG_SYSTEM_SKIPTO_LANDMARK_FORM'),
  97                          'msgNoLandmarksFound' => Text::_('PLG_SYSTEM_SKIPTO_LANDMARK_NONE'),
  98                          'msgNoHeadingsFound'  => Text::_('PLG_SYSTEM_SKIPTO_HEADING_NONE'),
  99  
 100                          // Selectors for landmark and headings sections
 101                          'headings'  => 'h1, h2, h3',
 102                          'landmarks' => 'main, nav, search, aside, header, footer, form',
 103                      ],
 104                  ],
 105              ]
 106          );
 107  
 108          /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
 109          $wa = $document->getWebAssetManager();
 110          $wa->useScript('skipto');
 111      }
 112  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer