PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/layout/general.php

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