function get_content()
 {
     if ($this->content !== NULL) {
         return $this->content;
     }
     global $CFG, $USER;
     $this->content->text .= '<div id="textresize">';
     if (isset($USER->fontsize) && accessibility_getsize($USER->fontsize) == 10) {
         // Check if the decrease button should be disabled, i.e. we can't decrease any further (apply 'disabled' class and remove href if so)
         $this->content->text .= '<a title="' . get_string('dectext', 'block_accessibility') . '" id="dec" class="outer disabled">';
     } else {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/accessibility/changesize.php?op=dec&amp;redirect=' . $_SERVER['REQUEST_URI'] . '" title="' . get_string('dectext', 'block_accessibility') . '" id="dec" class="outer">';
     }
     $this->content->text .= '   <div class="middle">
                                         <div class="inner">' . get_string('char', 'block_accessibility') . '-</div>
                                     </div>
                                 </a>
                                 <a href="' . $CFG->wwwroot . '/blocks/accessibility/changesize.php?op=reset&amp;redirect=' . $_SERVER['REQUEST_URI'] . '" title="' . get_string('resettext', 'block_accessibility') . '" id="reset" class="outer right">
                                     <div class="middle">
                                         <div class="inner">' . get_string('char', 'block_accessibility') . '</div>
                                     </div>
                                 </a>';
     if (isset($USER->fontsize) && accessibility_getsize($USER->fontsize) == 26) {
         // Check if the increase button should be disabled, i.e. we can't increase any further
         $this->content->text .= '<a title="' . get_string('inctext', 'block_accessibility') . '" id="inc" class="outer disabled right">';
     } else {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/accessibility/changesize.php?op=inc&amp;redirect=' . $_SERVER['REQUEST_URI'] . '" title="' . get_string('inctext', 'block_accessibility') . '" id="inc" class="outer right">';
     }
     $this->content->text .= '   <div class="middle">
                                         <div class="inner">' . get_string('char', 'block_accessibility') . '+</div>
                                     </div>
                                 </a>';
     if (isset($USER->fontsize) || isset($USER->colourscheme)) {
         // Check if the save button should be disabled, i.e. there's no setting in $USER->fontsize that we can save
         $this->content->text .= '<a id="save" href="' . $CFG->wwwroot . '/blocks/accessibility/database.php?op=save&amp;size=true&amp;scheme=true&amp;redirect=' . $_SERVER['REQUEST_URI'] . '" class="outer right" title="' . get_string('save', 'block_accessibility') . '">';
     } else {
         $this->content->text .= '<a id="save" class="outer disabled right" title="' . get_string('save', 'block_accessibility') . '">';
     }
     $this->content->text .= '   <div class="middle">
                                         <div class="inner">
                                             <img id="saveicon" src="' . $CFG->wwwroot . '/blocks/accessibility/pix/document-save';
     if (!isset($USER->fontsize) && !isset($USER->colourscheme)) {
         $this->content->text .= '-grey';
     }
     $this->content->text .= '.png" />
                                         </div>
                                     </div>
                                 </a>
                             </div>
                             <div id="colourchange">
                                 <a href="' . $CFG->wwwroot . '/blocks/accessibility/changecolour.php?scheme=1&amp;redirect=' . $_SERVER['REQUEST_URI'] . '" title="' . get_string('col1text', 'block_accessibility') . '" id="colour1" class="outer row">
                                     <div class="middle">
                                         <div class="inner">' . get_string('char', 'block_accessibility') . '</div>
                                     </div>
                                 </a>
                                 <a href="' . $CFG->wwwroot . '/blocks/accessibility/changecolour.php?scheme=2&amp;redirect=' . $_SERVER['REQUEST_URI'] . '" title="' . get_string('col2text', 'block_accessibility') . '" id="colour2" class="outer row right">
                                     <div class="middle">
                                         <div class="inner">' . get_string('char', 'block_accessibility') . '</div>
                                     </div>
                                 </a>
                                 <a href="' . $CFG->wwwroot . '/blocks/accessibility/changecolour.php?scheme=3&amp;redirect=' . $_SERVER['REQUEST_URI'] . '" title="' . get_string('col3text', 'block_accessibility') . '" id="colour3" class="outer row right">
                                     <div class="middle">
                                         <div class="inner">' . get_string('char', 'block_accessibility') . '</div>
                                     </div>
                                 </a>
                                 <a href="' . $CFG->wwwroot . '/blocks/accessibility/changecolour.php?scheme=4&amp;redirect=' . $_SERVER['REQUEST_URI'] . '" title="' . get_string('col4text', 'block_accessibility') . '" id="colour4" class="outer row right">
                                     <div class="middle">
                                         <div class="inner">' . get_string('char', 'block_accessibility') . '</div>
                                     </div>
                                 </a>
                             </div>
                             <div style="clear:both;"></div>';
     require_js(array('yui_yahoo', 'yui_event', 'yui_dom', 'yui_connection', 'yui_selector', $CFG->wwwroot . '/blocks/accessibility/accessibility.js'));
     // setup a couple of global javascript variables, and set the javascript's init function to run with body.onload
     $this->content->text .= '<script type="text/javascript">/* <![CDATA[ */var stylesheet;var webroot="' . $CFG->wwwroot . '";YAHOO.util.Event.on(document.body, "load", accessibility_init()); /* ]]> */</script>';
     $this->content->footer = '<div id="accessibility_message">';
     if (isset($USER->accessabilitymsg)) {
         // If there's a message to display, show it in the footer.
         $this->content->footer .= $USER->accessabilitymsg;
         unset($USER->accessabilitymsg);
     }
     $this->content->footer .= '</div>';
     return $this->content;
 }
Beispiel #2
0
        // Clear the fontsize stored in the session
        if (accessibility_is_ajax()) {
            // If we're responding to AJAX, send back the new font size to change to
            header('Content-Type: application/json');
            echo '{oldfontsize: ' . accessibility_getsize($current) . ', fontsize: ' . accessibility_getsize($USER->defaultfontsize) . '}';
            exit;
        } else {
            // Otherwise, redirect the user
            redirect($CFG->wwwroot . '/blocks/accessibility/database.php?op=reset&size=true&userid=' . $USER->id . '&amp;redirect=' . $redirect);
        }
        break;
    default:
        if (accessibility_is_ajax()) {
            header('HTTP/1.0 400 Bad Request');
        } else {
            print_error('invalidop', 'block_accessibility');
        }
        exit;
        break;
}
$USER->fontsize = $new;
// If we've just increased or decreased, save the new size to the session
if (accessibility_is_ajax()) {
    // If we're responding to AJAX, send back the new font size to change to
    header('Content-Type: application/json');
    echo '{fontsize: ' . $USER->fontsize . ', defaultsize: ' . accessibility_getsize($USER->defaultfontsize) . '}';
    exit;
} else {
    // Otherwise, redirect the user
    redirect($CFG->wwwroot . $redirect);
}
Beispiel #3
0
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'] = $redirect;
        }
        $redirecturl = new moodle_url('/blocks/accessibility/database.php', $urlparams);
        redirect($redirecturl);
        // ... REDIRECTED! EXIT