Commit 1ccf6db73adcef3aa079bf54c1fdba975732adae
1 parent
374fb771
+ класс Extra для вкл./выкл доп. функций на сайте в админке
Showing
5 changed files
with
196 additions
and
0 deletions
Show diff stats
1 | +<?php | ||
2 | + | ||
3 | +// Подключение | ||
4 | +include_once ($_SERVER['DOCUMENT_ROOT'] . "/config/config.php"); | ||
5 | +include_once ($_SERVER['DOCUMENT_ROOT'] . "/account/func/func.php"); | ||
6 | +include_once ($_SERVER['DOCUMENT_ROOT'] . "/libs/setup.php"); | ||
7 | +$setup = new setup (true); | ||
8 | + | ||
9 | +switch ($_REQUEST['jaction']) | ||
10 | +{ | ||
11 | + case 'extra': | ||
12 | + | ||
13 | + $objExtra = $setup->setupClass ('Extra'); | ||
14 | + if ($objExtra->setExtraStatus ($_REQUEST)) | ||
15 | + { | ||
16 | + echo json_encode (array ( | ||
17 | + 'html' => htmlMessage ('success', 'Сохранено') | ||
18 | + )); | ||
19 | + } | ||
20 | + else | ||
21 | + { | ||
22 | + echo json_encode (array ( | ||
23 | + 'html' => htmlMessage ('error', 'Не сохранено') | ||
24 | + )); | ||
25 | + } | ||
26 | + | ||
27 | + break; | ||
28 | +} | ||
0 | \ No newline at end of file | 29 | \ No newline at end of file |
css/admin.css
@@ -61,9 +61,13 @@ p{margin:0px;} | @@ -61,9 +61,13 @@ p{margin:0px;} | ||
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
64 | + | ||
64 | /* | 65 | /* |
66 | + =================== | ||
65 | ==== adminMenu ==== | 67 | ==== adminMenu ==== |
68 | + =================== | ||
66 | */ | 69 | */ |
70 | + | ||
67 | div.adminMenu { | 71 | div.adminMenu { |
68 | width: 190px; | 72 | width: 190px; |
69 | } | 73 | } |
@@ -125,6 +129,25 @@ div.adminMenu .activeMenu { | @@ -125,6 +129,25 @@ div.adminMenu .activeMenu { | ||
125 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#001560', endColorstr='#103782',GradientType=0 ); | 129 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#001560', endColorstr='#103782',GradientType=0 ); |
126 | } | 130 | } |
127 | 131 | ||
132 | +/* | ||
133 | + =============== | ||
134 | + ==== Extra ==== | ||
135 | + =============== | ||
136 | +*/ | ||
137 | + | ||
138 | +#Extra .line .label { | ||
139 | + text-transform: uppercase; | ||
140 | + color: #000; | ||
141 | + margin: 0 1px 0 0; | ||
142 | + text-align: center; | ||
143 | + text-decoration: none; | ||
144 | + white-space: nowrap; | ||
145 | + width: 100px; | ||
146 | +} | ||
147 | + | ||
148 | +#Extra .line > div { | ||
149 | + display: inline-block; | ||
150 | +} | ||
128 | 151 | ||
129 | .td_top {background-color:#296da4; color:#ffffff;} | 152 | .td_top {background-color:#296da4; color:#ffffff;} |
130 | .td_1 {background-color:#f6f6f6; color:#000000;} | 153 | .td_1 {background-color:#f6f6f6; color:#000000;} |
1 | + | ||
2 | + function extraAction ($array) | ||
3 | + { | ||
4 | + $.ajax({ | ||
5 | + type: 'GET', | ||
6 | + url: '/ajax/extra.php', | ||
7 | + dataType: 'json', | ||
8 | + data: $.param ($array['json']), | ||
9 | + success: function (response) | ||
10 | + { | ||
11 | + switch ($array['json']['jaction']) | ||
12 | + { | ||
13 | + case 'extra': | ||
14 | + | ||
15 | + modalBoxLoad (response.html, { | ||
16 | + autoClose: 800, | ||
17 | + }); | ||
18 | + break; | ||
19 | + } | ||
20 | + }, | ||
21 | + error: function() | ||
22 | + { | ||
23 | + modalBoxLoad ('×òî-òî ïîøëî íå òàê...'); | ||
24 | + } | ||
25 | + }); | ||
26 | + | ||
27 | + } | ||
28 | + | ||
29 | +$(function() | ||
30 | +{ | ||
31 | + $(".switch").bootstrapSwitch( | ||
32 | + { | ||
33 | + onSwitchChange: function(event, state) | ||
34 | + { | ||
35 | + extraAction ({ | ||
36 | + 'json': { | ||
37 | + 'jaction': 'extra', | ||
38 | + 'status_id': state === false ? 0 : 1, | ||
39 | + 'extra_id': $(this).closest('.line').attr('id').replace('extra-', ''), | ||
40 | + } | ||
41 | + }); | ||
42 | + } | ||
43 | + }); | ||
44 | +}); | ||
0 | \ No newline at end of file | 45 | \ No newline at end of file |
1 | +<?php | ||
2 | + | ||
3 | +class Extra | ||
4 | +{ | ||
5 | + var $db = null; | ||
6 | + var $tpl = null; | ||
7 | + var $error = null; | ||
8 | + var $cache = null; | ||
9 | + | ||
10 | + public function __construct (&$db, &$tpl, &$error, &$cache) | ||
11 | + { | ||
12 | + $this->db = &$db; | ||
13 | + $this->tpl = &$tpl; | ||
14 | + $this->error = &$error; | ||
15 | + $this->cache = &$cache; | ||
16 | + } | ||
17 | + | ||
18 | + public function trim (&$data) | ||
19 | + { | ||
20 | + foreach ($data as $key => $value) | ||
21 | + { | ||
22 | + if (! is_array ($data[$key])) | ||
23 | + { | ||
24 | + $data[$key] = trim ($value); | ||
25 | + } | ||
26 | + } | ||
27 | + } | ||
28 | + | ||
29 | + public function valid ($data, $upload = null) | ||
30 | + { | ||
31 | + return true; | ||
32 | + } | ||
33 | + | ||
34 | + public function getAll () | ||
35 | + { | ||
36 | + return $this->db->getAll(' | ||
37 | + SELECT * | ||
38 | + FROM `extra` | ||
39 | + INNER JOIN `extra_status` ON `extra_status`.status_id = `extra`.status_id | ||
40 | + ', array (), DB_FETCHMODE_ASSOC); | ||
41 | + } | ||
42 | + | ||
43 | + public function init () | ||
44 | + { | ||
45 | + // assign var | ||
46 | + $this->tpl->assign('mass', array ( | ||
47 | + 'extra' => $this->getAll(), | ||
48 | + )); | ||
49 | + | ||
50 | + // assign template | ||
51 | + $this->tpl->assign("tpl", "extra.tpl"); | ||
52 | + } | ||
53 | + | ||
54 | + public function getOneByName ($NAME) | ||
55 | + { | ||
56 | + return $this->db->getRow(' | ||
57 | + SELECT * | ||
58 | + FROM `extra` | ||
59 | + INNER JOIN `extra_status` ON `extra_status`.status_id = `extra`.status_id | ||
60 | + WHERE `extra`.extra_name=? | ||
61 | + ', array ($NAME), DB_FETCHMODE_ASSOC); | ||
62 | + } | ||
63 | + | ||
64 | + public function getOneById ($id) | ||
65 | + { | ||
66 | + return $this->db->getRow(' | ||
67 | + SELECT * | ||
68 | + FROM `extra` | ||
69 | + INNER JOIN `extra_status` ON `extra_status`.status_id = `extra`.status_id | ||
70 | + WHERE `extra`.extra_id=? | ||
71 | + ', array ($id), DB_FETCHMODE_ASSOC); | ||
72 | + } | ||
73 | + | ||
74 | + public function getStatusIdByName ($NAME) | ||
75 | + { | ||
76 | + $result = $this->getOneByName ($NAME); | ||
77 | + | ||
78 | + return $result['status_id']; | ||
79 | + } | ||
80 | + | ||
81 | + public function setExtraStatus ($param) | ||
82 | + { | ||
83 | + return $this->db->query(' | ||
84 | + UPDATE `extra` | ||
85 | + SET status_id = '.(int)$param['status_id'].' | ||
86 | + WHERE extra_id = '.(int)$param['extra_id'].' | ||
87 | + '); | ||
88 | + } | ||
89 | + | ||
90 | + public function displaySnow () | ||
91 | + { | ||
92 | + return ' | ||
93 | + <link rel="stylesheet" type="text/css" href="/js/snowstorm.css" /> | ||
94 | + '; | ||
95 | + // <script src="/js/snowstorm.js"></script> | ||
96 | + } | ||
97 | +} |