first commit
This commit is contained in:
46
plugins/system/skipto/services/provider.php
Normal file
46
plugins/system/skipto/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage System.skipto
|
||||
*
|
||||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\System\Skipto\Extension\Skipto;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
public function register(Container $container): void
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new Skipto(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('system', 'skipto')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
38
plugins/system/skipto/skipto.xml
Normal file
38
plugins/system/skipto/skipto.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="system" method="upgrade">
|
||||
<name>plg_system_skipto</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2020-02</creationDate>
|
||||
<copyright>(C) 2019 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>4.0.0</version>
|
||||
<description>PLG_SYSTEM_SKIPTO_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\System\Skipto</namespace>
|
||||
<files>
|
||||
<folder plugin="skipto">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_system_skipto.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_system_skipto.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="section"
|
||||
type="list"
|
||||
label="PLG_SYSTEM_SKIPTO_SECTION"
|
||||
default="administrator"
|
||||
validate="options"
|
||||
>
|
||||
<option value="site">PLG_SYSTEM_SKIPTO_SECTION_SITE</option>
|
||||
<option value="administrator">PLG_SYSTEM_SKIPTO_SECTION_ADMIN</option>
|
||||
<option value="both">PLG_SYSTEM_SKIPTO_SECTION_BOTH</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
102
plugins/system/skipto/src/Extension/Skipto.php
Normal file
102
plugins/system/skipto/src/Extension/Skipto.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage System.skipto
|
||||
*
|
||||
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\System\Skipto\Extension;
|
||||
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Skipto plugin to add accessible keyboard navigation to the site and administrator templates.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
final class Skipto extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Add the skipto navigation menu.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function onAfterDispatch()
|
||||
{
|
||||
$section = $this->params->get('section', 'administrator');
|
||||
|
||||
if ($section !== 'both' && $this->getApplication()->isClient($section) !== true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the document object.
|
||||
$document = $this->getApplication()->getDocument();
|
||||
|
||||
if ($document->getType() !== 'html') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Are we in a modal?
|
||||
if ($this->getApplication()->getInput()->get('tmpl', '', 'cmd') === 'component') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load language file.
|
||||
$this->loadLanguage();
|
||||
|
||||
// Add plugin settings and strings for translations in JavaScript.
|
||||
$document->addScriptOptions(
|
||||
'skipto-settings',
|
||||
[
|
||||
'settings' => [
|
||||
'skipTo' => [
|
||||
// Feature switches
|
||||
'enableActions' => false,
|
||||
'enableHeadingLevelShortcuts' => false,
|
||||
|
||||
// Customization of button and menu
|
||||
'accesskey' => '9',
|
||||
'displayOption' => 'popup',
|
||||
|
||||
// Button labels and messages
|
||||
'buttonLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_TITLE'),
|
||||
'buttonTooltipAccesskey' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_ACCESS_KEY'),
|
||||
|
||||
// Menu labels and messages
|
||||
'landmarkGroupLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_LANDMARK'),
|
||||
'headingGroupLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_HEADING'),
|
||||
'mofnGroupLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_HEADING_MOFN'),
|
||||
'headingLevelLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_HEADING_LEVEL'),
|
||||
'mainLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_LANDMARK_MAIN'),
|
||||
'searchLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_LANDMARK_SEARCH'),
|
||||
'navLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_LANDMARK_NAV'),
|
||||
'regionLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_LANDMARK_REGION'),
|
||||
'asideLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_LANDMARK_ASIDE'),
|
||||
'footerLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_LANDMARK_FOOTER'),
|
||||
'headerLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_LANDMARK_HEADER'),
|
||||
'formLabel' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_LANDMARK_FORM'),
|
||||
'msgNoLandmarksFound' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_LANDMARK_NONE'),
|
||||
'msgNoHeadingsFound' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_SKIPTO_HEADING_NONE'),
|
||||
|
||||
// Selectors for landmark and headings sections
|
||||
'headings' => 'h1, h2, h3',
|
||||
'landmarks' => 'main, nav, search, aside, header, footer, form',
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $document->getWebAssetManager();
|
||||
$wa->useScript('skipto');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user