From 4c4df5340263d832fc37405a843b60c9238c4e79 Mon Sep 17 00:00:00 2001 From: Daniel Thee Roperto Date: Fri, 9 Sep 2016 15:57:24 +1000 Subject: [PATCH] Issue #15 - Added countdown to navbar, redirect to info.php when ended. --- lang/en/auth_outage.php | 3 +- renderer.php | 26 ++---- settings.php | 2 +- res/default.css => views/warningbar.css | 0 views/warningbar.php | 104 ++++++++++++++++++++++++ 5 files changed, 114 insertions(+), 21 deletions(-) rename res/default.css => views/warningbar.css (100%) create mode 100644 views/warningbar.php diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index 524eef9..08c8555 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -40,7 +40,7 @@ $string['description'] = 'Public Description'; $string['menudefaults'] = 'Default Settings'; $string['menumanage'] = 'Manage'; $string['messageoutageongoing'] = 'Our system will be under maintenance until {$a->stop}.'; -$string['messageoutagewarning'] = 'There is an scheduled downtime from {$a->start} until {$a->stop}.'; +$string['messageoutagewarning'] = 'Shutting down in {{countdown}} ...'; $string['outageedit'] = 'Edit Outage'; $string['outagecreate'] = 'Create Outage'; $string['outagedelete'] = 'Delete Outage'; @@ -49,6 +49,7 @@ $string['outageduration'] = 'Outage Duration'; $string['outagedurationerrorinvalid'] = 'Outage duration must be positive.'; $string['outageslist'] = 'Outages List'; $string['pluginname'] = 'Outage manager'; +$string['readmore'] = 'Read More'; $string['starttime'] = 'Start date and time'; $string['textplaceholdershint'] = 'You can use {{start}} and {{stop}} as placeholders on the title/description for the actual start/stop time.'; $string['titleerrorinvalid'] = 'Title cannot be left blank.'; diff --git a/renderer.php b/renderer.php index 573be9c..4ca1f9e 100644 --- a/renderer.php +++ b/renderer.php @@ -152,6 +152,8 @@ class auth_outage_renderer extends plugin_renderer_base { } public function renderoutagebar(outage $outage) { + global $CFG; + $start = userdate($outage->starttime, get_string('strftimedatetimeshort')); $stop = userdate($outage->stoptime, get_string('strftimedatetimeshort')); @@ -161,24 +163,10 @@ class auth_outage_renderer extends plugin_renderer_base { ['start' => $start, 'stop' => $stop] ); - return - html_writer::tag('style', get_config('auth_outage', 'css')) - . html_writer::div( - html_writer::div( - html_writer::div($outage->get_title(), 'auth_outage_warningbar_box_title') - . html_writer::div( - $message . ' ' - . html_writer::tag('small', - '[' . html_writer::link( - new moodle_url('/auth/outage/info.php'), 'more', ['target' => 'outage'] - ) . ']' - ), - 'auth_outage_warningbar_box_message' - ), - 'auth_outage_warningbar_box' - ), - 'auth_outage_warningbar' - ) - . html_writer::div(' ', 'auth_outage_warningbar_spacer'); + ob_start(); + require($CFG->dirroot . '/auth/outage/views/warningbar.php'); + $html = ob_get_contents(); + ob_end_clean(); + return $html; } } diff --git a/settings.php b/settings.php index b6c0b94..3df7fc2 100644 --- a/settings.php +++ b/settings.php @@ -55,7 +55,7 @@ if ($hassiteconfig && is_enabled_auth('outage')) { new admin_setting_configtextarea('auth_outage/css', get_string('defaultlayoutcss', 'auth_outage'), get_string('defaultlayoutcssdescription', 'auth_outage'), - file_get_contents($CFG->dirroot.'/auth/outage/res/default.css'), + file_get_contents($CFG->dirroot . '/auth/outage/views/warningbar.css'), PARAM_TEXT) ); // Create category for Outage. diff --git a/res/default.css b/views/warningbar.css similarity index 100% rename from res/default.css rename to views/warningbar.css diff --git a/views/warningbar.php b/views/warningbar.php new file mode 100644 index 0000000..fc26212 --- /dev/null +++ b/views/warningbar.php @@ -0,0 +1,104 @@ +. + +/** + * View included by the renderer to output the outage warning bar. + * + * @package auth_outage + * @author Daniel Thee Roperto + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +if (!defined('MOODLE_INTERNAL')) { + die('Direct access to this script is forbidden.'); // It must be included from a Moodle page. +} + +// If debugging include directly from file, otherwise use plugin settings. +echo html_writer::tag('style', + debugging() ? file_get_contents($CFG->dirroot . '/auth/outage/views/warningbar.css') : get_config('auth_outage', 'css') +); + +?> + +
+
+
get_title(); ?>
+
+ + + [ 'outage'] + ); ?>] + +
+
+
+ + + +