? legacy_theme.txt
Index: lang/en_utf8/moodle.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/moodle.php,v
retrieving revision 1.280
diff -u -r1.280 moodle.php
--- lang/en_utf8/moodle.php 9 Mar 2010 21:42:38 -0000 1.280
+++ lang/en_utf8/moodle.php 21 Mar 2010 06:45:59 -0000
@@ -227,11 +227,13 @@
$string['choosecourse'] = 'Choose a course';
$string['choosedots'] = 'Choose...';
$string['chooseenrolmethod'] = 'Choose enrolment plugin';
+$string['chooselegacytheme'] = 'Choose for legacy browsers';
$string['chooselivelogs'] = 'Or watch current activity';
$string['chooselogs'] = 'Choose which logs you want to see';
$string['choosereportfilter'] = 'Choose a filter for the report';
$string['choosetheme'] = 'Choose theme';
$string['chooseuser'] = 'Choose a user';
+$string['chosenlegacytheme'] = 'Chosen for legacy browsers';
$string['city'] = 'City/town';
$string['clambroken'] = 'Your administrator has enabled virus checking for file uploads but has misconfigured something.
Your file upload was NOT successful. Your administrator has been emailed to notify them so they can fix it.
Maybe try uploading this file later.';
$string['clamdeletedfile'] = 'The file has been deleted';
@@ -924,6 +926,7 @@
$string['latestnews'] = 'Latest News';
$string['layouttable'] = 'Layout table';
$string['leavetokeep'] = 'Leave blank to keep current password';
+$string['legacythemesaved'] = 'New legacy theme saved';
$string['license'] = 'GPL License';
$string['liketologin'] = 'Would you like to log in now with a full user account?';
$string['list'] = 'List';
Index: lib/pagelib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/pagelib.php,v
retrieving revision 1.173
diff -u -r1.173 pagelib.php
--- lib/pagelib.php 11 Feb 2010 13:27:03 -0000 1.173
+++ lib/pagelib.php 21 Mar 2010 06:46:01 -0000
@@ -204,6 +204,12 @@
*/
protected $_legacypageobject = null;
+ /**
+ * Associative array of browser shortnames (as used by check_browser_version)
+ * and their minimum required versions
+ */
+ protected $_legacybrowsers = array('MSIE' => 7.0);
+
/// Magic getter methods =============================================================
/// Due to the __get magic below, you normally do not call these as $PAGE->magic_get_x
/// methods, but instead use the $PAGE->x syntax.
@@ -1158,14 +1164,34 @@
case 'site':
if ($mnetpeertheme) {
return $mnetpeertheme;
+ } else if(!empty($CFG->themelegacy) && $this->browser_is_outdated()) {
+ return $CFG->themelegacy;
} else {
- return $CFG->theme;
+ return $CFG->theme;
}
}
}
}
/**
+ * Determines whether the current browser should
+ * default to the admin-selected legacy theme
+ *
+ * @return true if legacy theme should be used, otherwise false
+ *
+ */
+ protected function browser_is_outdated() {
+ foreach($this->_legacybrowsers as $browser => $version) {
+ if(check_browser_version($browser, '0') &&
+ !check_browser_version($browser, $version)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
* Sets ->pagetype from the script name. For example, if the script that was
* run is mod/quiz/view.php, ->pagetype will be set to 'mod-quiz-view'.
* @param string $script the path to the script that should be used to
Index: theme/index.php
===================================================================
RCS file: /cvsroot/moodle/moodle/theme/index.php,v
retrieving revision 1.58
diff -u -r1.58 index.php
--- theme/index.php 20 Mar 2010 22:16:00 -0000 1.58
+++ theme/index.php 21 Mar 2010 06:46:06 -0000
@@ -23,6 +23,7 @@
require_once($CFG->libdir . '/adminlib.php');
$choose = optional_param('choose', '', PARAM_SAFEDIR);
+$chooselegacy = optional_param('chooselegacy', '', PARAM_SAFEDIR);
$reset = optional_param('reset', 0, PARAM_BOOL);
admin_externalpage_setup('themeselector');
@@ -53,6 +54,27 @@
echo $OUTPUT->footer();
exit;
+} else if ($chooselegacy and confirm_sesskey()) {
+ // The user has chosen one legacy theme from the list of all themes, show a
+ // 'You have chosen a new legacy theme' confirmation page.
+
+ $theme = theme_config::load($chooselegacy);
+ $chooselegacy = $theme->name;
+
+ set_config('themelegacy', $chooselegacy);
+
+ admin_externalpage_print_header();
+ echo $OUTPUT->heading(get_string('legacythemesaved'));
+
+ echo $OUTPUT->box_start();
+ $text = get_string('choosereadme', 'theme_'.$CFG->theme);
+ echo format_text($text, FORMAT_MOODLE);
+ echo $OUTPUT->box_end();
+
+ echo $OUTPUT->continue_button($CFG->wwwroot . '/' . $CFG->admin . '/index.php');
+
+ echo $OUTPUT->footer();
+ exit;
}
// Otherwise, show a list of themes.
@@ -96,14 +118,30 @@
$infocell = $OUTPUT->heading($themename, 3);
if ($themename != $CFG->theme) {
$infocell .= $OUTPUT->single_button(new moodle_url('index.php', array('choose' => $themename, 'sesskey' => sesskey())), get_string('choose'), 'get');
+ }
+ if (empty($CFG->themelegacy) || $themename != $CFG->themelegacy) {
+ $infocell .= $OUTPUT->single_button(new moodle_url('index.php', array('chooselegacy' => $themename,
+ 'sesskey' => sesskey())),
+ get_string('chooselegacytheme'),
+ 'get');
+ } else if (!empty($CFG->themelegacy) && $themename == $CFG->themelegacy) {
+ $infocell .= $OUTPUT->single_button('', get_string('chosenlegacytheme'), 'get', array('disabled' => 'true'));
}
+
$row[] = $infocell;
$table->data[$themename] = $row;
if ($themename == $CFG->theme) {
$table->rowclasses[$themename] = 'selectedtheme';
}
+ if (!empty($CFG->themelegacy) && $themename == $CFG->themelegacy) {
+ $existing_rowclasses = '';
+ if(!empty($table->rowclasses[$themename])) {
+ $existing_rowclasses = $table->rowclasses[$themename] . ' ';
+ }
+ $table->rowclasses[$themename] = $existing_rowclasses . 'selectedlegacytheme';
+ }
}
echo html_writer::table($table);