Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libraries/src/Event/CoreEventAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ trait CoreEventAware
'onSchemaPrepareData' => Plugin\System\Schemaorg\PrepareDataEvent::class,
'onSchemaPrepareForm' => Plugin\System\Schemaorg\PrepareFormEvent::class,
'onSchemaPrepareSave' => Plugin\System\Schemaorg\PrepareSaveEvent::class,
// Plugin: Stats
'onGetStatsData' => Plugin\System\Stats\GetStatsDataEvent::class,
// Content
'onContentPrepare' => Content\ContentPrepareEvent::class,
'onContentAfterTitle' => Content\AfterTitleEvent::class,
Expand Down
94 changes: 94 additions & 0 deletions libraries/src/Event/Plugin/System/Stats/GetStatsDataEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

/**
* Joomla! Content Management System
*
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\Event\Plugin\System\Stats;

use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\ReshapeArgumentsAware;
use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;
use Joomla\CMS\Event\Result\ResultTypeArrayAware;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
* Class for Stats plugin.
* Example:
* new GetStatsDataEvent('onEventName', ['context' => 'com_example.example']);
*
* @since __DEPLOY_VERSION__
*/
class GetStatsDataEvent extends AbstractImmutableEvent implements ResultAwareInterface
{
use ReshapeArgumentsAware;
use ResultAware;
use ResultTypeArrayAware;

/**
* The argument names, in order expected by legacy plugins.
*
* @var array
*
* @since __DEPLOY_VERSION__
* @deprecated __DEPLOY_VERSION__ will be removed in 6.0
*/
protected $legacyArgumentsOrder = ['context'];

/**
* Constructor.
*
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws \BadMethodCallException
*
* @since __DEPLOY_VERSION__
*/
public function __construct($name, array $arguments = [])
{
// Reshape the arguments array to preserve b/c with legacy listeners
if ($this->legacyArgumentsOrder) {
$arguments = $this->reshapeArguments($arguments, $this->legacyArgumentsOrder);
}

parent::__construct($name, $arguments);

if (!\array_key_exists('context', $this->arguments)) {
throw new \BadMethodCallException("Argument 'context' of event {$name} is required but has not been provided");
}
}

/**
* Setter for the context argument.
*
* @param string $value The value to set
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
protected function onSetContext(string $value): string
{
return $value;
}

/**
* Getter for the context argument.
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
public function getContext(): string
{
return $this->arguments['context'];
}
}
61 changes: 40 additions & 21 deletions plugins/system/accessibility/src/Extension/Accessibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

namespace Joomla\Plugin\System\Accessibility\Extension;

use Joomla\CMS\Event\Application\BeforeCompileHeadEvent;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Event\SubscriberInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -21,43 +23,60 @@
*
* @since 4.0.0
*/
final class Accessibility extends CMSPlugin
final class Accessibility extends CMSPlugin implements SubscriberInterface
{
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public static function getSubscribedEvents(): array
{
return [
'onBeforeCompileHead' => 'onBeforeCompileHead',
];
}

/**
* Add the javascript for the accessibility menu
*
* @param BeforeCompileHeadEvent $event The event object
*
* @return void
*
* @since 4.0.0
*/
public function onBeforeCompileHead()
public function onBeforeCompileHead(BeforeCompileHeadEvent $event): void
{
$section = $this->params->get('section', 'administrator');
$app = $event->getApplication();

if ($section !== 'both' && $this->getApplication()->isClient($section) !== true) {
if ($section !== 'both' && $app->isClient($section) !== true) {
return;
}

// Get the document object.
$document = $this->getApplication()->getDocument();
$document = $event->getDocument();

if ($document->getType() !== 'html') {
return;
}

// Are we in a modal?
if ($this->getApplication()->getInput()->get('tmpl', '', 'cmd') === 'component') {
if ($app->getInput()->get('tmpl', '', 'cmd') === 'component') {
return;
}

// Load language file.
$this->loadLanguage();

// Determine if it is an LTR or RTL language
$direction = $this->getApplication()->getLanguage()->isRtl() ? 'right' : 'left';
$direction = $app->getLanguage()->isRtl() ? 'right' : 'left';

// Detect the current active language
$lang = $this->getApplication()->getLanguage()->getTag();
$lang = $app->getLanguage()->getTag();

/**
* Add strings for translations in Javascript.
Expand All @@ -67,20 +86,20 @@ public function onBeforeCompileHead()
'accessibility-options',
[
'labels' => [
'menuTitle' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_MENU_TITLE'),
'increaseText' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_INCREASE_TEXT'),
'decreaseText' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_DECREASE_TEXT'),
'increaseTextSpacing' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_INCREASE_SPACING'),
'decreaseTextSpacing' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_DECREASE_SPACING'),
'invertColors' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_INVERT_COLORS'),
'grayHues' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_GREY'),
'underlineLinks' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_UNDERLINE'),
'bigCursor' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_CURSOR'),
'readingGuide' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_READING'),
'textToSpeech' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_TTS'),
'speechToText' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_STT'),
'resetTitle' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_RESET'),
'closeTitle' => $this->getApplication()->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_CLOSE'),
'menuTitle' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_MENU_TITLE'),
'increaseText' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_INCREASE_TEXT'),
'decreaseText' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_DECREASE_TEXT'),
'increaseTextSpacing' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_INCREASE_SPACING'),
'decreaseTextSpacing' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_DECREASE_SPACING'),
'invertColors' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_INVERT_COLORS'),
'grayHues' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_GREY'),
'underlineLinks' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_UNDERLINE'),
'bigCursor' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_CURSOR'),
'readingGuide' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_READING'),
'textToSpeech' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_TTS'),
'speechToText' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_STT'),
'resetTitle' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_RESET'),
'closeTitle' => $app->getLanguage()->_('PLG_SYSTEM_ACCESSIBILITY_CLOSE'),
],
'icon' => [
'position' => [
Expand Down
Loading