PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/layout/frontpage.php

https://github.com/roelmann/krystle
PHP | 292 lines | 238 code | 41 blank | 13 comment | 67 complexity | 5d42f0f49a80d1ff6d22d74b5123d061 MD5 | raw file
  1. <?php //require the theme lib.php file - but check first whether the theme location has been set in moodle config.php
  2. if (!empty($CFG->themedir) and file_exists("$CFG->themedir/krystle")) {
  3. require_once ($CFG->themedir."/krystle/lib.php");
  4. } else {
  5. require_once ($CFG->dirroot."/theme/krystle/lib.php");
  6. }
  7. $hasheading = ($PAGE->heading);
  8. $hasnavbar = (empty($PAGE->layout_options['nonavbar']) && $PAGE->has_navbar());
  9. $hasfooter = (empty($PAGE->layout_options['nofooter']));
  10. // $PAGE->blocks->region_has_content('region_name') doesn't work as we do some sneaky stuff
  11. // to hide nav and/or settings blocks if requested
  12. $blocks_side_pre = trim($OUTPUT->blocks_for_region('side-pre'));
  13. $hassidepre = strlen($blocks_side_pre);
  14. $blocks_side_post = trim($OUTPUT->blocks_for_region('side-post'));
  15. $hassidepost = strlen($blocks_side_post);
  16. $topsettings = $this->page->get_renderer('theme_krystle','topsettings');
  17. $awesome_nav = $topsettings->navigation_tree($this->page->navigation);
  18. $awesome_settings = $topsettings->settings_tree($this->page->settingsnav);
  19. $custommenu = $OUTPUT->custom_menu();
  20. $hascustommenu = (empty($PAGE->layout_options['nocustommenu']) && !empty($custommenu));
  21. // Course call backs - for Moodle2.4
  22. $courseheader = $coursecontentheader = $coursecontentfooter = $coursefooter = '';
  23. if (empty($PAGE->layout_options['nocourseheaderfooter'])) { //Check if we're displaying course specific headers and footers
  24. $courseheader = method_exists($OUTPUT, "course_header") ? $OUTPUT->course_header() : NULL; //Course header - Backward compatible for <2.4
  25. $coursecontentheader = method_exists($OUTPUT, "course_content_header") ? $OUTPUT->course_content_header() : NULL; //Course content header - Backward compatible for <2.4
  26. if (empty($PAGE->layout_options['nocoursefooter'])) { //Chekc if we're displaying course footers
  27. $coursefooter = method_exists($OUTPUT, "course_footer") ? $OUTPUT->course_footer() : NULL; //Course footer - Backward compatible for <2.4
  28. $coursecontentfooter = method_exists($OUTPUT, "course_content_footer") ? $OUTPUT->course_content_footer() : NULL; //Course Content Footer - Backward compatible for <2.4
  29. }
  30. }
  31. //Call function to initialise awesomebar
  32. krystle_initialise_awesomebar($PAGE);
  33. //Set body classes for various functions and layouts
  34. $bodyclasses = array();
  35. if(!empty($PAGE->theme->settings->useeditbuttons) && $PAGE->user_allowed_editing()) {
  36. krystle_initialise_editbuttons($PAGE);
  37. $bodyclasses[] = 'krystle_with_edit_buttons';
  38. }
  39. if ($hassidepre && !$hassidepost) {
  40. $bodyclasses[] = 'side-pre-only';
  41. } else if ($hassidepost && !$hassidepre) {
  42. $bodyclasses[] = 'side-post-only';
  43. } else if (!$hassidepost && !$hassidepre) {
  44. $bodyclasses[] = 'content-only';
  45. }
  46. if(!empty($PAGE->theme->settings->persistentedit) && $PAGE->user_allowed_editing()) {
  47. if(property_exists($USER, 'editing') && $USER->editing) {
  48. $OUTPUT->set_really_editing(true);
  49. }
  50. $USER->editing = 1;
  51. $bodyclasses[] = 'krystle_persistent_edit';
  52. }
  53. //Custom footnote in settings?
  54. if (!empty($PAGE->theme->settings->footnote)) {
  55. $footnote = $PAGE->theme->settings->footnote;
  56. } else {
  57. $footnote = '<!-- There was no custom footnote set -->';
  58. }
  59. // Tell IE to use the latest engine (no Compatibility mode), if the user is using IE.
  60. $ie = false;
  61. if (class_exists('core_useragent')) {
  62. if (core_useragent::check_ie_version()) {
  63. $ie = true;
  64. }
  65. } else if (check_browser_version("MSIE", "0")) {
  66. $ie = true;
  67. }
  68. if ($ie) {
  69. header('X-UA-Compatible: IE=edge');
  70. }
  71. //Settings for responsive design taken from Zebra theme
  72. $userespond = ($PAGE->theme->settings->userespond); //Check the theme settings to see if respond.js should be called
  73. $usecf = ($PAGE->theme->settings->usecf); //Check the theme settings to see if Chrome Frame should be called
  74. $cfmaxversion = ($PAGE->theme->settings->cfmaxversion); //Check the theme settings to see which versions of IE get prompted for Chrome Frame
  75. $ieversion = strpos($PAGE->bodyclasses, $cfmaxversion);
  76. $usingie = strpos($PAGE->bodyclasses, 'ie ie'); //Check if the user is using IE
  77. $usingie9 = strpos($PAGE->bodyclasses, 'ie9'); //Make sure the user isn't using IE9 because it can use @media declarations natively
  78. $usingios = (preg_match('/iPhone|iPod|iPad/i', $_SERVER['HTTP_USER_AGENT']));
  79. $requiresrespond = ($userespond && $usingie && !$usingie9); //Check all the options necessary to print respond.js
  80. $requirescf = ($usecf && $usingie && $ieversion); // Check all the options necessary to print chrome frame
  81. //Settings for profilebar taken from Aardvark
  82. $hasemailurl = (!empty($PAGE->theme->settings->emailurl));
  83. $hasprofilebarcustom = (!empty($PAGE->theme->settings->profilebarcustom));
  84. //Standard Moodle top of file - doctype/html etc
  85. echo $OUTPUT->doctype() ?>
  86. <html <?php echo $OUTPUT->htmlattributes() ?>>
  87. <head>
  88. <?php if ($usecf) { ?><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><?php } ?>
  89. <title><?php echo $PAGE->title ?></title>
  90. <meta name="description" content="<?php p(strip_tags(format_text($SITE->summary, FORMAT_HTML))) ?>" />
  91. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  92. <link rel="shortcut icon" type="image/png" href="<?php echo $OUTPUT->pix_url('favicon/favicon', 'theme'); ?>" />
  93. <link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo $OUTPUT->pix_url('favicon/h/apple-touch-icon-precomposed', 'theme'); ?>">
  94. <link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php echo $OUTPUT->pix_url('favicon/m/apple-touch-icon-precomposed', 'theme'); ?>">
  95. <link rel="apple-touch-icon-precomposed" href="<?php echo $OUTPUT->pix_url('favicon/l/apple-touch-icon-precomposed', 'theme'); ?>">
  96. <?php echo $OUTPUT->standard_head_html() ?>
  97. <!--Scroll to top button script-->
  98. <script type="text/javascript">
  99. YUI().use('node', function(Y) {
  100. window.thisisy = Y;
  101. Y.one(window).on('scroll', function(e) {
  102. var node = Y.one('#back-to-top');
  103. if (Y.one('window').get('docScrollY') > Y.one('#page-content-wrapper').getY()) {
  104. node.setStyle('display', 'block');
  105. } else {
  106. node.setStyle('display', 'none');
  107. }
  108. });
  109. });
  110. </script>
  111. </head>
  112. <body id="<?php p($PAGE->bodyid) ?>" class="<?php p($PAGE->bodyclasses.' '.join(' ', $bodyclasses)) ?>">
  113. <?php echo $OUTPUT->standard_top_of_body_html();
  114. //Awesome bar - at top of page
  115. if (empty($PAGE->layout_options['noawesomebar'])) { ?>
  116. <div id="awesomebar" class="krystle-awesome-bar">
  117. <?php
  118. if( $this->page->pagelayout != 'maintenance' // Don't show awesomebar if site is being upgraded
  119. && !(get_user_preferences('auth_forcepasswordchange') && !session_is_loggedinas()) // Don't show it when forcibly changing password either
  120. ) {
  121. echo $awesome_nav;
  122. if ($hascustommenu && !empty($PAGE->theme->settings->custommenuinawesomebar) && empty($PAGE->theme->settings->custommenuafterawesomebar)) {
  123. echo $custommenu;
  124. }
  125. echo $awesome_settings;
  126. if ($hascustommenu && !empty($PAGE->theme->settings->custommenuinawesomebar) && !empty($PAGE->theme->settings->custommenuafterawesomebar)) {
  127. echo $custommenu;
  128. }
  129. echo $topsettings->settings_search_box();
  130. }
  131. ?>
  132. </div>
  133. <?php } ?>
  134. <!-- Main page div -->
  135. <div id="page">
  136. <?php if ($hasheading || $hasnavbar) { ?>
  137. <div id="page-header">
  138. <div id="page-header-wrapper">
  139. <?php if ($hasheading) { ?>
  140. <h1 class="headermain"><?php echo $PAGE->heading ?></h1>
  141. <div class="headermenu">
  142. <?php
  143. include('profileblock.php') //ProfileBlock is included as a separate php file to make future editing easier
  144. ?>
  145. </div>
  146. <?php } ?>
  147. </div>
  148. </div>
  149. <!-- Add custom menu if its not included in awesomebar already -->
  150. <?php if ($hascustommenu && empty($PAGE->theme->settings->custommenuinawesomebar)) { ?>
  151. <div id="custommenu" class="krystle-awesome-bar"><?php echo $custommenu; ?></div>
  152. <?php } ?>
  153. <!-- Add breadcumbs -->
  154. <?php if ($hasnavbar) { ?>
  155. <div class="navbar clearfix">
  156. <div class="breadcrumb"><?php echo $OUTPUT->navbar(); ?></div>
  157. <div class="navbutton"> <?php echo $PAGE->button; ?></div>
  158. </div>
  159. <?php } ?>
  160. <?php } ?>
  161. <!-- END OF HEADER -->
  162. <div id="page-content-wrapper" class="clearfix">
  163. <div id="page-content">
  164. <div id="region-main-box">
  165. <div id="region-post-box">
  166. <div id="region-main-wrap">
  167. <div id="region-main">
  168. <div class="region-content">
  169. <?php include('bxslider.php'); //BoxSlider is included as a separate php file to make future editing easier ?>
  170. <!--course callback contents for certain course types in 2.4-->
  171. <?php if (!empty($courseheader)) { ?>
  172. <div id="course-header"><?php echo $courseheader; ?></div>
  173. <?php } ?>
  174. <?php echo $coursecontentheader; ?>
  175. <!--Main Content for page -->
  176. <?php echo method_exists($OUTPUT, "main_content")?$OUTPUT->main_content():core_renderer::MAIN_CONTENT_TOKEN ?>
  177. <!--course callback contents for certain course types in 2.4-->
  178. <?php echo $coursecontentfooter; ?>
  179. </div>
  180. </div>
  181. </div>
  182. <!--SidePre region content - usually left-->
  183. <?php if ($hassidepre) { ?>
  184. <div id="region-pre" class="block-region">
  185. <div class="region-content">
  186. <?php echo $blocks_side_pre ?>
  187. </div>
  188. </div>
  189. <?php } ?>
  190. <!--SidePost region content - usually right-->
  191. <?php if ($hassidepost) { ?>
  192. <div id="region-post" class="block-region">
  193. <div class="region-content">
  194. <?php echo $blocks_side_post ?>
  195. </div>
  196. </div>
  197. <?php } ?>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <!-- START OF FOOTER -->
  203. <!-- Course footer as per 2.4 callbacks-->
  204. <?php if (!empty($coursefooter)) { ?>
  205. <div id="course-footer"><?php echo $coursefooter; ?></div>
  206. <?php } ?>
  207. <!--Main theme footer-->
  208. <?php if ($hasfooter) { ?>
  209. <div id="page-footer" class="clearfix">
  210. <div class="footnote"><?php echo $footnote; ?></div>
  211. <p class="helplink"><?php echo page_doc_link(get_string('moodledocslink')) ?></p>
  212. <?php
  213. echo $OUTPUT->login_info();
  214. echo $OUTPUT->home_link();
  215. echo $OUTPUT->standard_footer_html();
  216. ?>
  217. </div>
  218. <?php } ?>
  219. </div>
  220. <!-- Responsive scripts - called as required from theme settings -->
  221. <?php if ($requirescf) {
  222. $PAGE->requires->js(new moodle_url('http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js')); ?>
  223. <script>
  224. //<![CDATA[
  225. window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})
  226. //]]>
  227. </script>
  228. <?php }
  229. if ($requiresrespond) {
  230. if (!empty($CFG->themedir) and file_exists("$CFG->themedir/krystle")) {
  231. $PAGE->requires->js($CFG->themedir.'/krystle/yui/respond.js');
  232. } else {
  233. $PAGE->requires->js($CFG->dirroot.'/theme/krystle/yui/respond.js');
  234. }
  235. }
  236. if ($usingios) { //Check if the user is using iOS and serve a JS to fix a viewport re-flow bug
  237. if (!empty($CFG->themedir) and file_exists("$CFG->themedir/krystle")) {
  238. $PAGE->requires->js($CFG->themedir.'/krystle/yui/iOS-viewport-fix.js');
  239. } else {
  240. $PAGE->requires->js($CFG->dirroot.'/theme/krystle/yui/iOS-viewport-fix.js');
  241. }
  242. } ?>
  243. <!--Standard bottom of page-->
  244. <?php echo $OUTPUT->standard_end_of_body_html() ?>
  245. <!--Scroll to top arrow - see script in header-->
  246. <div id="back-to-top">
  247. <a class="arrow" href="#">▲</a>
  248. <a class="text" href="#">Back to Top</a>
  249. </div>
  250. </body>
  251. </html>