Merge branch '42316-26' of git://github.com/samhemelryk/moodle
[moodle.git] / theme / mymobile / lib.php
blob9f187c9d55ce11371c51577a00d0af55e32e1ed3
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Lib file for mymobile theme
20 * @package theme_mymobile
21 * @copyright John Stabinger
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 /**
26 * Allow AJAX updating of the user defined columns for tablets or not
28 * @param moodle_page $page
30 function mymobile_initialise_colpos(moodle_page $page) {
31 user_preference_allow_ajax_update('theme_mymobile_chosen_colpos', PARAM_ALPHA);
34 /**
35 * Get the user preference for columns for tablets or not
37 * @param string $default
38 * @return mixed
40 function mymobile_get_colpos($default = 'on') {
41 return get_user_preferences('theme_mymobile_chosen_colpos', $default);
44 /**
45 * Makes our changes to the CSS
47 * @param string $css
48 * @param theme_config $theme
49 * @return string
51 function mymobile_user_settings($css, $theme) {
52 if (!empty($theme->settings->customcss)) {
53 $customcss = $theme->settings->customcss;
54 } else {
55 $customcss = null;
57 $css = mymobile_set_customcss($css, $customcss);
58 return $css;
61 function mymobile_set_customcss($css, $customcss) {
62 $tag = '[[setting:customcss]]';
63 $css = str_replace($tag, $customcss, $css);
64 return $css;
67 function theme_mymobile_page_init(moodle_page $page) {
68 $page->requires->jquery();
69 // Remove 'migrate' when '.live' event handlers successfully converted to '.on' in 'custom131.js':...
70 $page->requires->jquery_plugin('migrate');
71 $page->requires->jquery_plugin('mymobile', 'theme_mymobile');
72 $page->requires->jquery_plugin('mobile', 'theme_mymobile');