Skip to content

Commit

Permalink
MDL-56442 administration: Display hours in maintenance mode messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ligned committed Oct 20, 2016
1 parent 6a69cda commit f251038
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions lang/en/admin.php
Expand Up @@ -663,6 +663,7 @@
$string['longtimewarning'] = '<b>Please note that this process can take a long time.</b>';
$string['maintenancemode'] = 'In maintenance mode';
$string['maintenancemodeisscheduled'] = 'This site will be switched to maintenance mode in {$a->min} mins {$a->sec} secs';
$string['maintenancemodeisscheduledlong'] = 'This site will be switched to maintenance mode in {$a->hour} hours {$a->min} mins {$a->sec} secs';
$string['maintfileopenerror'] = 'Error opening maintenance files!';
$string['maintinprogress'] = 'Maintenance is in progress...';
$string['manageformats'] = 'Manage course formats';
Expand Down
12 changes: 9 additions & 3 deletions lib/outputrenderers.php
Expand Up @@ -659,14 +659,20 @@ public function maintenance_warning() {
$errorclass = ($timeleft < 30) ? 'error' : 'warning';
$output .= $this->box_start($errorclass . ' moodle-has-zindex maintenancewarning');
$a = new stdClass();
$a->min = (int)($timeleft/60);
$a->hour = (int)($timeleft / 3600);
$a->min = (int)(($timeleft / 60) % 60);
$a->sec = (int)($timeleft % 60);
$output .= get_string('maintenancemodeisscheduled', 'admin', $a) ;
if ($a->hour > 0) {
$output .= get_string('maintenancemodeisscheduledlong', 'admin', $a);
} else {
$output .= get_string('maintenancemodeisscheduled', 'admin', $a);
}

$output .= $this->box_end();
$this->page->requires->yui_module('moodle-core-maintenancemodetimer', 'M.core.maintenancemodetimer',
array(array('timeleftinsec' => $timeleft)));
$this->page->requires->strings_for_js(
array('maintenancemodeisscheduled', 'sitemaintenance'),
array('maintenancemodeisscheduled', 'maintenancemodeisscheduledlong', 'sitemaintenance'),
'admin');
}
return $output;
Expand Down
Expand Up @@ -39,8 +39,13 @@ Y.extend(MAINTENANCEMODETIMER, Y.Base, {
} else {
var a = {};
a.sec = this.timeleftinsec % 60;
a.min = Math.floor(this.timeleftinsec / 60);
this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduled', 'admin', a));
a.min = Math.floor(this.timeleftinsec / 60) % 60;
a.hour = Math.floor(this.timeleftinsec / 3600);
if (a.hour > 0) {
this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduledlong', 'admin', a));
} else {
this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduled', 'admin', a));
}
}
// Set error class to highlight the importance.
if (this.timeleftinsec < 30) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -39,8 +39,13 @@ Y.extend(MAINTENANCEMODETIMER, Y.Base, {
} else {
var a = {};
a.sec = this.timeleftinsec % 60;
a.min = Math.floor(this.timeleftinsec / 60);
this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduled', 'admin', a));
a.min = Math.floor(this.timeleftinsec / 60) % 60;
a.hour = Math.floor(this.timeleftinsec / 3600);
if (a.hour > 0) {
this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduledlong', 'admin', a));
} else {
this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduled', 'admin', a));
}
}
// Set error class to highlight the importance.
if (this.timeleftinsec < 30) {
Expand Down
9 changes: 7 additions & 2 deletions lib/yui/src/maintenancemodetimer/js/maintenancemodetimer.js
Expand Up @@ -37,8 +37,13 @@ Y.extend(MAINTENANCEMODETIMER, Y.Base, {
} else {
var a = {};
a.sec = this.timeleftinsec % 60;
a.min = Math.floor(this.timeleftinsec / 60);
this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduled', 'admin', a));
a.min = Math.floor(this.timeleftinsec / 60) % 60;
a.hour = Math.floor(this.timeleftinsec / 3600);
if (a.hour > 0) {
this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduledlong', 'admin', a));
} else {
this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduled', 'admin', a));
}
}
// Set error class to highlight the importance.
if (this.timeleftinsec < 30) {
Expand Down

0 comments on commit f251038

Please sign in to comment.