From a44091bffe08230d545284db510728320fda1b2d Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 9 Oct 2006 10:12:41 +0000 Subject: [PATCH] Fixing Theme Config Variables MDL-6784 --- course/search.php | 2 +- lib/moodlelib.php | 19 ++++++++++++++++--- lib/setup.php | 11 +++++++---- lib/weblib.php | 28 ++++++++++++++-------------- theme/chameleon/footer.html | 6 +++--- theme/chameleon/header.html | 2 +- theme/chameleon/ui/chameleon.php | 8 ++++---- theme/cornflower/footer.html | 2 +- theme/cornflower/header.html | 11 ++++++----- theme/formal_white/header.html | 8 ++++---- theme/index.php | 10 +++++----- theme/metal/header.html | 2 +- theme/oceanblue/header.html | 2 +- theme/orangewhite/header.html | 4 ++-- theme/orangewhitepda/header.html | 2 +- theme/preview.php | 2 +- theme/standard/header.html | 2 +- theme/standardblue/header.html | 2 +- theme/standardgreen/header.html | 2 +- theme/standardlogo/header.html | 4 ++-- theme/standardred/header.html | 2 +- theme/standardwhite/header.html | 2 +- theme/wood/header.html | 2 +- 23 files changed, 76 insertions(+), 59 deletions(-) diff --git a/course/search.php b/course/search.php index e2d5d7a4483..652f2370b37 100644 --- a/course/search.php +++ b/course/search.php @@ -176,7 +176,7 @@ if (empty($THEME->custompix)) { $pixpath = "$CFG->wwwroot/pix"; } else { - $pixpath = "$CFG->wwwroot/theme/$CFG->theme/pix"; + $pixpath = "$CFG->themedir/$CFG->theme/pix"; } echo "wwwroot/course/edit.php?id=$course->id\"> "; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 29bb598ff81..8519da19ea4 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -4670,11 +4670,11 @@ function get_list_of_themes() { } foreach ($themelist as $key => $theme) { - if (!file_exists("$CFG->dirroot/theme/$theme/config.php")) { // bad folder + if (!file_exists("$CFG->themedir/$theme/config.php")) { // bad folder continue; } unset($THEME); // Note this is not the global one!! :-) - include("$CFG->dirroot/theme/$theme/config.php"); + include("$CFG->themedir/$theme/config.php"); if (!isset($THEME->sheets)) { // Not a valid 1.5 theme continue; } @@ -5127,10 +5127,21 @@ function get_list_of_plugins($plugin='mod', $exclude='', $basedir='') { $plugins = array(); if (empty($basedir)) { - $basedir = $CFG->dirroot .'/'. $plugin; + + # This switch allows us to use the appropiate theme directory - and potentialy alternatives for other plugins + switch ($plugin) { + case "theme": + $basedir = $CFG->themedir; + break; + + default: + $basedir = $CFG->dirroot .'/'. $plugin; + } + } else { $basedir = $basedir .'/'. $plugin; } + if (file_exists($basedir) && filetype($basedir) == 'dir') { $dirhandle = opendir($basedir); while (false !== ($dir = readdir($dirhandle))) { @@ -5978,8 +5989,10 @@ function httpsrequired() { if (!empty($CFG->loginhttps)) { $HTTPSPAGEREQUIRED = true; $CFG->httpswwwroot = str_replace('http:', 'https:', $CFG->wwwroot); + $CFG->httpsthemewww = str_replace('http:', 'https:', $CFG->themewww); } else { $CFG->httpswwwroot = $CFG->wwwroot; + $CFG->httpsthemewww = $CFG->themewww; } } diff --git a/lib/setup.php b/lib/setup.php index c28c8236a30..c23a806f4b8 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -496,15 +496,18 @@ $CFG->os = PHP_OS; /// Load up theme variables (colours etc) if (!isset($CFG->themedir)) { - $CFG->themedir = $CFG->dirroot.'/theme/'; - $CFG->themewww = $CFG->wwwroot.'/theme/'; + $CFG->themedir = $CFG->dirroot.'/theme'; + $CFG->themewww = $CFG->wwwroot.'/theme'; } + $CFG->httpsthemewww = $CFG->themewww; if (isset($_GET['theme'])) { if ($CFG->allowthemechangeonurl || confirm_sesskey()) { - if (!detect_munged_arguments($_GET['theme'], 0) and file_exists($CFG->themedir. $_GET['theme'])) { - $SESSION->theme = $_GET['theme']; + $themename = clean_param($_GET['theme'], PARAM_SAFEDIR); + if (($themename != '') and file_exists($CFG->themedir.'/'.$themename)) { + $SESSION->theme = $themename; } + unset($themename); } } diff --git a/lib/weblib.php b/lib/weblib.php index be2e6842fdf..1aa70fa2f31 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2414,7 +2414,7 @@ function style_sheet_setup($lastmodified=0, $lifetime=300, $themename='', $force if (!empty($forceconfig)) { // Page wants to use the config from this theme instead unset($THEME); - include($CFG->themedir.$forceconfig.'/'.'config.php'); + include($CFG->themedir.'/'.$forceconfig.'/'.'config.php'); } /// If this is the standard theme calling us, then find out what sheets we need @@ -2445,8 +2445,8 @@ function style_sheet_setup($lastmodified=0, $lifetime=300, $themename='', $force /// Work out the last modified date for this theme foreach ($THEME->sheets as $sheet) { - if (file_exists($CFG->themedir.$themename.'/'.$sheet.'.css')) { - $sheetmodified = filemtime($CFG->themedir.$themename.'/'.$sheet.'.css'); + if (file_exists($CFG->themedir.'/'.$themename.'/'.$sheet.'.css')) { + $sheetmodified = filemtime($CFG->themedir.'/'.$themename.'/'.$sheet.'.css'); if ($sheetmodified > $lastmodified) { $lastmodified = $sheetmodified; } @@ -2504,12 +2504,12 @@ function style_sheet_setup($lastmodified=0, $lifetime=300, $themename='', $force /// Actually output all the files in order. foreach ($files as $file) { echo '/***** '.$file[1].' start *****/'."\n\n"; - @include_once($file[0].$file[1]); + @include_once($file[0].'/'.$file[1]); echo '/***** '.$file[1].' end *****/'."\n\n"; } } - return $CFG->themewww.$themename; // Only to help old themes (1.4 and earlier) + return $CFG->themewww.'/'.$themename; // Only to help old themes (1.4 and earlier) } @@ -2523,13 +2523,13 @@ function theme_setup($theme = '', $params=NULL) { } /// If the theme doesn't exist for some reason then revert to standardwhite - if (!file_exists($CFG->themedir. $theme .'/config.php')) { + if (!file_exists($CFG->themedir .'/'. $theme .'/config.php')) { $CFG->theme = $theme = 'standardwhite'; } /// Load up the theme config $THEME = NULL; // Just to be sure - include($CFG->themedir. $theme .'/config.php'); // Main config for current theme + include($CFG->themedir .'/'. $theme .'/config.php'); // Main config for current theme /// Put together the parameters if (!$params) { @@ -2556,23 +2556,23 @@ function theme_setup($theme = '', $params=NULL) { $CFG->pixpath = $CFG->wwwroot .'/pix'; $CFG->modpixpath = $CFG->wwwroot .'/mod'; } else { - $CFG->pixpath = $CFG->themewww . $theme .'/pix'; - $CFG->modpixpath = $CFG->themewww . $theme .'/pix/mod'; + $CFG->pixpath = $CFG->themewww .'/'. $theme .'/pix'; + $CFG->modpixpath = $CFG->themewww .'/'. $theme .'/pix/mod'; } /// Header and footer paths - $CFG->header = $CFG->themedir . $theme .'/header.html'; - $CFG->footer = $CFG->themedir . $theme .'/footer.html'; + $CFG->header = $CFG->themedir .'/'. $theme .'/header.html'; + $CFG->footer = $CFG->themedir .'/'. $theme .'/footer.html'; /// Define stylesheet loading order $CFG->stylesheets = array(); if ($theme != 'standard') { /// The standard sheet is always loaded first - $CFG->stylesheets[] = $CFG->themewww.'standard/styles.php'.$paramstring; + $CFG->stylesheets[] = $CFG->themewww.'/standard/styles.php'.$paramstring; } if (!empty($THEME->parent)) { /// Parent stylesheets are loaded next - $CFG->stylesheets[] = $CFG->themewww.$THEME->parent.'/styles.php'.$paramstring; + $CFG->stylesheets[] = $CFG->themewww.'/'.$THEME->parent.'/styles.php'.$paramstring; } - $CFG->stylesheets[] = $CFG->themewww.$theme.'/styles.php'.$paramstring; + $CFG->stylesheets[] = $CFG->themewww.'/'.$theme.'/styles.php'.$paramstring; } diff --git a/theme/chameleon/footer.html b/theme/chameleon/footer.html index dd44283c711..a54e3d9567b 100644 --- a/theme/chameleon/footer.html +++ b/theme/chameleon/footer.html @@ -14,9 +14,9 @@

- +

diff --git a/theme/chameleon/header.html b/theme/chameleon/header.html index 25f5d43c8e4..78c7601dc03 100644 --- a/theme/chameleon/header.html +++ b/theme/chameleon/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> diff --git a/theme/chameleon/ui/chameleon.php b/theme/chameleon/ui/chameleon.php index 4de72d9ed06..3bf627c2fd0 100644 --- a/theme/chameleon/ui/chameleon.php +++ b/theme/chameleon/ui/chameleon.php @@ -20,11 +20,11 @@ if (isset($THEME->chameleonenabled) && $THEME->chameleonenabled) { $chameleon_theme = (isset($CFG->coursetheme)) ? $CFG->coursetheme : current_theme(); ?> - + - - - + + + -

+

diff --git a/theme/cornflower/header.html b/theme/cornflower/header.html index 2461dfe3b38..321854f0a49 100644 --- a/theme/cornflower/header.html +++ b/theme/cornflower/header.html @@ -4,11 +4,11 @@ <?php echo $title ?> - + javascript"); ?> - - +
@@ -38,13 +38,14 @@
- +
- +
diff --git a/theme/formal_white/header.html b/theme/formal_white/header.html index 7ab4d12bda5..2e8efcc4434 100644 --- a/theme/formal_white/header.html +++ b/theme/formal_white/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> @@ -21,13 +21,13 @@ if ($home) { // This is what gets printed on the home page only ?>
-

Moodle/logo.jpg' />

+

Moodle/logo.jpg' />

@@ -42,4 +42,4 @@
-
\ No newline at end of file +
diff --git a/theme/index.php b/theme/index.php index 09801b8c6cc..df5a70f6edf 100644 --- a/theme/index.php +++ b/theme/index.php @@ -23,7 +23,7 @@ if ($choose and confirm_sesskey()) { - if (!is_dir($choose)) { + if (!is_dir($CFG->themedir .'/'. $choose)) { error("This theme is not installed!"); } if (set_config("theme", $choose)) { @@ -64,11 +64,11 @@ unset($THEME); - if (!file_exists($CFG->themedir.$theme.'/config.php')) { // bad folder + if (!file_exists($CFG->themedir.'/'.$theme.'/config.php')) { // bad folder continue; } - include($CFG->themedir.$theme.'/config.php'); + include($CFG->themedir.'/'.$theme.'/config.php'); $readme = ''; $screenshot = ''; @@ -76,10 +76,10 @@ if (file_exists("$theme/README.html")) { $readme = '
  • '. - link_to_popup_window('/theme/'.$theme.'/README.html', $theme, $strinfo, 400, 500, '', 'none', true).'
  • '; + link_to_popup_window($CFG->themewww .'/'. $theme .'/README.html', $theme, $strinfo, 400, 500, '', 'none', true).''; } else if (file_exists("$theme/README.txt")) { $readme = '
  • '. - link_to_popup_window('/theme/'.$theme.'/README.txt', $theme, $strinfo, 400, 500, '', 'none', true).'
  • '; + link_to_popup_window($CFG->themewww .'/'. $theme .'/README.txt', $theme, $strinfo, 400, 500, '', 'none', true).''; } if (file_exists("$theme/screenshot.png")) { $screenshotpath = "$theme/screenshot.png"; diff --git a/theme/metal/header.html b/theme/metal/header.html index 7a0023c4be4..292c09f6cb9 100644 --- a/theme/metal/header.html +++ b/theme/metal/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> diff --git a/theme/oceanblue/header.html b/theme/oceanblue/header.html index 637f22b2e70..a6716ce4a0f 100644 --- a/theme/oceanblue/header.html +++ b/theme/oceanblue/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> diff --git a/theme/orangewhite/header.html b/theme/orangewhite/header.html index aebd7d7d863..85c5518fd2c 100644 --- a/theme/orangewhite/header.html +++ b/theme/orangewhite/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> @@ -41,4 +41,4 @@
    -
    \ No newline at end of file +
    diff --git a/theme/orangewhitepda/header.html b/theme/orangewhitepda/header.html index 89d94d08177..85c5518fd2c 100644 --- a/theme/orangewhitepda/header.html +++ b/theme/orangewhitepda/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> diff --git a/theme/preview.php b/theme/preview.php index dbd44096efc..2d29504181c 100644 --- a/theme/preview.php +++ b/theme/preview.php @@ -4,7 +4,7 @@ $preview = optional_param('preview','standard',PARAM_FILE); // which theme to show - if (!file_exists($preview)) { + if (!file_exists($CFG->themedir .'/'. $preview)) { $preview = 'standard'; } diff --git a/theme/standard/header.html b/theme/standard/header.html index 9ad45ffe698..2968d1aa3f2 100644 --- a/theme/standard/header.html +++ b/theme/standard/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> diff --git a/theme/standardblue/header.html b/theme/standardblue/header.html index 7a0023c4be4..292c09f6cb9 100644 --- a/theme/standardblue/header.html +++ b/theme/standardblue/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> diff --git a/theme/standardgreen/header.html b/theme/standardgreen/header.html index 7a0023c4be4..292c09f6cb9 100644 --- a/theme/standardgreen/header.html +++ b/theme/standardgreen/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> diff --git a/theme/standardlogo/header.html b/theme/standardlogo/header.html index df9836c89c3..14226c71b35 100644 --- a/theme/standardlogo/header.html +++ b/theme/standardlogo/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> @@ -35,7 +35,7 @@ $standardlogo = $CFG->httpswwwroot.'/file.php/1/logo.gif'; } } else { - $standardlogo = $CFG->httpswwwroot.'/theme/'.current_theme().'/logo.gif'; + $standardlogo = $CFG->httpsthemewww .'/'. current_theme().'/logo.gif'; } //Accessibility: warning: ALT text will need editing if logo changes. 'headermain' is now H1. diff --git a/theme/standardred/header.html b/theme/standardred/header.html index 7a0023c4be4..292c09f6cb9 100644 --- a/theme/standardred/header.html +++ b/theme/standardred/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> diff --git a/theme/standardwhite/header.html b/theme/standardwhite/header.html index a5351c26b22..d87f2fde680 100644 --- a/theme/standardwhite/header.html +++ b/theme/standardwhite/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?> diff --git a/theme/wood/header.html b/theme/wood/header.html index 7a0023c4be4..292c09f6cb9 100644 --- a/theme/wood/header.html +++ b/theme/wood/header.html @@ -4,7 +4,7 @@ <?php echo $title ?> - + javascript"); ?>