Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/theme/splash/lib.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00032 function splash_process_css($css, $theme) {
00033  
00034     if (!empty($theme->settings->regionwidth)) {
00035         $regionwidth = $theme->settings->regionwidth;
00036     } else {
00037         $regionwidth = null;
00038     }
00039     $css = splash_set_regionwidth($css, $regionwidth);
00040  
00041     if (!empty($theme->settings->customcss)) {
00042         $customcss = $theme->settings->customcss;
00043     } else {
00044         $customcss = null;
00045     }
00046     $css = splash_set_customcss($css, $customcss);
00047  
00048     return $css;
00049 }
00050 
00058 function splash_set_regionwidth($css, $regionwidth) {
00059     $tag = '[[setting:regionwidth]]';
00060     $doubletag = '[[setting:regionwidthdouble]]';
00061     $leftmargintag = '[[setting:leftregionwidthmargin]]';
00062     $rightmargintag = '[[setting:rightregionwidthmargin]]';
00063     $replacement = $regionwidth;
00064     if (is_null($replacement)) {
00065         $replacement = 240;
00066     }
00067     $css = str_replace($tag, $replacement.'px', $css);
00068     $css = str_replace($doubletag, ($replacement*2).'px', $css);
00069     $css = str_replace($rightmargintag, ($replacement*3-5).'px', $css);
00070     $css = str_replace($leftmargintag, ($replacement+5).'px', $css);
00071     return $css;
00072 }
00073 
00081 function splash_set_customcss($css, $customcss) {
00082     $tag = '[[setting:customcss]]';
00083     $replacement = $customcss;
00084     if (is_null($replacement)) {
00085         $replacement = '';
00086     }
00087     $css = str_replace($tag, $replacement, $css);
00088     return $css;
00089 }
00090 
00099 function splash_initialise_colourswitcher(moodle_page $page) {
00100     user_preference_allow_ajax_update('theme_splash_chosen_colour', PARAM_ALPHA);
00101     $page->requires->yui_module('moodle-theme_splash-colourswitcher', 'M.theme_splash.initColourSwitcher', array(array('div'=>'#colourswitcher')));
00102 }
00103 
00110 function splash_get_colour($default='red') {
00111     return get_user_preferences('theme_splash_chosen_colour', $default);
00112 }
00113 
00121 function splash_check_colourswitch() {
00122     $changecolour = optional_param('splashcolour', null, PARAM_ALPHA);
00123     if (in_array($changecolour, array('red','green','blue','orange'))) {
00124         return set_user_preference('theme_splash_chosen_colour', $changecolour);
00125     }
00126     return false;
00127 }
 All Data Structures Namespaces Files Functions Variables Enumerations