Completed
Push — master ( 69d420...19a10e )
by
unknown
02:52
created
assets/lib/MODxAPI/modResource.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         $tpl = $this->get('template');
187 187
         $tvTPL = APIHelpers::getkey($this->tvTpl, $tpl, array());
188 188
         foreach ($tvTPL as $item) {
189
-            if (isset($this->tvid[$item]) && !array_key_exists($this->tvid[$item], $out)) {
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
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 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
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function set($key, $value)
317 317
     {
318
-        if (is_scalar($value) && is_scalar($key) && !empty($key)) {
318
+        if (is_scalar($value) && is_scalar($key) && ! empty($key)) {
319 319
             switch ($key) {
320 320
                 case 'parent':
321 321
                     $value = (int)$value;
@@ -388,12 +388,12 @@  discard block
 block discarded – undo
388 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
         }
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
     protected function getTime($value)
435 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
         }
@@ -509,8 +509,8 @@  discard block
 block discarded – undo
509 509
 
510 510
         if (
511 511
             $this->field['parent'] == 0 &&
512
-            !$this->modxConfig('udperms_allowroot') &&
513
-            !($uid && isset($_SESSION['mgrRole']) && $_SESSION['mgrRole'] == 1)
512
+            ! $this->modxConfig('udperms_allowroot') &&
513
+            ! ($uid && isset($_SESSION['mgrRole']) && $_SESSION['mgrRole'] == 1)
514 514
         ) {
515 515
             $this->log['rootForbidden'] = 'Only Administrators can create documents in the root folder because udperms_allowroot setting is off';
516 516
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
         $fld = $this->toArray(null, null, null, false);
530 530
         foreach ($this->default_field as $key => $value) {
531 531
             $tmp = $this->get($key);
532
-            if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
532
+            if ($this->newDoc && ( ! is_int($tmp) && $tmp == '')) {
533 533
                 if ($tmp == $value) {
534 534
                     switch ($key) {
535 535
                         case 'cacheable':
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
                     $this->field[$key] = $parent;
562 562
                     $this->Uset($key);
563 563
                     break;
564
-                case ($key == 'alias_visible' && !$this->checkVersion('1.0.10', true)):
564
+                case ($key == 'alias_visible' && ! $this->checkVersion('1.0.10', true)):
565 565
                     $this->eraseField('alias_visible');
566 566
                     break;
567 567
                 default:
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
             unset($fld[$key]);
571 571
         }
572 572
 
573
-        if (!empty($this->set)) {
573
+        if ( ! empty($this->set)) {
574 574
             if ($this->newDoc) {
575 575
                 $SQL = "INSERT into {$this->makeTable('site_content')} SET " . implode(', ', $this->set);
576 576
             } else {
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 
591 591
         $_deleteTVs = $_updateTVs = $_insertTVs = array();
592 592
         foreach ($fld as $key => $value) {
593
-            if (empty($this->tv[$key]) || !$this->isChanged($key)) {
593
+            if (empty($this->tv[$key]) || ! $this->isChanged($key)) {
594 594
                 continue;
595 595
             } elseif ($value === '') {
596 596
                 $_deleteTVs[] = $this->tv[$key];
@@ -599,37 +599,37 @@  discard block
 block discarded – undo
599 599
             }
600 600
         }
601 601
 
602
-        if (!$this->newDoc && !empty($_insertTVs)) {
603
-            $ids = implode(',',array_keys($_insertTVs));
602
+        if ( ! $this->newDoc && ! empty($_insertTVs)) {
603
+            $ids = implode(',', array_keys($_insertTVs));
604 604
             $result = $this->query("SELECT `tmplvarid` FROM {$this->makeTable('site_tmplvar_contentvalues')} WHERE `contentid`={$this->id} AND `tmplvarid` IN ({$ids})");
605
-            $existedTVs = $this->modx->db->getColumn('tmplvarid',$result);
605
+            $existedTVs = $this->modx->db->getColumn('tmplvarid', $result);
606 606
             foreach ($existedTVs as $id) {
607 607
                 $_updateTVs[$id] = $_insertTVs[$id];
608 608
                 unset($_insertTVs[$id]);
609 609
             }
610 610
         }
611 611
 
612
-        if (!empty($_updateTVs)) {
613
-            foreach($_updateTVs as $id => $value) {
612
+        if ( ! empty($_updateTVs)) {
613
+            foreach ($_updateTVs as $id => $value) {
614 614
                 $this->query("UPDATE {$this->makeTable('site_tmplvar_contentvalues')} SET `value` = '{$value}' WHERE `contentid` = {$this->id} AND `tmplvarid` = {$id}");
615 615
             }
616 616
         }
617 617
 
618
-        if (!empty($_insertTVs)) {
618
+        if ( ! empty($_insertTVs)) {
619 619
             $values = array();
620 620
             foreach ($_insertTVs as $id => $value) {
621 621
                 $values[] = "({$this->id}, {$id}, '{$value}')";
622 622
             }
623
-            $values = implode(',',$values);
623
+            $values = implode(',', $values);
624 624
             $this->query("INSERT into {$this->makeTable('site_tmplvar_contentvalues')} (`contentid`,`tmplvarid`,`value`) VALUES {$values}");
625 625
         }
626 626
 
627
-        if (!empty($_deleteTVs)) {
628
-            $ids = implode(',',$_deleteTVs);
627
+        if ( ! empty($_deleteTVs)) {
628
+            $ids = implode(',', $_deleteTVs);
629 629
             $this->query("DELETE FROM {$this->makeTable('site_tmplvar_contentvalues')} WHERE `contentid` = '{$this->id}' AND `tmplvarid` IN ({$ids})");
630 630
         }
631 631
 
632
-        if (!isset($this->mode)) {
632
+        if ( ! isset($this->mode)) {
633 633
             $this->mode = $this->newDoc ? "new" : "upd";
634 634
             $this->newDoc = false;
635 635
         }
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         $_ids = $this->cleanIDs($ids, ',');
705 705
         if (is_array($_ids) && $_ids != array()) {
706 706
             $id = $this->sanitarIn($_ids);
707
-            if (!empty($id)) {
707
+            if ( ! empty($id)) {
708 708
                 $q = $this->query("SELECT `id` FROM {$this->makeTable('site_content')} where `parent` IN ({$id})");
709 709
                 $id = $this->modx->db->getColumn('id', $q);
710 710
                 if ($depth > 0 || $depth === true) {
@@ -769,12 +769,12 @@  discard block
 block discarded – undo
769 769
         $alias = strtolower($alias);
770 770
         if ($this->modxConfig('friendly_urls')) {
771 771
             $_alias = $this->escape($alias);
772
-            if ((!$this->modxConfig('allow_duplicate_alias') && !$this->modxConfig('use_alias_path')) || ($this->modxConfig('allow_duplicate_alias') && $this->modxConfig('use_alias_path'))) {
772
+            if (( ! $this->modxConfig('allow_duplicate_alias') && ! $this->modxConfig('use_alias_path')) || ($this->modxConfig('allow_duplicate_alias') && $this->modxConfig('use_alias_path'))) {
773 773
                 $flag = $this->modx->db->getValue($this->query("SELECT `id` FROM {$this->makeTable('site_content')} WHERE `alias`='{$_alias}' AND `parent`={$this->get('parent')} LIMIT 1"));
774 774
             } else {
775 775
                 $flag = $this->modx->db->getValue($this->query("SELECT `id` FROM {$this->makeTable('site_content')} WHERE `alias`='{$_alias}' LIMIT 1"));
776 776
             }
777
-            if (($flag && $this->newDoc) || (!$this->newDoc && $flag && $this->id != $flag)) {
777
+            if (($flag && $this->newDoc) || ( ! $this->newDoc && $flag && $this->id != $flag)) {
778 778
                 $suffix = substr($alias, -2);
779 779
                 if (preg_match('/-(\d+)/', $suffix, $tmp) && isset($tmp[1]) && (int)$tmp[1] > 1) {
780 780
                     $suffix = (int)$tmp[1] + 1;
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
      */
841 841
     protected function loadTVDefault(array $tvId = array())
842 842
     {
843
-        if (is_array($tvId) && !empty($tvId)) {
843
+        if (is_array($tvId) && ! empty($tvId)) {
844 844
             $tbl_site_tmplvars = $this->makeTable('site_tmplvars');
845 845
             $fields = 'id,name,default_text as value,display,display_params,type';
846 846
             $implodeTvId = implode(',', $tvId);
@@ -862,11 +862,11 @@  discard block
 block discarded – undo
862 862
      */
863 863
     public function setTemplate($tpl)
864 864
     {
865
-        if (!is_numeric($tpl) || $tpl != (int)$tpl) {
865
+        if ( ! is_numeric($tpl) || $tpl != (int)$tpl) {
866 866
             if (is_scalar($tpl)) {
867 867
                 $sql = "SELECT `id` FROM {$this->makeTable('site_templates')} WHERE `templatename` = '" . $this->escape($tpl) . "'";
868 868
                 $rs = $this->query($sql);
869
-                if (!$rs || $this->modx->db->getRecordCount($rs) <= 0) {
869
+                if ( ! $rs || $this->modx->db->getRecordCount($rs) <= 0) {
870 870
                     throw new Exception("Template {$tpl} is not exists");
871 871
                 }
872 872
                 $tpl = $this->modx->db->getValue($rs);
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
         $template = $this->modxConfig('default_template');
928 928
         switch ($this->modxConfig('auto_template_logic')) {
929 929
             case 'sibling':
930
-                if (!$parent) {
930
+                if ( ! $parent) {
931 931
                     $site_start = $this->modxConfig('site_start');
932 932
                     $where = "sc.isfolder=0 AND sc.id!={$site_start}";
933 933
                     $sibl = $this->modx->getDocumentChildren($parent, 1, 0, 'template', $where, 'menuindex', 'ASC', 1);
Please login to merge, or discard this patch.