-
Notifications
You must be signed in to change notification settings - Fork 2
/
ModuleConfig.class.php
executable file
·53 lines (40 loc) · 1.47 KB
/
ModuleConfig.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
Class ModuleConfig {
public $output = '';
public function __construct($model) {
$this->model = $model;
}
function run() {
$this->output.= '<div class="sectionHeader">Настройки</div>' .
'<div class="sectionBody"><div style="display: inline-block; width:100%;">';
$this->actions();
//print_r($_POST);
$this->renderConfigInput();
$this->output.= '</div></div>';
return $this->output;
}
function actions() {
if ($_POST['save'] && is_array($_POST['Config'])) {
$this->model->setConfig($_POST['Config']);
$this->model->saveConfig();
$this->output .= '<p>Соранение прошло успешно!</p>';
}
}
function render() {
$res = $this->model->Parse();
foreach ($res as $parent => $r) {
$this->output.='<p>' . $r . '</p>';
}
}
public function renderConfigInput() {
$this->output.= '<form method="POST">';
$this->output.= '<table>';
foreach ($this->model->getConfig() as $key => $conf) {
$this->output.= '<tr><td>' . $conf[1] . '</td><td><input type="text" value="' . $conf[0] . '" name="Config[' . $key . ']" style="width:300px;"></td></tr>';
}
$this->output.='<tr><td></td><td><input type="submit" value="Сохранить" name="save"></td></tr>';
$this->output.= '</table>
</form>';
}
}
?>