@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | // Anti Hack |
16 | 16 | //--------------------------------------------------------- |
17 | 17 | if(!defined('RooCMS') || !defined('ACP')) { |
18 | - die('Access Denied'); |
|
18 | + die('Access Denied'); |
|
19 | 19 | } |
20 | 20 | //######################################################### |
21 | 21 | |
@@ -24,348 +24,348 @@ discard block |
||
24 | 24 | |
25 | 25 | class ACP_Config extends ACP_ConfigAction { |
26 | 26 | |
27 | - # classes |
|
28 | - private $config; |
|
27 | + # classes |
|
28 | + private $config; |
|
29 | 29 | |
30 | - private $part = "global"; |
|
30 | + private $part = "global"; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Key on "start" (c) |
|
36 | - * |
|
37 | - */ |
|
38 | - public function __construct() { |
|
34 | + /** |
|
35 | + * Key on "start" (c) |
|
36 | + * |
|
37 | + */ |
|
38 | + public function __construct() { |
|
39 | 39 | |
40 | - global $config, $tpl, $post; |
|
40 | + global $config, $tpl, $post; |
|
41 | 41 | |
42 | 42 | |
43 | - # include config class |
|
44 | - $this->config = $config; |
|
43 | + # include config class |
|
44 | + $this->config = $config; |
|
45 | 45 | |
46 | - # choice action |
|
47 | - if(isset($post->update_config)) { |
|
48 | - $this->update_config(); |
|
49 | - } |
|
50 | - else { |
|
51 | - $this->view_config(); |
|
52 | - } |
|
46 | + # choice action |
|
47 | + if(isset($post->update_config)) { |
|
48 | + $this->update_config(); |
|
49 | + } |
|
50 | + else { |
|
51 | + $this->view_config(); |
|
52 | + } |
|
53 | 53 | |
54 | - # Load Template |
|
55 | - $tpl->load_template("config"); |
|
56 | - } |
|
54 | + # Load Template |
|
55 | + $tpl->load_template("config"); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Show settings |
|
61 | - * |
|
62 | - */ |
|
63 | - private function view_config() { |
|
59 | + /** |
|
60 | + * Show settings |
|
61 | + * |
|
62 | + */ |
|
63 | + private function view_config() { |
|
64 | 64 | |
65 | - global $db, $smarty, $get; |
|
65 | + global $db, $smarty, $get; |
|
66 | 66 | |
67 | - $parts = []; |
|
67 | + $parts = []; |
|
68 | 68 | |
69 | - if(isset($get->_part) && $db->check_id($get->_part, CONFIG_PARTS_TABLE, "name") == 1) { |
|
70 | - $this->part = $get->_part; |
|
71 | - } |
|
72 | - //elseif(isset($get->_part) && $get->_part == "all") $this->part = "all"; |
|
69 | + if(isset($get->_part) && $db->check_id($get->_part, CONFIG_PARTS_TABLE, "name") == 1) { |
|
70 | + $this->part = $get->_part; |
|
71 | + } |
|
72 | + //elseif(isset($get->_part) && $get->_part == "all") $this->part = "all"; |
|
73 | 73 | |
74 | - # get data config |
|
75 | - $q_1 = $db->query("SELECT name, title, type, ico FROM ".CONFIG_PARTS_TABLE." ORDER BY type ASC, sort ASC"); |
|
76 | - while($part = $db->fetch_assoc($q_1)) { |
|
74 | + # get data config |
|
75 | + $q_1 = $db->query("SELECT name, title, type, ico FROM ".CONFIG_PARTS_TABLE." ORDER BY type ASC, sort ASC"); |
|
76 | + while($part = $db->fetch_assoc($q_1)) { |
|
77 | 77 | |
78 | - # get option |
|
79 | - if($this->part == $part['name']) { |
|
78 | + # get option |
|
79 | + if($this->part == $part['name']) { |
|
80 | 80 | |
81 | - $this_part = $part; |
|
81 | + $this_part = $part; |
|
82 | 82 | |
83 | - $q_2 = $db->query("SELECT id, title, description, option_name, option_type, variants, value, default_value, field_maxleight FROM ".CONFIG_TABLE." WHERE part='".$part['name']."' ORDER BY sort ASC"); |
|
84 | - while($option = $db->fetch_assoc($q_2)) { |
|
85 | - |
|
86 | - # parse |
|
87 | - $option['option'] = $this->init_field($option['option_name'], $option['option_type'], $option['value'], $option['variants'], $option['field_maxleight']); |
|
83 | + $q_2 = $db->query("SELECT id, title, description, option_name, option_type, variants, value, default_value, field_maxleight FROM ".CONFIG_TABLE." WHERE part='".$part['name']."' ORDER BY sort ASC"); |
|
84 | + while($option = $db->fetch_assoc($q_2)) { |
|
85 | + |
|
86 | + # parse |
|
87 | + $option['option'] = $this->init_field($option['option_name'], $option['option_type'], $option['value'], $option['variants'], $option['field_maxleight']); |
|
88 | 88 | |
89 | - # compile for output |
|
90 | - $this_part['options'][] = $option; |
|
91 | - } |
|
89 | + # compile for output |
|
90 | + $this_part['options'][] = $option; |
|
91 | + } |
|
92 | 92 | |
93 | - # tpl |
|
94 | - $smarty->assign('this_part', $this_part); |
|
95 | - } |
|
93 | + # tpl |
|
94 | + $smarty->assign('this_part', $this_part); |
|
95 | + } |
|
96 | 96 | |
97 | - $parts[$part['type']][] = $part; |
|
98 | - } |
|
97 | + $parts[$part['type']][] = $part; |
|
98 | + } |
|
99 | 99 | |
100 | - # tpl |
|
101 | - $smarty->assign('parts', $parts); |
|
102 | - $smarty->assign('thispart', $this->part); |
|
103 | - } |
|
100 | + # tpl |
|
101 | + $smarty->assign('parts', $parts); |
|
102 | + $smarty->assign('thispart', $this->part); |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * initialisation |
|
108 | - * |
|
109 | - * @param string $option_name - field name |
|
110 | - * @param string $option_type - field type |
|
111 | - * @param string $value - field value |
|
112 | - * @param string $variants - field variants (for selectable fields) |
|
113 | - * |
|
114 | - * @param int $maxlength |
|
115 | - * |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - private function init_field($option_name, $option_type, $value, $variants, $maxlength=0) { |
|
106 | + /** |
|
107 | + * initialisation |
|
108 | + * |
|
109 | + * @param string $option_name - field name |
|
110 | + * @param string $option_type - field type |
|
111 | + * @param string $value - field value |
|
112 | + * @param string $variants - field variants (for selectable fields) |
|
113 | + * |
|
114 | + * @param int $maxlength |
|
115 | + * |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + private function init_field($option_name, $option_type, $value, $variants, $maxlength=0) { |
|
119 | 119 | |
120 | - global $tpl, $smarty, $parse; |
|
120 | + global $tpl, $smarty, $parse; |
|
121 | 121 | |
122 | - $field = array('name'=>$option_name, 'value'=>$value, 'type'=>$option_type, 'maxlength'=>$maxlength); |
|
123 | - $smarty->assign('field', $field); |
|
124 | - |
|
125 | - switch($option_type) { |
|
126 | - # integer OR string OR email |
|
127 | - case 'int': |
|
128 | - case 'string': |
|
129 | - case 'email': |
|
130 | - case 'color': |
|
131 | - $out = $tpl->load_template("config_field_string",true); |
|
132 | - break; |
|
133 | - |
|
134 | - # text OR textarea |
|
135 | - case 'text': |
|
136 | - $out = $tpl->load_template("config_field_textarea",true); |
|
137 | - break; |
|
138 | - |
|
139 | - # html |
|
140 | - case 'html': |
|
141 | - $out = $tpl->load_template("config_field_html",true); |
|
142 | - break; |
|
143 | - |
|
144 | - # boolean |
|
145 | - case 'boolean': |
|
146 | - $out = $tpl->load_template("config_field_boolean",true); |
|
147 | - break; |
|
148 | - |
|
149 | - # date |
|
150 | - case 'date': |
|
151 | - $field['value'] = $parse->date->unix_to_rusint($field['value']); |
|
152 | - $out = $tpl->load_template("config_field_date",true); |
|
153 | - break; |
|
154 | - |
|
155 | - # select |
|
156 | - case 'select': |
|
157 | - $vars = explode("\n",$variants); |
|
158 | - foreach($vars AS $v) { |
|
159 | - $vars = explode("|",trim($v)); |
|
160 | - |
|
161 | - $s = ""; |
|
162 | - if($vars[1] == $value) { |
|
163 | - $s = "selected"; |
|
164 | - } |
|
165 | - |
|
166 | - $field['variants'][] = array('value'=>$vars[1], 'title'=>$vars[0], 'selected'=>$s); |
|
167 | - } |
|
168 | - |
|
169 | - $smarty->assign('field', $field); |
|
170 | - $out = $tpl->load_template("config_field_select",true); |
|
171 | - break; |
|
172 | - |
|
173 | - # image |
|
174 | - case 'image': |
|
175 | - $image = []; |
|
176 | - if(is_file(_UPLOADIMAGES."/".$field['value'])) { |
|
177 | - $image['src'] = $field['value']; |
|
178 | - $size = getimagesize(_UPLOADIMAGES."/".$image['src']); |
|
179 | - $image['width'] = $size[0]; |
|
180 | - $image['height'] = $size[1]; |
|
181 | - } |
|
182 | - |
|
183 | - # image types |
|
184 | - $imagetype = []; |
|
185 | - require _LIB."/mimetype.php"; |
|
186 | - $smarty->assign("allow_images_type", $imagetype); |
|
187 | - |
|
188 | - $smarty->assign("image", $image); |
|
189 | - $out = $tpl->load_template("config_field_image", true); |
|
190 | - break; |
|
191 | - |
|
192 | - default: |
|
193 | - $out = "Нераспознанный параметр"; |
|
194 | - break; |
|
195 | - } |
|
196 | - |
|
197 | - return $out; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * Update configuration |
|
203 | - */ |
|
204 | - private function update_config() { |
|
205 | - |
|
206 | - global $parse, $logger, $post, $img; |
|
207 | - |
|
208 | - # get type options from db |
|
209 | - $cfg_vars = $this->get_cfg_vars(); |
|
210 | - |
|
211 | - # if use special part |
|
212 | - $this->init_for_special_part(); |
|
213 | - |
|
214 | - # remove updater |
|
215 | - unset($post->update_config); |
|
216 | - |
|
217 | - # update option |
|
218 | - foreach($post AS $key=>$value) { |
|
219 | - |
|
220 | - $check = false; |
|
221 | - |
|
222 | - switch($cfg_vars[$key]['type']) { |
|
223 | - # integer |
|
224 | - case 'int': |
|
225 | - $value = round($value); |
|
226 | - settype($value, "integer"); |
|
227 | - $check = true; |
|
228 | - break; |
|
229 | - |
|
230 | ||
231 | - case 'email': |
|
232 | - $check = $parse->valid_email($value); |
|
233 | - break; |
|
234 | - |
|
235 | - # text OR textarea OR html |
|
236 | - case 'string': |
|
237 | - case 'color': |
|
238 | - case 'text': |
|
239 | - case 'html': |
|
240 | - $value = $this->check_string_value($value,$cfg_vars[$key]['maxleight']); |
|
241 | - $check = true; |
|
242 | - break; |
|
243 | - |
|
244 | - # boolean |
|
245 | - case 'boolean': //TODO: $value = (int) filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
246 | - if($value == "true" || $value == "false") { |
|
247 | - $check = true; |
|
248 | - } |
|
249 | - break; |
|
250 | - |
|
251 | - # date |
|
252 | - case 'date': |
|
253 | - $value = $parse->date->rusint_to_unix($post->$key); |
|
254 | - $check = true; |
|
255 | - break; |
|
256 | - |
|
257 | - # select |
|
258 | - case 'select': |
|
259 | - if(isset($cfg_vars[$key]['var'][$value])) { |
|
260 | - $check = true; |
|
261 | - } |
|
262 | - break; |
|
263 | - |
|
264 | - # image |
|
265 | - case 'image': |
|
266 | - $image = $img->upload_image("image_".$key, "", array(), false, false, true, $key); |
|
267 | - |
|
268 | - if(isset($image[0])) { |
|
269 | - if($value != "" && $value != $image[0]) { |
|
270 | - $img->erase_image(_UPLOADIMAGES."/".$value); |
|
271 | - } |
|
272 | - $value = $image[0]; |
|
273 | - $check = true; |
|
274 | - } |
|
275 | - break; |
|
276 | - } |
|
277 | - |
|
278 | - # update db |
|
279 | - $this->update_db_config($check, $key, $value); |
|
280 | - } |
|
122 | + $field = array('name'=>$option_name, 'value'=>$value, 'type'=>$option_type, 'maxlength'=>$maxlength); |
|
123 | + $smarty->assign('field', $field); |
|
124 | + |
|
125 | + switch($option_type) { |
|
126 | + # integer OR string OR email |
|
127 | + case 'int': |
|
128 | + case 'string': |
|
129 | + case 'email': |
|
130 | + case 'color': |
|
131 | + $out = $tpl->load_template("config_field_string",true); |
|
132 | + break; |
|
133 | + |
|
134 | + # text OR textarea |
|
135 | + case 'text': |
|
136 | + $out = $tpl->load_template("config_field_textarea",true); |
|
137 | + break; |
|
138 | + |
|
139 | + # html |
|
140 | + case 'html': |
|
141 | + $out = $tpl->load_template("config_field_html",true); |
|
142 | + break; |
|
143 | + |
|
144 | + # boolean |
|
145 | + case 'boolean': |
|
146 | + $out = $tpl->load_template("config_field_boolean",true); |
|
147 | + break; |
|
148 | + |
|
149 | + # date |
|
150 | + case 'date': |
|
151 | + $field['value'] = $parse->date->unix_to_rusint($field['value']); |
|
152 | + $out = $tpl->load_template("config_field_date",true); |
|
153 | + break; |
|
154 | + |
|
155 | + # select |
|
156 | + case 'select': |
|
157 | + $vars = explode("\n",$variants); |
|
158 | + foreach($vars AS $v) { |
|
159 | + $vars = explode("|",trim($v)); |
|
160 | + |
|
161 | + $s = ""; |
|
162 | + if($vars[1] == $value) { |
|
163 | + $s = "selected"; |
|
164 | + } |
|
165 | + |
|
166 | + $field['variants'][] = array('value'=>$vars[1], 'title'=>$vars[0], 'selected'=>$s); |
|
167 | + } |
|
168 | + |
|
169 | + $smarty->assign('field', $field); |
|
170 | + $out = $tpl->load_template("config_field_select",true); |
|
171 | + break; |
|
172 | + |
|
173 | + # image |
|
174 | + case 'image': |
|
175 | + $image = []; |
|
176 | + if(is_file(_UPLOADIMAGES."/".$field['value'])) { |
|
177 | + $image['src'] = $field['value']; |
|
178 | + $size = getimagesize(_UPLOADIMAGES."/".$image['src']); |
|
179 | + $image['width'] = $size[0]; |
|
180 | + $image['height'] = $size[1]; |
|
181 | + } |
|
182 | + |
|
183 | + # image types |
|
184 | + $imagetype = []; |
|
185 | + require _LIB."/mimetype.php"; |
|
186 | + $smarty->assign("allow_images_type", $imagetype); |
|
187 | + |
|
188 | + $smarty->assign("image", $image); |
|
189 | + $out = $tpl->load_template("config_field_image", true); |
|
190 | + break; |
|
191 | + |
|
192 | + default: |
|
193 | + $out = "Нераспознанный параметр"; |
|
194 | + break; |
|
195 | + } |
|
196 | + |
|
197 | + return $out; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * Update configuration |
|
203 | + */ |
|
204 | + private function update_config() { |
|
205 | + |
|
206 | + global $parse, $logger, $post, $img; |
|
207 | + |
|
208 | + # get type options from db |
|
209 | + $cfg_vars = $this->get_cfg_vars(); |
|
210 | + |
|
211 | + # if use special part |
|
212 | + $this->init_for_special_part(); |
|
213 | + |
|
214 | + # remove updater |
|
215 | + unset($post->update_config); |
|
216 | + |
|
217 | + # update option |
|
218 | + foreach($post AS $key=>$value) { |
|
219 | + |
|
220 | + $check = false; |
|
221 | + |
|
222 | + switch($cfg_vars[$key]['type']) { |
|
223 | + # integer |
|
224 | + case 'int': |
|
225 | + $value = round($value); |
|
226 | + settype($value, "integer"); |
|
227 | + $check = true; |
|
228 | + break; |
|
229 | + |
|
230 | ||
231 | + case 'email': |
|
232 | + $check = $parse->valid_email($value); |
|
233 | + break; |
|
234 | + |
|
235 | + # text OR textarea OR html |
|
236 | + case 'string': |
|
237 | + case 'color': |
|
238 | + case 'text': |
|
239 | + case 'html': |
|
240 | + $value = $this->check_string_value($value,$cfg_vars[$key]['maxleight']); |
|
241 | + $check = true; |
|
242 | + break; |
|
243 | + |
|
244 | + # boolean |
|
245 | + case 'boolean': //TODO: $value = (int) filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
246 | + if($value == "true" || $value == "false") { |
|
247 | + $check = true; |
|
248 | + } |
|
249 | + break; |
|
250 | + |
|
251 | + # date |
|
252 | + case 'date': |
|
253 | + $value = $parse->date->rusint_to_unix($post->$key); |
|
254 | + $check = true; |
|
255 | + break; |
|
256 | + |
|
257 | + # select |
|
258 | + case 'select': |
|
259 | + if(isset($cfg_vars[$key]['var'][$value])) { |
|
260 | + $check = true; |
|
261 | + } |
|
262 | + break; |
|
263 | + |
|
264 | + # image |
|
265 | + case 'image': |
|
266 | + $image = $img->upload_image("image_".$key, "", array(), false, false, true, $key); |
|
267 | + |
|
268 | + if(isset($image[0])) { |
|
269 | + if($value != "" && $value != $image[0]) { |
|
270 | + $img->erase_image(_UPLOADIMAGES."/".$value); |
|
271 | + } |
|
272 | + $value = $image[0]; |
|
273 | + $check = true; |
|
274 | + } |
|
275 | + break; |
|
276 | + } |
|
277 | + |
|
278 | + # update db |
|
279 | + $this->update_db_config($check, $key, $value); |
|
280 | + } |
|
281 | 281 | |
282 | 282 | |
283 | - # notice |
|
284 | - $logger->info("Настройки обновлены", false); |
|
285 | - |
|
283 | + # notice |
|
284 | + $logger->info("Настройки обновлены", false); |
|
285 | + |
|
286 | 286 | |
287 | - # move |
|
288 | - if(isset($post->cp_script) && CP != $post->cp_script) { // Если мы изменяли путь скрипта к панели управления. |
|
289 | - $path = getenv("HTTP_REFERER"); |
|
290 | - $path = str_ireplace(CP, $post->cp_script, $path); |
|
287 | + # move |
|
288 | + if(isset($post->cp_script) && CP != $post->cp_script) { // Если мы изменяли путь скрипта к панели управления. |
|
289 | + $path = getenv("HTTP_REFERER"); |
|
290 | + $path = str_ireplace(CP, $post->cp_script, $path); |
|
291 | 291 | |
292 | - unlink(_SITEROOT."/".CP); |
|
293 | - |
|
294 | - go($path); |
|
295 | - } |
|
292 | + unlink(_SITEROOT."/".CP); |
|
293 | + |
|
294 | + go($path); |
|
295 | + } |
|
296 | 296 | |
297 | - # goback |
|
298 | - goback(); |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - /** |
|
303 | - * Update config in database |
|
304 | - * |
|
305 | - * @param bool $check - check status |
|
306 | - * @param string $option - option name |
|
307 | - * @param string $value - option value |
|
308 | - */ |
|
309 | - private function update_db_config($check, $option, $value) { |
|
310 | - |
|
311 | - global $db, $logger; |
|
312 | - |
|
313 | - if($check) { |
|
314 | - $db->query("UPDATE ".CONFIG_TABLE." SET value='".$value."' WHERE option_name='".$option."'"); |
|
315 | - |
|
316 | - # log |
|
317 | - $logger->log("Update config: option name=".$option.", value=".$value); |
|
318 | - } |
|
319 | - } |
|
320 | - |
|
321 | - |
|
322 | - /** |
|
323 | - * String type value parsing |
|
324 | - * |
|
325 | - * @param string $value |
|
326 | - * @param int $maxleight |
|
327 | - * |
|
328 | - * @return string |
|
329 | - */ |
|
330 | - private function check_string_value($value, $maxleight=0) { |
|
331 | - |
|
332 | - if($maxleight > 0) { |
|
333 | - $value = mb_substr($value, 0, $maxleight); |
|
334 | - } |
|
335 | - |
|
336 | - return $value; |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - /** |
|
341 | - * Request data types and values from db |
|
342 | - * |
|
343 | - * @return array |
|
344 | - */ |
|
345 | - private function get_cfg_vars() { |
|
297 | + # goback |
|
298 | + goback(); |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + /** |
|
303 | + * Update config in database |
|
304 | + * |
|
305 | + * @param bool $check - check status |
|
306 | + * @param string $option - option name |
|
307 | + * @param string $value - option value |
|
308 | + */ |
|
309 | + private function update_db_config($check, $option, $value) { |
|
310 | + |
|
311 | + global $db, $logger; |
|
312 | + |
|
313 | + if($check) { |
|
314 | + $db->query("UPDATE ".CONFIG_TABLE." SET value='".$value."' WHERE option_name='".$option."'"); |
|
315 | + |
|
316 | + # log |
|
317 | + $logger->log("Update config: option name=".$option.", value=".$value); |
|
318 | + } |
|
319 | + } |
|
320 | + |
|
321 | + |
|
322 | + /** |
|
323 | + * String type value parsing |
|
324 | + * |
|
325 | + * @param string $value |
|
326 | + * @param int $maxleight |
|
327 | + * |
|
328 | + * @return string |
|
329 | + */ |
|
330 | + private function check_string_value($value, $maxleight=0) { |
|
331 | + |
|
332 | + if($maxleight > 0) { |
|
333 | + $value = mb_substr($value, 0, $maxleight); |
|
334 | + } |
|
335 | + |
|
336 | + return $value; |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + /** |
|
341 | + * Request data types and values from db |
|
342 | + * |
|
343 | + * @return array |
|
344 | + */ |
|
345 | + private function get_cfg_vars() { |
|
346 | 346 | |
347 | - global $db; |
|
347 | + global $db; |
|
348 | 348 | |
349 | - $cfg_vars = []; |
|
350 | - $q = $db->query("SELECT option_name, option_type, variants, field_maxleight FROM ".CONFIG_TABLE); |
|
351 | - while($row = $db->fetch_assoc($q)) { |
|
349 | + $cfg_vars = []; |
|
350 | + $q = $db->query("SELECT option_name, option_type, variants, field_maxleight FROM ".CONFIG_TABLE); |
|
351 | + while($row = $db->fetch_assoc($q)) { |
|
352 | 352 | |
353 | - $cfg_vars[$row['option_name']]['type'] = $row['option_type']; |
|
354 | - $cfg_vars[$row['option_name']]['maxleight'] = $row['field_maxleight']; |
|
353 | + $cfg_vars[$row['option_name']]['type'] = $row['option_type']; |
|
354 | + $cfg_vars[$row['option_name']]['maxleight'] = $row['field_maxleight']; |
|
355 | 355 | |
356 | - if(trim($row['variants']) != "") { |
|
356 | + if(trim($row['variants']) != "") { |
|
357 | 357 | |
358 | - $vars = explode("\n",$row['variants']); |
|
358 | + $vars = explode("\n",$row['variants']); |
|
359 | 359 | |
360 | - foreach($vars AS $v) { |
|
361 | - $v = explode("|",trim($v)); |
|
362 | - $cfg_vars[$row['option_name']]['var'][$v[1]] = trim($v[1]); |
|
363 | - } |
|
364 | - } |
|
365 | - } |
|
360 | + foreach($vars AS $v) { |
|
361 | + $v = explode("|",trim($v)); |
|
362 | + $cfg_vars[$row['option_name']]['var'][$v[1]] = trim($v[1]); |
|
363 | + } |
|
364 | + } |
|
365 | + } |
|
366 | 366 | |
367 | - return $cfg_vars; |
|
368 | - } |
|
367 | + return $cfg_vars; |
|
368 | + } |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | # require special part for config |
23 | 23 | require_once "config_action.php"; |
24 | 24 | |
25 | -class ACP_Config extends ACP_ConfigAction { |
|
25 | +class ACP_Config extends ACP_ConfigAction { |
|
26 | 26 | |
27 | 27 | # classes |
28 | 28 | private $config; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * Key on "start" (c) |
36 | 36 | * |
37 | 37 | */ |
38 | - public function __construct() { |
|
38 | + public function __construct() { |
|
39 | 39 | |
40 | 40 | global $config, $tpl, $post; |
41 | 41 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | # choice action |
47 | 47 | if(isset($post->update_config)) { |
48 | 48 | $this->update_config(); |
49 | - } |
|
49 | + } |
|
50 | 50 | else { |
51 | 51 | $this->view_config(); |
52 | 52 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * Show settings |
61 | 61 | * |
62 | 62 | */ |
63 | - private function view_config() { |
|
63 | + private function view_config() { |
|
64 | 64 | |
65 | 65 | global $db, $smarty, $get; |
66 | 66 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return string |
117 | 117 | */ |
118 | - private function init_field($option_name, $option_type, $value, $variants, $maxlength=0) { |
|
118 | + private function init_field($option_name, $option_type, $value, $variants, $maxlength=0) { |
|
119 | 119 | |
120 | 120 | global $tpl, $smarty, $parse; |
121 | 121 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | /** |
202 | 202 | * Update configuration |
203 | 203 | */ |
204 | - private function update_config() { |
|
204 | + private function update_config() { |
|
205 | 205 | |
206 | 206 | global $parse, $logger, $post, $img; |
207 | 207 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @param string $option - option name |
307 | 307 | * @param string $value - option value |
308 | 308 | */ |
309 | - private function update_db_config($check, $option, $value) { |
|
309 | + private function update_db_config($check, $option, $value) { |
|
310 | 310 | |
311 | 311 | global $db, $logger; |
312 | 312 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return string |
329 | 329 | */ |
330 | - private function check_string_value($value, $maxleight=0) { |
|
330 | + private function check_string_value($value, $maxleight=0) { |
|
331 | 331 | |
332 | 332 | if($maxleight > 0) { |
333 | 333 | $value = mb_substr($value, 0, $maxleight); |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @return array |
344 | 344 | */ |
345 | - private function get_cfg_vars() { |
|
345 | + private function get_cfg_vars() { |
|
346 | 346 | |
347 | 347 | global $db; |
348 | 348 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | // Anti Hack |
16 | 16 | //--------------------------------------------------------- |
17 | 17 | if(!defined('RooCMS') || !defined('ACP')) { |
18 | - die('Access Denied'); |
|
18 | + die('Access Denied'); |
|
19 | 19 | } |
20 | 20 | //######################################################### |
21 | 21 | |
@@ -31,211 +31,211 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class ACP_Feeds { |
33 | 33 | |
34 | - # extends |
|
35 | - use FeedExtends; |
|
34 | + # extends |
|
35 | + use FeedExtends; |
|
36 | 36 | |
37 | - # objects |
|
38 | - private $engine; # ... object global structure operations |
|
37 | + # objects |
|
38 | + private $engine; # ... object global structure operations |
|
39 | 39 | |
40 | - # vars |
|
41 | - private $feed = []; # structure parametrs |
|
42 | - private $userlist = []; |
|
40 | + # vars |
|
41 | + private $feed = []; # structure parametrs |
|
42 | + private $userlist = []; |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Show must go on ... |
|
48 | - */ |
|
49 | - public function __construct() { |
|
50 | - |
|
51 | - global $tpl; |
|
52 | - |
|
53 | - require_once _CLASS."/class_structure.php"; |
|
54 | - $this->engine = new Structure(); |
|
55 | - |
|
56 | - # initialise |
|
57 | - $this->init(); |
|
58 | - |
|
59 | - # output |
|
60 | - $tpl->load_template("feeds"); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * init action |
|
66 | - */ |
|
67 | - private function init() { |
|
68 | - |
|
69 | - global $roocms, $get, $post, $db; |
|
70 | - |
|
71 | - # set object for works content |
|
72 | - if(isset($get->_page) && array_key_exists($this->engine->page_type, $this->engine->content_types)) { |
|
73 | - |
|
74 | - # get settings |
|
75 | - $this->feed = $this->get_settings(); |
|
76 | - |
|
77 | - # action |
|
78 | - switch($roocms->part) { |
|
79 | - # edit feed option |
|
80 | - case 'settings': |
|
81 | - $this->settings(); |
|
82 | - break; |
|
83 | - |
|
84 | - # update feed option |
|
85 | - case 'update_settings': |
|
86 | - $this->update_settings(); |
|
87 | - break; |
|
46 | + /** |
|
47 | + * Show must go on ... |
|
48 | + */ |
|
49 | + public function __construct() { |
|
50 | + |
|
51 | + global $tpl; |
|
52 | + |
|
53 | + require_once _CLASS."/class_structure.php"; |
|
54 | + $this->engine = new Structure(); |
|
55 | + |
|
56 | + # initialise |
|
57 | + $this->init(); |
|
58 | + |
|
59 | + # output |
|
60 | + $tpl->load_template("feeds"); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * init action |
|
66 | + */ |
|
67 | + private function init() { |
|
68 | + |
|
69 | + global $roocms, $get, $post, $db; |
|
70 | + |
|
71 | + # set object for works content |
|
72 | + if(isset($get->_page) && array_key_exists($this->engine->page_type, $this->engine->content_types)) { |
|
73 | + |
|
74 | + # get settings |
|
75 | + $this->feed = $this->get_settings(); |
|
76 | + |
|
77 | + # action |
|
78 | + switch($roocms->part) { |
|
79 | + # edit feed option |
|
80 | + case 'settings': |
|
81 | + $this->settings(); |
|
82 | + break; |
|
83 | + |
|
84 | + # update feed option |
|
85 | + case 'update_settings': |
|
86 | + $this->update_settings(); |
|
87 | + break; |
|
88 | 88 | |
89 | - # cp feed items |
|
90 | - case 'control': |
|
91 | - $this->control(); |
|
92 | - break; |
|
89 | + # cp feed items |
|
90 | + case 'control': |
|
91 | + $this->control(); |
|
92 | + break; |
|
93 | 93 | |
94 | - # create new item in feed |
|
95 | - case 'create_item': |
|
96 | - $this->create_item(); |
|
97 | - break; |
|
94 | + # create new item in feed |
|
95 | + case 'create_item': |
|
96 | + $this->create_item(); |
|
97 | + break; |
|
98 | 98 | |
99 | 99 | |
100 | - # modify |
|
101 | - case 'edit_item': |
|
102 | - case 'update_item': |
|
103 | - case 'migrate_item': |
|
104 | - case 'status_on_item': |
|
105 | - case 'status_off_item': |
|
106 | - case 'delete_item': |
|
107 | - if($db->check_id($get->_item, PAGES_FEED_TABLE)) { |
|
108 | - switch($roocms->part) { |
|
109 | - # edit item in feed |
|
110 | - case 'edit_item': |
|
111 | - $this->edit_item($get->_item); |
|
112 | - break; |
|
100 | + # modify |
|
101 | + case 'edit_item': |
|
102 | + case 'update_item': |
|
103 | + case 'migrate_item': |
|
104 | + case 'status_on_item': |
|
105 | + case 'status_off_item': |
|
106 | + case 'delete_item': |
|
107 | + if($db->check_id($get->_item, PAGES_FEED_TABLE)) { |
|
108 | + switch($roocms->part) { |
|
109 | + # edit item in feed |
|
110 | + case 'edit_item': |
|
111 | + $this->edit_item($get->_item); |
|
112 | + break; |
|
113 | 113 | |
114 | - # update item in feed |
|
115 | - case 'update_item': |
|
116 | - if(isset($post->update_item)) { |
|
117 | - $this->update_item($get->_item); |
|
118 | - } |
|
119 | - goback(); |
|
120 | - break; |
|
114 | + # update item in feed |
|
115 | + case 'update_item': |
|
116 | + if(isset($post->update_item)) { |
|
117 | + $this->update_item($get->_item); |
|
118 | + } |
|
119 | + goback(); |
|
120 | + break; |
|
121 | 121 | |
122 | - # migrate item in feeds |
|
123 | - case 'migrate_item': |
|
124 | - $this->migrate_item($get->_item); |
|
125 | - break; |
|
122 | + # migrate item in feeds |
|
123 | + case 'migrate_item': |
|
124 | + $this->migrate_item($get->_item); |
|
125 | + break; |
|
126 | 126 | |
127 | - # update status item in feed to on |
|
128 | - case 'status_on_item': |
|
129 | - $this->change_item_status($get->_item, 1); |
|
130 | - break; |
|
127 | + # update status item in feed to on |
|
128 | + case 'status_on_item': |
|
129 | + $this->change_item_status($get->_item, 1); |
|
130 | + break; |
|
131 | 131 | |
132 | - # update status item in feed to off |
|
133 | - case 'status_off_item': |
|
134 | - $this->change_item_status($get->_item, 0); |
|
135 | - break; |
|
132 | + # update status item in feed to off |
|
133 | + case 'status_off_item': |
|
134 | + $this->change_item_status($get->_item, 0); |
|
135 | + break; |
|
136 | 136 | |
137 | - # delete item from feed |
|
138 | - case 'delete_item': |
|
139 | - $this->delete_item($get->_item); |
|
140 | - break; |
|
141 | - } |
|
137 | + # delete item from feed |
|
138 | + case 'delete_item': |
|
139 | + $this->delete_item($get->_item); |
|
140 | + break; |
|
141 | + } |
|
142 | 142 | |
143 | - } |
|
144 | - else { |
|
145 | - goback(); |
|
146 | - } |
|
147 | - break; |
|
148 | - |
|
149 | - default: |
|
150 | - go(CP."?act=structure"); |
|
151 | - break; |
|
152 | - } |
|
153 | - } |
|
154 | - else { |
|
155 | - # go |
|
156 | - go(CP."?act=structure"); |
|
157 | - } |
|
158 | - } |
|
143 | + } |
|
144 | + else { |
|
145 | + goback(); |
|
146 | + } |
|
147 | + break; |
|
148 | + |
|
149 | + default: |
|
150 | + go(CP."?act=structure"); |
|
151 | + break; |
|
152 | + } |
|
153 | + } |
|
154 | + else { |
|
155 | + # go |
|
156 | + go(CP."?act=structure"); |
|
157 | + } |
|
158 | + } |
|
159 | 159 | |
160 | 160 | |
161 | - /** |
|
162 | - * feed view |
|
163 | - */ |
|
164 | - public function control() { |
|
165 | - |
|
166 | - global $db, $parse, $tags, $tpl, $smarty; |
|
167 | - |
|
168 | - # order request |
|
169 | - $order = $this->feed_order($this->feed['items_sorting']); |
|
170 | - |
|
171 | - $smarty->assign("feed", $this->feed); |
|
172 | - |
|
173 | - |
|
174 | - # feed items |
|
175 | - $taglinks = []; |
|
176 | - $feedlist = []; |
|
177 | - $q = $db->query("SELECT id, status, group_access, title, date_publications, date_end_publications, date_update, views FROM ".PAGES_FEED_TABLE." WHERE sid='".$this->feed['id']."' ORDER BY ".$order); |
|
178 | - while($row = $db->fetch_assoc($q)) { |
|
179 | - |
|
180 | - # flag future publications |
|
181 | - $row['publication_future'] = ($row['date_publications'] > time()) ? true : false ; |
|
182 | - |
|
183 | - # flag show/hide |
|
184 | - $row['publication_status'] = "show"; |
|
185 | - |
|
186 | - if($row['date_end_publications'] != 0) { |
|
187 | - |
|
188 | - # hide publications if ending period |
|
189 | - if($row['date_end_publications'] < time()) { |
|
190 | - $row['publication_status'] = "hide"; |
|
191 | - } |
|
161 | + /** |
|
162 | + * feed view |
|
163 | + */ |
|
164 | + public function control() { |
|
165 | + |
|
166 | + global $db, $parse, $tags, $tpl, $smarty; |
|
167 | + |
|
168 | + # order request |
|
169 | + $order = $this->feed_order($this->feed['items_sorting']); |
|
170 | + |
|
171 | + $smarty->assign("feed", $this->feed); |
|
172 | + |
|
173 | + |
|
174 | + # feed items |
|
175 | + $taglinks = []; |
|
176 | + $feedlist = []; |
|
177 | + $q = $db->query("SELECT id, status, group_access, title, date_publications, date_end_publications, date_update, views FROM ".PAGES_FEED_TABLE." WHERE sid='".$this->feed['id']."' ORDER BY ".$order); |
|
178 | + while($row = $db->fetch_assoc($q)) { |
|
179 | + |
|
180 | + # flag future publications |
|
181 | + $row['publication_future'] = ($row['date_publications'] > time()) ? true : false ; |
|
182 | + |
|
183 | + # flag show/hide |
|
184 | + $row['publication_status'] = "show"; |
|
185 | + |
|
186 | + if($row['date_end_publications'] != 0) { |
|
187 | + |
|
188 | + # hide publications if ending period |
|
189 | + if($row['date_end_publications'] < time()) { |
|
190 | + $row['publication_status'] = "hide"; |
|
191 | + } |
|
192 | 192 | |
193 | - # formated date |
|
194 | - $row['date_end_publications'] = $parse->date->unix_to_rus($row['date_end_publications']); |
|
195 | - } |
|
193 | + # formated date |
|
194 | + $row['date_end_publications'] = $parse->date->unix_to_rus($row['date_end_publications']); |
|
195 | + } |
|
196 | 196 | |
197 | - # formated date |
|
198 | - $row['date_publications'] = $parse->date->unix_to_rus($row['date_publications']); |
|
199 | - $row['date_update'] = $parse->date->unix_to_rus($row['date_update'], false, true, true); |
|
200 | - |
|
201 | - $taglinks[$row['id']] = "feeditemid=".$row['id']; |
|
202 | - $feedlist[$row['id']] = $row; |
|
203 | - } |
|
197 | + # formated date |
|
198 | + $row['date_publications'] = $parse->date->unix_to_rus($row['date_publications']); |
|
199 | + $row['date_update'] = $parse->date->unix_to_rus($row['date_update'], false, true, true); |
|
200 | + |
|
201 | + $taglinks[$row['id']] = "feeditemid=".$row['id']; |
|
202 | + $feedlist[$row['id']] = $row; |
|
203 | + } |
|
204 | 204 | |
205 | 205 | |
206 | - # tags collect |
|
207 | - $feedlist = $tags->collect_tags($feedlist, $taglinks); |
|
206 | + # tags collect |
|
207 | + $feedlist = $tags->collect_tags($feedlist, $taglinks); |
|
208 | 208 | |
209 | - # smarty |
|
210 | - $smarty->assign("subfeeds", $this->feed['subfeeds']); |
|
211 | - $smarty->assign("feedlist", $feedlist); |
|
209 | + # smarty |
|
210 | + $smarty->assign("subfeeds", $this->feed['subfeeds']); |
|
211 | + $smarty->assign("feedlist", $feedlist); |
|
212 | 212 | |
213 | - $content = $tpl->load_template("feeds_control", true); |
|
214 | - $smarty->assign("content", $content); |
|
215 | - } |
|
213 | + $content = $tpl->load_template("feeds_control", true); |
|
214 | + $smarty->assign("content", $content); |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * Create new record to feed |
|
220 | - */ |
|
221 | - public function create_item() { |
|
218 | + /** |
|
219 | + * Create new record to feed |
|
220 | + */ |
|
221 | + public function create_item() { |
|
222 | 222 | |
223 | - global $db, $users, $logger, $tags, $files, $img, $post, $tpl, $smarty; |
|
223 | + global $db, $users, $logger, $tags, $files, $img, $post, $tpl, $smarty; |
|
224 | 224 | |
225 | - # insert db |
|
226 | - if(isset($post->create_item)) { |
|
225 | + # insert db |
|
226 | + if(isset($post->create_item)) { |
|
227 | 227 | |
228 | - # Check post data |
|
229 | - $this->check_post_data_fields(); |
|
230 | - $this->control_post_data_date(); |
|
228 | + # Check post data |
|
229 | + $this->check_post_data_fields(); |
|
230 | + $this->control_post_data_date(); |
|
231 | 231 | |
232 | - if(!isset($_SESSION['error'])) { |
|
232 | + if(!isset($_SESSION['error'])) { |
|
233 | 233 | |
234 | - # Check secondary fields |
|
235 | - $this->correct_post_fields(); |
|
234 | + # Check secondary fields |
|
235 | + $this->correct_post_fields(); |
|
236 | 236 | |
237 | - # insert |
|
238 | - $db->query("INSERT INTO ".PAGES_FEED_TABLE." (title, meta_title, meta_description, meta_keywords, |
|
237 | + # insert |
|
238 | + $db->query("INSERT INTO ".PAGES_FEED_TABLE." (title, meta_title, meta_description, meta_keywords, |
|
239 | 239 | brief_item, full_item, author_id, |
240 | 240 | date_create, date_update, date_publications, date_end_publications, |
241 | 241 | group_access, |
@@ -246,159 +246,159 @@ discard block |
||
246 | 246 | '".$post->gids."', |
247 | 247 | '".$post->itemsort."', '".$this->feed['id']."')"); |
248 | 248 | |
249 | - # get feed item id |
|
250 | - $fiid = $db->insert_id(); |
|
249 | + # get feed item id |
|
250 | + $fiid = $db->insert_id(); |
|
251 | 251 | |
252 | - # save tags |
|
253 | - $tags->save_tags($post->tags, "feeditemid=".$fiid); |
|
252 | + # save tags |
|
253 | + $tags->save_tags($post->tags, "feeditemid=".$fiid); |
|
254 | 254 | |
255 | 255 | |
256 | - # attachment images |
|
257 | - $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
|
258 | - if($images) { |
|
259 | - foreach($images AS $image) { |
|
260 | - $img->insert_images($image, "feeditemid=".$fiid, $post->title); |
|
261 | - } |
|
262 | - } |
|
256 | + # attachment images |
|
257 | + $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
|
258 | + if($images) { |
|
259 | + foreach($images AS $image) { |
|
260 | + $img->insert_images($image, "feeditemid=".$fiid, $post->title); |
|
261 | + } |
|
262 | + } |
|
263 | 263 | |
264 | - # attachment files |
|
265 | - $files->upload("files", "feeditemid=".$fiid); |
|
264 | + # attachment files |
|
265 | + $files->upload("files", "feeditemid=".$fiid); |
|
266 | 266 | |
267 | - # recount items |
|
268 | - $this->count_items($this->feed['id']); |
|
267 | + # recount items |
|
268 | + $this->count_items($this->feed['id']); |
|
269 | 269 | |
270 | - # notice |
|
271 | - $logger->info("Запись #".$fiid." <".$post->title."> успешно создана."); |
|
270 | + # notice |
|
271 | + $logger->info("Запись #".$fiid." <".$post->title."> успешно создана."); |
|
272 | 272 | |
273 | - // TODO: Переделать! |
|
274 | - # mailling |
|
275 | - if($post->date_publications <= time() && $post->mailing == 1) { |
|
276 | - $this->mailing($fiid, $post->title, $post->brief_item); |
|
277 | - } |
|
278 | - } |
|
273 | + // TODO: Переделать! |
|
274 | + # mailling |
|
275 | + if($post->date_publications <= time() && $post->mailing == 1) { |
|
276 | + $this->mailing($fiid, $post->title, $post->brief_item); |
|
277 | + } |
|
278 | + } |
|
279 | 279 | |
280 | - # go |
|
281 | - go(CP."?act=feeds&part=control&page=".$this->feed['id']); |
|
282 | - } |
|
280 | + # go |
|
281 | + go(CP."?act=feeds&part=control&page=".$this->feed['id']); |
|
282 | + } |
|
283 | 283 | |
284 | - # userlist |
|
285 | - $this->userlist = $users->get_userlist(); |
|
284 | + # userlist |
|
285 | + $this->userlist = $users->get_userlist(); |
|
286 | 286 | |
287 | - # grouplist |
|
288 | - $groups = $users->get_usergroups(); |
|
287 | + # grouplist |
|
288 | + $groups = $users->get_usergroups(); |
|
289 | 289 | |
290 | - # popular tags |
|
291 | - $poptags = $tags->list_tags(true); |
|
290 | + # popular tags |
|
291 | + $poptags = $tags->list_tags(true); |
|
292 | 292 | |
293 | - # show upload files & images form |
|
294 | - $tpl->load_image_upload_tpl("imagesupload"); |
|
295 | - $tpl->load_files_upload_tpl("filesupload"); |
|
293 | + # show upload files & images form |
|
294 | + $tpl->load_image_upload_tpl("imagesupload"); |
|
295 | + $tpl->load_files_upload_tpl("filesupload"); |
|
296 | 296 | |
297 | - # smarty vars |
|
298 | - $smarty->assign("feed", $this->feed); # feed data |
|
299 | - $smarty->assign("poptags", $poptags); # tags |
|
300 | - $smarty->assign("userlist", $this->userlist); # users |
|
301 | - $smarty->assign("groups", $groups); # groups |
|
297 | + # smarty vars |
|
298 | + $smarty->assign("feed", $this->feed); # feed data |
|
299 | + $smarty->assign("poptags", $poptags); # tags |
|
300 | + $smarty->assign("userlist", $this->userlist); # users |
|
301 | + $smarty->assign("groups", $groups); # groups |
|
302 | 302 | |
303 | - # tpl |
|
304 | - $content = $tpl->load_template("feeds_create_item", true); |
|
305 | - $smarty->assign("content", $content); |
|
306 | - } |
|
303 | + # tpl |
|
304 | + $content = $tpl->load_template("feeds_create_item", true); |
|
305 | + $smarty->assign("content", $content); |
|
306 | + } |
|
307 | 307 | |
308 | 308 | |
309 | - /** |
|
310 | - * Edit record from feed |
|
311 | - * |
|
312 | - * @param int $id - record identificator from feed |
|
313 | - */ |
|
314 | - public function edit_item($id) { |
|
309 | + /** |
|
310 | + * Edit record from feed |
|
311 | + * |
|
312 | + * @param int $id - record identificator from feed |
|
313 | + */ |
|
314 | + public function edit_item($id) { |
|
315 | 315 | |
316 | - global $db, $users, $tags, $files, $img, $tpl, $smarty, $parse; |
|
316 | + global $db, $users, $tags, $files, $img, $tpl, $smarty, $parse; |
|
317 | 317 | |
318 | - # userlist |
|
319 | - $this->userlist = $users->get_userlist(); |
|
318 | + # userlist |
|
319 | + $this->userlist = $users->get_userlist(); |
|
320 | 320 | |
321 | - # grouplist |
|
322 | - $groups = $users->get_usergroups(); |
|
321 | + # grouplist |
|
322 | + $groups = $users->get_usergroups(); |
|
323 | 323 | |
324 | - # get data |
|
325 | - $q = $db->query("SELECT id, sid, status, group_access, sort, title, meta_title, meta_description, meta_keywords, brief_item, full_item, author_id, date_publications, date_end_publications FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
326 | - $item = $db->fetch_assoc($q); |
|
324 | + # get data |
|
325 | + $q = $db->query("SELECT id, sid, status, group_access, sort, title, meta_title, meta_description, meta_keywords, brief_item, full_item, author_id, date_publications, date_end_publications FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
326 | + $item = $db->fetch_assoc($q); |
|
327 | 327 | |
328 | - $item['date_publications'] = $parse->date->unix_to_rusint($item['date_publications']); |
|
328 | + $item['date_publications'] = $parse->date->unix_to_rusint($item['date_publications']); |
|
329 | 329 | |
330 | - if($item['date_end_publications'] != 0) { |
|
331 | - $item['date_end_publications'] = $parse->date->unix_to_rusint($item['date_end_publications']); |
|
332 | - } |
|
330 | + if($item['date_end_publications'] != 0) { |
|
331 | + $item['date_end_publications'] = $parse->date->unix_to_rusint($item['date_end_publications']); |
|
332 | + } |
|
333 | 333 | |
334 | - # check access granted for groups |
|
335 | - $gids = $users->get_gid_access_granted($item['group_access']); |
|
334 | + # check access granted for groups |
|
335 | + $gids = $users->get_gid_access_granted($item['group_access']); |
|
336 | 336 | |
337 | - # item tags |
|
338 | - $item['tags'] = implode(", ", array_map(array("Tags", "get_tag_title"), $tags->read_tags("feeditemid=".$id))); |
|
337 | + # item tags |
|
338 | + $item['tags'] = implode(", ", array_map(array("Tags", "get_tag_title"), $tags->read_tags("feeditemid=".$id))); |
|
339 | 339 | |
340 | - # popular tags |
|
341 | - $poptags = $tags->list_tags(true); |
|
340 | + # popular tags |
|
341 | + $poptags = $tags->list_tags(true); |
|
342 | 342 | |
343 | 343 | |
344 | - # download attached images |
|
345 | - $attachimg = $img->load_images("feeditemid=".$id); |
|
346 | - $smarty->assign("attachimg", $attachimg); |
|
344 | + # download attached images |
|
345 | + $attachimg = $img->load_images("feeditemid=".$id); |
|
346 | + $smarty->assign("attachimg", $attachimg); |
|
347 | 347 | |
348 | - # show attached images |
|
349 | - $attachedimages = $tpl->load_template("attached_images", true); |
|
350 | - $smarty->assign("attachedimages", $attachedimages); |
|
348 | + # show attached images |
|
349 | + $attachedimages = $tpl->load_template("attached_images", true); |
|
350 | + $smarty->assign("attachedimages", $attachedimages); |
|
351 | 351 | |
352 | 352 | |
353 | - # download attached files |
|
354 | - $attachfile = $files->load_files("feeditemid=".$id); |
|
355 | - $smarty->assign("attachfile", $attachfile); |
|
353 | + # download attached files |
|
354 | + $attachfile = $files->load_files("feeditemid=".$id); |
|
355 | + $smarty->assign("attachfile", $attachfile); |
|
356 | 356 | |
357 | - # show attached files |
|
358 | - $attachedfiles = $tpl->load_template("attached_files", true); |
|
359 | - $smarty->assign("attachedfiles", $attachedfiles); |
|
357 | + # show attached files |
|
358 | + $attachedfiles = $tpl->load_template("attached_files", true); |
|
359 | + $smarty->assign("attachedfiles", $attachedfiles); |
|
360 | 360 | |
361 | 361 | |
362 | - # show upload files & images form |
|
363 | - $tpl->load_image_upload_tpl("imagesupload"); |
|
364 | - $tpl->load_files_upload_tpl("filesupload"); |
|
362 | + # show upload files & images form |
|
363 | + $tpl->load_image_upload_tpl("imagesupload"); |
|
364 | + $tpl->load_files_upload_tpl("filesupload"); |
|
365 | 365 | |
366 | 366 | |
367 | - # smarty vars |
|
368 | - $smarty->assign("item", $item); # item data |
|
369 | - $smarty->assign("feed", $this->feed); # feed data |
|
370 | - $smarty->assign("poptags", $poptags); # tags |
|
371 | - $smarty->assign("userlist", $this->userlist); # users list |
|
372 | - $smarty->assign("gids", $gids); # group id access granted |
|
373 | - $smarty->assign("groups", $groups); # group list |
|
367 | + # smarty vars |
|
368 | + $smarty->assign("item", $item); # item data |
|
369 | + $smarty->assign("feed", $this->feed); # feed data |
|
370 | + $smarty->assign("poptags", $poptags); # tags |
|
371 | + $smarty->assign("userlist", $this->userlist); # users list |
|
372 | + $smarty->assign("gids", $gids); # group id access granted |
|
373 | + $smarty->assign("groups", $groups); # group list |
|
374 | 374 | |
375 | - # tpl |
|
376 | - $content = $tpl->load_template("feeds_edit_item", true); |
|
377 | - $smarty->assign("content", $content); |
|
378 | - } |
|
375 | + # tpl |
|
376 | + $content = $tpl->load_template("feeds_edit_item", true); |
|
377 | + $smarty->assign("content", $content); |
|
378 | + } |
|
379 | 379 | |
380 | 380 | |
381 | - /** |
|
382 | - * Update record |
|
383 | - * |
|
384 | - * @param int $id - record identificator from feed |
|
385 | - */ |
|
386 | - public function update_item($id) { |
|
381 | + /** |
|
382 | + * Update record |
|
383 | + * |
|
384 | + * @param int $id - record identificator from feed |
|
385 | + */ |
|
386 | + public function update_item($id) { |
|
387 | 387 | |
388 | - global $db, $logger, $tags, $files, $img, $post, $get; |
|
388 | + global $db, $logger, $tags, $files, $img, $post, $get; |
|
389 | 389 | |
390 | - # Проверяем вводимые поля на ошибки |
|
391 | - $this->check_post_data_fields(); |
|
392 | - $this->control_post_data_date(); |
|
390 | + # Проверяем вводимые поля на ошибки |
|
391 | + $this->check_post_data_fields(); |
|
392 | + $this->control_post_data_date(); |
|
393 | 393 | |
394 | - # update |
|
395 | - if(!isset($_SESSION['error'])) { |
|
394 | + # update |
|
395 | + if(!isset($_SESSION['error'])) { |
|
396 | 396 | |
397 | - # Check secondary fields |
|
398 | - $this->correct_post_fields(); |
|
397 | + # Check secondary fields |
|
398 | + $this->correct_post_fields(); |
|
399 | 399 | |
400 | - # update |
|
401 | - $db->query("UPDATE ".PAGES_FEED_TABLE." |
|
400 | + # update |
|
401 | + $db->query("UPDATE ".PAGES_FEED_TABLE." |
|
402 | 402 | SET |
403 | 403 | status = '".$post->status."', |
404 | 404 | group_access = '".$post->gids."', |
@@ -416,269 +416,269 @@ discard block |
||
416 | 416 | WHERE |
417 | 417 | id = '".$id."'"); |
418 | 418 | |
419 | - # save tags |
|
420 | - $tags->save_tags($post->tags, "feeditemid=".$id); |
|
419 | + # save tags |
|
420 | + $tags->save_tags($post->tags, "feeditemid=".$id); |
|
421 | 421 | |
422 | - # notice |
|
423 | - $logger->info("Запись #".$id." <".$post->title."> успешно отредактирована."); |
|
422 | + # notice |
|
423 | + $logger->info("Запись #".$id." <".$post->title."> успешно отредактирована."); |
|
424 | 424 | |
425 | - # update images |
|
426 | - $img->update_images_info("feeditemid", $id); |
|
425 | + # update images |
|
426 | + $img->update_images_info("feeditemid", $id); |
|
427 | 427 | |
428 | - # attachment images |
|
429 | - $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
|
430 | - if($images) { |
|
431 | - foreach($images AS $image) { |
|
432 | - $img->insert_images($image, "feeditemid=".$id, $post->title); |
|
433 | - } |
|
434 | - } |
|
428 | + # attachment images |
|
429 | + $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
|
430 | + if($images) { |
|
431 | + foreach($images AS $image) { |
|
432 | + $img->insert_images($image, "feeditemid=".$id, $post->title); |
|
433 | + } |
|
434 | + } |
|
435 | 435 | |
436 | - # attachment files |
|
437 | - $files->upload("files", "feeditemid=".$id); |
|
436 | + # attachment files |
|
437 | + $files->upload("files", "feeditemid=".$id); |
|
438 | 438 | |
439 | - # go |
|
440 | - go(CP."?act=feeds&part=control&page=".$get->_page); |
|
441 | - } |
|
439 | + # go |
|
440 | + go(CP."?act=feeds&part=control&page=".$get->_page); |
|
441 | + } |
|
442 | 442 | |
443 | - # back |
|
444 | - goback(); |
|
445 | - } |
|
443 | + # back |
|
444 | + goback(); |
|
445 | + } |
|
446 | 446 | |
447 | 447 | |
448 | - /** |
|
449 | - * Migrate record to another feed |
|
450 | - * |
|
451 | - * @param int $id - record identificator from feed |
|
452 | - */ |
|
453 | - public function migrate_item($id) { |
|
448 | + /** |
|
449 | + * Migrate record to another feed |
|
450 | + * |
|
451 | + * @param int $id - record identificator from feed |
|
452 | + */ |
|
453 | + public function migrate_item($id) { |
|
454 | 454 | |
455 | - global $db, $logger, $tpl, $smarty, $post; |
|
455 | + global $db, $logger, $tpl, $smarty, $post; |
|
456 | 456 | |
457 | - # Migrate |
|
458 | - if(isset($post->from) && isset($post->to) && $db->check_id($post->from, STRUCTURE_TABLE, "id", "page_type='feed'") && $db->check_id($post->to, STRUCTURE_TABLE, "id", "page_type='feed'")) { |
|
457 | + # Migrate |
|
458 | + if(isset($post->from) && isset($post->to) && $db->check_id($post->from, STRUCTURE_TABLE, "id", "page_type='feed'") && $db->check_id($post->to, STRUCTURE_TABLE, "id", "page_type='feed'")) { |
|
459 | 459 | |
460 | - $db->query("UPDATE ".PAGES_FEED_TABLE." |
|
460 | + $db->query("UPDATE ".PAGES_FEED_TABLE." |
|
461 | 461 | SET sid = '".$post->to."', |
462 | 462 | date_update = '".time()."' |
463 | 463 | WHERE id = '".$id."'"); |
464 | 464 | |
465 | - # recount items |
|
466 | - $this->count_items($post->from); |
|
467 | - $this->count_items($post->to); |
|
465 | + # recount items |
|
466 | + $this->count_items($post->from); |
|
467 | + $this->count_items($post->to); |
|
468 | 468 | |
469 | 469 | |
470 | - # notice |
|
471 | - $logger->info("Элемент #".$id." успешно перемещен."); |
|
470 | + # notice |
|
471 | + $logger->info("Элемент #".$id." успешно перемещен."); |
|
472 | 472 | |
473 | - #go |
|
474 | - go(CP."?act=feeds&part=control&page=".$post->to); |
|
475 | - } |
|
473 | + #go |
|
474 | + go(CP."?act=feeds&part=control&page=".$post->to); |
|
475 | + } |
|
476 | 476 | |
477 | 477 | |
478 | - # get data item from db |
|
479 | - $q = $db->query("SELECT id, sid, title FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
480 | - $data = $db->fetch_assoc($q); |
|
478 | + # get data item from db |
|
479 | + $q = $db->query("SELECT id, sid, title FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
480 | + $data = $db->fetch_assoc($q); |
|
481 | 481 | |
482 | - # smarty vars |
|
483 | - $smarty->assign("item", $data); |
|
482 | + # smarty vars |
|
483 | + $smarty->assign("item", $data); |
|
484 | 484 | |
485 | 485 | |
486 | - # get data feeds from db |
|
487 | - $feeds = []; |
|
488 | - $q = $db->query("SELECT id, title, alias FROM ".STRUCTURE_TABLE." WHERE page_type='feed' ORDER BY id ASC"); |
|
489 | - while($row = $db->fetch_assoc($q)) { |
|
490 | - $feeds[$row['id']] = $row; |
|
491 | - } |
|
486 | + # get data feeds from db |
|
487 | + $feeds = []; |
|
488 | + $q = $db->query("SELECT id, title, alias FROM ".STRUCTURE_TABLE." WHERE page_type='feed' ORDER BY id ASC"); |
|
489 | + while($row = $db->fetch_assoc($q)) { |
|
490 | + $feeds[$row['id']] = $row; |
|
491 | + } |
|
492 | 492 | |
493 | - # smarty vars |
|
494 | - $smarty->assign("feeds", $feeds); |
|
493 | + # smarty vars |
|
494 | + $smarty->assign("feeds", $feeds); |
|
495 | 495 | |
496 | - # tpl |
|
497 | - $content = $tpl->load_template("feeds_migrate_item", true); |
|
498 | - $smarty->assign("content", $content); |
|
499 | - } |
|
496 | + # tpl |
|
497 | + $content = $tpl->load_template("feeds_migrate_item", true); |
|
498 | + $smarty->assign("content", $content); |
|
499 | + } |
|
500 | 500 | |
501 | 501 | |
502 | - /** |
|
503 | - * Change status to record feed |
|
504 | - * |
|
505 | - * @param int $id - record id |
|
506 | - * @param int $status - 1=show , 0=hide |
|
507 | - */ |
|
508 | - public function change_item_status($id, $status = 1) { |
|
502 | + /** |
|
503 | + * Change status to record feed |
|
504 | + * |
|
505 | + * @param int $id - record id |
|
506 | + * @param int $status - 1=show , 0=hide |
|
507 | + */ |
|
508 | + public function change_item_status($id, $status = 1) { |
|
509 | 509 | |
510 | - global $db, $logger; |
|
510 | + global $db, $logger; |
|
511 | 511 | |
512 | - $status = (int) filter_var($status, FILTER_VALIDATE_BOOLEAN); |
|
512 | + $status = (int) filter_var($status, FILTER_VALIDATE_BOOLEAN); |
|
513 | 513 | |
514 | - # update data in db |
|
515 | - $db->query("UPDATE ".PAGES_FEED_TABLE." SET status='".$status."' WHERE id='".$id."'"); |
|
514 | + # update data in db |
|
515 | + $db->query("UPDATE ".PAGES_FEED_TABLE." SET status='".$status."' WHERE id='".$id."'"); |
|
516 | 516 | |
517 | - # notice |
|
518 | - $mstatus = ($status) ? "Видимый" : "Скрытый" ; |
|
519 | - $logger->info("Запись #".$id." успешно изменила свой статус на <".$mstatus.">."); |
|
517 | + # notice |
|
518 | + $mstatus = ($status) ? "Видимый" : "Скрытый" ; |
|
519 | + $logger->info("Запись #".$id." успешно изменила свой статус на <".$mstatus.">."); |
|
520 | 520 | |
521 | - # go |
|
522 | - goback(); |
|
523 | - } |
|
521 | + # go |
|
522 | + goback(); |
|
523 | + } |
|
524 | 524 | |
525 | 525 | |
526 | - /** |
|
527 | - * Remove record from feed |
|
528 | - * |
|
529 | - * @param int $id - record id |
|
530 | - */ |
|
531 | - public function delete_item($id) { |
|
526 | + /** |
|
527 | + * Remove record from feed |
|
528 | + * |
|
529 | + * @param int $id - record id |
|
530 | + */ |
|
531 | + public function delete_item($id) { |
|
532 | 532 | |
533 | - global $db, $logger, $img, $files, $tags; |
|
533 | + global $db, $logger, $img, $files, $tags; |
|
534 | 534 | |
535 | - # get sid |
|
536 | - $q = $db->query("SELECT sid FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
537 | - $row = $db->fetch_assoc($q); |
|
535 | + # get sid |
|
536 | + $q = $db->query("SELECT sid FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
537 | + $row = $db->fetch_assoc($q); |
|
538 | 538 | |
539 | - # del attached images |
|
540 | - $img->remove_images("feeditemid=".$id); |
|
539 | + # del attached images |
|
540 | + $img->remove_images("feeditemid=".$id); |
|
541 | 541 | |
542 | - # del attached files |
|
543 | - $files->remove_files("feeditemid=".$id); |
|
542 | + # del attached files |
|
543 | + $files->remove_files("feeditemid=".$id); |
|
544 | 544 | |
545 | - # del tags |
|
546 | - $tags->save_tags("", "feeditemid=".$id); |
|
545 | + # del tags |
|
546 | + $tags->save_tags("", "feeditemid=".$id); |
|
547 | 547 | |
548 | - # delete item |
|
549 | - $db->query("DELETE FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
548 | + # delete item |
|
549 | + $db->query("DELETE FROM ".PAGES_FEED_TABLE." WHERE id='".$id."'"); |
|
550 | 550 | |
551 | - # recount items |
|
552 | - $this->count_items($row['sid']); |
|
551 | + # recount items |
|
552 | + $this->count_items($row['sid']); |
|
553 | 553 | |
554 | - # notice |
|
555 | - $logger->info("Элемент #".$id." успешно удален."); |
|
554 | + # notice |
|
555 | + $logger->info("Элемент #".$id." успешно удален."); |
|
556 | 556 | |
557 | - # go |
|
558 | - goback(); |
|
559 | - } |
|
557 | + # go |
|
558 | + goback(); |
|
559 | + } |
|
560 | 560 | |
561 | 561 | |
562 | - /** |
|
563 | - * Remove feed |
|
564 | - * |
|
565 | - * @param int $sid - structure element id |
|
566 | - */ |
|
567 | - public function delete_feed($sid) { |
|
562 | + /** |
|
563 | + * Remove feed |
|
564 | + * |
|
565 | + * @param int $sid - structure element id |
|
566 | + */ |
|
567 | + public function delete_feed($sid) { |
|
568 | 568 | |
569 | - global $db, $img, $files, $tags; |
|
569 | + global $db, $img, $files, $tags; |
|
570 | 570 | |
571 | - $cond = ""; |
|
572 | - $f = $db->query("SELECT id FROM ".PAGES_FEED_TABLE." WHERE sid='".$sid."'"); |
|
573 | - while($fid = $db->fetch_assoc($f)) { |
|
574 | - # del tags |
|
575 | - $tags->save_tags("", "feeditemid=".$fid['id']); |
|
576 | - # cond |
|
577 | - $cond = $db->qcond_or($cond); |
|
578 | - $cond .= " attachedto='feeditemid=".$fid['id']."' " ; |
|
579 | - } |
|
571 | + $cond = ""; |
|
572 | + $f = $db->query("SELECT id FROM ".PAGES_FEED_TABLE." WHERE sid='".$sid."'"); |
|
573 | + while($fid = $db->fetch_assoc($f)) { |
|
574 | + # del tags |
|
575 | + $tags->save_tags("", "feeditemid=".$fid['id']); |
|
576 | + # cond |
|
577 | + $cond = $db->qcond_or($cond); |
|
578 | + $cond .= " attachedto='feeditemid=".$fid['id']."' " ; |
|
579 | + } |
|
580 | 580 | |
581 | - # del attached images |
|
582 | - if(trim($cond) != "") { |
|
583 | - $img->remove_images($cond, true); |
|
584 | - $files->remove_files($cond, true); |
|
585 | - } |
|
586 | - |
|
587 | - $db->query("DELETE FROM ".PAGES_FEED_TABLE." WHERE sid='".$sid."'"); |
|
588 | - } |
|
581 | + # del attached images |
|
582 | + if(trim($cond) != "") { |
|
583 | + $img->remove_images($cond, true); |
|
584 | + $files->remove_files($cond, true); |
|
585 | + } |
|
586 | + |
|
587 | + $db->query("DELETE FROM ".PAGES_FEED_TABLE." WHERE sid='".$sid."'"); |
|
588 | + } |
|
589 | 589 | |
590 | 590 | |
591 | - /** |
|
592 | - * Settings feed |
|
593 | - */ |
|
594 | - public function settings() { |
|
591 | + /** |
|
592 | + * Settings feed |
|
593 | + */ |
|
594 | + public function settings() { |
|
595 | 595 | |
596 | - global $config, $tpl, $smarty; |
|
596 | + global $config, $tpl, $smarty; |
|
597 | 597 | |
598 | - # Уведомление о глобальном отключении RSS лент |
|
599 | - $this->feed['rss_warn'] = (!$config->rss_power) ? true : false ; |
|
598 | + # Уведомление о глобальном отключении RSS лент |
|
599 | + $this->feed['rss_warn'] = (!$config->rss_power) ? true : false ; |
|
600 | 600 | |
601 | - # глобальное значение количества элементов на страницу |
|
602 | - $this->feed['global_items_per_page'] =& $config->feed_items_per_page; |
|
601 | + # глобальное значение количества элементов на страницу |
|
602 | + $this->feed['global_items_per_page'] =& $config->feed_items_per_page; |
|
603 | 603 | |
604 | - # default thumb size |
|
605 | - $default_thumb_size = array('width' => $config->gd_thumb_image_width, |
|
606 | - 'height' => $config->gd_thumb_image_height); |
|
604 | + # default thumb size |
|
605 | + $default_thumb_size = array('width' => $config->gd_thumb_image_width, |
|
606 | + 'height' => $config->gd_thumb_image_height); |
|
607 | 607 | |
608 | - # smarty vars |
|
609 | - $smarty->assign("feed",$this->feed); |
|
610 | - $smarty->assign("default_thumb_size", $default_thumb_size); |
|
608 | + # smarty vars |
|
609 | + $smarty->assign("feed",$this->feed); |
|
610 | + $smarty->assign("default_thumb_size", $default_thumb_size); |
|
611 | 611 | |
612 | - # tpl |
|
613 | - $content = $tpl->load_template("feeds_settings_feed", true); |
|
614 | - $smarty->assign("content", $content); |
|
615 | - } |
|
612 | + # tpl |
|
613 | + $content = $tpl->load_template("feeds_settings_feed", true); |
|
614 | + $smarty->assign("content", $content); |
|
615 | + } |
|
616 | 616 | |
617 | 617 | |
618 | - /** |
|
619 | - * Settings update to feed |
|
620 | - */ |
|
621 | - public function update_settings() { |
|
622 | - |
|
623 | - global $db, $img, $post, $logger; |
|
624 | - |
|
625 | - if(isset($post->update_settings)) { |
|
626 | - # update buffer |
|
627 | - $update = ""; |
|
628 | - |
|
629 | - # RSS flag |
|
630 | - $rss = 0; |
|
631 | - if($post->rss == "1") { |
|
632 | - $rss = 1; |
|
633 | - } |
|
634 | - $update .= " rss='".$rss."', "; |
|
635 | - |
|
636 | - # items per page |
|
637 | - $items_per_page = 0; |
|
638 | - if(round($post->items_per_page) >= 0) { |
|
639 | - $items_per_page = round($post->items_per_page); |
|
640 | - } |
|
641 | - $update .= " items_per_page='".$items_per_page."', " ; |
|
642 | - |
|
643 | - # thumbnail check |
|
644 | - $img->check_post_thumb_parametrs(); |
|
645 | - |
|
646 | - # items sorting in feed |
|
647 | - $items_sorting = "datepublication"; |
|
648 | - if(isset($post->items_sorting)) { |
|
649 | - switch($post->items_sorting) { |
|
650 | - case 'title_asc': |
|
651 | - $items_sorting = "title_asc"; |
|
652 | - break; |
|
653 | - |
|
654 | - case 'title_desc': |
|
655 | - $items_sorting = "title_desc"; |
|
656 | - break; |
|
657 | - |
|
658 | - case 'manual_sorting': |
|
659 | - $items_sorting = "manual_sorting"; |
|
660 | - break; |
|
661 | - } |
|
662 | - } |
|
663 | - $update .= " items_sorting = '".$items_sorting."', "; |
|
664 | - |
|
665 | - # show_child_feeds |
|
666 | - $show_child_feeds = "none"; |
|
667 | - if(isset($post->show_child_feeds)) { |
|
668 | - switch($post->show_child_feeds) { |
|
669 | - case 'default': |
|
670 | - $show_child_feeds = "default"; |
|
671 | - break; |
|
672 | - |
|
673 | - case 'forced': |
|
674 | - $show_child_feeds = "forced"; |
|
675 | - break; |
|
676 | - } |
|
677 | - } |
|
678 | - |
|
679 | - |
|
680 | - # up data to db |
|
681 | - $db->query("UPDATE ".STRUCTURE_TABLE." |
|
618 | + /** |
|
619 | + * Settings update to feed |
|
620 | + */ |
|
621 | + public function update_settings() { |
|
622 | + |
|
623 | + global $db, $img, $post, $logger; |
|
624 | + |
|
625 | + if(isset($post->update_settings)) { |
|
626 | + # update buffer |
|
627 | + $update = ""; |
|
628 | + |
|
629 | + # RSS flag |
|
630 | + $rss = 0; |
|
631 | + if($post->rss == "1") { |
|
632 | + $rss = 1; |
|
633 | + } |
|
634 | + $update .= " rss='".$rss."', "; |
|
635 | + |
|
636 | + # items per page |
|
637 | + $items_per_page = 0; |
|
638 | + if(round($post->items_per_page) >= 0) { |
|
639 | + $items_per_page = round($post->items_per_page); |
|
640 | + } |
|
641 | + $update .= " items_per_page='".$items_per_page."', " ; |
|
642 | + |
|
643 | + # thumbnail check |
|
644 | + $img->check_post_thumb_parametrs(); |
|
645 | + |
|
646 | + # items sorting in feed |
|
647 | + $items_sorting = "datepublication"; |
|
648 | + if(isset($post->items_sorting)) { |
|
649 | + switch($post->items_sorting) { |
|
650 | + case 'title_asc': |
|
651 | + $items_sorting = "title_asc"; |
|
652 | + break; |
|
653 | + |
|
654 | + case 'title_desc': |
|
655 | + $items_sorting = "title_desc"; |
|
656 | + break; |
|
657 | + |
|
658 | + case 'manual_sorting': |
|
659 | + $items_sorting = "manual_sorting"; |
|
660 | + break; |
|
661 | + } |
|
662 | + } |
|
663 | + $update .= " items_sorting = '".$items_sorting."', "; |
|
664 | + |
|
665 | + # show_child_feeds |
|
666 | + $show_child_feeds = "none"; |
|
667 | + if(isset($post->show_child_feeds)) { |
|
668 | + switch($post->show_child_feeds) { |
|
669 | + case 'default': |
|
670 | + $show_child_feeds = "default"; |
|
671 | + break; |
|
672 | + |
|
673 | + case 'forced': |
|
674 | + $show_child_feeds = "forced"; |
|
675 | + break; |
|
676 | + } |
|
677 | + } |
|
678 | + |
|
679 | + |
|
680 | + # up data to db |
|
681 | + $db->query("UPDATE ".STRUCTURE_TABLE." |
|
682 | 682 | SET |
683 | 683 | ".$update." |
684 | 684 | show_child_feeds='".$show_child_feeds."', |
@@ -690,176 +690,176 @@ discard block |
||
690 | 690 | WHERE |
691 | 691 | id='".$this->feed['id']."'"); |
692 | 692 | |
693 | - $logger->info("Настройки ленты #".$this->feed['id']." успешно обновлены."); |
|
694 | - } |
|
693 | + $logger->info("Настройки ленты #".$this->feed['id']." успешно обновлены."); |
|
694 | + } |
|
695 | 695 | |
696 | - # go |
|
697 | - goback(); |
|
698 | - } |
|
696 | + # go |
|
697 | + goback(); |
|
698 | + } |
|
699 | 699 | |
700 | 700 | |
701 | - /** |
|
702 | - * Recount records in feed |
|
703 | - * |
|
704 | - * @param int $sid - feed id |
|
705 | - */ |
|
706 | - public function count_items($sid) { |
|
701 | + /** |
|
702 | + * Recount records in feed |
|
703 | + * |
|
704 | + * @param int $sid - feed id |
|
705 | + */ |
|
706 | + public function count_items($sid) { |
|
707 | 707 | |
708 | - global $db; |
|
708 | + global $db; |
|
709 | 709 | |
710 | - # count |
|
711 | - $items = $db->count(PAGES_FEED_TABLE, "sid='".$sid."'"); |
|
710 | + # count |
|
711 | + $items = $db->count(PAGES_FEED_TABLE, "sid='".$sid."'"); |
|
712 | 712 | |
713 | - # save |
|
714 | - $db->query("UPDATE ".STRUCTURE_TABLE." SET items='".$items."' WHERE id='".$sid."'"); |
|
715 | - } |
|
713 | + # save |
|
714 | + $db->query("UPDATE ".STRUCTURE_TABLE." SET items='".$items."' WHERE id='".$sid."'"); |
|
715 | + } |
|
716 | 716 | |
717 | 717 | |
718 | - /** |
|
719 | - * Check data post |
|
720 | - */ |
|
721 | - private function check_post_data_fields() { |
|
718 | + /** |
|
719 | + * Check data post |
|
720 | + */ |
|
721 | + private function check_post_data_fields() { |
|
722 | 722 | |
723 | - global $post, $logger; |
|
723 | + global $post, $logger; |
|
724 | 724 | |
725 | - # title |
|
726 | - if(!isset($post->title)) { |
|
727 | - $logger->error("Не заполнен заголовок элемента", false); |
|
728 | - } |
|
725 | + # title |
|
726 | + if(!isset($post->title)) { |
|
727 | + $logger->error("Не заполнен заголовок элемента", false); |
|
728 | + } |
|
729 | 729 | |
730 | - # full desc item |
|
731 | - if(!isset($post->full_item)) { |
|
732 | - $logger->error("Не заполнен подробный текст элемента", false); |
|
733 | - } |
|
730 | + # full desc item |
|
731 | + if(!isset($post->full_item)) { |
|
732 | + $logger->error("Не заполнен подробный текст элемента", false); |
|
733 | + } |
|
734 | 734 | |
735 | - # status |
|
736 | - $post->status = (int) filter_var($post->status, FILTER_VALIDATE_BOOLEAN); |
|
737 | - } |
|
735 | + # status |
|
736 | + $post->status = (int) filter_var($post->status, FILTER_VALIDATE_BOOLEAN); |
|
737 | + } |
|
738 | 738 | |
739 | 739 | |
740 | - /** |
|
741 | - * Check dates from data post |
|
742 | - */ |
|
743 | - private function control_post_data_date() { |
|
740 | + /** |
|
741 | + * Check dates from data post |
|
742 | + */ |
|
743 | + private function control_post_data_date() { |
|
744 | 744 | |
745 | - global $post, $parse; |
|
745 | + global $post, $parse; |
|
746 | 746 | |
747 | - # check isset date publication |
|
748 | - if(!isset($post->date_publications)) { |
|
749 | - $post->date_publications = date("d.m.Y",time()); |
|
750 | - } |
|
747 | + # check isset date publication |
|
748 | + if(!isset($post->date_publications)) { |
|
749 | + $post->date_publications = date("d.m.Y",time()); |
|
750 | + } |
|
751 | 751 | |
752 | - # check isset date end publication |
|
753 | - if(!isset($post->date_end_publications)) { |
|
754 | - $post->date_end_publications = 0; |
|
755 | - } |
|
752 | + # check isset date end publication |
|
753 | + if(!isset($post->date_end_publications)) { |
|
754 | + $post->date_end_publications = 0; |
|
755 | + } |
|
756 | 756 | |
757 | - # date publications |
|
758 | - $post->date_publications = $parse->date->rusint_to_unix($post->date_publications); |
|
757 | + # date publications |
|
758 | + $post->date_publications = $parse->date->rusint_to_unix($post->date_publications); |
|
759 | 759 | |
760 | - # date end publications |
|
761 | - if($post->date_end_publications != 0) { |
|
762 | - $post->date_end_publications = $parse->date->rusint_to_unix($post->date_end_publications); |
|
763 | - } |
|
760 | + # date end publications |
|
761 | + if($post->date_end_publications != 0) { |
|
762 | + $post->date_end_publications = $parse->date->rusint_to_unix($post->date_end_publications); |
|
763 | + } |
|
764 | 764 | |
765 | - if($post->date_end_publications <= $post->date_publications) { |
|
766 | - $post->date_end_publications = 0; |
|
767 | - } |
|
768 | - } |
|
765 | + if($post->date_end_publications <= $post->date_publications) { |
|
766 | + $post->date_end_publications = 0; |
|
767 | + } |
|
768 | + } |
|
769 | 769 | |
770 | 770 | |
771 | - /** |
|
772 | - * Check and correct secondary fields |
|
773 | - */ |
|
774 | - private function correct_post_fields() { |
|
771 | + /** |
|
772 | + * Check and correct secondary fields |
|
773 | + */ |
|
774 | + private function correct_post_fields() { |
|
775 | 775 | |
776 | - global $users, $post; |
|
776 | + global $users, $post; |
|
777 | 777 | |
778 | - # tags |
|
779 | - if(!isset($post->tags)) { |
|
780 | - $post->tags = NULL; |
|
781 | - } |
|
778 | + # tags |
|
779 | + if(!isset($post->tags)) { |
|
780 | + $post->tags = NULL; |
|
781 | + } |
|
782 | 782 | |
783 | - # sort |
|
784 | - if(!isset($post->itemsort) || round($post->itemsort) < 0) { |
|
785 | - $post->itemsort = 0; |
|
786 | - } |
|
787 | - else { |
|
788 | - $post->itemsort = round($post->itemsort); |
|
789 | - } |
|
783 | + # sort |
|
784 | + if(!isset($post->itemsort) || round($post->itemsort) < 0) { |
|
785 | + $post->itemsort = 0; |
|
786 | + } |
|
787 | + else { |
|
788 | + $post->itemsort = round($post->itemsort); |
|
789 | + } |
|
790 | 790 | |
791 | - # group ids with access |
|
792 | - if(isset($post->gids) && is_array($post->gids)) { |
|
793 | - $post->gids = implode(",", $post->gids); |
|
794 | - } |
|
795 | - else { |
|
796 | - $post->gids = 0; |
|
797 | - } |
|
791 | + # group ids with access |
|
792 | + if(isset($post->gids) && is_array($post->gids)) { |
|
793 | + $post->gids = implode(",", $post->gids); |
|
794 | + } |
|
795 | + else { |
|
796 | + $post->gids = 0; |
|
797 | + } |
|
798 | 798 | |
799 | - # userlist |
|
800 | - $this->userlist = $users->get_userlist(); |
|
801 | - |
|
802 | - # author |
|
803 | - if(!isset($post->author_id) || !array_key_exists($post->author_id, $this->userlist)) { |
|
804 | - $post->author_id = 0; |
|
805 | - } |
|
806 | - } |
|
799 | + # userlist |
|
800 | + $this->userlist = $users->get_userlist(); |
|
801 | + |
|
802 | + # author |
|
803 | + if(!isset($post->author_id) || !array_key_exists($post->author_id, $this->userlist)) { |
|
804 | + $post->author_id = 0; |
|
805 | + } |
|
806 | + } |
|
807 | 807 | |
808 | 808 | |
809 | - /** |
|
810 | - * Это временная функция |
|
811 | - * |
|
812 | - * @param int $id |
|
813 | - * @param string $title |
|
814 | - * @param string $subject |
|
815 | - */ |
|
816 | - private function mailing($id, $title, $subject) { |
|
817 | - |
|
818 | - global $parse, $mailer, $logger, $users, $mailer, $site; |
|
819 | - |
|
820 | - # get userlist |
|
821 | - $userlist = $users->get_userlist(1, 0, 1); |
|
822 | - |
|
823 | - # html |
|
824 | - $subject = $parse->text->html($subject); |
|
825 | - $subject = "<h1>".$title."</h1> |
|
809 | + /** |
|
810 | + * Это временная функция |
|
811 | + * |
|
812 | + * @param int $id |
|
813 | + * @param string $title |
|
814 | + * @param string $subject |
|
815 | + */ |
|
816 | + private function mailing($id, $title, $subject) { |
|
817 | + |
|
818 | + global $parse, $mailer, $logger, $users, $mailer, $site; |
|
819 | + |
|
820 | + # get userlist |
|
821 | + $userlist = $users->get_userlist(1, 0, 1); |
|
822 | + |
|
823 | + # html |
|
824 | + $subject = $parse->text->html($subject); |
|
825 | + $subject = "<h1>".$title."</h1> |
|
826 | 826 | ".$subject." |
827 | 827 | <br /><br /><a href=\"http://".$site['domain']."/index.php?page=".$this->feed['alias']."&id=".$id."\">Читать полностью</a>"; |
828 | 828 | |
829 | - # send to email |
|
830 | - if(count($userlist) != 0) { |
|
831 | - $mailer->spread($userlist, $title, $subject); |
|
832 | - } |
|
833 | - else { |
|
834 | - $logger->error("Сообщение не отправлено! Не обнаружены подписчики подходящие под заданные критерии.", false); |
|
835 | - } |
|
836 | - } |
|
837 | - |
|
838 | - |
|
839 | - /** |
|
840 | - * get array with feed settings |
|
841 | - * |
|
842 | - * @return array<integer|string|boolean|array> |
|
843 | - */ |
|
844 | - private function get_settings() { |
|
845 | - |
|
846 | - $setting = array( |
|
847 | - 'id' => $this->engine->page_id, |
|
848 | - 'alias' => $this->engine->page_alias, |
|
849 | - 'title' => $this->engine->page_title, |
|
850 | - 'rss' => $this->engine->page_rss, |
|
851 | - 'show_child_feeds' => $this->engine->page_show_child_feeds, |
|
852 | - 'items_per_page' => $this->engine->page_items_per_page, |
|
853 | - 'items_sorting' => $this->engine->page_items_sorting, |
|
854 | - 'thumb_img_width' => $this->engine->page_thumb_img_width, |
|
855 | - 'thumb_img_height' => $this->engine->page_thumb_img_height, |
|
856 | - 'append_info_before' => $this->engine->page_append_info_before, |
|
857 | - 'append_info_after' => $this->engine->page_append_info_after, |
|
858 | - 'subfeeds' => $this->engine->load_tree($this->engine->page_id) |
|
859 | - ); |
|
860 | - |
|
861 | - return $setting; |
|
862 | - } |
|
829 | + # send to email |
|
830 | + if(count($userlist) != 0) { |
|
831 | + $mailer->spread($userlist, $title, $subject); |
|
832 | + } |
|
833 | + else { |
|
834 | + $logger->error("Сообщение не отправлено! Не обнаружены подписчики подходящие под заданные критерии.", false); |
|
835 | + } |
|
836 | + } |
|
837 | + |
|
838 | + |
|
839 | + /** |
|
840 | + * get array with feed settings |
|
841 | + * |
|
842 | + * @return array<integer|string|boolean|array> |
|
843 | + */ |
|
844 | + private function get_settings() { |
|
845 | + |
|
846 | + $setting = array( |
|
847 | + 'id' => $this->engine->page_id, |
|
848 | + 'alias' => $this->engine->page_alias, |
|
849 | + 'title' => $this->engine->page_title, |
|
850 | + 'rss' => $this->engine->page_rss, |
|
851 | + 'show_child_feeds' => $this->engine->page_show_child_feeds, |
|
852 | + 'items_per_page' => $this->engine->page_items_per_page, |
|
853 | + 'items_sorting' => $this->engine->page_items_sorting, |
|
854 | + 'thumb_img_width' => $this->engine->page_thumb_img_width, |
|
855 | + 'thumb_img_height' => $this->engine->page_thumb_img_height, |
|
856 | + 'append_info_before' => $this->engine->page_append_info_before, |
|
857 | + 'append_info_after' => $this->engine->page_append_info_after, |
|
858 | + 'subfeeds' => $this->engine->load_tree($this->engine->page_id) |
|
859 | + ); |
|
860 | + |
|
861 | + return $setting; |
|
862 | + } |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | /** |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | use FeedExtends; |
36 | 36 | |
37 | 37 | # objects |
38 | - private $engine; # ... object global structure operations |
|
38 | + private $engine; # ... object global structure operations |
|
39 | 39 | |
40 | 40 | # vars |
41 | - private $feed = []; # structure parametrs |
|
41 | + private $feed = []; # structure parametrs |
|
42 | 42 | private $userlist = []; |
43 | 43 | |
44 | 44 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->feed = $this->get_settings(); |
76 | 76 | |
77 | 77 | # action |
78 | - switch($roocms->part) { |
|
78 | + switch ($roocms->part) { |
|
79 | 79 | # edit feed option |
80 | 80 | case 'settings': |
81 | 81 | $this->settings(); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | case 'status_off_item': |
106 | 106 | case 'delete_item': |
107 | 107 | if($db->check_id($get->_item, PAGES_FEED_TABLE)) { |
108 | - switch($roocms->part) { |
|
108 | + switch ($roocms->part) { |
|
109 | 109 | # edit item in feed |
110 | 110 | case 'edit_item': |
111 | 111 | $this->edit_item($get->_item); |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | while($row = $db->fetch_assoc($q)) { |
179 | 179 | |
180 | 180 | # flag future publications |
181 | - $row['publication_future'] = ($row['date_publications'] > time()) ? true : false ; |
|
181 | + $row['publication_future'] = ($row['date_publications'] > time()) ? true : false; |
|
182 | 182 | |
183 | 183 | # flag show/hide |
184 | 184 | $row['publication_status'] = "show"; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $smarty->assign("feedlist", $feedlist); |
212 | 212 | |
213 | 213 | $content = $tpl->load_template("feeds_control", true); |
214 | - $smarty->assign("content", $content); |
|
214 | + $smarty->assign("content", $content); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
@@ -295,14 +295,14 @@ discard block |
||
295 | 295 | $tpl->load_files_upload_tpl("filesupload"); |
296 | 296 | |
297 | 297 | # smarty vars |
298 | - $smarty->assign("feed", $this->feed); # feed data |
|
299 | - $smarty->assign("poptags", $poptags); # tags |
|
300 | - $smarty->assign("userlist", $this->userlist); # users |
|
301 | - $smarty->assign("groups", $groups); # groups |
|
298 | + $smarty->assign("feed", $this->feed); # feed data |
|
299 | + $smarty->assign("poptags", $poptags); # tags |
|
300 | + $smarty->assign("userlist", $this->userlist); # users |
|
301 | + $smarty->assign("groups", $groups); # groups |
|
302 | 302 | |
303 | 303 | # tpl |
304 | 304 | $content = $tpl->load_template("feeds_create_item", true); |
305 | - $smarty->assign("content", $content); |
|
305 | + $smarty->assign("content", $content); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | |
366 | 366 | |
367 | 367 | # smarty vars |
368 | - $smarty->assign("item", $item); # item data |
|
369 | - $smarty->assign("feed", $this->feed); # feed data |
|
370 | - $smarty->assign("poptags", $poptags); # tags |
|
371 | - $smarty->assign("userlist", $this->userlist); # users list |
|
372 | - $smarty->assign("gids", $gids); # group id access granted |
|
373 | - $smarty->assign("groups", $groups); # group list |
|
368 | + $smarty->assign("item", $item); # item data |
|
369 | + $smarty->assign("feed", $this->feed); # feed data |
|
370 | + $smarty->assign("poptags", $poptags); # tags |
|
371 | + $smarty->assign("userlist", $this->userlist); # users list |
|
372 | + $smarty->assign("gids", $gids); # group id access granted |
|
373 | + $smarty->assign("groups", $groups); # group list |
|
374 | 374 | |
375 | 375 | # tpl |
376 | 376 | $content = $tpl->load_template("feeds_edit_item", true); |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | $db->query("UPDATE ".PAGES_FEED_TABLE." SET status='".$status."' WHERE id='".$id."'"); |
516 | 516 | |
517 | 517 | # notice |
518 | - $mstatus = ($status) ? "Видимый" : "Скрытый" ; |
|
518 | + $mstatus = ($status) ? "Видимый" : "Скрытый"; |
|
519 | 519 | $logger->info("Запись #".$id." успешно изменила свой статус на <".$mstatus.">."); |
520 | 520 | |
521 | 521 | # go |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | $tags->save_tags("", "feeditemid=".$fid['id']); |
576 | 576 | # cond |
577 | 577 | $cond = $db->qcond_or($cond); |
578 | - $cond .= " attachedto='feeditemid=".$fid['id']."' " ; |
|
578 | + $cond .= " attachedto='feeditemid=".$fid['id']."' "; |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | # del attached images |
@@ -596,17 +596,17 @@ discard block |
||
596 | 596 | global $config, $tpl, $smarty; |
597 | 597 | |
598 | 598 | # Уведомление о глобальном отключении RSS лент |
599 | - $this->feed['rss_warn'] = (!$config->rss_power) ? true : false ; |
|
599 | + $this->feed['rss_warn'] = (!$config->rss_power) ? true : false; |
|
600 | 600 | |
601 | 601 | # глобальное значение количества элементов на страницу |
602 | - $this->feed['global_items_per_page'] =& $config->feed_items_per_page; |
|
602 | + $this->feed['global_items_per_page'] = & $config->feed_items_per_page; |
|
603 | 603 | |
604 | 604 | # default thumb size |
605 | 605 | $default_thumb_size = array('width' => $config->gd_thumb_image_width, |
606 | 606 | 'height' => $config->gd_thumb_image_height); |
607 | 607 | |
608 | 608 | # smarty vars |
609 | - $smarty->assign("feed",$this->feed); |
|
609 | + $smarty->assign("feed", $this->feed); |
|
610 | 610 | $smarty->assign("default_thumb_size", $default_thumb_size); |
611 | 611 | |
612 | 612 | # tpl |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | if(round($post->items_per_page) >= 0) { |
639 | 639 | $items_per_page = round($post->items_per_page); |
640 | 640 | } |
641 | - $update .= " items_per_page='".$items_per_page."', " ; |
|
641 | + $update .= " items_per_page='".$items_per_page."', "; |
|
642 | 642 | |
643 | 643 | # thumbnail check |
644 | 644 | $img->check_post_thumb_parametrs(); |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | # items sorting in feed |
647 | 647 | $items_sorting = "datepublication"; |
648 | 648 | if(isset($post->items_sorting)) { |
649 | - switch($post->items_sorting) { |
|
649 | + switch ($post->items_sorting) { |
|
650 | 650 | case 'title_asc': |
651 | 651 | $items_sorting = "title_asc"; |
652 | 652 | break; |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | # show_child_feeds |
666 | 666 | $show_child_feeds = "none"; |
667 | 667 | if(isset($post->show_child_feeds)) { |
668 | - switch($post->show_child_feeds) { |
|
668 | + switch ($post->show_child_feeds) { |
|
669 | 669 | case 'default': |
670 | 670 | $show_child_feeds = "default"; |
671 | 671 | break; |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | |
747 | 747 | # check isset date publication |
748 | 748 | if(!isset($post->date_publications)) { |
749 | - $post->date_publications = date("d.m.Y",time()); |
|
749 | + $post->date_publications = date("d.m.Y", time()); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | # check isset date end publication |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * Class ACP_Feeds |
31 | 31 | */ |
32 | -class ACP_Feeds { |
|
32 | +class ACP_Feeds { |
|
33 | 33 | |
34 | 34 | # extends |
35 | 35 | use FeedExtends; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Show must go on ... |
48 | 48 | */ |
49 | - public function __construct() { |
|
49 | + public function __construct() { |
|
50 | 50 | |
51 | 51 | global $tpl; |
52 | 52 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * init action |
66 | 66 | */ |
67 | - private function init() { |
|
67 | + private function init() { |
|
68 | 68 | |
69 | 69 | global $roocms, $get, $post, $db; |
70 | 70 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | break; |
141 | 141 | } |
142 | 142 | |
143 | - } |
|
143 | + } |
|
144 | 144 | else { |
145 | 145 | goback(); |
146 | 146 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | go(CP."?act=structure"); |
151 | 151 | break; |
152 | 152 | } |
153 | - } |
|
153 | + } |
|
154 | 154 | else { |
155 | 155 | # go |
156 | 156 | go(CP."?act=structure"); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | /** |
162 | 162 | * feed view |
163 | 163 | */ |
164 | - public function control() { |
|
164 | + public function control() { |
|
165 | 165 | |
166 | 166 | global $db, $parse, $tags, $tpl, $smarty; |
167 | 167 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | /** |
219 | 219 | * Create new record to feed |
220 | 220 | */ |
221 | - public function create_item() { |
|
221 | + public function create_item() { |
|
222 | 222 | |
223 | 223 | global $db, $users, $logger, $tags, $files, $img, $post, $tpl, $smarty; |
224 | 224 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @param int $id - record identificator from feed |
313 | 313 | */ |
314 | - public function edit_item($id) { |
|
314 | + public function edit_item($id) { |
|
315 | 315 | |
316 | 316 | global $db, $users, $tags, $files, $img, $tpl, $smarty, $parse; |
317 | 317 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @param int $id - record identificator from feed |
385 | 385 | */ |
386 | - public function update_item($id) { |
|
386 | + public function update_item($id) { |
|
387 | 387 | |
388 | 388 | global $db, $logger, $tags, $files, $img, $post, $get; |
389 | 389 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @param int $id - record identificator from feed |
452 | 452 | */ |
453 | - public function migrate_item($id) { |
|
453 | + public function migrate_item($id) { |
|
454 | 454 | |
455 | 455 | global $db, $logger, $tpl, $smarty, $post; |
456 | 456 | |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * @param int $id - record id |
506 | 506 | * @param int $status - 1=show , 0=hide |
507 | 507 | */ |
508 | - public function change_item_status($id, $status = 1) { |
|
508 | + public function change_item_status($id, $status = 1) { |
|
509 | 509 | |
510 | 510 | global $db, $logger; |
511 | 511 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | * |
529 | 529 | * @param int $id - record id |
530 | 530 | */ |
531 | - public function delete_item($id) { |
|
531 | + public function delete_item($id) { |
|
532 | 532 | |
533 | 533 | global $db, $logger, $img, $files, $tags; |
534 | 534 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @param int $sid - structure element id |
566 | 566 | */ |
567 | - public function delete_feed($sid) { |
|
567 | + public function delete_feed($sid) { |
|
568 | 568 | |
569 | 569 | global $db, $img, $files, $tags; |
570 | 570 | |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | /** |
592 | 592 | * Settings feed |
593 | 593 | */ |
594 | - public function settings() { |
|
594 | + public function settings() { |
|
595 | 595 | |
596 | 596 | global $config, $tpl, $smarty; |
597 | 597 | |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | /** |
619 | 619 | * Settings update to feed |
620 | 620 | */ |
621 | - public function update_settings() { |
|
621 | + public function update_settings() { |
|
622 | 622 | |
623 | 623 | global $db, $img, $post, $logger; |
624 | 624 | |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | * |
704 | 704 | * @param int $sid - feed id |
705 | 705 | */ |
706 | - public function count_items($sid) { |
|
706 | + public function count_items($sid) { |
|
707 | 707 | |
708 | 708 | global $db; |
709 | 709 | |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | /** |
719 | 719 | * Check data post |
720 | 720 | */ |
721 | - private function check_post_data_fields() { |
|
721 | + private function check_post_data_fields() { |
|
722 | 722 | |
723 | 723 | global $post, $logger; |
724 | 724 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | /** |
741 | 741 | * Check dates from data post |
742 | 742 | */ |
743 | - private function control_post_data_date() { |
|
743 | + private function control_post_data_date() { |
|
744 | 744 | |
745 | 745 | global $post, $parse; |
746 | 746 | |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | /** |
772 | 772 | * Check and correct secondary fields |
773 | 773 | */ |
774 | - private function correct_post_fields() { |
|
774 | + private function correct_post_fields() { |
|
775 | 775 | |
776 | 776 | global $users, $post; |
777 | 777 | |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | # sort |
784 | 784 | if(!isset($post->itemsort) || round($post->itemsort) < 0) { |
785 | 785 | $post->itemsort = 0; |
786 | - } |
|
786 | + } |
|
787 | 787 | else { |
788 | 788 | $post->itemsort = round($post->itemsort); |
789 | 789 | } |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | # group ids with access |
792 | 792 | if(isset($post->gids) && is_array($post->gids)) { |
793 | 793 | $post->gids = implode(",", $post->gids); |
794 | - } |
|
794 | + } |
|
795 | 795 | else { |
796 | 796 | $post->gids = 0; |
797 | 797 | } |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | * @param string $title |
814 | 814 | * @param string $subject |
815 | 815 | */ |
816 | - private function mailing($id, $title, $subject) { |
|
816 | + private function mailing($id, $title, $subject) { |
|
817 | 817 | |
818 | 818 | global $parse, $mailer, $logger, $users, $mailer, $site; |
819 | 819 | |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | # send to email |
830 | 830 | if(count($userlist) != 0) { |
831 | 831 | $mailer->spread($userlist, $title, $subject); |
832 | - } |
|
832 | + } |
|
833 | 833 | else { |
834 | 834 | $logger->error("Сообщение не отправлено! Не обнаружены подписчики подходящие под заданные критерии.", false); |
835 | 835 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * |
842 | 842 | * @return array<integer|string|boolean|array> |
843 | 843 | */ |
844 | - private function get_settings() { |
|
844 | + private function get_settings() { |
|
845 | 845 | |
846 | 846 | $setting = array( |
847 | 847 | 'id' => $this->engine->page_id, |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | while($row = $db->fetch_assoc($q)) { |
179 | 179 | |
180 | 180 | # flag future publications |
181 | - $row['publication_future'] = ($row['date_publications'] > time()) ? true : false ; |
|
181 | + $row['publication_future'] = ($row['date_publications'] > time()) ? TRUE : FALSE ; |
|
182 | 182 | |
183 | 183 | # flag show/hide |
184 | 184 | $row['publication_status'] = "show"; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | # formated date |
198 | 198 | $row['date_publications'] = $parse->date->unix_to_rus($row['date_publications']); |
199 | - $row['date_update'] = $parse->date->unix_to_rus($row['date_update'], false, true, true); |
|
199 | + $row['date_update'] = $parse->date->unix_to_rus($row['date_update'], FALSE, TRUE, TRUE); |
|
200 | 200 | |
201 | 201 | $taglinks[$row['id']] = "feeditemid=".$row['id']; |
202 | 202 | $feedlist[$row['id']] = $row; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $smarty->assign("subfeeds", $this->feed['subfeeds']); |
211 | 211 | $smarty->assign("feedlist", $feedlist); |
212 | 212 | |
213 | - $content = $tpl->load_template("feeds_control", true); |
|
213 | + $content = $tpl->load_template("feeds_control", TRUE); |
|
214 | 214 | $smarty->assign("content", $content); |
215 | 215 | } |
216 | 216 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | # attachment images |
257 | 257 | $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
258 | 258 | if($images) { |
259 | - foreach($images AS $image) { |
|
259 | + foreach($images as $image) { |
|
260 | 260 | $img->insert_images($image, "feeditemid=".$fiid, $post->title); |
261 | 261 | } |
262 | 262 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $groups = $users->get_usergroups(); |
289 | 289 | |
290 | 290 | # popular tags |
291 | - $poptags = $tags->list_tags(true); |
|
291 | + $poptags = $tags->list_tags(TRUE); |
|
292 | 292 | |
293 | 293 | # show upload files & images form |
294 | 294 | $tpl->load_image_upload_tpl("imagesupload"); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $smarty->assign("groups", $groups); # groups |
302 | 302 | |
303 | 303 | # tpl |
304 | - $content = $tpl->load_template("feeds_create_item", true); |
|
304 | + $content = $tpl->load_template("feeds_create_item", TRUE); |
|
305 | 305 | $smarty->assign("content", $content); |
306 | 306 | } |
307 | 307 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | $item['tags'] = implode(", ", array_map(array("Tags", "get_tag_title"), $tags->read_tags("feeditemid=".$id))); |
339 | 339 | |
340 | 340 | # popular tags |
341 | - $poptags = $tags->list_tags(true); |
|
341 | + $poptags = $tags->list_tags(TRUE); |
|
342 | 342 | |
343 | 343 | |
344 | 344 | # download attached images |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $smarty->assign("attachimg", $attachimg); |
347 | 347 | |
348 | 348 | # show attached images |
349 | - $attachedimages = $tpl->load_template("attached_images", true); |
|
349 | + $attachedimages = $tpl->load_template("attached_images", TRUE); |
|
350 | 350 | $smarty->assign("attachedimages", $attachedimages); |
351 | 351 | |
352 | 352 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $smarty->assign("attachfile", $attachfile); |
356 | 356 | |
357 | 357 | # show attached files |
358 | - $attachedfiles = $tpl->load_template("attached_files", true); |
|
358 | + $attachedfiles = $tpl->load_template("attached_files", TRUE); |
|
359 | 359 | $smarty->assign("attachedfiles", $attachedfiles); |
360 | 360 | |
361 | 361 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $smarty->assign("groups", $groups); # group list |
374 | 374 | |
375 | 375 | # tpl |
376 | - $content = $tpl->load_template("feeds_edit_item", true); |
|
376 | + $content = $tpl->load_template("feeds_edit_item", TRUE); |
|
377 | 377 | $smarty->assign("content", $content); |
378 | 378 | } |
379 | 379 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | # attachment images |
429 | 429 | $images = $img->upload_image("images", "", array($this->feed['thumb_img_width'], $this->feed['thumb_img_height'])); |
430 | 430 | if($images) { |
431 | - foreach($images AS $image) { |
|
431 | + foreach($images as $image) { |
|
432 | 432 | $img->insert_images($image, "feeditemid=".$id, $post->title); |
433 | 433 | } |
434 | 434 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $smarty->assign("feeds", $feeds); |
495 | 495 | |
496 | 496 | # tpl |
497 | - $content = $tpl->load_template("feeds_migrate_item", true); |
|
497 | + $content = $tpl->load_template("feeds_migrate_item", TRUE); |
|
498 | 498 | $smarty->assign("content", $content); |
499 | 499 | } |
500 | 500 | |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | |
581 | 581 | # del attached images |
582 | 582 | if(trim($cond) != "") { |
583 | - $img->remove_images($cond, true); |
|
584 | - $files->remove_files($cond, true); |
|
583 | + $img->remove_images($cond, TRUE); |
|
584 | + $files->remove_files($cond, TRUE); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | $db->query("DELETE FROM ".PAGES_FEED_TABLE." WHERE sid='".$sid."'"); |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | global $config, $tpl, $smarty; |
597 | 597 | |
598 | 598 | # Уведомление о глобальном отключении RSS лент |
599 | - $this->feed['rss_warn'] = (!$config->rss_power) ? true : false ; |
|
599 | + $this->feed['rss_warn'] = (!$config->rss_power) ? TRUE : FALSE ; |
|
600 | 600 | |
601 | 601 | # глобальное значение количества элементов на страницу |
602 | 602 | $this->feed['global_items_per_page'] =& $config->feed_items_per_page; |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | $smarty->assign("default_thumb_size", $default_thumb_size); |
611 | 611 | |
612 | 612 | # tpl |
613 | - $content = $tpl->load_template("feeds_settings_feed", true); |
|
613 | + $content = $tpl->load_template("feeds_settings_feed", TRUE); |
|
614 | 614 | $smarty->assign("content", $content); |
615 | 615 | } |
616 | 616 | |
@@ -724,12 +724,12 @@ discard block |
||
724 | 724 | |
725 | 725 | # title |
726 | 726 | if(!isset($post->title)) { |
727 | - $logger->error("Не заполнен заголовок элемента", false); |
|
727 | + $logger->error("Не заполнен заголовок элемента", FALSE); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | # full desc item |
731 | 731 | if(!isset($post->full_item)) { |
732 | - $logger->error("Не заполнен подробный текст элемента", false); |
|
732 | + $logger->error("Не заполнен подробный текст элемента", FALSE); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | # status |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | $mailer->spread($userlist, $title, $subject); |
832 | 832 | } |
833 | 833 | else { |
834 | - $logger->error("Сообщение не отправлено! Не обнаружены подписчики подходящие под заданные критерии.", false); |
|
834 | + $logger->error("Сообщение не отправлено! Не обнаружены подписчики подходящие под заданные критерии.", FALSE); |
|
835 | 835 | } |
836 | 836 | } |
837 | 837 |