Issue #12: English references removed, using language pack, except on code related to Issue #11 later.

This commit is contained in:
Daniel Thee Roperto
2016-09-02 14:39:45 +10:00
parent 729c8f521a
commit 06b3e4f918
7 changed files with 67 additions and 29 deletions

View File

@@ -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();

View File

@@ -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'));
}
/**

View File

@@ -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();
}

View File

@@ -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';

View File

@@ -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])

View File

@@ -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')
));
)
);
}

View File

@@ -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";