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

36 lines
1.1 KiB
PHP
Raw Normal View History

2015-08-07 23:33:43 +02:00
<?php
2016-02-20 17:16:31 +01:00
class pluginMaintenanceMode extends Plugin {
2015-08-07 23:33:43 +02:00
2021-09-25 20:28:17 +02:00
public function init() {
2015-08-07 23:33:43 +02:00
$this->dbFields = array(
2018-07-02 00:24:53 +02:00
'enable'=>false,
2015-08-07 23:33:43 +02:00
'message'=>'Temporarily down for maintenance.'
);
}
2021-09-25 20:28:17 +02:00
public function form() {
global $L;
2015-08-07 23:33:43 +02:00
2021-09-25 20:28:17 +02:00
$html = '<div class="mb-3">';
$html .= '<label class="form-label" for="enable">'.$L->get('Enable maintenance mode').'</label>';
$html .= '<select class="form-select" id="enable" name="enable">';
$html .= '<option value="true" '.($this->getValue('enable')===true?'selected':'').'>'.$L->get('Enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('enable')===false?'selected':'').'>'.$L->get('Disabled').'</option>';
$html .= '</select>';
2015-08-07 23:33:43 +02:00
$html .= '</div>';
2021-09-25 20:28:17 +02:00
$html .= '<div class="mb-3">';
$html .= '<label class="form-label" for="message">'.$L->get('Message').'</label>';
$html .= '<input class="form-control" id="message" name="message" type="text" value="'.$this->getValue('message').'">';
2015-08-07 23:33:43 +02:00
$html .= '</div>';
return $html;
}
2021-09-25 20:28:17 +02:00
public function beforeAll() {
2018-08-02 22:33:53 +02:00
if ($this->getValue('enable')) {
exit( $this->getValue('message') );
2015-08-07 23:33:43 +02:00
}
}
2016-02-26 16:32:18 +01:00
}