. /** * Moodle's Clean theme, an example of how to make a Bootstrap theme * * DO NOT MODIFY THIS THEME! * COPY IT FIRST, THEN RENAME THE COPY AND MODIFY IT INSTEAD. * * For full information about creating Moodle themes, see: * http://docs.moodle.org/dev/Themes_2.0 * * @package theme_clean * @copyright 2013 Moodle, moodle.org * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Parses CSS before it is cached. * * This function can make alterations and replace patterns within the CSS. * * @param string $css The CSS * @param theme_config $theme The theme config object. * @return string The parsed CSS The parsed CSS. */ function theme_clean_process_css($css, $theme) { // Set the background image for the logo. $logo = $theme->setting_file_url('logo', 'logo'); $css = theme_clean_set_logo($css, $logo); // Set custom CSS. if (!empty($theme->settings->customcss)) { $customcss = $theme->settings->customcss; } else { $customcss = null; } $css = theme_clean_set_customcss($css, $customcss); return $css; } /** * Adds the logo to CSS. * * @param string $css The CSS. * @param string $logo The URL of the logo. * @return string The parsed CSS */ function theme_clean_set_logo($css, $logo) { $tag = '[[setting:logo]]'; $replacement = $logo; if (is_null($replacement)) { $replacement = ''; } $css = str_replace($tag, $replacement, $css); return $css; } /** * Serves any files associated with the theme settings. * * @param stdClass $course * @param stdClass $cm * @param context $context * @param string $filearea * @param array $args * @param bool $forcedownload * @param array $options * @return bool */ function theme_clean_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) { if ($context->contextlevel == CONTEXT_SYSTEM and $filearea === 'logo') { $theme = theme_config::load('clean'); // By default, theme files must be cache-able by both browsers and proxies. if (!array_key_exists('cacheability', $options)) { $options['cacheability'] = 'public'; } return $theme->setting_file_serve('logo', $args, $forcedownload, $options); } else { send_file_not_found(); } } /** * Adds any custom CSS to the CSS before it is cached. * * @param string $css The original CSS. * @param string $customcss The custom CSS to add. * @return string The CSS which now contains our custom CSS. */ function theme_clean_set_customcss($css, $customcss) { $tag = '[[setting:customcss]]'; $replacement = $customcss; if (is_null($replacement)) { $replacement = ''; } $css = str_replace($tag, $replacement, $css); return $css; } /** * Returns an object containing HTML for the areas affected by settings. * * Do not add Clean specific logic in here, child themes should be able to * rely on that function just by declaring settings with similar names. * * @param renderer_base $output Pass in $OUTPUT. * @param moodle_page $page Pass in $PAGE. * @return stdClass An object with the following properties: * - navbarclass A CSS class to use on the navbar. By default ''. * - heading HTML to use for the heading. A logo if one is selected or the default heading. * - footnote HTML to use as a footnote. By default ''. */ function theme_clean_get_html_for_settings(renderer_base $output, moodle_page $page) { global $CFG; $return = new stdClass; $return->navbarclass = ''; if (!empty($page->theme->settings->invert)) { $return->navbarclass .= ' navbar-inverse'; } // Only display the logo on the front page and login page, if one is defined. if (!empty($page->theme->settings->logo) && ($page->pagelayout == 'frontpage' || $page->pagelayout == 'login')) { $return->heading = html_writer::tag('div', '', array('class' => 'logo')); } else { $return->heading = $output->page_heading(); } $return->footnote = ''; if (!empty($page->theme->settings->footnote)) { $return->footnote = '
'.format_text($page->theme->settings->footnote).'
'; } return $return; } /** * All theme functions should start with theme_clean_ * @deprecated since 2.5.1 */ function clean_process_css() { throw new coding_exception('Please call theme_'.__FUNCTION__.' instead of '.__FUNCTION__); } /** * All theme functions should start with theme_clean_ * @deprecated since 2.5.1 */ function clean_set_logo() { throw new coding_exception('Please call theme_'.__FUNCTION__.' instead of '.__FUNCTION__); } /** * All theme functions should start with theme_clean_ * @deprecated since 2.5.1 */ function clean_set_customcss() { throw new coding_exception('Please call theme_'.__FUNCTION__.' instead of '.__FUNCTION__); }