Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made feedback & accessibility redirection from backend #4

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions administrator/language/en-GB/plg_system_accessibility.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ PLG_SYSTEM_ACCESSIBILITY_DECREASE_TEXT="Decrease Text Size"
PLG_SYSTEM_ACCESSIBILITY_EMOJIS="Icons"
PLG_SYSTEM_ACCESSIBILITY_EMOJIS_FALSE="Use Google Material Font"
PLG_SYSTEM_ACCESSIBILITY_EMOJIS_TRUE="Use Emojis"
PLG_SYSTEM_ACCESSIBILITY_FEEDBACK_REDIRECTION_LINK="Feedback Redirection Link"
PLG_SYSTEM_ACCESSIBILITY_FEEDBACK_REDIRECTION_LINK_DESC="User will be redirected to this link in case they want to give feedback regarding the accessibility of the website"
PLG_SYSTEM_ACCESSIBILITY_GREY="Grey Hues"
PLG_SYSTEM_ACCESSIBILITY_INCREASE_SPACING="Increase Text Spacing"
PLG_SYSTEM_ACCESSIBILITY_INCREASE_TEXT="Increase Text Size"
Expand All @@ -22,6 +24,8 @@ PLG_SYSTEM_ACCESSIBILITY_SECTION="Site Section"
PLG_SYSTEM_ACCESSIBILITY_SECTION_ADMIN="Administrator (Backend)"
PLG_SYSTEM_ACCESSIBILITY_SECTION_BOTH="Both"
PLG_SYSTEM_ACCESSIBILITY_SECTION_SITE="Site (Frontend)"
PLG_SYSTEM_ACCESSIBILITY_STATEMENT="Accessibility Statement"
PLG_SYSTEM_ACCESSIBILITY_STATEMENT_DESC="This will be displayed to the user as the Accessibility Statement of the website"
PLG_SYSTEM_ACCESSIBILITY_STT="Speech to Text"
PLG_SYSTEM_ACCESSIBILITY_TTS="Text to Speech"
PLG_SYSTEM_ACCESSIBILITY_UNDERLINE="Underline Links"
Expand Down
51 changes: 51 additions & 0 deletions plugins/system/accessibility/accessibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
*/

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Router\Route;




// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -39,6 +44,38 @@ class PlgSystemAccessibility extends CMSPlugin
*
* @since 4.0.0
*/
private function getAccessibilityFeedbackItemId()
{
$itemId = $this->params->get('feedback_redirection_link');

if ($itemId > 0 && Associations::isEnabled()) {
$feedbackAssociated = Associations::getAssociations('com_menus', '#__menu', 'com_menus.item', $itemId, 'id', '', '');
$currentLang = Factory::getLanguage()->getTag();

if (isset($feedbackAssociated[$currentLang])) {
$itemId = $feedbackAssociated[$currentLang]->id;
}
}

return $itemId;
}

private function getAccessibilityStatementItemId()
{
$itemId = $this->params->get('accessibility_statement');

if ($itemId > 0 && Associations::isEnabled()) {
$statementAssociated = Associations::getAssociations('com_menus', '#__menu', 'com_menus.item', $itemId, 'id', '', '');
$currentLang = Factory::getLanguage()->getTag();

if (isset($statementAssociated[$currentLang])) {
$itemId = $statementAssociated[$currentLang]->id;
}
}

return $itemId;
}

public function onBeforeCompileHead()
{
$section = $this->params->get('section', 'administrator');
Expand Down Expand Up @@ -68,6 +105,14 @@ public function onBeforeCompileHead()
// Detect the current active language
$lang = Factory::getLanguage()->getTag();

// Get the item id of the menu item for feedback redirection and accessibility statement
$feedbackMenuItemId = $this->getAccessibilityFeedbackItemId();
$statementMenuItemId = $this->getAccessibilityStatementItemId();

//generate the urls to pass it to the accessibility script
$feedbackUrl = Route::link('site', 'index.php?Itemid=' . $feedbackMenuItemId);
$statementUrl = Route::link('site', 'index.php?Itemid=' . $statementMenuItemId);

/**
* Add strings for translations in Javascript.
* Reference https://ranbuch.github.io/accessibility/
Expand Down Expand Up @@ -104,6 +149,12 @@ public function onBeforeCompileHead()
'enabled' => true,
'helpTitles' => true,
],
'statement' => [
'url' => isset($feedbackMenuItemId) ? $statementUrl : ''
],
'feedback' => [
'url' => isset($statementMenuItemId) ? $feedbackUrl : ''
],
'textToSpeechLang' => [$lang],
'speechToTextLang' => [$lang],
]
Expand Down
28 changes: 28 additions & 0 deletions plugins/system/accessibility/accessibility.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@
<option value="true">PLG_SYSTEM_ACCESSIBILITY_EMOJIS_TRUE</option>
<option value="false">PLG_SYSTEM_ACCESSIBILITY_EMOJIS_FALSE</option>
</field>
<field
addfieldprefix="Joomla\Component\Menus\Administrator\Field"
name="feedback_redirection_link"
type="modal_menu"
label="PLG_SYSTEM_ACCESSIBILITY_FEEDBACK_REDIRECTION_LINK"
description="PLG_SYSTEM_ACCESSIBILITY_FEEDBACK_REDIRECTION_LINK_DESC"
disable="separator,alias,heading,url"
select="true"
new="true"
edit="true"
clear="true"
>
<option value="">JOPTION_SELECT_MENU_ITEM</option>
</field>
<field
addfieldprefix="Joomla\Component\Menus\Administrator\Field"
name="accessibility_statement"
type="modal_menu"
label="PLG_SYSTEM_ACCESSIBILITY_STATEMENT"
description="PLG_SYSTEM_ACCESSIBILITY_STATEMENT_DESC"
disable="separator,alias,heading,url"
select="true"
new="true"
edit="true"
clear="true"
>
<option value="">JOPTION_SELECT_MENU_ITEM</option>
</field>
</fieldset>
</fields>
</config>
Expand Down