Merge branch 'wip-MDL-40137-m26' of git://github.com/samhemelryk/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2013-06-18 01:43:57 +02:00
commit 421e6decf4
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->rendererfactory = 'theme_overridden_renderer_factory';
$THEME->csspostprocess = 'clean_process_css'; $THEME->csspostprocess = 'theme_clean_process_css';
$THEME->blockrtlmanipulations = array( $THEME->blockrtlmanipulations = array(
'side-pre' => 'side-post', 'side-pre' => 'side-post',

View File

@ -28,11 +28,20 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @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. // Set the background image for the logo.
$logo = $theme->setting_file_url('logo', 'logo'); $logo = $theme->setting_file_url('logo', 'logo');
$css = clean_set_logo($css, $logo); $css = theme_clean_set_logo($css, $logo);
// Set custom CSS. // Set custom CSS.
if (!empty($theme->settings->customcss)) { if (!empty($theme->settings->customcss)) {
@ -40,13 +49,19 @@ function clean_process_css($css, $theme) {
} else { } else {
$customcss = null; $customcss = null;
} }
$css = clean_set_customcss($css, $customcss); $css = theme_clean_set_customcss($css, $customcss);
return $css; 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]]'; $tag = '[[setting:logo]]';
$replacement = $logo; $replacement = $logo;
if (is_null($replacement)) { if (is_null($replacement)) {
@ -58,6 +73,18 @@ function clean_set_logo($css, $logo) {
return $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()) { function theme_clean_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
if ($context->contextlevel == CONTEXT_SYSTEM and $filearea === 'logo') { if ($context->contextlevel == CONTEXT_SYSTEM and $filearea === 'logo') {
$theme = theme_config::load('clean'); $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]]'; $tag = '[[setting:customcss]]';
$replacement = $customcss; $replacement = $customcss;
if (is_null($replacement)) { if (is_null($replacement)) {
@ -111,3 +145,27 @@ function theme_clean_get_html_for_settings(renderer_base $output, moodle_page $p
return $return; 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__);
}