Permalink
Browse files

Fixed codechecker issues etc.

  • Loading branch information...
1 parent 5a3229b commit ff60a64fd1948200a8578e3d40c3717b45523c94 Mark Johnson committed Dec 20, 2011
View
83 block_accessibility.php 100644 → 100755
@@ -18,8 +18,7 @@
/**
* Define the accessibility block's class
*
- * @package blocks
- * @subpackage accessibility
+ * @package block_accessibility
* @author Mark Johnson <mark.johnson@tauntons.ac.uk>
* @copyright 2010 Tauntons College, UK
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -35,7 +34,7 @@ class block_accessibility extends block_base {
/**
* Set the title
*/
- function init() {
+ public function init() {
$this->title = get_string('pluginname', 'block_accessibility');
}
@@ -44,7 +43,7 @@ function init() {
*
* @return array
*/
- function applicable_formats() {
+ public function applicable_formats() {
return array('all' => true);
}
@@ -53,7 +52,7 @@ function applicable_formats() {
*
* @return object Block contents and footer
*/
- function get_content () {
+ public function get_content () {
global $CFG;
global $USER;
global $FULLME;
@@ -107,7 +106,7 @@ function get_content () {
$reset_attrs = array(
'id' => 'block_accessibility_reset',
'title' => get_string('resettext', 'block_accessibility'),
- 'href' => $size_url->out(FALSE, array('op' => 'reset'))
+ 'href' => $size_url->out(false, array('op' => 'reset'))
);
$c1_attrs = array(
@@ -129,56 +128,62 @@ function get_content () {
$content = '';
- $content .= html_writer::start_tag('div', array('id' => 'accessibility_controls', 'class' => 'content'));
- $content .= html_writer::start_tag('ul', array('id' => 'block_accessibility_textresize', 'class' => 'button_row'));
+ $strchar = get_string('char', 'block_accessibility');
+ $divattrs = array('id' => 'accessibility_controls', 'class' => 'content');
+ $listattrs = array('id' => 'block_accessibility_textresize', 'class' => 'button_row');
- $content .= html_writer::start_tag('li', array('class' => 'access-button'));
- $content .= html_writer::tag('a', get_string('char', 'block_accessibility').'-', $dec_attrs);
- $content .= html_writer::end_tag('li');
+ $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', get_string('char', 'block_accessibility'), $reset_attrs);
- $content .= html_writer::end_tag('li');
+ $content .= html_writer::start_tag('li', array('class' => 'access-button'));
+ $content .= html_writer::tag('a', $strchar.'-', $dec_attrs);
+ $content .= html_writer::end_tag('li');
- $content .= html_writer::start_tag('li', array('class' => 'access-button'));
- $content .= html_writer::tag('a', get_string('char', 'block_accessibility').'+', $inc_attrs);
- $content .= html_writer::end_tag('li');
+ $content .= html_writer::start_tag('li', array('class' => 'access-button'));
+ $content .= html_writer::tag('a', $strchar, $reset_attrs);
+ $content .= html_writer::end_tag('li');
- $content .= html_writer::start_tag('li', array('class' => 'access-button'));
- $content .= html_writer::tag('a', '&nbsp', $save_attrs);
- $content .= html_writer::end_tag('li');
+ $content .= html_writer::start_tag('li', array('class' => 'access-button'));
+ $content .= html_writer::tag('a', $strchar.'+', $inc_attrs);
+ $content .= html_writer::end_tag('li');
+
+ $content .= html_writer::start_tag('li', array('class' => 'access-button'));
+ $content .= html_writer::tag('a', '&nbsp', $save_attrs);
+ $content .= html_writer::end_tag('li');
$content .= html_writer::end_tag('ul');
// 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', get_string('char', 'block_accessibility'), $c1_attrs);
+ $content .= html_writer::tag('a', get_string('char', 'block_accessibility'), $c1_attrs);
$content .= html_writer::end_tag('li');
$content .= html_writer::start_tag('li', array('class' => 'access-button'));
- $content .= html_writer::tag('a', get_string('char', 'block_accessibility'), $c2_attrs);
+ $content .= html_writer::tag('a', get_string('char', 'block_accessibility'), $c2_attrs);
$content .= html_writer::end_tag('li');
$content .= html_writer::start_tag('li', array('class' => 'access-button'));
- $content .= html_writer::tag('a', get_string('char', 'block_accessibility'), $c3_attrs);
+ $content .= html_writer::tag('a', get_string('char', 'block_accessibility'), $c3_attrs);
$content .= html_writer::end_tag('li');
$content .= html_writer::start_tag('li', array('class' => 'access-button'));
- $content .= html_writer::tag('a', get_string('char', 'block_accessibility'), $c4_attrs);
+ $content .= html_writer::tag('a', get_string('char', 'block_accessibility'), $c4_attrs);
$content .= html_writer::end_tag('li');
$content .= html_writer::end_tag('ul');
- $content .= html_writer::end_tag('div');
+ $content .= html_writer::end_tag('div');
if (isset($USER->accessabilitymsg)) {
$message = $USER->accessabilitymsg;
unset($USER->accessabilitymsg);
} else {
$message = '';
}
- $content .= html_writer::tag('div', $message, array('id' => 'block_accessibility_message', 'class' => 'clearfix'));
+
+ $messageattrs = array('id' => 'block_accessibility_message', 'class' => 'clearfix');
+ $content .= html_writer::tag('div', $message, $messageattrs);
$options = $DB->get_record('accessibility', array('userid' => $USER->id));
@@ -215,7 +220,8 @@ function get_content () {
$content .= html_writer::empty_tag('input', $launch_attrs);
$content .= html_writer::empty_tag('input', $checkbox_attrs);
- $content .= html_writer::tag('label', get_string('autolaunch', 'block_accessibility'), $label_attrs);
+ $strlaunch = get_string('autolaunch', 'block_accessibility');
+ $content .= html_writer::tag('label', $strlaunch, $label_attrs);
$this->content->footer = '';
$this->content->text = $content;
@@ -226,7 +232,6 @@ function get_content () {
'requires' => array('base', 'node', 'stylesheet')
);
-
if ($options && $options->autoload_atbar) {
$jsdata = array(
'autoload_atbar' => true
@@ -246,19 +251,23 @@ function get_content () {
$this->page->requires->string_for_js('jsnocolour', 'block_accessibility');
$this->page->requires->string_for_js('jsnosizereset', 'block_accessibility');
$this->page->requires->string_for_js('launchtoolbar', 'block_accessibility');
- $this->page->requires->js_init_call('M.block_accessibility.init', $jsdata, false, $jsmodule);
+ $this->page->requires->js_init_call('M.block_accessibility.init',
+ $jsdata,
+ false,
+ $jsmodule);
return $this->content;
}
/**
* Periodically clear the TTS cache so it doesn't get out of hand.
*/
- function cron() {
+ public function cron() {
global $CFG;
$count = 0;
- $count += $this->clear_old_cache($CFG->dirroot.'/blocks/accessibility/toolbar/server/TTS/cache/chunks');
- $count += $this->clear_old_cache($CFG->dirroot.'/blocks/accessibility/toolbar/server/TTS/cache');
+ $cache = $CFG->dirroot.'/blocks/accessibility/toolbar/server/TTS/cache';
+ $count += $this->clear_old_cache($cache.'/chunks');
+ $count += $this->clear_old_cache($cache);
mtrace(get_string('clearedoldcache', 'block_accessibility', $count));
}
@@ -269,17 +278,17 @@ function cron() {
* @param string $path The Directory to delete from
* @return int Number of files deleted.
*/
- function clear_old_cache($path) {
+ public function clear_old_cache($path) {
$dh = opendir($path);
$count = 0;
while (false !== ($file = readdir($dh))) {
- $stat = stat($path.'/'.$file);
- if (is_file($path.'/'.$file) && $stat['mtime'] < time()-3600 && $file != 'index.html') {
- unlink($path.'/'.$file);
+ $filepath = $path.'/'.$file;
+ $stat = stat($filepath);
+ if (is_file($filepath) && $stat['mtime'] < time()-3600 && $file != 'index.html') {
+ unlink($filepath);
$count++;
}
}
return $count;
}
}
-?>
View
15 changecolour.php 100644 → 100755
@@ -25,8 +25,7 @@
* 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 blocks
- * @subpackage accessibility (3)
+ * @package block_accessibility (3)
* @copyright Copyright &copy; 2009 Taunton's College (4)
* @author Mark Johnson (5)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (6)
@@ -43,10 +42,16 @@
}
switch($scheme) {
- case 1:
+ case 1:
unset($USER->colourscheme);
if (!accessibility_is_ajax()) {
- $redirecturl = new moodle_url('/blocks/accessibility/database.php', array('op' => 'reset', 'scheme' => true, 'userid' => $USER->id, 'redirect' => $redirect));
+ $urlparams = array(
+ 'op' => 'reset',
+ 'scheme' => true,
+ 'userid' => $USER->id,
+ 'redirect' => $redirect
+ );
+ $redirecturl = new moodle_url('/blocks/accessibility/database.php', $urlparams);
}
break;
@@ -70,5 +75,3 @@
if (!accessibility_is_ajax()) {
redirect($redirecturl);
}
-
-?>
View
26 changesize.php 100644 → 100755
@@ -24,8 +24,9 @@
* string or suiable error code. If not, it redirects the user back to
* where they came from. (2)
*
- * @package blocks-accessibility (3)
- * @copyright 2009 Mark Johnson (4)
+ * @package block_accessibility (3)
+ * @author Mark Johnson <mark.johnson@tauntons.ac.uk>
+ * @copyright 2010 Tauntons College, UK
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (5)
*/
@@ -49,9 +50,10 @@
}
}
-if(!isset($USER->fontsize)) {
- // If the user hasn't already changed the size, we need to find a default so we know where we're increasing/decreasing from
- if($userstyle = $DB->get_record('accessibility', array('userid' => $USER->id))) {
+if (!isset($USER->fontsize)) {
+ // If the user hasn't already changed the size, we need to find a default so we know where
+ // we're increasing/decreasing from
+ if ($userstyle = $DB->get_record('accessibility', array('userid' => $USER->id))) {
// First, check the database to see if they've got a setting saved
$current = $userstyle->fontsize;
} else {
@@ -68,7 +70,7 @@
}
switch($op) {
case 'inc':
- if($current == 26) {
+ if ($current == 26) {
// If we're at the upper limit, don't increase any further.
$new = accessibility_getsize($current);
} else {
@@ -77,7 +79,7 @@
}
break;
case 'dec':
- if($current == 10) {
+ if ($current == 10) {
// If we're at the lower limit, don't decrease any further.
$new = accessibility_getsize($current);
} else {
@@ -96,7 +98,13 @@
exit();
} else {
// Otherwise, redirect the user
- $redirecturl = new moodle_url('/blocks/accessibility/database.php', array('op' => 'reset', 'size' => true, 'userid' => $USER->id, 'redirect' => $redirect));
+ $urlparams = array(
+ 'op' => 'reset',
+ 'size' => true,
+ 'userid' => $USER->id,
+ 'redirect' => $redirect
+ );
+ $redirecturl = new moodle_url('/blocks/accessibility/database.php', $urlparams);
redirect($redirecturl);
}
break;
@@ -125,5 +133,3 @@
// Otherwise, redirect the user
redirect($redirecturl);
}
-
-?>
View
24 database.php 100644 → 100755
@@ -25,9 +25,9 @@
* with suitable HTTP error codes. Otherwise, it sets a message to
* display, and redirects the user back to where they came from. (2)
*
- * @package blocks-accessibility (3)
+ * @package block_accessibility (3)
* @copyright 2009 &copy; Taunton's College (4)
- * @author Mark Johnson
+ * @author Mark Johnson <mark.johnson@taunton.ac.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (5)
*/
@@ -40,12 +40,12 @@
$atbar = optional_param('atbar', false, PARAM_BOOL);
-if(!accessibility_is_ajax()) {
+if (!accessibility_is_ajax()) {
$redirect = required_param('redirect', PARAM_TEXT);
$redirecturl = new moodle_url($redirect);
}
-switch($op) {
+switch ($op) {
case 'save':
if ($setting = $DB->get_record('accessibility', array('userid' => $USER->id))) {
@@ -75,7 +75,7 @@
$setting->userid = $USER->id;
$DB->insert_record('accessibility', $setting);
}
- if(!accessibility_is_ajax()) {
+ 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);
@@ -104,21 +104,17 @@
} else {
$DB->update_record('accessibility', $setting);
}
- if(!accessibility_is_ajax()) {
+ if (!accessibility_is_ajax()) {
$USER->accessabilitymsg = get_string('reset', 'block_accessibility');
}
- } else if(accessibility_is_ajax()) {
+ } else if (accessibility_is_ajax()) {
header("HTTP/1.0 404 Not Found");
}
- if(!accessibility_is_ajax()) {
+ if (!accessibility_is_ajax()) {
redirect($redirecturl);
}
break;
-default:
- header("HTTP/1.0 400 Bad Request");
+ default:
+ header("HTTP/1.0 400 Bad Request");
}
-
-
-
-?>
View
@@ -17,4 +17,4 @@
</KEYS>
</TABLE>
</TABLES>
-</XMLDB>
+</XMLDB>
Oops, something went wrong.

0 comments on commit ff60a64

Please sign in to comment.