mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
Issue #33 - Refactored code, created infopage_controller to control the display of an info page.
This commit is contained in:
71
renderer.php
71
renderer.php
@@ -185,77 +185,6 @@ class auth_outage_renderer extends plugin_renderer_base {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the outage page.
|
||||
* @param outage $outage Outage to be rendered.
|
||||
* @param null $time Time to use as refence. Null for current time.
|
||||
* @return string
|
||||
* @SuppressWarnings("unused") because $admineditlink is used inside require(...)
|
||||
*/
|
||||
public function renderoutagepage(outage $outage, $time = null) {
|
||||
global $CFG;
|
||||
|
||||
if (is_null($time)) {
|
||||
$time = time();
|
||||
}
|
||||
if (!is_int($time) || ($time <= 0)) {
|
||||
throw new InvalidArgumentException('$time is not an positive int or null.');
|
||||
}
|
||||
|
||||
$adminlinks = [];
|
||||
foreach ([
|
||||
'startofwarning' => -$outage->get_warning_duration(),
|
||||
'15secondsbefore' => -15,
|
||||
'start' => 0,
|
||||
'endofoutage' => $outage->get_duration_planned(),
|
||||
] as $title => $delta) {
|
||||
$adminlinks[] = html_writer::link(
|
||||
new moodle_url(
|
||||
'/auth/outage/info.php',
|
||||
[
|
||||
'id' => $outage->id,
|
||||
'auth_outage_preview' => $outage->id,
|
||||
'auth_outage_delta' => $delta,
|
||||
]
|
||||
),
|
||||
get_string('info' . $title, 'auth_outage')
|
||||
);
|
||||
}
|
||||
|
||||
$admineditlink = html_writer::link(
|
||||
new moodle_url('/auth/outage/edit.php', ['id' => $outage->id]),
|
||||
get_string('outageedit', 'auth_outage')
|
||||
);
|
||||
|
||||
$static = false;
|
||||
|
||||
ob_start();
|
||||
require($CFG->dirroot . '/auth/outage/views/infopage.php');
|
||||
$html = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the HTML for a static info page.
|
||||
* @param outage $outage Outage to generate the page.
|
||||
* @return string The HTML code.
|
||||
* @SuppressWarnings("unused") because variables are used in require(...)
|
||||
*/
|
||||
public function renderoutagepagestatic(outage $outage) {
|
||||
global $PAGE, $CFG;
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
$static = true;
|
||||
$time = $outage->starttime;
|
||||
|
||||
ob_start();
|
||||
require($CFG->dirroot . '/auth/outage/views/infopagestatic.php');
|
||||
$html = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the warning bar.
|
||||
* @param outage $outage The outage to show in the warning bar.
|
||||
|
||||
Reference in New Issue
Block a user