From 06b3e4f918d4cc0288872b5b7b4f7b60f6501180 Mon Sep 17 00:00:00 2001 From: Daniel Thee Roperto Date: Fri, 2 Sep 2016 14:39:45 +1000 Subject: [PATCH] Issue #12: English references removed, using language pack, except on code related to Issue #11 later. --- change.php | 6 +++--- classes/forms/outage/delete.php | 2 +- classes/forms/outage/edit.php | 10 +++++----- lang/en/auth_outage.php | 21 ++++++++++++++++++++ renderer.php | 34 +++++++++++++++++++++++---------- settings.php | 21 +++++++++++--------- version.php | 2 +- 7 files changed, 67 insertions(+), 29 deletions(-) diff --git a/change.php b/change.php index 12a242c..e16fa41 100644 --- a/change.php +++ b/change.php @@ -31,7 +31,7 @@ require_once('../../config.php'); require_once($CFG->libdir . '/adminlib.php'); require_once($CFG->libdir . '/formslib.php'); -outagelib::pagesetup(); +$renderer = outagelib::pagesetup(); $mform = new \auth_outage\forms\outage\edit(); @@ -53,8 +53,8 @@ $data = get_object_vars($outage); $data['description'] = ['text' => $data['description'], 'format' => '1']; $mform->set_data($data); + echo $OUTPUT->header(); - +echo $renderer->rendersubtitle('modifyoutage'); $mform->display(); - echo $OUTPUT->footer(); diff --git a/classes/forms/outage/delete.php b/classes/forms/outage/delete.php index 9a79076..90976ca 100644 --- a/classes/forms/outage/delete.php +++ b/classes/forms/outage/delete.php @@ -41,7 +41,7 @@ class delete extends \moodleform { $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); - $this->add_action_buttons(true, get_string('ok')); + $this->add_action_buttons(true, get_string('remove')); } /** diff --git a/classes/forms/outage/edit.php b/classes/forms/outage/edit.php index 21f2117..bed0be6 100644 --- a/classes/forms/outage/edit.php +++ b/classes/forms/outage/edit.php @@ -41,16 +41,16 @@ class edit extends \moodleform { $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); - $mform->addElement('date_time_selector', 'starttime', 'Start Time'); + $mform->addElement('date_time_selector', 'starttime', get_string('starttime', 'auth_outage')); - $mform->addElement('date_time_selector', 'stoptime', 'Stop Time'); + $mform->addElement('date_time_selector', 'stoptime', get_string('stoptime', 'auth_outage')); - $mform->addElement('duration', 'warningduration', 'Warning Duration'); + $mform->addElement('duration', 'warningduration', get_string('warningduration', 'auth_outage')); - $mform->addElement('text', 'title', 'Title'); + $mform->addElement('text', 'title', get_string('title', 'auth_outage')); $mform->setType('title', PARAM_TEXT); - $mform->addElement('editor', 'description', 'Description'); + $mform->addElement('editor', 'description', get_string('description', 'auth_outage')); $this->add_action_buttons(); } diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index 1608576..acc57ca 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -25,3 +25,24 @@ $string['auth_outagedescription'] = 'Auxiliary plugin that warns users about a future outage and prevents them from logging in once the outage starts.'; $string['pluginname'] = 'Outage'; + +$string['menudefaults'] = 'Default Settings'; +$string['manage'] = 'Manage'; + +$string['defaultwarningtime'] = 'Default Warning Time'; +$string['defaultwarningtimedescription'] = 'Default warning time (in minutes) for outages.'; +$string['defaultwarningmessage'] = 'Default Warning Message'; +$string['defaultwarningmessagedescription'] = 'Default warning message for outages. Use [from] and [until] placeholders as required.'; +$string['defaultwarningmessagevalue'] = 'There is an scheduled maintenance from [from] to [until] and our system will not be available during that time.'; + +$string['starttime'] = 'Start date and time'; +$string['stoptime'] = 'Stop date and time'; +$string['warningduration'] = 'Warning duration'; +$string['title'] = 'Title'; +$string['description'] = 'Public description'; +$string['modifyoutage'] = 'Modify Outage'; +$string['removeoutage'] = 'Remove Outage'; +$string['removeoutagewarning'] = 'You are about to permanently remove the outage below. This cannot be undone.'; +$string['outageslist'] = 'Outages List'; +$string['createoutage'] = 'Create Outage'; +$string['modify'] = 'Modify'; \ No newline at end of file diff --git a/renderer.php b/renderer.php index 97528c8..772ec5c 100644 --- a/renderer.php +++ b/renderer.php @@ -31,15 +31,21 @@ if (!defined('MOODLE_INTERNAL')) { */ class auth_outage_renderer extends plugin_renderer_base { + public function rendersubtitle($subtitlekey) { + if (!is_string($subtitlekey)) throw new \InvalidArgumentException('$subtitle is not a string.'); + return html_writer::tag('h2', get_string($subtitlekey, 'auth_outage')); + } + public function renderdeleteconfirmation(outage $outage) { - return html_writer::tag('h3', 'You are about to remove the following outage:') + return $this->rendersubtitle('removeoutage') + . html_writer::tag('p', get_string('removeoutagewarning', 'auth_outage')) . $this->renderoutage($outage, false); } public function renderoutagelist(array $outages) { global $OUTPUT; - $html = html_writer::tag('h1', 'Outage List'); + $html = $this->rendersubtitle('outageslist'); // Generate list of outages. foreach ($outages as $outage) { @@ -49,9 +55,12 @@ class auth_outage_renderer extends plugin_renderer_base // Add 'add' button. $url = new moodle_url('/auth/outage/create.php'); $img = html_writer::empty_tag('img', - ['src' => $OUTPUT->pix_url('t/add'), 'alt' => get_string('add'), 'class' => 'iconsmall']); + ['src' => $OUTPUT->pix_url('t/add'), 'alt' => get_string('create'), 'class' => 'iconsmall']); $html .= html_writer::empty_tag('br') - . html_writer::link($url, $img . ' Create new Outage', ['title' => get_string('delete')]) + . html_writer::link( + $url, + $img . ' ' . get_string('createoutage', 'auth_outage'), + ['title' => get_string('remove')]) . html_writer::empty_tag('br'); return $html; @@ -73,15 +82,20 @@ class auth_outage_renderer extends plugin_renderer_base ); $url = new moodle_url('/auth/outage/change.php', ['id' => $outage->id]); - $img = html_writer::empty_tag('img', - ['src' => $OUTPUT->pix_url('t/edit'), 'alt' => get_string('edit'), 'class' => 'iconsmall']); - $linkedit = html_writer::link($url, $img, ['title' => get_string('edit')]); + $img = html_writer::empty_tag( + 'img', + ['src' => $OUTPUT->pix_url('t/edit'), 'alt' => get_string('modify', 'auth_outage'), 'class' => 'iconsmall'] + ); + $linkedit = html_writer::link($url, $img, ['title' => get_string('modify', 'auth_outage')]); $url = new moodle_url('/auth/outage/remove.php', ['id' => $outage->id]); - $img = html_writer::empty_tag('img', - ['src' => $OUTPUT->pix_url('t/delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall']); - $linkdelete = html_writer::link($url, $img, ['title' => get_string('delete')]); + $img = html_writer::empty_tag( + 'img', + ['src' => $OUTPUT->pix_url('t/delete'), 'alt' => get_string('remove'), 'class' => 'iconsmall'] + ); + $linkdelete = html_writer::link($url, $img, ['title' => get_string('remove')]); + // TODO use language pack below, solve together with Issue #12. return html_writer::div( html_writer::span( html_writer::tag('b', $outage->title, ['data-id' => $outage->id]) diff --git a/settings.php b/settings.php index 67d766d..1507e1b 100644 --- a/settings.php +++ b/settings.php @@ -28,28 +28,31 @@ defined('MOODLE_INTERNAL') || die; if ($hassiteconfig) { // Configure default settings page. - $settings->visiblename = "Defaults"; + $settings->visiblename = get_string('menudefaults', 'auth_outage'); $settings->add( new admin_setting_configtext('auth_outage_warning_period', - "Default Warning Time", - "Default warning time (in minutes) for outages.", + get_string('defaultwarningtime', 'auth_outage'), + get_string('defaultwarningtimedescription', 'auth_outage'), 120, PARAM_INT)); $settings->add( new admin_setting_configtextarea('auth_outage_warning_text', - 'Default Warning Message', - 'Default warning message for outages. Use [from] and [until] placeholders as required.', - 'There is an scheduled maintenance from [from] to [until] and our system will not be available during that time.', + get_string('defaultwarningmessage', 'auth_outage'), + get_string('defaultwarningmessagedescription', 'auth_outage'), + get_string('defaultwarningmessagevalue', 'auth_outage'), PARAM_TEXT) ); // Create category for Outage. - $ADMIN->add('authsettings', new admin_category('auth_outage', 'Outage')); + $ADMIN->add('authsettings', new admin_category('auth_outage', get_string('pluginname', 'auth_outage'))); // Add settings page toconfigure defaults. $ADMIN->add('auth_outage', $settings); // Clear '$settings' to prevent adding again outsite category. $settings = null; // Add options. $ADMIN->add('auth_outage', - new admin_externalpage('auth_outage_manage', 'Manage', + new admin_externalpage( + 'auth_outage_manage', + get_string('menumanage', 'auth_outage'), new moodle_url($CFG->wwwroot . '/auth/outage/list.php') - )); + ) + ); } \ No newline at end of file diff --git a/version.php b/version.php index b53c672..0f174e7 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); // It must be included from a Moodle page. } -$plugin->version = 2016083102; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2016090100; // The current plugin version (Date: YYYYMMDDXX). $plugin->release = $plugin->version; // Same as version $plugin->requires = 2014051200; // Requires Moodle 2.7 or later. $plugin->component = "auth_outage";