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
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;
}
/// Add the required stylesheets
- $stylesheets = '';
- $theme = current_theme();
- if ($theme != 'standard') { /// The standard sheet is always loaded first
- $stylesheets .= '<link rel="stylesheet" type="text/css" href="'.
- $CFG->wwwroot.'/theme/standard/styles.php" />'."\n";
- }
- if (!empty($THEME->parent)) { /// Parent stylesheets are loaded next
- $stylesheets .= '<link rel="stylesheet" type="text/css" href="'.
- $CFG->wwwroot.'/theme/'.$THEME->parent.'/styles.php?parent=true" />'."\n";
+ $stylesheetshtml = '';
+ foreach ($CFG->stylesheets as $stylesheet) {
+ $stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n";
}
- $stylesheets .= '<link rel="stylesheet" type="text/css" href="'.
- $CFG->wwwroot.'/theme/'.$theme.'/styles.php" />'."\n";
-
- $meta = $stylesheets.$meta;
+ $meta = $stylesheetshtml.$meta;
if ($navigation == 'home') {
}
+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