[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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/>. 16 17 require_once($CFG->dirroot . '/theme/bootstrapbase/renderers.php'); 18 19 /** 20 * Clean core renderers. 21 * 22 * @package theme_clean 23 * @copyright 2015 Frédéric Massart - FMCorz.net 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 class theme_clean_core_renderer extends theme_bootstrapbase_core_renderer { 27 28 /** 29 * Either returns the parent version of the header bar, or a version with the logo replacing the header. 30 * 31 * @since Moodle 2.9 32 * @param array $headerinfo An array of header information, dependant on what type of header is being displayed. The following 33 * array example is user specific. 34 * heading => Override the page heading. 35 * user => User object. 36 * usercontext => user context. 37 * @param int $headinglevel What level the 'h' tag will be. 38 * @return string HTML for the header bar. 39 */ 40 public function context_header($headerinfo = null, $headinglevel = 1) { 41 42 if ($this->should_render_logo($headinglevel)) { 43 return html_writer::tag('div', '', array('class' => 'logo')); 44 } 45 return parent::context_header($headerinfo, $headinglevel); 46 } 47 48 /** 49 * Determines if we should render the logo. 50 * 51 * @param int $headinglevel What level the 'h' tag will be. 52 * @return bool Should the logo be rendered. 53 */ 54 protected function should_render_logo($headinglevel = 1) { 55 global $PAGE; 56 57 // Only render the logo if we're on the front page or login page 58 // and the theme has a logo. 59 if ($headinglevel == 1 && !empty($this->page->theme->settings->logo)) { 60 if ($PAGE->pagelayout == 'frontpage' || $PAGE->pagelayout == 'login') { 61 return true; 62 } 63 } 64 65 return false; 66 } 67 68 /** 69 * Returns the navigation bar home reference. 70 * 71 * The small logo is only rendered on pages where the logo is not displayed. 72 * 73 * @param bool $returnlink Whether to wrap the icon and the site name in links or not 74 * @return string The site name, the small logo or both depending on the theme settings. 75 */ 76 public function navbar_home($returnlink = true) { 77 global $CFG; 78 79 if ($this->should_render_logo() || empty($this->page->theme->settings->smalllogo)) { 80 // If there is no small logo we always show the site name. 81 return $this->get_home_ref($returnlink); 82 } 83 $imageurl = $this->page->theme->setting_file_url('smalllogo', 'smalllogo'); 84 $image = html_writer::img($imageurl, get_string('sitelogo', 'theme_' . $this->page->theme->name), 85 array('class' => 'small-logo')); 86 87 if ($returnlink) { 88 $logocontainer = html_writer::link(new moodle_url('/'), $image, 89 array('class' => 'small-logo-container', 'title' => get_string('home'))); 90 } else { 91 $logocontainer = html_writer::tag('span', $image, array('class' => 'small-logo-container')); 92 } 93 94 // Sitename setting defaults to true. 95 if (!isset($this->page->theme->settings->sitename) || !empty($this->page->theme->settings->sitename)) { 96 return $logocontainer . $this->get_home_ref($returnlink); 97 } 98 99 return $logocontainer; 100 } 101 102 /** 103 * Returns a reference to the site home. 104 * 105 * It can be either a link or a span. 106 * 107 * @param bool $returnlink 108 * @return string 109 */ 110 protected function get_home_ref($returnlink = true) { 111 global $CFG, $SITE; 112 113 $sitename = format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID))); 114 115 if ($returnlink) { 116 return html_writer::link(new moodle_url('/'), $sitename, array('class' => 'brand', 'title' => get_string('home'))); 117 } 118 119 return html_writer::tag('span', $sitename, array('class' => 'brand')); 120 } 121 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |