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