MDL-40137 theme_clean: corrected lib.php function names

This commit is contained in:
Sam Hemelryk 2013-06-12 13:01:26 +12:00
parent f192883305
commit d85f228f18
2 changed files with 65 additions and 7 deletions

View File

@ -54,7 +54,7 @@ $THEME->plugins_exclude_sheets = array(
);
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
$THEME->csspostprocess = 'clean_process_css';
$THEME->csspostprocess = 'theme_clean_process_css';
$THEME->blockrtlmanipulations = array(
'side-pre' => 'side-post',

View File

@ -28,11 +28,20 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function clean_process_css($css, $theme) {
/**
* 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 = clean_set_logo($css, $logo);
$css = theme_clean_set_logo($css, $logo);
// Set custom CSS.
if (!empty($theme->settings->customcss)) {
@ -40,13 +49,19 @@ function clean_process_css($css, $theme) {
} else {
$customcss = null;
}
$css = clean_set_customcss($css, $customcss);
$css = theme_clean_set_customcss($css, $customcss);
return $css;
}
function clean_set_logo($css, $logo) {
global $OUTPUT;
/**
* 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)) {
@ -58,6 +73,18 @@ function clean_set_logo($css, $logo) {
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');
@ -67,7 +94,14 @@ function theme_clean_pluginfile($course, $cm, $context, $filearea, $args, $force
}
}
function clean_set_customcss($css, $customcss) {
/**
* 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)) {
@ -110,4 +144,28 @@ function theme_clean_get_html_for_settings(renderer_base $output, moodle_page $p
}
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__);
}