koblog/bl-plugins/maintenance-mode/plugin.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2015-08-07 23:33:43 +02:00
<?php
class pluginMaintenanceMode extends Plugin
{
2015-08-07 23:33:43 +02:00
public function init()
{
$this->dbFields = array(
'enable' => false,
'message' => 'Temporarily down for maintenance.'
2015-08-07 23:33:43 +02:00
);
}
public function form()
{
global $L;
2015-08-07 23:33:43 +02:00
2018-07-02 00:24:53 +02:00
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>' . $L->get('Enable maintenance mode') . '</label>';
$html .= '<select name="enable">';
$html .= '<option value="true" ' . ($this->getValue('enable') === true ? 'selected' : '') . '>Enabled</option>';
$html .= '<option value="false" ' . ($this->getValue('enable') === false ? 'selected' : '') . '>Disabled</option>';
$html .= '</select>';
2015-08-07 23:33:43 +02:00
$html .= '</div>';
$html .= '<div>';
$html .= '<label>' . $L->get('Message') . '</label>';
$html .= '<input name="message" id="jsmessage" type="text" dir="auto" value="' . $this->getValue('message') . '">';
2015-08-07 23:33:43 +02:00
$html .= '</div>';
return $html;
}
public function beforeAll()
2015-08-07 23:33:43 +02:00
{
2018-08-02 22:33:53 +02:00
if ($this->getValue('enable')) {
exit($this->getValue('message'));
2015-08-07 23:33:43 +02:00
}
}
}