From 604cb17920ee22512a903995d8b7eb3609568eca Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 24 Feb 2012 09:19:12 +0800 Subject: [PATCH 1/5] MDL-27862 Themes: Strings updated on theme selection pages --- lang/en/admin.php | 5 ++++- theme/index.php | 15 ++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lang/en/admin.php b/lang/en/admin.php index f9597da7515..3b09b799052 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -378,6 +378,7 @@ $string['curlrecommended'] = 'Installing the optional cURL library is highly rec $string['curlrequired'] = 'The cURL PHP extension is now required by Moodle, in order to communicate with Moodle repositories.'; $string['curltimeoutkbitrate'] = 'Bitrate to use when calculating cURL timeouts (Kbps)'; $string['curltimeoutkbitrate_help'] = 'This setting is used to calculate an appropriate timeout during large cURL requests. As part of this calculation an HTTP HEAD request is made to determine the size of the content. Setting this to 0 disables this request from being made.'; +$string['currenttheme'] = 'Current theme'; $string['customcheck'] = 'Other checks'; $string['custommenu'] = 'Custom menu'; $string['custommenuitems'] = 'Custom menu items'; @@ -884,6 +885,8 @@ $string['searchresults'] = 'Search results'; $string['sectionerror'] = 'Section error!'; $string['secureforms'] = 'Use additional form security'; $string['security'] = 'Security'; +$string['selectdevice'] = 'Select device'; +$string['selecttheme'] = 'Select theme for {$a} device'; $string['server'] = 'Server'; $string['serverchecks'] = 'Server checks'; $string['serverlimit'] = 'Server limit'; @@ -947,7 +950,7 @@ $string['themedesignermode'] = 'Theme designer mode'; $string['themelist'] = 'Theme list'; $string['themenoselected'] = 'No theme selected'; $string['themeresetcaches'] = 'Clear theme caches'; -$string['themeselect'] = 'Select theme'; +$string['themeselect'] = 'Change theme'; $string['themeselector'] = 'Theme selector'; $string['themesettings'] = 'Theme settings'; $string['therewereerrors'] = 'There were errors in your data'; diff --git a/theme/index.php b/theme/index.php index 17cc1c0d1ff..e2711920923 100644 --- a/theme/index.php +++ b/theme/index.php @@ -76,14 +76,11 @@ if ($reset and confirm_sesskey()) { // Otherwise, show either a list of devices, or is enabledevicedetection set to no or a // device is specified show a list of themes. -echo $OUTPUT->header('themeselector'); -echo $OUTPUT->heading(get_string('themes')); - -echo $OUTPUT->single_button(new moodle_url('index.php', array('sesskey' => sesskey(), 'reset' => 1)), get_string('themeresetcaches', 'admin')); - $table = new html_table(); $table->data = array(); +$heading = ''; if (!empty($CFG->enabledevicedetection) && empty($device)) { + $heading = get_string('selectdevice', 'admin'); // Display a list of devices that a user can select a theme for. $strthemenotselected = get_string('themenoselected', 'admin'); @@ -91,7 +88,7 @@ if (!empty($CFG->enabledevicedetection) && empty($device)) { // Display the device selection screen $table->id = 'admindeviceselector'; - $table->head = array(get_string('devicetype', 'admin'), get_string('theme'), get_string('info')); + $table->head = array(get_string('devicetype', 'admin'), get_string('currenttheme', 'admin'), get_string('info')); $devices = get_device_type_list(); foreach ($devices as $device) { @@ -132,7 +129,7 @@ if (!empty($CFG->enabledevicedetection) && empty($device)) { } else { // Either a device has been selected of $CFG->enabledevicedetection is off so display a list // of themes to select. - + $heading = get_string('selecttheme', 'admin', $device); if (empty($device)) { // if $CFG->enabledevicedetection is off this will return 'default' $device = get_device_type(); @@ -194,6 +191,10 @@ if (!empty($CFG->enabledevicedetection) && empty($device)) { $table->rowclasses[$themename] = join(' ', $rowclasses); } } +echo $OUTPUT->header('themeselector'); +echo $OUTPUT->heading($heading); + +echo $OUTPUT->single_button(new moodle_url('index.php', array('sesskey' => sesskey(), 'reset' => 1)), get_string('themeresetcaches', 'admin')); echo html_writer::table($table); From bff67f49046e6102ee277bb710b6113fa8d4ace4 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 24 Feb 2012 12:06:13 +0800 Subject: [PATCH 2/5] MDL-27862 Themes: Added button to un-select theme for devices, except default device --- lang/en/admin.php | 1 + theme/index.php | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lang/en/admin.php b/lang/en/admin.php index 3b09b799052..d050f11faee 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -967,6 +967,7 @@ $string['unbookmarkthispage'] = 'Unbookmark this page'; $string['unicoderecommended'] = 'Storing all your data in Unicode (UTF-8) is recommended. New installations should be performed into databases that have their default character set as Unicode. If you are upgrading, you should perform the UTF-8 migration process (see the Admin page).'; $string['unicoderequired'] = 'It is required that you store all your data in Unicode format (UTF-8). New installations must be performed into databases that have their default character set as Unicode. If you are upgrading, you should perform the UTF-8 migration process (see the Admin page).'; $string['uninstallplugin'] = 'Uninstall'; +$string['unsettheme'] = 'Unset theme'; $string['unsupported'] = 'Unsupported'; $string['unsuspenduser'] = 'Activate user account'; $string['updateaccounts'] = 'Update existing accounts'; diff --git a/theme/index.php b/theme/index.php index e2711920923..bdc0160e45d 100644 --- a/theme/index.php +++ b/theme/index.php @@ -25,6 +25,7 @@ require_once($CFG->libdir . '/adminlib.php'); $choose = optional_param('choose', '', PARAM_PLUGIN); $reset = optional_param('reset', 0, PARAM_BOOL); $device = optional_param('device', '', PARAM_TEXT); +$unsettheme = optional_param('unsettheme', 0, PARAM_BOOL); admin_externalpage_setup('themeselector'); @@ -42,8 +43,7 @@ unset($SESSION->theme); if ($reset and confirm_sesskey()) { theme_reset_all_caches(); -} else if ($choose && $device && confirm_sesskey()) { - +} else if ($choose && $device && !$unsettheme && confirm_sesskey()) { // Load the theme to make sure it is valid. $theme = theme_config::load($choose); // Get the config argument for the chosen device. @@ -71,6 +71,10 @@ if ($reset and confirm_sesskey()) { echo $output->continue_button($CFG->wwwroot . '/theme/index.php'); echo $output->footer(); exit; +} else if ($device && $unsettheme && confirm_sesskey() && ($device != 'default')) { + //Unset the theme and continue. + unset_config(get_device_cfg_var_name($device)); + $device = ''; } // Otherwise, show either a list of devices, or is enabledevicedetection set to no or a @@ -100,6 +104,7 @@ if (!empty($CFG->enabledevicedetection) && empty($device)) { } $screenshotcell = $strthemenotselected; + $unsetthemebutton = ''; if ($themename) { // Check the theme exists $themename = clean_param($themename, PARAM_THEME); @@ -115,6 +120,13 @@ if (!empty($CFG->enabledevicedetection) && empty($device)) { // Show the name of the picked theme $headingthemename = $OUTPUT->heading($strthemename, 3); } + // If not default device then show option to unset theme. + if ($device != 'default') { + $unsetthemestr = get_string('unsettheme', 'admin'); + $unsetthemeurl = new moodle_url('/theme/index.php', array('device' => $device, 'sesskey' => sesskey(), 'unsettheme' => true)); + $unsetthemebutton = new single_button($unsetthemeurl, $unsetthemestr, 'get'); + $unsetthemebutton = $OUTPUT->render($unsetthemebutton); + } } $deviceurl = new moodle_url('/theme/index.php', array('device' => $device, 'sesskey' => sesskey())); @@ -123,7 +135,7 @@ if (!empty($CFG->enabledevicedetection) && empty($device)) { $table->data[] = array( $device, $screenshotcell, - $headingthemename . $OUTPUT->render($select) + $headingthemename . $OUTPUT->render($select) . $unsetthemebutton ); } } else { From 36ff8d05de34e39c7c92517689dd2a8243097fa4 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Wed, 7 Mar 2012 11:33:12 +0800 Subject: [PATCH 3/5] MDL-27862 Themes: replaced disabled use theme button with unset theme button --- theme/index.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/theme/index.php b/theme/index.php index bdc0160e45d..814fd788223 100644 --- a/theme/index.php +++ b/theme/index.php @@ -192,10 +192,19 @@ if (!empty($CFG->enabledevicedetection) && empty($device)) { // Contents of the second cell. $infocell = $OUTPUT->heading($strthemename, 3); - // Button to choose this as the main theme - $maintheme = new single_button(new moodle_url('/theme/index.php', array('device' => $device, 'choose' => $themename, 'sesskey' => sesskey())), get_string('usetheme'), 'get'); - $maintheme->disabled = $ischosentheme; - $infocell .= $OUTPUT->render($maintheme); + // Button to choose this as the main theme or unset this theme for + // devices other then default + if (($ischosentheme) && ($device != 'default')) { + $unsetthemestr = get_string('unsettheme', 'admin'); + $unsetthemeurl = new moodle_url('/theme/index.php', array('device' => $device, 'unsettheme' => true, 'sesskey' => sesskey())); + $unsetbutton = new single_button($unsetthemeurl, $unsetthemestr, 'get'); + $infocell .= $OUTPUT->render($unsetbutton); + } else if ((!$ischosentheme)) { + $setthemestr = get_string('usetheme'); + $setthemeurl = new moodle_url('/theme/index.php', array('device' => $device, 'choose' => $themename, 'sesskey' => sesskey())); + $setthemebutton = new single_button($setthemeurl, $setthemestr, 'get'); + $infocell .= $OUTPUT->render($setthemebutton); + } $row[] = $infocell; From df46b9b40dee3c949e3e1d9626039c89d6a515f5 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Wed, 7 Mar 2012 11:45:45 +0800 Subject: [PATCH 4/5] MDL-27862 Themes: clear theme cache button will redirect to the page on which it was pressed --- theme/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme/index.php b/theme/index.php index 814fd788223..5a3a69a9645 100644 --- a/theme/index.php +++ b/theme/index.php @@ -215,7 +215,7 @@ if (!empty($CFG->enabledevicedetection) && empty($device)) { echo $OUTPUT->header('themeselector'); echo $OUTPUT->heading($heading); -echo $OUTPUT->single_button(new moodle_url('index.php', array('sesskey' => sesskey(), 'reset' => 1)), get_string('themeresetcaches', 'admin')); +echo $OUTPUT->single_button(new moodle_url('index.php', array('sesskey' => sesskey(), 'reset' => 1, 'device' => $device)), get_string('themeresetcaches', 'admin')); echo html_writer::table($table); From c069c01755164ca334783f7808aeee2d6eedde80 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 9 Mar 2012 16:52:52 +0800 Subject: [PATCH 5/5] MDL-27862 Themes: Device name first letter is capital and font is made similar to theme name font --- theme/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme/index.php b/theme/index.php index 5a3a69a9645..ce2a3d10fd1 100644 --- a/theme/index.php +++ b/theme/index.php @@ -133,7 +133,7 @@ if (!empty($CFG->enabledevicedetection) && empty($device)) { $select = new single_button($deviceurl, $strthemeselect, 'get'); $table->data[] = array( - $device, + $OUTPUT->heading(ucfirst($device), 3), $screenshotcell, $headingthemename . $OUTPUT->render($select) . $unsetthemebutton );