MDL-36900 files: D&D upload uses new file name increment function
[moodle.git] / theme / mymobile / layout / general.php
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.
13 //
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
19  *
20  * @package    theme
21  * @subpackage mymobile
22  * @copyright  John Stabinger
23  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24  */
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';
39 }
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 = '';
51 }
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';
60 }
62 if (!empty($PAGE->theme->settings->showsitetopic)) {
63     $showsitetopic = $PAGE->theme->settings->showsitetopic;
64 } else {
65     $showsitetopic = 'topicnoshow';
66 }
68 if (!empty($PAGE->theme->settings->usetableview)) {
69     $showusetableview = $PAGE->theme->settings->usetableview;
70 } else {
71     $showusetableview = 'tabshow';
72 }
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';
81 }
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 $courseheader = $coursecontentheader = $coursecontentfooter = $coursefooter = '';
93 if (empty($PAGE->layout_options['nocourseheaderfooter'])) {
94     $courseheader = $OUTPUT->course_header();
95     $coursecontentheader = $OUTPUT->course_content_header();
96     if (empty($PAGE->layout_options['nocoursefooter'])) {
97         $coursecontentfooter = $OUTPUT->course_content_footer();
98         $coursefooter = $OUTPUT->course_footer();
99     }
102 $bodyclasses = array();
103 $bodyclasses[] = (string)$hasithumb;
104 $bodyclasses[] = (string)$showsitetopic;
105 // add ithumb class to decide whether to show or hide images and site topic
107 // TODO: Better illustrate preceedence
108 $gowide = ($mydevice == 'default' && $showusetableview == 'tabshow' || $mydevice == 'tablet' && $showusetableview == 'tabshow');
109 if ($gowide) {
110     // initialize column position choices.
111     mymobile_initialise_colpos($PAGE);
113 $usercol = (mymobile_get_colpos() == 'on');
115 $renderer = $PAGE->get_renderer('theme_mymobile');
117 echo $OUTPUT->doctype() ?>
118 <html id="mymobile" <?php echo $OUTPUT->htmlattributes() ?>>
119 <head>
120     <title><?php echo $PAGE->title ?></title>
121     <link rel="shortcut icon" href="<?php echo $OUTPUT->pix_url('favicon', 'theme')?>" />
122     <link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo $OUTPUT->pix_url('m2m2x', 'theme')?>" />
123     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php echo $OUTPUT->pix_url('m2m', 'theme')?>" />
124     <link rel="apple-touch-icon-precomposed" href="<?php echo $OUTPUT->pix_url('m2m', 'theme')?>" />
126     <meta name="description" content="<?php echo strip_tags(format_text($SITE->summary, FORMAT_HTML)) ?>" />
127     <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1" />
129     <?php echo $OUTPUT->standard_head_html() ?>
130 </head>
131 <body id="<?php p($PAGE->bodyid) ?>" class="<?php p($PAGE->bodyclasses.' '.join(' ', $bodyclasses)) ?>">
132     <?php echo $OUTPUT->standard_top_of_body_html() ?>
133     <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) ?>">
134         <!-- start header -->
135         <div data-role="header" <?php echo($datatheme);?> class="mymobileheader" data-position="fixed">
136             <h1><?php echo $PAGE->heading ?></h1>
137             <?php if (isloggedin() && $mypagetype != 'site-index') { ?>
138             <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>
139             <?php } else if (!isloggedin()) {
140                 echo $OUTPUT->login_info();
141             } ?>
142             <?php if (!empty($courseheader)) { ?>
143             <div data-role="course-header"><?php echo $courseheader; ?></div>
144             <?php } ?>
145             <!-- start navbar -->
146             <div data-role="navbar">
147                 <ul>
148                 <?php if (!$gowide && !$hasmyblocks && !$toblock && $mypagetype == "mod-quiz-attempt" || !$gowide && !$hasmyblocks && !$toblock && $mylayoutype != "incourse") { ?>
149                     <li><a data-theme="c" class="blockload" href="<?php echo $urlblocks->out(); ?>"><?php p(get_string('blocks')); ?></a></li>
150                 <?php } ?>
151                 <?php if (!$toset) { ?>
152                     <li><a data-theme="c" href="<?php echo $urlsettings->out(); ?>"><?php p(get_string('settings')); ?></a></li>
153                 <?php } ?>
154                 <?php if ($jumptocurrent == 'true' && !$toblock && !$toset) { ?>
155                     <li><a data-theme="c" class="jumptocurrent" href="#"><?php p(get_string('jump')); ?></a></li>
156                 <?php } ?>
157                 <?php if (isloggedin() && $hasnavbar) { ?>
158                     <li><?php echo $OUTPUT->navbar(); ?></li>
159                 <?php } ?>
160                 </ul>
161             </div>
162             <!-- end navbar -->
163         </div>
164         <div id="page-header"><!-- empty page-header needed by moodle yui --></div>
165         <!-- end header -->
167         <!-- main content -->
168         <div data-role="content" class="mymobilecontent" <?php echo $databodytheme; ?>>
169           <?php if($toset) {  //if we get the true, that means load/show settings only ?>
170             <h2 class="jsets"><?php p(get_string('settings')); ?></h2>
171             <?php
172             //load lang menu if available
173             echo $OUTPUT->lang_menu();
174             ?>
175             <ul data-role="listview" data-theme="<?php echo $dthemeb;?>" data-dividertheme="<?php echo $dtheme;?>" data-inset="true" class="settingsul">
176                 <?php echo $renderer->settings_tree($PAGE->settingsnav); ?>
177             </ul>
178             <?php echo $OUTPUT->login_info(); ?>
179           <?php } ?>
181             <div class="content-primary">
182                 <div class="region-content <?php if ($toblock) { echo 'mobile_blocksonly'; } ?>" id="themains">
183                 <?php
184                 //only show main content if we are not showing anything else
185                 if (!$toblock && !$toset) { ?>
186                     <?php if ($hasshowmobileintro && $mypagetype == 'site-index') { ?>
187                         <?php echo $PAGE->theme->settings->showmobileintro; ?>
188                     <?php } ?>
189                     <?php echo $coursecontentheader; ?>
190                     <?php echo $OUTPUT->main_content(); ?>
191                     <?php echo $coursecontentfooter; ?>
192                 <?php } ?>
193                 </div>
194             </div>
196             <?php if ($gowide && $hasmyblocks && !$toset) {
197             //if we get the true, that means load/show blocks only for tablet views only ?>
198             <div class="content-secondary">
199                 <div class="tablets">
200                     <h1><?php echo $PAGE->heading ?></h1>
201                     <span><?php echo $PAGE->course->summary; ?></span>
202                 </div>
204                 <?php if ($hasmyblocks) { ?>
205                 <div data-role="collapsible-set" data-theme="<?php echo $dthemeb;?>">
206                     <?php echo $OUTPUT->blocks_for_region('myblocks') ?>
207                 </div>
208                 <?php } ?>
210                 <?php if ($gowide && isloggedin() && !isguestuser()) { ?>
212                 <div data-role="collapsible" data-collapsed="false" <?php echo $datatheme;?> data-content-theme="<?php echo $dthemeb;?>" id="profcol">
213                     <h3><?php p(''.$USER->firstname.' '.$USER->lastname.''); ?></h3>
214                     <div class="ui-grid-a">
215                         <div class="ui-block-a">
216                             <?php echo html_writer::tag('div', $OUTPUT->user_picture($USER, array('size'=>80)), array('class'=>'userimg'));?>
217                         </div>
218                         <div class="ui-block-b">
219                             <a data-role="button" data-icon="home" href="<?php p($CFG->wwwroot) ?>/my/"><?php p(get_string('myhome')); ?></a>
220                             <a data-role="button" data-icon="info" href="<?php p($CFG->wwwroot) ?>/user/profile.php"><?php p(get_string('myprofile')); ?></a>
221                             <a data-role="button" data-icon="back" data-ajax="false" href="<?php p($CFG->wwwroot) ?>/login/logout.php"><?php p(get_string('logout')); ?></a>
222                         </div>
223                     </div>
224                 </div>
226                 <div data-role="fieldcontain" id="sliderdiv">
227                     <label for="slider"><?php p(get_string('mtoggle','theme_mymobile')); ?>:</label>
228                     <select name="slider" class="slider" data-role="slider" id="slider">
229                         <option value="on">On</option>
230                         <option value="off">Off</option>
231                     </select>
232                 </div>
234                 <?php } else if (!isloggedin() || isguestuser()) { ?>
235                 <a data-role="button" <?php echo $datatheme;?> data-ajax="false" href="<?php p($CFG->wwwroot) ?>/login/index.php"><?php p(get_string('login')); ?></a>
236                  <?php } ?>
237             </div>
238             <?php } ?>
240             <?php
241             if ($toblock && !$gowide) {
242                 //regular block load for phones + handhelds
243                 if ($hasmyblocks) {
244                     ?><div class="headingwrap ui-bar-<?php echo $dtheme;?> ui-footer jsetsbar">
245                         <h2 class="jsets ui-title"><?php p(get_string('blocks')); ?></h2>
246                     </div>
247                     <div data-role="collapsible-set"><?php echo $OUTPUT->blocks_for_region('myblocks') ?></div><?php
248                 }
249             }
250             ?>
251         </div>
252         <!-- end main content -->
254         <!-- start footer -->
255         <?php if (!empty($coursefooter)) { ?>
256         <div data-role="course-footer"><?php echo $coursefooter; ?></div>
257         <?php } ?>
259         <div data-role="footer" class="mobilefooter" <?php echo $datatheme;?>>
260             <div data-role="navbar" class="jnav" >
261                 <ul>
262                     <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>
263                     <?php if (!empty($CFG->messaging)) { ?>
264                     <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>
265                     <?php } ?>
266                     <?php if ($mypagetype != 'site-index') { ?>
267                     <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>
268                     <?php } ?>
269                 </ul>
270             </div>
271         </div>
272         <!-- end footer -->
274         <div id="underfooter">
275             <?php
276             echo $OUTPUT->login_info_footer();
277             echo '<div class="noajax">';
278             echo $OUTPUT->standard_footer_html();
279             echo '</div>';
280             ?>
281         </div>
282     </div><!-- ends page -->
284     <!-- empty divs with info for the JS to use -->
285     <div id="<?php echo sesskey(); ?>" class="mobilesession"></div>
286     <div id="<?php p($CFG->wwwroot); ?>" class="mobilesiteurl"></div>
287     <div id="<?php echo $dtheme;?>" class="datatheme"></div>
288     <div id="<?php echo $dthemeb;?>" class="datathemeb"></div>
289     <div id="page-footer"><!-- empty page footer needed by moodle yui for embeds --></div>
290     <!-- end js divs -->
292     <?php echo $OUTPUT->standard_end_of_body_html() ?>
293 </body>
294 </html>