This more or less completes the PHP side of the 1.5 themes

Added $user->theme and $course->theme choices, controlled by admin
variables on the main config variables page.

By default this is all turned off, since multiple themes can be
a little disorienting.

A hidden feature is session themes ... you can change the theme
on any page by passing theme=xxxx as a parameter.  By default this
requires sesskey (so that people don't change theme on each other),
but this security can be switched off using a hidden variable
$CFG->allowthemechangeonurl = true;   Good for quick tests.
This commit is contained in:
moodler
2005-02-10 10:28:27 +00:00
parent 730967f2e7
commit 32e2b30209
9 changed files with 100 additions and 5 deletions
+12
View File
@@ -246,6 +246,18 @@ class configvarrss extends configvar {
$interface['framename'] = new configvar (get_string('configframename', 'admin'),
'<input name="framename" type="text" size="15" value="'.s($config->framename).'" alt="framename" />' );
/// language list
$interface['themelist'] = new configvar ( get_string('configthemelist', 'admin'),
'<input name="themelist" type="text" size="60" value="'.s($config->themelist).'" alt="themelist" />' );
/// user themes
$interface['allowuserthemes'] = new configvar (get_string('configallowuserthemes', 'admin'),
choose_from_menu ($noyesoptions, 'allowuserthemes', $config->allowuserthemes, '', '', '', true) );
/// course themes
$interface['allowcoursethemes'] = new configvar (get_string('configallowcoursethemes', 'admin'),
choose_from_menu ($noyesoptions, 'allowcoursethemes', $config->allowcoursethemes, '', '', '', true) );
+16 -1
View File
@@ -12,6 +12,9 @@
if (!isset($form->lang)) {
$form->lang = '';
}
if (!isset($form->theme)) {
$form->theme = '';
}
if (!isset($form->enrolperiod)) {
$form->enrolperiod = 0;
}
@@ -258,6 +261,18 @@
?>
</td>
</tr>
<?php if (!empty($CFG->allowcoursethemes)) { ?>
<tr valign="top">
<td align="right"> <?php print_string("forcetheme") ?>: </td>
<td>
<?php
$themes[''] = get_string("forceno");
$themes += get_list_of_themes();
choose_from_menu($themes, 'theme', $form->theme, "", "", "");
?>
</td>
</tr>
<?php } ?>
<tr valign="top">
<td align="right"><?php print_string("managemeta") ?>:</td>
<td>
@@ -269,7 +284,7 @@
} else {
echo ((empty($form->metacourse)) ? get_string("no") : get_string("yes"));
echo " - $disable_meta ";
} ?>&nbsp;<?php print_string("managemetaexplan"); ?>
} ?>
</td>
</tr>
<tr>
+3
View File
@@ -9,6 +9,9 @@ $string['change'] = 'change';
$string['cachetext'] = 'Text cache lifetime';
$string['calendarsettings'] = 'Calendar';
$string['configallowunenroll'] = 'If this is set \'Yes\', then students are allowed to unenroll themselves from courses whenever they like. Otherwise they are not allowed, and this process will be solely controlled by the teachers and administrators.';
$string['configthemelist'] = 'Leave this blank to allow any valid theme to be used. If you want to shorten the theme menu, you can specify a comma-separated list of names here. For example: standard,orangewhite';
$string['configallowcoursethemes'] = 'If you enable this, then courses will be allowed to set their own themes. Course themes override all other theme choices (site, user, or session themes)';
$string['configallowuserthemes'] = 'If you enable this, then users will be allowed to set their own themes. User themes override site themes (but not course themes)';
$string['configallusersaresitestudents'] = 'For activities on the front page of the site, should ALL users be considered as students? If you answer \"Yes\", then any confirmed user account will be allowed to participate as a student in those activities. If you answer \"No\", then only users who are already a participant in at least one course will be able to take part in those front page activities. Only admins and specially assigned teachers can act as teachers for these front page activities.';
$string['configautologinguests'] = 'Should visitors be logged in as guests automatically when entering courses with guest access?';
$string['configcachetext'] = 'For larger sites or sites that use text filters, this setting can really speed things up. Copies of texts will be retained in their processed form for the time specified here. Setting this too small may actually slow things down slightly, but setting it too large may mean texts take too long to refresh (with new links, for example).';
+3
View File
@@ -240,6 +240,7 @@ $string['datemostrecentlast'] = 'Date - most recent last';
$string['day'] = 'day';
$string['days'] = 'days';
$string['decodinginternallinks'] = 'Decoding internal links';
$string['default'] = 'Default';
$string['defaultcoursefullname'] = 'Course Fullname 101';
$string['defaultcourseshortname'] = 'CF101';
$string['defaultcoursestudent'] = 'Student';
@@ -431,6 +432,7 @@ $string['forcelanguage'] = 'Force language';
$string['forceno'] = 'Do not force';
$string['forcepasswordchange'] = 'Force password change';
$string['forcepasswordchangehelp'] = 'Prompt user to change it on their next login';
$string['forcetheme'] = 'Force theme';
$string['forgotten'] = 'Forgotten your username or password?';
$string['format'] = 'Format';
$string['formathtml'] = 'HTML format';
@@ -824,6 +826,7 @@ $string['potentialcreators'] = 'Potential course creators';
$string['potentialstudents'] = 'Potential students';
$string['potentialteachers'] = 'Potential teachers';
$string['preferredlanguage'] = 'Preferred language';
$string['preferredtheme'] = 'Preferred theme';
$string['preview'] = 'Preview';
$string['previeworchoose'] = 'Preview or choose a theme';
$string['previous'] = 'Previous';
+3
View File
@@ -5,6 +5,8 @@
$defaults = array (
'allowunenroll' => true,
'allowcoursethemes' => false,
'allowuserthemes' => false,
'allusersaresitestudents' => true,
'auth' => 'email',
'auth_pop3mailbox' => 'INBOX',
@@ -66,6 +68,7 @@
'teacherassignteachers' => true,
'template' => 'default',
'textfilters' => 'mod/glossary/dynalink.php',
'themelist' => '',
'timezone' => 99,
'theme' => 'standard',
'unzip' => '',
+38
View File
@@ -2764,6 +2764,9 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml='', $a
if (!empty($course->lang)) { // Course language is defined
$CFG->courselang = $course->lang;
}
if (!empty($course->theme)) { // Course language is defined
$CFG->coursetheme = $course->theme;
}
include_once($CFG->libdir .'/phpmailer/class.phpmailer.php');
@@ -3737,6 +3740,41 @@ function get_list_of_countries() {
return $string;
}
/**
* Returns a list of valid and compatible themes
*
* @uses $CFG
* @return array
*/
function get_list_of_themes() {
global $CFG;
$themes = array();
if (!empty($CFG->themelist)) { // use admin's list of themes
$themelist = explode(',', $CFG->themelist);
} else {
$themelist = get_list_of_plugins("theme");
}
foreach ($themelist as $key => $theme) {
if (!file_exists("$CFG->dirroot/theme/$theme/config.php")) { // bad folder
continue;
}
unset($THEME); // Note this is not the global one!! :-)
include_once("$CFG->dirroot/theme/$theme/config.php");
if (!isset($THEME->sheets)) { // Not a valid 1.5 theme
continue;
}
$themes[$theme] = $theme;
}
asort($themes);
return $themes;
}
/**
* Returns a list of picture names in the current language
*
+1 -1
View File
@@ -305,7 +305,7 @@ global $THEME;
/// Load up theme variables (colours etc)
if (isset($_GET['theme'])) {
if (confirm_sesskey()) {
if ($CFG->allowthemechangeonurl || confirm_sesskey()) {
if (!detect_munged_arguments($_GET['theme'], 0) and file_exists($CFG->dirroot .'/theme/'. $_GET['theme'])) {
$SESSION->theme = $_GET['theme'];
}
+9 -3
View File
@@ -1501,6 +1501,12 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta=
if (!empty($course->lang)) {
$CFG->courselang = $course->lang;
}
if (!empty($course->theme)) {
if (!empty($CFG->allowcoursethemes)) {
$CFG->coursetheme = $course->theme;
theme_setup();
}
}
/// Add the required stylesheets
$stylesheetshtml = '';
@@ -1737,17 +1743,17 @@ function print_footer($course=NULL, $usercourse=NULL) {
* @return string
*/
function current_theme() {
global $CFG, $USER, $SESSION;
global $CFG, $USER, $SESSION, $course;
/// Logic for this will probably change to accomodate local theme rules.
if (!empty($CFG->coursetheme)) { // Course theme can override all other settings for this page
if (!empty($CFG->coursetheme) and !empty($CFG->allowcoursethemes)) { // Course theme can override all others
return $CFG->coursetheme;
} else if (!empty($SESSION->theme)) { // Session theme can override other settings
return $SESSION->theme;
} else if (!empty($USER->theme)) { // User theme can override site theme
} else if (!empty($USER->theme) and !empty($CFG->allowuserthemes)) { // User theme can override site theme
return $USER->theme;
} else {
+15
View File
@@ -8,6 +8,9 @@
if (empty($user->lang)) {
$user->lang = $CFG->lang;
}
if (!isset($user->theme)) {
$user->theme = '';
}
?>
@@ -189,6 +192,18 @@ if (isadmin()) {
?>
</td>
</tr>
<?php if (!empty($CFG->allowuserthemes)) { ?>
<tr valign="top">
<td align="right"> <?php print_string("preferredtheme") ?>: </td>
<td> <?php
$themes[''] = get_string('default');
$themes += get_list_of_themes();
choose_from_menu($themes, 'theme', $user->theme, "", "", "");
if (isset($err["theme"])) formerr($err["theme"]);
?>
</td>
</tr>
<?php } ?>
<tr valign="top">
<td align="right"> <?php print_string("timezone") ?>: </td>
<td> <?php