PageRenderTime 75ms CodeModel.GetById 40ms app.highlight 18ms RepoModel.GetById 13ms app.codeStats 0ms

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