Some changes in the way theme setup is achieved, there is now a function
authormoodler <moodler>
Mon, 31 Jan 2005 05:59:13 +0000 (05:59 +0000)
committermoodler <moodler>
Mon, 31 Jan 2005 05:59:13 +0000 (05:59 +0000)
for it called theme_setup

lib/setup.php
lib/weblib.php

index 25f9e9b8c6c12f2cc643a068bf38bd710a7a77b2..8917a25938db778145e16d34ed2f8f5a0a145657 100644 (file)
@@ -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
index 76429b2be7a53831d6ef54addbca698e33fbd56d..afae6a39fce94044a09a51fb5e4ed9f445abc3c4 100644 (file)
@@ -1490,7 +1490,7 @@ function highlightfast($needle, $haystack) {
 function print_header ($title='', $heading='', $navigation='', $focus='', $meta='',
                        $cache=true, $button='&nbsp;', $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 .= '<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') {
@@ -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&amp;'.$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