]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20799 renewed support for alternative theme dir location
authorPetr Skoda <skodak@moodle.org>
Wed, 23 Dec 2009 18:52:42 +0000 (18:52 +0000)
committerPetr Skoda <skodak@moodle.org>
Wed, 23 Dec 2009 18:52:42 +0000 (18:52 +0000)
config-dist.php
lib/moodlelib.php
theme/image.php
theme/javascripts.php
theme/styles.php
theme/styles_debug.php

index 7e87ead75648e49ee187240e98e8182f6b8d2516..94d8ab0310bf1113797b1440ccb305b36916088f 100644 (file)
@@ -330,8 +330,6 @@ $CFG->admin = 'admin';
 //
 //     $CFG->emailconnectionerrorsto = 'your@emailaddress.com';
 //
-// NOTE: if you are using custompix in your theme, see /fixpix.php.
-//
 // Set the priority of themes from highest to lowest. This is useful (for
 // example) in sites where the user theme should override all other theme
 // settings for accessibility reasons. You can also disable types of themes
@@ -340,7 +338,11 @@ $CFG->admin = 'admin';
 // NOTE: course, category, session, user themes still require the
 // respective settings to be enabled
 //
-
+// It is possible to add extra themes directory stored outside of $CFG->dirroot.
+// This local directory does not have to be accessible from internet.
+//
+//     $CFG->themedir = '/location/of/extra/themes';
+//
 //=========================================================================
 // 8. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!!
 //=========================================================================
index 8de666157a53830eb21921d6ebf35d16add43713..0e17e1f9aa57fbb7e4034d4aa64e2be49e2faa4a 100644 (file)
@@ -714,7 +714,9 @@ function clean_param($param, $type) {
 
         case PARAM_THEME:
             $param = clean_param($param, PARAM_SAFEDIR);
-            if (file_exists($CFG->dirroot.'/theme/'.$param)) {
+            if (file_exists("$CFG->dirroot/theme/$param/config.php")) {
+                return $param;
+            } else if (!empty($CFG->themedir) and file_exists("$CFG->themedir/$param/config.php")) {
                 return $param;
             } else {
                 return '';  // Specified theme is not installed
@@ -6798,8 +6800,11 @@ function get_plugin_list($plugintype) {
         $fulldirs[] = $CFG->dirroot.'/mod';
 
     } else if ($plugintype === 'theme') {
-        // themes are an exception because they may be stored also in dataroot
         $fulldirs[] = $CFG->dirroot.'/theme';
+        // themes are special because they may be stored also in separate directory
+        if (!empty($CFG->themedir) and file_exists($CFG->themedir) and is_dir($CFG->themedir) ) {
+            $fulldirs[] = $CFG->themedir;
+        }
 
     } else {
         $types = get_plugin_types(true);
@@ -6815,8 +6820,6 @@ function get_plugin_list($plugintype) {
 
     $result = array();
 
-    //TODO: MDL-20799 add themedir support
-
     foreach ($fulldirs as $fulldir) {
         if (!is_dir($fulldir)) {
             continue;
@@ -6863,7 +6866,6 @@ function get_list_of_plugins($directory='mod', $exclude='', $basedir='') {
     $plugins = array();
 
     if (empty($basedir)) {
-        // TODO: MDL-20799 megre theme with themedir if defined
         $basedir = $CFG->dirroot .'/'. $directory;
 
     } else {
index 27ccacf298eaf3fe68c933355a982f6fa81dd7ae..28ccd214da3dc9ea8acf03b071f395ed089692a0 100644 (file)
@@ -23,6 +23,7 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+
 // we need just the values from config.php and minlib.php
 define('ABORT_AFTER_CONFIG', true);
 require('../config.php'); // this stops immediately at the beginning of lib/setup.php
@@ -36,7 +37,11 @@ if (empty($component) or empty($image)) {
     image_not_found();
 }
 
-if (!file_exists("$CFG->dirroot/theme/$themename/config.php") and !file_exists("$CFG->dataroot/theme/$themename/config.php")) {
+if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
+    // exists
+} else if (!empty($CFG->themedir) and file_exists("$CFG->themedir/$themename/config.php")) {
+    // exists
+} else {
     image_not_found();
 }
 
index 7667397eaa97d4b374484850fd2746641e1fbea7..f347b11c023c6a4c0c199db7ebd5dc6ed4b74b40 100644 (file)
@@ -31,7 +31,11 @@ require('../config.php'); // this stops immediately at the beginning of lib/setu
 $themename = min_optional_param('theme', 'standard', 'SAFEDIR');
 $rev       = min_optional_param('rev', 0, 'INT');
 
-if (!file_exists("$CFG->dirroot/theme/$themename/config.php") and !file_exists("$CFG->dataroot/theme/$themename/config.php")) {
+if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
+    // exists
+} else if (!empty($CFG->themedir) and file_exists("$CFG->themedir/$themename/config.php")) {
+    // exists
+} else {
     header('HTTP/1.0 404 not found');
     die('Theme was not found, sorry.');
 }
index 4be3059314ac4b8f36eac347589959af98ed8973..a68fc2bf91c0fcbab8f1c2a023f3f74ef5bcbf2a 100644 (file)
@@ -23,6 +23,7 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+
 // we need just the values from config.php and minlib.php
 define('ABORT_AFTER_CONFIG', true);
 require('../config.php'); // this stops immediately at the beginning of lib/setup.php
@@ -36,7 +37,11 @@ if (!in_array($type, array('all', 'ie', 'editor', 'yui', 'plugins', 'parents', '
     die('Theme was not found, sorry.');
 }
 
-if (!file_exists("$CFG->dirroot/theme/$themename/config.php") and !file_exists("$CFG->dataroot/theme/$themename/config.php")) {
+if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
+    // exists
+} else if (!empty($CFG->themedir) and file_exists("$CFG->themedir/$themename/config.php")) {
+    // exists
+} else {
     header('HTTP/1.0 404 not found');
     die('Theme was not found, sorry.');
 }
index d558d7e9339a38c310d6383c3dc627a6ae52d23b..c35903b7a8198866e62750cb26abf2cef4f68ec3 100644 (file)
@@ -23,6 +23,7 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+
 // no chaching
 define('NO_MOODLE_COOKIES', true); // Session not used here
 define('NO_UPGRADE_CHECK', true);  // Ignore upgrade check
@@ -33,7 +34,11 @@ $type      = required_param('type', PARAM_SAFEDIR);
 $subtype   = optional_param('subtype', '', PARAM_SAFEDIR);
 $sheet     = optional_param('sheet', '', PARAM_SAFEDIR);
 
-if (!file_exists("$CFG->dirroot/theme/$themename/config.php") and !file_exists("$CFG->dataroot/theme/$themename/config.php")) {
+if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
+    // exists
+} else if (!empty($CFG->themedir) and file_exists("$CFG->themedir/$themename/config.php")) {
+    // exists
+} else {
     css_not_found();
 }