-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml.ext.php
More file actions
81 lines (63 loc) · 1.71 KB
/
html.ext.php
File metadata and controls
81 lines (63 loc) · 1.71 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
class EXT_Html extends SYS_Model_Database
{
//--------------------------------------------------------------------------
public $table = 'html';
// public $name = 'Текст страницы (HTML)';
// public $add_action = FALSE;
//--------------------------------------------------------------------------
public function init()
{
$this->fields['html'] = array(
'id' => NULL,
'type' => NULL,
'status' => array(
'label' => 'Статус',
'field' => 'radiogroup',
'options' => 'status_list',
'default' => 1,
),
'rel_id' => NULL,
'body' => array(
'label' => '',
'field' => 'html',
),
);
}
//--------------------------------------------------------------------------
public function view($type, $rel_id = 0, $create_row = TRUE)
{
$this->db->where('type=? AND rel_id=?', $type, $rel_id);
$data = $this->get_row();
if ($data->id)
{
return $this->render($data);
}
elseif ($create_row)
{
$id = $this->insert(NULL, array(
'type' => $type,
'rel_id' => $rel_id
));
$this->db->where('id=?', $id);
return $this->render($this->get_row());
}
}
//--------------------------------------------------------------------------
public function render(&$data)
{
if ( ! $data->status && $this->user->group_id !=1) return;
return $data->admin_buttons . $data->body;
}
//--------------------------------------------------------------------------
public function status_list($val = NULL)
{
static $list = array(
0 => 'Отключен',
1 => 'Включен',
);
if ($val !== NULL) return $list[$val];
return $list;
}
//--------------------------------------------------------------------------
}