From d74d4f20530cc2d8c7e2236b27cd2fbb46e5e20c Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 31 Jan 2005 05:59:13 +0000 Subject: [PATCH] Some changes in the way theme setup is achieved, there is now a function for it called theme_setup --- lib/setup.php | 14 +----------- lib/weblib.php | 60 ++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 25f9e9b8c6..8917a25938 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -223,20 +223,8 @@ global $THEME; if (!isset($CFG->theme)) { $CFG->theme = 'standard'; } - $currenttheme = current_theme(); - include($CFG->dirroot .'/theme/'. $currenttheme .'/config.php'); - if (empty($CFG->custompix)) { // Could be set in the above file - $CFG->pixpath = $CFG->wwwroot .'/pix'; - $CFG->modpixpath = $CFG->wwwroot .'/mod'; - } else { - $CFG->pixpath = $CFG->wwwroot .'/theme/'. $currenttheme .'/pix'; - $CFG->modpixpath = $CFG->wwwroot .'/theme/'. $currenttheme .'/pix/mod'; - } - - $CFG->stylesheet = $CFG->wwwroot .'/theme/'. $currenttheme .'/styles.php'; - $CFG->header = $CFG->dirroot .'/theme/'. $currenttheme .'/header.html'; - $CFG->footer = $CFG->dirroot .'/theme/'. $currenttheme .'/footer.html'; + theme_setup(); // Sets up theme global variables /// A hack to get around magic_quotes_gpc being turned off diff --git a/lib/weblib.php b/lib/weblib.php index 76429b2be7..afae6a39fc 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1490,7 +1490,7 @@ function highlightfast($needle, $haystack) { function print_header ($title='', $heading='', $navigation='', $focus='', $meta='', $cache=true, $button=' ', $menu='', $usexml=false, $bodytags='') { - global $USER, $CFG, $THEME, $SESSION, $ME; + global $USER, $CFG, $SESSION, $ME; /// This is an ugly hack to be replaced later by a proper global $COURSE global $course; @@ -1499,20 +1499,11 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta= } /// Add the required stylesheets - $stylesheets = ''; - $theme = current_theme(); - if ($theme != 'standard') { /// The standard sheet is always loaded first - $stylesheets .= ''."\n"; - } - if (!empty($THEME->parent)) { /// Parent stylesheets are loaded next - $stylesheets .= ''."\n"; + $stylesheetshtml = ''; + foreach ($CFG->stylesheets as $stylesheet) { + $stylesheetshtml .= ''."\n"; } - $stylesheets .= ''."\n"; - - $meta = $stylesheets.$meta; + $meta = $stylesheetshtml.$meta; if ($navigation == 'home') { @@ -1800,6 +1791,47 @@ function style_sheet_setup($lastmodified=0, $lifetime=300, $themename='') { } +function theme_setup($theme = '', $extraparams='') { +/// Sets up global variables related to themes + + global $CFG, $THEME; + + if (empty($theme)) { + $theme = current_theme(); + } + if (empty($extraparams)) { + $params = ''; + $paramsparent = '?parent=true'; + } else { + $params = '?'.$extraparams; + $paramsparent = '?parent=true&'.$extraparams; + } + + $THEME = null; + include($CFG->dirroot .'/theme/'. $theme .'/config.php'); + + if (empty($CFG->custompix)) { // Could be set in the above file + $CFG->pixpath = $CFG->wwwroot .'/pix'; + $CFG->modpixpath = $CFG->wwwroot .'/mod'; + } else { + $CFG->pixpath = $CFG->wwwroot .'/theme/'. $theme .'/pix'; + $CFG->modpixpath = $CFG->wwwroot .'/theme/'. $theme .'/pix/mod'; + } + + $CFG->header = $CFG->dirroot .'/theme/'. $theme .'/header.html'; + $CFG->footer = $CFG->dirroot .'/theme/'. $theme .'/footer.html'; + + $CFG->stylesheets = array(); + if ($theme != 'standard') { /// The standard sheet is always loaded first + $CFG->stylesheets[] = $CFG->wwwroot.'/theme/standard/styles.php'.$params; + } + if (!empty($THEME->parent)) { /// Parent stylesheets are loaded next + $CFG->stylesheets[] = $CFG->wwwroot.'/theme/'.$THEME->parent.'/styles.php'.$paramsparent; + } + $CFG->stylesheets[] = $CFG->wwwroot.'/theme/'.$theme.'/styles.php'.$params; + +} + /** * Returns text to be displayed to the user which reflects their login status -- 2.39.5