From a380159f0e3617bde390a0b8531a4dabe435d88f Mon Sep 17 00:00:00 2001 From: TalesRG Date: Thu, 6 Mar 2025 18:07:15 -0300 Subject: [PATCH] chore : adiciona plugin para funcionamento do saberes 3.7 --- .idea/.gitignore | 8 + .idea/accessibility.iml | 8 + .idea/modules.xml | 8 + .idea/php.xml | 9 + CHANGELOG.txt | 28 ++ README.txt | 20 ++ block_accessibility.php | 349 +++++++++++++++++++ changecolour.php | 74 ++++ changesize.php | 120 +++++++ database.php | 121 +++++++ db/access.php | 50 +++ db/install.xml | 20 ++ db/upgrade.php | 130 +++++++ defaults.php | 25 ++ edit_form.php | 84 +++++ lang/de/block_accessibility.php | 64 ++++ lang/en/block_accessibility.php | 62 ++++ lang/es/block_accessibility.php | 64 ++++ lang/fr/block_accessibility.php | 67 ++++ lang/hr/block_accessibility.php | 70 ++++ lang/pt-br/block_accessibility.php | 69 ++++ lib.php | 125 +++++++ module.js | 532 +++++++++++++++++++++++++++++ pix/document-save-grey.png | Bin 0 -> 1077 bytes pix/document-save.png | Bin 0 -> 1150 bytes pix/loader.gif | Bin 0 -> 13440 bytes styles.css | 131 +++++++ userstyles.php | 188 ++++++++++ version.php | 38 +++ 29 files changed, 2464 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/accessibility.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 CHANGELOG.txt create mode 100644 README.txt create mode 100644 block_accessibility.php create mode 100644 changecolour.php create mode 100644 changesize.php create mode 100644 database.php create mode 100644 db/access.php create mode 100644 db/install.xml create mode 100644 db/upgrade.php create mode 100644 defaults.php create mode 100644 edit_form.php create mode 100644 lang/de/block_accessibility.php create mode 100644 lang/en/block_accessibility.php create mode 100644 lang/es/block_accessibility.php create mode 100644 lang/fr/block_accessibility.php create mode 100644 lang/hr/block_accessibility.php create mode 100644 lang/pt-br/block_accessibility.php create mode 100644 lib.php create mode 100644 module.js create mode 100644 pix/document-save-grey.png create mode 100644 pix/document-save.png create mode 100644 pix/loader.gif create mode 100644 styles.css create mode 100644 userstyles.php create mode 100644 version.php diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/accessibility.iml b/.idea/accessibility.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/accessibility.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..08065b2 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..2b95591 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100644 index 0000000..df39a8c --- /dev/null +++ b/CHANGELOG.txt @@ -0,0 +1,28 @@ +New in 2.2.3: +* Minor bugfixes + +New in 2.2.2: +* Moodle 2.8 support +* Various bugfixes and improvements + +New in 2.2.1: +* IE support improved +* Scaling of headings adjusted +* Disabling/enabling buttons within block fixed +* Javascript script improved +* Various bugfixes and improvements + +New in 2.2: +* Compatibility with "Clean" theme +* Full no-js support (Plugin architecture is now moved entirely into server-side) +* Major fixes from previous relases +* Croatian language added +* Block instance configuration form implemented + +New in version 2.1.5: +* Fixed long-standing CSS inclusion bug, thanks to AviMoto + +New in version 2.1: +* Updated ATBar +* Added French Translation +* Various bug fixes diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..2834aac --- /dev/null +++ b/README.txt @@ -0,0 +1,20 @@ +Accessibility Block for Moodle + +Provides options for changing text size and colour scheme. Settings can be saved to persist between sessions. Colour settings can be defined at the block instance level (Block instance configuration). + +Also integrates ATbar from Southampton University ECS http://www.atbar.org. Code used under BSD Licence. + +To install, place all files in /blocks/accessibility/ directory and visit /admin/index.php in your browser. To achieve block appearance throughout entire Moodle site (so-called "Sticky block") once the plugin is installed into Moodle, it's recommended to add its instance onto the Moodle homepage (/index.php). Homepage instance of the block enables "Page contexts" option in block instance configuration to be set to "Display throughout entire site". + +This block was initially written by Mark Johnson +It is copyright of Mark Johnson, Richard Taunton's Sixth Form College and contributors. + +Developers can find the documentation here: https://drive.google.com/folderview?id=0BwrUG2o1JsD_bGo2S3hJNXFDd28&usp=sharing + +Translations are copyright of their respective authors, as indicated in each language file. + +Current languages are English, German, Spanish, Portuguese, Croatian and French. If you're +interested in adding a translation please raise a bug on Github +https://github.com/marxjohnson/moodle-block_accessibility/issues + +Released Under the GNU General Public Licence http://www.gnu.org/copyleft/gpl.html diff --git a/block_accessibility.php b/block_accessibility.php new file mode 100644 index 0000000..a2c4ffc --- /dev/null +++ b/block_accessibility.php @@ -0,0 +1,349 @@ +. + +/** + * Define the accessibility block's class + * + * @package block_accessibility + * @author Mark Johnson + * @copyright 2010 Tauntons College, UK + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); +require_once($CFG->dirroot . '/blocks/accessibility/lib.php'); + +/** + * accessibility Block's class + */ +class block_accessibility extends block_base { + + const JS_URL = '/blocks/accessibility/module.js'; + const CSS_URL = '/blocks/accessibility/userstyles.php'; + const FONTSIZE_URL = '/blocks/accessibility/changesize.php'; + const COLOUR_URL = '/blocks/accessibility/changecolour.php'; + const DB_URL = '/blocks/accessibility/database.php'; + + /** + * Set the title and include the stylesheet + * + * We need to include the stylesheet here rather than in {@see get_content()} since get_content + * is sometimes called after $OUTPUT->heading(), e.g. such as /user/index.php where the middle + * region is hard-coded. + * However, /admin/plugins.php calls init() for each plugin after $OUTPUT->heading(), so the + * sheet is not included at all on that page. + */ + public function init() { + $this->title = get_string('pluginname', 'block_accessibility'); + } + + /** + * Called after init(). Here we have instance id so we can use config for specific instance + * The function will include CSS declarations into Moodle Page + * CSS declarations will be generated according to user settings and instance configuration + * + */ + public function specialization() { + $instanceid = $this->instance->id; + + if (!$this->page->requires->is_head_done()) { + + // Link default/saved settings to a page. + // Each block instance has it's own configuration form, so we need instance id. + $cssurl = self::CSS_URL . '?instance_id=' . $instanceid; + $this->page->requires->css($cssurl); + } + } + + /** + * instance_allow_multiple explicitly tells there cannot be multiple + * block instance on the same page + * + */ + public function instance_allow_multiple() { + return false; + } + + /** + * Set where the block should be allowed to be added + * + * @return array + */ + public function applicable_formats() { + return array('all' => true); + } + + /** + * Generate the contents for the block + * + * @return object Block contents and footer + */ + public function get_content() { + global $USER; + global $FULLME; + global $DB; + + // Until Issue #63 is fixed, we don't want to display block for unauthenticated users. + if (!isloggedin()) { + return null; + } + + if ($this->content !== null) { + return $this->content; + } + + // Get the current page url (redirection after action when no Javascript). + $params = array('redirect' => $FULLME); + + // Set block services paths: changesize.php, changecolour.php and database.php. + $sizeurl = new moodle_url(self::FONTSIZE_URL, $params); + $coloururl = new moodle_url(self::COLOUR_URL, $params); + + $params['op'] = 'save'; + $params['size'] = true; + $params['scheme'] = true; + $dburl = new moodle_url(self::DB_URL, $params); + + // Initialization of increase_font, decrease_font and save button. + $incattrs = array( + 'title' => get_string('inctext', 'block_accessibility'), + 'id' => "block_accessibility_inc", + 'href' => $sizeurl->out(false, array('op' => 'inc')) + ); + $decattrs = array( + 'title' => get_string('dectext', 'block_accessibility'), + 'id' => "block_accessibility_dec", + 'href' => $sizeurl->out(false, array('op' => 'dec')) + ); + $saveattrs = array( + 'title' => get_string('save', 'block_accessibility'), + 'id' => "block_accessibility_save", + 'href' => $dburl->out(false) + ); + + // Initialization of reset button. + $resetattrs = array( + 'id' => 'block_accessibility_reset', + 'title' => get_string('resettext', 'block_accessibility'), + 'href' => $sizeurl->out(false, array('op' => 'reset')) + ); + + // If any of increase/decrease buttons reached maximum size, disable it. + if (isset($USER->fontsize)) { + if ($USER->fontsize == MIN_FONTSIZE) { + $decattrs['class'] = 'disabled'; + unset($decattrs['href']); + } + if ($USER->fontsize == MAX_FONTSIZE) { + $incattrs['class'] = 'disabled'; + unset($incattrs['href']); + } + } else { + // Or disable reset button. + $resetattrs['class'] = 'disabled'; + } + + // Initialization of scheme profiles buttons. + $c1attrs = array( + 'title' => get_string('col1text', 'block_accessibility'), + 'id' => 'block_accessibility_colour1', + 'href' => $coloururl->out(false, array('scheme' => 1)) + ); + $c2attrs = array( + 'title' => get_string('col2text', 'block_accessibility'), + 'id' => 'block_accessibility_colour2', + 'href' => $coloururl->out(false, array('scheme' => 2)) + ); + $c3attrs = array( + 'title' => get_string('col3text', 'block_accessibility'), + 'id' => 'block_accessibility_colour3', + 'href' => $coloururl->out(false, array('scheme' => 3)) + ); + $c4attrs = array( + 'title' => get_string('col4text', 'block_accessibility'), + 'id' => 'block_accessibility_colour4', + 'href' => $coloururl->out(false, array('scheme' => 4)) + ); + + if (!isset($USER->colourscheme)) { + $c1attrs['class'] = 'disabled'; + } + + // The display:inline-block CSS declaration is not applied to block's buttons because IE7 doesn't support, float is + // used instead for IE7 only. + $clearfix = ''; + if (preg_match('/(?i)msie [1-7]/', $_SERVER['HTTP_USER_AGENT'])) { + $clearfix = html_writer::tag('div', '', array('style' => 'clear:both')); // Required for IE7. + } + + // Render block HTML. + $content = ''; + + $strchar = get_string('char', 'block_accessibility'); + $resetchar = "R"; + $divattrs = array('id' => 'accessibility_controls', 'class' => 'content'); + $listattrs = array('id' => 'block_accessibility_textresize', 'class' => 'button_row'); + + $content .= html_writer::start_tag('div', $divattrs); + $content .= html_writer::start_tag('ul', $listattrs); + + $content .= html_writer::start_tag('li', array('class' => 'access-button')); + $content .= html_writer::tag('a', $strchar . '-', $decattrs); + $content .= html_writer::end_tag('li'); + + $content .= html_writer::start_tag('li', array('class' => 'access-button')); + $content .= html_writer::tag('a', $strchar, $resetattrs); + $content .= html_writer::end_tag('li'); + + $content .= html_writer::start_tag('li', array('class' => 'access-button')); + $content .= html_writer::tag('a', $strchar . '+', $incattrs); + $content .= html_writer::end_tag('li'); + + $content .= html_writer::start_tag('li', array('class' => 'access-button')); + $content .= html_writer::tag('a', ' ', $saveattrs); + $content .= html_writer::end_tag('li'); + + $content .= html_writer::end_tag('ul'); + + $content .= $clearfix; + + // Colour change buttons. + $content .= html_writer::start_tag('ul', array('id' => 'block_accessibility_changecolour')); + + $content .= html_writer::start_tag('li', array('class' => 'access-button')); + $content .= html_writer::tag('a', $resetchar, $c1attrs); + $content .= html_writer::end_tag('li'); + + $content .= html_writer::start_tag('li', array('class' => 'access-button')); + $content .= html_writer::tag('a', $strchar, $c2attrs); + $content .= html_writer::end_tag('li'); + + $content .= html_writer::start_tag('li', array('class' => 'access-button')); + $content .= html_writer::tag('a', $strchar, $c3attrs); + $content .= html_writer::end_tag('li'); + + $content .= html_writer::start_tag('li', array('class' => 'access-button')); + $content .= html_writer::tag('a', $strchar, $c4attrs); + $content .= html_writer::end_tag('li'); + + $content .= html_writer::end_tag('ul'); + + $content .= $clearfix; + + // Display "settings saved" or etc. + if (isset($USER->accessabilitymsg)) { + $message = $USER->accessabilitymsg; + unset($USER->accessabilitymsg); + } else { + $message = ''; + } + $messageattrs = array('id' => 'block_accessibility_message', 'class' => 'clearfix'); + $content .= html_writer::tag('div', $message, $messageattrs); + + // Data to pass to module.js. + $jsdata['autoload_atbar'] = false; + $jsdata['instance_id'] = $this->instance->id; + + // Render ATBar. + $showatbar = DEFAULT_SHOWATBAR; + if (isset($this->config->showATbar)) { + $showatbar = $this->config->showATbar; + } + + if ($showatbar) { + + // Load database record for a current user. + $options = $DB->get_record('block_accessibility', array('userid' => $USER->id)); + + // Initialize ATBar. + $checkboxattrs = array( + 'type' => 'checkbox', + 'value' => 1, + 'id' => 'atbar_auto', + 'name' => 'atbar_auto', + 'class' => 'atbar_control', + ); + + $labelattrs = array( + 'for' => 'atbar_auto', + 'class' => 'atbar_control' + ); + + if ($options && $options->autoload_atbar) { + $checkboxattrs['checked'] = 'checked'; + $jsdata['autoload_atbar'] = true; + } + + // ATbar launch button (if javascript is enabled). + $launchattrs = array( + 'type' => 'button', + 'value' => get_string('launchtoolbar', 'block_accessibility'), + 'id' => 'block_accessibility_launchtoolbar', + 'class' => 'atbar_control access-button' + ); + + // Render ATBar. + $content .= html_writer::empty_tag('input', $launchattrs); + + $spanattrs = array('class' => 'atbar-always'); + $content .= html_writer::start_tag('span', $spanattrs); + $content .= html_writer::empty_tag('input', $checkboxattrs); + $strlaunch = get_string('autolaunch', 'block_accessibility'); + $content .= html_writer::tag('label', $strlaunch, $labelattrs); + $content .= html_writer::end_tag('span'); + } + + $content .= html_writer::end_tag('div'); + + // Loader icon. + $spanattrs = array('id' => 'loader-icon'); + $content .= html_writer::start_tag('span', $spanattrs); + $content .= html_writer::end_tag('span'); + + $content .= $clearfix; + + $this->content = new stdClass; + $this->content->footer = ''; + $this->content->text = $content; + + // Keep in mind that dynamic AJAX mode cannot work properly with IE <= 8 (for now), so javascript will not even be loaded. + if (!preg_match('/(?i)msie [1-8]/', $_SERVER['HTTP_USER_AGENT'])) { + // Language strings to pass to module.js. + $this->page->requires->string_for_js('saved', 'block_accessibility'); + $this->page->requires->string_for_js('jsnosave', 'block_accessibility'); + $this->page->requires->string_for_js('reset', 'block_accessibility'); + $this->page->requires->string_for_js('jsnosizereset', 'block_accessibility'); + $this->page->requires->string_for_js('jsnocolourreset', 'block_accessibility'); + $this->page->requires->string_for_js('jsnosize', 'block_accessibility'); + $this->page->requires->string_for_js('jsnocolour', 'block_accessibility'); + $this->page->requires->string_for_js('jsnosizereset', 'block_accessibility'); + $this->page->requires->string_for_js('jsnotloggedin', 'block_accessibility'); + $this->page->requires->string_for_js('launchtoolbar', 'block_accessibility'); + + $jsmodule = array( + 'name' => 'block_accessibility', + 'fullpath' => self::JS_URL, + 'requires' => array('base', 'node', 'stylesheet') + ); + + // Include js script and pass the arguments. + $this->page->requires->js_init_call('M.block_accessibility.init', $jsdata, false, $jsmodule); + } + + return $this->content; + } + +} diff --git a/changecolour.php b/changecolour.php new file mode 100644 index 0000000..73499ab --- /dev/null +++ b/changecolour.php @@ -0,0 +1,74 @@ +. + +/** + * Sets the session variable for custom colour schemes (1) + * + * This page accepts the required colour scheme as an argument, and + * sets a session variable accordingly. If the colour scheme is 1 (the + * theme default) the variable is unset. + * If the page is being requested via AJAX, we just return HTTP 200, or + * 400 if the parameter was invalid. If requesting normally, we redirect + * to reset the saved setting, or to the page we came from as required. (2) + * + * @package block_accessibility (3) + * @copyright Copyright © 2009 Taunton's College (4) + * @author Mark Johnson (5) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (6) + * @param int scheme - The number of the colour scheme, 1-4 (7) + */ + +require_once('../../config.php'); +require_once($CFG->dirroot . '/blocks/accessibility/lib.php'); +require_login(); + +$scheme = required_param('scheme', PARAM_INT); + +switch ($scheme) { + case 1: + // Clear the scheme stored in the session. + unset($USER->colourscheme); + + // Clear user records in database. + $urlparams = array( + 'op' => 'reset', + 'scheme' => true, + 'userid' => $USER->id + ); + if (!accessibility_is_ajax()) { + $redirect = required_param('redirect', PARAM_TEXT); + $urlparams['redirect'] = safe_redirect_url($redirect); + } + $redirecturl = new moodle_url('/blocks/accessibility/database.php', $urlparams); + redirect($redirecturl); + break; + + case 2: + case 3: + case 4: + $USER->colourscheme = $scheme; + break; + + default: + header("HTTP/1.0 400 Bad Request"); + break; +} + +if (!accessibility_is_ajax()) { + $redirect = required_param('redirect', PARAM_TEXT); + $redirecturl = new moodle_url($redirect); + redirect($redirecturl); +} diff --git a/changesize.php b/changesize.php new file mode 100644 index 0000000..6b532ae --- /dev/null +++ b/changesize.php @@ -0,0 +1,120 @@ +. + +/** + * Changes the text size via PHP or AJAX (1) + * + * This file finds the current font size, increases/decreases/resets it + * as specified, and stores it in the $USER->fontsize session variable. + * If requested via AJAX, it also returns the font size as a JSON + * string or suiable error code. If not, it redirects the user back to + * where they came from. (2) + * + * @package block_accessibility (3) + * @author Mark Johnson + * @copyright 2010 Tauntons College, UK + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (5) + */ + +header('Cache-Control: no-cache'); + +require_once('../../config.php'); +require_once($CFG->dirroot . '/blocks/accessibility/lib.php'); +require_login(); + +// If the user hasn't already changed the size, we need to find a default/referent so we know where we're +// increasing/decreasing from. +if (!isset($USER->defaultfontsize)) { + $USER->defaultfontsize = DEFAULT_FONTSIZE; +} + +// Get the current font size in px. +// NOTE: User settings priority: 1. $USER session, 2. database, 3. default. +$current = $USER->defaultfontsize; +if (isset($USER->fontsize)) { + $current = $USER->fontsize; // User session. +} else { + if ($userstyle = $DB->get_record('block_accessibility', array('userid' => $USER->id))) { + $current = $userstyle->fontsize; // User stored settings. + } +} + +// If value is in %, convert it to px to get array index of px so we are able to increment it... +if ($current > MAX_PX_FONTSIZE) { // Must be in % then. + // If we're already dealing with a percentage... + $current = accessibility_getsize($current); // Get the size in pixels. +} + +// Ok, we have font size in px now, get new percentage value from it. + +$op = required_param('op', PARAM_TEXT); +switch ($op) { + case 'inc': + if ($current == MAX_PX_FONTSIZE) { + // If we're at the upper limit, don't increase any further. + $new = accessibility_getsize($current); + } else { + // Otherwise, increase. + $new = accessibility_getsize($current + 1); + } + break; + case 'dec': + if ($current == MIN_PX_FONTSIZE) { + // If we're at the lower limit, don't decrease any further. + $new = accessibility_getsize($current); + } else { + $new = accessibility_getsize($current - 1); + } + break; + case 'reset': + // Clear the fontsize stored in the session. + unset($USER->fontsize); + unset($USER->defaultfontsize); + + // Clear user records in database. + $urlparams = array( + 'op' => 'reset', + 'size' => true, + 'userid' => $USER->id + ); + if (!accessibility_is_ajax()) { + $redirect = required_param('redirect', PARAM_TEXT); + $urlparams['redirect'] = safe_redirect_url($redirect); + } + + $redirecturl = new moodle_url('/blocks/accessibility/database.php', $urlparams); + redirect($redirecturl); + + break; + default: + if (accessibility_is_ajax()) { + header('HTTP/1.0 400 Bad Request'); + } else { + print_error('invalidop', 'block_accessibility'); + } + exit(); +} + +// Set the new font size in % +$USER->fontsize = $new; // If we've just increased or decreased, save the new size to the session. + +if (!accessibility_is_ajax()) { + // Otherwise, redirect the user + // if action is not achieved through ajax, redirect back to page is required. + $redirect = required_param('redirect', PARAM_TEXT); + $redirecturl = new moodle_url($redirect); + redirect($redirecturl); +} diff --git a/database.php b/database.php new file mode 100644 index 0000000..e533072 --- /dev/null +++ b/database.php @@ -0,0 +1,121 @@ +. + +/** + * Interacts with the database to save/reset font size settings (1) + * + * This file handles all the blocks database interaction. If saving, + * it will check if the current user already has a saved setting, and + * create/update it as appropriate. If resetting, it will delete the + * user's setting from the database. If responding to AJAX, it responds + * with suitable HTTP error codes. Otherwise, it sets a message to + * display, and redirects the user back to where they came from. (2) + * + * @package block_accessibility (3) + * @copyright 2009 © Taunton's College (4) + * @author Mark Johnson + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (5) + */ + +require_once('../../config.php'); +require_once($CFG->dirroot . '/blocks/accessibility/lib.php'); +require_login(); + +$op = required_param('op', PARAM_TEXT); +$size = optional_param('size', false, PARAM_BOOL); +$scheme = optional_param('scheme', false, PARAM_BOOL); +$atbar = optional_param('atbar', false, PARAM_BOOL); + +if (!accessibility_is_ajax()) { + $redirect = required_param('redirect', PARAM_TEXT); + $redirecturl = safe_redirect_url($redirect); +} + +switch ($op) { + case 'save': + + if ($setting = $DB->get_record('block_accessibility', array('userid' => $USER->id))) { + // Check if the user's already got a saved setting. If they have, just update it. + if ($size && isset($USER->fontsize)) { + $setting->fontsize = $USER->fontsize; + } + if ($scheme && isset($USER->colourscheme)) { + $setting->colourscheme = $USER->colourscheme; + } + if ($atbar) { + $setting->autoload_atbar = 1; + } + $DB->update_record('block_accessibility', $setting); + } else { + $setting = new stdClass; + // Otherwise, create a new record for them. + if ($size && isset($USER->fontsize)) { + $setting->fontsize = $USER->fontsize; + } + if ($scheme && isset($USER->colourscheme)) { + $setting->colourscheme = $USER->colourscheme; + } + if ($atbar) { + $setting->autoload_atbar = 1; + } + $setting->userid = $USER->id; + $DB->insert_record('block_accessibility', $setting); + } + if (!accessibility_is_ajax()) { + // If not responding to AJAX, set a message to display and redirect. + $USER->accessabilitymsg = get_string('saved', 'block_accessibility'); + redirect($redirecturl); + } + break; + + case 'reset': + if ($setting = $DB->get_record('block_accessibility', array('userid' => $USER->id))) { + // If they've got a record, delete it and redirect the user if appropriate. + if ($size) { + $setting->fontsize = null; + } else { + if (!empty($USER->fontsize)) { + $setting->fontsize = $USER->fontsize; + } + } + if ($scheme) { + $setting->colourscheme = null; + } else { + if (!empty($USER->colourscheme)) { + $setting->colourscheme = $USER->colourscheme; + } + } + if ($atbar) { + $setting->autoload_atbar = 0; + } + + if (empty($setting->fontsize) && empty($setting->colourscheme) && empty($setting->atbar)) { + $DB->delete_records('block_accessibility', array('userid' => $USER->id)); + } else { + $DB->update_record('block_accessibility', $setting); + } + if (!accessibility_is_ajax()) { + $USER->accessabilitymsg = get_string('reset', 'block_accessibility'); + } + } + if (!accessibility_is_ajax()) { + redirect($redirecturl); + } + break; + + default: + header("HTTP/1.0 400 Bad Request"); +} diff --git a/db/access.php b/db/access.php new file mode 100644 index 0000000..3cc85dc --- /dev/null +++ b/db/access.php @@ -0,0 +1,50 @@ +. + +/** + * Capability definitions for the course_menu block + * + * @package block + * @subpackage course_accessibility + * @copyright 2013 onwards Paul Vaughan + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$capabilities = array( + + // New standard capability 'addinstance'. + 'block/accessibility:addinstance' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/site:manageblocks' + ), + 'block/accessibility:myaddinstance' => array( + 'riskbitmask' => RISK_PERSONAL, + 'captype' => 'read', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'user' => CAP_ALLOW, + ), + 'clonepermissionsfrom' => 'moodle/my:manageblocks' + ), + +); diff --git a/db/install.xml b/db/install.xml new file mode 100644 index 0000000..fc413d5 --- /dev/null +++ b/db/install.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/db/upgrade.php b/db/upgrade.php new file mode 100644 index 0000000..41848c9 --- /dev/null +++ b/db/upgrade.php @@ -0,0 +1,130 @@ +. + +/** + * Defines upgrades for Accessibility Block + * + * @package block_accessibility (4) + * @copyright Copyright 2009 onwards Taunton's College (5) + * @author Mark Johnson (6) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (7) + */ +defined('MOODLE_INTERNAL') || die(); + +function xmldb_block_accessibility_upgrade($oldversion = 0) { + + global $CFG, $THEME, $DB; + + $dbman = $DB->get_manager(); + + $result = true; + + // And upgrade begins here. For each one, you'll need one + // block of code similar to the next one. Please, delete + // this comment lines once this file start handling proper + // upgrade code. + + if ($result && $oldversion < 2009071000) { + + // Changing type of field fontsize on table accessibility to number. + $table = new XMLDBTable('accessibility'); + $field = new XMLDBField('fontsize'); + $field->setAttributes(XMLDB_TYPE_NUMBER, + '4, 1', + XMLDB_UNSIGNED, + null, + null, + null, + null, + null, + 'userid'); + + // Launch change of type for field fontsize. + $result = $result && $dbman->change_field_type($table, $field); + upgrade_block_savepoint(true, 2009071000, 'accessibility'); + } + + if ($result && $oldversion < 2009082500) { + + // Define field colourscheme to be added to accessibility. + $table = new xmldb_table('accessibility'); + $field = new xmldb_field('colourscheme', + XMLDB_TYPE_INTEGER, + '1', + XMLDB_UNSIGNED, + null, + null, + null, + null, + null, + 'fontsize'); + + // Launch add field colourscheme. + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + upgrade_block_savepoint(true, 2009082500, 'accessibility'); + } + + if ($oldversion < 2010121500) { + + // Define field autoload_atbar to be added to accessibility. + $table = new xmldb_table('accessibility'); + $cs = new xmldb_field('colourscheme', + XMLDB_TYPE_INTEGER, + '1', + XMLDB_UNSIGNED, + null, + null, + null, + null, + null, + 'fontsize'); + $field = new xmldb_field('autoload_atbar', + XMLDB_TYPE_INTEGER, + '1', + XMLDB_UNSIGNED, + XMLDB_NOTNULL, + null, + '0', + 'colourscheme'); + if (!$dbman->field_exists($table, $cs)) { + $dbman->add_field($table, $cs); + } + // Conditionally launch add field autoload_atbar. + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Accessibility savepoint reached. + upgrade_block_savepoint(true, 2010121500, 'accessibility'); + } + + if ($oldversion < 2011122000) { + + // Define table accessibility to be renamed to block_accessibility. + $table = new xmldb_table('accessibility'); + + // Launch rename table for accessibility. + $dbman->rename_table($table, 'block_accessibility'); + + // Accessibility savepoint reached. + upgrade_block_savepoint(true, 2011122000, 'accessibility'); + } + + return $result; + +} diff --git a/defaults.php b/defaults.php new file mode 100644 index 0000000..1fe4033 --- /dev/null +++ b/defaults.php @@ -0,0 +1,25 @@ +. + +$defaults = array( + // The fg1 and bg1 would be reset/default colour - do not define it. + 'bg2' => '#FFFFCC', + 'fg2' => '', // Default theme colours will be unchanged. + 'bg3' => '#99CCFF', + 'fg3' => '', + 'bg4' => '#000000', + 'fg4' => '#FFFF00', +); diff --git a/edit_form.php b/edit_form.php new file mode 100644 index 0000000..ffa87e1 --- /dev/null +++ b/edit_form.php @@ -0,0 +1,84 @@ +. + +class block_accessibility_edit_form extends block_edit_form { + + const CNF_AUTOSAVE = 'config_autosave'; + const CNF_ATBAR = 'config_showATbar'; + const CNF_FG = 'config_fg'; + const CNF_BG = 'config_bg'; + + const RE_COLOUR = '/^#[a-f0-9]{6}$/i'; + + protected function specific_definition($mform) { + + // Load default colours. + global $CFG; + require_once($CFG->dirroot . '/blocks/accessibility/defaults.php'); + + // Allow ATbar. + $mform->addElement('advcheckbox', self::CNF_ATBAR, + get_string(self::CNF_ATBAR, 'block_accessibility'), + get_string(self::CNF_ATBAR . '_checkbox', 'block_accessibility'), + null, + array(0, 1) + ); + $mform->setDefault(self::CNF_ATBAR, 1); + $mform->setType(self::CNF_ATBAR, PARAM_INT); + $mform->addHelpButton(self::CNF_ATBAR, self::CNF_ATBAR, 'block_accessibility'); + + // Colour schemes. + for ($i = 2; $i < 5; $i++) { // This is how many declarations we defined in defaults.php. + // Get previously saved configuration. + $form = $this->block->config; // Or cast it to (array) and get properties like with []. + $fg = str_replace('config_', '', self::CNF_FG); + $bg = str_replace('config_', '', self::CNF_BG); + $fgcolour = isset($form->{$fg . $i}) ? $form->{$fg . $i} : $defaults['fg' . $i]; + $bgcolour = isset($form->{$bg . $i}) ? $form->{$bg . $i} : $defaults['bg' . $i]; + + // Display scheme example and identifier number of a scheme. + $mform->addElement('html', ' +
+
+
+ A + Colour scheme #' . $i . ' +
+
'); + + // Foreground colour. + $id = self::CNF_FG . $i; + $mform->addElement('text', $id, get_string(self::CNF_FG, 'block_accessibility')); + $mform->setDefault($id, $defaults['fg' . $i]); + $mform->setType($id, PARAM_TEXT); + $mform->addHelpButton($id, self::CNF_FG, 'block_accessibility'); + $mform->addRule($id, get_string('color_input_error', 'block_accessibility'), 'regex', self::RE_COLOUR, 'server', false, + false); + + // Background colour. + $id = self::CNF_BG . $i; + $mform->addElement('text', $id, get_string(self::CNF_BG, 'block_accessibility')); + $mform->setDefault($id, $defaults['bg' . $i]); + $mform->setType($id, PARAM_TEXT); + $mform->addHelpButton($id, self::CNF_BG, 'block_accessibility'); + $mform->addRule($id, get_string('color_input_error', 'block_accessibility'), 'regex', self::RE_COLOUR, 'server', false, + false); + + } + + } +} diff --git a/lang/de/block_accessibility.php b/lang/de/block_accessibility.php new file mode 100644 index 0000000..4cfb39a --- /dev/null +++ b/lang/de/block_accessibility.php @@ -0,0 +1,64 @@ +. + +/** + * German translation (1) + * + * @author Joachim Vogelgesang (2) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (3) + */ +defined('MOODLE_INTERNAL') || die(); + +$string['autolaunch'] = '(immer?)'; +$string['blockname'] = 'Barrierefreiheit'; +$string['char'] = 'A'; +$string['clearedoldcache'] = '{$a} alte Dateien aus dem Cache gelöscht'; +$string['dectext'] = 'Textgröße verkleinern'; +$string['inctext'] = 'Textgröße erhöhen'; +$string['invalidop'] = 'Die angegebene Operation war ungültig!'; +$string['jsnocolour'] = 'Fehler beim Ändern des Farbschemas'; +$string['jsnocolourreset'] = 'Fehler beim Zurücksetzen des Farbschemas'; +$string['jsnosave'] = 'Fehler beim Speichern der Einstellungen'; +$string['jsnosize'] = 'Fehler beim Ändern der Größe'; +$string['jsnosizereset'] = 'Fehler beim Zurücksetzen der Textgröße'; +$string['launchtoolbar'] = 'ATbar starten'; +$string['pluginname'] = 'Barrierefreiheit'; +$string['pluginnameplural'] = 'Barrierefreiheit'; +$string['resettext'] = 'Textgröße zurücksetzen (Löscht gespeicherte Einstellung'; +$string['reset'] = 'Einstellung gelöscht'; +$string['save'] = 'Einstellung speichern'; +$string['saved'] = 'Einstellung gespeichert'; +$string['col1text'] = 'Standard Farbschema (Löscht gespeicherte Einstellung)'; +$string['col2text'] = 'Reduzierter Kontrast 1'; +$string['col3text'] = 'Reduzierter Kontrast 2'; +$string['col4text'] = 'Hoher Kontrast'; + +// Configuration form - please help us translate it on GitHub. +$string['config_autosave'] = 'Auto save'; +$string['config_autosave_checkbox'] = 'Save user settings automatically (button "save" will disappear)'; +$string['config_autosave_help'] = 'Font size and colour schemes settings are automatically saved to the session as long as user is logged in to the system. However, session settings will be cleared once the user log off. The user can keep chosen settings throughout the sessions using the "save" button in the block. Enabling Auto-save option will remove the "save" button and automatically save settings for the user. This might lead to slightly higher impact to the system performance, which is why this option is disabled by default.'; +$string['config_showATbar'] = 'ATbar'; +$string['config_showATbar_checkbox'] = 'Allow ATbar appearance within Accessibility block'; +$string['config_showATbar_help'] = 'Accessibility block also integrates ATbar from Southampton University ECS http://www.atbar.org.'; +$string['config_fg'] = 'Text colour (not required)'; +$string['config_fg_help'] = 'Define colour scheme foreground colour here. Keep in mind that the colour will be applied uniformly to all user interface elements. It is not always desirable to have the same colour in each user interface element. It is recommended to leave foreground colour field empty so that elements can keep its default colours. Try to change background colour only.'; +$string['config_bg'] = 'Background colour'; +$string['config_bg_help'] = 'Define colour scheme background colour here. Keep in mind that the background colour will be applied uniformly to all user interface elements.'; +$string['color_input_error'] = 'Please enter a color in a format as such: #FF0050'; + +$string['accessibility:addinstance'] = 'Add a new Accessibility block'; +$string['accessibility:myaddinstance'] = 'Add a new Accessibility block to My home'; +$string['jsnotloggedin'] = 'Error! Please check if you are logged-in to the system or contact your administrator'; diff --git a/lang/en/block_accessibility.php b/lang/en/block_accessibility.php new file mode 100644 index 0000000..3fc2f4c --- /dev/null +++ b/lang/en/block_accessibility.php @@ -0,0 +1,62 @@ +. + +/** + * English Lang Strings (1) + * + * @author Mark Johnson (2) + * @copyright © Taunton's College 2009 (3) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (4) + */ +defined('MOODLE_INTERNAL') || die(); + +$string['autolaunch'] = '(always?)'; +$string['blockname'] = 'Accessibility'; +$string['clearedoldcache'] = 'Cleared {$a} old files from the cache'; +$string['char'] = 'A'; +$string['dectext'] = 'Decrease Text Size'; +$string['inctext'] = 'Increase Text Size'; +$string['invalidop'] = 'The specified operation was invalid!'; +$string['jsnocolour'] = 'Error changing colour scheme'; +$string['jsnocolourreset'] = 'Error resetting colour scheme'; +$string['jsnosave'] = 'Error saving settings'; +$string['jsnosize'] = 'Error changing size'; +$string['jsnosizereset'] = 'Error resetting text size'; +$string['launchtoolbar'] = 'Launch ATbar'; +$string['pluginname'] = 'Accessibility'; +$string['pluginnameplural'] = 'Accessibility Blocks'; +$string['resettext'] = 'Reset Text Size (Clears Saved Setting)'; +$string['reset'] = 'Setting Cleared'; +$string['save'] = 'Save Setting'; +$string['saved'] = 'Setting Saved'; +$string['col1text'] = 'Deafult Colour Scheme (Clears Saved Setting)'; +$string['col2text'] = 'Lowered Contrast 1'; +$string['col3text'] = 'Lowered Contrast 2'; +$string['col4text'] = 'High Contrast'; + +// Configuration form - please help us translate it on GitHub. +$string['config_showATbar'] = 'ATbar'; +$string['config_showATbar_checkbox'] = 'Allow ATbar appearance within Accessibility block'; +$string['config_showATbar_help'] = 'Accessibility block also integrates ATbar from Southampton University ECS http://www.atbar.org.'; +$string['config_fg'] = 'Text colour (not required)'; +$string['config_fg_help'] = 'Define colour scheme foreground colour here. Keep in mind that the colour will be applied uniformly to all user interface elements. It is not always desirable to have the same colour in each user interface element. It is recommended to leave foreground colour field empty so that elements can keep its default colours. Try to change background colour only.'; +$string['config_bg'] = 'Background colour'; +$string['config_bg_help'] = 'Define colour scheme background colour here. Keep in mind that the background colour will be applied uniformly to all user interface elements.'; +$string['color_input_error'] = 'Please enter a color in a format as such: #FF0050'; + +$string['accessibility:addinstance'] = 'Add a new Accessibility block'; +$string['accessibility:myaddinstance'] = 'Add a new Accessibility block to My home'; +$string['jsnotloggedin'] = 'Error! Please check if you are logged-in to the system or contact your administrator'; diff --git a/lang/es/block_accessibility.php b/lang/es/block_accessibility.php new file mode 100644 index 0000000..8a8324b --- /dev/null +++ b/lang/es/block_accessibility.php @@ -0,0 +1,64 @@ +. + +/** + * Spanish translation (1) + * + * @author Enrique Robredo (2) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (3) + */ +defined('MOODLE_INTERNAL') || die(); + +$string['autolaunch'] = '(¿siempre?)'; +$string['blockname'] = 'Accesibilidad'; +$string['char'] = 'A'; +$string['clearedoldcache'] = 'Eliminados de la caché {$a} archivos antiguos'; +$string['dectext'] = 'Disminuir Texto'; +$string['inctext'] = 'Aumentar Texto'; +$string['invalidop'] = 'Esta operación será invalidada'; +$string['jsnocolour'] = 'Se ha producido un error cambiando el esquema de colores'; +$string['jsnocolourreset'] = 'Se ha producido un error reiniciano el esquema de colores'; +$string['jsnosave'] = 'Se ha producido un error cambiando la configuración'; +$string['jsnosize'] = 'Se ha producido un error cambiando el tamaño'; +$string['jsnosizereset'] = 'Se ha producido un error reiniciando el tamaño del texto'; +$string['launchtoolbar'] = 'Lanzar ATbar'; +$string['pluginname'] = 'Accesibilidad'; +$string['pluginnameplural'] = 'Accesibilidad'; +$string['resettext'] = 'Recuperar tamaño de la fuente (Se pierde la configuración guardada)'; +$string['reset'] = 'Configuración Reiniciada'; +$string['save'] = 'Guardar configuración'; +$string['saved'] = 'Configuración guardada'; +$string['col1text'] = 'Volver al esquema de colores original (Se pierde la configuración guardada)'; +$string['col2text'] = 'Bajo Contraste 1'; +$string['col3text'] = 'Bajo Contraste 2'; +$string['col4text'] = 'Alto Contraste'; + +// Configuration form - please help us translate it on GitHub. +$string['config_autosave'] = 'Auto save'; +$string['config_autosave_checkbox'] = 'Save user settings automatically (button "save" will disappear)'; +$string['config_autosave_help'] = 'Font size and colour schemes settings are automatically saved to the session as long as user is logged in to the system. However, session settings will be cleared once the user log off. The user can keep chosen settings throughout the sessions using the "save" button in the block. Enabling Auto-save option will remove the "save" button and automatically save settings for the user. This might lead to slightly higher impact to the system performance, which is why this option is disabled by default.'; +$string['config_showATbar'] = 'ATbar'; +$string['config_showATbar_checkbox'] = 'Allow ATbar appearance within Accessibility block'; +$string['config_showATbar_help'] = 'Accessibility block also integrates ATbar from Southampton University ECS http://www.atbar.org.'; +$string['config_fg'] = 'Text colour (not required)'; +$string['config_fg_help'] = 'Define colour scheme foreground colour here. Keep in mind that the colour will be applied uniformly to all user interface elements. It is not always desirable to have the same colour in each user interface element. It is recommended to leave foreground colour field empty so that elements can keep its default colours. Try to change background colour only.'; +$string['config_bg'] = 'Background colour'; +$string['config_bg_help'] = 'Define colour scheme background colour here. Keep in mind that the background colour will be applied uniformly to all user interface elements.'; +$string['color_input_error'] = 'Please enter a color in a format as such: #FF0050'; + +$string['accessibility:addinstance'] = 'Add a new Accessibility block'; +$string['accessibility:myaddinstance'] = 'Add a new Accessibility block to My home'; +$string['jsnotloggedin'] = 'Error! Please check if you are logged-in to the system or contact your administrator'; diff --git a/lang/fr/block_accessibility.php b/lang/fr/block_accessibility.php new file mode 100644 index 0000000..ab97d3a --- /dev/null +++ b/lang/fr/block_accessibility.php @@ -0,0 +1,67 @@ +. + +/** + * French Lang Strings (1) + * + * @author steve.colin@ecampus-hainaut.be (2) + * @copyright © eCampus Provincial 2012 http://www.ecampus-hainaut.be (3) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (4) + */ +defined('MOODLE_INTERNAL') || die(); + +$string['autolaunch'] = '(toujours?)'; +$string['blockname'] = 'Accessibilit'; +$string['clearedoldcache'] = 'Nettoy {$a} vieux fichier(s) dans le cache'; +$string['char'] = 'A'; +$string['dectext'] = 'Diminuer Taille du Texte'; +$string['inctext'] = 'Augmenter Taille du Texte'; +$string['invalidop'] = 'Opration invalide!'; +$string['jsnocolour'] = 'Erreur lors du changement de couleurs'; +$string['jsnocolourreset'] = 'Erreur lors de la remise zro des couleurs'; +$string['jsnosave'] = 'Erreur lors de la sauvegarder des paramtres'; +$string['jsnosize'] = 'Erreur lors du changement de la taille'; +$string['jsnosizereset'] = 'Erreur lors de la remise zro de la taille du texte'; +$string['launchtoolbar'] = 'Lancer ATbar'; +$string['pluginname'] = 'Accessibilit'; +$string['pluginnameplural'] = 'Accessibilit Block'; +$string['resettext'] = 'Remise zro de la taille du texte'; +$string['reset'] = 'Paramtres r-initialiss'; +$string['save'] = 'Sauver les paramtres'; +$string['saved'] = 'Paramtres sauvs'; +$string['col1text'] = 'Couleurs par dfaut'; +$string['col2text'] = 'Contraste lev 1'; +$string['col3text'] = 'Contraste lev 2'; +$string['col4text'] = 'Contraste Haut'; + +/* Configuration form - please help us translate it on GitHub + ------------------------------------------------------------ +*/ +$string['config_autosave'] = 'Auto save'; // label +$string['config_autosave_checkbox'] = 'Save user settings automatically (button "save" will disappear)'; // checkbox label +$string['config_autosave_help'] = 'Font size and colour schemes settings are automatically saved to the session as long as user is logged in to the system. However, session settings will be cleared once the user log off. The user can keep chosen settings throughout the sessions using the "save" button in the block. Enabling Auto-save option will remove the "save" button and automatically save settings for the user. This might lead to slightly higher impact to the system performance, which is why this option is disabled by default.'; // help block +$string['config_showATbar'] = 'ATbar'; +$string['config_showATbar_checkbox'] = 'Allow ATbar appearance within Accessibility block'; +$string['config_showATbar_help'] = 'Accessibility block also integrates ATbar from Southampton University ECS http://www.atbar.org.'; +$string['config_fg'] = 'Text colour (not required)'; +$string['config_fg_help'] = 'Define colour scheme foreground colour here. Keep in mind that the colour will be applied uniformly to all user interface elements. It is not always desirable to have the same colour in each user interface element. It is recommended to leave foreground colour field empty so that elements can keep its default colours. Try to change background colour only.'; +$string['config_bg'] = 'Background colour'; +$string['config_bg_help'] = 'Define colour scheme background colour here. Keep in mind that the background colour will be applied uniformly to all user interface elements.'; +$string['color_input_error'] = 'Please enter a color in a format as such: #FF0050'; + +$string['accessibility:addinstance'] = 'Add a new Accessibility block'; +$string['accessibility:myaddinstance'] = 'Add a new Accessibility block to My home'; +$string['jsnotloggedin'] = 'Error! Please check if you are logged-in to the system or contact your administrator'; diff --git a/lang/hr/block_accessibility.php b/lang/hr/block_accessibility.php new file mode 100644 index 0000000..04c89ca --- /dev/null +++ b/lang/hr/block_accessibility.php @@ -0,0 +1,70 @@ +. + + +/** + * English Lang Strings (1) + * + * @author Mark Johnson (2) + * @copyright © Taunton's College 2009 (3) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (4) + */ +defined('MOODLE_INTERNAL') || die(); + +$string['autolaunch'] = '(uvijek?)'; +$string['blockname'] = 'Pristupačnost'; +$string['clearedoldcache'] = 'Obrisano {$a} datoteka iz cachea'; +$string['char'] = 'A'; +$string['dectext'] = 'Povećaj tekst'; +$string['inctext'] = 'Smanji tekst'; +$string['invalidop'] = 'Tražena operacija ne postoji!'; +$string['jsnocolour'] = 'Greška kod promjene profila boja'; +$string['jsnocolourreset'] = 'Greška kod resetiranja profila boja'; +$string['jsnosave'] = 'Greška kod pohrane postavki'; +$string['jsnosize'] = 'Greška kod promjene veličine teksta'; +$string['jsnosizereset'] = 'Greška kod resetiranja veličine teksta'; +$string['launchtoolbar'] = 'Pokreni ATbar'; +$string['pluginname'] = 'Pristupačnost'; +$string['pluginnameplural'] = 'Blokovi za pristupačnost'; +$string['resettext'] = 'Resetiranje veličine teksta (postavke obrisane)'; +$string['reset'] = 'Postavke obrisane'; +$string['save'] = 'Pohrani postavke'; +$string['saved'] = 'Postavke pohranjene'; +$string['col1text'] = 'Pretpostavljeni profil boja (postavke obrisane)'; +$string['col2text'] = 'Smanjeni kontrast 1'; +$string['col3text'] = 'Smanjeni kontrast 2'; +$string['col4text'] = 'Visoki kontrast'; + +/* Configuration form - please help us translate it on GitHub + ------------------------------------------------------------ +*/ +/* not implemented +$string['config_autosave'] = 'Auto save'; // label +$string['config_autosave_checkbox'] = 'Save user settings automatically (button "save" will disappear)'; // checkbox label +$string['config_autosave_help'] = 'Font size and colour schemes settings are automatically saved to the session as long as user is logged in to the system. However, session settings will be cleared once the user log off. The user can keep chosen settings throughout the sessions using the "save" button in the block. Enabling Auto-save option will remove the "save" button and automatically save settings for the user. This might lead to slightly higher impact to the system performance, which is why this option is disabled by default.'; // help block +*/ +$string['config_showATbar'] = 'ATbar'; +$string['config_showATbar_checkbox'] = 'Allow ATbar appearance within Accessibility block'; +$string['config_showATbar_help'] = 'Accessibility block also integrates ATbar from Southampton University ECS http://www.atbar.org.'; +$string['config_fg'] = 'Text colour (not required)'; +$string['config_fg_help'] = 'Define colour scheme foreground colour here. Keep in mind that the colour will be applied uniformly to all user interface elements. It is not always desirable to have the same colour in each user interface element. It is recommended to leave foreground colour field empty so that elements can keep its default colours. Try to change background colour only.'; +$string['config_bg'] = 'Background colour'; +$string['config_bg_help'] = 'Define colour scheme background colour here. Keep in mind that the background colour will be applied uniformly to all user interface elements.'; +$string['color_input_error'] = 'Please enter a color in a format as such: #FF0050'; + +$string['accessibility:addinstance'] = 'Dodaj novi Accessibility block'; +$string['accessibility:myaddinstance'] = 'Dodaj novi Accessibility block na glavnu stranicu'; +$string['jsnotloggedin'] = 'Greška! Molimo Vas provjerite jeste li prijavljeni u sustav ili kontaktirajte administratora'; diff --git a/lang/pt-br/block_accessibility.php b/lang/pt-br/block_accessibility.php new file mode 100644 index 0000000..5e2bd82 --- /dev/null +++ b/lang/pt-br/block_accessibility.php @@ -0,0 +1,69 @@ +. + + +/** + * English Lang Strings + * + * @author Fernando Souza + * @author Willian Mano + * @copyright Fernando Souza 2013, Willian Mano 2016 + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +defined('MOODLE_INTERNAL') || die(); + +$string['autolaunch'] = '(sempre?)'; +$string['blockname'] = 'Acessibilidade'; +$string['clearedoldcache'] = 'Arquivos antigos {$a} apagados do cache'; +$string['char'] = 'A'; +$string['dectext'] = 'Diminuir o Tamanho do Texto'; +$string['inctext'] = 'Aumentar o Tamanho do Texto'; +$string['invalidop'] = 'A operação especificada é inválida!'; +$string['jsnocolour'] = 'Erro de mudança no esquema de cores'; +$string['jsnocolourreset'] = 'Erro em redefinir o esquema de cores'; +$string['jsnosave'] = 'Erro ao salvar as configurações'; +$string['jsnosize'] = 'Error ao mudar o tamanho'; +$string['jsnosizereset'] = 'Erro ao redefinir o tamanho do texto'; +$string['launchtoolbar'] = 'Lançar ATbar'; +$string['pluginname'] = 'Acessibilidade'; +$string['pluginnameplural'] = 'Blocos de Acessibilidade'; +$string['resettext'] = 'Redefiniri o Tamanho do Texto (Apaga a Configuração Salva)'; +$string['reset'] = 'Configuração Apagada'; +$string['save'] = 'Salvar Configuração'; +$string['saved'] = 'Configuração Salva'; +$string['col1text'] = 'Esquema de Cores Padrão (Apaga a configuração salva)'; +$string['col2text'] = 'Contraste Baixado 1'; +$string['col3text'] = 'Contraste Baixado 2'; +$string['col4text'] = 'Contraste Alto'; + +/* Configuration form - please help us translate it on GitHub + ------------------------------------------------------------ +*/ +$string['config_autosave'] = 'Salvar automaticamente'; // label +$string['config_autosave_checkbox'] = 'Salvar configurações do usuário automaticamente(botão "salvar" desaparecerá)'; // checkbox label +$string['config_autosave_help'] = 'Configurações de Tamanho da fonte e Esquema de cores são salvas automaticamente na sessão enquanto o usuário estiver logado no sistema. No entanto, configurações de sessão serão apagadas quando o usuário sair do sistema. O usuário pode manter as configurações escolhidas ao logo das sessões usando o botão "Salvar" no bloco. Habilitando a opção "Salvar automaticamente" o botão "Salvar" será removido e as configurações do usuário serão automaticamente salvas. Isto pode impactar na performance do sistema, por isso esta opção é desabilitada por padrão.'; // help block +$string['config_showATbar'] = 'ATbar'; +$string['config_showATbar_checkbox'] = 'Permitir a barra ATbar junto com o bloco Acessibilidade'; +$string['config_showATbar_help'] = 'O bloco Acessibilidade també é integrado com a barra ATbar da Universidade de Southampton ECS http://www.atbar.org.'; +$string['config_fg'] = 'Cor do texto (não obrigatório)'; +$string['config_fg_help'] = 'Defina a cor do texto aqui. Tenha em mente que a cor do texto será aplicada uniformemente a todos os elementos da interface do usuário. Não é sempre desejável ter a mesma cor em cada elemento da interface do usuário. É recomendado deixar o campo da cor do texto vazio, assim os elementos podem manter suas cores padrão. Tente mudar apenas a cor de fundo.'; +$string['config_bg'] = 'Cor de fundo'; +$string['config_bg_help'] = 'Defina a cor de fundo aqui. Tenha em mente que a cor de fundo será aplicada uniformemente a todos os elementos da interface do usuário.'; +$string['color_input_error'] = 'Por favor, insira uma cor como no formato: #FF0050'; + +$string['accessibility:addinstance'] = 'Adicionar um novo bloco Acessibilidade'; +$string['accessibility:myaddinstance'] = 'Adicionar um novo bloco Acessibilidade à Página inicial'; +$string['jsnotloggedin'] = 'Erro! Por favor, verifique se você está logado no sistema ou contate seu administrador'; diff --git a/lib.php b/lib.php new file mode 100644 index 0000000..f0ecccf --- /dev/null +++ b/lib.php @@ -0,0 +1,125 @@ +. + +/** + * Defines 2 functions used in the block (1) + * + * 2 functions are defined here. {@link accessibility_getsize()} which + * converts the current textsize between px and %, and + * {@link accessibility_is_ajax()} which finds out if we're responding + * to an AJAX request. (2) + * + * @package block_accessibility (3) + * @copyright Copyright 2009 onwards Taunton's College (4) + * @author Mark Johnson (5) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (6) + */ + +/** + * Convert text size in pixels into a percentage eqivalent, or vice versa, accoring to the YUI + * fonts CSS guidelines + * http://developer.yahoo.com/yui/fonts/ + * + * @param int|real $size the text size we're converting. Sizes between 10 and 26 will be treated + * as pixel values. Sizes between 77 and 197 will be treated as percentage + * values. + * @return number the converted size + */ + +defined('MOODLE_INTERNAL') || die(); + +// Block constants. +// ! this definitions might cause conflicts to other Moodle plugins if there is used the same name. +define('DEFAULT_FONTSIZE', 100); // In %. +define('MAX_FONTSIZE', 197); // In %. +define('MIN_FONTSIZE', 77); // In %. +define('MAX_PX_FONTSIZE', 26); // In px. +define('MIN_PX_FONTSIZE', 10); // In px. + +define('DEFAULT_SHOWATBAR', true); +define('DEFAULT_AUTOSAVE', false); + +function accessibility_getsize($size) { + + // Define the array of sizes in px against sizes as % + // make sure to maintain defined constants above in the script + // http://yuilibrary.com/yui/docs/cssfonts/. + $sizes = array( + 10 => 77, + 11 => 85, + 12 => 93, + 13 => 100, + 14 => 108, + 15 => 116, + 16 => 123.1, + 17 => 131, + 18 => 138.5, + 19 => 146.5, + 20 => 153.9, + 21 => 161.6, + 22 => 167, + 23 => 174, + 24 => 182, + 25 => 189, + 26 => 197 + ); + if (is_int($size) && array_key_exists($size, $sizes)) { // If we're looking at a key (px). + return $sizes[$size]; // Return the value (%). + } else { + if (in_array($size, $sizes)) { // If we're looking at a value (%). + return array_search($size, $sizes); // Return the key (px). + } else { + throw new moodle_exception('invalidsize', 'block_accessibility'); + } + } +} + +/** + * Find out whether we're desponding to an AJAX call by seeing if the HTTP_X_REQUESTED_WITH header + * is XMLHttpRequest + * + * @return boolean whether we're reponding to an AJAX call or not + */ +function accessibility_is_ajax() { + $reqwith = 'HTTP_X_REQUESTED_WITH'; + if (isset($_SERVER[$reqwith]) && $_SERVER[$reqwith] == 'XMLHttpRequest') { + $xhr = true; + } else { + $xhr = false; + } + return $xhr; +} + +/** + * Prevent redirecting to external URLs and redirect to the Moodle wwwroot if one is passed + * + * @param string $redirect + * @return string Safe URL to redirect to + */ +function safe_redirect_url($redirect) { + global $CFG; + $redirecturl = new moodle_url($redirect); + + if (preg_match('/^(http(s)?:)?\/\//', $redirecturl)) { + $urltest = preg_replace('/^http(s)?:/', '', $redirecturl); + $roottest = preg_replace('/^http(s)?:/', '', $CFG->wwwroot); + + if (!preg_match('/^' . preg_quote($roottest, '/') . '/', $urltest)) { + $redirecturl = $CFG->wwwroot; + } + } + return $redirecturl; +} diff --git a/module.js b/module.js new file mode 100644 index 0000000..685bd94 --- /dev/null +++ b/module.js @@ -0,0 +1,532 @@ +M.block_accessibility = { + /* + Note: As of 29.04.2014. no duplicate CSS declaration in both module.js and userstyles.php + CSS is now declared and generated based on user settings in a single point - userstyles.php + module.js script updates user settings and fetch updated stylesheet over AJAX for each action + */ + + ATBAR_SRC: 'https://core.atbar.org/atbar/en/latest/atbar.min.js', + + // font sizes in %, this is defined in changesize.php as well + DEFAULT_FONTSIZE: 100, + MAX_FONTSIZE: 197, + MIN_FONTSIZE: 77, + + // only in JS-mode, because .getStyle('fontSize') will return computed style in px + DAFAULT_PX_FONTSIZE: 13, + MAX_PX_FONTSIZE: 26, + MIN_PX_FONTSIZE: 10+1, // +1 because of unknown error...YUI for 77% returns style of 11px + + MAIN_SELECTOR : '#page', // userstyles.php applies CSS font-size to this element + + //stylesheet: '', + + sheetnode: '', + + instance_id: '', + + defaultsize: null, + + watch: null, + + debug: false, + + transactionsCount: 0, // AJAX transactions + + init: function(Y, autoload_atbar, instance_id) { + // keep in mind that dynamic AJAX mode cannot work properly with IE <= 8 (for now), so this script will not even be loaded in block_accessibillity.php + + + // TO-DO: determine if block is visible (for example in chat session is not) + + this.Y = Y; + this.instance_id = instance_id; + + this.sheetnode = Y.one('link[href="'+M.cfg.wwwroot+ + '/blocks/accessibility/userstyles.php?instance_id='+instance_id+'"]'); + //this.stylesheet = Y.StyleSheet(this.sheetnode); + + // Set default font size + //this.log('Initial size: '+Y.one('body').getStyle('fontSize')); + //this.defaultsize = M.block_accessibility.get_current_fontsize('body'); // this is disabled because it gives false results... + this.defaultsize = M.block_accessibility.DEFAULT_FONTSIZE; + + // Attach the click handler + Y.all('#block_accessibility_textresize a').on('click', function(e) { + if (!e.target.hasClass('disabled')) { + // If it is, and the button's not disabled, pass it's id to the changesize function + M.block_accessibility.changesize(e.target); + } + }); + + Y.all('#block_accessibility_changecolour a').on('click', function(e) { + if (!e.target.hasClass('disabled')) { + // If it is, and the button's not disabled, pass it's id to the changecolour function + M.block_accessibility.changecolour(e.target); + } + }); + + // Remove href attributes from anchors + Y.all('#accessibility_controls a').each(function(node){ + node.removeAttribute('href'); + }); + + // ATBar might be disabled in block's config + if(Y.one('#atbar_auto') !== null){ + // checkbox for setting 'always' chackbox + Y.one('#atbar_auto').on('click', function(e) { + if (e.target.get('checked')) { + M.block_accessibility.atbar_autoload('on'); + } else { + M.block_accessibility.atbar_autoload('off'); + } + }); + + // Create Bookmarklet-style link using code from ATbar site + // http://access.ecs.soton.ac.uk/StudyBar/versions + Y.one('#block_accessibility_launchtoolbar').on('click', function() { + M.block_accessibility.load_atbar(); + + // Do we really need it? + // Hide block buttons until ATbar is closed + Y.one('#block_accessibility_textresize').setStyle('display', 'none'); + Y.one('#block_accessibility_changecolour').setStyle('display', 'none'); + M.block_accessibility.watch_atbar_for_close(); + }); + + if (autoload_atbar) { + M.block_accessibility.load_atbar(); + // Hide block buttons until ATbar is closed + Y.one('#block_accessibility_textresize').setStyle('display', 'none'); + Y.one('#block_accessibility_changecolour').setStyle('display', 'none'); + // Wait 1 second to give the bar a chance to load + setTimeout("M.block_accessibility.watch_atbar_for_close();", 1000); + } + } + + + + // assign loader icon events + // Y.on('io:start', M.block_accessibility.show_loading); // this triggers even for io actions outside block causing conflicts + // Y.on('io:complete', M.block_accessibility.hide_loading); + }, + + + /** + * Code from ATbar bookmarklet to load bar into page + */ + load_atbar: function() { + var jf = document.createElement('script'); + jf.src = M.block_accessibility.ATBAR_SRC; + jf.type = 'text/javascript'; + jf.id = 'ToolBar'; + document.getElementsByTagName('head')[0].appendChild(jf); + }, + + /** + * Displays the specified message in the block's footer + * + * @param {String} msg the message to display + */ + show_message: function(msg) { + //this.log('Message set to '+msg); + this.Y.one('#block_accessibility_message').setContent(msg); + + // make message disappear after some time + if(msg) setTimeout("M.block_accessibility.show_message('')", 5000); + }, + + /** + * Calls the database script on the server to save the current setting to + * the database. Displays a message on success, or an error on failure. + * + * @requires accessibility_show_message + * @requires webroot + * + */ + savesize: function() { + this.Y.io(M.cfg.wwwroot+'/blocks/accessibility/database.php', { + data: 'op=save&size=true&scheme=true', + method: 'get', + on: { + success: function(id, o) { + M.block_accessibility.show_message(M.util.get_string('saved', 'block_accessibility')); + //setTimeout("M.block_accessibility.show_message('')", 5000); + }, + failure: function(id, o) { + alert(M.util.get_string('jsnosave', 'block_accessibility')+' '+o.status+' '+o.statusText); + }, + start: M.block_accessibility.show_loading, + end: M.block_accessibility.hide_loading + } + }); + }, + + /** + * Enables or disables the buttons as specified + * + * @requires webroot + * + * @param {String} id the ID of the button to enable/disable + * @param {String} op the operation we're doing, either 'on' or 'off'. + * + */ + toggle_textsizer: function(id, op) { + var button = this.Y.one('#block_accessibility_'+id); + if (op == 'on') { + if (button.hasClass('disabled')) { + //this.log('Enabling '+button); + button.removeClass('disabled'); + } + } else if (op == 'off') { + if(!button.hasClass('disabled')) { + //this.log('Disabling '+button); + button.addClass('disabled'); + } + } + }, + + /** + * This handles clicks from the buttons. If increasing, decreasing or + * resetting size, it calls changesize.php via AJAX and sets the text + * size to the number returned from the server. If saving the size, it + * calls accessibility_savesize. + * Also enables/disables buttons as required when sizes are changed. + * + * @requires accessibility_toggle_textsizer + * @requires accessibility_savesize + * @requires accessibility_resetsize + * @requires stylesheet + * @requires webroot + * + * @param {Node} button the button that was pushed + * + */ + changesize: function(button) { + + Y = this.Y; + + switch (button.get('id')) { + case "block_accessibility_inc": + //this.log('Increasing size from '+this.defaultsize); + Y.io(M.cfg.wwwroot+'/blocks/accessibility/changesize.php', { + data: 'op=inc&cur='+this.defaultsize, // we need to find a default so we know where we're increasing/decreasing from, otherwise PHP will assume 100% + method: 'get', + on: { + success: function(id, o) { + + // if redirected to login page, or some other error... + if (!(o.response === undefined) && o.response.length > 0) { + alert(M.util.get_string('jsnotloggedin', 'block_accessibility')+': '+o.status+' '+o.statusText); + } + + // now that we updated user setting to the server, load updated stylesheet + M.block_accessibility.reload_stylesheet(); + var new_fontsize = M.block_accessibility.get_current_fontsize(M.block_accessibility.MAIN_SELECTOR); + M.block_accessibility.log('Increasing size to '+new_fontsize); + + // Disable/enable buttons as necessary + var min_fontsize = M.block_accessibility.MIN_PX_FONTSIZE; + var max_fontsize = M.block_accessibility.MAX_PX_FONTSIZE; + if(new_fontsize == M.block_accessibility.defaultsize) { + M.block_accessibility.toggle_textsizer('reset', 'off'); + } else { + M.block_accessibility.toggle_textsizer('reset', 'on'); + } + if (new_fontsize >= max_fontsize) { + M.block_accessibility.toggle_textsizer('inc', 'off'); + } + M.block_accessibility.toggle_textsizer('dec', 'on'); + M.block_accessibility.toggle_textsizer('save', 'on'); + + }, + failure: function(o) { + alert(M.util.get_string('jsnosize', 'block_accessibility')+': '+o.status+' '+o.statusText); + }, + start: M.block_accessibility.show_loading, + end: M.block_accessibility.hide_loading + } + }); + break; + case "block_accessibility_dec": + //this.log('Decreasing size from '+this.defaultsize); + Y.io(M.cfg.wwwroot+'/blocks/accessibility/changesize.php', { + data: 'op=dec&cur='+this.defaultsize, + method: 'get', + on: { + success: function(id, o) { + + // if redirected to login page, or some other error... + if (!(o.response === undefined) && o.response.length > 0) { + alert(M.util.get_string('jsnotloggedin', 'block_accessibility')+': '+o.status+' '+o.statusText); + } + + // now that we updated user setting to the server, load updated stylesheet + M.block_accessibility.reload_stylesheet(); + var new_fontsize = M.block_accessibility.get_current_fontsize(M.block_accessibility.MAIN_SELECTOR); + M.block_accessibility.log('Decreasing size to '+new_fontsize); + + // Disable/enable buttons as necessary + var min_fontsize = M.block_accessibility.MIN_PX_FONTSIZE; + var max_fontsize = M.block_accessibility.MAX_PX_FONTSIZE; + if(new_fontsize == M.block_accessibility.defaultsize) { + M.block_accessibility.toggle_textsizer('reset', 'off'); + } else { + M.block_accessibility.toggle_textsizer('reset', 'on'); + } + if (new_fontsize <= min_fontsize) { + M.block_accessibility.toggle_textsizer('dec', 'off'); + } + M.block_accessibility.toggle_textsizer('inc', 'on'); + M.block_accessibility.toggle_textsizer('save', 'on'); + + }, + failure: function(id, o) { + alert(M.util.get_string('jsnosize', 'block_accessibility')+': '+o.status+' '+o.statusText); + }, + start: M.block_accessibility.show_loading, + end: M.block_accessibility.hide_loading + } + }); + break; + case "block_accessibility_reset": + //this.log('Resetting size from '+this.defaultsize); + Y.io(M.cfg.wwwroot+'/blocks/accessibility/changesize.php', { + data: 'op=reset&cur='+this.defaultsize, + method: 'get', + on: { + success: function(id, o) { + + // if redirected to login page, or some other error... + if (!(o.response === undefined) && o.response.length > 0) { + alert(M.util.get_string('jsnotloggedin', 'block_accessibility')+': '+o.status+' '+o.statusText); + } + + // now that we updated user setting to the server, load updated stylesheet + M.block_accessibility.reload_stylesheet(); + var new_fontsize = M.block_accessibility.get_current_fontsize(M.block_accessibility.MAIN_SELECTOR); + M.block_accessibility.log('Resetting size to '+new_fontsize); + + // Disable/enable buttons as necessary + var min_fontsize = M.block_accessibility.MIN_PX_FONTSIZE; + var max_fontsize = M.block_accessibility.MAX_PX_FONTSIZE; + M.block_accessibility.toggle_textsizer('reset', 'off'); + if(new_fontsize <= min_fontsize) { + M.block_accessibility.toggle_textsizer('dec', 'on'); + } else if (new_fontsize >= max_fontsize){ + M.block_accessibility.toggle_textsizer('inc', 'on'); + } + M.block_accessibility.toggle_textsizer('save', 'off'); + //M.block_accessibility.resetsize(); + + }, + failure: function(id, o) { + alert(M.util.get_string('jsnosize', 'block_accessibility')+': '+o.status+' '+o.statusText); + }, + start: M.block_accessibility.show_loading, + end: M.block_accessibility.hide_loading + } + }); + break; + case "block_accessibility_save": + //this.log('Saving Size'); + M.block_accessibility.savesize(); + break; + } + }, + + /** + * This handles clicks from the colour scheme buttons. + * We start by getting the scheme number from the theme button's ID. + * We then get the elements that need dynamically re-styling via their + * CSS selectors and loop through the arrays to style them appropriately. + * + * @requires accessibility_toggle_textsizer + * @requires accessibility_resetscheme + * @requires stylesheet + * @requires webroot + * + * @param {String} button - the button that was clicked. + * + */ + + changecolour: function(button) { + Y = this.Y; + scheme = button.get('id').substring(26); + Y.io(M.cfg.wwwroot+'/blocks/accessibility/changecolour.php', { + data: 'scheme='+scheme, + method: 'get', + on: { + success: function (id, o) { + // if redirected to login page, or some other error... + if (!(o.response === undefined) && o.response.length > 0) { + alert(M.util.get_string('jsnotloggedin', 'block_accessibility')+': '+o.status+' '+o.statusText); + } + + M.block_accessibility.reload_stylesheet(); + if(scheme == 1){ + M.block_accessibility.toggle_textsizer('save', 'off'); // reset + M.block_accessibility.toggle_textsizer('colour1', 'off'); + } + else{ + M.block_accessibility.toggle_textsizer('save', 'on'); + M.block_accessibility.toggle_textsizer('colour1', 'on'); + } + }, + failure: function(id, o) { + alert(get_string('jsnocolour', 'block_accessibility')+': '+o.status+' '+o.statusText); + }, + start: M.block_accessibility.show_loading, + end: M.block_accessibility.hide_loading + } + }); + }, + + atbar_autoload: function(op) { + if (op == 'on') { + this.Y.io(M.cfg.wwwroot+'/blocks/accessibility/database.php', { + data: 'op=save&atbar=true', + method: 'get', + on: { + success: function(id, o) { + M.block_accessibility.show_message(M.util.get_string('saved', 'block_accessibility')); + //setTimeout("M.block_accessibility.show_message('')", 5000); + }, + failure: function(id, o) { + if (o.status != '404') { + alert(M.util.get_string('jsnosave', 'block_accessibility')+': '+o.status+' '+o.statusText); + } + }, + start: M.block_accessibility.show_loading, + end: M.block_accessibility.hide_loading + } + }); + } else if (op == 'off') { + this.Y.io(M.cfg.wwwroot+'/blocks/accessibility/database.php', { + data: 'op=reset&atbar=true', + method: 'get', + on: { + success: function(id, o) { + M.block_accessibility.show_message(M.util.get_string('reset', 'block_accessibility')); + //setTimeout("M.block_accessibility.show_message('')", 5000); + }, + failure: function(id, o) { + if (o.status != '404') { + alert(M.util.get_string('jsnoreset', 'block_accessibility')+': '+o.status+' '+o.statusText); + } + }, + start: M.block_accessibility.show_loading, + end: M.block_accessibility.hide_loading + } + }); + } + }, + + watch_atbar_for_close: function() { + Y = this.Y; + this.watch = setInterval(function() { + + if (typeof AtKit !== 'undefined') { + if (AtKit.isRendered()) { + Y.one('#block_accessibility_textresize').setStyle('display', 'block'); + Y.one('#block_accessibility_changecolour').setStyle('display', 'block'); + clearInterval(M.block_accessibility.watch); + } + } + }, 1000); + }, + + log: function(data) { + if (this.debug) { + console.log(data); + } + }, + + /** + * Stylesheet is generated by userstyles.php based on user settings (e.g. font size) + * After settings are changed, the script should download and include updated stylesheet + * + */ + reload_stylesheet: function(){ + var cache_prevention_salt = new Date().getTime(); + var oldStylesheet = M.block_accessibility.sheetnode; + var newStylesheet = null; + var cssURL = M.cfg.wwwroot+ + '/blocks/accessibility/userstyles.php?instance_id='+ + M.block_accessibility.instance_id+ + '&v='+cache_prevention_salt + + if (document.createStyleSheet) // only for IE < 11 and IE > 8 + { + /* + here we use href attribute change which makes some delay while reloading stylesheet + + 1. one another idea would be to load stylesheet using this.Y.io(.. and create