Completed
Push — master ( dd6676...f6f2fd )
by Agel_Nash
10:19
created
assets/lib/class.summary.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     }
70 70
 
71 71
     /**
72
-     * @return mixed
72
+     * @return string
73 73
      */
74 74
     public function getCut()
75 75
     {
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
     /**
150 150
      * @param $resource
151 151
      * @param $truncLen
152
-     * @param $truncOffset
153
-     * @param $truncChars
152
+     * @param integer $truncOffset
153
+     * @param boolean $truncChars
154 154
      * @param string $splitter
155 155
      * @return array|mixed|string
156 156
      */
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      */
243 243
     /**
244 244
      * @param $string
245
-     * @param $limit
245
+     * @param integer $limit
246 246
      * @param string $break
247 247
      * @return string
248 248
      */
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
     }
266 266
 
267 267
     /**
268
-     * @param $str
268
+     * @param string $str
269 269
      * @return mixed
270 270
      */
271 271
     protected function rTriming($str)
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function dotted($scheme = 0)
85 85
     {
86
-        if (($scheme == 1 && ($this->_useCut || $this->_useSubstr)) || ($scheme == 2 && $this->_useSubstr && !$this->_useCut)) {
86
+        if (($scheme == 1 && ($this->_useCut || $this->_useSubstr)) || ($scheme == 2 && $this->_useSubstr && ! $this->_useCut)) {
87 87
             $this->_cfg['content'] .= '…'; //...
88 88
         } else {
89
-            if ($scheme && (!$this->_useCut || $scheme != 2)) {
89
+            if ($scheme && ( ! $this->_useCut || $scheme != 2)) {
90 90
                 $this->_cfg['content'] .= '.';
91 91
             }
92 92
         }
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
                         $this->_cfg['content'] = APIhelpers::sanitarTag($this->_cfg['content']);
116 116
                         break;
117 117
                     case 'chars':
118
-                        if (!(isset($process[1]) && $process[1] > 0)) {
118
+                        if ( ! (isset($process[1]) && $process[1] > 0)) {
119 119
                             $process[1] = 200;
120 120
                         }
121 121
                         $this->_cfg['content'] = APIhelpers::mb_trim_word($this->_cfg['content'], $process[1]);
122 122
                         break;
123 123
                     case 'len':
124
-                        if (!(isset($process[1]) && $process[1] > 0)) {
124
+                        if ( ! (isset($process[1]) && $process[1] > 0)) {
125 125
                             $process[1] = 200;
126 126
                         }
127 127
                         $this->_cfg['content'] = $this->summary($this->_cfg['content'], $process[1], 50, true,
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
                 } else {
209 209
                     $next_char = "";
210 210
                 }
211
-                if (!$quotes_on) {
211
+                if ( ! $quotes_on) {
212 212
                     // Check if it's a tag
213 213
                     // On a "<" add 3 if it's an opening tag (like <a href...)
214 214
                     // or add only 1 if it's an ending tag (like </a>)
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
     protected function rTriming($str)
296 296
     {
297 297
         $str = preg_replace('/[\r\n]++/', ' ', $str);
298
-        if (!$this->_useCut || $this->_dotted != 2) {
298
+        if ( ! $this->_useCut || $this->_dotted != 2) {
299 299
             $str = preg_replace("/(([\.,\-:!?;\s])|(&\w+;))+$/ui", "", $str);
300 300
         }
301 301
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 if (mb_strstr($tag, ' ', 'UTF-8')) {
349 349
                     $tag = mb_substr($tag, 0, strpos($tag, ' '), 'UTF-8');
350 350
                 }
351
-                if (!mb_stristr($tag, 'br', 'UTF-8') && !mb_stristr($tag, 'img', 'UTF-8') && !empty ($tag)) {
351
+                if ( ! mb_stristr($tag, 'br', 'UTF-8') && ! mb_stristr($tag, 'img', 'UTF-8') && ! empty ($tag)) {
352 352
                     $endTags .= '</' . $tag . '>';
353 353
                 }
354 354
             }
Please login to merge, or discard this patch.
Braces   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Class SummaryText
19 19
  */
20
-class SummaryText
21
-{
20
+class SummaryText
21
+{
22 22
     /**
23 23
      * @var array
24 24
      */
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
      * @param $action
46 46
      * @param null $break
47 47
      */
48
-    public function __construct($text, $action, $break = null)
49
-    {
48
+    public function __construct($text, $action, $break = null)
49
+    {
50 50
         $this->_cfg['content'] = is_scalar($text) ? $text : '';
51 51
         $this->_cfg['original'] = $this->_cfg['content'];
52 52
         $this->_cfg['summary'] = is_scalar($action) ? $action : '';
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
      * @param $cut
58 58
      * @return bool
59 59
      */
60
-    public function setCut($cut)
61
-    {
62
-        if (is_scalar($cut) && $cut != '') {
60
+    public function setCut($cut)
61
+    {
62
+        if (is_scalar($cut) && $cut != '') {
63 63
             $this->_cfg['cut'] = $cut;
64 64
             $flag = true;
65
-        } else {
65
+        } else {
66 66
             $flag = false;
67 67
         }
68 68
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * @return mixed
74 74
      */
75
-    public function getCut()
76
-    {
75
+    public function getCut()
76
+    {
77 77
         return \APIHelpers::getkey($this->_cfg, 'cut', '<cut/>');
78 78
     }
79 79
 
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
      * @param int $scheme
82 82
      * @return mixed
83 83
      */
84
-    protected function dotted($scheme = 0)
85
-    {
86
-        if (($scheme == 1 && ($this->_useCut || $this->_useSubstr)) || ($scheme == 2 && $this->_useSubstr && !$this->_useCut)) {
84
+    protected function dotted($scheme = 0)
85
+    {
86
+        if (($scheme == 1 && ($this->_useCut || $this->_useSubstr)) || ($scheme == 2 && $this->_useSubstr && !$this->_useCut)) {
87 87
             $this->_cfg['content'] .= '&hellip;'; //...
88
-        } else {
89
-            if ($scheme && (!$this->_useCut || $scheme != 2)) {
88
+        } else {
89
+            if ($scheme && (!$this->_useCut || $scheme != 2)) {
90 90
                 $this->_cfg['content'] .= '.';
91 91
             }
92 92
         }
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
      * @param int $dotted
99 99
      * @return mixed
100 100
      */
101
-    public function run($dotted = 0)
102
-    {
101
+    public function run($dotted = 0)
102
+    {
103 103
         $this->_dotted = $dotted;
104
-        if (isset($this->_cfg['content'], $this->_cfg['summary']) && $this->_cfg['summary'] != '' && $this->_cfg['content'] != '') {
104
+        if (isset($this->_cfg['content'], $this->_cfg['summary']) && $this->_cfg['summary'] != '' && $this->_cfg['content'] != '') {
105 105
             $param = explode(",", $this->_cfg['summary']);
106 106
             $this->_cfg['content'] = $this->beforeCut($this->_cfg['content'], $this->getCut());
107
-            foreach ($param as $doing) {
107
+            foreach ($param as $doing) {
108 108
 
109 109
                 $process = explode(":", $doing);
110
-                switch ($process[0]) {
110
+                switch ($process[0]) {
111 111
                     case 'notags':
112 112
                         $this->_cfg['content'] = strip_tags($this->_cfg['content']);
113 113
                         break;
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
                         $this->_cfg['content'] = APIhelpers::sanitarTag($this->_cfg['content']);
116 116
                         break;
117 117
                     case 'chars':
118
-                        if (!(isset($process[1]) && $process[1] > 0)) {
118
+                        if (!(isset($process[1]) && $process[1] > 0)) {
119 119
                             $process[1] = 200;
120 120
                         }
121 121
                         $this->_cfg['content'] = APIhelpers::mb_trim_word($this->_cfg['content'], $process[1]);
122 122
                         break;
123 123
                     case 'len':
124
-                        if (!(isset($process[1]) && $process[1] > 0)) {
124
+                        if (!(isset($process[1]) && $process[1] > 0)) {
125 125
                             $process[1] = 200;
126 126
                         }
127 127
                         $this->_cfg['content'] = $this->summary($this->_cfg['content'], $process[1], 50, true,
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
      * @param string $splitter
140 140
      * @return array|mixed
141 141
      */
142
-    protected function beforeCut($resource, $splitter = '')
143
-    {
144
-        if ($splitter !== '') {
142
+    protected function beforeCut($resource, $splitter = '')
143
+    {
144
+        if ($splitter !== '') {
145 145
             $summary = str_replace('<p>' . $splitter . '</p>', $splitter,
146 146
                 $resource); // For TinyMCE or if it isn't wrapped inside paragraph tags
147 147
             $summary = explode($splitter, $summary, 2);
148 148
             $this->_useCut = isset($summary[1]);
149 149
             $summary = $summary['0'];
150
-        } else {
150
+        } else {
151 151
             $summary = $resource;
152 152
         }
153 153
 
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
      * @param string $splitter
163 163
      * @return array|mixed|string
164 164
      */
165
-    protected function summary($resource, $truncLen, $truncOffset, $truncChars, $splitter = '')
166
-    {
167
-        if (isset($this->_useCut) && $splitter != '' && mb_strstr($resource, $splitter, 'UTF-8')) {
165
+    protected function summary($resource, $truncLen, $truncOffset, $truncChars, $splitter = '')
166
+    {
167
+        if (isset($this->_useCut) && $splitter != '' && mb_strstr($resource, $splitter, 'UTF-8')) {
168 168
             $summary = $this->beforeCut($resource, $splitter);
169
-        } else {
170
-            if ($this->_useCut !== true && (mb_strlen($resource, 'UTF-8') > $truncLen)) {
169
+        } else {
170
+            if ($this->_useCut !== true && (mb_strlen($resource, 'UTF-8') > $truncLen)) {
171 171
 
172 172
                 $summary = $this->html_substr($resource, $truncLen, $truncOffset, $truncChars);
173
-                if ($resource != $summary) {
173
+                if ($resource != $summary) {
174 174
                     $this->_useSubstr = true;
175 175
                 }
176
-            } else {
176
+            } else {
177 177
                 $summary = $resource;
178 178
             }
179 179
         }
@@ -194,60 +194,60 @@  discard block
 block discarded – undo
194 194
      * @param bool $truncChars
195 195
      * @return string
196 196
      */
197
-    protected function html_substr($posttext, $minimum_length = 200, $length_offset = 100, $truncChars = false)
198
-    {
197
+    protected function html_substr($posttext, $minimum_length = 200, $length_offset = 100, $truncChars = false)
198
+    {
199 199
         $tag_counter = 0;
200 200
         $quotes_on = false;
201
-        if (mb_strlen($posttext) > $minimum_length && $truncChars !== true) {
201
+        if (mb_strlen($posttext) > $minimum_length && $truncChars !== true) {
202 202
             $c = 0;
203 203
             $len = mb_strlen($posttext, 'UTF-8');
204
-            for ($i = 0; $i < $len; $i++) {
204
+            for ($i = 0; $i < $len; $i++) {
205 205
                 $current_char = mb_substr($posttext, $i, 1, 'UTF-8');
206
-                if ($i < mb_strlen($posttext, 'UTF-8') - 1) {
206
+                if ($i < mb_strlen($posttext, 'UTF-8') - 1) {
207 207
                     $next_char = mb_substr($posttext, $i + 1, 1, 'UTF-8');
208
-                } else {
208
+                } else {
209 209
                     $next_char = "";
210 210
                 }
211
-                if (!$quotes_on) {
211
+                if (!$quotes_on) {
212 212
                     // Check if it's a tag
213 213
                     // On a "<" add 3 if it's an opening tag (like <a href...)
214 214
                     // or add only 1 if it's an ending tag (like </a>)
215
-                    if ($current_char == '<') {
216
-                        if ($next_char == '/') {
215
+                    if ($current_char == '<') {
216
+                        if ($next_char == '/') {
217 217
                             $tag_counter += 1;
218
-                        } else {
218
+                        } else {
219 219
                             $tag_counter += 3;
220 220
                         }
221 221
                     }
222 222
                     // Slash signifies an ending (like </a> or ... />)
223 223
                     // substract 2
224
-                    if ($current_char == '/' && $tag_counter <> 0) {
224
+                    if ($current_char == '/' && $tag_counter <> 0) {
225 225
                         $tag_counter -= 2;
226 226
                     }
227 227
                     // On a ">" substract 1
228
-                    if ($current_char == '>') {
228
+                    if ($current_char == '>') {
229 229
                         $tag_counter -= 1;
230 230
                     }
231 231
                     // If quotes are encountered, start ignoring the tags
232 232
                     // (for directory slashes)
233
-                    if ($current_char == '"') {
233
+                    if ($current_char == '"') {
234 234
                         $quotes_on = true;
235 235
                     }
236
-                } else {
236
+                } else {
237 237
                     // IF quotes are encountered again, turn it back off
238
-                    if ($current_char == '"') {
238
+                    if ($current_char == '"') {
239 239
                         $quotes_on = false;
240 240
                     }
241 241
                 }
242 242
 
243 243
                 // Count only the chars outside html tags
244
-                if ($tag_counter == 2 || $tag_counter == 0) {
244
+                if ($tag_counter == 2 || $tag_counter == 0) {
245 245
                     $c++;
246 246
                 }
247 247
 
248 248
                 // Check if the counter has reached the minimum length yet,
249 249
                 // then wait for the tag_counter to become 0, and chop the string there
250
-                if ($c > $minimum_length - $length_offset && $tag_counter == 0) {
250
+                if ($c > $minimum_length - $length_offset && $tag_counter == 0) {
251 251
                     $posttext = mb_substr($posttext, 0, $i + 1, 'UTF-8');
252 252
 
253 253
                     return $posttext;
@@ -267,20 +267,20 @@  discard block
 block discarded – undo
267 267
      * @param string $break
268 268
      * @return string
269 269
      */
270
-    protected function textTrunc($string, $limit, $break = ". ")
271
-    {
270
+    protected function textTrunc($string, $limit, $break = ". ")
271
+    {
272 272
         // Original PHP code from The Art of Web: www.the-art-of-web.com
273 273
 
274 274
         // return with no change if string is shorter than $limit
275
-        if (mb_strlen($string, 'UTF-8') < $limit) {
275
+        if (mb_strlen($string, 'UTF-8') < $limit) {
276 276
             return $string;
277 277
         }
278 278
 
279 279
         $string = mb_substr($string, 0, $limit, 'UTF-8');
280
-        if (false !== ($breakpoint = mb_strrpos($string, $break, 'UTF-8'))) {
280
+        if (false !== ($breakpoint = mb_strrpos($string, $break, 'UTF-8'))) {
281 281
             $string = mb_substr($string, 0, $breakpoint + 1, 'UTF-8');
282
-        } else {
283
-            if ($break != ' ') {
282
+        } else {
283
+            if ($break != ' ') {
284 284
                 $string = $this->textTrunc($string, $limit, " ");
285 285
             }
286 286
         }
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
      * @param $str
293 293
      * @return mixed
294 294
      */
295
-    protected function rTriming($str)
296
-    {
295
+    protected function rTriming($str)
296
+    {
297 297
         $str = preg_replace('/[\r\n]++/', ' ', $str);
298
-        if (!$this->_useCut || $this->_dotted != 2) {
298
+        if (!$this->_useCut || $this->_dotted != 2) {
299 299
             $str = preg_replace("/(([\.,\-:!?;\s])|(&\w+;))+$/ui", "", $str);
300 300
         }
301 301
 
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
      * @param $text
309 309
      * @return string
310 310
      */
311
-    private function closeTags($text)
312
-    {
311
+    private function closeTags($text)
312
+    {
313 313
         $openPattern = "/<([^\/].*?)>/";
314 314
         $closePattern = "/<\/(.*?)>/";
315 315
         $endTags = '';
@@ -319,15 +319,15 @@  discard block
 block discarded – undo
319 319
 
320 320
         $c = 0;
321 321
         $loopCounter = count($closeTags[1]); //used to prevent an infinite loop if the html is malformed
322
-        while ($c < count($closeTags[1]) && $loopCounter) {
322
+        while ($c < count($closeTags[1]) && $loopCounter) {
323 323
             $i = 0;
324
-            while ($i < count($openTags[1])) {
324
+            while ($i < count($openTags[1])) {
325 325
                 $tag = trim($openTags[1][$i]);
326 326
 
327
-                if (mb_strstr($tag, ' ', 'UTF-8')) {
327
+                if (mb_strstr($tag, ' ', 'UTF-8')) {
328 328
                     $tag = mb_substr($tag, 0, strpos($tag, ' '), 'UTF-8');
329 329
                 }
330
-                if ($tag == $closeTags[1][$c]) {
330
+                if ($tag == $closeTags[1][$c]) {
331 331
                     $openTags[1][$i] = '';
332 332
                     $c++;
333 333
                     break;
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 
340 340
         $results = $openTags[1];
341 341
 
342
-        if (is_array($results)) {
342
+        if (is_array($results)) {
343 343
             $results = array_reverse($results);
344 344
 
345
-            foreach ($results as $tag) {
345
+            foreach ($results as $tag) {
346 346
                 $tag = trim($tag);
347 347
 
348
-                if (mb_strstr($tag, ' ', 'UTF-8')) {
348
+                if (mb_strstr($tag, ' ', 'UTF-8')) {
349 349
                     $tag = mb_substr($tag, 0, strpos($tag, ' '), 'UTF-8');
350 350
                 }
351
-                if (!mb_stristr($tag, 'br', 'UTF-8') && !mb_stristr($tag, 'img', 'UTF-8') && !empty ($tag)) {
351
+                if (!mb_stristr($tag, 'br', 'UTF-8') && !mb_stristr($tag, 'img', 'UTF-8') && !empty ($tag)) {
352 352
                     $endTags .= '</' . $tag . '>';
353 353
                 }
354 354
             }
Please login to merge, or discard this patch.
assets/lib/MODxAPI/MODx.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -618,7 +618,7 @@
 block discarded – undo
618 618
     }
619 619
 
620 620
     /**
621
-     * @param $table
621
+     * @param null|string $table
622 622
      * @return mixed|string
623 623
      */
624 624
     final public function makeTable($table)
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function addQuery($q)
199 199
     {
200
-        if (is_scalar($q) && !empty($q)) {
200
+        if (is_scalar($q) && ! empty($q)) {
201 201
             $this->_query[] = $q;
202 202
         }
203 203
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
     final public function escape($value)
233 233
     {
234
-        if (!is_scalar($value)) {
234
+        if ( ! is_scalar($value)) {
235 235
             $value = '';
236 236
         } else {
237 237
             $value = $this->modx->db->escape($value);
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
             //Если уже загружен объект, с которым мы хотим временно поработать
373 373
             case ($this->getID() == $id && $id):
374 374
                 //Если $id не указан, но уже загружен какой-то объект
375
-            case (!$id && $this->getID()):
375
+            case ( ! $id && $this->getID()):
376 376
             default:
377 377
                 $obj = $this;
378 378
                 break;
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
      */
408 408
     public function set($key, $value)
409 409
     {
410
-        if ((is_scalar($value) || $this->isJsonField($key)) && is_scalar($key) && !empty($key)) {
410
+        if ((is_scalar($value) || $this->isJsonField($key)) && is_scalar($key) && ! empty($key)) {
411 411
             $this->field[$key] = $value;
412 412
         }
413 413
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
      */
455 455
     final protected function Uset($key, $id = '')
456 456
     {
457
-        if (!isset($this->field[$key])) {
457
+        if ( ! isset($this->field[$key])) {
458 458
             $tmp = "`{$key}`=''";
459 459
             $this->log[] = "{$key} is empty";
460 460
         } else {
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
                 throw new Exception("{$key} is invalid <pre>" . print_r($this->field[$key], true) . "</pre>");
465 465
             }
466 466
         }
467
-        if (!empty($tmp)) {
467
+        if ( ! empty($tmp)) {
468 468
             if ($id == '') {
469 469
                 $this->set[] = $tmp;
470 470
             } else {
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
     final public function cleanIDs($IDs, $sep = ',', $ignore = array())
486 486
     {
487 487
         $out = array();
488
-        if (!is_array($IDs)) {
488
+        if ( ! is_array($IDs)) {
489 489
             if (is_scalar($IDs)) {
490 490
                 $IDs = explode($sep, $IDs);
491 491
             } else {
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
         foreach ($IDs as $item) {
497 497
             $item = trim($item);
498 498
             if (is_scalar($item) && (int)$item >= 0) { //Fix 0xfffffffff
499
-                if (!empty($ignore) && in_array((int)$item, $ignore, true)) {
499
+                if ( ! empty($ignore) && in_array((int)$item, $ignore, true)) {
500 500
                     $this->log[] = 'Ignore id ' . (int)$item;
501 501
                 } else {
502 502
                     $out[] = (int)$item;
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
      */
517 517
     final public function fromJson($data, $callback = null)
518 518
     {
519
-        if (is_scalar($data) && !empty($data)) {
519
+        if (is_scalar($data) && ! empty($data)) {
520 520
             $json = json_decode($data);
521 521
         } else {
522 522
             throw new Exception("json is not string with json data");
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
      */
635 635
     final public function sanitarIn($data, $sep = ',')
636 636
     {
637
-        if (!is_array($data)) {
637
+        if ( ! is_array($data)) {
638 638
             $data = explode($sep, $data);
639 639
         }
640 640
         $out = array();
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
         if ($where != '') {
677 677
             $sql = $this->query("SELECT `" . $this->escape($PK) . "` FROM " . $this->makeTable($table) . " WHERE " . $where);
678 678
             $id = $this->modx->db->getValue($sql);
679
-            if (is_null($id) || (!$this->newDoc && $id == $this->getID())) {
679
+            if (is_null($id) || ( ! $this->newDoc && $id == $this->getID())) {
680 680
                 $flag = true;
681 681
             } else {
682 682
                 $flag = false;
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
      */
873 873
     public function getNoEncodeFields()
874 874
     {
875
-        return $this->_decodedFields->filter(function ($value) {
875
+        return $this->_decodedFields->filter(function($value) {
876 876
             return ($value === false);
877 877
         });
878 878
     }
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
      */
884 884
     public function getNoDecodeFields()
885 885
     {
886
-        return $this->_decodedFields->filter(function ($value) {
886
+        return $this->_decodedFields->filter(function($value) {
887 887
             return ($value === true);
888 888
         });
889 889
     }
Please login to merge, or discard this patch.
Braces   +201 added lines, -200 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
 /**
8 8
  * Class MODxAPIhelpers
9 9
  */
10
-class MODxAPIhelpers
11
-{
10
+class MODxAPIhelpers
11
+{
12 12
     /**
13 13
      * @param $email
14 14
      * @param bool $dns
15 15
      * @return false|string
16 16
      */
17
-    public function emailValidate($email, $dns = true)
18
-    {
17
+    public function emailValidate($email, $dns = true)
18
+    {
19 19
         return \APIhelpers::emailValidate($email, $dns);
20 20
     }
21 21
 
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
      * @param string $data
25 25
      * @return string
26 26
      */
27
-    public function genPass($len, $data = '')
28
-    {
27
+    public function genPass($len, $data = '')
28
+    {
29 29
         return \APIhelpers::genPass($len, $data);
30 30
     }
31 31
 
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
      * @param string $out
34 34
      * @return string
35 35
      */
36
-    public function getUserIP($out = '127.0.0.1')
37
-    {
36
+    public function getUserIP($out = '127.0.0.1')
37
+    {
38 38
         return \APIhelpers::getUserIP($out);
39 39
     }
40 40
 
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
      * @param $data
43 43
      * @return array|mixed|string
44 44
      */
45
-    public function sanitarTag($data)
46
-    {
45
+    public function sanitarTag($data)
46
+    {
47 47
         return \APIhelpers::sanitarTag($data);
48 48
     }
49 49
 
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
      * @param array $mixArray
55 55
      * @return bool
56 56
      */
57
-    public function checkString($value, $minLen = 1, $alph = array(), $mixArray = array())
58
-    {
57
+    public function checkString($value, $minLen = 1, $alph = array(), $mixArray = array())
58
+    {
59 59
         return \APIhelpers::checkString($value, $minLen, $alph, $mixArray);
60 60
     }
61 61
 }
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 /**
64 64
  * Class MODxAPI
65 65
  */
66
-abstract class MODxAPI extends MODxAPIhelpers
67
-{
66
+abstract class MODxAPI extends MODxAPIhelpers
67
+{
68 68
     /**
69 69
      * Объект DocumentParser - основной класс MODX
70 70
      * @var \DocumentParser
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
      * @param bool $debug
144 144
      * @throws Exception
145 145
      */
146
-    public function __construct(DocumentParser $modx, $debug = false)
147
-    {
146
+    public function __construct(DocumentParser $modx, $debug = false)
147
+    {
148 148
         $this->modx = $modx;
149
-        if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) {
149
+        if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) {
150 150
             throw new Exception('Magic Quotes is a deprecated and mostly useless setting that should be disabled. Please ask your server administrator to disable it in php.ini or in your webserver config.');
151 151
         }
152 152
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
      * @param boolean $flag
159 159
      * @return $this
160 160
      */
161
-    public function setDebug($flag)
162
-    {
161
+    public function setDebug($flag)
162
+    {
163 163
         $this->_debug = (bool)$flag;
164 164
 
165 165
         return $this;
@@ -168,16 +168,16 @@  discard block
 block discarded – undo
168 168
     /**
169 169
      * @return bool
170 170
      */
171
-    public function getDebug()
172
-    {
171
+    public function getDebug()
172
+    {
173 173
         return $this->_debug;
174 174
     }
175 175
 
176 176
     /**
177 177
      * @return array
178 178
      */
179
-    public function getDefaultFields()
180
-    {
179
+    public function getDefaultFields()
180
+    {
181 181
         return $this->default_field;
182 182
     }
183 183
 
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
      * @param null $default
187 187
      * @return mixed
188 188
      */
189
-    final public function modxConfig($name, $default = null)
190
-    {
189
+    final public function modxConfig($name, $default = null)
190
+    {
191 191
         return APIHelpers::getkey($this->modx->config, $name, $default);
192 192
     }
193 193
 
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
      * @param $q
196 196
      * @return $this
197 197
      */
198
-    public function addQuery($q)
199
-    {
200
-        if (is_scalar($q) && !empty($q)) {
198
+    public function addQuery($q)
199
+    {
200
+        if (is_scalar($q) && !empty($q)) {
201 201
             $this->_query[] = $q;
202 202
         }
203 203
 
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
     /**
208 208
      * @return array
209 209
      */
210
-    public function getQueryList()
211
-    {
210
+    public function getQueryList()
211
+    {
212 212
         return $this->_query;
213 213
     }
214 214
 
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
      * @param $SQL
217 217
      * @return mixed
218 218
      */
219
-    final public function query($SQL)
220
-    {
221
-        if ($this->getDebug()) {
219
+    final public function query($SQL)
220
+    {
221
+        if ($this->getDebug()) {
222 222
             $this->addQuery($SQL);
223 223
         }
224 224
 
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
      * @param $value
230 230
      * @return string|void
231 231
      */
232
-    final public function escape($value)
233
-    {
234
-        if (!is_scalar($value)) {
232
+    final public function escape($value)
233
+    {
234
+        if (!is_scalar($value)) {
235 235
             $value = '';
236
-        } else {
236
+        } else {
237 237
             $value = $this->modx->db->escape($value);
238 238
         }
239 239
 
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
      * @param bool $flag
247 247
      * @return $this
248 248
      */
249
-    final public function invokeEvent($name, $data = array(), $flag = false)
250
-    {
249
+    final public function invokeEvent($name, $data = array(), $flag = false)
250
+    {
251 251
         $flag = (isset($flag) && $flag != '') ? (bool)$flag : false;
252
-        if ($flag) {
252
+        if ($flag) {
253 253
             $this->modx->invokeEvent($name, $data);
254 254
         }
255 255
 
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
      * @param boolean $flag
263 263
      * @return array|bool
264 264
      */
265
-    final public function getInvokeEventResult($name, $data = array(), $flag = null)
266
-    {
265
+    final public function getInvokeEventResult($name, $data = array(), $flag = null)
266
+    {
267 267
         $flag = (isset($flag) && $flag != '') ? (bool)$flag : false;
268 268
 
269 269
         return $flag ? $this->modx->invokeEvent($name, $data) : false;
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
     /**
273 273
      * @return $this
274 274
      */
275
-    final public function clearLog()
276
-    {
275
+    final public function clearLog()
276
+    {
277 277
         $this->log = array();
278 278
 
279 279
         return $this;
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
     /**
283 283
      * @return array
284 284
      */
285
-    final public function getLog()
286
-    {
285
+    final public function getLog()
286
+    {
287 287
         return $this->log;
288 288
     }
289 289
 
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
      * @param bool $flush
292 292
      * @return $this
293 293
      */
294
-    final public function list_log($flush = false)
295
-    {
294
+    final public function list_log($flush = false)
295
+    {
296 296
         echo '<pre>' . print_r(APIHelpers::sanitarTag($this->log), true) . '</pre>';
297
-        if ($flush) {
297
+        if ($flush) {
298 298
             $this->clearLog();
299 299
         }
300 300
 
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
      * @param bool $full
306 306
      * @return string
307 307
      */
308
-    final public function getCachePath($full = true)
309
-    {
308
+    final public function getCachePath($full = true)
309
+    {
310 310
         $path = $this->modx->getCachePath();
311
-        if ($full) {
311
+        if ($full) {
312 312
             $path = MODX_BASE_PATH . substr($path, strlen(MODX_BASE_URL));
313 313
         }
314 314
 
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
      * @param null|boolean $fire_events
320 320
      * @param bool $custom
321 321
      */
322
-    final public function clearCache($fire_events = false, $custom = false)
323
-    {
322
+    final public function clearCache($fire_events = false, $custom = false)
323
+    {
324 324
         $IDs = array();
325
-        if ($custom === false) {
325
+        if ($custom === false) {
326 326
             $this->modx->clearCache();
327 327
             include_once(MODX_MANAGER_PATH . 'processors/cache_sync.class.processor.php');
328 328
             $sync = new synccache();
@@ -330,22 +330,22 @@  discard block
 block discarded – undo
330 330
             $sync->setCachepath($path);
331 331
             $sync->setReport(false);
332 332
             $sync->emptyCache();
333
-        } else {
334
-            if (is_scalar($custom)) {
333
+        } else {
334
+            if (is_scalar($custom)) {
335 335
                 $custom = array($custom);
336 336
             }
337
-            switch ($this->modx->config['cache_type']) {
337
+            switch ($this->modx->config['cache_type']) {
338 338
                 case 2:
339 339
                     $cacheFile = "_*.pageCache.php";
340 340
                     break;
341 341
                 default:
342 342
                     $cacheFile = ".pageCache.php";
343 343
             }
344
-            if (is_array($custom)) {
345
-                foreach ($custom as $id) {
344
+            if (is_array($custom)) {
345
+                foreach ($custom as $id) {
346 346
                     $tmp = glob(MODX_BASE_PATH . "assets/cache/docid_" . $id . $cacheFile);
347
-                    foreach ($tmp as $file) {
348
-                        if (is_readable($file)) {
347
+                    foreach ($tmp as $file) {
348
+                        if (is_readable($file)) {
349 349
                             unlink($file);
350 350
                         }
351 351
                         $IDs[] = $id;
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
      * @param integer $id
362 362
      * @return MODxAPI
363 363
      */
364
-    public function switchObject($id)
365
-    {
366
-        switch (true) {
364
+    public function switchObject($id)
365
+    {
366
+        switch (true) {
367 367
             //Если загружен другой объект - не тот, с которым мы хотим временно поработать
368 368
             case ($this->getID() != $id && $id):
369 369
                 $obj = clone $this;
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
      * @param bool $flag
386 386
      * @return $this
387 387
      */
388
-    public function useIgnore($flag = true)
389
-    {
388
+    public function useIgnore($flag = true)
389
+    {
390 390
         $this->ignoreError = $flag ? 'IGNORE' : '';
391 391
 
392 392
         return $this;
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
     /**
396 396
      * @return bool
397 397
      */
398
-    public function hasIgnore()
399
-    {
398
+    public function hasIgnore()
399
+    {
400 400
         return (bool)$this->ignoreError;
401 401
     }
402 402
 
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
      * @param $value
406 406
      * @return $this
407 407
      */
408
-    public function set($key, $value)
409
-    {
410
-        if ((is_scalar($value) || $this->isJsonField($key)) && is_scalar($key) && !empty($key)) {
408
+    public function set($key, $value)
409
+    {
410
+        if ((is_scalar($value) || $this->isJsonField($key)) && is_scalar($key) && !empty($key)) {
411 411
             $this->field[$key] = $value;
412 412
         }
413 413
 
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
     /**
418 418
      * @return null|int
419 419
      */
420
-    final public function getID()
421
-    {
420
+    final public function getID()
421
+    {
422 422
         return $this->id;
423 423
     }
424 424
 
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
      * @param $key
427 427
      * @return mixed
428 428
      */
429
-    public function get($key)
430
-    {
429
+    public function get($key)
430
+    {
431 431
         return APIHelpers::getkey($this->field, $key, null);
432 432
     }
433 433
 
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
      * @param $data
436 436
      * @return $this
437 437
      */
438
-    public function fromArray($data)
439
-    {
440
-        if (is_array($data)) {
441
-            foreach ($data as $key => $value) {
438
+    public function fromArray($data)
439
+    {
440
+        if (is_array($data)) {
441
+            foreach ($data as $key => $value) {
442 442
                 $this->set($key, $value);
443 443
             }
444 444
         }
@@ -452,22 +452,22 @@  discard block
 block discarded – undo
452 452
      * @return $this
453 453
      * @throws Exception
454 454
      */
455
-    final protected function Uset($key, $id = '')
456
-    {
457
-        if (!isset($this->field[$key])) {
455
+    final protected function Uset($key, $id = '')
456
+    {
457
+        if (!isset($this->field[$key])) {
458 458
             $tmp = "`{$key}`=''";
459 459
             $this->log[] = "{$key} is empty";
460
-        } else {
461
-            if ($this->issetField($key) && is_scalar($this->field[$key])) {
460
+        } else {
461
+            if ($this->issetField($key) && is_scalar($this->field[$key])) {
462 462
                 $tmp = "`{$key}`='{$this->escape($this->field[$key])}'";
463
-            } else {
463
+            } else {
464 464
                 throw new Exception("{$key} is invalid <pre>" . print_r($this->field[$key], true) . "</pre>");
465 465
             }
466 466
         }
467
-        if (!empty($tmp)) {
468
-            if ($id == '') {
467
+        if (!empty($tmp)) {
468
+            if ($id == '') {
469 469
                 $this->set[] = $tmp;
470
-            } else {
470
+            } else {
471 471
                 $this->set[$id][] = $tmp;
472 472
             }
473 473
         }
@@ -482,23 +482,24 @@  discard block
 block discarded – undo
482 482
      * @return array
483 483
      * @throws Exception
484 484
      */
485
-    final public function cleanIDs($IDs, $sep = ',', $ignore = array())
486
-    {
485
+    final public function cleanIDs($IDs, $sep = ',', $ignore = array())
486
+    {
487 487
         $out = array();
488
-        if (!is_array($IDs)) {
489
-            if (is_scalar($IDs)) {
488
+        if (!is_array($IDs)) {
489
+            if (is_scalar($IDs)) {
490 490
                 $IDs = explode($sep, $IDs);
491
-            } else {
491
+            } else {
492 492
                 $IDs = array();
493 493
                 throw new Exception('Invalid IDs list <pre>' . print_r($IDs, 1) . '</pre>');
494 494
             }
495 495
         }
496
-        foreach ($IDs as $item) {
496
+        foreach ($IDs as $item) {
497 497
             $item = trim($item);
498
-            if (is_scalar($item) && (int)$item >= 0) { //Fix 0xfffffffff
499
-                if (!empty($ignore) && in_array((int)$item, $ignore, true)) {
498
+            if (is_scalar($item) && (int)$item >= 0) {
499
+//Fix 0xfffffffff
500
+                if (!empty($ignore) && in_array((int)$item, $ignore, true)) {
500 501
                     $this->log[] = 'Ignore id ' . (int)$item;
501
-                } else {
502
+                } else {
502 503
                     $out[] = (int)$item;
503 504
                 }
504 505
             }
@@ -514,26 +515,26 @@  discard block
 block discarded – undo
514 515
      * @return $this
515 516
      * @throws Exception
516 517
      */
517
-    final public function fromJson($data, $callback = null)
518
-    {
519
-        if (is_scalar($data) && !empty($data)) {
518
+    final public function fromJson($data, $callback = null)
519
+    {
520
+        if (is_scalar($data) && !empty($data)) {
520 521
             $json = json_decode($data);
521
-        } else {
522
+        } else {
522 523
             throw new Exception("json is not string with json data");
523 524
         }
524 525
 
525
-        if ($this->jsonError($json)) {
526
-            if (isset($callback) && is_callable($callback)) {
526
+        if ($this->jsonError($json)) {
527
+            if (isset($callback) && is_callable($callback)) {
527 528
                 call_user_func_array($callback, array($json));
528
-            } else {
529
-                if (isset($callback)) {
529
+            } else {
530
+                if (isset($callback)) {
530 531
                     throw new Exception("Can't call callback JSON unpack <pre>" . print_r($callback, 1) . "</pre>");
531 532
                 }
532
-                foreach ($json as $key => $val) {
533
+                foreach ($json as $key => $val) {
533 534
                     $this->set($key, $val);
534 535
                 }
535 536
             }
536
-        } else {
537
+        } else {
537 538
             throw new Exception('Error from JSON decode: <pre>' . print_r($data, 1) . '</pre>');
538 539
         }
539 540
 
@@ -545,19 +546,19 @@  discard block
 block discarded – undo
545 546
      * @return string
546 547
      * @throws Exception
547 548
      */
548
-    final public function toJson($callback = null)
549
-    {
549
+    final public function toJson($callback = null)
550
+    {
550 551
         $data = $this->toArray();
551
-        if (isset($callback) && is_callable($callback)) {
552
+        if (isset($callback) && is_callable($callback)) {
552 553
             $data = call_user_func_array($callback, array($data));
553
-        } else {
554
-            if (isset($callback)) {
554
+        } else {
555
+            if (isset($callback)) {
555 556
                 throw new Exception("Can't call callback JSON pre pack <pre>" . print_r($callback, 1) . "</pre>");
556 557
             }
557 558
         }
558 559
         $json = json_encode($data);
559 560
 
560
-        if ($this->jsonError($data)) {
561
+        if ($this->jsonError($data)) {
561 562
             throw new Exception('Error from JSON decode: <pre>' . print_r($data, 1) . '</pre>');
562 563
         }
563 564
 
@@ -568,10 +569,10 @@  discard block
 block discarded – undo
568 569
      * @param $data
569 570
      * @return bool
570 571
      */
571
-    final protected function jsonError($data)
572
-    {
572
+    final protected function jsonError($data)
573
+    {
573 574
         $flag = false;
574
-        if (json_last_error() === JSON_ERROR_NONE && is_object($data) && $data instanceof stdClass) {
575
+        if (json_last_error() === JSON_ERROR_NONE && is_object($data) && $data instanceof stdClass) {
575 576
             $flag = true;
576 577
         }
577 578
 
@@ -584,25 +585,25 @@  discard block
 block discarded – undo
584 585
      * @param string $sep
585 586
      * @return array
586 587
      */
587
-    public function toArray($prefix = '', $suffix = '', $sep = '_')
588
-    {
588
+    public function toArray($prefix = '', $suffix = '', $sep = '_')
589
+    {
589 590
         $tpl = '';
590 591
         $plh = '[+key+]';
591
-        if ($prefix !== '') {
592
+        if ($prefix !== '') {
592 593
             $tpl = $prefix . $sep;
593 594
         }
594 595
         $tpl .= $plh;
595
-        if ($suffix !== '') {
596
+        if ($suffix !== '') {
596 597
             $tpl .= $sep . $suffix;
597 598
         }
598 599
         $out = array();
599 600
         $fields = $this->field;
600 601
         $fields[$this->fieldPKName()] = $this->getID();
601
-        if ($tpl != $plh) {
602
-            foreach ($fields as $key => $value) {
602
+        if ($tpl != $plh) {
603
+            foreach ($fields as $key => $value) {
603 604
                 $out[str_replace($plh, $key, $tpl)] = $value;
604 605
             }
605
-        } else {
606
+        } else {
606 607
             $out = $fields;
607 608
         }
608 609
 
@@ -612,8 +613,8 @@  discard block
 block discarded – undo
612 613
     /**
613 614
      * @return string
614 615
      */
615
-    final public function fieldPKName()
616
-    {
616
+    final public function fieldPKName()
617
+    {
617 618
         return $this->pkName;
618 619
     }
619 620
 
@@ -621,8 +622,8 @@  discard block
 block discarded – undo
621 622
      * @param $table
622 623
      * @return mixed|string
623 624
      */
624
-    final public function makeTable($table)
625
-    {
625
+    final public function makeTable($table)
626
+    {
626 627
         //Без использования APIHelpers::getkey(). Иначе getFullTableName будет всегда выполняться
627 628
         return (isset($this->_table[$table])) ? $this->_table[$table] : $this->modx->getFullTableName($table);
628 629
     }
@@ -632,14 +633,14 @@  discard block
 block discarded – undo
632 633
      * @param string $sep
633 634
      * @return array|string
634 635
      */
635
-    final public function sanitarIn($data, $sep = ',')
636
-    {
637
-        if (!is_array($data)) {
636
+    final public function sanitarIn($data, $sep = ',')
637
+    {
638
+        if (!is_array($data)) {
638 639
             $data = explode($sep, $data);
639 640
         }
640 641
         $out = array();
641
-        foreach ($data as $item) {
642
-            if ($item !== '') {
642
+        foreach ($data as $item) {
643
+            if ($item !== '') {
643 644
                 $out[] = $this->escape($item);
644 645
             }
645 646
         }
@@ -654,34 +655,34 @@  discard block
 block discarded – undo
654 655
      * @param string $PK
655 656
      * @return bool
656 657
      */
657
-    public function checkUnique($table, $field, $PK = 'id')
658
-    {
659
-        if (is_array($field)) {
658
+    public function checkUnique($table, $field, $PK = 'id')
659
+    {
660
+        if (is_array($field)) {
660 661
             $where = array();
661
-            foreach ($field as $_field) {
662
+            foreach ($field as $_field) {
662 663
                 $val = $this->get($_field);
663
-                if ($val != '') {
664
+                if ($val != '') {
664 665
                     $where[] = "`" . $this->escape($_field) . "` = '" . $this->escape($val) . "'";
665 666
                 }
666 667
             }
667 668
             $where = implode(' AND ', $where);
668
-        } else {
669
+        } else {
669 670
             $where = '';
670 671
             $val = $this->get($field);
671
-            if ($val != '') {
672
+            if ($val != '') {
672 673
                 $where = "`" . $this->escape($field) . "` = '" . $this->escape($val) . "'";
673 674
             }
674 675
         }
675 676
 
676
-        if ($where != '') {
677
+        if ($where != '') {
677 678
             $sql = $this->query("SELECT `" . $this->escape($PK) . "` FROM " . $this->makeTable($table) . " WHERE " . $where);
678 679
             $id = $this->modx->db->getValue($sql);
679
-            if (is_null($id) || (!$this->newDoc && $id == $this->getID())) {
680
+            if (is_null($id) || (!$this->newDoc && $id == $this->getID())) {
680 681
                 $flag = true;
681
-            } else {
682
+            } else {
682 683
                 $flag = false;
683 684
             }
684
-        } else {
685
+        } else {
685 686
             $flag = false;
686 687
         }
687 688
 
@@ -692,8 +693,8 @@  discard block
 block discarded – undo
692 693
      * @param array $data
693 694
      * @return $this
694 695
      */
695
-    public function create($data = array())
696
-    {
696
+    public function create($data = array())
697
+    {
697 698
         $this->close();
698 699
         $this->fromArray($data);
699 700
 
@@ -704,8 +705,8 @@  discard block
 block discarded – undo
704 705
      * @param $id
705 706
      * @return $this
706 707
      */
707
-    public function copy($id)
708
-    {
708
+    public function copy($id)
709
+    {
709 710
         $this->edit($id)->id = 0;
710 711
         $this->newDoc = true;
711 712
 
@@ -715,8 +716,8 @@  discard block
 block discarded – undo
715 716
     /**
716 717
      *
717 718
      */
718
-    public function close()
719
-    {
719
+    public function close()
720
+    {
720 721
         $this->newDoc = true;
721 722
         $this->id = null;
722 723
         $this->field = array();
@@ -728,8 +729,8 @@  discard block
 block discarded – undo
728 729
      * @param $key
729 730
      * @return bool
730 731
      */
731
-    public function issetField($key)
732
-    {
732
+    public function issetField($key)
733
+    {
733 734
         return (is_scalar($key) && array_key_exists($key, $this->default_field));
734 735
     }
735 736
 
@@ -757,8 +758,8 @@  discard block
 block discarded – undo
757 758
      * @param $data
758 759
      * @return array|mixed|string
759 760
      */
760
-    final public function sanitarTag($data)
761
-    {
761
+    final public function sanitarTag($data)
762
+    {
762 763
         return parent::sanitarTag($this->modx->stripTags($data));
763 764
     }
764 765
 
@@ -767,17 +768,17 @@  discard block
 block discarded – undo
767 768
      * @param bool $dmi3yy
768 769
      * @return bool
769 770
      */
770
-    final protected function checkVersion($version, $dmi3yy = true)
771
-    {
771
+    final protected function checkVersion($version, $dmi3yy = true)
772
+    {
772 773
         $flag = false;
773 774
         $currentVer = $this->modx->getVersionData('version');
774
-        if (is_array($currentVer)) {
775
+        if (is_array($currentVer)) {
775 776
             $currentVer = APIHelpers::getkey($currentVer, 'version', '');
776 777
         }
777 778
         $tmp = substr($currentVer, 0, strlen($version));
778
-        if (version_compare($tmp, $version, '>=')) {
779
+        if (version_compare($tmp, $version, '>=')) {
779 780
             $flag = true;
780
-            if ($dmi3yy) {
781
+            if ($dmi3yy) {
781 782
                 $flag = (boolean)preg_match('/^' . $tmp . '(.*)\-d/', $currentVer);
782 783
             }
783 784
         }
@@ -789,10 +790,10 @@  discard block
 block discarded – undo
789 790
      * @param string $name
790 791
      * @return bool|mixed
791 792
      */
792
-    protected function eraseField($name)
793
-    {
793
+    protected function eraseField($name)
794
+    {
794 795
         $flag = false;
795
-        if (array_key_exists($name, $this->field)) {
796
+        if (array_key_exists($name, $this->field)) {
796 797
             $flag = $this->field[$name];
797 798
             unset($this->field[$name]);
798 799
         }
@@ -805,8 +806,8 @@  discard block
 block discarded – undo
805 806
      * @param  string $field имя поля
806 807
      * @return boolean
807 808
      */
808
-    public function isJsonField($field)
809
-    {
809
+    public function isJsonField($field)
810
+    {
810 811
         return (is_scalar($field) && in_array($field, $this->jsonFields));
811 812
     }
812 813
 
@@ -815,9 +816,9 @@  discard block
 block discarded – undo
815 816
      * @param  string $field имя поля
816 817
      * @return $this
817 818
      */
818
-    public function markAsDecode($field)
819
-    {
820
-        if (is_scalar($field)) {
819
+    public function markAsDecode($field)
820
+    {
821
+        if (is_scalar($field)) {
821 822
             $this->_decodedFields->set($field, false);
822 823
         }
823 824
 
@@ -829,9 +830,9 @@  discard block
 block discarded – undo
829 830
      * @param  string $field имя поля
830 831
      * @return $this
831 832
      */
832
-    public function markAsEncode($field)
833
-    {
834
-        if (is_scalar($field)) {
833
+    public function markAsEncode($field)
834
+    {
835
+        if (is_scalar($field)) {
835 836
             $this->_decodedFields->set($field, true);
836 837
         }
837 838
 
@@ -842,10 +843,10 @@  discard block
 block discarded – undo
842 843
      * Пометить все поля как запакованные
843 844
      * @return $this
844 845
      */
845
-    public function markAllEncode()
846
-    {
846
+    public function markAllEncode()
847
+    {
847 848
         $this->_decodedFields->clear();
848
-        foreach ($this->jsonFields as $field) {
849
+        foreach ($this->jsonFields as $field) {
849 850
             $this->markAsEncode($field);
850 851
         }
851 852
 
@@ -856,10 +857,10 @@  discard block
 block discarded – undo
856 857
      * Пометить все поля как распакованные
857 858
      * @return $this
858 859
      */
859
-    public function markAllDecode()
860
-    {
860
+    public function markAllDecode()
861
+    {
861 862
         $this->_decodedFields->clear();
862
-        foreach ($this->jsonFields as $field) {
863
+        foreach ($this->jsonFields as $field) {
863 864
             $this->markAsDecode($field);
864 865
         }
865 866
 
@@ -870,9 +871,9 @@  discard block
 block discarded – undo
870 871
      * Получить список не запакованных полей
871 872
      * @return DLCollection
872 873
      */
873
-    public function getNoEncodeFields()
874
-    {
875
-        return $this->_decodedFields->filter(function ($value) {
874
+    public function getNoEncodeFields()
875
+    {
876
+        return $this->_decodedFields->filter(function ($value) {
876 877
             return ($value === false);
877 878
         });
878 879
     }
@@ -881,9 +882,9 @@  discard block
 block discarded – undo
881 882
      * Получить список не распакованных полей
882 883
      * @return DLCollection
883 884
      */
884
-    public function getNoDecodeFields()
885
-    {
886
-        return $this->_decodedFields->filter(function ($value) {
885
+    public function getNoDecodeFields()
886
+    {
887
+        return $this->_decodedFields->filter(function ($value) {
887 888
             return ($value === true);
888 889
         });
889 890
     }
@@ -893,8 +894,8 @@  discard block
 block discarded – undo
893 894
      * @param  string $field имя поля
894 895
      * @return boolean
895 896
      */
896
-    public function isDecodableField($field)
897
-    {
897
+    public function isDecodableField($field)
898
+    {
898 899
         $data = $this->get($field);
899 900
 
900 901
         /**
@@ -909,8 +910,8 @@  discard block
 block discarded – undo
909 910
      * @param  string $field имя поля
910 911
      * @return boolean
911 912
      */
912
-    public function isEncodableField($field)
913
-    {
913
+    public function isEncodableField($field)
914
+    {
914 915
         /**
915 916
          * Если поле было распаковано ранее и еще не упаковано
916 917
          */
@@ -923,14 +924,14 @@  discard block
 block discarded – undo
923 924
      * @param  bool $store обновить распакованное поле
924 925
      * @return array ассоциативный массив с данными из json строки
925 926
      */
926
-    public function decodeField($field, $store = false)
927
-    {
927
+    public function decodeField($field, $store = false)
928
+    {
928 929
         $out = array();
929
-        if ($this->isDecodableField($field)) {
930
+        if ($this->isDecodableField($field)) {
930 931
             $data = $this->get($field);
931 932
             $out = jsonHelper::jsonDecode($data, array('assoc' => true), true);
932 933
         }
933
-        if ($store) {
934
+        if ($store) {
934 935
             $this->field[$field] = $out;
935 936
             $this->markAsDecode($field);
936 937
         }
@@ -942,9 +943,9 @@  discard block
 block discarded – undo
942 943
      * Декодирование всех json полей
943 944
      * @return $this
944 945
      */
945
-    protected function decodeFields()
946
-    {
947
-        foreach ($this->getNoDecodeFields() as $field => $flag) {
946
+    protected function decodeFields()
947
+    {
948
+        foreach ($this->getNoDecodeFields() as $field => $flag) {
948 949
             $this->decodeField($field, true);
949 950
         }
950 951
 
@@ -957,14 +958,14 @@  discard block
 block discarded – undo
957 958
      * @param  bool $store обновить запакованное поле
958 959
      * @return string|null json строка
959 960
      */
960
-    public function encodeField($field, $store = false)
961
-    {
961
+    public function encodeField($field, $store = false)
962
+    {
962 963
         $out = null;
963
-        if ($this->isEncodableField($field)) {
964
+        if ($this->isEncodableField($field)) {
964 965
             $data = $this->get($field);
965 966
             $out = json_encode($data);
966 967
         }
967
-        if ($store) {
968
+        if ($store) {
968 969
             $this->field[$field] = $out;
969 970
             $this->markAsEncode($field);
970 971
         }
@@ -976,9 +977,9 @@  discard block
 block discarded – undo
976 977
      * Запаковка всех json полей
977 978
      * @return $this
978 979
      */
979
-    protected function encodeFields()
980
-    {
981
-        foreach ($this->getNoEncodeFields() as $field => $flag) {
980
+    protected function encodeFields()
981
+    {
982
+        foreach ($this->getNoEncodeFields() as $field => $flag) {
982 983
             $this->encodeField($field, true);
983 984
         }
984 985
 
Please login to merge, or discard this patch.
assets/snippets/DocLister/lib/DLdebug.class.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                 'format' => $format,
89 89
                 'start'  => microtime(true) - $this->DocLister->getTimeStart()
90 90
             );
91
-            if (is_scalar($key) && !empty($key)) {
91
+            if (is_scalar($key) && ! empty($key)) {
92 92
                 $data['time'] = microtime(true);
93 93
                 $this->_calcLog[$key] = $data;
94 94
             } else {
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function updateMessage($message, $key, $format = null)
106 106
     {
107
-        if (is_scalar($key) && !empty($key) && isset($this->_calcLog[$key])) {
107
+        if (is_scalar($key) && ! empty($key) && isset($this->_calcLog[$key])) {
108 108
             $this->_calcLog[$key]['msg'] = $message;
109
-            if (!is_null($format)) {
109
+            if ( ! is_null($format)) {
110 110
                 $this->_calcLog[$key]['format'] = $format;
111 111
             }
112 112
         }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     private function _sendLogEvent($type, $message, $title = '')
167 167
     {
168
-        $title = "DocLister" . (!empty($title) ? ' - ' . $title : '');
168
+        $title = "DocLister" . ( ! empty($title) ? ' - ' . $title : '');
169 169
         $this->modx->logEvent(0, $type, $message, $title);
170 170
     }
171 171
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
                                 $msg = $this->dumpData($msg);
204 204
                                 break;
205 205
                         }
206
-                        if (!empty($title) && !is_numeric($title)) {
206
+                        if ( ! empty($title) && ! is_numeric($title)) {
207 207
                             $message .= $this->DocLister->parseChunk('@CODE:<strong>[+title+]</strong>: [+msg+]<br />',
208 208
                                 compact('msg', 'title'));
209 209
                         } else {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                     </li>';
223 223
                 $out .= $this->DocLister->parseChunk("@CODE: " . $tpl, $item);
224 224
             }
225
-            if (!empty($out)) {
225
+            if ( ! empty($out)) {
226 226
                 $out = $this->DocLister->parseChunk("@CODE:
227 227
                 <style>.dlDebug{
228 228
                     background: #eee !important;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     public function dumpData($data, $wrap = '', $charset = 'UTF-8')
280 280
     {
281 281
         $out = $this->DocLister->sanitarData(print_r($data, 1), $charset);
282
-        if (!empty($wrap) && is_string($wrap)) {
282
+        if ( ! empty($wrap) && is_string($wrap)) {
283 283
             $out = "<{$wrap}>{$out}</{$wrap}>";
284 284
         }
285 285
 
Please login to merge, or discard this patch.
Braces   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  * Class DLdebug
7 7
  */
8
-class DLdebug
9
-{
8
+class DLdebug
9
+{
10 10
     /**
11 11
      * @var array
12 12
      */
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
      * DLdebug constructor.
36 36
      * @param $DocLister
37 37
      */
38
-    public function __construct($DocLister)
39
-    {
40
-        if ($DocLister instanceof DocLister) {
38
+    public function __construct($DocLister)
39
+    {
40
+        if ($DocLister instanceof DocLister) {
41 41
             $this->DocLister = $DocLister;
42 42
             $this->modx = $this->DocLister->getMODX();
43 43
         }
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
     /**
48 48
      * @return array
49 49
      */
50
-    public function getLog()
51
-    {
50
+    public function getLog()
51
+    {
52 52
         return $this->_log;
53 53
     }
54 54
 
55 55
     /**
56 56
      * @return $this
57 57
      */
58
-    public function clearLog()
59
-    {
58
+    public function clearLog()
59
+    {
60 60
         $this->_log = array();
61 61
 
62 62
         return $this;
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
     /**
66 66
      * @return int
67 67
      */
68
-    public function countLog()
69
-    {
68
+    public function countLog()
69
+    {
70 70
         return count($this->_log);
71 71
     }
72 72
 
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
      * @param int $mode
80 80
      * @param bool $format
81 81
      */
82
-    public function debug($message, $key = null, $mode = 0, $format = false)
83
-    {
82
+    public function debug($message, $key = null, $mode = 0, $format = false)
83
+    {
84 84
         $mode = (int)$mode;
85
-        if ($mode > 0 && $this->DocLister->getDebug() >= $mode) {
85
+        if ($mode > 0 && $this->DocLister->getDebug() >= $mode) {
86 86
             $data = array(
87 87
                 'msg'    => $message,
88 88
                 'format' => $format,
89 89
                 'start'  => microtime(true) - $this->DocLister->getTimeStart()
90 90
             );
91
-            if (is_scalar($key) && !empty($key)) {
91
+            if (is_scalar($key) && !empty($key)) {
92 92
                 $data['time'] = microtime(true);
93 93
                 $this->_calcLog[$key] = $data;
94
-            } else {
94
+            } else {
95 95
                 $this->_log[$this->countLog()] = $data;
96 96
             }
97 97
         }
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
      * @param $key
103 103
      * @param null $format
104 104
      */
105
-    public function updateMessage($message, $key, $format = null)
106
-    {
107
-        if (is_scalar($key) && !empty($key) && isset($this->_calcLog[$key])) {
105
+    public function updateMessage($message, $key, $format = null)
106
+    {
107
+        if (is_scalar($key) && !empty($key) && isset($this->_calcLog[$key])) {
108 108
             $this->_calcLog[$key]['msg'] = $message;
109
-            if (!is_null($format)) {
109
+            if (!is_null($format)) {
110 110
                 $this->_calcLog[$key]['format'] = $format;
111 111
             }
112 112
         }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
      * @param null $msg
118 118
      * @param null $format
119 119
      */
120
-    public function debugEnd($key, $msg = null, $format = null)
121
-    {
122
-        if (is_scalar($key) && isset($this->_calcLog[$key], $this->_calcLog[$key]['time']) && $this->DocLister->getDebug() > 0) {
120
+    public function debugEnd($key, $msg = null, $format = null)
121
+    {
122
+        if (is_scalar($key) && isset($this->_calcLog[$key], $this->_calcLog[$key]['time']) && $this->DocLister->getDebug() > 0) {
123 123
             $this->_log[$this->countLog()] = array(
124 124
                 'msg'    => isset($msg) ? $msg : $this->_calcLog[$key]['msg'],
125 125
                 'start'  => $this->_calcLog[$key]['start'],
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
      * @param $message
136 136
      * @param string $title
137 137
      */
138
-    public function info($message, $title = '')
139
-    {
138
+    public function info($message, $title = '')
139
+    {
140 140
         $this->_sendLogEvent(1, $message, $title);
141 141
     }
142 142
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
      * @param $message
145 145
      * @param string $title
146 146
      */
147
-    public function warning($message, $title = '')
148
-    {
147
+    public function warning($message, $title = '')
148
+    {
149 149
         $this->_sendLogEvent(2, $message, $title);
150 150
     }
151 151
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
      * @param $message
154 154
      * @param string $title
155 155
      */
156
-    public function error($message, $title = '')
157
-    {
156
+    public function error($message, $title = '')
157
+    {
158 158
         $this->_sendLogEvent(3, $message, $title);
159 159
     }
160 160
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
      * @param $message
164 164
      * @param string $title
165 165
      */
166
-    private function _sendLogEvent($type, $message, $title = '')
167
-    {
166
+    private function _sendLogEvent($type, $message, $title = '')
167
+    {
168 168
         $title = "DocLister" . (!empty($title) ? ' - ' . $title : '');
169 169
         $this->modx->logEvent(0, $type, $message, $title);
170 170
     }
@@ -172,26 +172,26 @@  discard block
 block discarded – undo
172 172
     /**
173 173
      * @return string
174 174
      */
175
-    public function showLog()
176
-    {
175
+    public function showLog()
176
+    {
177 177
         $out = "";
178
-        if ($this->DocLister->getDebug() > 0 && is_array($this->_log)) {
179
-            foreach ($this->_log as $item) {
178
+        if ($this->DocLister->getDebug() > 0 && is_array($this->_log)) {
179
+            foreach ($this->_log as $item) {
180 180
                 $item['time'] = isset($item['time']) ? round(floatval($item['time']), 5) : 0;
181 181
                 $item['start'] = isset($item['start']) ? round(floatval($item['start']), 5) : 0;
182 182
 
183
-                if (isset($item['msg'])) {
184
-                    if (is_scalar($item['msg'])) {
183
+                if (isset($item['msg'])) {
184
+                    if (is_scalar($item['msg'])) {
185 185
                         $item['msg'] = array($item['msg']);
186 186
                     }
187
-                    if (is_scalar($item['format'])) {
187
+                    if (is_scalar($item['format'])) {
188 188
                         $item['format'] = array($item['format']);
189 189
                     }
190 190
                     $message = '';
191 191
                     $i = 0;
192
-                    foreach ($item['msg'] as $title => $msg) {
192
+                    foreach ($item['msg'] as $title => $msg) {
193 193
                         $format = isset($item['format'][$i]) ? $item['format'][$i] : null;
194
-                        switch ($format) {
194
+                        switch ($format) {
195 195
                             case 'sql':
196 196
                                 $msg = $this->dumpData(Formatter\SqlFormatter::format($msg), '', null);
197 197
                                 break;
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
203 203
                                 $msg = $this->dumpData($msg);
204 204
                                 break;
205 205
                         }
206
-                        if (!empty($title) && !is_numeric($title)) {
206
+                        if (!empty($title) && !is_numeric($title)) {
207 207
                             $message .= $this->DocLister->parseChunk('@CODE:<strong>[+title+]</strong>: [+msg+]<br />',
208 208
                                 compact('msg', 'title'));
209
-                        } else {
209
+                        } else {
210 210
                             $message .= $msg;
211 211
                         }
212 212
                         $i++;
213 213
                     }
214 214
                     $item['msg'] = $message;
215
-                } else {
215
+                } else {
216 216
                     $item['msg'] = '';
217 217
                 }
218 218
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                     </li>';
223 223
                 $out .= $this->DocLister->parseChunk("@CODE: " . $tpl, $item);
224 224
             }
225
-            if (!empty($out)) {
225
+            if (!empty($out)) {
226 226
                 $out = $this->DocLister->parseChunk("@CODE:
227 227
                 <style>.dlDebug{
228 228
                     background: #eee !important;
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
      * @param string $charset
277 277
      * @return string
278 278
      */
279
-    public function dumpData($data, $wrap = '', $charset = 'UTF-8')
280
-    {
279
+    public function dumpData($data, $wrap = '', $charset = 'UTF-8')
280
+    {
281 281
         $out = $this->DocLister->sanitarData(print_r($data, 1), $charset);
282
-        if (!empty($wrap) && is_string($wrap)) {
282
+        if (!empty($wrap) && is_string($wrap)) {
283 283
             $out = "<{$wrap}>{$out}</{$wrap}>";
284 284
         }
285 285
 
Please login to merge, or discard this patch.
assets/snippets/DocLister/core/extender/request.extender.inc 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if ( ! defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -111,7 +111,8 @@
 block discarded – undo
111 111
     {
112 112
         $out = false;
113 113
         if (preg_match("/^\((.*)\)$/iu", $data, $data) && isset($data[1]) && $data[1] != '') {
114
-            if ($data[1] == "*") { //Юзать если нужны массивы в суппер-глабальных массивах
114
+            if ($data[1] == "*") {
115
+//Юзать если нужны массивы в суппер-глабальных массивах
115 116
                 /**
116 117
                  * Но в таком случае в $this->param попадут все!!! элементы массива, которые были переданы
117 118
                  *
Please login to merge, or discard this patch.
assets/snippets/DocLister/core/controller/onetable.php 3 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if ( ! defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
                 $where[] = "`{$this->getPK()}` IN ({$sanitarInIDs})";
214 214
             }
215 215
 
216
-            if (!empty($where)) {
216
+            if ( ! empty($where)) {
217 217
                 $where = "WHERE " . implode(" AND ", $where);
218 218
             }
219 219
             $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0));
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
         $tmpWhere = $this->getCFGDef('addWhereList', '');
243 243
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
244
-        if (!empty($tmpWhere)) {
244
+        if ( ! empty($tmpWhere)) {
245 245
             $where[] = $tmpWhere;
246 246
         }
247 247
         $sanitarInIDs = $this->sanitarIn($this->IDs);
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
                 $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))";
271 271
             }
272 272
         }
273
-        if (!empty($tmpWhere)) {
273
+        if ( ! empty($tmpWhere)) {
274 274
             $where[] = $tmpWhere;
275 275
         }
276
-        if (!empty($where)) {
276
+        if ( ! empty($where)) {
277 277
             $where = "WHERE " . implode(" AND ", $where);
278 278
         } else {
279 279
             $where = '';
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                     }
339 339
                 }
340 340
             }
341
-            if (!empty($where)) {
341
+            if ( ! empty($where)) {
342 342
                 $where = "WHERE " . implode(" AND ", $where);
343 343
             } else {
344 344
                 $where = '';
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 
364 364
         $tmp = $this->getCFGDef('addWhereFolder', '');
365 365
         $where = "`{$this->getParentField()}` IN ({$sanitarInIDs})";
366
-        if (!empty($tmp)) {
366
+        if ( ! empty($tmp)) {
367 367
             $where .= " AND " . $tmp;
368 368
         }
369 369
 
Please login to merge, or discard this patch.
Braces   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if (!defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
  * @param contentField =`description` //content
15 15
  * @param table =`` //table name
16 16
  */
17
-class onetableDocLister extends DocLister
18
-{
17
+class onetableDocLister extends DocLister
18
+{
19 19
     /**
20 20
      * @var string
21 21
      */
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
     /**
35 35
      * @absctract
36 36
      */
37
-    public function getDocs($tvlist = '')
38
-    {
39
-        if ($this->checkExtender('paginate')) {
37
+    public function getDocs($tvlist = '')
38
+    {
39
+        if ($this->checkExtender('paginate')) {
40 40
             $this->extender['paginate']->init($this);
41
-        } else {
41
+        } else {
42 42
             $this->setConfig(array('start' => 0));
43 43
         }
44 44
         $type = $this->getCFGDef('idType', 'parents');
@@ -51,25 +51,25 @@  discard block
 block discarded – undo
51 51
      * @param string $tpl
52 52
      * @return string
53 53
      */
54
-    public function _render($tpl = '')
55
-    {
54
+    public function _render($tpl = '')
55
+    {
56 56
         $out = '';
57
-        if ($tpl == '') {
57
+        if ($tpl == '') {
58 58
             $tpl = $this->getCFGDef('tpl', '');
59 59
         }
60
-        if ($tpl != '') {
60
+        if ($tpl != '') {
61 61
             $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.
62 62
 
63 63
             $i = 1;
64 64
             $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl"));
65 65
             $noneTPL = $this->getCFGDef("noneTPL", "");
66
-            if (count($this->_docs) == 0 && $noneTPL != '') {
66
+            if (count($this->_docs) == 0 && $noneTPL != '') {
67 67
                 $out = $this->parseChunk($noneTPL, $sysPlh);
68
-            } else {
68
+            } else {
69 69
                 /**
70 70
                  * @var $extUser user_DL_Extender
71 71
                  */
72
-                if ($extUser = $this->getExtender('user')) {
72
+                if ($extUser = $this->getExtender('user')) {
73 73
                     $extUser->init($this, array('fields' => $this->getCFGDef("userFields", "")));
74 74
                 }
75 75
 
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
                  */
84 84
                 $extPrepare = $this->getExtender('prepare');
85 85
                 $this->skippedDocs = 0;
86
-                foreach ($this->_docs as $item) {
86
+                foreach ($this->_docs as $item) {
87 87
                     $this->renderTPL = $tpl;
88
-                    if ($extUser) {
88
+                    if ($extUser) {
89 89
                         $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+]....
90 90
                     }
91 91
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
                     $date = $this->getCFGDef('dateSource', 'pub_date');
101 101
                     $date = isset($item[$date]) ? $item[$date] + $this->modx->config['server_offset_time'] : '';
102
-                    if ($date != '' && $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
102
+                    if ($date != '' && $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
103 103
                         $item[$this->getCFGDef("sysKey", "dl") . '.date'] = strftime($this->getCFGDef('dateFormat',
104 104
                             '%d.%b.%y %H:%M'), $date);
105 105
                     }
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
                     $findTpl = $this->renderTPL;
108 108
                     $tmp = $this->uniformPrepare($item, $i);
109 109
                     extract($tmp, EXTR_SKIP);
110
-                    if ($this->renderTPL == '') {
110
+                    if ($this->renderTPL == '') {
111 111
                         $this->renderTPL = $findTpl;
112 112
                     }
113 113
 
114
-                    if ($extPrepare) {
114
+                    if ($extPrepare) {
115 115
                         $item = $extPrepare->init($this, array(
116 116
                             'data'      => $item,
117 117
                             'nameParam' => 'prepare'
118 118
                         ));
119
-                        if (is_bool($item) && $item === false) {
119
+                        if (is_bool($item) && $item === false) {
120 120
                             $this->skippedDocs++;
121 121
                             continue;
122 122
                         }
123 123
                     }
124 124
                     $tmp = $this->parseChunk($this->renderTPL, $item);
125
-                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
125
+                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
126 126
                         $this->toPlaceholders($tmp, 1,
127 127
                             "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page
128 128
                     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                 }
132 132
             }
133 133
             $out = $this->renderWrap($out);
134
-        } else {
134
+        } else {
135 135
             $out = 'none TPL';
136 136
         }
137 137
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
      * @param array $array
145 145
      * @return string
146 146
      */
147
-    public function getJSON($data, $fields, $array = array())
148
-    {
147
+    public function getJSON($data, $fields, $array = array())
148
+    {
149 149
         $out = array();
150 150
         $fields = is_array($fields) ? $fields : explode(",", $fields);
151 151
         $date = $this->getCFGDef('dateSource', 'pub_date');
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
          */
166 166
         $extE = $this->getExtender('e', true, true);
167 167
 
168
-        foreach ($data as $num => $item) {
168
+        foreach ($data as $num => $item) {
169 169
             $row = $item;
170 170
 
171
-            switch (true) {
171
+            switch (true) {
172 172
                 case ((array('1') == $fields || in_array('summary', $fields)) && $extSummary):
173 173
                     $row['summary'] = $this->getSummary($this->_docs[$num], $extSummary, 'introtext');
174 174
                 //without break
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
                 // no break
180 180
             }
181 181
 
182
-            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
183
-                if (is_array($tmp)) {
182
+            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
183
+                if (is_array($tmp)) {
184 184
                     $row = $tmp;
185 185
                 }
186 186
             }
187 187
 
188
-            if ($extPrepare) {
188
+            if ($extPrepare) {
189 189
                 $row = $extPrepare->init($this, array('data' => $row));
190
-                if (is_bool($row) && $row === false) {
190
+                if (is_bool($row) && $row === false) {
191 191
                     continue;
192 192
                 }
193 193
             }
@@ -200,20 +200,20 @@  discard block
 block discarded – undo
200 200
     /**
201 201
      * @return array
202 202
      */
203
-    protected function getDocList()
204
-    {
203
+    protected function getDocList()
204
+    {
205 205
         $out = array();
206 206
         $sanitarInIDs = $this->sanitarIn($this->IDs);
207
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
207
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
208 208
             $where = $this->getCFGDef('addWhereList', '');
209
-            if ($where != '') {
209
+            if ($where != '') {
210 210
                 $where = array($where);
211 211
             }
212
-            if ($sanitarInIDs != "''") {
212
+            if ($sanitarInIDs != "''") {
213 213
                 $where[] = "`{$this->getPK()}` IN ({$sanitarInIDs})";
214 214
             }
215 215
 
216
-            if (!empty($where)) {
216
+            if (!empty($where)) {
217 217
                 $where = "WHERE " . implode(" AND ", $where);
218 218
             }
219 219
             $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0));
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
             $rows = $this->modx->db->makeArray($rs);
225 225
             $out = array();
226
-            foreach ($rows as $item) {
226
+            foreach ($rows as $item) {
227 227
                 $out[$item[$this->getPK()]] = $item;
228 228
             }
229 229
         }
@@ -234,22 +234,22 @@  discard block
 block discarded – undo
234 234
     /**
235 235
      * @return array
236 236
      */
237
-    protected function getChildrenList()
238
-    {
237
+    protected function getChildrenList()
238
+    {
239 239
         $where = array();
240 240
         $out = array();
241 241
 
242 242
         $tmpWhere = $this->getCFGDef('addWhereList', '');
243 243
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
244
-        if (!empty($tmpWhere)) {
244
+        if (!empty($tmpWhere)) {
245 245
             $where[] = $tmpWhere;
246 246
         }
247 247
         $sanitarInIDs = $this->sanitarIn($this->IDs);
248 248
 
249 249
         $tmpWhere = null;
250
-        if ($sanitarInIDs != "''") {
250
+        if ($sanitarInIDs != "''") {
251 251
             $tmpWhere = "(`{$this->getParentField()}` IN (" . $sanitarInIDs . ")";
252
-            switch ($this->getCFGDef('showParent', '0')) {
252
+            switch ($this->getCFGDef('showParent', '0')) {
253 253
                 case -1:
254 254
                     $tmpWhere .= ")";
255 255
                     break;
@@ -262,32 +262,32 @@  discard block
 block discarded – undo
262 262
                     break;
263 263
             }
264 264
         }
265
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
265
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
266 266
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
267
-            if (empty($tmpWhere)) {
267
+            if (empty($tmpWhere)) {
268 268
                 $tmpWhere = $this->getPK() . " IN({$addDocs})";
269
-            } else {
269
+            } else {
270 270
                 $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))";
271 271
             }
272 272
         }
273
-        if (!empty($tmpWhere)) {
273
+        if (!empty($tmpWhere)) {
274 274
             $where[] = $tmpWhere;
275 275
         }
276
-        if (!empty($where)) {
276
+        if (!empty($where)) {
277 277
             $where = "WHERE " . implode(" AND ", $where);
278
-        } else {
278
+        } else {
279 279
             $where = '';
280 280
         }
281 281
         $fields = $this->getCFGDef('selectFields', '*');
282 282
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', "`{$this->getPK()}`"));
283
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
283
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
284 284
             $sql = $this->dbQuery("SELECT {$fields} FROM " . $this->table . " " . $where . " " .
285 285
                 $group . " " .
286 286
                 $this->SortOrderSQL($this->getPK()) . " " .
287 287
                 $this->LimitSQL($this->getCFGDef('queryLimit', 0))
288 288
             );
289 289
             $rows = $this->modx->db->makeArray($sql);
290
-            foreach ($rows as $item) {
290
+            foreach ($rows as $item) {
291 291
                 $out[$item[$this->getPK()]] = $item;
292 292
             }
293 293
         }
@@ -298,22 +298,22 @@  discard block
 block discarded – undo
298 298
     /**
299 299
      * @absctract
300 300
      */
301
-    public function getChildrenCount()
302
-    {
301
+    public function getChildrenCount()
302
+    {
303 303
         $out = 0;
304 304
         $sanitarInIDs = $this->sanitarIn($this->IDs);
305
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
305
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
306 306
             $where = $this->getCFGDef('addWhereList', '');
307
-            if ($where != '') {
307
+            if ($where != '') {
308 308
                 $where = array($where);
309
-            } else {
309
+            } else {
310 310
                 $where = array();
311 311
             }
312
-            if ($sanitarInIDs != "''") {
313
-                if ($sanitarInIDs != "''") {
314
-                    switch ($this->getCFGDef('idType', 'parents')) {
312
+            if ($sanitarInIDs != "''") {
313
+                if ($sanitarInIDs != "''") {
314
+                    switch ($this->getCFGDef('idType', 'parents')) {
315 315
                         case 'parents':
316
-                            switch ($this->getCFGDef('showParent', '0')) {
316
+                            switch ($this->getCFGDef('showParent', '0')) {
317 317
                                 case '-1':
318 318
                                     $tmpWhere = "`{$this->getParentField()}` IN ({$sanitarInIDs})";
319 319
                                     break;
@@ -325,10 +325,10 @@  discard block
 block discarded – undo
325 325
                                     $tmpWhere = "(`{$this->getParentField()}` IN ({$sanitarInIDs}) OR `{$this->getPK()}` IN({$sanitarInIDs}))";
326 326
                                     break;
327 327
                             }
328
-                            if (($addDocs = $this->getCFGDef('documents', '')) != '') {
328
+                            if (($addDocs = $this->getCFGDef('documents', '')) != '') {
329 329
                                 $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
330 330
                                 $where[] = "((" . $tmpWhere . ") OR `{$this->getPK()}` IN({$addDocs}))";
331
-                            } else {
331
+                            } else {
332 332
                                 $where[] = $tmpWhere;
333 333
                             }
334 334
                             break;
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
                     }
339 339
                 }
340 340
             }
341
-            if (!empty($where)) {
341
+            if (!empty($where)) {
342 342
                 $where = "WHERE " . implode(" AND ", $where);
343
-            } else {
343
+            } else {
344 344
                 $where = '';
345 345
             }
346 346
 
@@ -357,13 +357,13 @@  discard block
 block discarded – undo
357 357
      * @param string $id
358 358
      * @return array
359 359
      */
360
-    public function getChildrenFolder($id)
361
-    {
360
+    public function getChildrenFolder($id)
361
+    {
362 362
         $sanitarInIDs = $this->sanitarIn($id);
363 363
 
364 364
         $tmp = $this->getCFGDef('addWhereFolder', '');
365 365
         $where = "`{$this->getParentField()}` IN ({$sanitarInIDs})";
366
-        if (!empty($tmp)) {
366
+        if (!empty($tmp)) {
367 367
             $where .= " AND " . $tmp;
368 368
         }
369 369
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
         $rows = $this->modx->db->makeArray($rs);
373 373
         $out = array();
374
-        foreach ($rows as $item) {
374
+        foreach ($rows as $item) {
375 375
             $out[] = $item[$this->getPK()];
376 376
         }
377 377
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
             $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0));
220 220
             $fields = $this->getCFGDef('selectFields', '*');
221 221
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', ''));
222
-            $rs = $this->dbQuery("SELECT {$fields} FROM {$this->table} {$where} {$group} {$this->SortOrderSQL($this->getPK())} {$limit}");
222
+            $rs = $this->dbQuery("select {$fields} FROM {$this->table} {$where} {$group} {$this->SortOrderSQL($this->getPK())} {$limit}");
223 223
 
224 224
             $rows = $this->modx->db->makeArray($rs);
225 225
             $out = array();
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
         $fields = $this->getCFGDef('selectFields', '*');
282 282
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', "`{$this->getPK()}`"));
283 283
         if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
284
-            $sql = $this->dbQuery("SELECT {$fields} FROM " . $this->table . " " . $where . " " .
284
+            $sql = $this->dbQuery("select {$fields} FROM " . $this->table . " " . $where . " " .
285 285
                 $group . " " .
286 286
                 $this->SortOrderSQL($this->getPK()) . " " .
287 287
                 $this->LimitSQL($this->getCFGDef('queryLimit', 0))
Please login to merge, or discard this patch.
assets/lib/Module/Action.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public static function listValue()
76 76
     {
77
-        $out = self::_workValue(function ($data, $modObj) {
77
+        $out = self::_workValue(function($data, $modObj) {
78 78
             $listFunction = $data['key'] . 'Lists';
79 79
             $out = method_exists($modObj, $listFunction) ? $modObj->$listFunction() : array();
80 80
             $out['selected'] = $modObj->get($data['key']);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         self::$TPL = 'ajax/getValue';
96 96
         $data = Helper::jeditable('data');
97 97
         $out = array();
98
-        if (!empty($data)) {
98
+        if ( ! empty($data)) {
99 99
             $modObj = self::$classTable;
100 100
             $modObj->edit($data['id']);
101 101
             if ($modObj->getID() && ((is_object($callback) && ($callback instanceof \Closure)) || is_callable($callback))) {
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public static function saveValue()
113 113
     {
114
-        return self::_workValue(function ($data, $modObj) {
114
+        return self::_workValue(function($data, $modObj) {
115 115
             $out = array();
116 116
             if (isset($_POST['value']) && is_scalar($_POST['value'])) {
117 117
                 if ($modObj->set($data['key'], $_POST['value'])->save()) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public static function getValue()
135 135
     {
136
-        return self::_workValue(function ($data, $modObj) {
136
+        return self::_workValue(function($data, $modObj) {
137 137
             return array(
138 138
                 'value' => $modObj->get($data['key'])
139 139
             );
Please login to merge, or discard this patch.
Braces   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
  * Class Action
5 5
  * @package Module
6 6
  */
7
-abstract class Action
8
-{
7
+abstract class Action
8
+{
9 9
     /**
10 10
      * Объект DocumentParser - основной класс MODX
11 11
      * @var \DocumentParser
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
     /**
21 21
      * @param \DocumentParser $modx
22 22
      */
23
-    public static function setMODX(\DocumentParser $modx)
24
-    {
23
+    public static function setMODX(\DocumentParser $modx)
24
+    {
25 25
         self::$modx = $modx;
26 26
     }
27 27
 
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
      * @param Template $tpl
31 31
      * @param \MODxAPI $classTable
32 32
      */
33
-    public static function init(\DocumentParser $modx, Template $tpl, \MODxAPI $classTable)
34
-    {
33
+    public static function init(\DocumentParser $modx, Template $tpl, \MODxAPI $classTable)
34
+    {
35 35
         self::setMODX($modx);
36 36
         self::$TPL = Template::showLog();
37 37
         self::$_tplObj = $tpl;
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * @return string
43 43
      */
44
-    public static function TABLE()
45
-    {
44
+    public static function TABLE()
45
+    {
46 46
         return static::$TABLE;
47 47
     }
48 48
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
      * @param $id
51 51
      * @return bool
52 52
      */
53
-    protected static function _checkObj($id)
54
-    {
53
+    protected static function _checkObj($id)
54
+    {
55 55
         $q = self::$modx->db->select('id', self::$modx->getFullTableName(self::TABLE()), "id = " . $id);
56 56
 
57 57
         return (self::$modx->db->getRecordCount($q) == 1);
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
      * @param $id
63 63
      * @return mixed
64 64
      */
65
-    protected static function _getValue($field, $id)
66
-    {
65
+    protected static function _getValue($field, $id)
66
+    {
67 67
         $q = self::$modx->db->select($field, self::$modx->getFullTableName(self::TABLE()), "id = " . $id);
68 68
 
69 69
         return self::$modx->db->getValue($q);
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * @return array|mixed
74 74
      */
75
-    public static function listValue()
76
-    {
77
-        $out = self::_workValue(function ($data, $modObj) {
75
+    public static function listValue()
76
+    {
77
+        $out = self::_workValue(function ($data, $modObj) {
78 78
             $listFunction = $data['key'] . 'Lists';
79 79
             $out = method_exists($modObj, $listFunction) ? $modObj->$listFunction() : array();
80 80
             $out['selected'] = $modObj->get($data['key']);
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
      * @param $callback
91 91
      * @return array|mixed
92 92
      */
93
-    protected static function _workValue($callback)
94
-    {
93
+    protected static function _workValue($callback)
94
+    {
95 95
         self::$TPL = 'ajax/getValue';
96 96
         $data = Helper::jeditable('data');
97 97
         $out = array();
98
-        if (!empty($data)) {
98
+        if (!empty($data)) {
99 99
             $modObj = self::$classTable;
100 100
             $modObj->edit($data['id']);
101
-            if ($modObj->getID() && ((is_object($callback) && ($callback instanceof \Closure)) || is_callable($callback))) {
101
+            if ($modObj->getID() && ((is_object($callback) && ($callback instanceof \Closure)) || is_callable($callback))) {
102 102
                 $out = call_user_func($callback, $data, $modObj);
103 103
             }
104 104
         }
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
     /**
110 110
      * @return array|mixed
111 111
      */
112
-    public static function saveValue()
113
-    {
114
-        return self::_workValue(function ($data, $modObj) {
112
+    public static function saveValue()
113
+    {
114
+        return self::_workValue(function ($data, $modObj) {
115 115
             $out = array();
116
-            if (isset($_POST['value']) && is_scalar($_POST['value'])) {
117
-                if ($modObj->set($data['key'], $_POST['value'])->save()) {
116
+            if (isset($_POST['value']) && is_scalar($_POST['value'])) {
117
+                if ($modObj->set($data['key'], $_POST['value'])->save()) {
118 118
                     $textMethod = $data['key'] . 'Text';
119
-                    if (method_exists($modObj, $textMethod)) {
119
+                    if (method_exists($modObj, $textMethod)) {
120 120
                         $out['value'] = $modObj->$textMethod();
121
-                    } else {
121
+                    } else {
122 122
                         $out['value'] = $modObj->get($data['key']);
123 123
                     }
124 124
                 }
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
     /**
132 132
      * @return array|mixed
133 133
      */
134
-    public static function getValue()
135
-    {
136
-        return self::_workValue(function ($data, $modObj) {
134
+    public static function getValue()
135
+    {
136
+        return self::_workValue(function ($data, $modObj) {
137 137
             return array(
138 138
                 'value' => $modObj->get($data['key'])
139 139
             );
@@ -143,21 +143,21 @@  discard block
 block discarded – undo
143 143
     /**
144 144
      * @return array
145 145
      */
146
-    public static function deleted()
147
-    {
146
+    public static function deleted()
147
+    {
148 148
         $data = array();
149 149
         $dataID = (int)Template::getParam('docId', $_GET);
150
-        if ($dataID > 0 && self::_checkObj($dataID)) {
150
+        if ($dataID > 0 && self::_checkObj($dataID)) {
151 151
             $oldValue = self::_getValue('deleted_at', $dataID);
152 152
             $q = self::$modx->db->update(array(
153 153
                 'deleted_at' => empty($oldValue) ? date('Y-m-d H:i:s') : null
154 154
             ), self::$modx->getFullTableName(self::TABLE()), "id = " . $dataID);
155
-            if ($q) {
155
+            if ($q) {
156 156
                 $data['log'] = $oldValue ? 'Запись с ID ' . $dataID . ' восстановлена' : 'Запись с ID ' . $dataID . ' удалена';
157
-            } else {
157
+            } else {
158 158
                 $data['log'] = $oldValue ? 'Не удалось восстановить запись с ID ' . $dataID : 'Не удалось удалить запись с ID ' . $dataID;
159 159
             }
160
-        } else {
160
+        } else {
161 161
             $data['log'] = '<span class="error">Ошибка</span>. Не удалось определить обновляему запись';
162 162
         }
163 163
 
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
     /**
168 168
      * 
169 169
      */
170
-    public static function lists()
171
-    {
170
+    public static function lists()
171
+    {
172 172
         self::$TPL = 'ajax/lists';
173 173
     }
174 174
 
175 175
     /**
176 176
      * @return null
177 177
      */
178
-    public static function getClassTable()
179
-    {
178
+    public static function getClassTable()
179
+    {
180 180
         return self::$classTable;
181 181
     }
182 182
 }
Please login to merge, or discard this patch.
assets/lib/Module/Helper.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         $request = $post ? $_POST : $_GET;
69 69
         $match = (isset($request[$key]) && is_scalar($request[$key]) && preg_match("/^(.*)_(\d+)$/i", $request[$key],
70 70
                 $match)) ? $match : array();
71
-        if (!empty($match)) {
71
+        if ( ! empty($match)) {
72 72
             $data = array(
73 73
                 'key' => $match[1],
74 74
                 'id'  => $match[2]
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         if ($post) {
95 95
             curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
96 96
         }
97
-        if (!empty($header)) {
97
+        if ( ! empty($header)) {
98 98
             curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
99 99
         }
100 100
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     {
114 114
         require_once(MODX_BASE_PATH . "assets/snippets/DocLister/lib/jsonHelper.class.php");
115 115
         $error = \jsonHelper::json_last_error_msg();
116
-        if (!in_array($error, array('error_none', 'other'))) {
116
+        if ( ! in_array($error, array('error_none', 'other'))) {
117 117
             $error = true;
118 118
         }
119 119
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     {
133 133
         $handle = fopen($path, "r");
134 134
         $i = $total = 0;
135
-        while (!feof($handle)) {
135
+        while ( ! feof($handle)) {
136 136
             $i++;
137 137
             $buffer = fgets($handle, $size);
138 138
             if (is_callable($callback)) {
Please login to merge, or discard this patch.
Braces   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
  * Class Helper
7 7
  * @package Module
8 8
  */
9
-class Helper extends \APIhelpers
10
-{
9
+class Helper extends \APIhelpers
10
+{
11 11
     /**
12 12
      * Объект DocumentParser - основной класс MODX
13 13
      * @var \DocumentParser
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
      * @param \DocumentParser $modx
24 24
      * @param string $mode
25 25
      */
26
-    public static function init(\DocumentParser $modx, $mode = 'list')
27
-    {
26
+    public static function init(\DocumentParser $modx, $mode = 'list')
27
+    {
28 28
         self::$modx = $modx;
29 29
         self::setMode($mode);
30 30
     }
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
     /**
33 33
      * @return string
34 34
      */
35
-    public static function getMode()
36
-    {
35
+    public static function getMode()
36
+    {
37 37
         return self::$mode;
38 38
     }
39 39
 
40 40
     /**
41 41
      * @param $text
42 42
      */
43
-    public static function setMode($text)
44
-    {
43
+    public static function setMode($text)
44
+    {
45 45
         self::$mode = $text;
46 46
     }
47 47
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
      * @param string $where
51 51
      * @return mixed
52 52
      */
53
-    protected static function _counter($from, $where = '')
54
-    {
53
+    protected static function _counter($from, $where = '')
54
+    {
55 55
         $q = self::$modx->db->select('count(id)', self::$modx->getFullTableName($from), $where);
56 56
 
57 57
         return self::$modx->db->getValue($q);
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
      * @param bool $post
63 63
      * @return array
64 64
      */
65
-    public static function jeditable($key = 'id', $post = true)
66
-    {
65
+    public static function jeditable($key = 'id', $post = true)
66
+    {
67 67
         $data = array();
68 68
         $request = $post ? $_POST : $_GET;
69 69
         $match = (isset($request[$key]) && is_scalar($request[$key]) && preg_match("/^(.*)_(\d+)$/i", $request[$key],
70 70
                 $match)) ? $match : array();
71
-        if (!empty($match)) {
71
+        if (!empty($match)) {
72 72
             $data = array(
73 73
                 'key' => $match[1],
74 74
                 'id'  => $match[2]
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
      * @param array $header
86 86
      * @return mixed
87 87
      */
88
-    public static function curl($url, $data = '', $post = false, array $header = array())
89
-    {
88
+    public static function curl($url, $data = '', $post = false, array $header = array())
89
+    {
90 90
         $ch = curl_init();
91 91
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
92 92
         $post = (bool)$post;
93 93
         curl_setopt($ch, CURLOPT_POST, $post);
94
-        if ($post) {
94
+        if ($post) {
95 95
             curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
96 96
         }
97
-        if (!empty($header)) {
97
+        if (!empty($header)) {
98 98
             curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
99 99
         }
100 100
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
      * @param $json string строка с JSON для записи в лог при отладке
110 110
      * @return bool|string
111 111
      */
112
-    public function isErrorJSON($json)
113
-    {
112
+    public function isErrorJSON($json)
113
+    {
114 114
         require_once(MODX_BASE_PATH . "assets/snippets/DocLister/lib/jsonHelper.class.php");
115 115
         $error = \jsonHelper::json_last_error_msg();
116
-        if (!in_array($error, array('error_none', 'other'))) {
116
+        if (!in_array($error, array('error_none', 'other'))) {
117 117
             $error = true;
118 118
         }
119 119
 
@@ -128,21 +128,21 @@  discard block
 block discarded – undo
128 128
      * @param int $size
129 129
      * @return array
130 130
      */
131
-    public static function readFileLine($path, $callback, array $callbackParams = array(), $lines = 0, $size = 4096)
132
-    {
131
+    public static function readFileLine($path, $callback, array $callbackParams = array(), $lines = 0, $size = 4096)
132
+    {
133 133
         $handle = fopen($path, "r");
134 134
         $i = $total = 0;
135
-        while (!feof($handle)) {
135
+        while (!feof($handle)) {
136 136
             $i++;
137 137
             $buffer = fgets($handle, $size);
138
-            if (is_callable($callback)) {
138
+            if (is_callable($callback)) {
139 139
                 $callbackParams['line'] = $buffer;
140 140
                 $callbackParams['numLine'] = $i;
141
-                if (call_user_func($callback, $callbackParams)) {
141
+                if (call_user_func($callback, $callbackParams)) {
142 142
                     $total++;
143 143
                 }
144 144
             }
145
-            if ($lines > 0 && $i >= $lines) {
145
+            if ($lines > 0 && $i >= $lines) {
146 146
                 break;
147 147
             }
148 148
         }
Please login to merge, or discard this patch.
assets/lib/Module/Template.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $this->_publicFolder = "/" . $tplFolder . "/public/";
64 64
         $this->_tplFolder = MODX_BASE_PATH . $tplFolder . "/template/";
65 65
 
66
-        if (!defined('MODX_MAIN_URL')) {
66
+        if ( ! defined('MODX_MAIN_URL')) {
67 67
             define('MODX_MAIN_URL', MODX_SITE_URL);
68 68
         }
69 69
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     protected function _getMainTpl($name)
109 109
     {
110 110
         $content = '';
111
-        if (!self::isAjax()) {
111
+        if ( ! self::isAjax()) {
112 112
 
113 113
             ob_start();
114 114
             extract($this->vars);
Please login to merge, or discard this patch.
Braces   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
  * Class Template
5 5
  * @package Module
6 6
  */
7
-abstract class Template
8
-{
7
+abstract class Template
8
+{
9 9
     /**
10 10
      * @var \DocumentParser|null
11 11
      */
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
      * @param bool $ajax
50 50
      * @param null $tplFolder
51 51
      */
52
-    public function __construct(\DocumentParser $modx, $ajax = false, $tplFolder = null)
53
-    {
52
+    public function __construct(\DocumentParser $modx, $ajax = false, $tplFolder = null)
53
+    {
54 54
         $this->_modx = $modx;
55 55
         self::$_ajax = (boolean)$ajax;
56 56
         $this->loadVars();
57
-        if (is_null($tplFolder)) {
57
+        if (is_null($tplFolder)) {
58 58
             $tplFolder = dirname(dirname(__FILE__));
59 59
         }
60 60
         $FS = \Helpers\FS::getInstance();
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $this->_publicFolder = "/" . $tplFolder . "/public/";
64 64
         $this->_tplFolder = MODX_BASE_PATH . $tplFolder . "/template/";
65 65
 
66
-        if (!defined('MODX_MAIN_URL')) {
66
+        if (!defined('MODX_MAIN_URL')) {
67 67
             define('MODX_MAIN_URL', MODX_SITE_URL);
68 68
         }
69 69
     }
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
     /**
72 72
      * @return bool
73 73
      */
74
-    public static function isAjax()
75
-    {
74
+    public static function isAjax()
75
+    {
76 76
         return self::$_ajax;
77 77
     }
78 78
 
79 79
     /**
80 80
      * @return string
81 81
      */
82
-    public function publicFolder()
83
-    {
82
+    public function publicFolder()
83
+    {
84 84
         return $this->_publicFolder;
85 85
     }
86 86
 
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
      * @param $path
89 89
      * @return string
90 90
      */
91
-    public function src($path)
92
-    {
91
+    public function src($path)
92
+    {
93 93
         return rtrim(MODX_MAIN_URL, '/') . $this->publicFolder() . ltrim($path, '/');
94 94
     }
95 95
 
96 96
     /**
97 97
      * @return string
98 98
      */
99
-    public function showHeader()
100
-    {
99
+    public function showHeader()
100
+    {
101 101
         return $this->_getMainTpl('header.inc.php');
102 102
     }
103 103
 
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
      * @param $name
106 106
      * @return string
107 107
      */
108
-    protected function _getMainTpl($name)
109
-    {
108
+    protected function _getMainTpl($name)
109
+    {
110 110
         $content = '';
111
-        if (!self::isAjax()) {
111
+        if (!self::isAjax()) {
112 112
 
113 113
             ob_start();
114 114
             extract($this->vars);
115
-            if (file_exists($incPath . $name)) {
115
+            if (file_exists($incPath . $name)) {
116 116
                 include($incPath . $name);
117 117
                 $content = ob_get_contents();
118 118
             }
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
     /**
126 126
      *
127 127
      */
128
-    public function loadVars()
129
-    {
128
+    public function loadVars()
129
+    {
130 130
         $vars = array();
131
-        foreach ($this->vars as $item) {
131
+        foreach ($this->vars as $item) {
132 132
             global $$item;
133 133
             $vars[$item] = $$item;
134 134
         }
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
     /**
141 141
      * @return string
142 142
      */
143
-    public function showFooter()
144
-    {
143
+    public function showFooter()
144
+    {
145 145
         return $this->_getMainTpl('footer.inc.php');
146 146
     }
147 147
 
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
      * @param array $tplParams
151 151
      * @return string
152 152
      */
153
-    public function showBody($TplName, array $tplParams = array())
154
-    {
153
+    public function showBody($TplName, array $tplParams = array())
154
+    {
155 155
         ob_start();
156
-        if (file_exists($this->_tplFolder . $TplName . "." . self::TPL_EXT)) {
156
+        if (file_exists($this->_tplFolder . $TplName . "." . self::TPL_EXT)) {
157 157
             extract($this->vars);
158 158
             include($this->_tplFolder . $TplName . "." . self::TPL_EXT);
159 159
         }
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
      * @param null $default
170 170
      * @return mixed|null
171 171
      */
172
-    public static function getParam($key, array $param = array(), $default = null)
173
-    {
172
+    public static function getParam($key, array $param = array(), $default = null)
173
+    {
174 174
         return isset($param[$key]) ? $param[$key] : $default;
175 175
     }
176 176
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
      * @param bool $full
182 182
      * @return string
183 183
      */
184
-    public function makeUrl($action, array $data = array(), $module = null, $full = false)
185
-    {
184
+    public function makeUrl($action, array $data = array(), $module = null, $full = false)
185
+    {
186 186
         $action = is_scalar($action) ? $action : '';
187 187
         $content = self::getParam('content', $this->vars, array());
188 188
         $data = array_merge(
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             )
198 198
         );
199 199
         $out = implode("?", array($this->_modx->getManagerPath(), http_build_query($data)));
200
-        if ($full) {
200
+        if ($full) {
201 201
             $out = $this->_modx->getConfig('site_url') . ltrim($out, '/');
202 202
         }
203 203
 
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
     /**
208 208
      * @return string
209 209
      */
210
-    public static function showLog()
211
-    {
210
+    public static function showLog()
211
+    {
212 212
         return self::isAjax() ? 'log' : 'main';
213 213
     }
214 214
 
Please login to merge, or discard this patch.
assets/lib/MODxAPI/modChunk.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 /**
5 5
  * Class modChunk
6 6
  */
7
-class modChunk extends autoTable
8
-{
7
+class modChunk extends autoTable
8
+{
9 9
     /**
10 10
      * @var string
11 11
      */
Please login to merge, or discard this patch.