themes: MDL-19077 change how the theme is initialised and CSS is served.

This is part of http://docs.moodle.org/en/Development:Theme_engines_for_Moodle%3F

$THEME is now initialised at the same time as $OUTPUT. Old functions like
theme_setup are deprecated in favour of methods on $PAGE. There is a new
theme_config class in outputlib.php that deals with loading the theme config.php file.

CSS used to be served by themes styles.php files calling a function in weblib.php.
Now it works by each theme's styles.php file doing
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');
which is less code to be copied into each theme. (Old-style styles.php files still
work thanks to some code in deprecatedlib.php.)

Admin UI for choosing a theme cleaned up.

A couple of theme-specific hard-coded hacks like $THEME->cssconstants and
$THEME->CSSEdit have been replaced by a more generic $THEME->customcssoutputfunction
hook. See examples at the end of outputlib.php

Also:
* Fix setting the theme in the URL, which seems to have been broken since 1.9.
* Fix up errors on a few pages caused by the new initialisation order.
* MDL-19097 moodle_page::set_course should not set $COURSE unless it is $PAGE.
* httpsrequired() from moodlelib.php moved to $PAGE->https_required().
* Move has_started() method to the renderer base class.
* Further fixes to display of early errors.
* Remove print_header/footer_old from weblib. I did not mean to commit them before.
This commit is contained in:
tjhunt 2009-07-01 05:54:26 +00:00
parent 0456fc1ac4
commit b70094743a
37 changed files with 1646 additions and 1531 deletions

View file

@ -1,19 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$lifetime = 600; // Seconds to cache this stylesheet
$nomoodlecookie = true; // Cookies prevent caching, so don't use them
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,20 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,144 +1,144 @@
<?php // $Id$
<?php
require_once("../config.php");
require_once($CFG->libdir.'/adminlib.php');
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
$choose = optional_param("choose",'',PARAM_FILE); // set this theme as default
/**
* This page prvides the Administration -> ... -> Theme selector UI.
*/
admin_externalpage_setup('themeselector');
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/adminlib.php');
unset($SESSION->theme);
$choose = optional_param('choose', '', PARAM_FILE);
$stradministration = get_string("administration");
$strconfiguration = get_string("configuration");
$strthemes = get_string("themes");
$strpreview = get_string("preview");
$strchoose = get_string("choose");
$strinfo = get_string("info");
$strtheme = get_string("theme");
$strthemesaved = get_string("themesaved");
$strscreenshot = get_string("screenshot");
$stroldtheme = get_string("oldtheme");
admin_externalpage_setup('themeselector');
unset($SESSION->theme);
if ($choose and confirm_sesskey()) {
if (!is_dir($CFG->themedir .'/'. $choose)) {
print_error('themenotinstall');
}
if (set_config("theme", $choose)) {
theme_setup($choose);
admin_externalpage_print_header();
print_heading(get_string("themesaved"));
if ($choose and confirm_sesskey()) {
// The user has chosen one theme from the list of all themes, show a
// 'You have chosen a new theme' confirmation page.
if (file_exists("$choose/README.html")) {
print_box_start();
readfile("$choose/README.html");
print_box_end();
} else if (file_exists("$choose/README.txt")) {
print_box_start("center");
$file = file("$choose/README.txt");
echo format_text(implode('', $file), FORMAT_MOODLE);
print_box_end();
}
print_continue("$CFG->wwwroot/");
admin_externalpage_print_footer();
exit;
} else {
print_error('cannotsettheme');
}
if (!is_dir($CFG->themedir .'/'. $choose)) {
print_error('themenotinstall');
}
admin_externalpage_print_header('themeselector');
set_config('theme', $choose);
admin_externalpage_print_header();
print_heading(get_string('themesaved'));
print_heading($strthemes);
$readmehtml = $CFG->themedir . '/' . $choose . '/README.html';
$readmetxt = $CFG->themedir . '/' . $choose . '/README.txt';
if (is_readable($readmehtml)) {
print_box_start();
readfile($readmehtml);
print_box_end();
$themes = get_plugin_list("theme");
$sesskey = sesskey();
echo "<table style=\"margin-left:auto;margin-right:auto;\" cellpadding=\"7\" cellspacing=\"5\">\n";
if (!$USER->screenreader) {
echo "\t<tr class=\"generaltableheader\">\n\t\t<th scope=\"col\">$strtheme</th>\n";
echo "\t\t<th scope=\"col\">$strinfo</th>\n\t</tr>\n";
} else if (is_readable($readmetxt)) {
print_box_start();
$text = file_get_contents($readmetxt);
echo format_text($text, FORMAT_MOODLE);
print_box_end();
}
$original_theme = fullclone($THEME);
foreach ($themes as $theme => $themedir) {
unset($THEME);
if (!file_exists($themedir.'/config.php')) { // bad folder
continue;
}
include($themedir.'/config.php');
$readme = '';
$screenshot = '';
$screenshotpath = '';
if (file_exists("$theme/README.html")) {
$readme = "\t\t\t\t<li>".
link_to_popup_window($CFG->themewww .'/'. $theme .'/README.html', $theme, $strinfo, 400, 500, '', 'none', true)."</li>\n";
} else if (file_exists("$theme/README.txt")) {
$readme = "\t\t\t\t<li>".
link_to_popup_window($CFG->themewww .'/'. $theme .'/README.txt', $theme, $strinfo, 400, 500, '', 'none', true)."</li>\n";
}
if (file_exists("$theme/screenshot.png")) {
$screenshotpath = "$theme/screenshot.png";
} else if (file_exists("$theme/screenshot.jpg")) {
$screenshotpath = "$theme/screenshot.jpg";
}
echo "\t<tr>\n";
// no point showing this if user is using screen reader
if (!$USER->screenreader) {
echo "\t\t<td align=\"center\">\n";
if ($screenshotpath) {
$screenshot = "\t\t\t\t<li><a href=\"$theme/screenshot.jpg\">$strscreenshot</a></li>\n";
echo "\t\t\t<object type=\"text/html\" data=\"$screenshotpath\" height=\"200\" width=\"400\">$theme</object>\n\t\t</td>\n";
} else {
echo "\t\t\t<object type=\"text/html\" data=\"preview.php?preview=$theme\" height=\"200\" width=\"400\">$theme</object>\n\t\t</td>\n";
}
}
if ($CFG->theme == $theme) {
echo "\t\t" . '<td valign="top" style="border-style:solid; border-width:1px; border-color:#555555">'."\n";
} else {
echo "\t\t" . '<td valign="top">'."\n";
}
if (isset($THEME->sheets)) {
echo "\t\t\t" . '<p style="font-size:1.5em;font-weight:bold;">'.$theme.'</p>'."\n";
} else {
echo "\t\t\t" . '<p style="font-size:1.5em;font-weight:bold;color:red;">'.$theme.' (Moodle 1.4)</p>'."\n";
}
if ($screenshot or $readme) {
echo "\t\t\t<ul>\n";
if (!$USER->screenreader) {
echo "\t\t\t\t<li><a href=\"preview.php?preview=$theme\">$strpreview</a></li>\n";
}
echo $screenshot.$readme;
echo "\t\t\t</ul>\n";
}
$options = null;
$options['choose'] = $theme;
$options['sesskey'] = $sesskey;
echo "\t\t\t" . print_single_button('index.php', $options, $strchoose, 'get', null, true) . "\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
}
echo "</table>\n";
$THEME = $original_theme;
print_continue($CFG->wwwroot . '/' . $CFG->admin . '/index.php');
admin_externalpage_print_footer();
exit;
}
// Otherwise, show a list of themes.
admin_externalpage_print_header('themeselector');
print_heading(get_string('themes'));
$table = new stdClass;
$table->id = 'adminthemeselector';
$table->head = array(get_string('theme'), get_string('info'));
$themes = get_plugin_list('theme');
$sesskey = sesskey();
foreach ($themes as $themename => $themedir) {
// Load the theme config.
try {
$theme = theme_config::load($themename);
} catch (coding_exception $e) {
// Bad theme, just skip it for now.
continue;
}
// Build the table row, and also a list of items to go in the second cell.
$row = array();
$infoitems = array();
// Preview link.
$infoitems['preview'] = '<a href="preview.php?preview=' . $themename . '">' . get_string('preview') . '</a>';
// First cell (a preview) and also a link to the screenshot, if there is one.
$screenshotpath = '';
if (file_exists($theme->dir . '/screenshot.png')) {
$screenshotpath = $themename . '/screenshot.png';
} else if (file_exists($theme->dir . '/screenshot.jpg')) {
$screenshotpath = $themename . '/screenshot.jpg';
}
if ($screenshotpath) {
$infoitems['screenshot'] = '<a href="' . $CFG->themewww .'/'. $screenshotpath . '">' .
get_string('screenshot') . '</a>';
}
// Link to the themes's readme.
$readmeurl = '';
if (file_exists($theme->dir . '/README.html')) {
$readmeurl = $CFG->themewww .'/'. $themename .'/README.html';
} else if (file_exists($theme->dir . '/README.txt')) {
$readmeurl = $CFG->themewww .'/'. $themename .'/README.txt';
}
if ($readmeurl) {
$infoitems['readme'] = link_to_popup_window($readmeurl, $themename, get_string('info'), 400, 500, '', 'none', true);
}
// Contents of the first screenshot/preview cell.
if ($screenshotpath) {
$row[] = '<object type="text/html" data="' . $CFG->themewww .'/' . $screenshotpath .
'" height="200" width="400">' . $themename . '</object>';
} else {
$row[] = '<object type="text/html" data="preview.php?preview=' . $themename .
'" height="200" width="400">' . $themename . '</object>';
}
// Contents of the second cell.
$infocell = $OUTPUT->heading($themename, 3);
if ($infoitems) {
$infocell .= "<ul>\n<li>" . implode("</li>\n<li>", $infoitems) . "</li>\n</ul>\n";
}
if ($themename != $CFG->theme) {
$infocell .= print_single_button('index.php', array('choose' => $themename, 'sesskey' => $sesskey),
get_string('choose'), 'get', null, true);
}
$row[] = $infocell;
$table->data[$themename] = $row;
if ($themename == $CFG->theme) {
$table->rowclass[$themename] = 'selectedtheme';
}
}
print_table($table);
admin_externalpage_print_footer();
?>

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,41 +1,49 @@
<?php // $Id$
<?php
require_once("../config.php");
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
$preview = optional_param('preview','standard',PARAM_FILE); // which theme to show
/**
* This page alows you to preview an arbitrary theme before selecting it.
*/
if (!file_exists($CFG->themedir .'/'. $preview)) {
$preview = 'standard';
}
require_once("../config.php");
if (!$site = get_site()) {
print_error('siteisnotdefined', 'debug');
}
$preview = optional_param('preview','standard',PARAM_FILE); // which theme to show
require_login();
if (!file_exists($CFG->themedir .'/'. $preview)) {
$preview = 'standard';
}
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_login();
$CFG->theme = $preview;
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
theme_setup($CFG->theme, array('forceconfig='.$CFG->theme));
$PAGE->force_theme($preview);
$stradministration = get_string("administration");
$strconfiguration = get_string("configuration");
$strthemes = get_string("themes");
$strpreview = get_string("preview");
$strsavechanges = get_string("savechanges");
$strtheme = get_string("theme");
$strthemesaved = get_string("themesaved");
$strthemes = get_string('themes');
$strpreview = get_string('preview');
$navlinks = array();
$navlinks[] = array('name' => $strthemes, 'link' => null, 'type' => 'misc');
$navlinks[] = array('name' => $strpreview, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("$site->shortname: $strpreview", $site->fullname, $navigation);
$navlinks = array();
$navlinks[] = array('name' => $strthemes, 'link' => null, 'type' => 'misc');
$navlinks[] = array('name' => $strpreview, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("$SITE->shortname: $strpreview", $SITE->fullname, $navigation);
print_box_start();
print_heading($preview);
print_box_end();
print_box_start();
print_heading($preview);
print_box_end();
print_footer();
print_footer();

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -459,6 +459,18 @@ table.flexible .r1 {
color: gray;
}
#adminthemeselector .selectedtheme td.c0 {
border-top: 2px solid black;
border-left: 2px solid black;
border-bottom: 2px solid black;
}
#adminthemeselector .selectedtheme td.c1 {
border-top: 2px solid black;
border-right: 2px solid black;
border-bottom: 2px solid black;
}
/***
*** Blocks
***/

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');

200
theme/styles.php Normal file
View file

@ -0,0 +1,200 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file is responsible for serving the CSS of each theme.
*
* It should not be linked to directly. Instead, it gets included by
* theme/themename/styles.php. See theme/standard/styles.php as an example.
*
* In this script, we are serving the styles for theme $themename, but we are
* serving them on behalf of theme $fortheme.
*
* To understand this, image that the currently selected theme is standardwhite.
* This theme uses both its own stylesheets, and also the ones from the standard theme.
* So, when we are serving theme/standard/styles.php, we need to use the config in
* theme/standardwhite/config.php to control the settings. This is controled by the
* for=... parameter in the URL.
*
* In case you are wondering, in the above scenario, we have to serve the standard
* theme CSS with a URL like theme/standard/styles.php, so that relative links from
* the CSS to images in the theme folder will work.
*
* @package moodlecore
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (empty($themename)) {
die('Direct access to this script is forbidden.');
// This script should only be required by theme/themename/styles.php.
}
// These may already be defined if we got here via style_sheet_setup in lib/deprecatedlib.php
if (!defined('NO_MOODLE_COOKIES')) {
define('NO_MOODLE_COOKIES', true); // Session not used here
}
if (!defined('NO_UPGRADE_CHECK')) {
define('NO_UPGRADE_CHECK', true); // Ignore upgrade check
}
require_once(dirname(__FILE__) . '/../config.php');
$fortheme = required_param('for', PARAM_FILE);
$lang = optional_param('lang', '', PARAM_FILE);
$CACHE_LIFETIME = 1800; // Cache stylesheets for half an hour.
$DEFAULT_SHEET_LIST = array('styles_layout', 'styles_fonts', 'styles_color');
// Fix for IE6 caching - we don't want the filemtime('styles.php'), instead use now.
$lastmodified = time();
// Set the correct content type. (Should we also be specifying charset here?)
header('Content-type: text/css');
if (!debugging('', DEBUG_DEVELOPER)) {
// Do not send caching headers for developer. (This makes it easy to edit themes.
// You don't have to keep clearing the browser cache.)
header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $lastmodified) . ' GMT');
header('Expires: ' . gmdate("D, d M Y H:i:s", $lastmodified + $CACHE_LIFETIME) . ' GMT');
header('Cache-Control: max-age=' . $lifetime);
header('Pragma: ');
}
if (!empty($showdeprecatedstylesheetsetupwarning)) {
echo <<<END
/***************************************************************
***************************************************************
**** ****
**** WARNING! This theme uses an old-fashioned styles.php ****
**** file. It should be updated by copying styles.php from ****
**** the standard theme of a recent version of Moodle. ****
**** ****
***************************************************************
***************************************************************/
END;
}
// Load the configuration of the selected theme. (See comment at the top of the file.)
$PAGE->force_theme($fortheme);
// Now work out which stylesheets we shold be serving from this theme.
if ($themename == $fortheme) {
$themesheets = $THEME->sheets;
} else if (!empty($THEME->parent) && $themename == $THEME->parent) {
if ($THEME->parentsheets === true) {
// Use all the sheets we have.
$themesheets = $DEFAULT_SHEET_LIST;
} else if (!empty($THEME->parentsheets)) {
$themesheets = $THEME->parentsheets;
} else {
echo "/* The current theme does not require anything from the standard theme. */\n\n";
exit;
}
} else if ($themename == 'standard') {
if ($THEME->standardsheets === true) {
// Use all the sheets we have.
$themesheets = $DEFAULT_SHEET_LIST;
} else if (!empty($THEME->standardsheets)) {
$themesheets = $THEME->standardsheets;
} else {
echo "/* The current theme does not require anything from the standard theme. */\n\n";
exit;
}
}
// Conver the sheet names to file names.
$files = array();
foreach ($themesheets as $sheet) {
$files[] = $CFG->themedir . '/' . $themename . '/' . $sheet . '.css';
}
// If this is the standard theme, then also include the styles.php files from
// each of the plugins, as determined by the theme settings.
if ($themename == 'standard') {
if (!empty($THEME->modsheets)) {
$files += get_sheets_for_plugin_type('mod');
}
if (!empty($THEME->blocksheets)) {
$files += get_sheets_for_plugin_type('block');
}
if (!empty($THEME->courseformatsheets)) {
$files += get_sheets_for_plugin_type('format');
}
if (!empty($THEME->gradereportsheets)) {
$files += get_sheets_for_plugin_type('gradereport');
}
if (!empty($THEME->langsheets) && $lang) {
$file = $CFG->dirroot . '/lang/' . $lang . '/styles.php';
if (file_exists($file)) {
$files[] = $file;
}
}
}
if (empty($files)) {
echo "/* The current theme does not require anything from this theme. */\n\n";
exit;
}
// Output a commen with a summary of the included files.
echo <<<END
/*
* Styles from theme '$themename' for theme '$fortheme'
*
* Files included here:
*
END;
$toreplace = array($CFG->dirroot, $CFG->themedir);
foreach ($files as $file) {
echo ' * ' . str_replace($toreplace, '', $file) . "\n";
}
echo " */\n\n";
if (!empty($THEME->cssoutputfunction)) {
call_user_func($THEME->cssoutputfunction, $files);
} else {
foreach ($files as $file) {
$shortname = str_replace($toreplace, '', $file);
echo '/******* ' . $shortname . " start *******/\n\n";
@include_once($file);
echo '/******* ' . $shortname . " end *******/\n\n";
}
}
function get_sheets_for_plugin_type($type) {
$files = array();
$mods = get_plugin_list($type);
foreach ($mods as $moddir) {
$file = $moddir . '/styles.php';
if (file_exists($file)) {
$files[] = $file;
}
}
return $files;
}

View file

@ -1,21 +1,29 @@
<?PHP /* $Id$ */
<?php
/// Every theme should contain a copy of this script. It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD.
/**
* Serve the CSS for this theme. Every theme must contain a copy of this file
* DO NOT MODIFY THIS FILE IT IS IMPORTANT TO THE WORKING OF THE MOODLE THEMES SYSTEM.
* If you are are trying to change something, you should probably be looking at config.php.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // session not used here
define('NO_UPGRADE_CHECK', true); // ignore upgrade check
require_once("../../config.php"); // Load up the Moodle libraries
$themename = basename(dirname(__FILE__)); // Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE); // Get config from this theme
$lang = optional_param('lang', '', PARAM_FILE); // Look for styles in this language
$lifetime = 1800; // Seconds to cache this stylesheet
style_sheet_setup(time(), $lifetime, $themename, $forceconfig, $lang);
?>
$themename = basename(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../../theme/styles.php');