themes: MDL-19077 - more work on the theme_config class.

* Writing lots more PHPdoc comments for all the settings.
* Strip the comments from the standard theme config.php (see below)
* Move finding the layout template from moodle_core_renderer to the theme_config class
* Move loading meta.php files from moodle_core_renderer to the theme_config class
* MDL-19719 Remove support for $THEME->langsheets, and lang/.../styles.php
* MDL-19719 Put the Vietnamese-specific code into the standard theme
* Support for styles.php in all plugin types (at the theme's discretion). (c/f MDL-16438)
* More PHP doc comments for moodle_core_renderer methods.

About stripping comments from config.php: I'm not sure if this
is a good idea, and I may revert this bit. I am hoping that once
http://phpdocs.moodle.org/HEAD/moodlecore/theme_config.html has
been updated, that will be better than copying and pasting these
comments into every theme. I intend to post in the themes forum
to canvas opinions.
This commit is contained in:
tjhunt 2009-07-07 05:05:06 +00:00
parent 87b6851cf9
commit fdeb7fa192
5 changed files with 652 additions and 561 deletions

View file

@ -1,189 +1,77 @@
<?PHP // $Id$
<?php
////////////////////////////////////////////////////////////////////////////////
/// This file contains a few configuration variables that control
/// how Moodle uses this theme.
////////////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Configuration for Moodle's standard theme.
*
* There is documentation of all the things that can be configured here at
* http://phpdocs.moodle.org/HEAD/moodlecore/theme_config.html
*
* For an overview of how Moodle themes work, Please see
* http://docs.moodle.org/en/Developement:How_Moodle_outputs_HTML
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$THEME->sheets = array('styles_layout', 'styles_fonts', 'styles_color');
/// This variable is an array containing the names of all the
/// stylesheet files you want included in this theme, and in what order
////////////////////////////////////////////////////////////////////////////////
$THEME->standardsheets = true;
/// This variable can be set to an array containing
/// filenames from the *STANDARD* theme. If the
/// array exists, it will be used to choose the
/// files to include in the standard style sheet.
/// When false, then no files are used.
/// When true or NON-EXISTENT, then ALL standard files are used.
/// This parameter can be used, for example, to prevent
/// having to override too many classes.
/// Note that the trailing .css should not be included
/// eg $THEME->standardsheets = array('styles_layout','styles_fonts','styles_color');
////////////////////////////////////////////////////////////////////////////////
$THEME->parent = '';
/// This variable can be set to the name of a parent theme
/// which you want to have included before the current theme.
/// This can make it easy to make modifications to another
/// theme without having to actually change the files
/// If this variable is empty or false then a parent theme
/// is not used.
////////////////////////////////////////////////////////////////////////////////
$THEME->parentsheets = false;
/// This variable can be set to an array containing
/// filenames from a chosen *PARENT* theme. If the
/// array exists, it will be used to choose the
/// files to include in the standard style sheet.
/// When false, then no files are used.
/// When true or NON-EXISTENT, then ALL standard files are used.
/// This parameter can be used, for example, to prevent
/// having to override too many classes.
/// Note that the trailing .css should not be included
/// eg $THEME->parentsheets = array('styles_layout','styles_fonts','styles_color');
////////////////////////////////////////////////////////////////////////////////
$THEME->modsheets = true;
/// When this is enabled, then this theme will search for
/// files named "styles.php" inside all Activity modules and
/// include them. This allows modules to provide some basic
/// layouts so they work out of the box.
/// It is HIGHLY recommended to leave this enabled.
$THEME->blocksheets = true;
/// When this is enabled, then this theme will search for
/// files named "styles.php" inside all Block modules and
/// include them. This allows Blocks to provide some basic
/// layouts so they work out of the box.
/// It is HIGHLY recommended to leave this enabled.
$THEME->langsheets = false;
/// By setting this to true, then this theme will search for
/// a file named "styles.php" inside the current language
/// directory. This allows different languages to provide
/// different styles.
$THEME->courseformatsheets = true;
/// When this is enabled, this theme will search for files
/// named "styles.php" inside all course formats and
/// include them. This allows course formats to provide
/// their own default styles.
$THEME->parent = null;
$THEME->parentsheets = false;
$THEME->standardsheets = true;
$THEME->pluginsheets = array('mod', 'block', 'format', 'gradereport');
$THEME->metainclude = false;
/// When this is enabled (or not set!) then Moodle will try
/// to include a file meta.php from this theme into the
/// <head></head> part of the page.
$THEME->parentmetainclude = false;
$THEME->standardmetainclude = true;
$THEME->custompix = false;
/// When this is enabled (or not set!) then Moodle will try
/// to include a file meta.php from the standard theme into the
/// <head></head> part of the page.
$THEME->layouttemplates = array(
'normal' => 'layout.php',
'home' => 'layout-home.php',
);
$THEME->blockregions = array('side-pre', 'side-post');
$THEME->defaultblockregion = 'side-post';
$THEME->parentmetainclude = false;
/// When this is enabled (or not set!) then Moodle will try
/// to include a file meta.php from the parent theme into the
/// <head></head> part of the page.
$THEME->navmenuwidth = 50;
/// You can use this to control the cutoff point for strings
/// in the navmenus (list of activities in popup menu etc)
/// Default is 50 characters wide.
$THEME->makenavmenulist = false;
/// By setting this to true, then you will have access to a
/// new variable in your header.html and footer.html called
/// $navmenulist ... this contains a simple XHTML menu of
/// all activities in the current course, mostly useful for
/// creating popup navigation menus and so on.
$THEME->resource_mp3player_colors =
$THEME->resource_mp3player_colors =
'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.
'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'.
'font=Arial&fontColour=3333FF&buffer=10&waitForPlay=no&autoPlay=yes';
/// With this you can control the colours of the "big" MP3 player
/// that is used for MP3 resources.
$THEME->filter_mediaplugin_colors =
$THEME->filter_mediaplugin_colors =
'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.
'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'.
'waitForPlay=yes';
/// ...And this controls the small embedded player
//$THEME->rarrow = '&#x25BA;' //OR '&rarr;';
//$THEME->larrow = '&#x25C4;' //OR '&larr;';
//$CFG->block_search_button = link_arrow_right(get_string('search'), $url='', $accesshide=true);
$THEME->navmenuwidth = 50;
// You can use this to control the cutoff point for strings
// in the navmenus (list of activities in popup menu etc)
// Default is 50 characters wide.
$THEME->custompix = false;
/// If true, then this theme must have a "pix"
/// subdirectory that contains copies of all
/// files from the moodle/pix directory, plus a
/// "pix/mod" directory containing all the icons
/// for all the activity modules.
///$THEME->rarrow = '&#x25BA;' //OR '&rarr;';
///$THEME->larrow = '&#x25C4;' //OR '&larr;';
///$CFG->block_search_button = link_arrow_right(get_string('search'), $url='', $accesshide=true);
///
/// Accessibility: Right and left arrow-like characters are
/// used in the breadcrumb trail, course navigation menu
/// (previous/next activity), calendar, and search forum block.
///
/// If the theme does not set characters, appropriate defaults
/// are set by (lib/weblib.php:check_theme_arrows). The suggestions
/// above are 'silent' in a screen-reader like JAWS. Please DO NOT
/// use &lt; &gt; &raquo; - these are confusing for blind users.
////////////////////////////////////////////////////////////////////////////////
$THEME->blockregions = array('side-pre', 'side-post');
$THEME->defaultblockregion = 'side-post';
/// Areas where blocks may appear on any page that uses this theme. For each
/// region you list in $THEME->blockregions you must call blocks_print_group
/// with that region id somewhere in header.html or footer.html.
/// defaultblockregion is the region where new blocks will be added, and
/// where any blocks in unrecognised regions will be shown. (Suppose someone
/// added a block when anther theme was selected).
////////////////////////////////////////////////////////////////////////////////
$THEME->rendererfactory = 'standard_renderer_factory';
/// This is an advanced features that lets you control the HTML that Moodle
/// generates. You need to specify a class that implements the renderer_factory
/// interface. As well as the default 'standard_renderer_factory', there is
/// also the experimental 'template_renderer_factory', or you could implement
/// your own. For more information, please see
/// http://docs.moodle.org/en/Developement:How_Moodle_outputs_HTML
////////////////////////////////////////////////////////////////////////////////
$THEME->makenavmenulist = false;
// By setting this to true, then you will have access to a
// new variable in your header.html and footer.html called
// $navmenulist ... this contains a simple XHTML menu of
// all activities in the current course, mostly useful for
// creating popup navigation menus and so on.

View file

@ -41,6 +41,20 @@ body, table, td, th, li {
/*letter-spacing:0.02em;*/
}
/*
* Apparently (at least in 2005, when this was added) Vietnamese test, on Windows
* computers, would only show up in Arial. Specify that here, with a !important
* rule, so that other themes that inherit from that standard theme do not
* un-intentionally break Vietnamese sites by changing the font.
*/
body.lang-vi_utf8,
body.lang-vi_utf8 table,
body.lang-vi_utf8 td,
body.lang-vi_utf8 th,
body.lang-vi_utf8 li {
font-family: Arial, Verdana, Helvetica, sans-serif !important;
}
th {
font-weight: bold;
}

View file

@ -1,124 +1,79 @@
<?PHP // $Id$
<?php
////////////////////////////////////////////////////////////////////////////////
/// This file contains a few configuration variables that control
/// how Moodle uses this theme.
////////////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Configuration for Moodle's standard theme.
*
* There is documentation of all the things that can be configured here at
* http://phpdocs.moodle.org/HEAD/moodlecore/theme_config.html
*
* For an overview of how Moodle themes work, Please see
* http://docs.moodle.org/en/Developement:How_Moodle_outputs_HTML
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$THEME->sheets = array('gradients');
/// This variable is an array containing the names of all the
/// stylesheet files you want included in this theme, and in what order
////////////////////////////////////////////////////////////////////////////////
$THEME->parent = null;
$THEME->parentsheets = false;
$THEME->standardsheets = true;
$THEME->pluginsheets = array('mod', 'block', 'format', 'gradereport');
$THEME->standardsheets = array('styles_layout','styles_fonts','styles_color','styles_moz');
$THEME->metainclude = false;
$THEME->parentmetainclude = false;
$THEME->standardmetainclude = true;
/// This variable can be set to an array containing
/// filenames from the *STANDARD* theme. If the
/// array exists, it will be used to choose the
/// files to include in the standard style sheet.
/// When false, then no files are used.
/// When true or NON-EXISTENT, then ALL standard files are used.
/// This parameter can be used, for example, to prevent
/// having to override too many classes.
/// Note that the trailing .css should not be included
/// eg $THEME->standardsheets = array('styles_layout','styles_fonts','styles_color');
////////////////////////////////////////////////////////////////////////////////
$THEME->parent = '';
/// This variable can be set to the name of a parent theme
/// which you want to have included before the current theme.
/// This can make it easy to make modifications to another
/// theme without having to actually change the files
/// If this variable is empty or false then a parent theme
/// is not used.
////////////////////////////////////////////////////////////////////////////////
$THEME->parentsheets = false;
/// This variable can be set to an array containing
/// filenames from a chosen *PARENT* theme. If the
/// array exists, it will be used to choose the
/// files to include in the standard style sheet.
/// When false, then no files are used.
/// When true or NON-EXISTENT, then ALL standard files are used.
/// This parameter can be used, for example, to prevent
/// having to override too many classes.
/// Note that the trailing .css should not be included
/// eg $THEME->parentsheets = array('styles_layout','styles_fonts','styles_color');
////////////////////////////////////////////////////////////////////////////////
$THEME->modsheets = true;
/// When this is enabled, then this theme will search for
/// files named "styles.php" inside all Activity modules and
/// include them. This allows modules to provide some basic
/// layouts so they work out of the box.
/// It is HIGHLY recommended to leave this enabled.
$THEME->blocksheets = true;
/// When this is enabled, then this theme will search for
/// files named "styles.php" inside all Block modules and
/// include them. This allows Blocks to provide some basic
/// layouts so they work out of the box.
/// It is HIGHLY recommended to leave this enabled.
$THEME->langsheets = false;
/// By setting this to true, then this theme will search for
/// a file named "styles.php" inside the current language
/// directory. This allows different languages to provide
/// different styles.
$THEME->navmenuwidth = 50;
/// You can use this to control the cutoff point for strings
/// in the navmenus (list of activities in popup menu etc)
/// Default is 50 characters wide.
$THEME->makenavmenulist = false;
/// By setting this to true, then you will have access to a
/// new variable in your header.html and footer.html called
/// $navmenulist ... this contains a simple XHTML menu of
/// all activities in the current course, mostly useful for
/// creating popup navigation menus and so on.
$THEME->custompix = false;
$THEME->layouttemplates = array(
'normal' => 'layout.php',
'home' => 'layout-home.php',
);
$THEME->blockregions = array('side-pre', 'side-post');
$THEME->defaultblockregion = 'side-post';
$THEME->resource_mp3player_colors =
'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.
'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'.
'font=Arial&fontColour=3333FF&buffer=10&waitForPlay=no&autoPlay=yes';
/// With this you can control the colours of the "big" MP3 player
/// that is used for MP3 resources.
$THEME->filter_mediaplugin_colors =
'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.
'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'.
'waitForPlay=yes';
/// ...And this controls the small embedded player
//$THEME->rarrow = '&#x25BA;' //OR '&rarr;';
//$THEME->larrow = '&#x25C4;' //OR '&larr;';
//$CFG->block_search_button = link_arrow_right(get_string('search'), $url='', $accesshide=true);
$THEME->navmenuwidth = 50;
// You can use this to control the cutoff point for strings
// in the navmenus (list of activities in popup menu etc)
// Default is 50 characters wide.
$THEME->custompix = false;
$THEME->makenavmenulist = false;
// By setting this to true, then you will have access to a
// new variable in your header.html and footer.html called
// $navmenulist ... this contains a simple XHTML menu of
// all activities in the current course, mostly useful for
// creating popup navigation menus and so on.
/// If true, then this theme must have a "pix"
/// subdirectory that contains copies of all
/// files from the moodle/pix directory, plus a
/// "pix/mod" directory containing all the icons
/// for all the activity modules.
////////////////////////////////////////////////////////////////////////////////
?>
$THEME->modsheets = true;

View file

@ -55,7 +55,7 @@ require_once(dirname(__FILE__) . '/../config.php');
$fortheme = required_param('for', PARAM_FILE);
$lang = optional_param('lang', '', PARAM_FILE);
$pluginsheets = optional_param('pluginsheets', '', PARAM_BOOL);
$CACHE_LIFETIME = 1800; // Cache stylesheets for half an hour.
$DEFAULT_SHEET_LIST = array('styles_layout', 'styles_fonts', 'styles_color');
@ -92,9 +92,28 @@ if (!empty($showdeprecatedstylesheetsetupwarning)) {
END;
}
// This is a bit tricky, but the following initialisation code may output
// notices or debug developer warnings (for example, if the theme uses some
// Deprecated settings in it config.php file. Therefore start a CSS comment
// so that any debugging output does not break the CSS. This comment is closed
// below.
echo '/*';
// Load the configuration of the selected theme. (See comment at the top of the file.)
$PAGE->force_theme($fortheme);
// We will build up a list of CSS file path names, then concatenate them all.
$files = array();
// If this theme wants plugin sheets, include them. Do this first, so styles
// here can be overridden by theme CSS.
if ($pluginsheets) {
foreach ($THEME->pluginsheets as $plugintype) {
$files += get_sheets_for_plugin_type($plugintype);
}
}
// Now work out which stylesheets we shold be serving from this theme.
if ($themename == $fortheme) {
$themesheets = $THEME->sheets;
@ -106,8 +125,7 @@ if ($themename == $fortheme) {
} else if (!empty($THEME->parentsheets)) {
$themesheets = $THEME->parentsheets;
} else {
echo "/* The current theme does not require anything from the standard theme. */\n\n";
exit;
$themesheets = array();
}
} else if ($themename == 'standard') {
@ -117,66 +135,37 @@ if ($themename == $fortheme) {
} else if (!empty($THEME->standardsheets)) {
$themesheets = $THEME->standardsheets;
} else {
echo "/* The current theme does not require anything from the standard theme. */\n\n";
exit;
$themesheets = array();
}
}
// Conver the sheet names to file names.
$files = array();
// Conver the theme stylessheet names to file names.
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";
echo " The $fortheme theme does not require anything from the $themename 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);
$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);
call_user_func($THEME->cssoutputfunction, $files, $toreplace);
} else {
foreach ($files as $file) {