Example #1
0
/**
 * Returns the html for the <header> of the document.
 *
 * @param renderer_base $output Pass in $OUTPUT.
 * @param moodle_page $page Pass in $PAGE.
 * @return string The html.
 */
function theme_ws_html_header(renderer_base $output, moodle_page $page)
{
    global $CFG;
    //if the sitetitle hasn't been set, then set to the default
    if (empty($page->theme->settings->sitetitle)) {
        $page->theme->settings->sitetitle = get_string('sitetitledefault', 'theme_ws');
    }
    //save a css class to indicate whether there is a logo image or not
    $logoimg = 'no-logo-img';
    //if a logo file has been specified, then use it
    if (!empty($page->theme->settings->logo)) {
        $src = $page->theme->setting_file_url('logo', 'logo');
        $brand = '<img alt="' . $page->theme->settings->sitetitle . '" src="' . $src . '">';
        $logoimg = 'logo-img';
        //if no logo file is specified, then use the site title
    } else {
        $brand = '<span class="site-title">' . $page->theme->settings->sitetitle . '</span>';
    }
    return '
	<header role="banner" class="navbar navbar-static-top moodle-has-zindex' . (!empty($page->theme->settings->sitesubtitle) ? ' hassubtitle' : '') . '">
    <nav role="navigation" class="navbar-inner">
        <div class="container-fluid ' . $logoimg . '">
			<a class="brand" href="' . $CFG->wwwroot . '">
				' . $brand . '
			</a>
			' . (!empty($page->theme->settings->sitesubtitle) ? '<span class="sitesubtitle">' . $page->theme->settings->sitesubtitle . '</span>' : '') . '
			' . (!empty($page->theme->settings->helpurl) ? '<a class="helpbtn" title="help" href="' . $page->theme->settings->helpurl . '" target="_blank"><span>?</span></a>' : '') . '
			' . ($output->custom_menu() || $output->page_heading_menu() ? '<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>' : '') . $output->user_menu() . '
            <div class="nav-collapse collapse">
                ' . $output->custom_menu() . '
                <ul class="nav pull-right">
                    <li>' . $output->page_heading_menu() . '</li>
                </ul>
            </div>
        </div>
    </nav>
</header>
';
}