Skip to content

Commit

Permalink
MDL-20799 renewed support for alternative theme dir location
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Dec 23, 2009
1 parent ea4e787 commit 73e504b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 12 deletions.
8 changes: 5 additions & 3 deletions config-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
//
// $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
Expand All @@ -340,7 +338,11 @@
// 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!!!
//=========================================================================
Expand Down
12 changes: 7 additions & 5 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion theme/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,7 +37,11 @@
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();
}

Expand Down
6 changes: 5 additions & 1 deletion theme/javascripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
$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.');
}
Expand Down
7 changes: 6 additions & 1 deletion theme/styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,7 +37,11 @@
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.');
}
Expand Down
7 changes: 6 additions & 1 deletion theme/styles_debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +34,11 @@
$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();
}

Expand Down

0 comments on commit 73e504b

Please sign in to comment.