@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package Comments |
|
4 | - * @category modules |
|
5 | - * @author Nazar Mokrynskyi <[email protected]> |
|
6 | - * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi |
|
7 | - * @license MIT License, see license.txt |
|
8 | - */ |
|
3 | + * @package Comments |
|
4 | + * @category modules |
|
5 | + * @author Nazar Mokrynskyi <[email protected]> |
|
6 | + * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi |
|
7 | + * @license MIT License, see license.txt |
|
8 | + */ |
|
9 | 9 | namespace cs; |
10 | 10 | Event::instance()->on( |
11 | 11 | 'System/Index/construct', |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @var int Avatar size in px, can be redefined |
38 | 38 | */ |
39 | - public $avatar_size = 36; |
|
39 | + public $avatar_size = 36; |
|
40 | 40 | |
41 | 41 | protected function construct () { |
42 | - $this->module = current_module(); |
|
43 | - $this->cache = new Cache_prefix("Comments/$this->module"); |
|
42 | + $this->module = current_module(); |
|
43 | + $this->cache = new Cache_prefix("Comments/$this->module"); |
|
44 | 44 | } |
45 | 45 | /** |
46 | 46 | * Set module (current module assumed by default) |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * @param string $module Module name |
49 | 49 | */ |
50 | 50 | function set_module ($module) { |
51 | - $this->module = $module; |
|
52 | - $this->cache = new Cache_prefix("Comments/$this->module"); |
|
51 | + $this->module = $module; |
|
52 | + $this->cache = new Cache_prefix("Comments/$this->module"); |
|
53 | 53 | } |
54 | 54 | /** |
55 | 55 | * Returns database index |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return array|false Array of comment data on success or <b>false</b> on failure |
68 | 68 | */ |
69 | 69 | function get ($id) { |
70 | - $id = (int)$id; |
|
70 | + $id = (int)$id; |
|
71 | 71 | return $this->db()->qf([ |
72 | 72 | "SELECT |
73 | 73 | `id`, |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | * @return array|bool Array of comment data on success or <b>false</b> on failure |
97 | 97 | */ |
98 | 98 | function add ($item, $text, $parent = 0) { |
99 | - $L = Language::instance(); |
|
99 | + $L = Language::instance(); |
|
100 | 100 | $User = User::instance(); |
101 | 101 | $text = xap($text, true); |
102 | 102 | if (!$text) { |
103 | 103 | return false; |
104 | 104 | } |
105 | - $item = (int)$item; |
|
106 | - $parent = (int)$parent; |
|
105 | + $item = (int)$item; |
|
106 | + $parent = (int)$parent; |
|
107 | 107 | if ( |
108 | 108 | $parent != 0 && |
109 | 109 | $this->db_prime()->qfs([ |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | * @return array|false Array of comment data on success or <b>false</b> on failure |
172 | 172 | */ |
173 | 173 | function set ($id, $text) { |
174 | - $text = xap($text, true); |
|
174 | + $text = xap($text, true); |
|
175 | 175 | if (!$text) { |
176 | 176 | return false; |
177 | 177 | } |
178 | - $id = (int)$id; |
|
179 | - $comment = $this->get($id); |
|
178 | + $id = (int)$id; |
|
179 | + $comment = $this->get($id); |
|
180 | 180 | if (!$comment) { |
181 | 181 | return false; |
182 | 182 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $this->module |
193 | 193 | )) { |
194 | 194 | unset($this->cache->{$comment['item']}); |
195 | - $comment['text'] = $text; |
|
195 | + $comment['text'] = $text; |
|
196 | 196 | return $comment; |
197 | 197 | } |
198 | 198 | return false; |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | * @return bool |
206 | 206 | */ |
207 | 207 | function del ($id) { |
208 | - $id = (int)$id; |
|
209 | - $comment = $this->db_prime()->qf([ |
|
208 | + $id = (int)$id; |
|
209 | + $comment = $this->db_prime()->qf([ |
|
210 | 210 | "SELECT `p`.`item`, COUNT(`c`.`id`) AS `count` |
211 | 211 | FROM `[prefix]comments` AS `p` |
212 | 212 | LEFT JOIN `[prefix]comments` AS `c` |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @return bool |
244 | 244 | */ |
245 | 245 | function del_all ($item) { |
246 | - $item = (int)$item; |
|
246 | + $item = (int)$item; |
|
247 | 247 | if ($this->db_prime()->q( |
248 | 248 | "DELETE FROM `[prefix]comments` |
249 | 249 | WHERE |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | if (!is_array($data)) { |
276 | 276 | return 0; |
277 | 277 | } |
278 | - $count = 0; |
|
278 | + $count = 0; |
|
279 | 279 | foreach ($data as &$d) { |
280 | - $count += $this->count_internal($d['comments']) + 1; |
|
280 | + $count += $this->count_internal($d['comments']) + 1; |
|
281 | 281 | } |
282 | 282 | return $count; |
283 | 283 | } |
@@ -300,12 +300,12 @@ discard block |
||
300 | 300 | * @return false|array |
301 | 301 | */ |
302 | 302 | function tree_data ($item, $parent = 0) { |
303 | - $Cache = $this->cache; |
|
304 | - $L = Language::instance(); |
|
303 | + $Cache = $this->cache; |
|
304 | + $L = Language::instance(); |
|
305 | 305 | if (($comments = $Cache->{"$item/$L->clang"}) === false) { |
306 | - $item = (int)$item; |
|
307 | - $parent = (int)$parent; |
|
308 | - $comments = $this->db()->qfa([ |
|
306 | + $item = (int)$item; |
|
307 | + $parent = (int)$parent; |
|
308 | + $comments = $this->db()->qfa([ |
|
309 | 309 | "SELECT |
310 | 310 | `id`, |
311 | 311 | `parent`, |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * Cache only root tree data |
331 | 331 | */ |
332 | 332 | if ($parent == 0) { |
333 | - $Cache->{"$item/$L->clang"} = $comments; |
|
333 | + $Cache->{"$item/$L->clang"} = $comments; |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | return $comments; |
@@ -343,15 +343,15 @@ discard block |
||
343 | 343 | * @return string |
344 | 344 | */ |
345 | 345 | function tree_html ($comments) { |
346 | - $L = Language::instance(); |
|
347 | - $User = User::instance(); |
|
346 | + $L = Language::instance(); |
|
347 | + $User = User::instance(); |
|
348 | 348 | if (!is_array($comments) || !$comments) { |
349 | 349 | return ''; |
350 | 350 | } |
351 | - $content = ''; |
|
351 | + $content = ''; |
|
352 | 352 | foreach ($comments as $comment) { |
353 | - $uniqid = uniqid('comment_', true); |
|
354 | - $content .= str_replace($uniqid, $comment['text'], h::{'article.cs-comments-comment'}( |
|
353 | + $uniqid = uniqid('comment_', true); |
|
354 | + $content .= str_replace($uniqid, $comment['text'], h::{'article.cs-comments-comment'}( |
|
355 | 355 | h::{'img.cs-comments-comment-avatar'}([ |
356 | 356 | 'src' => $User->avatar($this->avatar_size, $comment['user']), |
357 | 357 | 'alt' => $User->username($comment['user']), |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @return string |
408 | 408 | */ |
409 | 409 | function block ($item) { |
410 | - $L = new Language_prefix('comments_'); |
|
410 | + $L = new Language_prefix('comments_'); |
|
411 | 411 | return h::{'section#comments.cs-comments-comments'}( |
412 | 412 | $L->comments.':'. |
413 | 413 | ( |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package Comments |
|
4 | - * @category modules |
|
5 | - * @author Nazar Mokrynskyi <[email protected]> |
|
6 | - * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi |
|
7 | - * @license MIT License, see license.txt |
|
8 | - */ |
|
3 | + * @package Comments |
|
4 | + * @category modules |
|
5 | + * @author Nazar Mokrynskyi <[email protected]> |
|
6 | + * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi |
|
7 | + * @license MIT License, see license.txt |
|
8 | + */ |
|
9 | 9 | namespace cs\modules\Comments; |
10 | 10 | use |
11 | 11 | cs\Config, |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | throw new ExitException($L->comment_sending_server_error, 500); |
53 | 53 | } |
54 | 54 | /** |
55 | - * @var Comments $Comments |
|
56 | - */ |
|
55 | + * @var Comments $Comments |
|
56 | + */ |
|
57 | 57 | $result = $Comments->add($_POST['item'], $_POST['text'], $_POST['parent']); |
58 | 58 | if ($result) { |
59 | 59 | $result['comments'] = false; |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package Comments |
|
4 | - * @category modules |
|
5 | - * @author Nazar Mokrynskyi <[email protected]> |
|
6 | - * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi |
|
7 | - * @license MIT License, see license.txt |
|
8 | - */ |
|
3 | + * @package Comments |
|
4 | + * @category modules |
|
5 | + * @author Nazar Mokrynskyi <[email protected]> |
|
6 | + * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi |
|
7 | + * @license MIT License, see license.txt |
|
8 | + */ |
|
9 | 9 | namespace cs\modules\Comments; |
10 | 10 | use |
11 | 11 | cs\Config, |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | throw new ExitException($L->comment_editing_server_error, 500); |
55 | 55 | } |
56 | 56 | /** |
57 | - * @var Comments $Comments |
|
58 | - */ |
|
57 | + * @var Comments $Comments |
|
58 | + */ |
|
59 | 59 | $result = $Comments->set($Route->route[0], $_POST['text']); |
60 | 60 | if ($result) { |
61 | 61 | $Page->json($result['text']); |