Completed
Push — master ( 221463...5e5b97 )
by Agel_Nash
02:58
created
assets/lib/MODxAPI/modResource.php 2 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     }
310 310
 
311 311
     /**
312
-     * @param $key
312
+     * @param string $key
313 313
      * @param $value
314 314
      * @return $this
315 315
      */
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
     }
406 406
 
407 407
     /**
408
-     * @param $data
409
-     * @return bool|string
408
+     * @param integer $data
409
+     * @return string|false
410 410
      */
411 411
     protected function findUserBy($data)
412 412
     {
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 
661 661
     /**
662 662
      * @param $ids
663
-     * @param int|bool $depth
663
+     * @param boolean $depth
664 664
      * @return array
665 665
      */
666 666
     public function childrens($ids, $depth)
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
     }
714 714
 
715 715
     /**
716
-     * @return array
716
+     * @return integer[]
717 717
      */
718 718
     private function systemID()
719 719
     {
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
     }
831 831
 
832 832
     /**
833
-     * @param $tpl
833
+     * @param string $tpl
834 834
      * @return int
835 835
      * @throws Exception
836 836
      */
Please login to merge, or discard this patch.
Braces   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 /**
5 5
  * Class modResource
6 6
  */
7
-class modResource extends MODxAPI
8
-{
7
+class modResource extends MODxAPI
8
+{
9 9
     /**
10 10
      * @var string
11 11
      */
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
      * @param DocumentParser $modx
156 156
      * @param bool $debug
157 157
      */
158
-    public function __construct($modx, $debug = false)
159
-    {
158
+    public function __construct($modx, $debug = false)
159
+    {
160 160
         parent::__construct($modx, $debug);
161 161
         $this->get_TV();
162 162
         $uTable = $this->makeTable("manager_users");
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
     /**
170 170
      * @return array
171 171
      */
172
-    public function toArrayMain()
173
-    {
172
+    public function toArrayMain()
173
+    {
174 174
         $out = array_intersect_key(parent::toArray(), $this->default_field);
175 175
 
176 176
         return $out;
@@ -180,18 +180,18 @@  discard block
 block discarded – undo
180 180
      * @param bool $render
181 181
      * @return array
182 182
      */
183
-    public function toArrayTV($render = false)
184
-    {
183
+    public function toArrayTV($render = false)
184
+    {
185 185
         $out = array_diff_key(parent::toArray(), $this->default_field);
186 186
         $tpl = $this->get('template');
187 187
         $tvTPL = APIHelpers::getkey($this->tvTpl, $tpl, array());
188
-        foreach ($tvTPL as $item) {
189
-            if (isset($this->tvid[$item]) && !array_key_exists($this->tvid[$item], $out)) {
188
+        foreach ($tvTPL as $item) {
189
+            if (isset($this->tvid[$item]) && !array_key_exists($this->tvid[$item], $out)) {
190 190
                 $out[$this->tvid[$item]] = $this->get($this->tvid[$item]);
191 191
             }
192 192
         }
193
-        if ($render) {
194
-            foreach ($out as $key => $val) {
193
+        if ($render) {
194
+            foreach ($out as $key => $val) {
195 195
                 $out[$key] = $this->renderTV($key);
196 196
             }
197 197
         }
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
      * @param bool $render
207 207
      * @return array
208 208
      */
209
-    public function toArray($prefix = '', $suffix = '', $sep = '_', $render = true)
210
-    {
209
+    public function toArray($prefix = '', $suffix = '', $sep = '_', $render = true)
210
+    {
211 211
         $out = array_merge(
212 212
             $this->toArrayMain(),
213 213
             $this->toArrayTV($render),
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
     /**
221 221
      * @return null|string
222 222
      */
223
-    public function getUrl()
224
-    {
223
+    public function getUrl()
224
+    {
225 225
         $out = null;
226 226
         $id = (int)$this->getID();
227
-        if (!empty($id)) {
227
+        if (!empty($id)) {
228 228
             $out = $this->modx->makeUrl($id);
229 229
         }
230 230
 
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
      * @param string $second
237 237
      * @return mixed
238 238
      */
239
-    public function getTitle($main = 'menutitle', $second = 'pagetitle')
240
-    {
239
+    public function getTitle($main = 'menutitle', $second = 'pagetitle')
240
+    {
241 241
         $title = $this->get($main);
242
-        if (empty($title) && $title !== '0') {
242
+        if (empty($title) && $title !== '0') {
243 243
             $title = $this->get($second);
244 244
         }
245 245
 
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
     /**
250 250
      * @return bool
251 251
      */
252
-    public function isWebShow()
253
-    {
252
+    public function isWebShow()
253
+    {
254 254
         $pub = ($this->get('publishedon') < time() && $this->get('published'));
255 255
         $unpub = ($this->get('unpub_date') == 0 || $this->get('unpub_date') > time());
256 256
         $del = ($this->get('deleted') == 0 && ($this->get('deletedon') == 0 || $this->get('deletedon') > time()));
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
     /**
262 262
      * @return $this
263 263
      */
264
-    public function touch()
265
-    {
264
+    public function touch()
265
+    {
266 266
         $this->set('editedon', time());
267 267
 
268 268
         return $this;
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
      * @param $tvname
273 273
      * @return null|string
274 274
      */
275
-    public function renderTV($tvname)
276
-    {
275
+    public function renderTV($tvname)
276
+    {
277 277
         $out = null;
278
-        if ($this->getID() > 0) {
278
+        if ($this->getID() > 0) {
279 279
             include_once MODX_MANAGER_PATH . "includes/tmplvars.format.inc.php";
280 280
             include_once MODX_MANAGER_PATH . "includes/tmplvars.commands.inc.php";
281 281
             $tvval = $this->get($tvname);
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
      * @param $key
294 294
      * @return mixed
295 295
      */
296
-    public function get($key)
297
-    {
296
+    public function get($key)
297
+    {
298 298
         $out = parent::get($key);
299
-        if (isset($this->tv[$key])) {
299
+        if (isset($this->tv[$key])) {
300 300
             $tpl = $this->get('template');
301 301
             $tvTPL = APIHelpers::getkey($this->tvTpl, $tpl, array());
302 302
             $tvID = APIHelpers::getkey($this->tv, $key, 0);
303
-            if (in_array($tvID, $tvTPL) && is_null($out)) {
303
+            if (in_array($tvID, $tvTPL) && is_null($out)) {
304 304
                 $out = APIHelpers::getkey($this->tvd[$key], 'value', null);
305 305
             }
306 306
         }
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
      * @param $value
314 314
      * @return $this
315 315
      */
316
-    public function set($key, $value)
317
-    {
318
-        if (is_scalar($value) && is_scalar($key) && !empty($key)) {
319
-            switch ($key) {
316
+    public function set($key, $value)
317
+    {
318
+        if (is_scalar($value) && is_scalar($key) && !empty($key)) {
319
+            switch ($key) {
320 320
                 case 'parent':
321 321
                     $value = (int)$value;
322 322
                     break;
@@ -326,38 +326,38 @@  discard block
 block discarded – undo
326 326
                     break;
327 327
                 case 'published':
328 328
                     $value = (int)((bool)$value);
329
-                    if ($value) {
329
+                    if ($value) {
330 330
                         $this->field['publishedon'] = time() + $this->modxConfig('server_offset_time');
331 331
                     }
332 332
                     break;
333 333
                 case 'pub_date':
334 334
                     $value = $this->getTime($value);
335
-                    if ($value > 0 && time() + $this->modxConfig('server_offset_time') > $value) {
335
+                    if ($value > 0 && time() + $this->modxConfig('server_offset_time') > $value) {
336 336
                         $this->field['published'] = 1;
337 337
                         $this->field['publishedon'] = $value;
338 338
                     }
339 339
                     break;
340 340
                 case 'unpub_date':
341 341
                     $value = $this->getTime($value);
342
-                    if ($value > 0 && time() + $this->modxConfig('server_offset_time') > $value) {
342
+                    if ($value > 0 && time() + $this->modxConfig('server_offset_time') > $value) {
343 343
                         $this->field['published'] = 0;
344 344
                         $this->field['publishedon'] = 0;
345 345
                     }
346 346
                     break;
347 347
                 case 'deleted':
348 348
                     $value = (int)((bool)$value);
349
-                    if ($value) {
349
+                    if ($value) {
350 350
                         $this->field['deletedon'] = time() + $this->modxConfig('server_offset_time');
351
-                    } else {
351
+                    } else {
352 352
                         $this->field['deletedon'] = 0;
353 353
                     }
354 354
                     break;
355 355
                 case 'deletedon':
356 356
                     $value = $this->getTime($value);
357
-                    if ($value > 0 && time() + $this->modxConfig('server_offset_time') < $value) {
357
+                    if ($value > 0 && time() + $this->modxConfig('server_offset_time') < $value) {
358 358
                         $value = 0;
359 359
                     }
360
-                    if ($value) {
360
+                    if ($value) {
361 361
                         $this->field['deleted'] = 1;
362 362
                     }
363 363
                     break;
@@ -384,20 +384,20 @@  discard block
 block discarded – undo
384 384
      * @param int $default
385 385
      * @return int|mixed
386 386
      */
387
-    protected function getUser($value, $default = 0)
388
-    {
387
+    protected function getUser($value, $default = 0)
388
+    {
389 389
         $currentAdmin = APIHelpers::getkey($_SESSION, 'mgrInternalKey', 0);
390 390
         $value = (int)$value;
391
-        if (!empty($value)) {
391
+        if (!empty($value)) {
392 392
             $by = $this->findUserBy($value);
393
-            $exists = $this->managerUsers->exists(function ($key, Helpers\Collection $val) use ($by, $value) {
393
+            $exists = $this->managerUsers->exists(function ($key, Helpers\Collection $val) use ($by, $value) {
394 394
                 return ($val->containsKey($by) && $val->get($by) === (string)$value);
395 395
             });
396
-            if (!$exists) {
396
+            if (!$exists) {
397 397
                 $value = 0;
398 398
             }
399 399
         }
400
-        if (empty($value)) {
400
+        if (empty($value)) {
401 401
             $value = empty($currentAdmin) ? $default : $currentAdmin;
402 402
         }
403 403
 
@@ -408,9 +408,9 @@  discard block
 block discarded – undo
408 408
      * @param $data
409 409
      * @return bool|string
410 410
      */
411
-    protected function findUserBy($data)
412
-    {
413
-        switch (true) {
411
+    protected function findUserBy($data)
412
+    {
413
+        switch (true) {
414 414
             case (is_int($data) || ((int)$data > 0 && (string)intval($data) === $data)):
415 415
                 $find = 'id';
416 416
                 break;
@@ -431,14 +431,14 @@  discard block
 block discarded – undo
431 431
      * @param $value
432 432
      * @return int|mixed|string
433 433
      */
434
-    protected function getTime($value)
435
-    {
434
+    protected function getTime($value)
435
+    {
436 436
         $value = trim($value);
437
-        if (!empty($value)) {
438
-            if (!is_numeric($value)) {
437
+        if (!empty($value)) {
438
+            if (!is_numeric($value)) {
439 439
                 $value = (int)strtotime($value);
440 440
             }
441
-            if (!empty($value)) {
441
+            if (!empty($value)) {
442 442
                 $value += $this->modxConfig('server_offset_time');
443 443
             }
444 444
         }
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
      * @param array $data
451 451
      * @return $this
452 452
      */
453
-    public function create($data = array())
454
-    {
453
+    public function create($data = array())
454
+    {
455 455
         parent::create($data);
456 456
         $this->set('createdby', null)
457 457
             ->set('editedby', null)
@@ -465,22 +465,22 @@  discard block
 block discarded – undo
465 465
      * @param $id
466 466
      * @return $this
467 467
      */
468
-    public function edit($id)
469
-    {
468
+    public function edit($id)
469
+    {
470 470
         $id = is_scalar($id) ? trim($id) : '';
471
-        if ($this->getID() != $id) {
471
+        if ($this->getID() != $id) {
472 472
             $this->close();
473 473
             $this->newDoc = false;
474 474
 
475 475
             $result = $this->query("SELECT * from {$this->makeTable('site_content')} where `id`=" . (int)$id);
476 476
             $this->fromArray($this->modx->db->getRow($result));
477 477
             $result = $this->query("SELECT * from {$this->makeTable('site_tmplvar_contentvalues')} where `contentid`=" . (int)$id);
478
-            while ($row = $this->modx->db->getRow($result)) {
478
+            while ($row = $this->modx->db->getRow($result)) {
479 479
                 $this->field[$this->tvid[$row['tmplvarid']]] = $row['value'];
480 480
             }
481
-            if (empty($this->field['id'])) {
481
+            if (empty($this->field['id'])) {
482 482
                 $this->id = null;
483
-            } else {
483
+            } else {
484 484
                 $this->id = $this->field['id'];
485 485
                 $this->set('editedby', null)->touch();
486 486
             }
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
      * @param bool $clearCache
496 496
      * @return bool|null|void
497 497
      */
498
-    public function save($fire_events = false, $clearCache = false)
499
-    {
498
+    public function save($fire_events = false, $clearCache = false)
499
+    {
500 500
         $parent = null;
501
-        if ($this->field['pagetitle'] == '') {
501
+        if ($this->field['pagetitle'] == '') {
502 502
             $this->log['emptyPagetitle'] = 'Pagetitle is empty in <pre>' . print_r($this->field, true) . '</pre>';
503 503
 
504 504
             return false;
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
         ), $fire_events);
515 515
 
516 516
         $fld = $this->toArray(null, null, null, false);
517
-        foreach ($this->default_field as $key => $value) {
517
+        foreach ($this->default_field as $key => $value) {
518 518
             $tmp = $this->get($key);
519
-            if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
520
-                if ($tmp == $value) {
521
-                    switch ($key) {
519
+            if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
520
+                if ($tmp == $value) {
521
+                    switch ($key) {
522 522
                         case 'cacheable':
523 523
                             $value = $this->modxConfig('cache_default');
524 524
                             break;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
                 }
539 539
                 $this->field[$key] = $value;
540 540
             }
541
-            switch (true) {
541
+            switch (true) {
542 542
                 case $key == 'parent':
543 543
                     $parent = (int)$this->get($key);
544 544
                     $q = $this->query("SELECT count(`id`) FROM {$this->makeTable('site_content')} WHERE `id`='{$parent}'");
545
-                    if ($this->modx->db->getValue($q) != 1) {
545
+                    if ($this->modx->db->getValue($q) != 1) {
546 546
                         $parent = $value;
547 547
                     }
548 548
                     $this->field[$key] = $parent;
@@ -557,41 +557,41 @@  discard block
 block discarded – undo
557 557
             unset($fld[$key]);
558 558
         }
559 559
 
560
-        if (!empty($this->set)) {
561
-            if ($this->newDoc) {
560
+        if (!empty($this->set)) {
561
+            if ($this->newDoc) {
562 562
                 $SQL = "INSERT into {$this->makeTable('site_content')} SET " . implode(', ', $this->set);
563
-            } else {
563
+            } else {
564 564
                 $SQL = "UPDATE {$this->makeTable('site_content')} SET " . implode(', ',
565 565
                         $this->set) . " WHERE `id` = " . $this->id;
566 566
             }
567 567
             $this->query($SQL);
568 568
 
569
-            if ($this->newDoc) {
569
+            if ($this->newDoc) {
570 570
                 $this->id = $this->modx->db->getInsertId();
571 571
             }
572 572
 
573
-            if ($parent > 0) {
573
+            if ($parent > 0) {
574 574
                 $this->query("UPDATE {$this->makeTable('site_content')} SET `isfolder`='1' WHERE `id`='{$parent}'");
575 575
             }
576 576
         }
577 577
 
578
-        foreach ($fld as $key => $value) {
579
-            if (empty($this->tv[$key])) {
578
+        foreach ($fld as $key => $value) {
579
+            if (empty($this->tv[$key])) {
580 580
                 continue;
581 581
             }
582
-            if ($value === '') {
582
+            if ($value === '') {
583 583
                 $this->query("DELETE FROM {$this->makeTable('site_tmplvar_contentvalues')} WHERE `contentid` = '{$this->id}' AND `tmplvarid` = '{$this->tv[$key]}'");
584
-            } else {
584
+            } else {
585 585
                 $value = $this->escape($value);
586 586
                 $result = $this->query("SELECT `value` FROM {$this->makeTable('site_tmplvar_contentvalues')} WHERE `contentid` = '{$this->id}' AND `tmplvarid` = '{$this->tv[$key]}'");
587
-                if ($this->modx->db->getRecordCount($result) > 0) {
587
+                if ($this->modx->db->getRecordCount($result) > 0) {
588 588
                     $this->query("UPDATE {$this->makeTable('site_tmplvar_contentvalues')} SET `value` = '{$value}' WHERE `contentid` = '{$this->id}' AND `tmplvarid` = '{$this->tv[$key]}';");
589
-                } else {
589
+                } else {
590 590
                     $this->query("INSERT into {$this->makeTable('site_tmplvar_contentvalues')} SET `contentid` = {$this->id},`tmplvarid` = {$this->tv[$key]},`value` = '{$value}';");
591 591
                 }
592 592
             }
593 593
         }
594
-        if (!isset($this->mode)) {
594
+        if (!isset($this->mode)) {
595 595
             $this->mode = $this->newDoc ? "new" : "upd";
596 596
             $this->newDoc = false;
597 597
         }
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
             'docObj' => $this
603 603
         ), $fire_events);
604 604
 
605
-        if ($clearCache) {
605
+        if ($clearCache) {
606 606
             $this->clearCache($fire_events);
607 607
         }
608 608
 
@@ -614,14 +614,14 @@  discard block
 block discarded – undo
614 614
      * @return $this
615 615
      * @throws Exception
616 616
      */
617
-    public function toTrash($ids)
618
-    {
617
+    public function toTrash($ids)
618
+    {
619 619
         $ignore = $this->systemID();
620 620
         $_ids = $this->cleanIDs($ids, ',', $ignore);
621
-        if (is_array($_ids) && $_ids != array()) {
621
+        if (is_array($_ids) && $_ids != array()) {
622 622
             $id = $this->sanitarIn($_ids);
623 623
             $this->query("UPDATE {$this->makeTable('site_content')} SET `deleted`='1' WHERE `id` IN ({$id})");
624
-        } else {
624
+        } else {
625 625
             throw new Exception('Invalid IDs list for mark trash: <pre>' . print_r($ids,
626 626
                     1) . '</pre> please, check ignore list: <pre>' . print_r($ignore, 1) . '</pre>');
627 627
         }
@@ -633,15 +633,15 @@  discard block
 block discarded – undo
633 633
      * @param bool $fire_events
634 634
      * @return $this
635 635
      */
636
-    public function clearTrash($fire_events = false)
637
-    {
636
+    public function clearTrash($fire_events = false)
637
+    {
638 638
         $q = $this->query("SELECT `id` FROM {$this->makeTable('site_content')} WHERE `deleted`='1'");
639 639
         $q = $this->modx->makeArray($q);
640 640
         $_ids = array();
641
-        foreach ($q as $item) {
641
+        foreach ($q as $item) {
642 642
             $_ids[] = $item['id'];
643 643
         }
644
-        if (is_array($_ids) && $_ids != array()) {
644
+        if (is_array($_ids) && $_ids != array()) {
645 645
             $this->invokeEvent('OnBeforeEmptyTrash', array(
646 646
                 "ids" => $_ids
647 647
             ), $fire_events);
@@ -663,15 +663,15 @@  discard block
 block discarded – undo
663 663
      * @param int|bool $depth
664 664
      * @return array
665 665
      */
666
-    public function childrens($ids, $depth)
667
-    {
666
+    public function childrens($ids, $depth)
667
+    {
668 668
         $_ids = $this->cleanIDs($ids, ',');
669
-        if (is_array($_ids) && $_ids != array()) {
669
+        if (is_array($_ids) && $_ids != array()) {
670 670
             $id = $this->sanitarIn($_ids);
671
-            if (!empty($id)) {
671
+            if (!empty($id)) {
672 672
                 $q = $this->query("SELECT `id` FROM {$this->makeTable('site_content')} where `parent` IN ({$id})");
673 673
                 $id = $this->modx->db->getColumn('id', $q);
674
-                if ($depth > 0 || $depth === true) {
674
+                if ($depth > 0 || $depth === true) {
675 675
                     $id = $this->childrens($id, is_bool($depth) ? $depth : ($depth - 1));
676 676
                 }
677 677
                 $_ids = array_merge($_ids, $id);
@@ -687,24 +687,24 @@  discard block
 block discarded – undo
687 687
      * @return $this
688 688
      * @throws Exception
689 689
      */
690
-    public function delete($ids, $fire_events = false)
691
-    {
690
+    public function delete($ids, $fire_events = false)
691
+    {
692 692
         $ids = $this->childrens($ids, true);
693 693
         $_ids = $this->cleanIDs($ids, ',', $this->systemID());
694
-        if (is_array($_ids) && $_ids != array()) {
694
+        if (is_array($_ids) && $_ids != array()) {
695 695
             $this->invokeEvent('OnBeforeEmptyTrash', array(
696 696
                 "ids" => $_ids
697 697
             ), $fire_events);
698 698
 
699 699
             $id = $this->sanitarIn($_ids);
700
-            if (!empty($id)) {
700
+            if (!empty($id)) {
701 701
                 $this->query("DELETE from {$this->makeTable('site_content')} where `id` IN ({$id})");
702 702
                 $this->query("DELETE from {$this->makeTable('site_tmplvar_contentvalues')} where `contentid` IN ({$id})");
703 703
                 $this->invokeEvent('OnEmptyTrash', array(
704 704
                     "ids" => $_ids
705 705
                 ), $fire_events);
706 706
             }
707
-        } else {
707
+        } else {
708 708
             throw new Exception('Invalid IDs list for delete: <pre>' . print_r($ids,
709 709
                     1) . '</pre> please, check ignore list: <pre>' . print_r($ignore, 1) . '</pre>');
710 710
         }
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
     /**
716 716
      * @return array
717 717
      */
718
-    private function systemID()
719
-    {
718
+    private function systemID()
719
+    {
720 720
         $ignore = array(
721 721
             0, //empty document
722 722
             (int)$this->modxConfig('site_start'),
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
         );
727 727
         $data = $this->query("SELECT DISTINCT setting_value FROM {$this->makeTable('web_user_settings')} WHERE `setting_name`='login_home' AND `setting_value`!=''");
728 728
         $data = $this->modx->db->makeArray($data);
729
-        foreach ($data as $item) {
729
+        foreach ($data as $item) {
730 730
             $ignore[] = (int)$item['setting_value'];
731 731
         }
732 732
 
@@ -738,22 +738,22 @@  discard block
 block discarded – undo
738 738
      * @param $alias
739 739
      * @return string
740 740
      */
741
-    private function checkAlias($alias)
742
-    {
741
+    private function checkAlias($alias)
742
+    {
743 743
         $alias = strtolower($alias);
744
-        if ($this->modxConfig('friendly_urls')) {
744
+        if ($this->modxConfig('friendly_urls')) {
745 745
             $_alias = $this->escape($alias);
746
-            if ((!$this->modxConfig('allow_duplicate_alias') && !$this->modxConfig('use_alias_path')) || ($this->modxConfig('allow_duplicate_alias') && $this->modxConfig('use_alias_path'))) {
746
+            if ((!$this->modxConfig('allow_duplicate_alias') && !$this->modxConfig('use_alias_path')) || ($this->modxConfig('allow_duplicate_alias') && $this->modxConfig('use_alias_path'))) {
747 747
                 $flag = $this->modx->db->getValue($this->query("SELECT `id` FROM {$this->makeTable('site_content')} WHERE `alias`='{$_alias}' AND `parent`={$this->get('parent')} LIMIT 1"));
748
-            } else {
748
+            } else {
749 749
                 $flag = $this->modx->db->getValue($this->query("SELECT `id` FROM {$this->makeTable('site_content')} WHERE `alias`='{$_alias}' LIMIT 1"));
750 750
             }
751
-            if (($flag && $this->newDoc) || (!$this->newDoc && $flag && $this->id != $flag)) {
751
+            if (($flag && $this->newDoc) || (!$this->newDoc && $flag && $this->id != $flag)) {
752 752
                 $suffix = substr($alias, -2);
753
-                if (preg_match('/-(\d+)/', $suffix, $tmp) && isset($tmp[1]) && (int)$tmp[1] > 1) {
753
+                if (preg_match('/-(\d+)/', $suffix, $tmp) && isset($tmp[1]) && (int)$tmp[1] > 1) {
754 754
                     $suffix = (int)$tmp[1] + 1;
755 755
                     $alias = substr($alias, 0, -2) . '-' . $suffix;
756
-                } else {
756
+                } else {
757 757
                     $alias .= '-2';
758 758
                 }
759 759
                 $alias = $this->checkAlias($alias);
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
      * @param $key
768 768
      * @return bool
769 769
      */
770
-    public function issetField($key)
771
-    {
770
+    public function issetField($key)
771
+    {
772 772
         return (array_key_exists($key, $this->default_field) || array_key_exists($key, $this->tv));
773 773
     }
774 774
 
@@ -776,15 +776,15 @@  discard block
 block discarded – undo
776 776
      * @param bool $reload
777 777
      * @return $this
778 778
      */
779
-    protected function get_TV($reload = false)
780
-    {
781
-        if (empty($this->modx->_TVnames) || $reload) {
779
+    protected function get_TV($reload = false)
780
+    {
781
+        if (empty($this->modx->_TVnames) || $reload) {
782 782
             $result = $this->query('SELECT `id`,`name` FROM ' . $this->makeTable('site_tmplvars'));
783
-            while ($row = $this->modx->db->GetRow($result)) {
783
+            while ($row = $this->modx->db->GetRow($result)) {
784 784
                 $this->modx->_TVnames[$row['name']] = $row['id'];
785 785
             }
786 786
         }
787
-        foreach ($this->modx->_TVnames as $name => $id) {
787
+        foreach ($this->modx->_TVnames as $name => $id) {
788 788
             $this->tvid[$id] = $name;
789 789
             $this->tv[$name] = $id;
790 790
         }
@@ -796,12 +796,12 @@  discard block
 block discarded – undo
796 796
     /**
797 797
      * @return $this
798 798
      */
799
-    protected function loadTVTemplate()
800
-    {
799
+    protected function loadTVTemplate()
800
+    {
801 801
         $q = $this->query("SELECT `tmplvarid`, `templateid` FROM " . $this->makeTable('site_tmplvar_templates'));
802 802
         $q = $this->modx->db->makeArray($q);
803 803
         $this->tvTpl = array();
804
-        foreach ($q as $item) {
804
+        foreach ($q as $item) {
805 805
             $this->tvTpl[$item['templateid']][] = $item['tmplvarid'];
806 806
         }
807 807
 
@@ -812,16 +812,16 @@  discard block
 block discarded – undo
812 812
      * @param array $tvId
813 813
      * @return $this
814 814
      */
815
-    protected function loadTVDefault(array $tvId = array())
816
-    {
817
-        if (is_array($tvId) && !empty($tvId)) {
815
+    protected function loadTVDefault(array $tvId = array())
816
+    {
817
+        if (is_array($tvId) && !empty($tvId)) {
818 818
             $tbl_site_tmplvars = $this->makeTable('site_tmplvars');
819 819
             $fields = 'id,name,default_text as value,display,display_params,type';
820 820
             $implodeTvId = implode(',', $tvId);
821 821
             $rs = $this->query("SELECT {$fields} FROM {$tbl_site_tmplvars} WHERE id IN({$implodeTvId})");
822 822
             $rows = $this->modx->db->makeArray($rs);
823 823
             $this->tvd = array();
824
-            foreach ($rows as $item) {
824
+            foreach ($rows as $item) {
825 825
                 $this->tvd[$item['name']] = $item;
826 826
             }
827 827
         }
@@ -834,17 +834,17 @@  discard block
 block discarded – undo
834 834
      * @return int
835 835
      * @throws Exception
836 836
      */
837
-    public function setTemplate($tpl)
838
-    {
839
-        if (!is_numeric($tpl) || $tpl != (int)$tpl) {
840
-            if (is_scalar($tpl)) {
837
+    public function setTemplate($tpl)
838
+    {
839
+        if (!is_numeric($tpl) || $tpl != (int)$tpl) {
840
+            if (is_scalar($tpl)) {
841 841
                 $sql = "SELECT `id` FROM {$this->makeTable('site_templates')} WHERE `templatename` = '" . $this->escape($tpl) . "'";
842 842
                 $rs = $this->query($sql);
843
-                if (!$rs || $this->modx->db->getRecordCount($rs) <= 0) {
843
+                if (!$rs || $this->modx->db->getRecordCount($rs) <= 0) {
844 844
                     throw new Exception("Template {$tpl} is not exists");
845 845
                 }
846 846
                 $tpl = $this->modx->db->getValue($rs);
847
-            } else {
847
+            } else {
848 848
                 throw new Exception("Invalid template name: " . print_r($tpl, 1));
849 849
             }
850 850
         }
@@ -855,14 +855,14 @@  discard block
 block discarded – undo
855 855
     /**
856 856
      * @return string
857 857
      */
858
-    private function getAlias()
859
-    {
860
-        if ($this->modxConfig('friendly_urls') && $this->modxConfig('automatic_alias') && $this->get('alias') == '') {
858
+    private function getAlias()
859
+    {
860
+        if ($this->modxConfig('friendly_urls') && $this->modxConfig('automatic_alias') && $this->get('alias') == '') {
861 861
             $alias = strtr($this->get('pagetitle'), $this->table);
862
-        } else {
863
-            if ($this->get('alias') != '') {
862
+        } else {
863
+            if ($this->get('alias') != '') {
864 864
                 $alias = $this->get('alias');
865
-            } else {
865
+            } else {
866 866
                 $alias = '';
867 867
             }
868 868
         }
Please login to merge, or discard this patch.
assets/lib/Helpers/Video.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function __construct($link = null, $autostart = true, $info = false)
92 92
     {
93
-        if (!empty($link)) {
93
+        if ( ! empty($link)) {
94 94
             $this->setLink($link);
95 95
             $this->setInfo($info);
96 96
             if ($autostart) {
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
     /** Обработка ссылки. Возвращает идентификатор видеохостинга или false */
182 182
     public function process($link = null, $info = null)
183 183
     {
184
-        if (!empty($link)) {
184
+        if ( ! empty($link)) {
185 185
             $this->setLink($link);
186 186
         }
187
-        if (!empty($info)) {
187
+        if ( ! empty($info)) {
188 188
             $this->setInfo($info);
189 189
         }
190 190
 
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
     /** Скачать превью. Если не указать имя файла для записи - функция вернет содержимое файла */
209 209
     public function fetchImage($filename = null)
210 210
     {
211
-        if (!$url = $this->getImage()) {
211
+        if ( ! $url = $this->getImage()) {
212 212
             return false;
213 213
         }
214 214
 
215
-        if (!$res = $this->fetchPage($url)) {
215
+        if ( ! $res = $this->fetchPage($url)) {
216 216
             return false;
217 217
         }
218 218
 
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
     /** Проверка и подготовка ссылки и частей */
225 225
     protected function cleanLink()
226 226
     {
227
-        if (!preg_match('/^(http|https)\:\/\//i', $this->link)) {
227
+        if ( ! preg_match('/^(http|https)\:\/\//i', $this->link)) {
228 228
             $this->link = 'http://' . $this->link;
229 229
         }
230 230
 
231
-        if (!$this->link_parts = parse_url($this->link)) {
231
+        if ( ! $this->link_parts = parse_url($this->link)) {
232 232
             return false;
233 233
         }
234 234
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         if ('youtube.com' == $h) {
245 245
             parse_str($this->link_parts['query'], $q);
246 246
 
247
-            if ('/watch' == $p && !empty($q['v'])) {
247
+            if ('/watch' == $p && ! empty($q['v'])) {
248 248
                 return $this->foundYoutube($q['v']);
249 249
             }
250 250
             if (0 === strpos($p, '/embed/')) {
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     /** Обработка VIMEO */
318 318
     protected function foundVimeo($id)
319 319
     {
320
-        if (empty($id) || !is_numeric($id)) {
320
+        if (empty($id) || ! is_numeric($id)) {
321 321
             return false;
322 322
         }
323 323
 
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
         $class = isset($options['class']) ? $options['class'] : '';
397 397
 
398 398
         $url = $this->getVideo($autoplay);
399
-        if (!empty($class)) {
399
+        if ( ! empty($class)) {
400 400
             $class = ' class="' . $class . '"';
401 401
         }
402 402
 
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
     /** Прогоняем тест по видам URL */
407 407
     public static function RunTest($links = null)
408 408
     {
409
-        if (!is_array($links)) {
409
+        if ( ! is_array($links)) {
410 410
             $links = static::$test;
411 411
         }
412 412
 
Please login to merge, or discard this patch.
Braces   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
  * VideoThumb::RunTest()
12 12
  * @See: https://gist.github.com/cmsx/5539570
13 13
  */
14
-class Video
15
-{
14
+class Video
15
+{
16 16
     /** Ссылка на ролик */
17 17
     protected $link;
18 18
 
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
      * @param string|null $link ссылка на видео
89 89
      * @param bool $autostart сразу определить превью и клип
90 90
      */
91
-    public function __construct($link = null, $autostart = true, $info = false)
92
-    {
93
-        if (!empty($link)) {
91
+    public function __construct($link = null, $autostart = true, $info = false)
92
+    {
93
+        if (!empty($link)) {
94 94
             $this->setLink($link);
95 95
             $this->setInfo($info);
96
-            if ($autostart) {
96
+            if ($autostart) {
97 97
                 $this->process();
98 98
             }
99 99
         }
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
     /**
103 103
      * @return string
104 104
      */
105
-    public function getScheme()
106
-    {
107
-        switch ($this->scheme) {
105
+    public function getScheme()
106
+    {
107
+        switch ($this->scheme) {
108 108
             case 'http':
109 109
                 $out = 'http://';
110 110
                 break;
@@ -122,42 +122,42 @@  discard block
 block discarded – undo
122 122
     /**
123 123
      * @param $info
124 124
      */
125
-    public function setInfo($info)
126
-    {
125
+    public function setInfo($info)
126
+    {
127 127
         $this->info = (bool)$info;
128 128
     }
129 129
 
130 130
     /**
131 131
      * @return bool
132 132
      */
133
-    public function getInfo()
134
-    {
133
+    public function getInfo()
134
+    {
135 135
         return $this->info;
136 136
     }
137 137
 
138 138
     /** Видеохостинг */
139
-    public function getHosting()
140
-    {
139
+    public function getHosting()
140
+    {
141 141
         return $this->hosting;
142 142
     }
143 143
 
144 144
     /** Идентификатор видео */
145
-    public function getId()
146
-    {
145
+    public function getId()
146
+    {
147 147
         return $this->id;
148 148
     }
149 149
 
150 150
     /** Ссылка на превью */
151
-    public function getImage()
152
-    {
151
+    public function getImage()
152
+    {
153 153
         return $this->getScheme() . $this->image;
154 154
     }
155 155
 
156 156
     /** Ссылка на видео */
157
-    public function getVideo($autoplay = false)
158
-    {
157
+    public function getVideo($autoplay = false)
158
+    {
159 159
         $url = $this->video;
160
-        if ($autoplay) {
160
+        if ($autoplay) {
161 161
             $url .= '&autoplay=1';
162 162
         }
163 163
 
@@ -165,39 +165,39 @@  discard block
 block discarded – undo
165 165
     }
166 166
 
167 167
     /** Название видео */
168
-    public function getTitle()
169
-    {
168
+    public function getTitle()
169
+    {
170 170
         return $this->title;
171 171
     }
172 172
 
173 173
     /** Задать ссылку на видео */
174
-    public function setLink($link)
175
-    {
174
+    public function setLink($link)
175
+    {
176 176
         $this->link = $link;
177 177
 
178 178
         return $this;
179 179
     }
180 180
 
181 181
     /** Обработка ссылки. Возвращает идентификатор видеохостинга или false */
182
-    public function process($link = null, $info = null)
183
-    {
184
-        if (!empty($link)) {
182
+    public function process($link = null, $info = null)
183
+    {
184
+        if (!empty($link)) {
185 185
             $this->setLink($link);
186 186
         }
187
-        if (!empty($info)) {
187
+        if (!empty($info)) {
188 188
             $this->setInfo($info);
189 189
         }
190 190
 
191
-        if ($this->cleanLink()) {
192
-            if ($this->maybeYoutube()) {
191
+        if ($this->cleanLink()) {
192
+            if ($this->maybeYoutube()) {
193 193
                 return self::YOUTUBE;
194 194
             }
195 195
 
196
-            if ($this->maybeVimeo()) {
196
+            if ($this->maybeVimeo()) {
197 197
                 return self::VIMEO;
198 198
             }
199 199
 
200
-            if ($this->maybeRutube()) {
200
+            if ($this->maybeRutube()) {
201 201
                 return self::RUTUBE;
202 202
             }
203 203
         }
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
     }
207 207
 
208 208
     /** Скачать превью. Если не указать имя файла для записи - функция вернет содержимое файла */
209
-    public function fetchImage($filename = null)
210
-    {
211
-        if (!$url = $this->getImage()) {
209
+    public function fetchImage($filename = null)
210
+    {
211
+        if (!$url = $this->getImage()) {
212 212
             return false;
213 213
         }
214 214
 
215
-        if (!$res = $this->fetchPage($url)) {
215
+        if (!$res = $this->fetchPage($url)) {
216 216
             return false;
217 217
         }
218 218
 
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
     }
223 223
 
224 224
     /** Проверка и подготовка ссылки и частей */
225
-    protected function cleanLink()
226
-    {
227
-        if (!preg_match('/^(http|https)\:\/\//i', $this->link)) {
225
+    protected function cleanLink()
226
+    {
227
+        if (!preg_match('/^(http|https)\:\/\//i', $this->link)) {
228 228
             $this->link = 'http://' . $this->link;
229 229
         }
230 230
 
231
-        if (!$this->link_parts = parse_url($this->link)) {
231
+        if (!$this->link_parts = parse_url($this->link)) {
232 232
             return false;
233 233
         }
234 234
 
@@ -236,21 +236,21 @@  discard block
 block discarded – undo
236 236
     }
237 237
 
238 238
     /** Проверка YOUTUBE */
239
-    protected function maybeYoutube()
240
-    {
239
+    protected function maybeYoutube()
240
+    {
241 241
         $h = str_replace('www.', '', $this->link_parts['host']);
242 242
         $p = isset($this->link_parts['path']) ? $this->link_parts['path'] : false;
243 243
 
244
-        if ('youtube.com' == $h) {
244
+        if ('youtube.com' == $h) {
245 245
             parse_str($this->link_parts['query'], $q);
246 246
 
247
-            if ('/watch' == $p && !empty($q['v'])) {
247
+            if ('/watch' == $p && !empty($q['v'])) {
248 248
                 return $this->foundYoutube($q['v']);
249 249
             }
250
-            if (0 === strpos($p, '/embed/')) {
250
+            if (0 === strpos($p, '/embed/')) {
251 251
                 return $this->foundYoutube(str_replace('/embed/', '', $p));
252 252
             }
253
-        } elseif ('youtu.be' == $h) {
253
+        } elseif ('youtu.be' == $h) {
254 254
             return $this->foundYoutube(trim($p, '/'));
255 255
         }
256 256
 
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
     }
259 259
 
260 260
     /** Проверка VIMEO */
261
-    protected function maybeVimeo()
262
-    {
261
+    protected function maybeVimeo()
262
+    {
263 263
         $h = str_replace('www.', '', $this->link_parts['host']);
264 264
         $p = isset($this->link_parts['path']) ? $this->link_parts['path'] : false;
265 265
 
266
-        if ('vimeo.com' == $h) {
266
+        if ('vimeo.com' == $h) {
267 267
             return $this->foundVimeo(trim($p, '/'));
268
-        } elseif ('player.vimeo.com' == $h && 0 === strpos($p, '/video/')) {
268
+        } elseif ('player.vimeo.com' == $h && 0 === strpos($p, '/video/')) {
269 269
             return $this->foundVimeo(str_replace('/video/', '', $p));
270 270
         }
271 271
 
@@ -273,20 +273,20 @@  discard block
 block discarded – undo
273 273
     }
274 274
 
275 275
     /** Проверка RUTUBE */
276
-    protected function maybeRutube($html = null)
277
-    {
276
+    protected function maybeRutube($html = null)
277
+    {
278 278
         $link = $html ?: $this->link;
279 279
 
280
-        foreach ($this->regexp[self::RUTUBE] as $regexp) {
281
-            if (preg_match($regexp, $link, $matches)) {
280
+        foreach ($this->regexp[self::RUTUBE] as $regexp) {
281
+            if (preg_match($regexp, $link, $matches)) {
282 282
                 return $this->foundRutube($matches[1]);
283 283
             }
284 284
         }
285 285
 
286 286
         // Проверка на особенную ссылку RUtube`a
287
-        if (is_null($html) && preg_match($this->regexp_rutube_extra, $this->link, $matches)) {
287
+        if (is_null($html) && preg_match($this->regexp_rutube_extra, $this->link, $matches)) {
288 288
             $html = $this->fetchPage($matches[0]);
289
-            if ($r = $this->maybeRutube($html)) {
289
+            if ($r = $this->maybeRutube($html)) {
290 290
                 return $r;
291 291
             }
292 292
         }
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
     }
296 296
 
297 297
     /** Обработка YOUTUBE */
298
-    protected function foundYoutube($id)
299
-    {
300
-        if (empty($id) || strlen($id) != 11) {
298
+    protected function foundYoutube($id)
299
+    {
300
+        if (empty($id) || strlen($id) != 11) {
301 301
             return false;
302 302
         }
303 303
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         /** @see https://developers.google.com/youtube/player_parameters */
308 308
         $this->video = 'www.youtube.com/embed/' . $id . '?showinfo=0&modestbranding=1&rel=0';
309 309
 
310
-        if ($this->info) {
310
+        if ($this->info) {
311 311
             $this->getYoutubeInfo($id);
312 312
         }
313 313
 
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
     }
316 316
 
317 317
     /** Обработка VIMEO */
318
-    protected function foundVimeo($id)
319
-    {
320
-        if (empty($id) || !is_numeric($id)) {
318
+    protected function foundVimeo($id)
319
+    {
320
+        if (empty($id) || !is_numeric($id)) {
321 321
             return false;
322 322
         }
323 323
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         $this->id = $id;
326 326
         $this->video = 'player.vimeo.com/video/' . $id . '?';
327 327
 
328
-        if ($this->info) {
328
+        if ($this->info) {
329 329
             $this->getVimeoInfo($id);
330 330
         }
331 331
 
@@ -333,13 +333,13 @@  discard block
 block discarded – undo
333 333
     }
334 334
 
335 335
     /** Обработка RUTUBE */
336
-    protected function foundRutube($id)
337
-    {
336
+    protected function foundRutube($id)
337
+    {
338 338
         $this->hosting = self::RUTUBE;
339 339
         $this->id = $id;
340 340
         $this->video = 'rutube.ru/video/embed/' . $id . '?';
341 341
 
342
-        if ($this->info) {
342
+        if ($this->info) {
343 343
             $this->getRutubeInfo($id);
344 344
         }
345 345
 
@@ -347,34 +347,34 @@  discard block
 block discarded – undo
347 347
     }
348 348
 
349 349
     /** Парсинг XML от RUTUBE и определение превьюхи */
350
-    protected function getRutubeInfo($id)
351
-    {
352
-        if (@$xml = simplexml_load_file("http://rutube.ru/cgi-bin/xmlapi.cgi?rt_mode=movie&rt_movie_id=" . $id . "&utf=1")) {
350
+    protected function getRutubeInfo($id)
351
+    {
352
+        if (@$xml = simplexml_load_file("http://rutube.ru/cgi-bin/xmlapi.cgi?rt_mode=movie&rt_movie_id=" . $id . "&utf=1")) {
353 353
             $this->title = (string)$xml->title;
354 354
             $this->image = (string)$xml->thumbnail_url;
355 355
         }
356 356
     }
357 357
 
358 358
     /** Парсинг XML от VIMEO и определение превьюхи */
359
-    protected function getVimeoInfo($id)
360
-    {
361
-        if (@$xml = simplexml_load_file('http://vimeo.com/api/v2/video/' . $id . '.xml')) {
359
+    protected function getVimeoInfo($id)
360
+    {
361
+        if (@$xml = simplexml_load_file('http://vimeo.com/api/v2/video/' . $id . '.xml')) {
362 362
             $this->title = (string)$xml->video->title;
363 363
             $this->image = (string)$xml->video->thumbnail_large ?: $xml->video->thumbnail_medium;
364 364
         }
365 365
     }
366 366
 
367 367
     /** Получение названия ролика */
368
-    protected function getYoutubeInfo($id)
369
-    {
370
-        if (@$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/' . $id)) {
368
+    protected function getYoutubeInfo($id)
369
+    {
370
+        if (@$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/' . $id)) {
371 371
             $this->title = (string)$xml->title;
372 372
         }
373 373
     }
374 374
 
375 375
     /** Скачивание страницы с помощью CURL */
376
-    protected function fetchPage($url)
377
-    {
376
+    protected function fetchPage($url)
377
+    {
378 378
         $ch = curl_init();
379 379
         curl_setopt($ch, CURLOPT_URL, $url);
380 380
         curl_setopt($ch, CURLOPT_FAILONERROR, true);
@@ -388,15 +388,15 @@  discard block
 block discarded – undo
388 388
      * @param $options
389 389
      * @return string
390 390
      */
391
-    public function getEmbed($options)
392
-    {
391
+    public function getEmbed($options)
392
+    {
393 393
         $autoplay = isset($options["autoplay"]) ? $options["autoplay"] : $this->autoplay;
394 394
         $width = isset($options["width"]) ? (int)$options["width"] : $this->width;
395 395
         $height = isset($options["height"]) ? (int)$options["height"] : $this->height;
396 396
         $class = isset($options['class']) ? $options['class'] : '';
397 397
 
398 398
         $url = $this->getVideo($autoplay);
399
-        if (!empty($class)) {
399
+        if (!empty($class)) {
400 400
             $class = ' class="' . $class . '"';
401 401
         }
402 402
 
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
     }
405 405
 
406 406
     /** Прогоняем тест по видам URL */
407
-    public static function RunTest($links = null)
408
-    {
409
-        if (!is_array($links)) {
407
+    public static function RunTest($links = null)
408
+    {
409
+        if (!is_array($links)) {
410 410
             $links = static::$test;
411 411
         }
412 412
 
413
-        foreach ($links as $link) {
413
+        foreach ($links as $link) {
414 414
             $v = new static($link);
415 415
             echo "<h1>$link</h1>\n"
416 416
                 . "<h3>" . $v->getHosting() . "</h3>"
Please login to merge, or discard this patch.
assets/lib/MODxAPI/modUsers.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             $this->close();
94 94
             $this->newDoc = false;
95 95
 
96
-            if (!$find = $this->findUser($id)) {
96
+            if ( ! $find = $this->findUser($id)) {
97 97
                 $this->id = null;
98 98
             } else {
99 99
                 $result = $this->query("
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function set($key, $value)
121 121
     {
122
-        if (is_scalar($value) && is_scalar($key) && !empty($key)) {
122
+        if (is_scalar($value) && is_scalar($key) && ! empty($key)) {
123 123
             switch ($key) {
124 124
                 case 'password':
125 125
                     $this->givenPassword = $value;
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
             return false;
156 156
         }
157 157
 
158
-        if (!$this->checkUnique('web_users', 'username')) {
158
+        if ( ! $this->checkUnique('web_users', 'username')) {
159 159
             $this->log['UniqueUsername'] = 'username not unique <pre>' . print_r($this->get('username'),
160 160
                     true) . '</pre>';
161 161
 
162 162
             return false;
163 163
         }
164 164
 
165
-        if (!$this->checkUnique('web_user_attributes', 'email', 'internalKey')) {
165
+        if ( ! $this->checkUnique('web_user_attributes', 'email', 'internalKey')) {
166 166
             $this->log['UniqueEmail'] = 'Email not unique <pre>' . print_r($this->get('email'), true) . '</pre>';
167 167
 
168 168
             return false;
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
         $fld = $this->toArray();
172 172
         foreach ($this->default_field['user'] as $key => $value) {
173 173
             $tmp = $this->get($key);
174
-            if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
174
+            if ($this->newDoc && ( ! is_int($tmp) && $tmp == '')) {
175 175
                 $this->field[$key] = $value;
176 176
             }
177 177
             $this->Uset($key, 'user');
178 178
             unset($fld[$key]);
179 179
         }
180
-        if (!empty($this->set['user'])) {
180
+        if ( ! empty($this->set['user'])) {
181 181
             if ($this->newDoc) {
182 182
                 $SQL = "INSERT into {$this->makeTable('web_users')} SET " . implode(', ', $this->set['user']);
183 183
             } else {
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 
194 194
         foreach ($this->default_field['attribute'] as $key => $value) {
195 195
             $tmp = $this->get($key);
196
-            if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
196
+            if ($this->newDoc && ( ! is_int($tmp) && $tmp == '')) {
197 197
                 $this->field[$key] = $value;
198 198
             }
199 199
             $this->Uset($key, 'attribute');
200 200
             unset($fld[$key]);
201 201
         }
202
-        if (!empty($this->set['attribute'])) {
202
+        if ( ! empty($this->set['attribute'])) {
203 203
             if ($this->newDoc) {
204 204
                 $this->set('internalKey', $this->id)->Uset('internalKey', 'attribute');
205 205
                 $SQL = "INSERT into {$this->makeTable('web_user_attributes')} SET " . implode(', ',
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                 $this->query("INSERT into {$this->makeTable('web_user_settings')} SET `webuser` = {$this->id},`setting_name` = '{$key}',`setting_value` = '{$value}';");
223 223
             }
224 224
         }
225
-        if (!$this->newDoc && $this->givenPassword) {
225
+        if ( ! $this->newDoc && $this->givenPassword) {
226 226
             $this->invokeEvent('OnWebChangePassword', array(
227 227
                 'userObj'      => $this,
228 228
                 'userid'       => $this->id,
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
         $b = $tmp->get('blocked');
319 319
         $bu = $tmp->get('blockeduntil');
320 320
         $ba = $tmp->get('blockedafter');
321
-        $flag = (($b && !$bu && !$ba) || ($bu && $now < $bu) || ($ba && $now > $ba));
321
+        $flag = (($b && ! $bu && ! $ba) || ($bu && $now < $bu) || ($ba && $now > $ba));
322 322
         unset($tmp);
323 323
 
324 324
         return $flag;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 
341 341
         $flag = $pluginFlag = false;
342 342
         if (
343
-            (null !== $tmp->getID()) && (!$blocker || ($blocker && !$tmp->checkBlock($id)))
343
+            (null !== $tmp->getID()) && ( ! $blocker || ($blocker && ! $tmp->checkBlock($id)))
344 344
         ) {
345 345
             $eventResult = $this->getInvokeEventResult('OnWebAuthentication', array(
346 346
                 'userObj'       => $this,
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             } else {
357 357
                 $pluginFlag = (bool)$eventResult;
358 358
             }
359
-            if (!$pluginFlag) {
359
+            if ( ! $pluginFlag) {
360 360
                 $flag = ($tmp->get('password') == $tmp->getPassword($password));
361 361
             }
362 362
         }
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
      */
398 398
     public function logOut($cookieName = 'WebLoginPE', $fire_events = null)
399 399
     {
400
-        if (!$uid = $this->modx->getLoginUserID('web')) {
400
+        if ( ! $uid = $this->modx->getLoginUserID('web')) {
401 401
             return;
402 402
         }
403 403
         $params = array(
Please login to merge, or discard this patch.
Braces   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 /**
5 5
  * Class modUsers
6 6
  */
7
-class modUsers extends MODxAPI
8
-{
7
+class modUsers extends MODxAPI
8
+{
9 9
     /**
10 10
      * @var array
11 11
      */
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
      * @param $key
54 54
      * @return bool
55 55
      */
56
-    public function issetField($key)
57
-    {
56
+    public function issetField($key)
57
+    {
58 58
         return (array_key_exists($key, $this->default_field['user']) || array_key_exists($key,
59 59
                 $this->default_field['attribute']) || in_array($key, $this->default_field['hidden']));
60 60
     }
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
      * @param string $data
64 64
      * @return string|false
65 65
      */
66
-    protected function findUser($data)
67
-    {
68
-        switch (true) {
66
+    protected function findUser($data)
67
+    {
68
+        switch (true) {
69 69
             case (is_int($data) || ((int)$data > 0 && (string)intval($data) === $data)):
70 70
                 $find = 'attribute.internalKey';
71 71
                 break;
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
      * @param $id
87 87
      * @return $this
88 88
      */
89
-    public function edit($id)
90
-    {
89
+    public function edit($id)
90
+    {
91 91
         $id = is_scalar($id) ? trim($id) : '';
92
-        if ($this->getID() != $id) {
92
+        if ($this->getID() != $id) {
93 93
             $this->close();
94 94
             $this->newDoc = false;
95 95
 
96
-            if (!$find = $this->findUser($id)) {
96
+            if (!$find = $this->findUser($id)) {
97 97
                 $this->id = null;
98
-            } else {
98
+            } else {
99 99
                 $result = $this->query("
100 100
                     SELECT * from {$this->makeTable('web_user_attributes')} as attribute
101 101
                     LEFT JOIN {$this->makeTable('web_users')} as user ON user.id=attribute.internalKey
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
      * @param $value
118 118
      * @return $this
119 119
      */
120
-    public function set($key, $value)
121
-    {
122
-        if (is_scalar($value) && is_scalar($key) && !empty($key)) {
123
-            switch ($key) {
120
+    public function set($key, $value)
121
+    {
122
+        if (is_scalar($value) && is_scalar($key) && !empty($key)) {
123
+            switch ($key) {
124 124
                 case 'password':
125 125
                     $this->givenPassword = $value;
126 126
                     $value = $this->getPassword($value);
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
      * @param $pass
137 137
      * @return string
138 138
      */
139
-    public function getPassword($pass)
140
-    {
139
+    public function getPassword($pass)
140
+    {
141 141
         return md5($pass);
142 142
     }
143 143
 
@@ -146,83 +146,83 @@  discard block
 block discarded – undo
146 146
      * @param bool $clearCache
147 147
      * @return bool|int|null|void
148 148
      */
149
-    public function save($fire_events = false, $clearCache = false)
150
-    {
151
-        if ($this->get('email') == '' || $this->get('username') == '' || $this->get('password') == '') {
149
+    public function save($fire_events = false, $clearCache = false)
150
+    {
151
+        if ($this->get('email') == '' || $this->get('username') == '' || $this->get('password') == '') {
152 152
             $this->log['EmptyPKField'] = 'Email, username or password is empty <pre>' . print_r($this->toArray(),
153 153
                     true) . '</pre>';
154 154
 
155 155
             return false;
156 156
         }
157 157
 
158
-        if (!$this->checkUnique('web_users', 'username')) {
158
+        if (!$this->checkUnique('web_users', 'username')) {
159 159
             $this->log['UniqueUsername'] = 'username not unique <pre>' . print_r($this->get('username'),
160 160
                     true) . '</pre>';
161 161
 
162 162
             return false;
163 163
         }
164 164
 
165
-        if (!$this->checkUnique('web_user_attributes', 'email', 'internalKey')) {
165
+        if (!$this->checkUnique('web_user_attributes', 'email', 'internalKey')) {
166 166
             $this->log['UniqueEmail'] = 'Email not unique <pre>' . print_r($this->get('email'), true) . '</pre>';
167 167
 
168 168
             return false;
169 169
         }
170 170
 
171 171
         $fld = $this->toArray();
172
-        foreach ($this->default_field['user'] as $key => $value) {
172
+        foreach ($this->default_field['user'] as $key => $value) {
173 173
             $tmp = $this->get($key);
174
-            if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
174
+            if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
175 175
                 $this->field[$key] = $value;
176 176
             }
177 177
             $this->Uset($key, 'user');
178 178
             unset($fld[$key]);
179 179
         }
180
-        if (!empty($this->set['user'])) {
181
-            if ($this->newDoc) {
180
+        if (!empty($this->set['user'])) {
181
+            if ($this->newDoc) {
182 182
                 $SQL = "INSERT into {$this->makeTable('web_users')} SET " . implode(', ', $this->set['user']);
183
-            } else {
183
+            } else {
184 184
                 $SQL = "UPDATE {$this->makeTable('web_users')} SET " . implode(', ',
185 185
                         $this->set['user']) . " WHERE id = " . $this->id;
186 186
             }
187 187
             $this->query($SQL);
188 188
         }
189 189
 
190
-        if ($this->newDoc) {
190
+        if ($this->newDoc) {
191 191
             $this->id = $this->modx->db->getInsertId();
192 192
         }
193 193
 
194
-        foreach ($this->default_field['attribute'] as $key => $value) {
194
+        foreach ($this->default_field['attribute'] as $key => $value) {
195 195
             $tmp = $this->get($key);
196
-            if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
196
+            if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
197 197
                 $this->field[$key] = $value;
198 198
             }
199 199
             $this->Uset($key, 'attribute');
200 200
             unset($fld[$key]);
201 201
         }
202
-        if (!empty($this->set['attribute'])) {
203
-            if ($this->newDoc) {
202
+        if (!empty($this->set['attribute'])) {
203
+            if ($this->newDoc) {
204 204
                 $this->set('internalKey', $this->id)->Uset('internalKey', 'attribute');
205 205
                 $SQL = "INSERT into {$this->makeTable('web_user_attributes')} SET " . implode(', ',
206 206
                         $this->set['attribute']);
207
-            } else {
207
+            } else {
208 208
                 $SQL = "UPDATE {$this->makeTable('web_user_attributes')} SET " . implode(', ',
209 209
                         $this->set['attribute']) . " WHERE  internalKey = " . $this->getID();
210 210
             }
211 211
             $this->query($SQL);
212 212
         }
213 213
 
214
-        foreach ($fld as $key => $value) {
215
-            if ($value == '') {
214
+        foreach ($fld as $key => $value) {
215
+            if ($value == '') {
216 216
                 continue;
217 217
             }
218 218
             $result = $this->query("SELECT `setting_value` FROM {$this->makeTable('web_user_settings')} WHERE `webuser` = '{$this->id}' AND `setting_name` = '{$key}'");
219
-            if ($this->modx->db->getRecordCount($result) > 0) {
219
+            if ($this->modx->db->getRecordCount($result) > 0) {
220 220
                 $this->query("UPDATE {$this->makeTable('web_user_settings')} SET `setting_value` = '{$value}' WHERE `webuser` = '{$this->id}' AND `setting_name` = '{$key}';");
221
-            } else {
221
+            } else {
222 222
                 $this->query("INSERT into {$this->makeTable('web_user_settings')} SET `webuser` = {$this->id},`setting_name` = '{$key}',`setting_value` = '{$value}';");
223 223
             }
224 224
         }
225
-        if (!$this->newDoc && $this->givenPassword) {
225
+        if (!$this->newDoc && $this->givenPassword) {
226 226
             $this->invokeEvent('OnWebChangePassword', array(
227 227
                 'userObj'      => $this,
228 228
                 'userid'       => $this->id,
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             'user'    => $this->toArray()
240 240
         ), $fire_events);
241 241
 
242
-        if ($clearCache) {
242
+        if ($clearCache) {
243 243
             $this->clearCache($fire_events);
244 244
         }
245 245
 
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
      * @param bool $fire_events
252 252
      * @return bool|null|void
253 253
      */
254
-    public function delete($ids, $fire_events = false)
255
-    {
256
-        if ($this->edit($ids)) {
254
+    public function delete($ids, $fire_events = false)
255
+    {
256
+        if ($this->edit($ids)) {
257 257
             $flag = $this->query("
258 258
           DELETE user,attribute FROM {$this->makeTable('web_user_attributes')} as attribute
259 259
             LEFT JOIN {$this->makeTable('web_users')} as user ON user.id=attribute.internalKey
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                 'username'    => $this->get('username'),
268 268
                 'timestamp'   => time()
269 269
             ), $fire_events);
270
-        } else {
270
+        } else {
271 271
             $flag = false;
272 272
         }
273 273
         $this->close();
@@ -282,13 +282,13 @@  discard block
 block discarded – undo
282 282
      * @param bool $fire_events
283 283
      * @return bool
284 284
      */
285
-    public function authUser($id = 0, $fulltime = true, $cookieName = 'WebLoginPE', $fire_events = false)
286
-    {
285
+    public function authUser($id = 0, $fulltime = true, $cookieName = 'WebLoginPE', $fire_events = false)
286
+    {
287 287
         $flag = false;
288
-        if (null === $this->getID() && $id) {
288
+        if (null === $this->getID() && $id) {
289 289
             $this->edit($id);
290 290
         }
291
-        if (null !== $this->getID()) {
291
+        if (null !== $this->getID()) {
292 292
             $flag = true;
293 293
             $this->SessionHandler('start', $cookieName, $fulltime);
294 294
             $this->invokeEvent("OnWebLogin", array(
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
      * @param int $id
308 308
      * @return bool
309 309
      */
310
-    public function checkBlock($id = 0)
311
-    {
310
+    public function checkBlock($id = 0)
311
+    {
312 312
         $tmp = clone $this;
313
-        if ($id && $tmp->getID() != $id) {
313
+        if ($id && $tmp->getID() != $id) {
314 314
             $tmp->edit($id);
315 315
         }
316 316
         $now = time();
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
      * @param bool $fire_events
332 332
      * @return bool
333 333
      */
334
-    public function testAuth($id, $password, $blocker, $fire_events = false)
335
-    {
334
+    public function testAuth($id, $password, $blocker, $fire_events = false)
335
+    {
336 336
         $tmp = clone $this;
337
-        if ($id && $tmp->getID() != $id) {
337
+        if ($id && $tmp->getID() != $id) {
338 338
             $tmp->edit($id);
339 339
         }
340 340
 
341 341
         $flag = $pluginFlag = false;
342 342
         if (
343 343
             (null !== $tmp->getID()) && (!$blocker || ($blocker && !$tmp->checkBlock($id)))
344
-        ) {
344
+        ) {
345 345
             $eventResult = $this->getInvokeEventResult('OnWebAuthentication', array(
346 346
                 'userObj'       => $this,
347 347
                 'userid'        => $tmp->getID(),
@@ -349,14 +349,14 @@  discard block
 block discarded – undo
349 349
                 'userpassword'  => $password,
350 350
                 'savedpassword' => $tmp->get('password')
351 351
             ), $fire_events);
352
-            if (is_array($eventResult)) {
353
-                foreach ($eventResult as $result) {
352
+            if (is_array($eventResult)) {
353
+                foreach ($eventResult as $result) {
354 354
                     $pluginFlag = (bool)$result;
355 355
                 }
356
-            } else {
356
+            } else {
357 357
                 $pluginFlag = (bool)$eventResult;
358 358
             }
359
-            if (!$pluginFlag) {
359
+            if (!$pluginFlag) {
360 360
                 $flag = ($tmp->get('password') == $tmp->getPassword($password));
361 361
             }
362 362
         }
@@ -370,18 +370,18 @@  discard block
 block discarded – undo
370 370
      * @param string $cookieName
371 371
      * @return bool
372 372
      */
373
-    public function AutoLogin($fulltime = true, $cookieName = 'WebLoginPE', $fire_events = null)
374
-    {
373
+    public function AutoLogin($fulltime = true, $cookieName = 'WebLoginPE', $fire_events = null)
374
+    {
375 375
         $flag = false;
376
-        if (isset($_COOKIE[$cookieName])) {
376
+        if (isset($_COOKIE[$cookieName])) {
377 377
             $cookie = explode('|', $_COOKIE[$cookieName], 2);
378
-            if (isset($cookie[0], $cookie[1]) && strlen($cookie[0]) == 32 && strlen($cookie[1]) == 32) {
378
+            if (isset($cookie[0], $cookie[1]) && strlen($cookie[0]) == 32 && strlen($cookie[1]) == 32) {
379 379
                 $this->close();
380 380
                 $q = $this->modx->db->query("SELECT id FROM " . $this->makeTable('web_users') . " WHERE md5(username)='{$this->escape($cookie[0])}'");
381 381
                 $id = $this->modx->db->getValue($q);
382 382
                 if ($this->edit($id) && null !== $this->getID() && $this->get('password') == $cookie[1] && $this->testAuth($this->getID(),
383 383
                         $cookie[1], true)
384
-                ) {
384
+                ) {
385 385
                     $flag = $this->authUser($this->getID(), $fulltime, $cookieName, $fire_events);
386 386
 
387 387
                 }
@@ -395,9 +395,9 @@  discard block
 block discarded – undo
395 395
      * @param string $cookieName
396 396
      * @param null $fire_events
397 397
      */
398
-    public function logOut($cookieName = 'WebLoginPE', $fire_events = null)
399
-    {
400
-        if (!$uid = $this->modx->getLoginUserID('web')) {
398
+    public function logOut($cookieName = 'WebLoginPE', $fire_events = null)
399
+    {
400
+        if (!$uid = $this->modx->getLoginUserID('web')) {
401 401
             return;
402 402
         }
403 403
         $params = array(
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
      *
423 423
      * remeber может быть числом в секундах
424 424
      */
425
-    protected function SessionHandler($directive, $cookieName, $remember = true)
426
-    {
427
-        switch ($directive) {
425
+    protected function SessionHandler($directive, $cookieName, $remember = true)
426
+    {
427
+        switch ($directive) {
428 428
             case 'start':
429
-                if ($this->getID()) {
429
+                if ($this->getID()) {
430 430
                     $_SESSION['webShortname'] = $this->get('username');
431 431
                     $_SESSION['webFullname'] = $this->get('fullname');
432 432
                     $_SESSION['webEmail'] = $this->get('email');
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
                     $_SESSION['webUsrConfigSet'] = array();
441 441
                     $_SESSION['webUserGroupNames'] = $this->getUserGroups();
442 442
                     $_SESSION['webDocgroups'] = $this->getDocumentGroups();
443
-                    if ($remember) {
443
+                    if ($remember) {
444 444
                         $cookieValue = md5($this->get('username')) . '|' . $this->get('password');
445 445
                         $cookieExpires = time() + (is_bool($remember) ? (60 * 60 * 24 * 365 * 5) : (int)$remember);
446 446
                         setcookie($cookieName, $cookieValue, $cookieExpires, '/');
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
                 }
449 449
                 break;
450 450
             case 'destroy':
451
-                if (isset($_SESSION['mgrValidated'])) {
451
+                if (isset($_SESSION['mgrValidated'])) {
452 452
                     unset($_SESSION['webShortname']);
453 453
                     unset($_SESSION['webFullname']);
454 454
                     unset($_SESSION['webEmail']);
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
                     unset($_SESSION['webDocgroups']);
465 465
 
466 466
                     setcookie($cookieName, '', time() - 60, '/');
467
-                } else {
468
-                    if (isset($_COOKIE[session_name()])) {
467
+                } else {
468
+                    if (isset($_COOKIE[session_name()])) {
469 469
                         setcookie(session_name(), '', time() - 60, '/');
470 470
                     }
471 471
                     setcookie($cookieName, '', time() - 60, '/');
@@ -481,11 +481,11 @@  discard block
 block discarded – undo
481 481
      * @param int $userID
482 482
      * @return array
483 483
      */
484
-    public function getDocumentGroups($userID = 0)
485
-    {
484
+    public function getDocumentGroups($userID = 0)
485
+    {
486 486
         $out = array();
487 487
         $user = $this->switchObject($userID);
488
-        if (null !== $user->getID()) {
488
+        if (null !== $user->getID()) {
489 489
             $web_groups = $this->modx->getFullTableName('web_groups');
490 490
             $webgroup_access = $this->modx->getFullTableName('webgroup_access');
491 491
 
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
      * @param int $userID
505 505
      * @return array
506 506
      */
507
-    public function getUserGroups($userID = 0)
508
-    {
507
+    public function getUserGroups($userID = 0)
508
+    {
509 509
         $out = array();
510 510
         $user = $this->switchObject($userID);
511
-        if (null !== $user->getID()) {
511
+        if (null !== $user->getID()) {
512 512
             $web_groups = $this->makeTable('web_groups');
513 513
             $webgroup_names = $this->makeTable('webgroup_names');
514 514
 
@@ -527,11 +527,11 @@  discard block
 block discarded – undo
527 527
      * @param array $groupIds
528 528
      * @return $this
529 529
      */
530
-    public function setUserGroups($userID = 0, $groupIds = array())
531
-    {
530
+    public function setUserGroups($userID = 0, $groupIds = array())
531
+    {
532 532
         $user = $this->switchObject($userID);
533
-        if (($uid = $user->getID()) && is_array($groupIds)) {
534
-            foreach ($groupIds as $gid) {
533
+        if (($uid = $user->getID()) && is_array($groupIds)) {
534
+            foreach ($groupIds as $gid) {
535 535
                 $this->query("REPLACE INTO {$this->makeTable('web_groups')} (`webgroup`, `webuser`) VALUES ('{$gid}', '{$uid}')");
536 536
             }
537 537
         }
Please login to merge, or discard this patch.
assets/lib/MODxAPI/MODx.php 1 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 && null !== $this->getID()):
375
+            case ( ! $id && null !== $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.
assets/lib/Module/Action.php 1 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() !== null && ((is_object($callback) && ($callback instanceof \Closure)) || is_callable($callback))) {
101
+            if ($modObj->getID() !== null && ((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/snippets/DocLister/lib/DLCollection.class.php 1 patch
Braces   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 /**
5 5
  * Class DLCollection
6 6
  */
7
-class DLCollection extends \Helpers\Collection
8
-{
7
+class DLCollection extends \Helpers\Collection
8
+{
9 9
     /**
10 10
      * Объект DocumentParser - основной класс MODX
11 11
      * @var \DocumentParser
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
      * @param DocumentParser $modx
19 19
      * @param mixed $data
20 20
      */
21
-    public function __construct(DocumentParser $modx, $data = array())
22
-    {
21
+    public function __construct(DocumentParser $modx, $data = array())
22
+    {
23 23
         $this->modx = $modx;
24
-        switch (true) {
24
+        switch (true) {
25 25
             case is_resource($data):
26 26
             case (is_object($data) && $data instanceof \mysqli_result):
27 27
                 $this->fromQuery($data, false);
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
                 $this->data = $data;
31 31
                 break;
32 32
             case (is_object($data) && $data instanceof \IteratorAggregate):
33
-                foreach ($data as $key => $item) {
33
+                foreach ($data as $key => $item) {
34 34
                     $this->add($item, $key);
35 35
                 }
36 36
                 break;
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
      * @param bool $exec
45 45
      * @return int
46 46
      */
47
-    public function fromQuery($q, $exec = true)
48
-    {
47
+    public function fromQuery($q, $exec = true)
48
+    {
49 49
         $i = 0;
50
-        if ($exec) {
50
+        if ($exec) {
51 51
             $q = $this->modx->db->query($q);
52 52
         }
53
-        while ($row = $this->modx->db->getRow($q)) {
53
+        while ($row = $this->modx->db->getRow($q)) {
54 54
             $data = $this->create($row);
55 55
             $this->add($data);
56 56
             $i++;
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
      * @param array $data
64 64
      * @return static
65 65
      */
66
-    public function create(array $data = array())
67
-    {
66
+    public function create(array $data = array())
67
+    {
68 68
         return new static($this->modx, $data);
69 69
     }
70 70
 }
Please login to merge, or discard this patch.
assets/snippets/DocLister/lib/DLpaginate.class.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
     public function getOutput()
252 252
     {
253 253
         $out = '';
254
-        if (!$this->calculate && $this->calculate() && !empty($this->pagination)) {
254
+        if ( ! $this->calculate && $this->calculate() && ! empty($this->pagination)) {
255 255
             $out = str_replace(array("[+class+]", "[+wrap+]"), array($this->className, $this->pagination),
256 256
                     $this->mainTpl) . "\n";
257 257
         }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     {
289 289
         $flag = (strpos($this->target, '?') === false);
290 290
         $value = $this->getPageQuery($id);
291
-        if ($flag && !empty($this->urlF)) {
291
+        if ($flag && ! empty($this->urlF)) {
292 292
             $out = str_replace($this->urlF, $value, $this->target);
293 293
         } else {
294 294
             $out = $this->target;
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
         $this->calculate = true;
310 310
         $error = false;
311 311
 
312
-        if (!empty($this->urlF) && is_scalar($this->urlF) && $this->urlF != '%' && strpos($this->target,
312
+        if ( ! empty($this->urlF) && is_scalar($this->urlF) && $this->urlF != '%' && strpos($this->target,
313 313
                 $this->urlF) === false
314 314
         ) {
315 315
             //Es necesario especificar el comodin para sustituir
316 316
             $error = true;
317
-        } elseif (!empty($this->urlF) && is_scalar($this->urlF) && $this->urlF == '%' && strpos($this->target,
317
+        } elseif ( ! empty($this->urlF) && is_scalar($this->urlF) && $this->urlF == '%' && strpos($this->target,
318 318
                 $this->urlF) === false
319 319
         ) {
320 320
             $error = true;
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
         if ($this->total_pages < 0) {
324 324
             $error = true;
325 325
         }
326
-        if (!is_int($this->limit)) {
326
+        if ( ! is_int($this->limit)) {
327 327
             $error = true;
328 328
         }
329 329
         if ($error) {
Please login to merge, or discard this patch.
Braces   +74 added lines, -72 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * Class DLpaginate
5 5
  */
6
-class DLpaginate
7
-{
6
+class DLpaginate
7
+{
8 8
     /**
9 9
      * Script Name: *Digg Style Paginator Class
10 10
      * Script URI: http://www.mis-algoritmos.com/2007/05/27/digg-style-pagination-class/
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
      * @param array $config
58 58
      * @return $this
59 59
      */
60
-    public function setMode($mode, array $config = array())
61
-    {
60
+    public function setMode($mode, array $config = array())
61
+    {
62 62
         $this->mode = $mode;
63 63
         $this->modeConfig = $config;
64 64
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
      * @param $value
72 72
      * @return $this
73 73
      */
74
-    public function items($value)
75
-    {
74
+    public function items($value)
75
+    {
76 76
         $this->total_pages = (int)$value;
77 77
 
78 78
         return $this;
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
      * @param $value
85 85
      * @return $this
86 86
      */
87
-    public function limit($value)
88
-    {
87
+    public function limit($value)
88
+    {
89 89
         $this->limit = (int)$value;
90 90
 
91 91
         return $this;
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
      * @param $value
98 98
      * @return $this
99 99
      */
100
-    public function target($value)
101
-    {
100
+    public function target($value)
101
+    {
102 102
         $this->target = $value;
103 103
 
104 104
         return $this;
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
      * @param $value
111 111
      * @return $this
112 112
      */
113
-    public function currentPage($value)
114
-    {
113
+    public function currentPage($value)
114
+    {
115 115
         $this->page = (int)$value;
116 116
 
117 117
         return $this;
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
      * @param $value
124 124
      * @return $this
125 125
      */
126
-    public function adjacents($value)
127
-    {
126
+    public function adjacents($value)
127
+    {
128 128
         $this->adjacents = (int)$value;
129 129
 
130 130
         return $this;
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
      * @param string $value
137 137
      * @return $this
138 138
      */
139
-    public function showCounter($value = "")
140
-    {
139
+    public function showCounter($value = "")
140
+    {
141 141
         $this->showCounter = ($value === true) ? true : false;
142 142
 
143 143
         return $this;
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
      * @param string $value
150 150
      * @return $this
151 151
      */
152
-    public function changeClass($value = "")
153
-    {
152
+    public function changeClass($value = "")
153
+    {
154 154
         $this->className = $value;
155 155
 
156 156
         return $this;
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
      * @param $value
161 161
      * @return $this
162 162
      */
163
-    public function mainTpl($value)
164
-    {
163
+    public function mainTpl($value)
164
+    {
165 165
         $this->mainTpl = $value;
166 166
 
167 167
         return $this;
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
      * @param $value
172 172
      * @return $this
173 173
      */
174
-    public function nextLabel($value)
175
-    {
174
+    public function nextLabel($value)
175
+    {
176 176
         $this->nextT = $value;
177 177
 
178 178
         return $this;
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
      * @param $value
183 183
      * @return $this
184 184
      */
185
-    public function nextIcon($value)
186
-    {
185
+    public function nextIcon($value)
186
+    {
187 187
         $this->nextI = $value;
188 188
 
189 189
         return $this;
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
      * @param $value
194 194
      * @return $this
195 195
      */
196
-    public function prevLabel($value)
197
-    {
196
+    public function prevLabel($value)
197
+    {
198 198
         $this->prevT = $value;
199 199
 
200 200
         return $this;
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
      * @param $value
205 205
      * @return $this
206 206
      */
207
-    public function prevIcon($value)
208
-    {
207
+    public function prevIcon($value)
208
+    {
209 209
         $this->prevI = $value;
210 210
 
211 211
         return $this;
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
      * @param string $value
218 218
      * @return $this
219 219
      */
220
-    public function parameterName($value = "")
221
-    {
220
+    public function parameterName($value = "")
221
+    {
222 222
         $this->parameterName = $value;
223 223
 
224 224
         return $this;
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
      * @param string $value
231 231
      * @return $this
232 232
      */
233
-    public function urlFriendly($value = "%")
234
-    {
235
-        if (preg_match('/^\s/', $value)) {
233
+    public function urlFriendly($value = "%")
234
+    {
235
+        if (preg_match('/^\s/', $value)) {
236 236
             $this->urlF = false;
237 237
         }
238 238
         $this->urlF = $value;
@@ -240,18 +240,18 @@  discard block
 block discarded – undo
240 240
         return $this;
241 241
     }
242 242
 
243
-    public function show()
244
-    {
243
+    public function show()
244
+    {
245 245
         echo $this->getOutput();
246 246
     }
247 247
 
248 248
     /**
249 249
      * @return string
250 250
      */
251
-    public function getOutput()
252
-    {
251
+    public function getOutput()
252
+    {
253 253
         $out = '';
254
-        if (!$this->calculate && $this->calculate() && !empty($this->pagination)) {
254
+        if (!$this->calculate && $this->calculate() && !empty($this->pagination)) {
255 255
             $out = str_replace(array("[+class+]", "[+wrap+]"), array($this->className, $this->pagination),
256 256
                     $this->mainTpl) . "\n";
257 257
         }
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
      * @param $page
264 264
      * @return int|mixed
265 265
      */
266
-    protected function getPageQuery($page)
267
-    {
268
-        switch ($this->mode) {
266
+    protected function getPageQuery($page)
267
+    {
268
+        switch ($this->mode) {
269 269
             case 'offset':
270 270
                 $display = isset($this->modeConfig['display']) ? $this->modeConfig['display'] : 0;
271 271
                 $out = $display * ($page - 1);
@@ -284,15 +284,15 @@  discard block
 block discarded – undo
284 284
      * @param $id
285 285
      * @return mixed|string
286 286
      */
287
-    public function get_pagenum_link($id)
288
-    {
287
+    public function get_pagenum_link($id)
288
+    {
289 289
         $flag = (strpos($this->target, '?') === false);
290 290
         $value = $this->getPageQuery($id);
291
-        if ($flag && !empty($this->urlF)) {
291
+        if ($flag && !empty($this->urlF)) {
292 292
             $out = str_replace($this->urlF, $value, $this->target);
293
-        } else {
293
+        } else {
294 294
             $out = $this->target;
295
-            if ($id > 1) {
295
+            if ($id > 1) {
296 296
                 $out .= ($flag ? "?" : "&") . $this->parameterName . "=" . $value;
297 297
             }
298 298
         }
@@ -303,30 +303,30 @@  discard block
 block discarded – undo
303 303
     /**
304 304
      * @return bool
305 305
      */
306
-    public function calculate()
307
-    {
306
+    public function calculate()
307
+    {
308 308
         $this->pagination = "";
309 309
         $this->calculate = true;
310 310
         $error = false;
311 311
 
312 312
         if (!empty($this->urlF) && is_scalar($this->urlF) && $this->urlF != '%' && strpos($this->target,
313 313
                 $this->urlF) === false
314
-        ) {
314
+        ) {
315 315
             //Es necesario especificar el comodin para sustituir
316 316
             $error = true;
317 317
         } elseif (!empty($this->urlF) && is_scalar($this->urlF) && $this->urlF == '%' && strpos($this->target,
318 318
                 $this->urlF) === false
319
-        ) {
319
+        ) {
320 320
             $error = true;
321 321
         }
322 322
 
323
-        if ($this->total_pages < 0) {
323
+        if ($this->total_pages < 0) {
324 324
             $error = true;
325 325
         }
326
-        if (!is_int($this->limit)) {
326
+        if (!is_int($this->limit)) {
327 327
             $error = true;
328 328
         }
329
-        if ($error) {
329
+        if ($error) {
330 330
             return false;
331 331
         }
332 332
 
@@ -342,26 +342,28 @@  discard block
 block discarded – undo
342 342
                 Now we apply our rules and draw the pagination object.
343 343
                 We're actually saving the code to a variable in case we want to draw it more than once.
344 344
         */
345
-        if ($lastpage > 1) {
346
-            if ($this->page) {
347
-                if ($this->page > 1) {
345
+        if ($lastpage > 1) {
346
+            if ($this->page) {
347
+                if ($this->page > 1) {
348 348
                     $this->pagination .= $this->firstT ? $this->renderItemTPL($this->firstT, 0) : '';
349 349
                     $this->pagination .= $this->prevT ? $this->renderItemTPL($this->prevT, $prev) : '';
350
-                } else {
350
+                } else {
351 351
                     $this->pagination .= $this->firstI ? $this->renderItemTPL($this->firstI, 0) : '';
352 352
                     $this->pagination .= $this->prevI ? $this->renderItemTPL($this->prevI, $prev) : '';
353 353
                 }
354 354
             }
355 355
             //pages
356
-            if ($lastpage < 7 + ($this->adjacents * 2)) { //not enough pages to bother breaking it up
357
-                for ($counter = 1; $counter <= $lastpage; $counter++) {
356
+            if ($lastpage < 7 + ($this->adjacents * 2)) {
357
+//not enough pages to bother breaking it up
358
+                for ($counter = 1; $counter <= $lastpage; $counter++) {
358 359
                     $tpl = ($counter == $this->page) ? $this->currentT : $this->numberT;
359 360
                     $this->pagination .= $this->renderItemTPL($tpl, $counter);
360 361
                 }
361
-            } elseif ($lastpage > 5 + ($this->adjacents * 2)) { //enough pages to hide some
362
+            } elseif ($lastpage > 5 + ($this->adjacents * 2)) {
363
+//enough pages to hide some
362 364
                 //close to beginning; only hide later pages
363
-                if ($this->page < 1 + ($this->adjacents * 2)) {
364
-                    for ($counter = 1; $counter < 4 + ($this->adjacents * 2); $counter++) {
365
+                if ($this->page < 1 + ($this->adjacents * 2)) {
366
+                    for ($counter = 1; $counter < 4 + ($this->adjacents * 2); $counter++) {
365 367
                         $tpl = ($counter == $this->page) ? $this->currentT : $this->numberT;
366 368
                         $this->pagination .= $this->renderItemTPL($tpl, $counter);
367 369
                     }
@@ -369,12 +371,12 @@  discard block
 block discarded – undo
369 371
                     $this->pagination .= $this->renderItemTPL($this->numberT, $lpm1);
370 372
                     $this->pagination .= $this->renderItemTPL($this->numberT, $lastpage);
371 373
                 } //in middle; hide some front and some back
372
-                elseif ($lastpage - ($this->adjacents * 2) > $this->page && $this->page > ($this->adjacents * 2)) {
374
+                elseif ($lastpage - ($this->adjacents * 2) > $this->page && $this->page > ($this->adjacents * 2)) {
373 375
                     $this->pagination .= $this->renderItemTPL($this->numberT, 1);
374 376
                     $this->pagination .= $this->renderItemTPL($this->numberT, 2);
375 377
                     $this->pagination .= $this->renderItemTPL($this->dotsT, 3);
376 378
 
377
-                    for ($counter = $this->page - $this->adjacents; $counter <= $this->page + $this->adjacents; $counter++) {
379
+                    for ($counter = $this->page - $this->adjacents; $counter <= $this->page + $this->adjacents; $counter++) {
378 380
                         $tpl = ($counter == $this->page) ? $this->currentT : $this->numberT;
379 381
                         $this->pagination .= $this->renderItemTPL($tpl, $counter);
380 382
                     }
@@ -382,27 +384,27 @@  discard block
 block discarded – undo
382 384
                     $this->pagination .= $this->renderItemTPL($this->numberT, $lpm1);
383 385
                     $this->pagination .= $this->renderItemTPL($this->numberT, $lastpage);
384 386
                 } //close to end; only hide early pages
385
-                else {
387
+                else {
386 388
                     $this->pagination .= $this->renderItemTPL($this->numberT, 1);
387 389
                     $this->pagination .= $this->renderItemTPL($this->numberT, 2);
388 390
                     $this->pagination .= $this->renderItemTPL($this->dotsT, 3);
389 391
 
390
-                    for ($counter = $lastpage - (2 + ($this->adjacents * 2)); $counter <= $lastpage; $counter++) {
392
+                    for ($counter = $lastpage - (2 + ($this->adjacents * 2)); $counter <= $lastpage; $counter++) {
391 393
                         $tpl = ($counter == $this->page) ? $this->currentT : $this->numberT;
392 394
                         $this->pagination .= $this->renderItemTPL($tpl, $counter);
393 395
                     }
394 396
                 }
395 397
             }
396
-            if ($this->page) {
397
-                if ($this->page < $counter - 1) {
398
+            if ($this->page) {
399
+                if ($this->page < $counter - 1) {
398 400
                     $this->pagination .= $this->nextT ? $this->renderItemTPL($this->nextT, $next) : '';
399 401
                     $this->pagination .= $this->lastT ? $this->renderItemTPL($this->lastT, $lastpage) : '';
400
-                } else {
402
+                } else {
401 403
                     $this->pagination .= $this->nextI ? $this->renderItemTPL($this->nextI, $next) : '';
402 404
                     $this->pagination .= $this->lastI ? $this->renderItemTPL($this->lastI, $lastpage) : '';
403 405
                 }
404 406
 
405
-                if ($this->showCounter) {
407
+                if ($this->showCounter) {
406 408
                     $this->pagination .= "<div class=\"pagination_data\">($this->total_pages Pages)</div>";
407 409
                 }
408 410
             }
@@ -416,8 +418,8 @@  discard block
 block discarded – undo
416 418
      * @param $num
417 419
      * @return mixed
418 420
      */
419
-    protected function renderItemTPL($tpl, $num)
420
-    {
421
+    protected function renderItemTPL($tpl, $num)
422
+    {
421 423
         return str_replace(array('[+num+]', '[+link+]'), array($num, $this->get_pagenum_link($num)), $tpl);
422 424
     }
423 425
 }
Please login to merge, or discard this patch.
assets/snippets/DocLister/snippet.DLReflect.php 1 patch
Braces   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *            year - по годам
26 26
  */
27 27
 $reflectType = APIHelpers::getkey($params, 'reflectType', 'month');
28
-if (!in_array($reflectType, array('year', 'month'))) {
28
+if (!in_array($reflectType, array('year', 'month'))) {
29 29
     return '';
30 30
 }
31 31
 
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
  */
51 51
 $activeReflectTPL = APIHelpers::getkey($params, 'activeReflectTPL', '@CODE: <li><span>[+title+]</span></li>');
52 52
 
53
-list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function () {
53
+list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function () {
54 54
     return array('m-Y', '%m-%Y', array('DLReflect', 'validateMonth'));
55
-}, function () {
55
+}, function () {
56 56
     return array('Y', '%Y', array('DLReflect', 'validateYear'));
57 57
 });
58 58
 $tmp = $originalDate = date($dateFormat);
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
  *        Если не указан в параметре, то генерируется автоматически текущая дата
66 66
  */
67 67
 $currentReflect = APIHelpers::getkey($params, 'currentReflect', $tmp);
68
-if (!call_user_func($reflectValidator, $currentYear)) {
68
+if (!call_user_func($reflectValidator, $currentYear)) {
69 69
     $currentReflect = $tmp;
70 70
 }
71 71
 $originalCurrentReflect = $currentReflect;
72 72
 
73 73
 $selectCurrentReflect = APIHelpers::getkey($params, 'selectCurrentReflect', 1);
74
-if (!$selectCurrentReflect && $currentReflect == $tmp) {
74
+if (!$selectCurrentReflect && $currentReflect == $tmp) {
75 75
     $currentReflect = null;
76 76
 }
77 77
 
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
  */
100 100
 $tmp = APIHelpers::getkey($params, 'activeReflect', $currentReflect);
101 101
 $tmpGet = APIHelpers::getkey($_GET, $reflectType, $tmp);
102
-if (!call_user_func($reflectValidator, $tmpGet)) {
102
+if (!call_user_func($reflectValidator, $tmpGet)) {
103 103
     $activeReflect = $tmp;
104
-    if (!call_user_func($reflectValidator, $activeReflect)) {
104
+    if (!call_user_func($reflectValidator, $activeReflect)) {
105 105
         $activeReflect = $currentReflect;
106 106
     }
107
-} else {
107
+} else {
108 108
     $activeReflect = $tmpGet;
109 109
 }
110 110
 
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 $DLParams['api'] = 'id';
160 160
 $DLParams['orderBy'] = $reflectField;
161 161
 $DLParams['saveDLObject'] = 'DLAPI';
162
-if ($reflectSource == 'tv') {
162
+if ($reflectSource == 'tv') {
163 163
     $DLParams['tvSortType'] = 'TVDATETIME';
164 164
     $DLParams['selectFields'] = "DATE_FORMAT(STR_TO_DATE(`dltv_" . $reflectField . "_1`.`value`,'%d-%m-%Y %H:%i:%s'), '" . $sqlDateFormat . "') as `id`";
165
-} else {
165
+} else {
166 166
     $DLParams['orderBy'] = $reflectField;
167 167
     $DLParams['selectFields'] = "DATE_FORMAT(FROM_UNIXTIME(" . $reflectField . "), '" . $sqlDateFormat . "') as `id`";
168 168
 }
@@ -170,32 +170,32 @@  discard block
 block discarded – undo
170 170
 /** Получаем объект DocLister'a */
171 171
 $DLAPI = $modx->getPlaceholder('DLAPI');
172 172
 
173
-if ($reflectType == 'month') {
173
+if ($reflectType == 'month') {
174 174
     //Загружаем лексикон с месяцами
175 175
     $DLAPI->loadLang('months');
176 176
 }
177 177
 
178 178
 /** Разбираем API ответ от DocLister'a */
179 179
 $totalReflects = json_decode($totalReflects, true);
180
-if (is_null($totalReflects)) {
180
+if (is_null($totalReflects)) {
181 181
     $totalReflects = array();
182 182
 }
183 183
 $totalReflects = new DLCollection($modx, $totalReflects);
184
-$totalReflects = $totalReflects->filter(function ($el) {
184
+$totalReflects = $totalReflects->filter(function ($el) {
185 185
     return !empty($el['id']);
186 186
 });
187 187
 /** Добавляем активную дату в коллекцию */
188
-if (!is_null($activeReflect)) {
188
+if (!is_null($activeReflect)) {
189 189
     $totalReflects->add(array('id' => $activeReflect), $activeReflect);
190 190
 }
191 191
 $hasCurrentReflect = ($totalReflects->indexOf(array('id' => $originalCurrentReflect)) !== false);
192 192
 
193 193
 /** Добавляем текущую дату в коллекцию */
194
-if ($appendCurrentReflect) {
194
+if ($appendCurrentReflect) {
195 195
     $totalReflects->add(array('id' => $originalCurrentReflect), $originalCurrentReflect);
196 196
 }
197 197
 /** Сортируем даты по возрастанию */
198
-$totalReflects->sort(function ($a, $b) use ($dateFormat) {
198
+$totalReflects->sort(function ($a, $b) use ($dateFormat) {
199 199
     $aDate = DateTime::createFromFormat($dateFormat, $a['id']);
200 200
     $bDate = DateTime::createFromFormat($dateFormat, $b['id']);
201 201
 
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
     $activeReflect,
208 208
     $originalDate,
209 209
     $dateFormat
210
-) {
210
+) {
211 211
     $aDate = DateTime::createFromFormat($dateFormat, $val['id']);
212
-    if (is_null($activeReflect)) {
212
+    if (is_null($activeReflect)) {
213 213
         $activeReflect = $originalDate;
214 214
     }
215 215
     $bDate = DateTime::createFromFormat($dateFormat, $activeReflect);
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     return $aDate->getTimestamp() < $bDate->getTimestamp();
218 218
 });
219 219
 /** Удаляем текущую активную дату из списка дат идущих за текущим */
220
-if ($rReflect->indexOf(array('id' => $originalCurrentReflect)) !== false) {
220
+if ($rReflect->indexOf(array('id' => $originalCurrentReflect)) !== false) {
221 221
     $rReflect->reindex()->remove(0);
222 222
 }
223 223
 /** Разворачиваем в обратном порядке список дат до текущей даты */
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
 
226 226
 /** Расчитываем сколько дат из какого списка взять */
227 227
 $showBefore = ($lReflect->count() < $limitBefore || empty($limitBefore)) ? $lReflect->count() : $limitBefore;
228
-if (($rReflect->count() < $limitAfter) || empty($limitAfter)) {
228
+if (($rReflect->count() < $limitAfter) || empty($limitAfter)) {
229 229
     $showAfter = $rReflect->count();
230 230
     $showBefore += !empty($limitAfter) ? ($limitAfter - $rReflect->count()) : 0;
231
-} else {
232
-    if ($limitBefore > 0) {
231
+} else {
232
+    if ($limitBefore > 0) {
233 233
         $showAfter = $limitAfter + ($limitBefore - $showBefore);
234
-    } else {
234
+    } else {
235 235
         $showAfter = $limitAfter;
236 236
     }
237 237
 }
@@ -241,25 +241,25 @@  discard block
 block discarded – undo
241 241
 $outReflects = new DLCollection($modx);
242 242
 /** Берем нужное число элементов с левой стороны */
243 243
 $i = 0;
244
-foreach ($lReflect as $item) {
245
-    if ((++$i) > $showBefore) {
244
+foreach ($lReflect as $item) {
245
+    if ((++$i) > $showBefore) {
246 246
         break;
247 247
     }
248 248
     $outReflects->add($item['id']);
249 249
 }
250 250
 /** Добавляем текущую дату */
251
-if (is_null($activeReflect)) {
252
-    if (($hasCurrentReflect && !$selectCurrentReflect) || $appendCurrentReflect) {
251
+if (is_null($activeReflect)) {
252
+    if (($hasCurrentReflect && !$selectCurrentReflect) || $appendCurrentReflect) {
253 253
         $outReflects->add($originalCurrentReflect);
254 254
     }
255
-} else {
255
+} else {
256 256
     $outReflects->add($activeReflect);
257 257
 }
258 258
 
259 259
 /** Берем оставшее число позиций с правой стороны */
260 260
 $i = 0;
261
-foreach ($rReflect as $item) {
262
-    if ((++$i) > $showAfter) {
261
+foreach ($rReflect as $item) {
262
+    if ((++$i) > $showAfter) {
263 263
         break;
264 264
     }
265 265
     $outReflects->add($item['id']);
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 
268 268
 $sortDir = APIHelpers::getkey($params, 'sortDir', 'ASC');
269 269
 /** Сортируем результатирующий список  */
270
-$outReflects = $outReflects->sort(function ($a, $b) use ($sortDir, $dateFormat) {
270
+$outReflects = $outReflects->sort(function ($a, $b) use ($sortDir, $dateFormat) {
271 271
     $aDate = DateTime::createFromFormat($dateFormat, $a);
272 272
     $bDate = DateTime::createFromFormat($dateFormat, $b);
273 273
     $out = false;
274
-    switch ($sortDir) {
274
+    switch ($sortDir) {
275 275
         case 'ASC':
276 276
             $out = $aDate->getTimestamp() - $bDate->getTimestamp();
277 277
             break;
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
 })->reindex()->unique();
285 285
 
286 286
 /** Применяем шаблон к каждой отображаемой дате */
287
-foreach ($outReflects as $reflectItem) {
287
+foreach ($outReflects as $reflectItem) {
288 288
     $tpl = (!is_null($activeReflect) && $activeReflect == $reflectItem) ? $activeReflectTPL : $reflectTPL;
289 289
 
290
-    $data = DLReflect::switchReflect($reflectType, function () use ($reflectItem, $DLAPI) {
290
+    $data = DLReflect::switchReflect($reflectType, function () use ($reflectItem, $DLAPI) {
291 291
         list($vMonth, $vYear) = explode('-', $reflectItem, 2);
292 292
 
293 293
         return array(
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             'monthName' => $DLAPI->getMsg('months.' . (int)$vMonth),
296 296
             'year'      => $vYear,
297 297
         );
298
-    }, function () use ($reflectItem) {
298
+    }, function () use ($reflectItem) {
299 299
         return array(
300 300
             'year' => $reflectItem
301 301
         );
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
 /**
322 322
  * Ну и выводим стек отладки если это нужно
323 323
  */
324
-if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
324
+if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
325 325
     $debug = $DLAPI->debug->showLog();
326
-} else {
326
+} else {
327 327
     $debug = '';
328 328
 }
329 329
 
Please login to merge, or discard this patch.
assets/snippets/DLUsers/src/Actions.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     public function logout($params)
98 98
     {
99 99
         $LogoutName = APIHelpers::getkey($params, 'LogoutName', 'logout');
100
-        if (is_scalar($LogoutName) && !empty($LogoutName) && isset($_GET[$LogoutName])) {
100
+        if (is_scalar($LogoutName) && ! empty($LogoutName) && isset($_GET[$LogoutName])) {
101 101
             $userID = $this->UserID('web');
102 102
             if ($userID) {
103 103
                 $this->userObj->edit($userID);
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             $dataTPL = $this->userObj->toArray();
178 178
             $dataTPL['url.logout'] = $this->logoutUrl($params);
179 179
             $homeID = APIHelpers::getkey($params, 'homeID');
180
-            if (!empty($homeID)) {
180
+            if ( ! empty($homeID)) {
181 181
                 $dataTPL['url.profile'] = $this->makeUrl($homeID);
182 182
             }
183 183
         } else {
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                 'errorCode'  => $errorCode
198 198
             );
199 199
             $authId = APIHelpers::getkey($params, 'authId');
200
-            if (!empty($authId)) {
200
+            if ( ! empty($authId)) {
201 201
                 $dataTPL['authPage'] = $this->makeUrl($authId);
202 202
                 $dataTPL['method'] = strtolower(__CLASS__ . '::' . 'authpage');
203 203
             }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         if ($request === false) {
232 232
             $request = array();
233 233
         }
234
-        if (!empty($_SERVER['HTTP_REFERER'])) {
234
+        if ( ! empty($_SERVER['HTTP_REFERER'])) {
235 235
             /**
236 236
              * Thank you for super protection against hacking in protect.inc.php:-)
237 237
              */
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
244 244
             $backUrl = APIHelpers::getkey($_POST, 'backUrl', $POST['backUrl']);
245
-            if (!is_scalar($backUrl)) {
245
+            if ( ! is_scalar($backUrl)) {
246 246
                 $backUrl = $refer;
247 247
             } else {
248 248
                 $backUrl = urldecode($backUrl);
@@ -254,12 +254,12 @@  discard block
 block discarded – undo
254 254
         if ($backUrl === false) {
255 255
             $backUrl = array();
256 256
         }
257
-        if (!empty($backUrl['path']) && $request['path'] != $backUrl['path']) {
257
+        if ( ! empty($backUrl['path']) && $request['path'] != $backUrl['path']) {
258 258
             $POST['backUrl'] = $backUrl['path'];
259 259
         } else {
260 260
             $POST['backUrl'] = $this->getBackUrl($backUrl);
261 261
         }
262
-        if (!empty($POST['backUrl'])) {
262
+        if ( ! empty($POST['backUrl'])) {
263 263
             $idURL = $this->moveTo(array(
264 264
                 'url'      => '/' . ltrim($POST['backUrl'], '/'),
265 265
                 'validate' => true
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
     {
296 296
         $selfHost = rtrim(str_replace("http://", "", $this->config['site_url']), '/');
297 297
         if (empty($request['host']) || $request['host'] == $selfHost) {
298
-            $query = !empty($request['query']) ? '?' . $request['query'] : '';
299
-            $out = !empty($request['path']) ? $request['path'] . $query : '';
298
+            $query = ! empty($request['query']) ? '?' . $request['query'] : '';
299
+            $out = ! empty($request['path']) ? $request['path'] . $query : '';
300 300
         } else {
301 301
             $out = '';
302 302
         }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
                 'email'    => APIHelpers::getkey($_POST, $emailField, ''),
336 336
                 'remember' => (bool)((int)APIHelpers::getkey($_POST, $rememberField, 0))
337 337
             ));
338
-            if (!empty($POST['email']) && is_scalar($POST['email']) && !$userObj->emailValidate($POST['email'],
338
+            if ( ! empty($POST['email']) && is_scalar($POST['email']) && ! $userObj->emailValidate($POST['email'],
339 339
                     false)
340 340
             ) {
341 341
                 $userObj->edit($POST['email']);
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
                     "rememberme"   => $POST['remember'],
347 347
                     'userObj'      => $userObj
348 348
                 ));
349
-                if ($userObj->getID() && !$userObj->checkBlock($userObj->getID())) {
349
+                if ($userObj->getID() && ! $userObj->checkBlock($userObj->getID())) {
350 350
                     $pluginFlag = $this->modx->invokeEvent("OnWebAuthentication", array(
351 351
                         "userid"        => $userObj->getID(),
352 352
                         "username"      => $userObj->get('username'),
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
                 $POST['email'] = '';
386 386
             }
387 387
         }
388
-        if (!empty($error)) {
388
+        if ( ! empty($error)) {
389 389
             $errorCode = $error;
390 390
             $error = APIHelpers::getkey($params, $error, '');
391 391
             $error = static::getLangMsg($error, $error);
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
      */
435 435
     public function isGuestGoHome($params)
436 436
     {
437
-        if (!$this->UserID('web')) {
437
+        if ( ! $this->UserID('web')) {
438 438
             /**
439 439
              * @see : http://modx.im/blog/triks/105.html
440 440
              */
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     {
471 471
         $id = (int)APIHelpers::getkey($params, 'id', 0);
472 472
         $uri = APIHelpers::getkey($params, 'url', '');
473
-        if ((empty($uri) && !empty($id)) || !is_string($uri)) {
473
+        if ((empty($uri) && ! empty($id)) || ! is_string($uri)) {
474 474
             $uri = $this->makeUrl($id);
475 475
         }
476 476
         $code = (int)APIHelpers::getkey($params, 'code', 0);
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
     protected static function loadLang($lang)
539 539
     {
540 540
         $file = dirname(dirname(__FILE__)) . '/lang/' . $lang . '.php';
541
-        if (!FS::getInstance()->checkFile($file)) {
541
+        if ( ! FS::getInstance()->checkFile($file)) {
542 542
             $file = false;
543 543
         }
544
-        if (!empty($lang) && !isset(static::$langDic[$lang]) && !empty($file)) {
544
+        if ( ! empty($lang) && ! isset(static::$langDic[$lang]) && ! empty($file)) {
545 545
             static::$langDic[$lang] = include_once($file);
546 546
             if (is_array(static::$langDic[$lang])) {
547 547
                 static::$langDic[$lang] = APIHelpers::renameKeyArr(static::$langDic[$lang], $lang);
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
             }
551 551
         }
552 552
 
553
-        return !(empty($lang) || empty(static::$langDic[$lang]));
553
+        return ! (empty($lang) || empty(static::$langDic[$lang]));
554 554
     }
555 555
 
556 556
     /**
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
         }
569 569
         if (class_exists('evoBabel', false) && isset(self::$instance->modx->snippetCache['lang'])) {
570 570
             $msg = self::$instance->modx->runSnippet('lang', array('a' => 'DLUsers.' . $key));
571
-            if (!empty($msg)) {
571
+            if ( ! empty($msg)) {
572 572
                 $out = $msg;
573 573
             }
574 574
         }
Please login to merge, or discard this patch.
Braces   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
  * Class Actions
14 14
  * @package DLUsers
15 15
  */
16
-class Actions
17
-{
16
+class Actions
17
+{
18 18
     /**
19 19
      * Объект DocumentParser - основной класс MODX
20 20
      * @var \DocumentParser
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @return self
42 42
      */
43
-    public static function getInstance(DocumentParser $modx, $lang, $userClass = 'modUsers', $debug = false)
44
-    {
43
+    public static function getInstance(DocumentParser $modx, $lang, $userClass = 'modUsers', $debug = false)
44
+    {
45 45
 
46
-        if (null === self::$instance) {
46
+        if (null === self::$instance) {
47 47
             self::$instance = new self($modx, $userClass, $debug);
48 48
         }
49 49
 
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
      * is not allowed to call from outside: private!
58 58
      *
59 59
      */
60
-    private function __construct(DocumentParser $modx, $userClass, $debug)
61
-    {
60
+    private function __construct(DocumentParser $modx, $userClass, $debug)
61
+    {
62 62
         $this->modx = $modx;
63 63
         $this->userObj = new $userClass($this->modx, $debug);
64 64
         $this->url = new DLCollection($this->modx);
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
      *
77 77
      * @return void
78 78
      */
79
-    private function __clone()
80
-    {
79
+    private function __clone()
80
+    {
81 81
 
82 82
     }
83 83
 
@@ -86,23 +86,23 @@  discard block
 block discarded – undo
86 86
      *
87 87
      * @return void
88 88
      */
89
-    private function __wakeup()
90
-    {
89
+    private function __wakeup()
90
+    {
91 91
 
92 92
     }
93 93
 
94 94
     /**
95 95
      * Сброс авторизации и обновление страницы
96 96
      */
97
-    public function logout($params)
98
-    {
97
+    public function logout($params)
98
+    {
99 99
         $LogoutName = APIHelpers::getkey($params, 'LogoutName', 'logout');
100
-        if (is_scalar($LogoutName) && !empty($LogoutName) && isset($_GET[$LogoutName])) {
100
+        if (is_scalar($LogoutName) && !empty($LogoutName) && isset($_GET[$LogoutName])) {
101 101
             $userID = $this->UserID('web');
102
-            if ($userID) {
102
+            if ($userID) {
103 103
                 $this->userObj->edit($userID);
104 104
                 $params = array();
105
-                if ($this->userObj->getID()) {
105
+                if ($this->userObj->getID()) {
106 106
                     $params = array(
107 107
                         "userid"   => $this->userObj->getID(),
108 108
                         "username" => $this->userObj->get('username')
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
                     $this->modx->invokeEvent("OnBeforeWebLogout", $params);
111 111
                 }
112 112
                 $this->userObj->logOut();
113
-                if ($this->userObj->getID()) {
113
+                if ($this->userObj->getID()) {
114 114
                     $this->modx->invokeEvent("OnWebLogout", $params);
115 115
                 }
116 116
 
117 117
                 $go = APIHelpers::getkey($params, 'url', '');
118
-                if (empty($go)) {
118
+                if (empty($go)) {
119 119
                     $go = str_replace(
120 120
                         array("?" . $LogoutName, "&" . $LogoutName),
121 121
                         array("", ""),
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
                 }
125 125
 
126 126
                 $start = $this->makeUrl($this->config['site_start']);
127
-                if ($start == $go) {
127
+                if ($start == $go) {
128 128
                     $go = $this->config['site_url'];
129
-                } else {
129
+                } else {
130 130
                     $go = $this->config['site_url'] . ltrim($go, '/');
131 131
                 }
132 132
                 $this->moveTo(array('url' => $go));
133
-            } else {
133
+            } else {
134 134
                 //Если юзер не авторизован, то показываем ему 404 ошибку
135 135
                 $this->modx->sendErrorPage();
136 136
             }
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
      * Генерация ссылки под кнопку выход
144 144
      * @return string
145 145
      */
146
-    public function logoutUrl($params)
147
-    {
146
+    public function logoutUrl($params)
147
+    {
148 148
         $LogoutName = APIHelpers::getkey($params, 'LogoutName', 'logout');
149 149
         $request = parse_url($_SERVER['REQUEST_URI']);
150 150
 
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
      *        если указан параметр authId, то данные из формы перекидываются в метод AuthPage
160 160
      *    В противном случае вся работа происходит внутри самого блока
161 161
      */
162
-    public function AuthBlock($params)
163
-    {
162
+    public function AuthBlock($params)
163
+    {
164 164
         $POST = array('backUrl' => $_SERVER['REQUEST_URI']);
165 165
 
166 166
         $error = $errorCode = '';
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
         $emailField = APIHelpers::getkey($params, 'emailField', 'email');
170 170
         $rememberField = APIHelpers::getkey($params, 'rememberField', 'remember');
171 171
 
172
-        if ($this->UserID('web')) {
172
+        if ($this->UserID('web')) {
173 173
             $tpl = APIHelpers::getkey($params, 'tplProfile', '');
174
-            if (empty($tpl)) {
174
+            if (empty($tpl)) {
175 175
                 $tpl = $this->getTemplate('tplProfile');
176 176
             }
177 177
             $dataTPL = $this->userObj->toArray();
178 178
             $dataTPL['url.logout'] = $this->logoutUrl($params);
179 179
             $homeID = APIHelpers::getkey($params, 'homeID');
180
-            if (!empty($homeID)) {
180
+            if (!empty($homeID)) {
181 181
                 $dataTPL['url.profile'] = $this->makeUrl($homeID);
182 182
             }
183
-        } else {
183
+        } else {
184 184
             $tpl = APIHelpers::getkey($params, 'tplForm', '');
185
-            if (empty($tpl)) {
185
+            if (empty($tpl)) {
186 186
                 $tpl = $this->getTemplate('authForm');
187 187
             }
188 188
             $POST = $this->Auth($pwdField, $emailField, $rememberField, $POST['backUrl'], __METHOD__, $error,
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                 'errorCode'  => $errorCode
198 198
             );
199 199
             $authId = APIHelpers::getkey($params, 'authId');
200
-            if (!empty($authId)) {
200
+            if (!empty($authId)) {
201 201
                 $dataTPL['authPage'] = $this->makeUrl($authId);
202 202
                 $dataTPL['method'] = strtolower(__CLASS__ . '::' . 'authpage');
203 203
             }
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
      * Авторизация на сайте со страницы авторизации
211 211
      * [!Auth? &login=`password` &pwdField=`password` &homeID=`72`!]
212 212
      */
213
-    public function AuthPage($params)
214
-    {
213
+    public function AuthPage($params)
214
+    {
215 215
         $homeID = APIHelpers::getkey($params, 'homeID');
216 216
         $this->isAuthGoHome(array('id' => $homeID));
217 217
 
@@ -223,52 +223,52 @@  discard block
 block discarded – undo
223 223
         $rememberField = APIHelpers::getkey($params, 'rememberField', 'remember');
224 224
 
225 225
         $tpl = APIHelpers::getkey($params, 'tpl', '');
226
-        if (empty($tpl)) {
226
+        if (empty($tpl)) {
227 227
             $tpl = $this->getTemplate('authForm');
228 228
         }
229 229
 
230 230
         $request = parse_url($_SERVER['REQUEST_URI']);
231
-        if ($request === false) {
231
+        if ($request === false) {
232 232
             $request = array();
233 233
         }
234
-        if (!empty($_SERVER['HTTP_REFERER'])) {
234
+        if (!empty($_SERVER['HTTP_REFERER'])) {
235 235
             /**
236 236
              * Thank you for super protection against hacking in protect.inc.php:-)
237 237
              */
238 238
             $refer = htmlspecialchars_decode($_SERVER['HTTP_REFERER'], ENT_QUOTES);
239
-        } else {
239
+        } else {
240 240
             $refer = $this->getBackUrl($request);
241 241
         }
242 242
 
243
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
243
+        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
244 244
             $backUrl = APIHelpers::getkey($_POST, 'backUrl', $POST['backUrl']);
245
-            if (!is_scalar($backUrl)) {
245
+            if (!is_scalar($backUrl)) {
246 246
                 $backUrl = $refer;
247
-            } else {
247
+            } else {
248 248
                 $backUrl = urldecode($backUrl);
249 249
             }
250
-        } else {
250
+        } else {
251 251
             $backUrl = $refer;
252 252
         }
253 253
         $backUrl = parse_url($backUrl);
254
-        if ($backUrl === false) {
254
+        if ($backUrl === false) {
255 255
             $backUrl = array();
256 256
         }
257
-        if (!empty($backUrl['path']) && $request['path'] != $backUrl['path']) {
257
+        if (!empty($backUrl['path']) && $request['path'] != $backUrl['path']) {
258 258
             $POST['backUrl'] = $backUrl['path'];
259
-        } else {
259
+        } else {
260 260
             $POST['backUrl'] = $this->getBackUrl($backUrl);
261 261
         }
262
-        if (!empty($POST['backUrl'])) {
262
+        if (!empty($POST['backUrl'])) {
263 263
             $idURL = $this->moveTo(array(
264 264
                 'url'      => '/' . ltrim($POST['backUrl'], '/'),
265 265
                 'validate' => true
266 266
             ));
267
-        } else {
267
+        } else {
268 268
             $idURL = 0;
269 269
         }
270
-        if (empty($idURL)) {
271
-            if (empty($homeID)) {
270
+        if (empty($idURL)) {
271
+            if (empty($homeID)) {
272 272
                 $homeID = $this->config['site_start'];
273 273
             }
274 274
             $POST['backUrl'] = $this->makeUrl($homeID);
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
      * @param array $request
292 292
      * @return string
293 293
      */
294
-    protected function getBackUrl(array $request = array())
295
-    {
294
+    protected function getBackUrl(array $request = array())
295
+    {
296 296
         $selfHost = rtrim(str_replace("http://", "", $this->config['site_url']), '/');
297
-        if (empty($request['host']) || $request['host'] == $selfHost) {
297
+        if (empty($request['host']) || $request['host'] == $selfHost) {
298 298
             $query = !empty($request['query']) ? '?' . $request['query'] : '';
299 299
             $out = !empty($request['path']) ? $request['path'] . $query : '';
300
-        } else {
300
+        } else {
301 301
             $out = '';
302 302
         }
303 303
 
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
         &$error,
325 325
         &$errorCode,
326 326
         $params = array()
327
-    ) {
327
+    ) {
328 328
         $POST = array(
329 329
             'backUrl' => urlencode($backUrl)
330 330
         );
331 331
         $userObj = &$this->userObj;
332
-        if ($_SERVER['REQUEST_METHOD'] == 'POST' && APIHelpers::getkey($_POST, 'method', '') == strtolower($method)) {
332
+        if ($_SERVER['REQUEST_METHOD'] == 'POST' && APIHelpers::getkey($_POST, 'method', '') == strtolower($method)) {
333 333
             $POST = array_merge($POST, array(
334 334
                 'password' => APIHelpers::getkey($_POST, $pwdField, ''),
335 335
                 'email'    => APIHelpers::getkey($_POST, $emailField, ''),
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
             ));
338 338
             if (!empty($POST['email']) && is_scalar($POST['email']) && !$userObj->emailValidate($POST['email'],
339 339
                     false)
340
-            ) {
340
+            ) {
341 341
                 $userObj->edit($POST['email']);
342 342
 
343 343
                 $this->modx->invokeEvent("OnBeforeWebLogin", array(
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
                     "rememberme"   => $POST['remember'],
347 347
                     'userObj'      => $userObj
348 348
                 ));
349
-                if ($userObj->getID() && !$userObj->checkBlock($userObj->getID())) {
349
+                if ($userObj->getID() && !$userObj->checkBlock($userObj->getID())) {
350 350
                     $pluginFlag = $this->modx->invokeEvent("OnWebAuthentication", array(
351 351
                         "userid"        => $userObj->getID(),
352 352
                         "username"      => $userObj->get('username'),
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
                         ($pluginFlag === true || $userObj->testAuth($userObj->getID(), $POST['password'], 0))
359 359
                         &&
360 360
                         $userObj->authUser($userObj->getID(), $POST['remember'])
361
-                    ) {
361
+                    ) {
362 362
                         $userObj->set('logincount', (int)$userObj->get('logincount') + 1);
363 363
                         $userObj->set('lastlogin', time());
364 364
                         $userObj->set('failedlogincount', 0);
@@ -371,21 +371,21 @@  discard block
 block discarded – undo
371 371
                             "rememberme"   => $POST['remember'],
372 372
                         ));
373 373
                         $this->moveTo(array('url' => urldecode($POST['backUrl'])));
374
-                    } else {
374
+                    } else {
375 375
                         $userObj->set('failedlogincount', (int)$userObj->get('failedlogincount') + 1);
376 376
                         $userObj->save(false, false);
377 377
 
378 378
                         $error = 'error.incorrect_password';
379 379
                     }
380
-                } else {
380
+                } else {
381 381
                     $error = 'error.no_user';
382 382
                 }
383
-            } else {
383
+            } else {
384 384
                 $error = 'error.incorrect_mail';
385 385
                 $POST['email'] = '';
386 386
             }
387 387
         }
388
-        if (!empty($error)) {
388
+        if (!empty($error)) {
389 389
             $errorCode = $error;
390 390
             $error = APIHelpers::getkey($params, $error, '');
391 391
             $error = static::getLangMsg($error, $error);
@@ -398,17 +398,17 @@  discard block
 block discarded – undo
398 398
      * Информация о пользователе
399 399
      * [!DLUsers? &action=`UserInfo` &field=`fullname` &id=`2`!]
400 400
      */
401
-    public function UserInfo($params)
402
-    {
401
+    public function UserInfo($params)
402
+    {
403 403
         $out = '';
404 404
         $userID = APIHelpers::getkey($params, 'id', 0);
405
-        if (empty($userID)) {
405
+        if (empty($userID)) {
406 406
             $userID = $this->UserID('web');
407 407
         }
408 408
         $field = APIHelpers::getkey($params, 'field', 'username');
409
-        if ($userID > 0) {
409
+        if ($userID > 0) {
410 410
             $this->userObj->edit($userID);
411
-            switch (true) {
411
+            switch (true) {
412 412
                 case ($field == $this->userObj->fieldPKName()):
413 413
                     $out = $this->userObj->getID();
414 414
                     break;
@@ -424,17 +424,17 @@  discard block
 block discarded – undo
424 424
     /**
425 425
      * ID пользователя
426 426
      */
427
-    public function UserID($type = 'web')
428
-    {
427
+    public function UserID($type = 'web')
428
+    {
429 429
         return $this->modx->getLoginUserID($type);
430 430
     }
431 431
 
432 432
     /**
433 433
      * Если не авторизован - то отправить на страницу
434 434
      */
435
-    public function isGuestGoHome($params)
436
-    {
437
-        if (!$this->UserID('web')) {
435
+    public function isGuestGoHome($params)
436
+    {
437
+        if (!$this->UserID('web')) {
438 438
             /**
439 439
              * @see : http://modx.im/blog/triks/105.html
440 440
              */
@@ -449,12 +449,12 @@  discard block
 block discarded – undo
449 449
     /**
450 450
      * Если авторизован - то открыть личный кабинет
451 451
      */
452
-    public function isAuthGoHome($params)
453
-    {
452
+    public function isAuthGoHome($params)
453
+    {
454 454
         $userID = $this->UserID('web');
455
-        if ($userID > 0) {
455
+        if ($userID > 0) {
456 456
             $id = APIHelpers::getkey($params, 'homeID');
457
-            if (empty($id)) {
457
+            if (empty($id)) {
458 458
                 $id = $this->modx->getConfig('login_home', $this->config['site_start']);
459 459
             }
460 460
             $this->moveTo(compact('id'));
@@ -466,28 +466,28 @@  discard block
 block discarded – undo
466 466
     /**
467 467
      * Редирект
468 468
      */
469
-    public function moveTo($params)
470
-    {
469
+    public function moveTo($params)
470
+    {
471 471
         $id = (int)APIHelpers::getkey($params, 'id', 0);
472 472
         $uri = APIHelpers::getkey($params, 'url', '');
473
-        if ((empty($uri) && !empty($id)) || !is_string($uri)) {
473
+        if ((empty($uri) && !empty($id)) || !is_string($uri)) {
474 474
             $uri = $this->makeUrl($id);
475 475
         }
476 476
         $code = (int)APIHelpers::getkey($params, 'code', 0);
477 477
         $addUrl = APIHelpers::getkey($params, 'addUrl', '');
478
-        if (is_scalar($addUrl) && $addUrl != '') {
478
+        if (is_scalar($addUrl) && $addUrl != '') {
479 479
             $uri .= "?" . $addUrl;
480 480
         }
481
-        if (APIHelpers::getkey($params, 'validate', false)) {
482
-            if (isset($this->modx->snippetCache['getPageID'])) {
481
+        if (APIHelpers::getkey($params, 'validate', false)) {
482
+            if (isset($this->modx->snippetCache['getPageID'])) {
483 483
                 $out = $this->modx->runSnippet('getPageID', compact('uri'));
484
-                if (empty($out)) {
484
+                if (empty($out)) {
485 485
                     $uri = '';
486 486
                 }
487
-            } else {
487
+            } else {
488 488
                 $uri = APIhelpers::sanitarTag($uri);
489 489
             }
490
-        } else {
490
+        } else {
491 491
             header("Location: " . $uri, true, ($code > 0 ? $code : 307));
492 492
         }
493 493
 
@@ -500,15 +500,15 @@  discard block
 block discarded – undo
500 500
      * @param  int $id ID документа
501 501
      * @return string
502 502
      */
503
-    protected function makeUrl($id = null)
504
-    {
503
+    protected function makeUrl($id = null)
504
+    {
505 505
         $id = (int)$id;
506
-        if ($id <= 0) {
506
+        if ($id <= 0) {
507 507
             $id = $this->modx->documentObject['id'];
508 508
         }
509
-        if ($this->url->containsKey($id)) {
509
+        if ($this->url->containsKey($id)) {
510 510
             $url = $this->url->get($id);
511
-        } else {
511
+        } else {
512 512
             $url = $this->modx->makeUrl($id);
513 513
             $this->url->set($id, $url);
514 514
         }
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
      * @param $name
521 521
      * @return string
522 522
      */
523
-    protected function getTemplate($name)
524
-    {
523
+    protected function getTemplate($name)
524
+    {
525 525
         $out = '';
526 526
         $file = dirname(dirname(__FILE__)) . '/tpl/' . $name . '.html';
527
-        if (FS::getInstance()->checkFile($file)) {
527
+        if (FS::getInstance()->checkFile($file)) {
528 528
             $out = '@CODE: ' . file_get_contents($file);
529 529
         }
530 530
 
@@ -535,17 +535,17 @@  discard block
 block discarded – undo
535 535
      * @param $lang
536 536
      * @return bool
537 537
      */
538
-    protected static function loadLang($lang)
539
-    {
538
+    protected static function loadLang($lang)
539
+    {
540 540
         $file = dirname(dirname(__FILE__)) . '/lang/' . $lang . '.php';
541
-        if (!FS::getInstance()->checkFile($file)) {
541
+        if (!FS::getInstance()->checkFile($file)) {
542 542
             $file = false;
543 543
         }
544
-        if (!empty($lang) && !isset(static::$langDic[$lang]) && !empty($file)) {
544
+        if (!empty($lang) && !isset(static::$langDic[$lang]) && !empty($file)) {
545 545
             static::$langDic[$lang] = include_once($file);
546
-            if (is_array(static::$langDic[$lang])) {
546
+            if (is_array(static::$langDic[$lang])) {
547 547
                 static::$langDic[$lang] = APIHelpers::renameKeyArr(static::$langDic[$lang], $lang);
548
-            } else {
548
+            } else {
549 549
                 static::$langDic[$lang] = array();
550 550
             }
551 551
         }
@@ -558,17 +558,17 @@  discard block
 block discarded – undo
558 558
      * @param $default
559 559
      * @return string
560 560
      */
561
-    protected static function getLangMsg($key, $default)
562
-    {
561
+    protected static function getLangMsg($key, $default)
562
+    {
563 563
         $out = $default;
564 564
         $lng = static::$lang;
565 565
         $dic = static::$langDic;
566
-        if (isset($dic[$lng], $dic[$lng][$lng . '.' . $key])) {
566
+        if (isset($dic[$lng], $dic[$lng][$lng . '.' . $key])) {
567 567
             $out = $dic[$lng][$lng . '.' . $key];
568 568
         }
569
-        if (class_exists('evoBabel', false) && isset(self::$instance->modx->snippetCache['lang'])) {
569
+        if (class_exists('evoBabel', false) && isset(self::$instance->modx->snippetCache['lang'])) {
570 570
             $msg = self::$instance->modx->runSnippet('lang', array('a' => 'DLUsers.' . $key));
571
-            if (!empty($msg)) {
571
+            if (!empty($msg)) {
572 572
                 $out = $msg;
573 573
             }
574 574
         }
Please login to merge, or discard this patch.