From d85f228f185401ffce1fd4b089a1f97661dc286c Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 12 Jun 2013 13:01:26 +1200 Subject: [PATCH] MDL-40137 theme_clean: corrected lib.php function names --- theme/clean/config.php | 2 +- theme/clean/lib.php | 70 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/theme/clean/config.php b/theme/clean/config.php index 240f5b67939..f4aa1578fad 100644 --- a/theme/clean/config.php +++ b/theme/clean/config.php @@ -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', diff --git a/theme/clean/lib.php b/theme/clean/lib.php index c8cf9f2f717..e8f7698f502 100644 --- a/theme/clean/lib.php +++ b/theme/clean/lib.php @@ -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__); } \ No newline at end of file