MDL-31484 backup - repeated restores with anonymised users now works correctly
[moodle.git] / theme / mymobile / layout / general.php
blobc862738f5c68060b2b0f3355f64b8cb0bf6fef64
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 * General layout for the mymobile theme
20 * @package theme
21 * @subpackage mymobile
22 * @copyright John Stabinger
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 // get blocks?
27 $toblock = optional_param('mymobile_blocks', false, PARAM_BOOL);
28 // get settings?
29 $toset = optional_param('mymobile_settings', false, PARAM_BOOL);
31 $mypagetype = $PAGE->pagetype;
32 $mylayoutype = $PAGE->pagelayout;
33 $mydevice = $PAGE->devicetypeinuse;
35 if (!empty($PAGE->theme->settings->colourswatch)) {
36 $showswatch = $PAGE->theme->settings->colourswatch;
37 } else {
38 $showswatch = 'light';
41 if ($showswatch == 'light') {
42 $dtheme = 'd';
43 $dthemeb = 'd';
44 $datatheme = 'data-theme="b"';
45 $databodytheme = 'data-theme="d"';
46 } else {
47 $dtheme = 'd';
48 $dthemeb = 'c';
49 $datatheme = 'data-theme="a"';
50 $databodytheme = '';
53 //custom settings
54 $hasshowmobileintro = (!empty($PAGE->theme->settings->showmobileintro));
56 if (!empty($PAGE->theme->settings->showfullsizeimages)) {
57 $hasithumb = $PAGE->theme->settings->showfullsizeimages;
58 } else {
59 $hasithumb = 'ithumb';
62 if (!empty($PAGE->theme->settings->showsitetopic)) {
63 $showsitetopic = $PAGE->theme->settings->showsitetopic;
64 } else {
65 $showsitetopic = 'topicnoshow';
68 if (!empty($PAGE->theme->settings->usetableview)) {
69 $showusetableview = $PAGE->theme->settings->usetableview;
70 } else {
71 $showusetableview = 'tabshow';
74 // TODO: Fix this hardcoding there are other course formats that peopleuse.
75 // Probably changing to an appropriate regex will do.
76 if ($mypagetype == 'course-view-topics' || $mypagetype == 'course-view-weeks') {
77 // jump to current topic only in course pages
78 $jumptocurrent = 'true';
79 } else {
80 $jumptocurrent = 'false';
83 // below sets a URL variable to use in some links
84 $urlblocks = new moodle_url($PAGE->url, array('mymobile_blocks' => 'true'));
85 $urlsettings = new moodle_url($PAGE->url, array('mymobile_settings' => 'true'));
87 $hasheading = ($PAGE->heading);
88 $hasnavbar = (empty($PAGE->layout_options['nonavbar']) && $PAGE->has_navbar());
89 $hasfooter = (empty($PAGE->layout_options['nofooter']));
90 $hasmyblocks = $PAGE->blocks->region_has_content('myblocks', $OUTPUT);
92 $bodyclasses = array();
93 $bodyclasses[] = (string)$hasithumb;
94 $bodyclasses[] = (string)$showsitetopic;
95 // add ithumb class to decide whether to show or hide images and site topic
97 // TODO: Better illustrate preceedence
98 $gowide = ($mydevice == 'default' && $showusetableview == 'tabshow' || $mydevice == 'tablet' && $showusetableview == 'tabshow');
99 if ($gowide) {
100 // initialize column position choices.
101 mymobile_initialise_colpos($PAGE);
103 $usercol = (mymobile_get_colpos() == 'on');
105 $renderer = $PAGE->get_renderer('theme_mymobile');
107 echo $OUTPUT->doctype() ?>
108 <html id="mymobile" <?php echo $OUTPUT->htmlattributes() ?>>
109 <head>
110 <title><?php echo $PAGE->title ?></title>
111 <link rel="shortcut icon" href="<?php echo $OUTPUT->pix_url('favicon', 'theme')?>" />
112 <link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo $OUTPUT->pix_url('m2m2x', 'theme')?>" />
113 <link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php echo $OUTPUT->pix_url('m2m', 'theme')?>" />
114 <link rel="apple-touch-icon-precomposed" href="<?php echo $OUTPUT->pix_url('m2m', 'theme')?>" />
116 <meta name="description" content="<?php echo strip_tags(format_text($SITE->summary, FORMAT_HTML)) ?>" />
117 <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1" />
119 <?php echo $OUTPUT->standard_head_html() ?>
120 </head>
121 <body id="<?php p($PAGE->bodyid) ?>" class="<?php p($PAGE->bodyclasses.' '.join(' ', $bodyclasses)) ?>">
122 <?php echo $OUTPUT->standard_top_of_body_html() ?>
123 <div id="<?php p($PAGE->bodyid) ?>PAGE" data-role="page" class="generalpage <?php echo 'ajaxedclass '; p($PAGE->bodyclasses.' '.join(' ', $bodyclasses)); ?> <?php if ($hasmyblocks && $usercol) { echo 'has-myblocks'; } ?> " data-title="<?php p($SITE->shortname) ?>">
124 <!-- start header -->
125 <div data-role="header" <?php echo($datatheme);?> class="mymobileheader" data-position="fixed">
126 <h1><?php echo $PAGE->heading ?></h1>
127 <?php if (isloggedin() && $mypagetype != 'site-index') { ?>
128 <a class="ui-btn-right" data-icon="home" href="<?php p($CFG->wwwroot) ?>" data-iconpos="notext" data-ajax="false"><?php p(get_string('home')); ?></a>
129 <?php } else if (!isloggedin()) {
130 echo $OUTPUT->login_info();
131 } ?>
132 <!-- start navbar -->
133 <div data-role="navbar">
134 <ul>
135 <?php if (!$gowide && !$hasmyblocks && !$toblock && $mypagetype == "mod-quiz-attempt" || !$gowide && !$hasmyblocks && !$toblock && $mylayoutype != "incourse") { ?>
136 <li><a data-theme="c" class="blockload" href="<?php echo $urlblocks->out(); ?>"><?php p(get_string('blocks')); ?></a></li>
137 <?php } ?>
138 <?php if (!$toset) { ?>
139 <li><a data-theme="c" href="<?php echo $urlsettings->out(); ?>"><?php p(get_string('settings')); ?></a></li>
140 <?php } ?>
141 <?php if ($jumptocurrent == 'true' && !$toblock && !$toset) { ?>
142 <li><a data-theme="c" class="jumptocurrent" href="#"><?php p(get_string('jump')); ?></a></li>
143 <?php } ?>
144 <?php if (isloggedin() && $hasnavbar) { ?>
145 <li><?php echo $OUTPUT->navbar(); ?></li>
146 <?php } ?>
147 </ul>
148 </div>
149 <!-- end navbar -->
150 </div>
151 <div id="page-header"><!-- empty page-header needed by moodle yui --></div>
152 <!-- end header -->
154 <!-- main content -->
155 <div data-role="content" class="mymobilecontent" <?php echo $databodytheme; ?>>
156 <?php if($toset) { //if we get the true, that means load/show settings only ?>
157 <h2 class="jsets"><?php p(get_string('settings')); ?></h2>
158 <?php
159 //load lang menu if available
160 echo $OUTPUT->lang_menu();
162 <ul data-role="listview" data-theme="<?php echo $dthemeb;?>" data-dividertheme="<?php echo $dtheme;?>" data-inset="true" class="settingsul">
163 <?php echo $renderer->settings_tree($PAGE->settingsnav); ?>
164 </ul>
165 <?php echo $OUTPUT->login_info(); ?>
166 <?php } ?>
168 <div class="content-primary">
169 <div class="region-content <?php if ($toblock) { echo 'mobile_blocksonly'; } ?>" id="themains">
170 <?php
171 //only show main content if we are not showing anything else
172 if (!$toblock && !$toset) { ?>
173 <?php if ($hasshowmobileintro && $mypagetype == 'site-index') { ?>
174 <?php echo $PAGE->theme->settings->showmobileintro; ?>
175 <?php } ?>
176 <?php echo $OUTPUT->main_content(); ?>
177 <?php } ?>
178 </div>
179 </div>
181 <?php if ($gowide && $hasmyblocks && !$toset) {
182 //if we get the true, that means load/show blocks only for tablet views only ?>
183 <div class="content-secondary">
184 <div class="tablets">
185 <h1><?php echo $PAGE->heading ?></h1>
186 <span><?php echo $PAGE->course->summary; ?></span>
187 </div>
189 <?php if ($hasmyblocks) { ?>
190 <div data-role="collapsible-set" data-theme="<?php echo $dthemeb;?>">
191 <?php echo $OUTPUT->blocks_for_region('myblocks') ?>
192 </div>
193 <?php } ?>
195 <?php if ($gowide && isloggedin() && !isguestuser()) { ?>
197 <div data-role="collapsible" data-collapsed="false" <?php echo $datatheme;?> data-content-theme="<?php echo $dthemeb;?>" id="profcol">
198 <h3><?php p(''.$USER->firstname.' '.$USER->lastname.''); ?></h3>
199 <div class="ui-grid-a">
200 <div class="ui-block-a">
201 <?php echo html_writer::tag('div', $OUTPUT->user_picture($USER, array('size'=>80)), array('class'=>'userimg'));?>
202 </div>
203 <div class="ui-block-b">
204 <a data-role="button" data-icon="home" href="<?php p($CFG->wwwroot) ?>/my/"><?php p(get_string('myhome')); ?></a>
205 <a data-role="button" data-icon="info" href="<?php p($CFG->wwwroot) ?>/user/profile.php"><?php p(get_string('myprofile')); ?></a>
206 <a data-role="button" data-icon="back" data-ajax="false" href="<?php p($CFG->wwwroot) ?>/login/logout.php"><?php p(get_string('logout')); ?></a>
207 </div>
208 </div>
209 </div>
211 <div data-role="fieldcontain" id="sliderdiv">
212 <label for="slider"><?php p(get_string('mtoggle','theme_mymobile')); ?>:</label>
213 <select name="slider" class="slider" data-role="slider" id="slider">
214 <option value="on">On</option>
215 <option value="off">Off</option>
216 </select>
217 </div>
219 <?php } else if (!isloggedin() || isguestuser()) { ?>
220 <a data-role="button" <?php echo $datatheme;?> data-ajax="false" href="<?php p($CFG->wwwroot) ?>/login/index.php"><?php p(get_string('login')); ?></a>
221 <?php } ?>
222 </div>
223 <?php } ?>
225 <?php
226 if ($toblock && !$gowide) {
227 //regular block load for phones + handhelds
228 if ($hasmyblocks) {
229 ?><div class="headingwrap ui-bar-<?php echo $dtheme;?> ui-footer jsetsbar">
230 <h2 class="jsets ui-title"><?php p(get_string('blocks')); ?></h2>
231 </div>
232 <div data-role="collapsible-set"><?php echo $OUTPUT->blocks_for_region('myblocks') ?></div><?php
236 </div>
237 <!-- end main content -->
239 <!-- start footer -->
240 <div data-role="footer" class="mobilefooter" <?php echo $datatheme;?>>
241 <div data-role="navbar" class="jnav" >
242 <ul>
243 <li><a id="mycal" class="callink" href="<?php p($CFG->wwwroot) ?>/calendar/view.php" data-icon="info" data-iconpos="top" ><?php p(get_string('calendar', 'calendar')); ?></a></li>
244 <?php if (!empty($CFG->messaging)) { ?>
245 <li><a id="mymess" href="<?php p($CFG->wwwroot) ?>/message/index.php" data-iconpos="top" data-icon="mymessage" ><?php p(get_string('messages', 'message')); ?></a></li>
246 <?php } ?>
247 <?php if ($mypagetype != 'site-index') { ?>
248 <li><a href="#" data-inline="true" data-role="button" data-iconpos="top" data-icon="arrow-u" id="uptotop"><?php p(get_string('up')); ?></a></li>
249 <?php } ?>
250 </ul>
251 </div>
252 </div>
253 <!-- end footer -->
255 <div id="underfooter">
256 <?php
257 echo $OUTPUT->login_info_footer();
258 echo '<div class="noajax">';
259 echo $OUTPUT->standard_footer_html();
260 echo '</div>';
262 </div>
263 </div><!-- ends page -->
265 <!-- empty divs with info for the JS to use -->
266 <div id="<?php echo sesskey(); ?>" class="mobilesession"></div>
267 <div id="<?php p($CFG->wwwroot); ?>" class="mobilesiteurl"></div>
268 <div id="<?php echo $dtheme;?>" class="datatheme"></div>
269 <div id="<?php echo $dthemeb;?>" class="datathemeb"></div>
270 <div id="page-footer"><!-- empty page footer needed by moodle yui for embeds --></div>
271 <!-- end js divs -->
273 <?php echo $OUTPUT->standard_end_of_body_html() ?>
274 </body>
275 </html>