diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..93adb3877d86df08253a790b596cf99004237294 --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# All in One Accessibility + +This module provides few options to make website WCAG & ADA Compliance. + +This module adds the scripts on all over the site. That script will +download additional script to provide ADA controls. + +The All In One Accessibility widget is developed to improve accessibility and +usability of your website. It uses the accessibility interface which handles UI +and design related adjustments. + +Enable wide array of people with disabilities to use your Drupal website +effectively with All In One Accessibility widget. It will integrate basic +accessibility features according to the WCAG 2.1 standards to make it accessible +to people with hearing or vision impairments, cognitive impairments, and +perception problems. + +For a full description of the module, visit the +[project page](https://www.drupal.org/project/all_in_one_accessibility). + +Submit bug reports and feature suggestions, or track changes in the +[issue queue](https://www.drupal.org/project/issues/all_in_one_accessibility). + + +## Table of contents + +- Configuration +- Requirements +- Installation +- Maintainers + + + +## Configuration + +- Configure user permissions in Administration » People » Permissions +- Visit All in One Accessiblity +- Users in roles with "Add ADA Tool/SCript all over the site" + permission can add/remove the Tool/SCript from entire website. +- Update color of ADA widget as per website theme in settings on the + Administer -> Configuration -> Development -> All in One + Accesiblity Page. + + +## Requirements + +* This module requires no modules outside of Drupal core. + + +## Installation + +Install as you would normally install a contributed Drupal module. For further +information, see +[Installing Drupal Modules](https://www.drupal.org/docs/extending-drupal/installing-drupal-modules). + + +## Maintainers: + +- [Rajesh Bhimani](https://www.drupal.org/u/rajesh-bhimani) + +Supporting organizations: + +* [Skynet Technologies USA LLC](https://www.skynettechnologies.com) diff --git a/README.txt b/README.txt index e147f98af2cf461b0b7b9227650577fa93c4d5f4..804114dcf6cb68af43a558b62776fdbb6c1c5ed5 100644 --- a/README.txt +++ b/README.txt @@ -1,31 +1,43 @@ # All in One Accessiblity + ## Description This module provides few options to make website WCAG & ADA Compliance. -This module adds the scripts on all over the site. That script will download additional script to provide ADA controls. +This module adds the scripts on all over the site. That script will +download additional script to provide ADA controls. ## CONFIGURATION -* Configure user permissions in Administration » People » Permissions - - * Access All in One Accessiblity - - Users in roles with "Add ADA Tool/SCript all over the site" permission can - add / remove the Tool/SCript from entire website. + - Configure user permissions in Administration » People » Permissions + + - Access All in One Accessiblity + + Users in roles with "Add ADA Tool/Script all over the site" + permission can add / remove the Tool/Script from entire website. -* Update color of ADA widget as per website theme in settings on the Administer -> Configuration -> - Development -> All in One Accesiblity Page. + - Update color of ADA widget as per website theme in settings on the + Administer -> Configuration -> Development -> All in One + Accesiblity Page. ## MAINTAINERS -Current maintainers: - * Rajesh Bhimani (Skynet Technologies) - https://www.drupal.org/user/3479403 - - -This project has been sponsored by: - * Skynet technologies - Skynet Technologies is ISO 9001:2015 & 27001:2013 certified company providing end-to-end IT Services including Website Design & Development, ecommerce shopping cart, SEO & Digital Marketing, ADA Website Design, Custom Analytics, Mobile App, CRM, ERP & Custom Software Development for 19 years. We deliver our services to Start-Ups, SMEs, Corporates, Government & Agencies. - - Our headquarter is in Amelia, Ohio. Also, We have subsidiaries in the USA (Nevada, Florida), India, and Australia. We are providing solutions for small to large businesses, enterprises, corporations, web development agencies, and firms. We believe in the customer-first approach. We go above and beyond to meet the tailored needs of our customers. Our primary aim is to serve our customers by allowing them to do a successful and profitable business with us online. - Visit https://www.skynettechnologies.com for more information. +Current maintainers: * Rajesh Bhimani (Skynet Technologies) - +<https://www.drupal.org/user/3479403> + +This project has been sponsored by: * Skynet technologies Skynet +Technologies is ISO 9001:2015 & 27001:2013 certified company providing +end-to-end IT Services including Website Design & Development, ecommerce +shopping cart, SEO & Digital Marketing, ADA Website Design, Custom +Analytics, Mobile App, CRM, ERP & Custom Software Development for 19 +years. We deliver our services to Start-Ups, SMEs, Corporates, +Government & Agencies. + +Our headquarter is in Amelia, Ohio. Also, We have subsidiaries in the +USA (Nevada, Florida), India, and Australia. We are providing solutions +for small to large businesses, enterprises, corporations, web +development agencies, and firms. We believe in the customer-first +approach. We go above and beyond to meet the tailored needs of our +customers. Our primary aim is to serve our customers by allowing them to +do a successful and profitable business with us online. Visit +<https://www.skynettechnologies.com> for more information. \ No newline at end of file diff --git a/all_in_one_accessibility.info.yml b/all_in_one_accessibility.info.yml index 6907f15316bdd577b40c74575497669a88cd561f..700efd9c5248acf3cf5eb2a713831fe8f9a935f9 100644 --- a/all_in_one_accessibility.info.yml +++ b/all_in_one_accessibility.info.yml @@ -1,10 +1,10 @@ name: All in One Accessibility -description: Web Accessibility Solution for WCAG & ADA Compliance. -package: AIOS_SKYNET +description: All in One Accessibility widget improves Drupal website ADA compliance and browser experience for ADA, WCAG 2.1, Section 508, Australian DDA, European EAA EN 301 549, UK Equality Act (EA), Israeli Standard 5568, California Unruh, Ontario AODA, Canada ACA, German BITV, and France RGAA Standards. +package: Accessibility type: module core: 8.x core_version_requirement: ^8 || ^9 || ^10 configure: all_in_one_accessibility.admin.allinoneaccessiblity -version: '1.0.0' +version: '1.5.2' project: 'all_in_one_accessibility' -datestamp: 1645791935 +datestamp: 1695380848 \ No newline at end of file diff --git a/all_in_one_accessibility.module b/all_in_one_accessibility.module index a377113763eab52de051cab5473bfe1b280c7c79..74e4dee35ee2ce5c17ea53e54bbbc1b3b8e8e732 100644 --- a/all_in_one_accessibility.module +++ b/all_in_one_accessibility.module @@ -9,6 +9,8 @@ use Drupal\Core\Render\Markup; use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\HttpFoundation\Request; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Extension\InfoParser; + /** * Implements hook_help(). */ @@ -28,40 +30,38 @@ function all_in_one_accessibility_help($route_name, RouteMatchInterface $route_m function all_in_one_accessibility_library_info_build() { + $aioa_path = \Drupal::service('extension.list.module')->getPath('all_in_one_accessibility') . '/all_in_one_accessibility.info.yml'; + $aioa_info_parse = new InfoParser(); + $aioa_info = $aioa_info_parse->parse($aioa_path); + $aioa_info_version = str_replace(".", "", $aioa_info['version']); + $allinone_userid = \Drupal::config('all_in_one_accessibility.userid.settings')->get(); $libraries = []; if (!\Drupal::service('router.admin_context')->isAdminRoute()) { $url = "https://www.skynettechnologies.com/add-ons/license-api.php?"; - if (!isset($allinone_userid["userid"])) { - $allinone_userid["userid"] = ""; - } - - $postdata['token'] = $allinone_userid["userid"]; - $postdata['SERVER_NAME'] = $_SERVER['SERVER_NAME']; - $curl = curl_init($url); - curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - $resp = curl_exec($curl); - $resp = json_decode($resp); - - if(!isset($allinone_userid["colorcode"])) - { - $allinone_userid["colorcode"] = ""; - } - $baseURL = "https://www.skynettechnologies.com/accessibility/js/".(!empty($resp->accessibilityloader) ? $resp->accessibilityloader : "accessibility-free-version-loader.js"); + if (!empty($allinone_userid["userid"]) || $aioa_info_version <= 151) { - if (strpos($_SERVER['HTTP_USER_AGENT'], "Chrome-Lighthouse") === false) { - $libraries['ada_lib'] = [ - 'js' => [ $baseURL.'?colorcode='.$allinone_userid["colorcode"]. "&token=". $postdata['token']."&position=". $allinone_userid["position"] => [ - "attributes" => ['id' => 'adajs'], + if(!isset($allinone_userid["colorcode"])) + { + $allinone_userid["colorcode"] = ""; + } + if (!isset($allinone_userid["aioa_icon_type"]) || empty($allinone_userid["aioa_icon_type"])) { + $allinone_userid["aioa_icon_type"] = "aioa-icon-type-1"; + } + if (!isset($allinone_userid["aioa_icon_size"]) || empty($allinone_userid["aioa_icon_size"])) { + $allinone_userid["aioa_icon_size"] = "aioa-default-icon"; + } + $baseURL = "https://www.skynettechnologies.com/accessibility/js/all-in-one-accessibility-js-widget-minify.js"; + if (strpos($_SERVER['HTTP_USER_AGENT'], "Chrome-Lighthouse") === false) { + $libraries['ada_lib'] = [ + 'js' => [ $baseURL.'?colorcode='.$allinone_userid["colorcode"]. "&token=". $allinone_userid["userid"]."&t=".rand(9999,9999999)."&position=". $allinone_userid["position"].".". $allinone_userid["aioa_icon_type"] . "." . $allinone_userid["aioa_icon_size"] => [ + "attributes" => ['id' => 'aioa-adawidget'], + ], ], - ], - ]; + ]; + } } } return $libraries; diff --git a/src/Form/UseridForm.php b/src/Form/UseridForm.php index fb4d2751d3d0d0887a8c284a7736b8aa474a9b18..696be5b735be5a8e4211ddb8e2dc208ef7b2e5da 100644 --- a/src/Form/UseridForm.php +++ b/src/Form/UseridForm.php @@ -1,10 +1,11 @@ <?php namespace Drupal\all_in_one_accessibility\Form; - use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\HttpFoundation\Request; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Extension\InfoParser; +use Drupal\Core\Url; /** * Provide settings page for adding CSS/JS before the end of body tag. @@ -29,45 +30,174 @@ class UseridForm extends ConfigFormBase { * Implements FormBuilder::buildForm. */ public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) { - $allinone_userid = $this->config('all_in_one_accessibility.userid.settings')->get(); + $aioa_path = \Drupal::service('extension.list.module')->getPath('all_in_one_accessibility') . '/all_in_one_accessibility.info.yml'; + $aioa_info_parse = new InfoParser(); + $aioa_info = $aioa_info_parse->parse($aioa_path); + $aioa_info_version = str_replace(".", "", $aioa_info['version']); + $aioa_host_info = \Drupal::request()->getHost(); + $allinone_userid = $this->config('all_in_one_accessibility.userid.settings')->get(); $form['allinone']['userid'] = [ '#type' => 'textfield', '#title' => $this->t('License Key'), '#default_value' => isset($allinone_userid['userid']) ? $allinone_userid['userid'] : '', - '#description' => empty($allinone_userid['userid']) ? $this->t('<p>You are currently using Free version which have limited features. </br>Please <a href="https://www.skynettechnologies.com/add-ons/product/all-in-one-accessibility/">Sign up</a> and get License Key for additional features on the ADA Widget.</p>') : '', + '#description' => empty($allinone_userid['userid']) ? $this->t('Please <a href="https://ada.skynettechnologies.us/trial-subscription?utm_source='. $aioa_host_info .'&utm_medium=drupal-module&utm_campaign=trial-subscription" target="_blank">subscribe</a> for a 10 days free trial and receive a license key to enable 52+ features of All in One Accessibility Pro.<br>No payment charged upfront, Cancel anytime.') : '', '#rows' => 10, ]; - - $form['allinone']['colorcode'] = [ - '#type' => 'textfield', - '#title' => $this->t('Hex color code'), - '#default_value' => isset($allinone_userid['colorcode']) ? $allinone_userid['colorcode'] : '', - '#description' => $this->t('<p>You can cutomize the ADA Widget color. For example: #FF5733'), - '#rows' => 10, + $form['allinone']['nofreeversion'] = [ + '#type' => 'hidden', + '#default_value' => 1 ]; + if($aioa_info_version <= 151 || !empty($allinone_userid['userid'])){ + $form['allinone']['colorcode'] = [ + '#type' => 'textfield', + '#title' => $this->t('Hex color code'), + '#default_value' => isset($allinone_userid['colorcode']) ? $allinone_userid['colorcode'] : '', + '#description' => $this->t('<p>You can cutomize the ADA Widget color. For example: #FF5733'), + '#rows' => 10, + ]; - $options = array( - 'top_left' => $this->t('Top left'), - 'top_center' => $this->t('Top Center'), - 'top_right' => $this->t('Top Right'), - 'middel_left' => $this->t('Middle left'), - 'middel_right' => $this->t('Middle Right'), - 'bottom_left' => $this->t('Bottom left'), - 'bottom_center' => $this->t('Bottom Center'), - 'bottom_right' => $this->t('Bottom Right') - ); - - $form['allinone']['position'] = [ - '#type' => 'radios', - '#title' => $this->t('Where would you like to place the accessibility icon on your site?'), - '#options' => $options, - '#default_value' => isset($allinone_userid['position']) ? $allinone_userid['position'] : 'bottom_right', - ]; + $options = array( + 'bottom_right' => $this->t('Bottom Right'), + 'bottom_left' => $this->t('Bottom left'), + 'bottom_center' => $this->t('Bottom Center'), + 'middel_left' => $this->t('Middle left'), + 'middel_right' => $this->t('Middle Right'), + 'top_left' => $this->t('Top left'), + 'top_center' => $this->t('Top Center'), + 'top_right' => $this->t('Top Right') + ); + + $form['allinone']['position'] = [ + '#type' => 'radios', + '#title' => $this->t('Where would you like to place the accessibility icon on your site?'), + '#options' => $options, + '#default_value' => isset($allinone_userid['position']) ? $allinone_userid['position'] : 'bottom_right', + ]; + } + if(!empty($allinone_userid['userid'])){ + $options1 = array( + 'aioa-icon-type-1' => $this->t('<img class="aioaicontype" src="https://www.skynettechnologies.com/sites/default/files/python/aioa-icon-type-1.svg" width="65" height="65" />'), + 'aioa-icon-type-2' => $this->t('<img class="aioaicontype" src="https://www.skynettechnologies.com/sites/default/files/python/aioa-icon-type-2.svg" width="65" height="65" />'), + 'aioa-icon-type-3' => $this->t('<img class="aioaicontype" src="https://www.skynettechnologies.com/sites/default/files/python/aioa-icon-type-3.svg" width="65" height="65" />'), + ); + if(!isset($allinone_userid['aioa_icon_type'])) + { + $allinone_userid['aioa_icon_type'] = "aioa-icon-type-1"; + } + $form['allinone']['aioa_icon_type'] = [ + '#type' => 'radios', + '#title' => $this->t('Select Icon Type:'), + '#options' => $options1, + '#default_value' => isset($allinone_userid['aioa_icon_type']) ? $allinone_userid['aioa_icon_type'] : 'aioa-icon-type-1', + ]; + + if (!isset($allinone_userid['aioa_icon_size'])) { + $allinone_userid['aioa_icon_size'] = "aioa-default-icon"; + } + $options2 = array( + 'aioa-big-icon' => $this->t('<img class="aioaiconsize" src="https://www.skynettechnologies.com/sites/default/files/python/'.$allinone_userid['aioa_icon_type'].'.svg" width="75" height="75" />'), + 'aioa-medium-icon' => $this->t('<img class="aioaiconsize" src="https://www.skynettechnologies.com/sites/default/files/python/' . $allinone_userid['aioa_icon_type'] . '.svg" width="65" height="65" />'), + 'aioa-default-icon' => $this->t('<img class="aioaiconsize" src="https://www.skynettechnologies.com/sites/default/files/python/' . $allinone_userid['aioa_icon_type'] . '.svg" width="55" height="55" />'), + 'aioa-small-icon' => $this->t('<img class="aioaiconsize" src="https://www.skynettechnologies.com/sites/default/files/python/' . $allinone_userid['aioa_icon_type'] . '.svg" width="45" height="45" />'), + 'aioa-extra-small-icon' => $this->t('<img class="aioaiconsize" src="https://www.skynettechnologies.com/sites/default/files/python/' . $allinone_userid['aioa_icon_type'] . '.svg" width="35" height="35" />'), + ); + + $form['allinone']['aioa_icon_size'] = [ + '#type' => 'radios', + '#title' => $this->t('Select Icon Size:'), + '#options' => $options2, + '#default_value' => isset($allinone_userid['aioa_icon_size']) ? $allinone_userid['aioa_icon_size'] : 'aioa-icon-type-1', + '#description' => $this->t('<script> + const sizeOptionsImg = document.querySelectorAll(".aioaiconsize"); + const typeOptions = document.querySelectorAll("input[name=\'aioa_icon_type\']"); + typeOptions.forEach(option => { + option.addEventListener("change", (event) => { + sizeOptionsImg.forEach(option2 => { + var ico_type = document.querySelector("input[name=\'aioa_icon_type\']:checked").value; + option2.setAttribute("src", "https://www.skynettechnologies.com/sites/default/files/python/" + ico_type + ".svg"); + }); + }); + }); + </script> + <style> + /* Radio Button Css */ + #edit-aioa-icon-type input, + #edit-aioa-icon-size input { + position: absolute; + left: -9999px; + } + #edit-aioa-icon-type .form-item, + #edit-aioa-icon-size .form-item { + margin-left: 0; + } + #edit-aioa-icon-type input[type=radio]+label, + #edit-aioa-icon-size input[type=radio]+label { + width: 130px; + height: 130px; + padding: 10px !important; + text-align: center; + background-color: #f7f9ff; + outline: 4px solid #f7f9ff; + outline-offset: -4px; + border-radius: 10px; + display: flex; + align-items: center; + justify-content: center; + margin-left: 12px; + margin-right: 12px; + } + #edit-aioa-icon-type input[type=radio]:checked+label, + #edit-aioa-icon-size input[type=radio]:checked+label { + outline-color: #80c944; + position: relative; + } + #edit-aioa-icon-type input[type=radio]:checked+label::before, + #edit-aioa-icon-size input[type=radio]:checked+label::before { + content: ""; + width: 20px; + height: 20px; + position: absolute; + left: auto; + right: -4px; + top: -4px; + background: url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 25 25\' class=\'aioa-feature-on\'%3E%3Cg%3E%3Ccircle fill=\'%2343A047\' cx=\'12.5\' cy=\'12.5\' r=\'12\'%3E%3C/circle%3E%3Cpath fill=\'%23FFFFFF\' d=\'M12.5,1C18.9,1,24,6.1,24,12.5S18.9,24,12.5,24S1,18.9,1,12.5S6.1,1,12.5,1 M12.5,0C5.6,0,0,5.6,0,12.5S5.6,25,12.5,25S25,19.4,25,12.5S19.4,0,12.5,0L12.5,0z\'%3E%3C/path%3E%3C/g%3E%3Cpolygon fill=\'%23FFFFFF\' points=\'9.8,19.4 9.8,19.4 9.8,19.4 4.4,13.9 7.1,11.1 9.8,13.9 17.9,5.6 20.5,8.4 \'%3E%3C/polygon%3E%3C/svg%3E") no-repeat center center/contain !important; + border: none; + } + /* IMAGE STYLES */ + #edit-aioa-icon-type label>img, + #edit-aioa-icon-size label>img { + cursor: pointer; + } + #edit-aioa-icon-type label, + #edit-aioa-icon-size label { + display: flex; + justify-content: center; + height: 90px; + width: 90px; + border: 2px solid gray; + border-radius: 3px; + } + + #edit-aioa-icon-type, + #edit-aioa-icon-size { + display: flex; + } + #edit-position { + max-width: 520px; + display: flex; + flex-wrap: wrap; + } + #edit-position .form-item{ + width: 33.33333%; + } + </style> ') + ]; + } return parent::buildForm($form, $form_state); } @@ -79,24 +209,78 @@ class UseridForm extends ConfigFormBase { public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); + $url = "https://www.skynettechnologies.com/add-ons/license-api.php?"; + $postdata['token'] = $values['userid']; + $postdata['SERVER_NAME'] = parse_url(Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString(), PHP_URL_HOST); + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + $resp = curl_exec($curl); + $resp = json_decode($resp); + + + if (empty($resp->accessibilityloader) && !empty(trim($values['userid']))) { + $values['userid'] = ""; + $values['aioa_icon_type'] = (!empty($values['aioa_icon_type']) ? $values['aioa_icon_type'] : "aioa-icon-type-1"); + $values['aioa_icon_size'] = (!empty($values['aioa_icon_size']) ? $values['aioa_icon_size'] : "aioa-default-icon"); + $this->messenger()->addStatus($this->t('Invalid License Key.')); + } else { + $this->messenger()->addStatus($this->t('Your Settings have been saved.')); + } + $this->configFactory() ->getEditable('all_in_one_accessibility.userid.settings') ->set('userid', $values['userid']) ->save(); $this->configFactory() - ->getEditable('all_in_one_accessibility.userid.settings') - ->set('colorcode', $values['colorcode']) - ->save(); + ->getEditable('all_in_one_accessibility.userid.settings') + ->set('colorcode', $values['colorcode']) + ->save(); + + $this->configFactory() + ->getEditable('all_in_one_accessibility.userid.settings') + ->set('position', $values['position']) + ->save(); + + $this->configFactory() + ->getEditable('all_in_one_accessibility.userid.settings') + ->set('aioa_icon_type', $values['aioa_icon_type']) + ->save(); + + $this->configFactory() + ->getEditable('all_in_one_accessibility.userid.settings') + ->set('aioa_icon_size', $values['aioa_icon_size']) + ->save(); $this->configFactory() ->getEditable('all_in_one_accessibility.userid.settings') - ->set('position', $values['position']) + ->set('nofreeversion', $values['nofreeversion']) ->save(); - - $this->messenger()->addStatus($this->t('Your Settings have been saved.')); - drupal_flush_all_caches(); + $curl = curl_init(); + curl_setopt_array($curl, array( + CURLOPT_URL => 'https://ada.skynettechnologies.us/api/widget-setting-update-platform', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => array( + 'u' => Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString(), + 'widget_position' => $values['position'], + 'widget_color_code' => $values['colorcode'], + 'widget_icon_type' => (!empty($values['aioa_icon_type']) ? $values['aioa_icon_type'] : "aioa-icon-type-1"), + 'widget_icon_size' => (!empty($values['aioa_icon_size']) ? $values['aioa_icon_size'] : "aioa-medium-icon") + ), + )); + $response = curl_exec($curl); + curl_close($curl); + drupal_flush_all_caches(); } - }