@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @var int Avatar size in px, can be redefined |
36 | 36 | */ |
37 | - public $avatar_size = 36; |
|
37 | + public $avatar_size = 36; |
|
38 | 38 | |
39 | 39 | protected function construct () { |
40 | - $this->module = Request::instance()->current_module; |
|
41 | - $this->cache = new Cache_prefix("Comments/$this->module"); |
|
40 | + $this->module = Request::instance()->current_module; |
|
41 | + $this->cache = new Cache_prefix("Comments/$this->module"); |
|
42 | 42 | } |
43 | 43 | /** |
44 | 44 | * Set module (current module assumed by default) |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @param string $module Module name |
47 | 47 | */ |
48 | 48 | function set_module ($module) { |
49 | - $this->module = $module; |
|
50 | - $this->cache = new Cache_prefix("Comments/$this->module"); |
|
49 | + $this->module = $module; |
|
50 | + $this->cache = new Cache_prefix("Comments/$this->module"); |
|
51 | 51 | } |
52 | 52 | /** |
53 | 53 | * Returns database index |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @return array|false Array of comment data on success or <b>false</b> on failure |
66 | 66 | */ |
67 | 67 | function get ($id) { |
68 | - $id = (int)$id; |
|
68 | + $id = (int)$id; |
|
69 | 69 | return $this->db()->qf([ |
70 | 70 | "SELECT |
71 | 71 | `id`, |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | * @return array|bool Array of comment data on success or <b>false</b> on failure |
95 | 95 | */ |
96 | 96 | function add ($item, $text, $parent = 0) { |
97 | - $L = Language::instance(); |
|
97 | + $L = Language::instance(); |
|
98 | 98 | $User = User::instance(); |
99 | 99 | $text = xap($text, true); |
100 | 100 | if (!$text) { |
101 | 101 | return false; |
102 | 102 | } |
103 | - $item = (int)$item; |
|
104 | - $parent = (int)$parent; |
|
103 | + $item = (int)$item; |
|
104 | + $parent = (int)$parent; |
|
105 | 105 | if ( |
106 | 106 | $parent != 0 && |
107 | 107 | $this->db_prime()->qfs([ |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | * @return array|false Array of comment data on success or <b>false</b> on failure |
170 | 170 | */ |
171 | 171 | function set ($id, $text) { |
172 | - $text = xap($text, true); |
|
172 | + $text = xap($text, true); |
|
173 | 173 | if (!$text) { |
174 | 174 | return false; |
175 | 175 | } |
176 | - $id = (int)$id; |
|
177 | - $comment = $this->get($id); |
|
176 | + $id = (int)$id; |
|
177 | + $comment = $this->get($id); |
|
178 | 178 | if (!$comment) { |
179 | 179 | return false; |
180 | 180 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $this->module |
191 | 191 | )) { |
192 | 192 | unset($this->cache->{$comment['item']}); |
193 | - $comment['text'] = $text; |
|
193 | + $comment['text'] = $text; |
|
194 | 194 | return $comment; |
195 | 195 | } |
196 | 196 | return false; |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | * @return bool |
204 | 204 | */ |
205 | 205 | function del ($id) { |
206 | - $id = (int)$id; |
|
207 | - $comment = $this->db_prime()->qf([ |
|
206 | + $id = (int)$id; |
|
207 | + $comment = $this->db_prime()->qf([ |
|
208 | 208 | "SELECT `p`.`item`, COUNT(`c`.`id`) AS `count` |
209 | 209 | FROM `[prefix]comments` AS `p` |
210 | 210 | LEFT JOIN `[prefix]comments` AS `c` |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return bool |
242 | 242 | */ |
243 | 243 | function del_all ($item) { |
244 | - $item = (int)$item; |
|
244 | + $item = (int)$item; |
|
245 | 245 | if ($this->db_prime()->q( |
246 | 246 | "DELETE FROM `[prefix]comments` |
247 | 247 | WHERE |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | if (!is_array($data)) { |
274 | 274 | return 0; |
275 | 275 | } |
276 | - $count = 0; |
|
276 | + $count = 0; |
|
277 | 277 | foreach ($data as &$d) { |
278 | - $count += $this->count_internal($d['comments']) + 1; |
|
278 | + $count += $this->count_internal($d['comments']) + 1; |
|
279 | 279 | } |
280 | 280 | return $count; |
281 | 281 | } |
@@ -298,12 +298,12 @@ discard block |
||
298 | 298 | * @return false|array |
299 | 299 | */ |
300 | 300 | function tree_data ($item, $parent = 0) { |
301 | - $Cache = $this->cache; |
|
302 | - $L = Language::instance(); |
|
301 | + $Cache = $this->cache; |
|
302 | + $L = Language::instance(); |
|
303 | 303 | if (($comments = $Cache->{"$item/$L->clang"}) === false) { |
304 | - $item = (int)$item; |
|
305 | - $parent = (int)$parent; |
|
306 | - $comments = $this->db()->qfa([ |
|
304 | + $item = (int)$item; |
|
305 | + $parent = (int)$parent; |
|
306 | + $comments = $this->db()->qfa([ |
|
307 | 307 | "SELECT |
308 | 308 | `id`, |
309 | 309 | `parent`, |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * Cache only root tree data |
329 | 329 | */ |
330 | 330 | if ($parent == 0) { |
331 | - $Cache->{"$item/$L->clang"} = $comments; |
|
331 | + $Cache->{"$item/$L->clang"} = $comments; |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | return $comments; |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | * @return string |
342 | 342 | */ |
343 | 343 | function tree_html ($comments) { |
344 | - $L = Language::instance(); |
|
345 | - $User = User::instance(); |
|
344 | + $L = Language::instance(); |
|
345 | + $User = User::instance(); |
|
346 | 346 | if (!is_array($comments) || !$comments) { |
347 | 347 | return ''; |
348 | 348 | } |
349 | - $content = ''; |
|
349 | + $content = ''; |
|
350 | 350 | foreach ($comments as $comment) { |
351 | - $uniqid = uniqid('comment_', true); |
|
352 | - $content .= str_replace($uniqid, $comment['text'], h::{'article.cs-comments-comment'}( |
|
351 | + $uniqid = uniqid('comment_', true); |
|
352 | + $content .= str_replace($uniqid, $comment['text'], h::{'article.cs-comments-comment'}( |
|
353 | 353 | h::{'img.cs-comments-comment-avatar'}([ |
354 | 354 | 'src' => $User->avatar($this->avatar_size, $comment['user']), |
355 | 355 | 'alt' => $User->username($comment['user']), |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @return string |
406 | 406 | */ |
407 | 407 | function block ($item) { |
408 | - $L = new Language_prefix('comments_'); |
|
408 | + $L = new Language_prefix('comments_'); |
|
409 | 409 | return h::{'section#comments.cs-comments-comments'}( |
410 | 410 | $L->comments.':'. |
411 | 411 | ( |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | protected $shortname; |
28 | 28 | |
29 | 29 | protected function construct () { |
30 | - $this->module = Request::instance()->current_module; |
|
31 | - $this->shortname = Config::instance()->module('Disqus')->shortname; |
|
30 | + $this->module = Request::instance()->current_module; |
|
31 | + $this->shortname = Config::instance()->module('Disqus')->shortname; |
|
32 | 32 | } |
33 | 33 | /** |
34 | 34 | * Set module (current module assumed by default) |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param string $module Module name |
37 | 37 | */ |
38 | 38 | function set_module ($module) { |
39 | - $this->module = $module; |
|
39 | + $this->module = $module; |
|
40 | 40 | } |
41 | 41 | /** |
42 | 42 | * Count of comments for specified item |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | return '<div id="disqus_thread"></div>'; |
74 | 74 | } |
75 | 75 | protected function count_js () { |
76 | - static $added = false; |
|
76 | + static $added = false; |
|
77 | 77 | if ($added) { |
78 | 78 | return; |
79 | 79 | } |
80 | - $added = true; |
|
80 | + $added = true; |
|
81 | 81 | Page::instance()->js( |
82 | 82 | "var disqus_shortname = '$this->shortname'; |
83 | 83 | if (!window.disqus_count_items) { window.disqus_count_items = []; }", |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | ); |
86 | 86 | } |
87 | 87 | protected function block_js ($item) { |
88 | - static $added = false; |
|
88 | + static $added = false; |
|
89 | 89 | if ($added) { |
90 | 90 | return; |
91 | 91 | } |
92 | - $added = true; |
|
92 | + $added = true; |
|
93 | 93 | Page::instance()->js( |
94 | 94 | "var disqus_shortname = '$this->shortname', disqus_identifier = '".str_replace("'", "\'", "$this->module/$item")."';", |
95 | 95 | 'code' |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function onOpen (ConnectionInterface $conn, RequestInterface $request = null) { |
28 | 28 | $L = Language::instance(); |
29 | 29 | /** @noinspection PhpUndefinedFieldInspection */ |
30 | - $ip = $this->ip( |
|
30 | + $ip = $this->ip( |
|
31 | 31 | [ |
32 | 32 | $conn->remoteAddress, |
33 | 33 | $request->getHeader('X-Forwarded-For'), |