Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'wip-mdl-27862-m21' of git://github.com/rajeshtaneja/moo…

…dle into MOODLE_21_STABLE
  • Loading branch information...
commit a5d7e18abe554e17cd9eb7703cddd70f2649bcb8 2 parents 361492a + d383e08
Aparup Banerjee nebgor authored

Showing 2 changed files with 42 additions and 16 deletions. Show diff stats Hide diff stats

  1. +5 1 lang/en/admin.php
  2. +37 15 theme/index.php
6 lang/en/admin.php
@@ -392,6 +392,7 @@
392 392 $string['curlrequired'] = 'The cURL PHP extension is now required by Moodle, in order to communicate with Moodle repositories.';
393 393 $string['curltimeoutkbitrate'] = 'Bitrate to use when calculating cURL timeouts (Kbps)';
394 394 $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.';
  395 +$string['currenttheme'] = 'Current theme';
395 396 $string['customcheck'] = 'Other checks';
396 397 $string['custommenu'] = 'Custom menu';
397 398 $string['custommenuitems'] = 'Custom menu items';
@@ -924,6 +925,8 @@
924 925 $string['sectionerror'] = 'Section error!';
925 926 $string['secureforms'] = 'Use additional form security';
926 927 $string['security'] = 'Security';
  928 +$string['selectdevice'] = 'Select device';
  929 +$string['selecttheme'] = 'Select theme for {$a} device';
927 930 $string['server'] = 'Server';
928 931 $string['serverchecks'] = 'Server checks';
929 932 $string['serverlimit'] = 'Server limit';
@@ -985,7 +988,7 @@
985 988 $string['themelist'] = 'Theme list';
986 989 $string['themenoselected'] = 'No theme selected';
987 990 $string['themeresetcaches'] = 'Clear theme caches';
988   -$string['themeselect'] = 'Select theme';
  991 +$string['themeselect'] = 'Change theme';
989 992 $string['themeselector'] = 'Theme selector';
990 993 $string['themesettings'] = 'Theme settings';
991 994 $string['therewereerrors'] = 'There were errors in your data';
@@ -1002,6 +1005,7 @@
1002 1005 $string['uninstall'] = 'Uninstall selected language pack';
1003 1006 $string['uninstallconfirm'] = 'You are about to completely uninstall language pack {$a}, are you sure?';
1004 1007 $string['uninstallplugin'] = 'Uninstall';
  1008 +$string['unsettheme'] = 'Unset theme';
1005 1009 $string['unsupported'] = 'Unsupported';
1006 1010 $string['updateaccounts'] = 'Update existing accounts';
1007 1011 $string['updatecomponent'] = 'Update component';
52 theme/index.php
@@ -25,6 +25,7 @@
25 25 $choose = optional_param('choose', '', PARAM_SAFEDIR);
26 26 $reset = optional_param('reset', 0, PARAM_BOOL);
27 27 $device = optional_param('device', '', PARAM_TEXT);
  28 +$unsettheme = optional_param('unsettheme', 0, PARAM_BOOL);
28 29
29 30 admin_externalpage_setup('themeselector');
30 31
@@ -42,8 +43,7 @@
42 43 if ($reset and confirm_sesskey()) {
43 44 theme_reset_all_caches();
44 45
45   -} else if ($choose && $device && confirm_sesskey()) {
46   -
  46 +} else if ($choose && $device && !$unsettheme && confirm_sesskey()) {
47 47 // Load the theme to make sure it is valid.
48 48 $theme = theme_config::load($choose);
49 49 // Get the config argument for the chosen device.
@@ -71,19 +71,20 @@
71 71 echo $output->continue_button($CFG->wwwroot . '/theme/index.php');
72 72 echo $output->footer();
73 73 exit;
  74 +} else if ($device && $unsettheme && confirm_sesskey() && ($device != 'default')) {
  75 + //Unset the theme and continue.
  76 + unset_config(get_device_cfg_var_name($device));
  77 + $device = '';
74 78 }
75 79
76 80 // Otherwise, show either a list of devices, or is enabledevicedetection set to no or a
77 81 // device is specified show a list of themes.
78 82
79   -echo $OUTPUT->header('themeselector');
80   -echo $OUTPUT->heading(get_string('themes'));
81   -
82   -echo $OUTPUT->single_button(new moodle_url('index.php', array('sesskey' => sesskey(), 'reset' => 1)), get_string('themeresetcaches', 'admin'));
83   -
84 83 $table = new html_table();
85 84 $table->data = array();
  85 +$heading = '';
86 86 if (!empty($CFG->enabledevicedetection) && empty($device)) {
  87 + $heading = get_string('selectdevice', 'admin');
87 88 // Display a list of devices that a user can select a theme for.
88 89
89 90 $strthemenotselected = get_string('themenoselected', 'admin');
@@ -91,7 +92,7 @@
91 92
92 93 // Display the device selection screen
93 94 $table->id = 'admindeviceselector';
94   - $table->head = array(get_string('devicetype', 'admin'), get_string('theme'), get_string('info'));
  95 + $table->head = array(get_string('devicetype', 'admin'), get_string('currenttheme', 'admin'), get_string('info'));
95 96
96 97 $devices = get_device_type_list();
97 98 foreach ($devices as $device) {
@@ -103,6 +104,7 @@
103 104 }
104 105
105 106 $screenshotcell = $strthemenotselected;
  107 + $unsetthemebutton = '';
106 108 if ($themename) {
107 109 // Check the theme exists
108 110 $themename = clean_param($themename, PARAM_THEME);
@@ -118,21 +120,28 @@
118 120 // Show the name of the picked theme
119 121 $headingthemename = $OUTPUT->heading($strthemename, 3);
120 122 }
  123 + // If not default device then show option to unset theme.
  124 + if ($device != 'default') {
  125 + $unsetthemestr = get_string('unsettheme', 'admin');
  126 + $unsetthemeurl = new moodle_url('/theme/index.php', array('device' => $device, 'sesskey' => sesskey(), 'unsettheme' => true));
  127 + $unsetthemebutton = new single_button($unsetthemeurl, $unsetthemestr, 'get');
  128 + $unsetthemebutton = $OUTPUT->render($unsetthemebutton);
  129 + }
121 130 }
122 131
123 132 $deviceurl = new moodle_url('/theme/index.php', array('device' => $device, 'sesskey' => sesskey()));
124 133 $select = new single_button($deviceurl, $strthemeselect, 'get');
125 134
126 135 $table->data[] = array(
127   - $device,
  136 + $OUTPUT->heading(ucfirst($device), 3),
128 137 $screenshotcell,
129   - $headingthemename . $OUTPUT->render($select)
  138 + $headingthemename . $OUTPUT->render($select) . $unsetthemebutton
130 139 );
131 140 }
132 141 } else {
133 142 // Either a device has been selected of $CFG->enabledevicedetection is off so display a list
134 143 // of themes to select.
135   -
  144 + $heading = get_string('selecttheme', 'admin', $device);
136 145 if (empty($device)) {
137 146 // if $CFG->enabledevicedetection is off this will return 'default'
138 147 $device = get_device_type();
@@ -183,10 +192,19 @@
183 192 // Contents of the second cell.
184 193 $infocell = $OUTPUT->heading($strthemename, 3);
185 194
186   - // Button to choose this as the main theme
187   - $maintheme = new single_button(new moodle_url('/theme/index.php', array('device' => $device, 'choose' => $themename, 'sesskey' => sesskey())), get_string('usetheme'), 'get');
188   - $maintheme->disabled = $ischosentheme;
189   - $infocell .= $OUTPUT->render($maintheme);
  195 + // Button to choose this as the main theme or unset this theme for
  196 + // devices other then default
  197 + if (($ischosentheme) && ($device != 'default')) {
  198 + $unsetthemestr = get_string('unsettheme', 'admin');
  199 + $unsetthemeurl = new moodle_url('/theme/index.php', array('device' => $device, 'unsettheme' => true, 'sesskey' => sesskey()));
  200 + $unsetbutton = new single_button($unsetthemeurl, $unsetthemestr, 'get');
  201 + $infocell .= $OUTPUT->render($unsetbutton);
  202 + } else if ((!$ischosentheme)) {
  203 + $setthemestr = get_string('usetheme');
  204 + $setthemeurl = new moodle_url('/theme/index.php', array('device' => $device, 'choose' => $themename, 'sesskey' => sesskey()));
  205 + $setthemebutton = new single_button($setthemeurl, $setthemestr, 'get');
  206 + $infocell .= $OUTPUT->render($setthemebutton);
  207 + }
190 208
191 209 $row[] = $infocell;
192 210
@@ -194,6 +212,10 @@
194 212 $table->rowclasses[$themename] = join(' ', $rowclasses);
195 213 }
196 214 }
  215 +echo $OUTPUT->header('themeselector');
  216 +echo $OUTPUT->heading($heading);
  217 +
  218 +echo $OUTPUT->single_button(new moodle_url('index.php', array('sesskey' => sesskey(), 'reset' => 1, 'device' => $device)), get_string('themeresetcaches', 'admin'));
197 219
198 220 echo html_writer::table($table);
199 221

0 comments on commit a5d7e18

Please sign in to comment.
Something went wrong with that request. Please try again.