[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Plugin 5 * @subpackage System.accessibility 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\Factory; 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 * System plugin to add additional accessibility features to the administrator interface. 23 * 24 * @since 4.0.0 25 */ 26 class PlgSystemAccessibility extends CMSPlugin 27 { 28 /** 29 * @var \Joomla\CMS\Application\CMSApplication 30 * 31 * @since 4.0.0 32 */ 33 protected $app; 34 35 /** 36 * Add the javascript for the accessibility menu 37 * 38 * @return void 39 * 40 * @since 4.0.0 41 */ 42 public function onBeforeCompileHead() 43 { 44 $section = $this->params->get('section', 'administrator'); 45 46 if ($section !== 'both' && $this->app->isClient($section) !== true) { 47 return; 48 } 49 50 // Get the document object. 51 $document = $this->app->getDocument(); 52 53 if ($document->getType() !== 'html') { 54 return; 55 } 56 57 // Are we in a modal? 58 if ($this->app->input->get('tmpl', '', 'cmd') === 'component') { 59 return; 60 } 61 62 // Load language file. 63 $this->loadLanguage(); 64 65 // Determine if it is an LTR or RTL language 66 $direction = Factory::getLanguage()->isRtl() ? 'right' : 'left'; 67 68 // Detect the current active language 69 $lang = Factory::getLanguage()->getTag(); 70 71 /** 72 * Add strings for translations in Javascript. 73 * Reference https://ranbuch.github.io/accessibility/ 74 */ 75 $document->addScriptOptions( 76 'accessibility-options', 77 [ 78 'labels' => [ 79 'menuTitle' => Text::_('PLG_SYSTEM_ACCESSIBILITY_MENU_TITLE'), 80 'increaseText' => Text::_('PLG_SYSTEM_ACCESSIBILITY_INCREASE_TEXT'), 81 'decreaseText' => Text::_('PLG_SYSTEM_ACCESSIBILITY_DECREASE_TEXT'), 82 'increaseTextSpacing' => Text::_('PLG_SYSTEM_ACCESSIBILITY_INCREASE_SPACING'), 83 'decreaseTextSpacing' => Text::_('PLG_SYSTEM_ACCESSIBILITY_DECREASE_SPACING'), 84 'invertColors' => Text::_('PLG_SYSTEM_ACCESSIBILITY_INVERT_COLORS'), 85 'grayHues' => Text::_('PLG_SYSTEM_ACCESSIBILITY_GREY'), 86 'underlineLinks' => Text::_('PLG_SYSTEM_ACCESSIBILITY_UNDERLINE'), 87 'bigCursor' => Text::_('PLG_SYSTEM_ACCESSIBILITY_CURSOR'), 88 'readingGuide' => Text::_('PLG_SYSTEM_ACCESSIBILITY_READING'), 89 'textToSpeech' => Text::_('PLG_SYSTEM_ACCESSIBILITY_TTS'), 90 'speechToText' => Text::_('PLG_SYSTEM_ACCESSIBILITY_STT'), 91 'resetTitle' => Text::_('PLG_SYSTEM_ACCESSIBILITY_RESET'), 92 'closeTitle' => Text::_('PLG_SYSTEM_ACCESSIBILITY_CLOSE'), 93 ], 94 'icon' => [ 95 'position' => [ 96 $direction => [ 97 'size' => '0', 98 'units' => 'px', 99 ], 100 ], 101 'useEmojis' => $this->params->get('useEmojis') != 'false' ? true : false, 102 ], 103 'hotkeys' => [ 104 'enabled' => true, 105 'helpTitles' => true, 106 ], 107 'textToSpeechLang' => [$lang], 108 'speechToTextLang' => [$lang], 109 ] 110 ); 111 112 $document->getWebAssetManager() 113 ->useScript('accessibility') 114 ->addInlineScript( 115 'window.addEventListener("load", function() {' 116 . 'new Accessibility(Joomla.getOptions("accessibility-options") || {});' 117 . '});', 118 ['name' => 'inline.plg.system.accessibility'], 119 ['type' => 'module'], 120 ['accessibility'] 121 ); 122 } 123 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |