Completed
Pull Request — develop (#545)
by Agel_Nash
05:36
created
manager/includes/document.parser.class.inc.php 3 patches
Doc Comments   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      * MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php"
278 278
      * $extname - extension name in lowercase
279 279
      *
280
-     * @param $extname
280
+     * @param string $extname
281 281
      * @param bool $reload
282 282
      * @return bool
283 283
      */
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
      * @param int $count_attempts
321 321
      * @param string $type $type
322 322
      * @param string $responseCode
323
-     * @return bool|null
323
+     * @return false|null
324 324
      * @global string $base_url
325 325
      * @global string $site_url
326 326
      */
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
     }
1022 1022
 
1023 1023
     /**
1024
-     * @param $contents
1024
+     * @param string $contents
1025 1025
      * @return mixed
1026 1026
      */
1027 1027
     public function RecoveryEscapedTags($contents)
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
     }
1046 1046
 
1047 1047
     /**
1048
-     * @param $tstart
1048
+     * @param double $tstart
1049 1049
      * @return array
1050 1050
      */
1051 1051
     public function getTimerStats($tstart)
@@ -1797,7 +1797,7 @@  discard block
 block discarded – undo
1797 1797
 
1798 1798
     /**
1799 1799
      * Remove Comment-Tags from output like <!--@- Comment -@-->
1800
-     * @param $content
1800
+     * @param string $content
1801 1801
      * @param string $left
1802 1802
      * @param string $right
1803 1803
      * @return mixed
@@ -1970,7 +1970,7 @@  discard block
 block discarded – undo
1970 1970
     /**
1971 1971
      * Run snippets as per the tags in $documentSource and replace the tags with the returned values.
1972 1972
      *
1973
-     * @param $content
1973
+     * @param string $content
1974 1974
      * @return string
1975 1975
      * @internal param string $documentSource
1976 1976
      */
@@ -3002,7 +3002,7 @@  discard block
 block discarded – undo
3002 3002
 
3003 3003
     /**
3004 3004
      * @param $templateID
3005
-     * @return mixed
3005
+     * @return string
3006 3006
      */
3007 3007
     public function _getTemplateCodeFromDB($templateID)
3008 3008
     {
@@ -3043,9 +3043,9 @@  discard block
 block discarded – undo
3043 3043
     }
3044 3044
 
3045 3045
     /**
3046
-     * @param $id
3046
+     * @param integer $id
3047 3047
      * @param int $top
3048
-     * @return mixed
3048
+     * @return string
3049 3049
      */
3050 3050
     public function getUltimateParentId($id, $top = 0)
3051 3051
     {
@@ -3376,7 +3376,7 @@  discard block
 block discarded – undo
3376 3376
      *
3377 3377
      * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role
3378 3378
      * @param int $id Element- / Resource-id
3379
-     * @return bool
3379
+     * @return false|null
3380 3380
      */
3381 3381
     public function lockElement($type, $id)
3382 3382
     {
@@ -3398,7 +3398,7 @@  discard block
 block discarded – undo
3398 3398
      * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role
3399 3399
      * @param int $id Element- / Resource-id
3400 3400
      * @param bool $includeAllUsers true = Deletes not only own user-locks
3401
-     * @return bool
3401
+     * @return false|null
3402 3402
      */
3403 3403
     public function unlockElement($type, $id, $includeAllUsers = false)
3404 3404
     {
@@ -3506,7 +3506,7 @@  discard block
 block discarded – undo
3506 3506
      * @param array $params
3507 3507
      * @param string $msg
3508 3508
      * @param array $files
3509
-     * @return mixed
3509
+     * @return boolean
3510 3510
      */
3511 3511
     public function sendmail($params = array(), $msg = '', $files = array())
3512 3512
     {
@@ -3910,7 +3910,7 @@  discard block
 block discarded – undo
3910 3910
      *                     Default: 1
3911 3911
      * @param string $fields List of fields
3912 3912
      *                       Default: id, pagetitle, description, alias
3913
-     * @return boolean|array
3913
+     * @return string
3914 3914
      */
3915 3915
     public function getPageInfo($pageid = -1, $active = 1, $fields = 'id, pagetitle, description, alias')
3916 3916
     {
@@ -4002,7 +4002,7 @@  discard block
 block discarded – undo
4002 4002
      *
4003 4003
      * @param string $type
4004 4004
      * @param bool $report
4005
-     * @return bool
4005
+     * @return boolean|null
4006 4006
      */
4007 4007
     public function clearCache($type = '', $report = false)
4008 4008
     {
@@ -4369,7 +4369,7 @@  discard block
 block discarded – undo
4369 4369
      * - Placeholders prefix. Default: '{'.
4370 4370
      * @param string $suffix {string}
4371 4371
      * - Placeholders suffix. Default: '}'.
4372
-     * @return bool|mixed|string {string; false} - Parsed chunk or false if $chunkArr is not array.
4372
+     * @return false|string {string; false} - Parsed chunk or false if $chunkArr is not array.
4373 4373
      * - Parsed chunk or false if $chunkArr is not array.
4374 4374
      */
4375 4375
     public function parseChunk($chunkName, $chunkArr, $prefix = '{', $suffix = '}')
@@ -5345,7 +5345,7 @@  discard block
 block discarded – undo
5345 5345
      * Remove event listener - only for use within the current execution cycle
5346 5346
      *
5347 5347
      * @param string $evtName
5348
-     * @return boolean
5348
+     * @return false|null
5349 5349
      */
5350 5350
     public function removeEventListener($evtName)
5351 5351
     {
@@ -5369,7 +5369,7 @@  discard block
 block discarded – undo
5369 5369
      *
5370 5370
      * @param string $evtName
5371 5371
      * @param array $extParams Parameters available to plugins. Each array key will be the PHP variable name, and the array value will be the variable value.
5372
-     * @return boolean|array
5372
+     * @return false|null
5373 5373
      */
5374 5374
     public function invokeEvent($evtName, $extParams = array())
5375 5375
     {
@@ -5968,7 +5968,7 @@  discard block
 block discarded – undo
5968 5968
 
5969 5969
     /**
5970 5970
      * @param string $str
5971
-     * @return bool|mixed|string
5971
+     * @return string
5972 5972
      */
5973 5973
     public function atBindFileContent($str = '')
5974 5974
     {
@@ -6019,8 +6019,8 @@  discard block
 block discarded – undo
6019 6019
     }
6020 6020
 
6021 6021
     /**
6022
-     * @param $str
6023
-     * @return bool|string
6022
+     * @param string $str
6023
+     * @return false|string
6024 6024
      */
6025 6025
     public function getExtFromFilename($str)
6026 6026
     {
@@ -6048,7 +6048,7 @@  discard block
 block discarded – undo
6048 6048
      * @param string $text Error message
6049 6049
      * @param string $file File where the error was detected
6050 6050
      * @param string $line Line number within $file
6051
-     * @return boolean
6051
+     * @return boolean|null
6052 6052
      */
6053 6053
     public function phpError($nr, $text, $file, $line)
6054 6054
     {
@@ -6100,7 +6100,7 @@  discard block
 block discarded – undo
6100 6100
      * @param string $text
6101 6101
      * @param string $line
6102 6102
      * @param string $output
6103
-     * @return bool
6103
+     * @return null|boolean
6104 6104
      */
6105 6105
     public function messageQuit($msg = 'unspecified error', $query = '', $is_error = true, $nr = '', $file = '', $source = '', $text = '', $line = '', $output = '')
6106 6106
     {
@@ -6522,7 +6522,7 @@  discard block
 block discarded – undo
6522 6522
 
6523 6523
     /**
6524 6524
      * @param string $str
6525
-     * @return bool|mixed|string
6525
+     * @return string
6526 6526
      */
6527 6527
     public function atBindInclude($str = '')
6528 6528
     {
@@ -6573,7 +6573,7 @@  discard block
 block discarded – undo
6573 6573
      * @param $str
6574 6574
      * @param int $flags
6575 6575
      * @param string $encode
6576
-     * @return mixed
6576
+     * @return string
6577 6577
      */
6578 6578
     public function htmlspecialchars($str, $flags = ENT_COMPAT, $encode = '')
6579 6579
     {
@@ -6582,7 +6582,7 @@  discard block
 block discarded – undo
6582 6582
     }
6583 6583
 
6584 6584
     /**
6585
-     * @param $string
6585
+     * @param string $string
6586 6586
      * @param bool $returnData
6587 6587
      * @return bool|mixed
6588 6588
      */
Please login to merge, or discard this patch.
Spacing   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         $this->q = self::_getCleanQueryString();
206 206
     }
207 207
 
208
-    final private function __clone() {}
208
+    final private function __clone(){}
209 209
 
210 210
     /**
211 211
      * @return DocumentParser
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      */
227 227
     function __call($method_name, $arguments)
228 228
     {
229
-        include_once(MODX_MANAGER_PATH . 'includes/extenders/deprecated.functions.inc.php');
229
+        include_once(MODX_MANAGER_PATH.'includes/extenders/deprecated.functions.inc.php');
230 230
         if (method_exists($this->old, $method_name)) {
231 231
             $error_type = 1;
232 232
         } else {
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
             $info = debug_backtrace();
245 245
             $m[] = $msg;
246 246
             if (!empty($this->currentSnippet)) {
247
-                $m[] = 'Snippet - ' . $this->currentSnippet;
247
+                $m[] = 'Snippet - '.$this->currentSnippet;
248 248
             } elseif (!empty($this->event->activePlugin)) {
249
-                $m[] = 'Plugin - ' . $this->event->activePlugin;
249
+                $m[] = 'Plugin - '.$this->event->activePlugin;
250 250
             }
251 251
             $m[] = $this->decoded_request_uri;
252
-            $m[] = str_replace('\\', '/', $info[0]['file']) . '(line:' . $info[0]['line'] . ')';
252
+            $m[] = str_replace('\\', '/', $info[0]['file']).'(line:'.$info[0]['line'].')';
253 253
             $msg = implode('<br />', $m);
254 254
             $this->logEvent(0, $error_type, $msg, $title);
255 255
         }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
     {
267 267
         $flag = false;
268 268
         if (is_scalar($connector) && !empty($connector) && isset($this->{$connector}) && $this->{$connector} instanceof DBAPI) {
269
-            $flag = (bool)$this->{$connector}->conn;
269
+            $flag = (bool) $this->{$connector}->conn;
270 270
         }
271 271
         return $flag;
272 272
     }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         }
294 294
         if (!$out && $flag) {
295 295
             $extname = trim(str_replace(array('..', '/', '\\'), '', strtolower($extname)));
296
-            $filename = MODX_MANAGER_PATH . "includes/extenders/ex_{$extname}.inc.php";
296
+            $filename = MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php";
297 297
             $out = is_file($filename) ? include $filename : false;
298 298
         }
299 299
         if ($out && !in_array($extname, $this->extensions)) {
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
     public function getMicroTime()
311 311
     {
312 312
         list ($usec, $sec) = explode(' ', microtime());
313
-        return ((float)$usec + (float)$sec);
313
+        return ((float) $usec + (float) $sec);
314 314
     }
315 315
 
316 316
     /**
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
             // append the redirect count string to the url
335 335
             $currentNumberOfRedirects = isset ($_REQUEST['err']) ? $_REQUEST['err'] : 0;
336 336
             if ($currentNumberOfRedirects > 3) {
337
-                $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>' . $url . '</i></p>');
337
+                $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>'.$url.'</i></p>');
338 338
             } else {
339 339
                 $currentNumberOfRedirects += 1;
340 340
                 if (strpos($url, "?") > 0) {
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
             }
346 346
         }
347 347
         if ($type == 'REDIRECT_REFRESH') {
348
-            $header = 'Refresh: 0;URL=' . $url;
348
+            $header = 'Refresh: 0;URL='.$url;
349 349
         } elseif ($type == 'REDIRECT_META') {
350
-            $header = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=' . $url . '" />';
350
+            $header = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL='.$url.'" />';
351 351
             echo $header;
352 352
             exit;
353 353
         } elseif ($type == 'REDIRECT_HEADER' || empty ($type)) {
@@ -355,10 +355,10 @@  discard block
 block discarded – undo
355 355
             global $base_url, $site_url;
356 356
             if (substr($url, 0, strlen($base_url)) == $base_url) {
357 357
                 // append $site_url to make it work with Location:
358
-                $url = $site_url . substr($url, strlen($base_url));
358
+                $url = $site_url.substr($url, strlen($base_url));
359 359
             }
360 360
             if (strpos($url, "\n") === false) {
361
-                $header = 'Location: ' . $url;
361
+                $header = 'Location: '.$url;
362 362
             } else {
363 363
                 $this->messageQuit('No newline allowed in redirect url.');
364 364
             }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
             header($responseCode);
368 368
         }
369 369
 
370
-        if(!empty($header)) {
370
+        if (!empty($header)) {
371 371
             header($header);
372 372
         }
373 373
 
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
 
472 472
     private function recoverySiteCache()
473 473
     {
474
-        $site_cache_dir = MODX_BASE_PATH . $this->getCacheFolder();
475
-        $site_cache_path = $site_cache_dir . 'siteCache.idx.php';
474
+        $site_cache_dir = MODX_BASE_PATH.$this->getCacheFolder();
475
+        $site_cache_path = $site_cache_dir.'siteCache.idx.php';
476 476
 
477 477
         if (is_file($site_cache_path)) {
478 478
             include($site_cache_path);
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
             return;
482 482
         }
483 483
 
484
-        include_once(MODX_MANAGER_PATH . 'processors/cache_sync.class.processor.php');
484
+        include_once(MODX_MANAGER_PATH.'processors/cache_sync.class.processor.php');
485 485
         $cache = new synccache();
486 486
         $cache->setCachepath($site_cache_dir);
487 487
         $cache->setReport(false);
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
                 $this->invokeEvent("OnBeforeManagerPageInit");
534 534
             }
535 535
 
536
-            if (isset ($_SESSION[$usrType . 'UsrConfigSet'])) {
537
-                $usrSettings = &$_SESSION[$usrType . 'UsrConfigSet'];
536
+            if (isset ($_SESSION[$usrType.'UsrConfigSet'])) {
537
+                $usrSettings = &$_SESSION[$usrType.'UsrConfigSet'];
538 538
             } else {
539 539
                 if ($usrType == 'web') {
540 540
                     $from = $tbl_web_user_settings;
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
                     $usrSettings[$row['setting_name']] = $row['setting_value'];
555 555
                 }
556 556
                 if (isset ($usrType)) {
557
-                    $_SESSION[$usrType . 'UsrConfigSet'] = $usrSettings;
557
+                    $_SESSION[$usrType.'UsrConfigSet'] = $usrSettings;
558 558
                 } // store user settings in session
559 559
             }
560 560
         }
@@ -699,10 +699,10 @@  discard block
 block discarded – undo
699 699
         $suf = $this->config['friendly_url_suffix'];
700 700
         $pre = preg_quote($pre, '/');
701 701
         $suf = preg_quote($suf, '/');
702
-        if ($pre && preg_match('@^' . $pre . '(.*)$@', $q, $_)) {
702
+        if ($pre && preg_match('@^'.$pre.'(.*)$@', $q, $_)) {
703 703
             $q = $_[1];
704 704
         }
705
-        if ($suf && preg_match('@(.*)' . $suf . '$@', $q, $_)) {
705
+        if ($suf && preg_match('@(.*)'.$suf.'$@', $q, $_)) {
706 706
             $q = $_[1];
707 707
         }
708 708
 
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
         if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */
725 725
             /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */
726 726
             if ($this->config['use_alias_path'] == 1) {
727
-                if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) {
727
+                if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir.'/'.$q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) {
728 728
                     $this->documentMethod = 'id';
729 729
                     return $q;
730 730
                 } else { /* not a valid id in terms of virtualDir, treat as alias */
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
      */
759 759
     public function getHashFile($key)
760 760
     {
761
-        return $this->getCacheFolder() . "docid_" . $key . ".pageCache.php";
761
+        return $this->getCacheFolder()."docid_".$key.".pageCache.php";
762 762
     }
763 763
 
764 764
     /**
@@ -769,9 +769,9 @@  discard block
 block discarded – undo
769 769
         $hash = $id;
770 770
         $tmp = null;
771 771
         $params = array();
772
-        if(!empty($this->systemCacheKey)){
772
+        if (!empty($this->systemCacheKey)) {
773 773
             $hash = $this->systemCacheKey;
774
-        }else {
774
+        } else {
775 775
             if (!empty($_GET)) {
776 776
                 // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID.
777 777
                 $params = $_GET;
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
                 $hash .= '_'.md5(http_build_query($params));
780 780
             }
781 781
         }
782
-        $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params));
783
-        if (is_array($evtOut) && count($evtOut) > 0){
782
+        $evtOut = $this->invokeEvent("OnMakePageCacheKey", array("hash" => $hash, "id" => $id, 'params' => $params));
783
+        if (is_array($evtOut) && count($evtOut) > 0) {
784 784
             $tmp = array_pop($evtOut);
785 785
         }
786 786
         return empty($tmp) ? $hash : $tmp;
@@ -922,12 +922,12 @@  discard block
 block discarded – undo
922 922
         if ($js = $this->getRegisteredClientStartupScripts()) {
923 923
             // change to just before closing </head>
924 924
             // $this->documentContent = preg_replace("/(<head[^>]*>)/i", "\\1\n".$js, $this->documentContent);
925
-            $this->documentOutput = preg_replace("/(<\/head>)/i", $js . "\n\\1", $this->documentOutput);
925
+            $this->documentOutput = preg_replace("/(<\/head>)/i", $js."\n\\1", $this->documentOutput);
926 926
         }
927 927
 
928 928
         // Insert jscripts & html block into template - template must have a </body> tag
929 929
         if ($js = $this->getRegisteredClientScripts()) {
930
-            $this->documentOutput = preg_replace("/(<\/body>)/i", $js . "\n\\1", $this->documentOutput);
930
+            $this->documentOutput = preg_replace("/(<\/body>)/i", $js."\n\\1", $this->documentOutput);
931 931
         }
932 932
         // End fix by sirlancelot
933 933
 
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
         // send out content-type and content-disposition headers
939 939
         if (IN_PARSER_MODE == "true") {
940 940
             $type = !empty ($this->contentTypes[$this->documentIdentifier]) ? $this->contentTypes[$this->documentIdentifier] : "text/html";
941
-            header('Content-Type: ' . $type . '; charset=' . $this->config['modx_charset']);
941
+            header('Content-Type: '.$type.'; charset='.$this->config['modx_charset']);
942 942
             //            if (($this->documentIdentifier == $this->config['error_page']) || $redirect_error)
943 943
             //                header('HTTP/1.0 404 Not Found');
944 944
             if (!$this->checkPreview() && $this->documentObject['content_dispo'] == 1) {
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
                     $name = preg_replace('|-+|', '-', $name);
957 957
                     $name = trim($name, '-');
958 958
                 }
959
-                $header = 'Content-Disposition: attachment; filename=' . $name;
959
+                $header = 'Content-Disposition: attachment; filename='.$name;
960 960
                 header($header);
961 961
             }
962 962
         }
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 
965 965
         $stats = $this->getTimerStats($this->tstart);
966 966
 
967
-        $out =& $this->documentOutput;
967
+        $out = & $this->documentOutput;
968 968
         $out = str_replace("[^q^]", $stats['queries'], $out);
969 969
         $out = str_replace("[^qt^]", $stats['queryTime'], $out);
970 970
         $out = str_replace("[^p^]", $stats['phpTime'], $out);
@@ -1003,17 +1003,17 @@  discard block
 block discarded – undo
1003 1003
                 $sc .= sprintf("%s. %s (%s)<br>", $s, $sname, sprintf("%2.2f ms", $t)); // currentSnippet
1004 1004
                 $tt += $t;
1005 1005
             }
1006
-            echo "<fieldset><legend><b>Snippets</b> (" . count($this->snippetsTime) . " / " . sprintf("%2.2f ms", $tt) . ")</legend>{$sc}</fieldset><br />";
1006
+            echo "<fieldset><legend><b>Snippets</b> (".count($this->snippetsTime)." / ".sprintf("%2.2f ms", $tt).")</legend>{$sc}</fieldset><br />";
1007 1007
             echo $this->snippetsCode;
1008 1008
         }
1009 1009
         if ($this->dumpPlugins) {
1010 1010
             $ps = "";
1011 1011
             $tt = 0;
1012 1012
             foreach ($this->pluginsTime as $s => $t) {
1013
-                $ps .= "$s (" . sprintf("%2.2f ms", $t * 1000) . ")<br>";
1013
+                $ps .= "$s (".sprintf("%2.2f ms", $t * 1000).")<br>";
1014 1014
                 $tt += $t;
1015 1015
             }
1016
-            echo "<fieldset><legend><b>Plugins</b> (" . count($this->pluginsTime) . " / " . sprintf("%2.2f ms", $tt * 1000) . ")</legend>{$ps}</fieldset><br />";
1016
+            echo "<fieldset><legend><b>Plugins</b> (".count($this->pluginsTime)." / ".sprintf("%2.2f ms", $tt * 1000).")</legend>{$ps}</fieldset><br />";
1017 1017
             echo $this->pluginsCode;
1018 1018
         }
1019 1019
 
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
         $srcTags = explode(',', $tags);
1040 1040
         $repTags = array();
1041 1041
         foreach ($srcTags as $tag) {
1042
-            $repTags[] = '\\' . $tag[0] . '\\' . $tag[1];
1042
+            $repTags[] = '\\'.$tag[0].'\\'.$tag[1];
1043 1043
         }
1044 1044
         return array($srcTags, $repTags);
1045 1045
     }
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
         $stats['phpTime'] = sprintf("%2.4f s", $stats['phpTime']);
1062 1062
         $stats['source'] = $this->documentGenerated == 1 ? "database" : "cache";
1063 1063
         $stats['queries'] = isset ($this->executedQueries) ? $this->executedQueries : 0;
1064
-        $stats['phpMemory'] = (memory_get_peak_usage(true) / 1024 / 1024) . " mb";
1064
+        $stats['phpMemory'] = (memory_get_peak_usage(true) / 1024 / 1024)." mb";
1065 1065
 
1066 1066
         return $stats;
1067 1067
     }
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
     {
1095 1095
         $cacheRefreshTime = 0;
1096 1096
         $recent_update = 0;
1097
-        @include(MODX_BASE_PATH . $this->getCacheFolder() . 'sitePublishing.idx.php');
1097
+        @include(MODX_BASE_PATH.$this->getCacheFolder().'sitePublishing.idx.php');
1098 1098
         $this->recentUpdate = $recent_update;
1099 1099
 
1100 1100
         $timeNow = $_SERVER['REQUEST_TIME'] + $this->config['server_offset_time'];
@@ -1148,8 +1148,8 @@  discard block
 block discarded – undo
1148 1148
                 }
1149 1149
 
1150 1150
                 $docObjSerial = serialize($this->documentObject);
1151
-                $cacheContent = $docObjSerial . "<!--__MODxCacheSpliter__-->" . $this->documentContent;
1152
-                $page_cache_path = MODX_BASE_PATH . $this->getHashFile($this->cacheKey);
1151
+                $cacheContent = $docObjSerial."<!--__MODxCacheSpliter__-->".$this->documentContent;
1152
+                $page_cache_path = MODX_BASE_PATH.$this->getHashFile($this->cacheKey);
1153 1153
                 file_put_contents($page_cache_path, "<?php die('Unauthorized access.'); ?>$cacheContent");
1154 1154
             }
1155 1155
         }
@@ -1191,16 +1191,16 @@  discard block
 block discarded – undo
1191 1191
             return array();
1192 1192
         }
1193 1193
         $spacer = md5('<<<EVO>>>');
1194
-        if($left==='{{' && strpos($content,';}}')!==false)  $content = str_replace(';}}', sprintf(';}%s}',   $spacer),$content);
1195
-        if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content);
1196
-        if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]',  $spacer),$content);
1197
-        if($left==='[[' && strpos($content,']]]')!==false)  $content = str_replace(']]]', sprintf(']%s]]',   $spacer),$content);
1194
+        if ($left === '{{' && strpos($content, ';}}') !== false)  $content = str_replace(';}}', sprintf(';}%s}', $spacer), $content);
1195
+        if ($left === '{{' && strpos($content, '{{}}') !== false) $content = str_replace('{{}}', sprintf('{%$1s{}%$1s}', $spacer), $content);
1196
+        if ($left === '[[' && strpos($content, ']]]]') !== false) $content = str_replace(']]]]', sprintf(']]%s]]', $spacer), $content);
1197
+        if ($left === '[[' && strpos($content, ']]]') !== false)  $content = str_replace(']]]', sprintf(']%s]]', $spacer), $content);
1198 1198
 
1199 1199
         $pos['<![CDATA['] = strpos($content, '<![CDATA[');
1200 1200
         $pos[']]>'] = strpos($content, ']]>');
1201 1201
 
1202 1202
         if ($pos['<![CDATA['] !== false && $pos[']]>'] !== false) {
1203
-            $content = substr($content, 0, $pos['<![CDATA[']) . substr($content, $pos[']]>'] + 3);
1203
+            $content = substr($content, 0, $pos['<![CDATA[']).substr($content, $pos[']]>'] + 3);
1204 1204
         }
1205 1205
 
1206 1206
         $lp = explode($left, $content);
@@ -1264,8 +1264,8 @@  discard block
 block discarded – undo
1264 1264
                 }
1265 1265
             }
1266 1266
         }
1267
-        foreach($tags as $i=>$tag) {
1268
-            if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag);
1267
+        foreach ($tags as $i=>$tag) {
1268
+            if (strpos($tag, $spacer) !== false) $tags[$i] = str_replace($spacer, '', $tag);
1269 1269
         }
1270 1270
         return $tags;
1271 1271
     }
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
         }
1306 1306
 
1307 1307
         foreach ($matches[1] as $i => $key) {
1308
-            if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1308
+            if (strpos($key, '[+') !== false) continue; // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1309 1309
             if (substr($key, 0, 1) == '#') {
1310 1310
                 $key = substr($key, 1);
1311 1311
             } // remove # for QuickEdit format
@@ -1325,8 +1325,8 @@  discard block
 block discarded – undo
1325 1325
             }
1326 1326
 
1327 1327
             if (is_array($value)) {
1328
-                include_once(MODX_MANAGER_PATH . 'includes/tmplvars.format.inc.php');
1329
-                include_once(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php');
1328
+                include_once(MODX_MANAGER_PATH.'includes/tmplvars.format.inc.php');
1329
+                include_once(MODX_MANAGER_PATH.'includes/tmplvars.commands.inc.php');
1330 1330
                 $value = getTVDisplayFormat($value[0], $value[1], $value[2], $value[3], $value[4]);
1331 1331
             }
1332 1332
 
@@ -1337,8 +1337,8 @@  discard block
 block discarded – undo
1337 1337
 
1338 1338
             if (strpos($content, $s) !== false) {
1339 1339
                 $content = str_replace($s, $value, $content);
1340
-            } elseif($this->debug) {
1341
-                $this->addLog('mergeDocumentContent parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1340
+            } elseif ($this->debug) {
1341
+                $this->addLog('mergeDocumentContent parse error', $_SERVER['REQUEST_URI'].$s, 2);
1342 1342
             }
1343 1343
         }
1344 1344
 
@@ -1505,8 +1505,8 @@  discard block
 block discarded – undo
1505 1505
             $s = &$matches[0][$i];
1506 1506
             if (strpos($content, $s) !== false) {
1507 1507
                 $content = str_replace($s, $value, $content);
1508
-            } elseif($this->debug) {
1509
-                $this->addLog('mergeSettingsContent parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1508
+            } elseif ($this->debug) {
1509
+                $this->addLog('mergeSettingsContent parse error', $_SERVER['REQUEST_URI'].$s, 2);
1510 1510
             }
1511 1511
         }
1512 1512
         return $content;
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
             }
1560 1560
 
1561 1561
             $value = $this->parseText($value, $params); // parse local scope placeholers for ConditionalTags
1562
-            $value = $this->mergePlaceholderContent($value, $params);  // parse page global placeholers
1562
+            $value = $this->mergePlaceholderContent($value, $params); // parse page global placeholers
1563 1563
             if ($this->config['enable_at_syntax']) {
1564 1564
                 $value = $this->mergeConditionalTagsContent($value);
1565 1565
             }
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
             $s = &$matches[0][$i];
1575 1575
             if (strpos($content, $s) !== false) {
1576 1576
                 $content = str_replace($s, $value, $content);
1577
-            } elseif($this->debug) {
1578
-                $this->addLog('mergeChunkContent parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1577
+            } elseif ($this->debug) {
1578
+                $this->addLog('mergeChunkContent parse error', $_SERVER['REQUEST_URI'].$s, 2);
1579 1579
             }
1580 1580
         }
1581 1581
         return $content;
@@ -1633,8 +1633,8 @@  discard block
 block discarded – undo
1633 1633
             $s = &$matches[0][$i];
1634 1634
             if (strpos($content, $s) !== false) {
1635 1635
                 $content = str_replace($s, $value, $content);
1636
-            } elseif($this->debug) {
1637
-                $this->addLog('mergePlaceholderContent parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1636
+            } elseif ($this->debug) {
1637
+                $this->addLog('mergePlaceholderContent parse error', $_SERVER['REQUEST_URI'].$s, 2);
1638 1638
             }
1639 1639
         }
1640 1640
         return $content;
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
             return $content;
1659 1659
         }
1660 1660
 
1661
-        $sp = '#' . md5('ConditionalTags' . $_SERVER['REQUEST_TIME']) . '#';
1661
+        $sp = '#'.md5('ConditionalTags'.$_SERVER['REQUEST_TIME']).'#';
1662 1662
         $content = str_replace(array('<?php', '<?=', '<?', '?>'), array("{$sp}b", "{$sp}p", "{$sp}s", "{$sp}e"), $content);
1663 1663
 
1664 1664
         $pieces = explode('<@IF:', $content);
@@ -1669,7 +1669,7 @@  discard block
 block discarded – undo
1669 1669
             }
1670 1670
             list($cmd, $text) = explode('>', $split, 2);
1671 1671
             $cmd = str_replace("'", "\'", $cmd);
1672
-            $content .= "<?php if(\$this->_parseCTagCMD('" . $cmd . "')): ?>";
1672
+            $content .= "<?php if(\$this->_parseCTagCMD('".$cmd."')): ?>";
1673 1673
             $content .= $text;
1674 1674
         }
1675 1675
         $pieces = explode('<@ELSEIF:', $content);
@@ -1680,13 +1680,13 @@  discard block
 block discarded – undo
1680 1680
             }
1681 1681
             list($cmd, $text) = explode('>', $split, 2);
1682 1682
             $cmd = str_replace("'", "\'", $cmd);
1683
-            $content .= "<?php elseif(\$this->_parseCTagCMD('" . $cmd . "')): ?>";
1683
+            $content .= "<?php elseif(\$this->_parseCTagCMD('".$cmd."')): ?>";
1684 1684
             $content .= $text;
1685 1685
         }
1686 1686
 
1687 1687
         $content = str_replace(array('<@ELSE>', '<@ENDIF>'), array('<?php else:?>', '<?php endif;?>'), $content);
1688 1688
         ob_start();
1689
-        $content = eval('?>' . $content);
1689
+        $content = eval('?>'.$content);
1690 1690
         $content = ob_get_clean();
1691 1691
         $content = str_replace(array("{$sp}b", "{$sp}p", "{$sp}s", "{$sp}e"), array('<?php', '<?=', '<?', '?>'), $content);
1692 1692
 
@@ -1811,7 +1811,7 @@  discard block
 block discarded – undo
1811 1811
         $matches = $this->getTagsFromContent($content, $left, $right);
1812 1812
         if (!empty($matches)) {
1813 1813
             foreach ($matches[0] as $i => $v) {
1814
-                $addBreakMatches[$i] = $v . "\n";
1814
+                $addBreakMatches[$i] = $v."\n";
1815 1815
             }
1816 1816
             $content = str_replace($addBreakMatches, '', $content);
1817 1817
             if (strpos($content, $left) !== false) {
@@ -1844,8 +1844,8 @@  discard block
 block discarded – undo
1844 1844
             $s = &$matches[0][$i];
1845 1845
             if (strpos($content, $s) !== false) {
1846 1846
                 $content = str_replace($s, $v, $content);
1847
-            } elseif($this->debug) {
1848
-                $this->addLog('ignoreCommentedTagsContent parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1847
+            } elseif ($this->debug) {
1848
+                $this->addLog('ignoreCommentedTagsContent parse error', $_SERVER['REQUEST_URI'].$s, 2);
1849 1849
             }
1850 1850
         }
1851 1851
         return $content;
@@ -1909,7 +1909,7 @@  discard block
 block discarded – undo
1909 1909
                 $msg = ($msg === false) ? 'ob_get_contents() error' : $msg;
1910 1910
                 $this->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], 'Plugin', $error_info['message'], $error_info['line'], $msg);
1911 1911
                 if ($this->isBackend()) {
1912
-                    $this->event->alert('An error occurred while loading. Please see the event log for more information.<p>' . $msg . '</p>');
1912
+                    $this->event->alert('An error occurred while loading. Please see the event log for more information.<p>'.$msg.'</p>');
1913 1913
                 }
1914 1914
             }
1915 1915
         } else {
@@ -1955,7 +1955,7 @@  discard block
 block discarded – undo
1955 1955
                 $echo = ($echo === false) ? 'ob_get_contents() error' : $echo;
1956 1956
                 $this->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], 'Snippet', $error_info['message'], $error_info['line'], $echo);
1957 1957
                 if ($this->isBackend()) {
1958
-                    $this->event->alert('An error occurred while loading. Please see the event log for more information<p>' . $echo . $return . '</p>');
1958
+                    $this->event->alert('An error occurred while loading. Please see the event log for more information<p>'.$echo.$return.'</p>');
1959 1959
                 }
1960 1960
             }
1961 1961
         }
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
         if (is_array($return) || is_object($return)) {
1964 1964
             return $return;
1965 1965
         } else {
1966
-            return $echo . $return;
1966
+            return $echo.$return;
1967 1967
         }
1968 1968
     }
1969 1969
 
@@ -2001,8 +2001,8 @@  discard block
 block discarded – undo
2001 2001
                 }
2002 2002
                 if (strpos($content, $s) !== false) {
2003 2003
                     $content = str_replace($s, $value, $content);
2004
-                } elseif($this->debug) {
2005
-                    $this->addLog('evalSnippetsSGVar parse error', $_SERVER['REQUEST_URI'] . $s, 2);
2004
+                } elseif ($this->debug) {
2005
+                    $this->addLog('evalSnippetsSGVar parse error', $_SERVER['REQUEST_URI'].$s, 2);
2006 2006
                 }
2007 2007
                 continue;
2008 2008
             }
@@ -2013,8 +2013,8 @@  discard block
 block discarded – undo
2013 2013
 
2014 2014
             if (strpos($content, $s) !== false) {
2015 2015
                 $content = str_replace($s, $value, $content);
2016
-            } elseif($this->debug) {
2017
-                $this->addLog('evalSnippets parse error', $_SERVER['REQUEST_URI'] . $s, 2);
2016
+            } elseif ($this->debug) {
2017
+                $this->addLog('evalSnippets parse error', $_SERVER['REQUEST_URI'].$s, 2);
2018 2018
             }
2019 2019
         }
2020 2020
 
@@ -2105,7 +2105,7 @@  discard block
 block discarded – undo
2105 2105
             $eventtime = sprintf('%2.2f ms', $eventtime * 1000);
2106 2106
             $code = str_replace("\t", '  ', $this->htmlspecialchars($value));
2107 2107
             $piece = str_replace("\t", '  ', $this->htmlspecialchars($piece));
2108
-            $print_r_params = str_replace("\t", '  ', $this->htmlspecialchars('$modx->event->params = ' . print_r($params, true)));
2108
+            $print_r_params = str_replace("\t", '  ', $this->htmlspecialchars('$modx->event->params = '.print_r($params, true)));
2109 2109
             $this->snippetsCode .= sprintf('<fieldset style="margin:1em;"><legend><b>%s</b>(%s)</legend><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">[[%s]]</pre><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">%s</pre><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">%s</pre></fieldset>', $snippetObject['name'], $eventtime, $piece, $print_r_params, $code);
2110 2110
             $this->snippetsTime[] = array('sname' => $key, 'time' => $eventtime);
2111 2111
         }
@@ -2349,7 +2349,7 @@  discard block
 block discarded – undo
2349 2349
             $rs = $this->db->select('name,snippet,properties', '[+prefix+]site_snippets', $where);
2350 2350
             $count = $this->db->getRecordCount($rs);
2351 2351
             if (1 < $count) {
2352
-                exit('Error $modx->_getSnippetObject()' . $snip_name);
2352
+                exit('Error $modx->_getSnippetObject()'.$snip_name);
2353 2353
             }
2354 2354
             if ($count) {
2355 2355
                 $row = $this->db->getRow($rs);
@@ -2375,7 +2375,7 @@  discard block
 block discarded – undo
2375 2375
     public function toAlias($text)
2376 2376
     {
2377 2377
         $suff = $this->config['friendly_url_suffix'];
2378
-        return str_replace(array('.xml' . $suff, '.rss' . $suff, '.js' . $suff, '.css' . $suff, '.txt' . $suff, '.json' . $suff, '.pdf' . $suff), array('.xml', '.rss', '.js', '.css', '.txt', '.json', '.pdf'), $text);
2378
+        return str_replace(array('.xml'.$suff, '.rss'.$suff, '.js'.$suff, '.css'.$suff, '.txt'.$suff, '.json'.$suff, '.pdf'.$suff), array('.xml', '.rss', '.js', '.css', '.txt', '.json', '.pdf'), $text);
2379 2379
     }
2380 2380
 
2381 2381
     /**
@@ -2407,7 +2407,7 @@  discard block
 block discarded – undo
2407 2407
                 $suff = '/';
2408 2408
             }
2409 2409
 
2410
-            $url = ($dir != '' ? $dir . '/' : '') . $pre . $alias . $suff;
2410
+            $url = ($dir != '' ? $dir.'/' : '').$pre.$alias.$suff;
2411 2411
         }
2412 2412
 
2413 2413
         $evtOut = $this->invokeEvent('OnMakeDocUrl', array(
@@ -2444,7 +2444,7 @@  discard block
 block discarded – undo
2444 2444
                 preg_match_all('!\[\~([0-9]+)\~\]!ise', $documentSource, $match);
2445 2445
                 $ids = implode(',', array_unique($match['1']));
2446 2446
                 if ($ids) {
2447
-                    $res = $this->db->select("id,alias,isfolder,parent,alias_visible", $this->getFullTableName('site_content'), "id IN (" . $ids . ") AND isfolder = '0'");
2447
+                    $res = $this->db->select("id,alias,isfolder,parent,alias_visible", $this->getFullTableName('site_content'), "id IN (".$ids.") AND isfolder = '0'");
2448 2448
                     while ($row = $this->db->getRow($res)) {
2449 2449
                         if ($this->config['use_alias_path'] == '1' && $row['parent'] != 0) {
2450 2450
                             $parent = $row['parent'];
@@ -2455,7 +2455,7 @@  discard block
 block discarded – undo
2455 2455
                                 $parent = $this->aliasListing[$parent]['parent'];
2456 2456
                             }
2457 2457
 
2458
-                            $aliases[$row['id']] = $path . '/' . $row['alias'];
2458
+                            $aliases[$row['id']] = $path.'/'.$row['alias'];
2459 2459
                         } else {
2460 2460
                             $aliases[$row['id']] = $row['alias'];
2461 2461
                         }
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
             $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0);
2468 2468
             $pref = $this->config['friendly_url_prefix'];
2469 2469
             $suff = $this->config['friendly_url_suffix'];
2470
-            $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) {
2470
+            $documentSource = preg_replace_callback($in, function($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) {
2471 2471
                 $modx = DocumentParser::getInstance();
2472 2472
                 $thealias = $aliases[$m[1]];
2473 2473
                 $thefolder = $isfolder[$m[1]];
@@ -2483,7 +2483,7 @@  discard block
 block discarded – undo
2483 2483
 
2484 2484
         } else {
2485 2485
             $in = '!\[\~([0-9]+)\~\]!is';
2486
-            $out = "index.php?id=" . '\1';
2486
+            $out = "index.php?id=".'\1';
2487 2487
             $documentSource = preg_replace($in, $out, $documentSource);
2488 2488
         }
2489 2489
 
@@ -2504,7 +2504,7 @@  discard block
 block discarded – undo
2504 2504
         $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
2505 2505
         $len_base_url = strlen($this->config['base_url']);
2506 2506
 
2507
-        $url_path = $q;//LANG
2507
+        $url_path = $q; //LANG
2508 2508
 
2509 2509
         if (substr($url_path, 0, $len_base_url) === $this->config['base_url']) {
2510 2510
             $url_path = substr($url_path, $len_base_url);
@@ -2516,7 +2516,7 @@  discard block
 block discarded – undo
2516 2516
             $strictURL = substr($strictURL, $len_base_url);
2517 2517
         }
2518 2518
         $http_host = $_SERVER['HTTP_HOST'];
2519
-        $requestedURL = "{$scheme}://{$http_host}" . '/' . $q; //LANG
2519
+        $requestedURL = "{$scheme}://{$http_host}".'/'.$q; //LANG
2520 2520
 
2521 2521
         $site_url = $this->config['site_url'];
2522 2522
 
@@ -2532,7 +2532,7 @@  discard block
 block discarded – undo
2532 2532
                 }
2533 2533
                 if ($this->config['base_url'] != $_SERVER['REQUEST_URI']) {
2534 2534
                     if (empty($_POST)) {
2535
-                        if (($this->config['base_url'] . '?' . $qstring) != $_SERVER['REQUEST_URI']) {
2535
+                        if (($this->config['base_url'].'?'.$qstring) != $_SERVER['REQUEST_URI']) {
2536 2536
                             $this->sendRedirect($url, 0, 'REDIRECT_HEADER', 'HTTP/1.0 301 Moved Permanently');
2537 2537
                             exit(0);
2538 2538
                         }
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
                 $docgrp = implode(",", $docgrp);
2596 2596
             }
2597 2597
             // get document
2598
-            $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
2598
+            $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
2599 2599
             $rs = $this->db->select('sc.*', "{$tblsc} sc
2600 2600
                 LEFT JOIN {$tbldg} dg ON dg.document = sc.id", "sc.{$method} = '{$identifier}' AND ({$access})", "", 1);
2601 2601
             if ($this->db->getRecordCount($rs) < 1) {
@@ -2631,9 +2631,9 @@  discard block
 block discarded – undo
2631 2631
             }
2632 2632
             if ($documentObject['template']) {
2633 2633
                 // load TVs and merge with document - Orig by Apodigm - Docvars
2634
-                $rs = $this->db->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars") . " tv
2635
-                INNER JOIN " . $this->getFullTableName("site_tmplvar_templates") . " tvtpl ON tvtpl.tmplvarid = tv.id
2636
-                LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues") . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'");
2634
+                $rs = $this->db->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars")." tv
2635
+                INNER JOIN " . $this->getFullTableName("site_tmplvar_templates")." tvtpl ON tvtpl.tmplvarid = tv.id
2636
+                LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues")." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'");
2637 2637
                 $tmplvars = array();
2638 2638
                 while ($row = $this->db->getRow($rs)) {
2639 2639
                     $tmplvars[$row['name']] = array(
@@ -2679,7 +2679,7 @@  discard block
 block discarded – undo
2679 2679
                 $st = md5($source);
2680 2680
             }
2681 2681
             if ($this->dumpSnippets == 1) {
2682
-                $this->snippetsCode .= "<fieldset><legend><b style='color: #821517;'>PARSE PASS " . ($i + 1) . "</b></legend><p>The following snippets (if any) were parsed during this pass.</p>";
2682
+                $this->snippetsCode .= "<fieldset><legend><b style='color: #821517;'>PARSE PASS ".($i + 1)."</b></legend><p>The following snippets (if any) were parsed during this pass.</p>";
2683 2683
             }
2684 2684
 
2685 2685
             // invoke OnParseDocument event
@@ -2765,7 +2765,7 @@  discard block
 block discarded – undo
2765 2765
 
2766 2766
             // Check use_alias_path and check if $this->virtualDir is set to anything, then parse the path
2767 2767
             if ($this->config['use_alias_path'] == 1) {
2768
-                $alias = (strlen($this->virtualDir) > 0 ? $this->virtualDir . '/' : '') . $this->documentIdentifier;
2768
+                $alias = (strlen($this->virtualDir) > 0 ? $this->virtualDir.'/' : '').$this->documentIdentifier;
2769 2769
                 if (isset($this->documentListing[$alias])) {
2770 2770
                     $this->documentIdentifier = $this->documentListing[$alias];
2771 2771
                 } else {
@@ -2826,7 +2826,7 @@  discard block
 block discarded – undo
2826 2826
                 } else {
2827 2827
                     $docAlias = $this->db->escape($this->documentIdentifier);
2828 2828
                     $rs = $this->db->select('id', $this->getFullTableName('site_content'), "deleted=0 and alias='{$docAlias}'");
2829
-                    $this->documentIdentifier = (int)$this->db->getValue($rs);
2829
+                    $this->documentIdentifier = (int) $this->db->getValue($rs);
2830 2830
                 }
2831 2831
             }
2832 2832
             $this->documentMethod = 'id';
@@ -2879,7 +2879,7 @@  discard block
 block discarded – undo
2879 2879
                 $_REQUEST[$n] = $_GET[$n] = $v;
2880 2880
             }
2881 2881
         }
2882
-        $_SERVER['PHP_SELF'] = $this->config['base_url'] . $qp['path'];
2882
+        $_SERVER['PHP_SELF'] = $this->config['base_url'].$qp['path'];
2883 2883
         $this->q = $qp['path'];
2884 2884
         return $qp['path'];
2885 2885
     }
@@ -2973,7 +2973,7 @@  discard block
 block discarded – undo
2973 2973
             $this->sendErrorPage();
2974 2974
         } else {
2975 2975
             // Inculde the necessary files to check document permissions
2976
-            include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
2976
+            include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php');
2977 2977
             $udperms = new udperms();
2978 2978
             $udperms->user = $this->getLoginUserID();
2979 2979
             $udperms->document = $this->documentIdentifier;
@@ -3027,7 +3027,7 @@  discard block
 block discarded – undo
3027 3027
         while ($id && $height--) {
3028 3028
             $thisid = $id;
3029 3029
             if ($this->config['aliaslistingfolder'] == 1) {
3030
-                $id = isset($this->aliasListing[$id]['parent']) ? $this->aliasListing[$id]['parent'] : $this->db->getValue("SELECT `parent` FROM " . $this->getFullTableName("site_content") . " WHERE `id` = '{$id}' LIMIT 0,1");
3030
+                $id = isset($this->aliasListing[$id]['parent']) ? $this->aliasListing[$id]['parent'] : $this->db->getValue("SELECT `parent` FROM ".$this->getFullTableName("site_content")." WHERE `id` = '{$id}' LIMIT 0,1");
3031 3031
                 if (!$id || $id == '0') {
3032 3032
                     break;
3033 3033
                 }
@@ -3078,15 +3078,15 @@  discard block
 block discarded – undo
3078 3078
 
3079 3079
         if ($this->config['aliaslistingfolder'] == 1) {
3080 3080
 
3081
-            $res = $this->db->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (" . $id . ") AND deleted = '0'");
3081
+            $res = $this->db->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (".$id.") AND deleted = '0'");
3082 3082
             $idx = array();
3083 3083
             while ($row = $this->db->getRow($res)) {
3084 3084
                 $pAlias = '';
3085 3085
                 if (isset($this->aliasListing[$row['parent']])) {
3086
-                    $pAlias .= !empty($this->aliasListing[$row['parent']]['path']) ? $this->aliasListing[$row['parent']]['path'] . '/' : '';
3087
-                    $pAlias .= !empty($this->aliasListing[$row['parent']]['alias']) ? $this->aliasListing[$row['parent']]['alias'] . '/' : '';
3086
+                    $pAlias .= !empty($this->aliasListing[$row['parent']]['path']) ? $this->aliasListing[$row['parent']]['path'].'/' : '';
3087
+                    $pAlias .= !empty($this->aliasListing[$row['parent']]['alias']) ? $this->aliasListing[$row['parent']]['alias'].'/' : '';
3088 3088
                 };
3089
-                $children[$pAlias . $row['alias']] = $row['id'];
3089
+                $children[$pAlias.$row['alias']] = $row['id'];
3090 3090
                 if ($row['isfolder'] == 1) {
3091 3091
                     $idx[] = $row['id'];
3092 3092
                 }
@@ -3118,7 +3118,7 @@  discard block
 block discarded – undo
3118 3118
                 $depth--;
3119 3119
 
3120 3120
                 foreach ($documentMap_cache[$id] as $childId) {
3121
-                    $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '') . $this->aliasListing[$childId]['alias'];
3121
+                    $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '').$this->aliasListing[$childId]['alias'];
3122 3122
                     if (!strlen($pkey)) {
3123 3123
                         $pkey = "{$childId}";
3124 3124
                     }
@@ -3147,7 +3147,7 @@  discard block
 block discarded – undo
3147 3147
         if (substr(strtolower($url), 0, 11) == "javascript:") {
3148 3148
             $fnc = substr($url, 11);
3149 3149
         } elseif ($url) {
3150
-            $fnc = "window.location.href='" . addslashes($url) . "';";
3150
+            $fnc = "window.location.href='".addslashes($url)."';";
3151 3151
         } else {
3152 3152
             $fnc = "history.back(-1);";
3153 3153
         }
@@ -3156,7 +3156,7 @@  discard block
 block discarded – undo
3156 3156
             <meta http-equiv=\"Content-Type\" content=\"text/html; charset={$modx_manager_charset};\">
3157 3157
             <script>
3158 3158
                 function __alertQuit() {
3159
-                    alert('" . addslashes($msg) . "');
3159
+                    alert('".addslashes($msg)."');
3160 3160
                     {$fnc}
3161 3161
                 }
3162 3162
                 window.setTimeout('__alertQuit();',100);
@@ -3178,9 +3178,9 @@  discard block
 block discarded – undo
3178 3178
         $state = 0;
3179 3179
         $pms = $_SESSION['mgrPermissions'];
3180 3180
         if ($pms) {
3181
-            $state = ((bool)$pms[$pm] === true);
3181
+            $state = ((bool) $pms[$pm] === true);
3182 3182
         }
3183
-        return (int)$state;
3183
+        return (int) $state;
3184 3184
     }
3185 3185
 
3186 3186
     /**
@@ -3193,8 +3193,8 @@  discard block
 block discarded – undo
3193 3193
      */
3194 3194
     public function elementIsLocked($type, $id, $includeThisUser = false)
3195 3195
     {
3196
-        $id = (int)$id;
3197
-        $type = (int)$type;
3196
+        $id = (int) $id;
3197
+        $type = (int) $type;
3198 3198
         if (!$type || !$id) {
3199 3199
             return null;
3200 3200
         }
@@ -3244,7 +3244,7 @@  discard block
 block discarded – undo
3244 3244
             return $lockedElements;
3245 3245
         }
3246 3246
 
3247
-        $type = (int)$type;
3247
+        $type = (int) $type;
3248 3248
         if (isset($lockedElements[$type])) {
3249 3249
             return $lockedElements[$type];
3250 3250
         } else {
@@ -3261,7 +3261,7 @@  discard block
 block discarded – undo
3261 3261
             $this->lockedElements = array();
3262 3262
             $this->cleanupExpiredLocks();
3263 3263
 
3264
-            $rs = $this->db->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks') . " ul
3264
+            $rs = $this->db->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks')." ul
3265 3265
                 LEFT JOIN {$this->getFullTableName('manager_users')} mu on ul.internalKey = mu.id");
3266 3266
             while ($row = $this->db->getRow($rs)) {
3267 3267
                 $this->lockedElements[$row['elementType']][$row['elementId']] = array(
@@ -3284,7 +3284,7 @@  discard block
 block discarded – undo
3284 3284
     public function cleanupExpiredLocks()
3285 3285
     {
3286 3286
         // Clean-up active_user_sessions first
3287
-        $timeout = (int)$this->config['session_timeout'] < 2 ? 120 : $this->config['session_timeout'] * 60; // session.js pings every 10min, updateMail() in mainMenu pings every minute, so 2min is minimum
3287
+        $timeout = (int) $this->config['session_timeout'] < 2 ? 120 : $this->config['session_timeout'] * 60; // session.js pings every 10min, updateMail() in mainMenu pings every minute, so 2min is minimum
3288 3288
         $validSessionTimeLimit = $this->time - $timeout;
3289 3289
         $this->db->delete($this->getFullTableName('active_user_sessions'), "lasthit < {$validSessionTimeLimit}");
3290 3290
 
@@ -3297,7 +3297,7 @@  discard block
 block discarded – undo
3297 3297
             foreach ($rs as $row) {
3298 3298
                 $userSids[] = $row['sid'];
3299 3299
             }
3300
-            $userSids = "'" . implode("','", $userSids) . "'";
3300
+            $userSids = "'".implode("','", $userSids)."'";
3301 3301
             $this->db->delete($this->getFullTableName('active_user_locks'), "sid NOT IN({$userSids})");
3302 3302
         } else {
3303 3303
             $this->db->delete($this->getFullTableName('active_user_locks'));
@@ -3381,8 +3381,8 @@  discard block
 block discarded – undo
3381 3381
     public function lockElement($type, $id)
3382 3382
     {
3383 3383
         $userId = $this->isBackend() && $_SESSION['mgrInternalKey'] ? $_SESSION['mgrInternalKey'] : 0;
3384
-        $type = (int)$type;
3385
-        $id = (int)$id;
3384
+        $type = (int) $type;
3385
+        $id = (int) $id;
3386 3386
         if (!$type || !$id || !$userId) {
3387 3387
             return false;
3388 3388
         }
@@ -3403,8 +3403,8 @@  discard block
 block discarded – undo
3403 3403
     public function unlockElement($type, $id, $includeAllUsers = false)
3404 3404
     {
3405 3405
         $userId = $this->isBackend() && $_SESSION['mgrInternalKey'] ? $_SESSION['mgrInternalKey'] : 0;
3406
-        $type = (int)$type;
3407
-        $id = (int)$id;
3406
+        $type = (int) $type;
3407
+        $id = (int) $id;
3408 3408
         if (!$type || !$id) {
3409 3409
             return false;
3410 3410
         }
@@ -3471,8 +3471,8 @@  discard block
 block discarded – undo
3471 3471
         }
3472 3472
 
3473 3473
         $usertype = $this->isFrontend() ? 1 : 0;
3474
-        $evtid = (int)$evtid;
3475
-        $type = (int)$type;
3474
+        $evtid = (int) $evtid;
3475
+        $type = (int) $type;
3476 3476
 
3477 3477
         // Types: 1 = information, 2 = warning, 3 = error
3478 3478
         if ($type < 1) {
@@ -3494,8 +3494,8 @@  discard block
 block discarded – undo
3494 3494
         if (isset($this->config['send_errormail']) && $this->config['send_errormail'] !== '0') {
3495 3495
             if ($this->config['send_errormail'] <= $type) {
3496 3496
                 $this->sendmail(array(
3497
-                    'subject' => 'MODX System Error on ' . $this->config['site_name'],
3498
-                    'body' => 'Source: ' . $source . ' - The details of the error could be seen in the MODX system events log.',
3497
+                    'subject' => 'MODX System Error on '.$this->config['site_name'],
3498
+                    'body' => 'Source: '.$source.' - The details of the error could be seen in the MODX system events log.',
3499 3499
                     'type' => 'text'
3500 3500
                 ));
3501 3501
             }
@@ -3543,7 +3543,7 @@  discard block
 block discarded – undo
3543 3543
             $p['fromname'] = $userinfo['username'];
3544 3544
         }
3545 3545
         if ($msg === '' && !isset($p['body'])) {
3546
-            $p['body'] = $_SERVER['REQUEST_URI'] . "\n" . $_SERVER['HTTP_USER_AGENT'] . "\n" . $_SERVER['HTTP_REFERER'];
3546
+            $p['body'] = $_SERVER['REQUEST_URI']."\n".$_SERVER['HTTP_USER_AGENT']."\n".$_SERVER['HTTP_REFERER'];
3547 3547
         } elseif (is_string($msg) && 0 < strlen($msg)) {
3548 3548
             $p['body'] = $msg;
3549 3549
         }
@@ -3583,8 +3583,8 @@  discard block
 block discarded – undo
3583 3583
             $files = array();
3584 3584
         }
3585 3585
         foreach ($files as $f) {
3586
-            if (file_exists(MODX_BASE_PATH . $f) && is_file(MODX_BASE_PATH . $f) && is_readable(MODX_BASE_PATH . $f)) {
3587
-                $this->mail->AddAttachment(MODX_BASE_PATH . $f);
3586
+            if (file_exists(MODX_BASE_PATH.$f) && is_file(MODX_BASE_PATH.$f) && is_readable(MODX_BASE_PATH.$f)) {
3587
+                $this->mail->AddAttachment(MODX_BASE_PATH.$f);
3588 3588
             }
3589 3589
         }
3590 3590
         $rs = $this->mail->send();
@@ -3629,7 +3629,7 @@  discard block
 block discarded – undo
3629 3629
      */
3630 3630
     public function isFrontend()
3631 3631
     {
3632
-        return ! $this->isBackend();
3632
+        return !$this->isBackend();
3633 3633
     }
3634 3634
 
3635 3635
     /**
@@ -3654,14 +3654,14 @@  discard block
 block discarded – undo
3654 3654
         $tblsc = $this->getFullTableName("site_content");
3655 3655
         $tbldg = $this->getFullTableName("document_groups");
3656 3656
         // modify field names to use sc. table reference
3657
-        $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3658
-        $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3657
+        $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3658
+        $sort = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3659 3659
         // get document groups for current user
3660 3660
         if ($docgrp = $this->getUserDocGroups()) {
3661 3661
             $docgrp = implode(",", $docgrp);
3662 3662
         }
3663 3663
         // build query
3664
-        $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3664
+        $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3665 3665
         $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc
3666 3666
                 LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}");
3667 3667
         $resourceArray = $this->db->makeArray($result);
@@ -3691,14 +3691,14 @@  discard block
 block discarded – undo
3691 3691
         $tbldg = $this->getFullTableName("document_groups");
3692 3692
 
3693 3693
         // modify field names to use sc. table reference
3694
-        $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3695
-        $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3694
+        $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3695
+        $sort = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3696 3696
         // get document groups for current user
3697 3697
         if ($docgrp = $this->getUserDocGroups()) {
3698 3698
             $docgrp = implode(",", $docgrp);
3699 3699
         }
3700 3700
         // build query
3701
-        $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3701
+        $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3702 3702
         $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc
3703 3703
                 LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND sc.published=1 AND sc.deleted=0 AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}");
3704 3704
         $resourceArray = $this->db->makeArray($result);
@@ -3733,16 +3733,16 @@  discard block
 block discarded – undo
3733 3733
             return $this->tmpCache[__FUNCTION__][$cacheKey];
3734 3734
         }
3735 3735
 
3736
-        $published = ($published !== 'all') ? 'AND sc.published = ' . $published : '';
3737
-        $deleted = ($deleted !== 'all') ? 'AND sc.deleted = ' . $deleted : '';
3736
+        $published = ($published !== 'all') ? 'AND sc.published = '.$published : '';
3737
+        $deleted = ($deleted !== 'all') ? 'AND sc.deleted = '.$deleted : '';
3738 3738
 
3739 3739
         if ($where != '') {
3740
-            $where = 'AND ' . $where;
3740
+            $where = 'AND '.$where;
3741 3741
         }
3742 3742
 
3743 3743
         // modify field names to use sc. table reference
3744
-        $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3745
-        $sort = ($sort == '') ? '' : 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3744
+        $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3745
+        $sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3746 3746
 
3747 3747
         // get document groups for current user
3748 3748
         if ($docgrp = $this->getUserDocGroups()) {
@@ -3750,7 +3750,7 @@  discard block
 block discarded – undo
3750 3750
         }
3751 3751
 
3752 3752
         // build query
3753
-        $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="' . $_SESSION['mgrRole'] . '" OR sc.privatemgr=0') . (!$docgrp ? '' : ' OR dg.document_group IN (' . $docgrp . ')');
3753
+        $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')');
3754 3754
 
3755 3755
         $tblsc = $this->getFullTableName('site_content');
3756 3756
         $tbldg = $this->getFullTableName('document_groups');
@@ -3802,10 +3802,10 @@  discard block
 block discarded – undo
3802 3802
             return false;
3803 3803
         } else {
3804 3804
             // modify field names to use sc. table reference
3805
-            $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3806
-            $sort = ($sort == '') ? '' : 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3805
+            $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3806
+            $sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3807 3807
             if ($where != '') {
3808
-                $where = 'AND ' . $where;
3808
+                $where = 'AND '.$where;
3809 3809
             }
3810 3810
 
3811 3811
             $published = ($published !== 'all') ? "AND sc.published = '{$published}'" : '';
@@ -3816,13 +3816,13 @@  discard block
 block discarded – undo
3816 3816
                 $docgrp = implode(',', $docgrp);
3817 3817
             }
3818 3818
 
3819
-            $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="' . $_SESSION['mgrRole'] . '" OR sc.privatemgr=0') . (!$docgrp ? '' : ' OR dg.document_group IN (' . $docgrp . ')');
3819
+            $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')');
3820 3820
 
3821 3821
             $tblsc = $this->getFullTableName('site_content');
3822 3822
             $tbldg = $this->getFullTableName('document_groups');
3823 3823
 
3824 3824
             $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc
3825
-                    LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (" . implode(',', $ids) . ") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit);
3825
+                    LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (".implode(',', $ids).") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit);
3826 3826
 
3827 3827
             $resourceArray = $this->db->makeArray($result);
3828 3828
 
@@ -3927,12 +3927,12 @@  discard block
 block discarded – undo
3927 3927
             $tbldg = $this->getFullTableName("document_groups");
3928 3928
             $activeSql = $active == 1 ? "AND sc.published=1 AND sc.deleted=0" : "";
3929 3929
             // modify field names to use sc. table reference
3930
-            $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3930
+            $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3931 3931
             // get document groups for current user
3932 3932
             if ($docgrp = $this->getUserDocGroups()) {
3933 3933
                 $docgrp = implode(",", $docgrp);
3934 3934
             }
3935
-            $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3935
+            $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3936 3936
             $result = $this->db->select($fields, "{$tblsc} sc LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id='{$pageid}' {$activeSql}) AND ({$access})", "", 1);
3937 3937
             $pageInfo = $this->db->getRow($result);
3938 3938
 
@@ -3979,7 +3979,7 @@  discard block
 block discarded – undo
3979 3979
     {
3980 3980
         if ($this->currentSnippet) {
3981 3981
             $tbl = $this->getFullTableName("site_snippets");
3982
-            $rs = $this->db->select('id', $tbl, "name='" . $this->db->escape($this->currentSnippet) . "'", '', 1);
3982
+            $rs = $this->db->select('id', $tbl, "name='".$this->db->escape($this->currentSnippet)."'", '', 1);
3983 3983
             if ($snippetId = $this->db->getValue($rs)) {
3984 3984
                 return $snippetId;
3985 3985
             }
@@ -4006,23 +4006,23 @@  discard block
 block discarded – undo
4006 4006
      */
4007 4007
     public function clearCache($type = '', $report = false)
4008 4008
     {
4009
-        $cache_dir = MODX_BASE_PATH . $this->getCacheFolder();
4009
+        $cache_dir = MODX_BASE_PATH.$this->getCacheFolder();
4010 4010
         if (is_array($type)) {
4011 4011
             foreach ($type as $_) {
4012 4012
                 $this->clearCache($_, $report);
4013 4013
             }
4014 4014
         } elseif ($type == 'full') {
4015
-            include_once(MODX_MANAGER_PATH . 'processors/cache_sync.class.processor.php');
4015
+            include_once(MODX_MANAGER_PATH.'processors/cache_sync.class.processor.php');
4016 4016
             $sync = new synccache();
4017 4017
             $sync->setCachepath($cache_dir);
4018 4018
             $sync->setReport($report);
4019 4019
             $sync->emptyCache();
4020 4020
         } elseif (preg_match('@^[1-9][0-9]*$@', $type)) {
4021 4021
             $key = ($this->config['cache_type'] == 2) ? $this->makePageCacheKey($type) : $type;
4022
-            $file_name = "docid_" . $key . "_*.pageCache.php";
4023
-            $cache_path = $cache_dir . $file_name;
4022
+            $file_name = "docid_".$key."_*.pageCache.php";
4023
+            $cache_path = $cache_dir.$file_name;
4024 4024
             $files = glob($cache_path);
4025
-            $files[] = $cache_dir . "docid_" . $key . ".pageCache.php";
4025
+            $files[] = $cache_dir."docid_".$key.".pageCache.php";
4026 4026
             foreach ($files as $file) {
4027 4027
                 if (!is_file($file)) {
4028 4028
                     continue;
@@ -4030,7 +4030,7 @@  discard block
 block discarded – undo
4030 4030
                 unlink($file);
4031 4031
             }
4032 4032
         } else {
4033
-            $files = glob($cache_dir . '*');
4033
+            $files = glob($cache_dir.'*');
4034 4034
             foreach ($files as $file) {
4035 4035
                 $name = basename($file);
4036 4036
                 if (strpos($name, '.pageCache.php') === false) {
@@ -4099,7 +4099,7 @@  discard block
 block discarded – undo
4099 4099
                         $f_url_suffix = '/';
4100 4100
                     }
4101 4101
 
4102
-                    $alPath = !empty ($al['path']) ? $al['path'] . '/' : '';
4102
+                    $alPath = !empty ($al['path']) ? $al['path'].'/' : '';
4103 4103
 
4104 4104
                     if ($al && $al['alias']) {
4105 4105
                         $alias = $al['alias'];
@@ -4107,7 +4107,7 @@  discard block
 block discarded – undo
4107 4107
 
4108 4108
                 }
4109 4109
 
4110
-                $alias = $alPath . $f_url_prefix . $alias . $f_url_suffix;
4110
+                $alias = $alPath.$f_url_prefix.$alias.$f_url_suffix;
4111 4111
                 $url = "{$alias}{$args}";
4112 4112
             } else {
4113 4113
                 $url = "index.php?id={$id}{$args}";
@@ -4126,7 +4126,7 @@  discard block
 block discarded – undo
4126 4126
             }
4127 4127
 
4128 4128
             //TODO: check to make sure that $site_url incudes the url :port (e.g. :8080)
4129
-            $host = $scheme == 'full' ? $this->config['site_url'] : $scheme . '://' . $_SERVER['HTTP_HOST'] . $host;
4129
+            $host = $scheme == 'full' ? $this->config['site_url'] : $scheme.'://'.$_SERVER['HTTP_HOST'].$host;
4130 4130
         }
4131 4131
 
4132 4132
         //fix strictUrl by Bumkaka
@@ -4135,9 +4135,9 @@  discard block
 block discarded – undo
4135 4135
         }
4136 4136
 
4137 4137
         if ($this->config['xhtml_urls']) {
4138
-            $url = preg_replace("/&(?!amp;)/", "&amp;", $host . $virtualDir . $url);
4138
+            $url = preg_replace("/&(?!amp;)/", "&amp;", $host.$virtualDir.$url);
4139 4139
         } else {
4140
-            $url = $host . $virtualDir . $url;
4140
+            $url = $host.$virtualDir.$url;
4141 4141
         }
4142 4142
 
4143 4143
         $evtOut = $this->invokeEvent('OnMakeDocUrl', array(
@@ -4161,21 +4161,21 @@  discard block
 block discarded – undo
4161 4161
         if (isset($this->aliasListing[$id])) {
4162 4162
             $out = $this->aliasListing[$id];
4163 4163
         } else {
4164
-            $q = $this->db->query("SELECT id,alias,isfolder,parent FROM " . $this->getFullTableName("site_content") . " WHERE id=" . (int)$id);
4164
+            $q = $this->db->query("SELECT id,alias,isfolder,parent FROM ".$this->getFullTableName("site_content")." WHERE id=".(int) $id);
4165 4165
             if ($this->db->getRecordCount($q) == '1') {
4166 4166
                 $q = $this->db->getRow($q);
4167 4167
                 $this->aliasListing[$id] = array(
4168
-                    'id' => (int)$q['id'],
4168
+                    'id' => (int) $q['id'],
4169 4169
                     'alias' => $q['alias'] == '' ? $q['id'] : $q['alias'],
4170
-                    'parent' => (int)$q['parent'],
4171
-                    'isfolder' => (int)$q['isfolder'],
4170
+                    'parent' => (int) $q['parent'],
4171
+                    'isfolder' => (int) $q['isfolder'],
4172 4172
                 );
4173 4173
                 if ($this->aliasListing[$id]['parent'] > 0) {
4174 4174
                     //fix alias_path_usage
4175 4175
                     if ($this->config['use_alias_path'] == '1') {
4176 4176
                         //&& $tmp['path'] != '' - fix error slash with epty path
4177 4177
                         $tmp = $this->getAliasListing($this->aliasListing[$id]['parent']);
4178
-                        $this->aliasListing[$id]['path'] = $tmp['path'] . ($tmp['alias_visible'] ? (($tmp['parent'] > 0 && $tmp['path'] != '') ? '/' : '') . $tmp['alias'] : '');
4178
+                        $this->aliasListing[$id]['path'] = $tmp['path'].($tmp['alias_visible'] ? (($tmp['parent'] > 0 && $tmp['path'] != '') ? '/' : '').$tmp['alias'] : '');
4179 4179
                     } else {
4180 4180
                         $this->aliasListing[$id]['path'] = '';
4181 4181
                     }
@@ -4216,7 +4216,7 @@  discard block
 block discarded – undo
4216 4216
         $out = array();
4217 4217
         if (empty($this->version) || !is_array($this->version)) {
4218 4218
             //include for compatibility modx version < 1.0.10
4219
-            include MODX_MANAGER_PATH . "includes/version.inc.php";
4219
+            include MODX_MANAGER_PATH."includes/version.inc.php";
4220 4220
             $this->version = array();
4221 4221
             $this->version['version'] = isset($modx_version) ? $modx_version : '';
4222 4222
             $this->version['branch'] = isset($modx_branch) ? $modx_branch : '';
@@ -4238,18 +4238,18 @@  discard block
 block discarded – undo
4238 4238
     {
4239 4239
         if (isset ($this->snippetCache[$snippetName])) {
4240 4240
             $snippet = $this->snippetCache[$snippetName];
4241
-            $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : '';
4241
+            $properties = !empty($this->snippetCache[$snippetName."Props"]) ? $this->snippetCache[$snippetName."Props"] : '';
4242 4242
         } else { // not in cache so let's check the db
4243
-            $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->db->escape($snippetName) . "'  AND ss.disabled=0;";
4243
+            $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM ".$this->getFullTableName("site_snippets")." as ss LEFT JOIN ".$this->getFullTableName('site_modules')." as sm on sm.guid=ss.moduleguid WHERE ss.`name`='".$this->db->escape($snippetName)."'  AND ss.disabled=0;";
4244 4244
             $result = $this->db->query($sql);
4245 4245
             if ($this->db->getRecordCount($result) == 1) {
4246 4246
                 $row = $this->db->getRow($result);
4247 4247
                 $snippet = $this->snippetCache[$snippetName] = $row['snippet'];
4248 4248
                 $mergedProperties = array_merge($this->parseProperties($row['properties']), $this->parseProperties($row['sharedproperties']));
4249
-                $properties = $this->snippetCache[$snippetName . "Props"] = json_encode($mergedProperties);
4249
+                $properties = $this->snippetCache[$snippetName."Props"] = json_encode($mergedProperties);
4250 4250
             } else {
4251 4251
                 $snippet = $this->snippetCache[$snippetName] = "return false;";
4252
-                $properties = $this->snippetCache[$snippetName . "Props"] = '';
4252
+                $properties = $this->snippetCache[$snippetName."Props"] = '';
4253 4253
             }
4254 4254
         }
4255 4255
         // load default params/properties
@@ -4349,8 +4349,8 @@  discard block
 block discarded – undo
4349 4349
             }
4350 4350
             if (strpos($tpl, $s) !== false) {
4351 4351
                 $tpl = str_replace($s, $value, $tpl);
4352
-            } elseif($this->debug) {
4353
-                $this->addLog('parseText parse error', $_SERVER['REQUEST_URI'] . $s, 2);
4352
+            } elseif ($this->debug) {
4353
+                $this->addLog('parseText parse error', $_SERVER['REQUEST_URI'].$s, 2);
4354 4354
             }
4355 4355
         }
4356 4356
 
@@ -4399,7 +4399,7 @@  discard block
 block discarded – undo
4399 4399
             case 'CODE':
4400 4400
                 break;
4401 4401
             case 'FILE':
4402
-                $template = file_get_contents(MODX_BASE_PATH . $template);
4402
+                $template = file_get_contents(MODX_BASE_PATH.$template);
4403 4403
                 break;
4404 4404
             case 'CHUNK':
4405 4405
                 $template = $this->getChunk($template);
@@ -4432,7 +4432,7 @@  discard block
 block discarded – undo
4432 4432
         if ($mode !== 'formatOnly' && empty($timestamp)) {
4433 4433
             return '-';
4434 4434
         }
4435
-        $timestamp = (int)$timestamp;
4435
+        $timestamp = (int) $timestamp;
4436 4436
 
4437 4437
         switch ($this->config['datetime_format']) {
4438 4438
             case 'YYYY/mm/dd':
@@ -4452,7 +4452,7 @@  discard block
 block discarded – undo
4452 4452
         }
4453 4453
 
4454 4454
         if (empty($mode)) {
4455
-            $strTime = strftime($dateFormat . " %H:%M:%S", $timestamp);
4455
+            $strTime = strftime($dateFormat." %H:%M:%S", $timestamp);
4456 4456
         } elseif ($mode == 'dateOnly') {
4457 4457
             $strTime = strftime($dateFormat, $timestamp);
4458 4458
         } elseif ($mode == 'formatOnly') {
@@ -4506,7 +4506,7 @@  discard block
 block discarded – undo
4506 4506
             $S = 0;
4507 4507
         }
4508 4508
         $timeStamp = mktime($H, $M, $S, $m, $d, $Y);
4509
-        $timeStamp = (int)$timeStamp;
4509
+        $timeStamp = (int) $timeStamp;
4510 4510
         return $timeStamp;
4511 4511
     }
4512 4512
 
@@ -4548,7 +4548,7 @@  discard block
 block discarded – undo
4548 4548
                     if ($v === 'value') {
4549 4549
                         unset($_[$i]);
4550 4550
                     } else {
4551
-                        $_[$i] = 'tv.' . $v;
4551
+                        $_[$i] = 'tv.'.$v;
4552 4552
                     }
4553 4553
                 }
4554 4554
                 $fields = implode(',', $_);
@@ -4557,12 +4557,12 @@  discard block
 block discarded – undo
4557 4557
             }
4558 4558
 
4559 4559
             if ($tvsort != '') {
4560
-                $tvsort = 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $tvsort))));
4560
+                $tvsort = 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $tvsort))));
4561 4561
             }
4562 4562
             if ($tvidnames == "*") {
4563 4563
                 $query = "tv.id<>0";
4564 4564
             } else {
4565
-                $query = (is_numeric($tvidnames[0]) ? "tv.id" : "tv.name") . " IN ('" . implode("','", $tvidnames) . "')";
4565
+                $query = (is_numeric($tvidnames[0]) ? "tv.id" : "tv.name")." IN ('".implode("','", $tvidnames)."')";
4566 4566
             }
4567 4567
 
4568 4568
             $this->getUserDocGroups();
@@ -4706,7 +4706,7 @@  discard block
 block discarded – undo
4706 4706
             return $this->tmpCache[__FUNCTION__][$cacheKey];
4707 4707
         }
4708 4708
 
4709
-        if (($idnames != '*' && !is_array($idnames)) || empty($idnames) ) {
4709
+        if (($idnames != '*' && !is_array($idnames)) || empty($idnames)) {
4710 4710
             return false;
4711 4711
         } else {
4712 4712
 
@@ -4724,23 +4724,23 @@  discard block
 block discarded – undo
4724 4724
             }
4725 4725
 
4726 4726
             // get user defined template variables
4727
-            $fields = ($fields == '') ? 'tv.*' : 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $fields))));
4728
-            $sort = ($sort == '') ? '' : 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $sort))));
4727
+            $fields = ($fields == '') ? 'tv.*' : 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $fields))));
4728
+            $sort = ($sort == '') ? '' : 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $sort))));
4729 4729
 
4730 4730
             if ($idnames == '*') {
4731 4731
                 $query = 'tv.id<>0';
4732 4732
             } else {
4733
-                $query = (is_numeric($idnames[0]) ? 'tv.id' : 'tv.name') . " IN ('" . implode("','", $idnames) . "')";
4733
+                $query = (is_numeric($idnames[0]) ? 'tv.id' : 'tv.name')." IN ('".implode("','", $idnames)."')";
4734 4734
             }
4735 4735
 
4736
-            $rs = $this->db->select("{$fields}, IF(tvc.value != '', tvc.value, tv.default_text) as value", $this->getFullTableName('site_tmplvars') . " tv
4737
-                    INNER JOIN " . $this->getFullTableName('site_tmplvar_templates') . " tvtpl ON tvtpl.tmplvarid = tv.id
4738
-                    LEFT JOIN " . $this->getFullTableName('site_tmplvar_contentvalues') . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$docid}'", "{$query} AND tvtpl.templateid = '{$docRow['template']}'", ($sort ? "{$sort} {$dir}" : ""));
4736
+            $rs = $this->db->select("{$fields}, IF(tvc.value != '', tvc.value, tv.default_text) as value", $this->getFullTableName('site_tmplvars')." tv
4737
+                    INNER JOIN " . $this->getFullTableName('site_tmplvar_templates')." tvtpl ON tvtpl.tmplvarid = tv.id
4738
+                    LEFT JOIN " . $this->getFullTableName('site_tmplvar_contentvalues')." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$docid}'", "{$query} AND tvtpl.templateid = '{$docRow['template']}'", ($sort ? "{$sort} {$dir}" : ""));
4739 4739
 
4740 4740
             $result = $this->db->makeArray($rs);
4741 4741
 
4742 4742
             // get default/built-in template variables
4743
-            if(is_array($docRow)){
4743
+            if (is_array($docRow)) {
4744 4744
                 ksort($docRow);
4745 4745
 
4746 4746
                 foreach ($docRow as $key => $value) {
@@ -4778,22 +4778,22 @@  discard block
 block discarded – undo
4778 4778
      */
4779 4779
     public function getTemplateVarOutput($idnames = array(), $docid = '', $published = 1, $sep = '')
4780 4780
     {
4781
-        if (is_array($idnames) && empty($idnames) ) {
4781
+        if (is_array($idnames) && empty($idnames)) {
4782 4782
             return false;
4783 4783
         } else {
4784 4784
             $output = array();
4785 4785
             $vars = ($idnames == '*' || is_array($idnames)) ? $idnames : array($idnames);
4786 4786
 
4787
-            $docid = (int)$docid > 0 ? (int)$docid : $this->documentIdentifier;
4787
+            $docid = (int) $docid > 0 ? (int) $docid : $this->documentIdentifier;
4788 4788
             // remove sort for speed
4789 4789
             $result = $this->getTemplateVars($vars, '*', $docid, $published, '', '');
4790 4790
 
4791 4791
             if ($result == false) {
4792 4792
                 return false;
4793 4793
             } else {
4794
-                $baspath = MODX_MANAGER_PATH . 'includes';
4795
-                include_once $baspath . '/tmplvars.format.inc.php';
4796
-                include_once $baspath . '/tmplvars.commands.inc.php';
4794
+                $baspath = MODX_MANAGER_PATH.'includes';
4795
+                include_once $baspath.'/tmplvars.format.inc.php';
4796
+                include_once $baspath.'/tmplvars.commands.inc.php';
4797 4797
 
4798 4798
                 for ($i = 0; $i < count($result); $i++) {
4799 4799
                     $row = $result[$i];
@@ -4818,7 +4818,7 @@  discard block
 block discarded – undo
4818 4818
      */
4819 4819
     public function getFullTableName($tbl)
4820 4820
     {
4821
-        return $this->db->config['dbase'] . ".`" . $this->db->config['table_prefix'] . $tbl . "`";
4821
+        return $this->db->config['dbase'].".`".$this->db->config['table_prefix'].$tbl."`";
4822 4822
     }
4823 4823
 
4824 4824
     /**
@@ -4897,7 +4897,7 @@  discard block
 block discarded – undo
4897 4897
     public function getCachePath()
4898 4898
     {
4899 4899
         global $base_url;
4900
-        $pth = $base_url . $this->getCacheFolder();
4900
+        $pth = $base_url.$this->getCacheFolder();
4901 4901
         return $pth;
4902 4902
     }
4903 4903
 
@@ -4949,8 +4949,8 @@  discard block
 block discarded – undo
4949 4949
         $out = false;
4950 4950
 
4951 4951
         if (!empty($context)) {
4952
-            if (is_scalar($context) && isset($_SESSION[$context . 'Validated'])) {
4953
-                $out = $_SESSION[$context . 'InternalKey'];
4952
+            if (is_scalar($context) && isset($_SESSION[$context.'Validated'])) {
4953
+                $out = $_SESSION[$context.'InternalKey'];
4954 4954
             }
4955 4955
         } else {
4956 4956
             switch (true) {
@@ -4978,8 +4978,8 @@  discard block
 block discarded – undo
4978 4978
         $out = false;
4979 4979
 
4980 4980
         if (!empty($context)) {
4981
-            if (is_scalar($context) && isset($_SESSION[$context . 'Validated'])) {
4982
-                $out = $_SESSION[$context . 'Shortname'];
4981
+            if (is_scalar($context) && isset($_SESSION[$context.'Validated'])) {
4982
+                $out = $_SESSION[$context.'Shortname'];
4983 4983
             }
4984 4984
         } else {
4985 4985
             switch (true) {
@@ -5050,8 +5050,8 @@  discard block
 block discarded – undo
5050 5050
      */
5051 5051
     public function getWebUserInfo($uid)
5052 5052
     {
5053
-        $rs = $this->db->select('wu.username, wu.password, wua.*', $this->getFullTableName("web_users") . " wu
5054
-                INNER JOIN " . $this->getFullTableName("web_user_attributes") . " wua ON wua.internalkey=wu.id", "wu.id='{$uid}'");
5053
+        $rs = $this->db->select('wu.username, wu.password, wua.*', $this->getFullTableName("web_users")." wu
5054
+                INNER JOIN " . $this->getFullTableName("web_user_attributes")." wua ON wua.internalkey=wu.id", "wu.id='{$uid}'");
5055 5055
         if ($row = $this->db->getRow($rs)) {
5056 5056
             if (!isset($row['usertype']) or !$row["usertype"]) {
5057 5057
                 $row["usertype"] = "web";
@@ -5087,7 +5087,7 @@  discard block
 block discarded – undo
5087 5087
         } else if (is_array($dg)) {
5088 5088
             // resolve ids to names
5089 5089
             $dgn = array();
5090
-            $ds = $this->db->select('name', $this->getFullTableName("documentgroup_names"), "id IN (" . implode(",", $dg) . ")");
5090
+            $ds = $this->db->select('name', $this->getFullTableName("documentgroup_names"), "id IN (".implode(",", $dg).")");
5091 5091
             while ($row = $this->db->getRow($ds)) {
5092 5092
                 $dgn[] = $row['name'];
5093 5093
             }
@@ -5115,7 +5115,7 @@  discard block
 block discarded – undo
5115 5115
         $rt = false;
5116 5116
         if ($_SESSION["webValidated"] == 1) {
5117 5117
             $tbl = $this->getFullTableName("web_users");
5118
-            $ds = $this->db->select('id, username, password', $tbl, "id='" . $this->getLoginUserID() . "'");
5118
+            $ds = $this->db->select('id, username, password', $tbl, "id='".$this->getLoginUserID()."'");
5119 5119
             if ($row = $this->db->getRow($ds)) {
5120 5120
                 if ($row["password"] == md5($oldPwd)) {
5121 5121
                     if (strlen($newPwd) < 6) {
@@ -5125,7 +5125,7 @@  discard block
 block discarded – undo
5125 5125
                     } else {
5126 5126
                         $this->db->update(array(
5127 5127
                             'password' => $this->db->escape($newPwd),
5128
-                        ), $tbl, "id='" . $this->getLoginUserID() . "'");
5128
+                        ), $tbl, "id='".$this->getLoginUserID()."'");
5129 5129
                         // invoke OnWebChangePassword event
5130 5130
                         $this->invokeEvent("OnWebChangePassword", array(
5131 5131
                             "userid" => $row["id"],
@@ -5156,8 +5156,8 @@  discard block
 block discarded – undo
5156 5156
         // check cache
5157 5157
         $grpNames = isset ($_SESSION['webUserGroupNames']) ? $_SESSION['webUserGroupNames'] : false;
5158 5158
         if (!is_array($grpNames)) {
5159
-            $rs = $this->db->select('wgn.name', $this->getFullTableName("webgroup_names") . " wgn
5160
-                    INNER JOIN " . $this->getFullTableName("web_groups") . " wg ON wg.webgroup=wgn.id AND wg.webuser='" . $this->getLoginUserID() . "'");
5159
+            $rs = $this->db->select('wgn.name', $this->getFullTableName("webgroup_names")." wgn
5160
+                    INNER JOIN " . $this->getFullTableName("web_groups")." wg ON wg.webgroup=wgn.id AND wg.webuser='".$this->getLoginUserID()."'");
5161 5161
             $grpNames = $this->db->getColumn("name", $rs);
5162 5162
             // save to cache
5163 5163
             $_SESSION['webUserGroupNames'] = $grpNames;
@@ -5190,7 +5190,7 @@  discard block
 block discarded – undo
5190 5190
         if (strpos(strtolower($src), "<style") !== false || strpos(strtolower($src), "<link") !== false) {
5191 5191
             $this->sjscripts[$nextpos] = $src;
5192 5192
         } else {
5193
-            $this->sjscripts[$nextpos] = "\t" . '<link rel="stylesheet" type="text/css" href="' . $src . '" ' . ($media ? 'media="' . $media . '" ' : '') . '/>';
5193
+            $this->sjscripts[$nextpos] = "\t".'<link rel="stylesheet" type="text/css" href="'.$src.'" '.($media ? 'media="'.$media.'" ' : '').'/>';
5194 5194
         }
5195 5195
     }
5196 5196
 
@@ -5269,7 +5269,7 @@  discard block
 block discarded – undo
5269 5269
         }
5270 5270
 
5271 5271
         if ($useThisVer && $plaintext != true && (strpos(strtolower($src), "<script") === false)) {
5272
-            $src = "\t" . '<script type="text/javascript" src="' . $src . '"></script>';
5272
+            $src = "\t".'<script type="text/javascript" src="'.$src.'"></script>';
5273 5273
         }
5274 5274
         if ($startup) {
5275 5275
             $pos = isset($overwritepos) ? $overwritepos : max(array_merge(array(0), array_keys($this->sjscripts))) + 1;
@@ -5416,7 +5416,7 @@  discard block
 block discarded – undo
5416 5416
                 $eventtime = $this->getMicroTime() - $eventtime;
5417 5417
                 $this->pluginsCode .= sprintf('<fieldset><legend><b>%s / %s</b> (%2.2f ms)</legend>', $evtName, $pluginName, $eventtime * 1000);
5418 5418
                 foreach ($parameter as $k => $v) {
5419
-                    $this->pluginsCode .= "{$k} => " . print_r($v, true) . '<br>';
5419
+                    $this->pluginsCode .= "{$k} => ".print_r($v, true).'<br>';
5420 5420
                 }
5421 5421
                 $this->pluginsCode .= '</fieldset><br />';
5422 5422
                 $this->pluginsTime["{$evtName} / {$pluginName}"] += $eventtime;
@@ -5444,13 +5444,13 @@  discard block
 block discarded – undo
5444 5444
         $plugin = array();
5445 5445
         if (isset ($this->pluginCache[$pluginName])) {
5446 5446
             $pluginCode = $this->pluginCache[$pluginName];
5447
-            $pluginProperties = isset($this->pluginCache[$pluginName . "Props"]) ? $this->pluginCache[$pluginName . "Props"] : '';
5447
+            $pluginProperties = isset($this->pluginCache[$pluginName."Props"]) ? $this->pluginCache[$pluginName."Props"] : '';
5448 5448
         } else {
5449 5449
             $pluginName = $this->db->escape($pluginName);
5450 5450
             $result = $this->db->select('name, plugincode, properties', $this->getFullTableName("site_plugins"), "name='{$pluginName}' AND disabled=0");
5451 5451
             if ($row = $this->db->getRow($result)) {
5452 5452
                 $pluginCode = $this->pluginCache[$row['name']] = $row['plugincode'];
5453
-                $pluginProperties = $this->pluginCache[$row['name'] . "Props"] = $row['properties'];
5453
+                $pluginProperties = $this->pluginCache[$row['name']."Props"] = $row['properties'];
5454 5454
             } else {
5455 5455
                 $pluginCode = $this->pluginCache[$pluginName] = "return false;";
5456 5456
                 $pluginProperties = '';
@@ -5557,7 +5557,7 @@  discard block
 block discarded – undo
5557 5557
     public function parseDocBlockFromFile($element_dir, $filename, $escapeValues = false)
5558 5558
     {
5559 5559
         $params = array();
5560
-        $fullpath = $element_dir . '/' . $filename;
5560
+        $fullpath = $element_dir.'/'.$filename;
5561 5561
         if (is_readable($fullpath)) {
5562 5562
             $tpl = @fopen($fullpath, "r");
5563 5563
             if ($tpl) {
@@ -5724,8 +5724,8 @@  discard block
 block discarded – undo
5724 5724
         $ph = array('site_url' => MODX_SITE_URL);
5725 5725
         $regexUrl = "/((http|https|ftp|ftps)\:\/\/[^\/]+(\/[^\s]+[^,.?!:;\s])?)/";
5726 5726
         $regexEmail = '#([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)#i';
5727
-        $emailSubject = isset($parsed['name']) ? '?subject=' . $parsed['name'] : '';
5728
-        $emailSubject .= isset($parsed['version']) ? ' v' . $parsed['version'] : '';
5727
+        $emailSubject = isset($parsed['name']) ? '?subject='.$parsed['name'] : '';
5728
+        $emailSubject .= isset($parsed['version']) ? ' v'.$parsed['version'] : '';
5729 5729
         foreach ($parsed as $key => $val) {
5730 5730
             if (is_array($val)) {
5731 5731
                 foreach ($val as $key2 => $val2) {
@@ -5734,7 +5734,7 @@  discard block
 block discarded – undo
5734 5734
                         $val2 = preg_replace($regexUrl, "<a href=\"{$url[0]}\" target=\"_blank\">{$url[0]}</a> ", $val2);
5735 5735
                     }
5736 5736
                     if (preg_match($regexEmail, $val2, $url)) {
5737
-                        $val2 = preg_replace($regexEmail, '<a href="mailto:\\1' . $emailSubject . '">\\1</a>', $val2);
5737
+                        $val2 = preg_replace($regexEmail, '<a href="mailto:\\1'.$emailSubject.'">\\1</a>', $val2);
5738 5738
                     }
5739 5739
                     $parsed[$key][$key2] = $val2;
5740 5740
                 }
@@ -5744,7 +5744,7 @@  discard block
 block discarded – undo
5744 5744
                     $val = preg_replace($regexUrl, "<a href=\"{$url[0]}\" target=\"_blank\">{$url[0]}</a> ", $val);
5745 5745
                 }
5746 5746
                 if (preg_match($regexEmail, $val, $url)) {
5747
-                    $val = preg_replace($regexEmail, '<a href="mailto:\\1' . $emailSubject . '">\\1</a>', $val);
5747
+                    $val = preg_replace($regexEmail, '<a href="mailto:\\1'.$emailSubject.'">\\1</a>', $val);
5748 5748
                 }
5749 5749
                 $parsed[$key] = $val;
5750 5750
             }
@@ -5758,32 +5758,32 @@  discard block
 block discarded – undo
5758 5758
         );
5759 5759
 
5760 5760
         $nl = "\n";
5761
-        $list = isset($parsed['logo']) ? '<img src="' . $this->config['base_url'] . ltrim($parsed['logo'], "/") . '" style="float:right;max-width:100px;height:auto;" />' . $nl : '';
5762
-        $list .= '<p>' . $nl;
5763
-        $list .= isset($parsed['name']) ? '<strong>' . $parsed['name'] . '</strong><br/>' . $nl : '';
5764
-        $list .= isset($parsed['description']) ? $parsed['description'] . $nl : '';
5765
-        $list .= '</p><br/>' . $nl;
5766
-        $list .= isset($parsed['version']) ? '<p><strong>' . $_lang['version'] . ':</strong> ' . $parsed['version'] . '</p>' . $nl : '';
5767
-        $list .= isset($parsed['license']) ? '<p><strong>' . $_lang['license'] . ':</strong> ' . $parsed['license'] . '</p>' . $nl : '';
5768
-        $list .= isset($parsed['lastupdate']) ? '<p><strong>' . $_lang['last_update'] . ':</strong> ' . $parsed['lastupdate'] . '</p>' . $nl : '';
5769
-        $list .= '<br/>' . $nl;
5761
+        $list = isset($parsed['logo']) ? '<img src="'.$this->config['base_url'].ltrim($parsed['logo'], "/").'" style="float:right;max-width:100px;height:auto;" />'.$nl : '';
5762
+        $list .= '<p>'.$nl;
5763
+        $list .= isset($parsed['name']) ? '<strong>'.$parsed['name'].'</strong><br/>'.$nl : '';
5764
+        $list .= isset($parsed['description']) ? $parsed['description'].$nl : '';
5765
+        $list .= '</p><br/>'.$nl;
5766
+        $list .= isset($parsed['version']) ? '<p><strong>'.$_lang['version'].':</strong> '.$parsed['version'].'</p>'.$nl : '';
5767
+        $list .= isset($parsed['license']) ? '<p><strong>'.$_lang['license'].':</strong> '.$parsed['license'].'</p>'.$nl : '';
5768
+        $list .= isset($parsed['lastupdate']) ? '<p><strong>'.$_lang['last_update'].':</strong> '.$parsed['lastupdate'].'</p>'.$nl : '';
5769
+        $list .= '<br/>'.$nl;
5770 5770
         $first = true;
5771 5771
         foreach ($arrayParams as $param => $label) {
5772 5772
             if (isset($parsed[$param])) {
5773 5773
                 if ($first) {
5774
-                    $list .= '<p><strong>' . $_lang['references'] . '</strong></p>' . $nl;
5775
-                    $list .= '<ul class="docBlockList">' . $nl;
5774
+                    $list .= '<p><strong>'.$_lang['references'].'</strong></p>'.$nl;
5775
+                    $list .= '<ul class="docBlockList">'.$nl;
5776 5776
                     $first = false;
5777 5777
                 }
5778
-                $list .= '    <li><strong>' . $label . '</strong>' . $nl;
5779
-                $list .= '        <ul>' . $nl;
5778
+                $list .= '    <li><strong>'.$label.'</strong>'.$nl;
5779
+                $list .= '        <ul>'.$nl;
5780 5780
                 foreach ($parsed[$param] as $val) {
5781
-                    $list .= '            <li>' . $val . '</li>' . $nl;
5781
+                    $list .= '            <li>'.$val.'</li>'.$nl;
5782 5782
                 }
5783
-                $list .= '        </ul></li>' . $nl;
5783
+                $list .= '        </ul></li>'.$nl;
5784 5784
             }
5785 5785
         }
5786
-        $list .= !$first ? '</ul>' . $nl : '';
5786
+        $list .= !$first ? '</ul>'.$nl : '';
5787 5787
 
5788 5788
         return $list;
5789 5789
     }
@@ -5859,7 +5859,7 @@  discard block
 block discarded – undo
5859 5859
      */
5860 5860
     public function addSnippet($name, $phpCode)
5861 5861
     {
5862
-        $this->snippetCache['#' . $name] = $phpCode;
5862
+        $this->snippetCache['#'.$name] = $phpCode;
5863 5863
     }
5864 5864
 
5865 5865
     /**
@@ -5868,7 +5868,7 @@  discard block
 block discarded – undo
5868 5868
      */
5869 5869
     public function addChunk($name, $text)
5870 5870
     {
5871
-        $this->chunkCache['#' . $name] = $text;
5871
+        $this->chunkCache['#'.$name] = $text;
5872 5872
     }
5873 5873
 
5874 5874
     /**
@@ -5904,7 +5904,7 @@  discard block
 block discarded – undo
5904 5904
         }
5905 5905
 
5906 5906
         if (!$isSafe) {
5907
-            $msg = $phpcode . "\n" . $this->currentSnippet . "\n" . print_r($_SERVER, true);
5907
+            $msg = $phpcode."\n".$this->currentSnippet."\n".print_r($_SERVER, true);
5908 5908
             $title = sprintf('Unknown eval was executed (%s)', $this->htmlspecialchars(substr(trim($phpcode), 0, 50)));
5909 5909
             $this->messageQuit($title, '', true, '', '', 'Parser', $msg);
5910 5910
             return;
@@ -5918,7 +5918,7 @@  discard block
 block discarded – undo
5918 5918
             return 'array()';
5919 5919
         }
5920 5920
 
5921
-        $output = $echo . $return;
5921
+        $output = $echo.$return;
5922 5922
         modx_sanitize_gpc($output);
5923 5923
         return $this->htmlspecialchars($output); // Maybe, all html tags are dangerous
5924 5924
     }
@@ -5936,8 +5936,8 @@  discard block
 block discarded – undo
5936 5936
 
5937 5937
         $safe = explode(',', $safe_functions);
5938 5938
 
5939
-        $phpcode = rtrim($phpcode, ';') . ';';
5940
-        $tokens = token_get_all('<?php ' . $phpcode);
5939
+        $phpcode = rtrim($phpcode, ';').';';
5940
+        $tokens = token_get_all('<?php '.$phpcode);
5941 5941
         foreach ($tokens as $i => $token) {
5942 5942
             if (!is_array($token)) {
5943 5943
                 continue;
@@ -5973,7 +5973,7 @@  discard block
 block discarded – undo
5973 5973
     public function atBindFileContent($str = '')
5974 5974
     {
5975 5975
 
5976
-        $search_path = array('assets/tvs/', 'assets/chunks/', 'assets/templates/', $this->config['rb_base_url'] . 'files/', '');
5976
+        $search_path = array('assets/tvs/', 'assets/chunks/', 'assets/templates/', $this->config['rb_base_url'].'files/', '');
5977 5977
 
5978 5978
         if (stripos($str, '@FILE') !== 0) {
5979 5979
             return $str;
@@ -5996,7 +5996,7 @@  discard block
 block discarded – undo
5996 5996
         $errorMsg = sprintf("Could not retrieve string '%s'.", $str);
5997 5997
 
5998 5998
         foreach ($search_path as $path) {
5999
-            $file_path = MODX_BASE_PATH . $path . $str;
5999
+            $file_path = MODX_BASE_PATH.$path.$str;
6000 6000
             if (strpos($file_path, MODX_MANAGER_PATH) === 0) {
6001 6001
                 return $errorMsg;
6002 6002
             } elseif (is_file($file_path)) {
@@ -6010,7 +6010,7 @@  discard block
 block discarded – undo
6010 6010
             return $errorMsg;
6011 6011
         }
6012 6012
 
6013
-        $content = (string)file_get_contents($file_path);
6013
+        $content = (string) file_get_contents($file_path);
6014 6014
         if ($content === false) {
6015 6015
             return $errorMsg;
6016 6016
         }
@@ -6123,22 +6123,22 @@  discard block
 block discarded – undo
6123 6123
 
6124 6124
         $version = isset ($GLOBALS['modx_version']) ? $GLOBALS['modx_version'] : '';
6125 6125
         $release_date = isset ($GLOBALS['release_date']) ? $GLOBALS['release_date'] : '';
6126
-        $request_uri = "http://" . $_SERVER['HTTP_HOST'] . ($_SERVER["SERVER_PORT"] == 80 ? "" : (":" . $_SERVER["SERVER_PORT"])) . $_SERVER['REQUEST_URI'];
6126
+        $request_uri = "http://".$_SERVER['HTTP_HOST'].($_SERVER["SERVER_PORT"] == 80 ? "" : (":".$_SERVER["SERVER_PORT"])).$_SERVER['REQUEST_URI'];
6127 6127
         $request_uri = $this->htmlspecialchars($request_uri, ENT_QUOTES, $this->config['modx_charset']);
6128 6128
         $ua = $this->htmlspecialchars($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, $this->config['modx_charset']);
6129 6129
         $referer = $this->htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES, $this->config['modx_charset']);
6130 6130
         if ($is_error) {
6131 6131
             $str = '<h2 style="color:red">&laquo; Evo Parse Error &raquo;</h2>';
6132 6132
             if ($msg != 'PHP Parse Error') {
6133
-                $str .= '<h3 style="color:red">' . $msg . '</h3>';
6133
+                $str .= '<h3 style="color:red">'.$msg.'</h3>';
6134 6134
             }
6135 6135
         } else {
6136 6136
             $str = '<h2 style="color:#003399">&laquo; Evo Debug/ stop message &raquo;</h2>';
6137
-            $str .= '<h3 style="color:#003399">' . $msg . '</h3>';
6137
+            $str .= '<h3 style="color:#003399">'.$msg.'</h3>';
6138 6138
         }
6139 6139
 
6140 6140
         if (!empty ($query)) {
6141
-            $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">SQL &gt; <span id="sqlHolder">' . $query . '</span></div>';
6141
+            $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">SQL &gt; <span id="sqlHolder">'.$query.'</span></div>';
6142 6142
         }
6143 6143
 
6144 6144
         $errortype = array(
@@ -6161,13 +6161,13 @@  discard block
 block discarded – undo
6161 6161
 
6162 6162
         if (!empty($nr) || !empty($file)) {
6163 6163
             if ($text != '') {
6164
-                $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">Error : ' . $text . '</div>';
6164
+                $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">Error : '.$text.'</div>';
6165 6165
             }
6166 6166
             if ($output != '') {
6167
-                $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">' . $output . '</div>';
6167
+                $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">'.$output.'</div>';
6168 6168
             }
6169 6169
             if ($nr !== '') {
6170
-                $table[] = array('ErrorType[num]', $errortype [$nr] . "[" . $nr . "]");
6170
+                $table[] = array('ErrorType[num]', $errortype [$nr]."[".$nr."]");
6171 6171
             }
6172 6172
             if ($file) {
6173 6173
                 $table[] = array('File', $file);
@@ -6187,7 +6187,7 @@  discard block
 block discarded – undo
6187 6187
         }
6188 6188
 
6189 6189
         if (!empty($this->event->activePlugin)) {
6190
-            $table[] = array('Current Plugin', $this->event->activePlugin . '(' . $this->event->name . ')');
6190
+            $table[] = array('Current Plugin', $this->event->activePlugin.'('.$this->event->name.')');
6191 6191
         }
6192 6192
 
6193 6193
         $str .= $MakeTable->create($table, array('Error information', ''));
@@ -6197,17 +6197,17 @@  discard block
 block discarded – undo
6197 6197
         $table[] = array('REQUEST_URI', $request_uri);
6198 6198
 
6199 6199
         if ($this->manager->action) {
6200
-            include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
6200
+            include_once(MODX_MANAGER_PATH.'includes/actionlist.inc.php');
6201 6201
             global $action_list;
6202 6202
             $actionName = (isset($action_list[$this->manager->action])) ? " - {$action_list[$this->manager->action]}" : '';
6203 6203
 
6204
-            $table[] = array('Manager action', $this->manager->action . $actionName);
6204
+            $table[] = array('Manager action', $this->manager->action.$actionName);
6205 6205
         }
6206 6206
 
6207 6207
         if (preg_match('@^[0-9]+@', $this->documentIdentifier)) {
6208 6208
             $resource = $this->getDocumentObject('id', $this->documentIdentifier);
6209 6209
             $url = $this->makeUrl($this->documentIdentifier, '', '', 'full');
6210
-            $table[] = array('Resource', '[' . $this->documentIdentifier . '] <a href="' . $url . '" target="_blank">' . $resource['pagetitle'] . '</a>');
6210
+            $table[] = array('Resource', '['.$this->documentIdentifier.'] <a href="'.$url.'" target="_blank">'.$resource['pagetitle'].'</a>');
6211 6211
         }
6212 6212
         $table[] = array('Referer', $referer);
6213 6213
         $table[] = array('User Agent', $ua);
@@ -6228,7 +6228,7 @@  discard block
 block discarded – undo
6228 6228
 
6229 6229
         $mem = memory_get_peak_usage(true);
6230 6230
         $total_mem = $mem - $this->mstart;
6231
-        $total_mem = ($total_mem / 1024 / 1024) . ' mb';
6231
+        $total_mem = ($total_mem / 1024 / 1024).' mb';
6232 6232
 
6233 6233
         $queryTime = $this->queryTime;
6234 6234
         $phpTime = $totalTime - $queryTime;
@@ -6249,18 +6249,18 @@  discard block
 block discarded – undo
6249 6249
         $str .= $this->get_backtrace(debug_backtrace());
6250 6250
         // Log error
6251 6251
         if (!empty($this->currentSnippet)) {
6252
-            $source = 'Snippet - ' . $this->currentSnippet;
6252
+            $source = 'Snippet - '.$this->currentSnippet;
6253 6253
         } elseif (!empty($this->event->activePlugin)) {
6254
-            $source = 'Plugin - ' . $this->event->activePlugin;
6254
+            $source = 'Plugin - '.$this->event->activePlugin;
6255 6255
         } elseif ($source !== '') {
6256
-            $source = 'Parser - ' . $source;
6256
+            $source = 'Parser - '.$source;
6257 6257
         } elseif ($query !== '') {
6258 6258
             $source = 'SQL Query';
6259 6259
         } else {
6260 6260
             $source = 'Parser';
6261 6261
         }
6262 6262
         if ($msg) {
6263
-            $source .= ' / ' . $msg;
6263
+            $source .= ' / '.$msg;
6264 6264
         }
6265 6265
         if (isset($actionName) && !empty($actionName)) {
6266 6266
             $source .= $actionName;
@@ -6292,12 +6292,12 @@  discard block
 block discarded – undo
6292 6292
 
6293 6293
         // Display error
6294 6294
         if (isset($_SESSION['mgrValidated'])) {
6295
-            echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>EVO Content Manager ' . $version . ' &raquo; ' . $release_date . '</title>
6295
+            echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>EVO Content Manager '.$version.' &raquo; '.$release_date.'</title>
6296 6296
                  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6297
-                 <link rel="stylesheet" type="text/css" href="' . $this->config['site_manager_url'] . 'media/style/' . $this->config['manager_theme'] . '/style.css" />
6297
+                 <link rel="stylesheet" type="text/css" href="' . $this->config['site_manager_url'].'media/style/'.$this->config['manager_theme'].'/style.css" />
6298 6298
                  <style type="text/css">body { padding:10px; } td {font:inherit;}</style>
6299 6299
                  </head><body>
6300
-                 ' . $str . '</body></html>';
6300
+                 ' . $str.'</body></html>';
6301 6301
 
6302 6302
         } else {
6303 6303
             echo 'Error';
@@ -6335,7 +6335,7 @@  discard block
 block discarded – undo
6335 6335
             switch ($val['type']) {
6336 6336
                 case '->':
6337 6337
                 case '::':
6338
-                    $functionName = $val['function'] = $val['class'] . $val['type'] . $val['function'];
6338
+                    $functionName = $val['function'] = $val['class'].$val['type'].$val['function'];
6339 6339
                     break;
6340 6340
                 default:
6341 6341
                     $functionName = $val['function'];
@@ -6345,7 +6345,7 @@  discard block
 block discarded – undo
6345 6345
             $args = array_pad(array(), $_, '$var');
6346 6346
             $args = implode(", ", $args);
6347 6347
             $modx = &$this;
6348
-            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) {
6348
+            $args = preg_replace_callback('/\$var/', function() use ($modx, &$tmp, $val) {
6349 6349
                 $arg = $val['args'][$tmp - 1];
6350 6350
                 switch (true) {
6351 6351
                     case is_null($arg): {
@@ -6357,7 +6357,7 @@  discard block
 block discarded – undo
6357 6357
                         break;
6358 6358
                     }
6359 6359
                     case is_scalar($arg): {
6360
-                        $out = strlen($arg) > 20 ? 'string $var' . $tmp : ("'" . $this->htmlspecialchars(str_replace("'", "\\'", $arg)) . "'");
6360
+                        $out = strlen($arg) > 20 ? 'string $var'.$tmp : ("'".$this->htmlspecialchars(str_replace("'", "\\'", $arg))."'");
6361 6361
                         break;
6362 6362
                     }
6363 6363
                     case is_bool($arg): {
@@ -6365,23 +6365,23 @@  discard block
 block discarded – undo
6365 6365
                         break;
6366 6366
                     }
6367 6367
                     case is_array($arg): {
6368
-                        $out = 'array $var' . $tmp;
6368
+                        $out = 'array $var'.$tmp;
6369 6369
                         break;
6370 6370
                     }
6371 6371
                     case is_object($arg): {
6372
-                        $out = get_class($arg) . ' $var' . $tmp;
6372
+                        $out = get_class($arg).' $var'.$tmp;
6373 6373
                         break;
6374 6374
                     }
6375 6375
                     default: {
6376
-                        $out = '$var' . $tmp;
6376
+                        $out = '$var'.$tmp;
6377 6377
                     }
6378 6378
                 }
6379 6379
                 $tmp++;
6380 6380
                 return $out;
6381 6381
             }, $args);
6382 6382
             $line = array(
6383
-                "<strong>" . $functionName . "</strong>(" . $args . ")",
6384
-                $path . " on line " . $val['line']
6383
+                "<strong>".$functionName."</strong>(".$args.")",
6384
+                $path." on line ".$val['line']
6385 6385
             );
6386 6386
             $table[] = array(implode("<br />", $line));
6387 6387
         }
@@ -6422,7 +6422,7 @@  discard block
 block discarded – undo
6422 6422
             $alias = strip_tags($alias); // strip HTML
6423 6423
             $alias = preg_replace('/[^\.A-Za-z0-9 _-]/', '', $alias); // strip non-alphanumeric characters
6424 6424
             $alias = preg_replace('/\s+/', '-', $alias); // convert white-space to dash
6425
-            $alias = preg_replace('/-+/', '-', $alias);  // convert multiple dashes to one
6425
+            $alias = preg_replace('/-+/', '-', $alias); // convert multiple dashes to one
6426 6426
             $alias = trim($alias, '-'); // trim excess
6427 6427
             return $alias;
6428 6428
         }
@@ -6438,7 +6438,7 @@  discard block
 block discarded – undo
6438 6438
         $precisions = count($sizes) - 1;
6439 6439
         foreach ($sizes as $unit => $bytes) {
6440 6440
             if ($size >= $bytes) {
6441
-                return number_format($size / $bytes, $precisions) . ' ' . $unit;
6441
+                return number_format($size / $bytes, $precisions).' '.$unit;
6442 6442
             }
6443 6443
             $precisions--;
6444 6444
         }
@@ -6542,10 +6542,10 @@  discard block
 block discarded – undo
6542 6542
 
6543 6543
         if (strpos($str, MODX_MANAGER_PATH) === 0) {
6544 6544
             return false;
6545
-        } elseif (is_file(MODX_BASE_PATH . $str)) {
6546
-            $file_path = MODX_BASE_PATH . $str;
6547
-        } elseif (is_file(MODX_BASE_PATH . "{$tpl_dir}{$str}")) {
6548
-            $file_path = MODX_BASE_PATH . $tpl_dir . $str;
6545
+        } elseif (is_file(MODX_BASE_PATH.$str)) {
6546
+            $file_path = MODX_BASE_PATH.$str;
6547
+        } elseif (is_file(MODX_BASE_PATH."{$tpl_dir}{$str}")) {
6548
+            $file_path = MODX_BASE_PATH.$tpl_dir.$str;
6549 6549
         } else {
6550 6550
             return false;
6551 6551
         }
@@ -6671,7 +6671,7 @@  discard block
 block discarded – undo
6671 6671
             $title = 'no title';
6672 6672
         }
6673 6673
         if (is_array($msg)) {
6674
-            $msg = '<pre>' . print_r($msg, true) . '</pre>';
6674
+            $msg = '<pre>'.print_r($msg, true).'</pre>';
6675 6675
         } elseif ($msg === '') {
6676 6676
             $msg = $_SERVER['REQUEST_URI'];
6677 6677
         }
@@ -6716,7 +6716,7 @@  discard block
 block discarded – undo
6716 6716
         if (is_array($SystemAlertMsgQueque)) {
6717 6717
             $title = '';
6718 6718
             if ($this->name && $this->activePlugin) {
6719
-                $title = "<div><b>" . $this->activePlugin . "</b> - <span style='color:maroon;'>" . $this->name . "</span></div>";
6719
+                $title = "<div><b>".$this->activePlugin."</b> - <span style='color:maroon;'>".$this->name."</span></div>";
6720 6720
             }
6721 6721
             $SystemAlertMsgQueque[] = "$title<div style='margin-left:10px;margin-top:3px;'>$msg</div>";
6722 6722
         }
Please login to merge, or discard this patch.
Braces   +58 added lines, -27 removed lines patch added patch discarded remove patch
@@ -205,7 +205,9 @@  discard block
 block discarded – undo
205 205
         $this->q = self::_getCleanQueryString();
206 206
     }
207 207
 
208
-    final private function __clone() {}
208
+    final private function __clone()
209
+    {
210
+}
209 211
 
210 212
     /**
211 213
      * @return DocumentParser
@@ -721,13 +723,15 @@  discard block
 block discarded – undo
721 723
             $this->virtualDir = '';
722 724
         }
723 725
 
724
-        if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */
726
+        if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) {
727
+/* we got an ID returned, check to make sure it's not an alias */
725 728
             /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */
726 729
             if ($this->config['use_alias_path'] == 1) {
727 730
                 if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) {
728 731
                     $this->documentMethod = 'id';
729 732
                     return $q;
730
-                } else { /* not a valid id in terms of virtualDir, treat as alias */
733
+                } else {
734
+/* not a valid id in terms of virtualDir, treat as alias */
731 735
                     $this->documentMethod = 'alias';
732 736
                     return $q;
733 737
                 }
@@ -735,7 +739,8 @@  discard block
 block discarded – undo
735 739
                 $this->documentMethod = 'id';
736 740
                 return $q;
737 741
             }
738
-        } else { /* we didn't get an ID back, so instead we assume it's an alias */
742
+        } else {
743
+/* we didn't get an ID back, so instead we assume it's an alias */
739 744
             if ($this->config['friendly_alias_urls'] != 1) {
740 745
                 $q = $qOrig;
741 746
             }
@@ -765,13 +770,14 @@  discard block
 block discarded – undo
765 770
      * @param $id
766 771
      * @return array|mixed|null|string
767 772
      */
768
-    public function makePageCacheKey($id){
773
+    public function makePageCacheKey($id)
774
+    {
769 775
         $hash = $id;
770 776
         $tmp = null;
771 777
         $params = array();
772
-        if(!empty($this->systemCacheKey)){
778
+        if(!empty($this->systemCacheKey)) {
773 779
             $hash = $this->systemCacheKey;
774
-        }else {
780
+        } else {
775 781
             if (!empty($_GET)) {
776 782
                 // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID.
777 783
                 $params = $_GET;
@@ -780,7 +786,7 @@  discard block
 block discarded – undo
780 786
             }
781 787
         }
782 788
         $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params));
783
-        if (is_array($evtOut) && count($evtOut) > 0){
789
+        if (is_array($evtOut) && count($evtOut) > 0) {
784 790
             $tmp = array_pop($evtOut);
785 791
         }
786 792
         return empty($tmp) ? $hash : $tmp;
@@ -1191,10 +1197,18 @@  discard block
 block discarded – undo
1191 1197
             return array();
1192 1198
         }
1193 1199
         $spacer = md5('<<<EVO>>>');
1194
-        if($left==='{{' && strpos($content,';}}')!==false)  $content = str_replace(';}}', sprintf(';}%s}',   $spacer),$content);
1195
-        if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content);
1196
-        if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]',  $spacer),$content);
1197
-        if($left==='[[' && strpos($content,']]]')!==false)  $content = str_replace(']]]', sprintf(']%s]]',   $spacer),$content);
1200
+        if($left==='{{' && strpos($content,';}}')!==false) {
1201
+            $content = str_replace(';}}', sprintf(';}%s}',   $spacer),$content);
1202
+        }
1203
+        if($left==='{{' && strpos($content,'{{}}')!==false) {
1204
+            $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content);
1205
+        }
1206
+        if($left==='[[' && strpos($content,']]]]')!==false) {
1207
+            $content = str_replace(']]]]',sprintf(']]%s]]',  $spacer),$content);
1208
+        }
1209
+        if($left==='[[' && strpos($content,']]]')!==false) {
1210
+            $content = str_replace(']]]', sprintf(']%s]]',   $spacer),$content);
1211
+        }
1198 1212
 
1199 1213
         $pos['<![CDATA['] = strpos($content, '<![CDATA[');
1200 1214
         $pos[']]>'] = strpos($content, ']]>');
@@ -1247,7 +1261,8 @@  discard block
 block discarded – undo
1247 1261
                         }
1248 1262
                     }
1249 1263
 
1250
-                    if (!in_array($fetch, $tags)) {  // Avoid double Matches
1264
+                    if (!in_array($fetch, $tags)) {
1265
+// Avoid double Matches
1251 1266
                         $tags[] = $fetch; // Fetch
1252 1267
                     };
1253 1268
                     $fetch = ''; // and reset
@@ -1265,7 +1280,9 @@  discard block
 block discarded – undo
1265 1280
             }
1266 1281
         }
1267 1282
         foreach($tags as $i=>$tag) {
1268
-            if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag);
1283
+            if(strpos($tag,$spacer)!==false) {
1284
+                $tags[$i] = str_replace($spacer, '', $tag);
1285
+            }
1269 1286
         }
1270 1287
         return $tags;
1271 1288
     }
@@ -1305,7 +1322,10 @@  discard block
 block discarded – undo
1305 1322
         }
1306 1323
 
1307 1324
         foreach ($matches[1] as $i => $key) {
1308
-            if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1325
+            if(strpos($key,'[+')!==false) {
1326
+                continue;
1327
+            }
1328
+            // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1309 1329
             if (substr($key, 0, 1) == '#') {
1310 1330
                 $key = substr($key, 1);
1311 1331
             } // remove # for QuickEdit format
@@ -2030,7 +2050,8 @@  discard block
 block discarded – undo
2030 2050
      * @return mixed|string
2031 2051
      */
2032 2052
     public function _getSGVar($value)
2033
-    { // Get super globals
2053
+    {
2054
+// Get super globals
2034 2055
         $key = $value;
2035 2056
         $_ = $this->config['enable_filter'];
2036 2057
         $this->config['enable_filter'] = 1;
@@ -2434,7 +2455,8 @@  discard block
 block discarded – undo
2434 2455
         if ($this->config['friendly_urls'] == 1) {
2435 2456
             $aliases = array();
2436 2457
             if (is_array($this->documentListing)) {
2437
-                foreach ($this->documentListing as $path => $docid) { // This is big Loop on large site!
2458
+                foreach ($this->documentListing as $path => $docid) {
2459
+// This is big Loop on large site!
2438 2460
                     $aliases[$docid] = $path;
2439 2461
                     $isfolder[$docid] = $this->aliasListing[$docid]['isfolder'];
2440 2462
                 }
@@ -2467,7 +2489,7 @@  discard block
 block discarded – undo
2467 2489
             $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0);
2468 2490
             $pref = $this->config['friendly_url_prefix'];
2469 2491
             $suff = $this->config['friendly_url_suffix'];
2470
-            $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) {
2492
+            $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff){
2471 2493
                 $modx = DocumentParser::getInstance();
2472 2494
                 $thealias = $aliases[$m[1]];
2473 2495
                 $thefolder = $isfolder[$m[1]];
@@ -4239,7 +4261,8 @@  discard block
 block discarded – undo
4239 4261
         if (isset ($this->snippetCache[$snippetName])) {
4240 4262
             $snippet = $this->snippetCache[$snippetName];
4241 4263
             $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : '';
4242
-        } else { // not in cache so let's check the db
4264
+        } else {
4265
+// not in cache so let's check the db
4243 4266
             $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->db->escape($snippetName) . "'  AND ss.disabled=0;";
4244 4267
             $result = $this->db->query($sql);
4245 4268
             if ($this->db->getRecordCount($result) == 1) {
@@ -4740,7 +4763,7 @@  discard block
 block discarded – undo
4740 4763
             $result = $this->db->makeArray($rs);
4741 4764
 
4742 4765
             // get default/built-in template variables
4743
-            if(is_array($docRow)){
4766
+            if(is_array($docRow)) {
4744 4767
                 ksort($docRow);
4745 4768
 
4746 4769
                 foreach ($docRow as $key => $value) {
@@ -5219,12 +5242,16 @@  discard block
 block discarded – undo
5219 5242
             return '';
5220 5243
         } // nothing to register
5221 5244
         if (!is_array($options)) {
5222
-            if (is_bool($options))  // backward compatibility with old plaintext parameter
5245
+            if (is_bool($options)) {
5246
+                // backward compatibility with old plaintext parameter
5223 5247
             {
5224 5248
                 $options = array('plaintext' => $options);
5225
-            } elseif (is_string($options)) // Also allow script name as 2nd param
5249
+            }
5250
+            } elseif (is_string($options)) {
5251
+                // Also allow script name as 2nd param
5226 5252
             {
5227 5253
                 $options = array('name' => $options);
5254
+            }
5228 5255
             } else {
5229 5256
                 $options = array();
5230 5257
             }
@@ -5236,7 +5263,8 @@  discard block
 block discarded – undo
5236 5263
         unset($overwritepos); // probably unnecessary--just making sure
5237 5264
 
5238 5265
         $useThisVer = true;
5239
-        if (isset($this->loadedjscripts[$key])) { // a matching script was found
5266
+        if (isset($this->loadedjscripts[$key])) {
5267
+// a matching script was found
5240 5268
             // if existing script is a startup script, make sure the candidate is also a startup script
5241 5269
             if ($this->loadedjscripts[$key]['startup']) {
5242 5270
                 $startup = true;
@@ -5256,7 +5284,8 @@  discard block
 block discarded – undo
5256 5284
                     // overwrite the old script (the position may be important for dependent scripts)
5257 5285
                     $overwritepos = $this->loadedjscripts[$key]['pos'];
5258 5286
                 }
5259
-            } else { // Use the original version
5287
+            } else {
5288
+// Use the original version
5260 5289
                 if ($startup == true && $this->loadedjscripts[$key]['startup'] == false) {
5261 5290
                     // need to move the exisiting script to the head
5262 5291
                     $version = $this->loadedjscripts[$key][$version];
@@ -5381,7 +5410,8 @@  discard block
 block discarded – undo
5381 5410
         }
5382 5411
 
5383 5412
         $results = null;
5384
-        foreach ($this->pluginEvent[$evtName] as $pluginName) { // start for loop
5413
+        foreach ($this->pluginEvent[$evtName] as $pluginName) {
5414
+// start for loop
5385 5415
             if ($this->dumpPlugins) {
5386 5416
                 $eventtime = $this->getMicroTime();
5387 5417
             }
@@ -5929,7 +5959,8 @@  discard block
 block discarded – undo
5929 5959
      * @return bool
5930 5960
      */
5931 5961
     public function isSafeCode($phpcode = '', $safe_functions = '')
5932
-    { // return true or false
5962
+    {
5963
+// return true or false
5933 5964
         if ($safe_functions == '') {
5934 5965
             return false;
5935 5966
         }
@@ -6345,7 +6376,7 @@  discard block
 block discarded – undo
6345 6376
             $args = array_pad(array(), $_, '$var');
6346 6377
             $args = implode(", ", $args);
6347 6378
             $modx = &$this;
6348
-            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) {
6379
+            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val){
6349 6380
                 $arg = $val['args'][$tmp - 1];
6350 6381
                 switch (true) {
6351 6382
                     case is_null($arg): {
Please login to merge, or discard this patch.
manager/includes/extenders/dbapi.mysql.class.inc.php 1 patch
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -414,6 +414,9 @@  discard block
 block discarded – undo
414 414
         }
415 415
     }
416 416
 
417
+    /**
418
+     * @param string $table
419
+     */
417 420
     public function save($fields, $table, $where = '')
418 421
     {
419 422
 
@@ -444,6 +447,7 @@  discard block
 block discarded – undo
444 447
     /**
445 448
      * @name:  freeResult
446 449
      *
450
+     * @param mysqli_result $rs
447 451
      */
448 452
     public function freeResult($rs)
449 453
     {
@@ -554,6 +558,7 @@  discard block
 block discarded – undo
554 558
      * @name:  getColumn
555 559
      * @desc:  returns an array of the values found on colun $name
556 560
      * @param: $dsq - dataset or query string
561
+     * @param string $name
557 562
      */
558 563
     public function getColumn($name, $dsq)
559 564
     {
@@ -720,6 +725,9 @@  discard block
 block discarded – undo
720 725
         return $result;
721 726
     }
722 727
 
728
+    /**
729
+     * @param string $table_name
730
+     */
723 731
     public function optimize($table_name)
724 732
     {
725 733
         $rs = $this->query("OPTIMIZE TABLE {$table_name}");
@@ -730,6 +738,9 @@  discard block
 block discarded – undo
730 738
         return $rs;
731 739
     }
732 740
 
741
+    /**
742
+     * @param string $table_name
743
+     */
733 744
     public function truncate($table_name)
734 745
     {
735 746
         $rs = $this->query("TRUNCATE {$table_name}");
Please login to merge, or discard this patch.
manager/includes/extenders/dbapi.mysqli.class.inc.php 2 patches
Doc Comments   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
     }
241 241
 
242 242
     /**
243
-     * @param string|array $fields
244
-     * @param string|array $from
245
-     * @param string|array $where
243
+     * @param string $fields
244
+     * @param string $from
245
+     * @param string $where
246 246
      * @param string $orderBy
247 247
      * @param string $limit
248 248
      * @return bool|mysqli_result
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
      * @param string $fromtable
327 327
      * @param string $where
328 328
      * @param string $limit
329
-     * @return mixed
329
+     * @return null|integer
330 330
      */
331 331
     public function insert($fields, $intotable, $fromfields = "*", $fromtable = "", $where = "", $limit = "")
332 332
     {
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 
369 369
     /**
370 370
      * @param $fields
371
-     * @param $table
371
+     * @param string $table
372 372
      * @param string $where
373 373
      * @return bool|mixed|mysqli_result
374 374
      */
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 
436 436
     /**
437 437
      * @param null|mysqli $conn
438
-     * @return mixed
438
+     * @return integer
439 439
      */
440 440
     public function getInsertId($conn = null)
441 441
     {
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
     }
514 514
 
515 515
     /**
516
-     * @param $name
516
+     * @param string $name
517 517
      * @param mysqli_result|string $dsq
518 518
      * @return array
519 519
      */
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
     /**
574 574
      * @param string $table
575
-     * @return array
575
+     * @return boolean
576 576
      */
577 577
     public function getTableMetaData($table)
578 578
     {
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
     }
620 620
 
621 621
     /**
622
-     * @param string|mysqli_result $rs
622
+     * @param string $rs
623 623
      * @param bool $index
624 624
      * @return array
625 625
      */
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         $pre = null,
31 31
         $charset = '',
32 32
         $connection_method = 'SET CHARACTER SET'
33
-    ) {
33
+    ){
34 34
         $this->config['host'] = $host ? $host : $GLOBALS['database_server'];
35 35
         $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase'];
36 36
         $this->config['user'] = $uid ? $uid : $GLOBALS['database_user'];
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         $ua = $modx->htmlspecialchars($_SERVER['HTTP_USER_AGENT']);
71 71
                         $referer = $modx->htmlspecialchars($_SERVER['HTTP_REFERER']);
72 72
                         $modx->sendmail(array(
73
-                            'subject' => 'Missing to create the database connection! from ' . $modx->config['site_name'],
73
+                            'subject' => 'Missing to create the database connection! from '.$modx->config['site_name'],
74 74
                             'body'    => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}",
75 75
                             'type'    => 'text'
76 76
                         ));
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
             $tend = $modx->getMicroTime();
86 86
             $totaltime = $tend - $tstart;
87 87
             if ($modx->dumpSQL) {
88
-                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s",
89
-                        $totaltime) . "</fieldset><br />";
88
+                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s",
89
+                        $totaltime)."</fieldset><br />";
90 90
             }
91 91
             $this->conn->set_charset($this->config['charset']);
92 92
             $this->isConnected = true;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         if (1000 < $safeCount) {
120 120
             exit("Too many loops '{$safeCount}'");
121 121
         }
122
-        if ( ! ($this->conn instanceof mysqli)) {
122
+        if (!($this->conn instanceof mysqli)) {
123 123
             $this->connect();
124 124
         }
125 125
         if (is_array($s)) {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     public function query($sql, $watchError = true)
146 146
     {
147 147
         $modx = DocumentParser::getInstance();
148
-        if ( ! ($this->conn instanceof mysqli)) {
148
+        if (!($this->conn instanceof mysqli)) {
149 149
             $this->connect();
150 150
         }
151 151
         $tStart = $modx->getMicroTime();
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                 case 1091:
166 166
                     break;
167 167
                 default:
168
-                    $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql);
168
+                    $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql);
169 169
             }
170 170
         } else {
171 171
             $tend = $modx->getMicroTime();
@@ -179,24 +179,24 @@  discard block
 block discarded – undo
179 179
                     $debug_path[] = $line['function'];
180 180
                 }
181 181
                 $debug_path = implode(' > ', array_reverse($debug_path));
182
-                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms",
183
-                        $totalTime * 1000) . "</legend>";
184
-                $modx->queryCode .= $sql . '<br><br>';
182
+                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms",
183
+                        $totalTime * 1000)."</legend>";
184
+                $modx->queryCode .= $sql.'<br><br>';
185 185
                 if ($modx->event->name) {
186
-                    $modx->queryCode .= 'Current Event  => ' . $modx->event->name . '<br>';
186
+                    $modx->queryCode .= 'Current Event  => '.$modx->event->name.'<br>';
187 187
                 }
188 188
                 if ($modx->event->activePlugin) {
189
-                    $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>';
189
+                    $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>';
190 190
                 }
191 191
                 if ($modx->currentSnippet) {
192
-                    $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>';
192
+                    $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>';
193 193
                 }
194 194
                 if (stripos($sql, 'select') === 0) {
195
-                    $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>';
195
+                    $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>';
196 196
                 } else {
197
-                    $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>';
197
+                    $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>';
198 198
                 }
199
-                $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>';
199
+                $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>';
200 200
                 $modx->queryCode .= "</fieldset><br />";
201 201
             }
202 202
             $modx->executedQueries++;
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
                     if ($value === null || strtolower($value) === 'null') {
304 304
                         $f = 'NULL';
305 305
                     } else {
306
-                        $f = "'" . $value . "'";
306
+                        $f = "'".$value."'";
307 307
                     }
308
-                    $fields[$key] = "`{$key}` = " . $f;
308
+                    $fields[$key] = "`{$key}` = ".$f;
309 309
                 }
310 310
                 $fields = implode(',', $fields);
311 311
             }
@@ -340,12 +340,12 @@  discard block
 block discarded – undo
340 340
                 $this->query("INSERT INTO {$intotable} {$fields}");
341 341
             } else {
342 342
                 if (empty($fromtable)) {
343
-                    $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '",
344
-                            array_values($fields)) . "')";
343
+                    $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '",
344
+                            array_values($fields))."')";
345 345
                     $this->query("INSERT INTO {$intotable} {$fields}");
346 346
                 } else {
347 347
                     $fromtable = $this->replaceFullTableName($fromtable);
348
-                    $fields = "(" . implode(",", array_keys($fields)) . ")";
348
+                    $fields = "(".implode(",", array_keys($fields)).")";
349 349
                     $where = trim($where);
350 350
                     $limit = trim($limit);
351 351
                     if ($where !== '' && stripos($where, 'WHERE') !== 0) {
@@ -439,8 +439,8 @@  discard block
 block discarded – undo
439 439
      */
440 440
     public function getInsertId($conn = null)
441 441
     {
442
-        if (! ($conn instanceof mysqli)) {
443
-            $conn =& $this->conn;
442
+        if (!($conn instanceof mysqli)) {
443
+            $conn = & $this->conn;
444 444
         }
445 445
 
446 446
         return $conn->insert_id;
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
      */
453 453
     public function getAffectedRows($conn = null)
454 454
     {
455
-        if (! ($conn instanceof mysqli)) {
456
-            $conn =& $this->conn;
455
+        if (!($conn instanceof mysqli)) {
456
+            $conn = & $this->conn;
457 457
         }
458 458
 
459 459
         return $conn->affected_rows;
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
      */
466 466
     public function getLastError($conn = null)
467 467
     {
468
-        if (! ($conn instanceof mysqli)) {
469
-            $conn =& $this->conn;
468
+        if (!($conn instanceof mysqli)) {
469
+            $conn = & $this->conn;
470 470
         }
471 471
 
472 472
         return $conn->error;
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
     {
491 491
         $out = false;
492 492
         if ($ds instanceof mysqli_result) {
493
-            switch($mode){
493
+            switch ($mode) {
494 494
                 case 'assoc':
495 495
                     $out = $ds->fetch_assoc();
496 496
                     break;
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
     public function getColumn($name, $dsq)
521 521
     {
522 522
         $col = array();
523
-        if ( ! ($dsq instanceof mysqli_result)) {
523
+        if (!($dsq instanceof mysqli_result)) {
524 524
             $dsq = $this->query($dsq);
525 525
         }
526 526
         if ($dsq) {
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
     public function getColumnNames($dsq)
540 540
     {
541 541
         $names = array();
542
-        if ( ! ($dsq instanceof mysqli_result)) {
542
+        if (!($dsq instanceof mysqli_result)) {
543 543
             $dsq = $this->query($dsq);
544 544
         }
545 545
         if ($dsq) {
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
     public function getValue($dsq)
560 560
     {
561 561
         $out = false;
562
-        if ( ! ($dsq instanceof mysqli_result)) {
562
+        if (!($dsq instanceof mysqli_result)) {
563 563
             $dsq = $this->query($dsq);
564 564
         }
565 565
         if ($dsq) {
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
         $tableName = trim($tableName);
658 658
         $dbase = trim($this->config['dbase'], '`');
659 659
         $prefix = $this->config['table_prefix'];
660
-        if ((bool)$force === true) {
660
+        if ((bool) $force === true) {
661 661
             $result = "`{$dbase}`.`{$prefix}{$tableName}`";
662 662
         } elseif (strpos($tableName, '[+prefix+]') !== false) {
663 663
             $result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $tableName);
Please login to merge, or discard this patch.
manager/includes/extenders/deprecated.functions.inc.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
      * @deprecated
73 73
      *
74 74
      * @param $rs
75
-     * @return int|mixed
75
+     * @return integer
76 76
      */
77 77
     public function insertId($rs)
78 78
     {
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,8 @@
 block discarded – undo
177 177
      * @return bool|string
178 178
      */
179 179
     public function putChunk($chunkName)
180
-    { // alias name >.<
180
+    {
181
+// alias name >.<
181 182
         $modx = DocumentParser::getInstance();
182 183
 
183 184
         return $modx->getChunk($chunkName);
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers.class.inc.php 3 patches
Doc Comments   +27 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     /**
95 95
      * @param string $mode
96 96
      * @param string $modifiers
97
-     * @return bool|string
97
+     * @return false|string
98 98
      */
99 99
     public function _getDelim($mode,$modifiers) {
100 100
         $c = substr($modifiers,0,1);
@@ -131,6 +131,14 @@  discard block
 block discarded – undo
131 131
             return $opt;
132 132
         }
133 133
     }
134
+
135
+    /**
136
+     * @param string $mode
137
+     * @param false|string $delim
138
+     * @param string $modifiers
139
+     *
140
+     * @return string
141
+     */
134 142
     public function _getRemainModifiers($mode,$delim,$modifiers) {
135 143
         if($delim) {
136 144
             if($mode=='(')
@@ -158,6 +166,9 @@  discard block
 block discarded – undo
158 166
         return substr($string,strpos($string, $delim)+$len);
159 167
     }
160 168
 
169
+    /**
170
+     * @param string $modifiers
171
+     */
161 172
     public function splitEachModifiers($modifiers) {
162 173
         $modx = DocumentParser::getInstance();
163 174
 
@@ -227,6 +238,10 @@  discard block
 block discarded – undo
227 238
         return $result;
228 239
     }
229 240
 
241
+    /**
242
+     * @param string $key
243
+     * @param string $value
244
+     */
230 245
     public function parsePhx($key,$value,$modifiers)
231 246
     {
232 247
         $modx = DocumentParser::getInstance();
@@ -293,6 +308,10 @@  discard block
 block discarded – undo
293 308
         else                  return true;
294 309
     }
295 310
 
311
+    /**
312
+     * @param string $cmd
313
+     * @param string $opt
314
+     */
296 315
     public function getValueFromPreset($key, $value, $cmd, $opt)
297 316
     {
298 317
         $modx = DocumentParser::getInstance();
@@ -978,6 +997,9 @@  discard block
 block discarded – undo
978 997
         return $value;
979 998
     }
980 999
 
1000
+    /**
1001
+     * @param string $cmd
1002
+     */
981 1003
     public function includeMdfFile($cmd) {
982 1004
         $modx = DocumentParser::getInstance();
983 1005
         $key = $this->key;
@@ -1133,6 +1155,10 @@  discard block
 block discarded – undo
1133 1155
     }
1134 1156
 
1135 1157
     // Sets a placeholder variable which can only be access by Modifiers
1158
+
1159
+    /**
1160
+     * @param string $value
1161
+     */
1136 1162
     public function setModifiersVariable($key, $value) {
1137 1163
         if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1138 1164
     }
Please login to merge, or discard this patch.
Spacing   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
3
+if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
4 4
 
5
-class MODIFIERS {
5
+class MODIFIERS{
6 6
     /**
7 7
      * @var array
8 8
      */
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
      * @param string $modifiers
71 71
      * @return bool|mixed|string
72 72
      */
73
-    public function phxFilter($key,$value,$modifiers)
73
+    public function phxFilter($key, $value, $modifiers)
74 74
     {
75 75
         $modx = DocumentParser::getInstance();
76
-        if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value);
76
+        if (substr($modifiers, 0, 3) !== 'id(') $value = $this->parseDocumentSource($value);
77 77
         $this->srcValue = $value;
78 78
         $modifiers = trim($modifiers);
79
-        $modifiers = ':'.trim($modifiers,':');
80
-        $modifiers = str_replace(array("\r\n","\r"), "\n", $modifiers);
79
+        $modifiers = ':'.trim($modifiers, ':');
80
+        $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers);
81 81
         $modifiers = $this->splitEachModifiers($modifiers);
82 82
 
83 83
         $this->placeholders = array();
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
         $this->placeholders['dummy'] = '';
86 86
         $this->condition = array();
87 87
         $this->vars = array();
88
-        $this->vars['name']    = & $key;
89
-        $value = $this->parsePhx($key,$value,$modifiers);
88
+        $this->vars['name'] = & $key;
89
+        $value = $this->parsePhx($key, $value, $modifiers);
90 90
         $this->vars = array();
91 91
         return $value;
92 92
     }
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
      * @param string $modifiers
97 97
      * @return bool|string
98 98
      */
99
-    public function _getDelim($mode,$modifiers) {
100
-        $c = substr($modifiers,0,1);
101
-        if(!in_array($c, array('"', "'", '`')) ) return false;
99
+    public function _getDelim($mode, $modifiers){
100
+        $c = substr($modifiers, 0, 1);
101
+        if (!in_array($c, array('"', "'", '`'))) return false;
102 102
 
103
-        $modifiers = substr($modifiers,1);
104
-        $closure = $mode=='(' ? "{$c})" : $c;
105
-        if(strpos($modifiers, $closure)===false) return false;
103
+        $modifiers = substr($modifiers, 1);
104
+        $closure = $mode == '(' ? "{$c})" : $c;
105
+        if (strpos($modifiers, $closure) === false) return false;
106 106
 
107 107
         return  $c;
108 108
     }
@@ -113,101 +113,101 @@  discard block
 block discarded – undo
113 113
      * @param string $modifiers
114 114
      * @return bool|string
115 115
      */
116
-    public function _getOpt($mode,$delim,$modifiers) {
117
-        if($delim) {
118
-            if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
116
+    public function _getOpt($mode, $delim, $modifiers){
117
+        if ($delim) {
118
+            if ($mode == '(') return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1);
119 119
 
120
-            return substr($modifiers,1,strpos($modifiers,$delim,1)-1);
120
+            return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1);
121 121
         }
122 122
         else {
123
-            if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') );
123
+            if ($mode == '(') return substr($modifiers, 0, strpos($modifiers, ')'));
124 124
 
125 125
             $chars = str_split($modifiers);
126
-            $opt='';
127
-            foreach($chars as $c) {
128
-                if($c==':' || $c==')') break;
129
-                $opt .=$c;
126
+            $opt = '';
127
+            foreach ($chars as $c) {
128
+                if ($c == ':' || $c == ')') break;
129
+                $opt .= $c;
130 130
             }
131 131
             return $opt;
132 132
         }
133 133
     }
134
-    public function _getRemainModifiers($mode,$delim,$modifiers) {
135
-        if($delim) {
136
-            if($mode=='(')
137
-                return $this->_fetchContent($modifiers, $delim . ')');
134
+    public function _getRemainModifiers($mode, $delim, $modifiers){
135
+        if ($delim) {
136
+            if ($mode == '(')
137
+                return $this->_fetchContent($modifiers, $delim.')');
138 138
             else {
139 139
                 $modifiers = trim($modifiers);
140
-                $modifiers = substr($modifiers,1);
140
+                $modifiers = substr($modifiers, 1);
141 141
                 return $this->_fetchContent($modifiers, $delim);
142 142
             }
143 143
         }
144 144
         else {
145
-            if($mode=='(') return $this->_fetchContent($modifiers, ')');
145
+            if ($mode == '(') return $this->_fetchContent($modifiers, ')');
146 146
             $chars = str_split($modifiers);
147
-            foreach($chars as $c) {
148
-                if($c==':') return $modifiers;
149
-                else $modifiers = substr($modifiers,1);
147
+            foreach ($chars as $c) {
148
+                if ($c == ':') return $modifiers;
149
+                else $modifiers = substr($modifiers, 1);
150 150
             }
151 151
             return $modifiers;
152 152
         }
153 153
     }
154 154
 
155
-    public function _fetchContent($string,$delim) {
155
+    public function _fetchContent($string, $delim){
156 156
         $len = strlen($delim);
157 157
         $string = $this->parseDocumentSource($string);
158
-        return substr($string,strpos($string, $delim)+$len);
158
+        return substr($string, strpos($string, $delim) + $len);
159 159
     }
160 160
 
161
-    public function splitEachModifiers($modifiers) {
161
+    public function splitEachModifiers($modifiers){
162 162
         $modx = DocumentParser::getInstance();
163 163
 
164 164
         $cmd = '';
165 165
         $bt = '';
166 166
         $result = array();
167
-        while($bt!==$modifiers) {
167
+        while ($bt !== $modifiers) {
168 168
             $bt = $modifiers;
169
-            $c = substr($modifiers,0,1);
170
-            $modifiers = substr($modifiers,1);
169
+            $c = substr($modifiers, 0, 1);
170
+            $modifiers = substr($modifiers, 1);
171 171
 
172
-            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
173
-                $c = substr($modifiers,strlen($match[1]),1);
172
+            if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
173
+                $c = substr($modifiers, strlen($match[1]), 1);
174 174
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
175
-                if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1);
176
-                else         $modifiers = substr($modifiers,strlen($match[1]));
175
+                if ($c === '(') $modifiers = substr($modifiers, strlen($match[1]) + 1);
176
+                else         $modifiers = substr($modifiers, strlen($match[1]));
177 177
 
178
-                $delim     = $this->_getDelim($c,$modifiers);
179
-                $opt       = $this->_getOpt($c,$delim,$modifiers);
180
-                $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers));
178
+                $delim     = $this->_getDelim($c, $modifiers);
179
+                $opt       = $this->_getOpt($c, $delim, $modifiers);
180
+                $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers));
181 181
 
182
-                $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
182
+                $result[] = array('cmd'=>trim($match[1]), 'opt'=>$opt, 'debuginfo'=>$debuginfo);
183 183
                 $cmd = '';
184 184
             }
185
-            elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
186
-                $modifiers = substr($modifiers,strlen($match[0]));
187
-                $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]);
185
+            elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
186
+                $modifiers = substr($modifiers, strlen($match[0]));
187
+                $result[] = array('cmd'=>'math', 'opt'=>'%s'.$c.$match[0]);
188 188
                 $cmd = '';
189 189
             }
190
-            elseif($c==='(' || $c==='=') {
190
+            elseif ($c === '(' || $c === '=') {
191 191
                 $modifiers = $m1 = trim($modifiers);
192
-                $delim     = $this->_getDelim($c,$modifiers);
193
-                $opt       = $this->_getOpt($c,$delim,$modifiers);
194
-                $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers));
192
+                $delim     = $this->_getDelim($c, $modifiers);
193
+                $opt       = $this->_getOpt($c, $delim, $modifiers);
194
+                $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers));
195 195
                 $debuginfo = "#i=1 #c=[{$c}] #delim=[{$delim}] #m1=[{$m1}] remainMdf=[{$modifiers}]";
196 196
 
197
-                $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo);
197
+                $result[] = array('cmd'=>trim($cmd), 'opt'=>$opt, 'debuginfo'=>$debuginfo);
198 198
 
199 199
                 $cmd = '';
200 200
             }
201
-            elseif($c==':') {
201
+            elseif ($c == ':') {
202 202
                 $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]";
203
-                if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
203
+                if ($cmd !== '') $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo);
204 204
 
205 205
                 $cmd = '';
206 206
             }
207
-            elseif(trim($modifiers)=='' && trim($cmd)!=='') {
207
+            elseif (trim($modifiers) == '' && trim($cmd) !== '') {
208 208
                 $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]";
209 209
                 $cmd .= $c;
210
-                $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
210
+                $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo);
211 211
 
212 212
                 break;
213 213
             }
@@ -216,65 +216,65 @@  discard block
 block discarded – undo
216 216
             }
217 217
         }
218 218
 
219
-        if(empty($result)) return array();
219
+        if (empty($result)) return array();
220 220
 
221
-        foreach($result as $i=>$a)
221
+        foreach ($result as $i=>$a)
222 222
         {
223 223
             $a['opt'] = $this->parseDocumentSource($a['opt']);
224
-            $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders);
224
+            $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'], $this->placeholders);
225 225
         }
226 226
 
227 227
         return $result;
228 228
     }
229 229
 
230
-    public function parsePhx($key,$value,$modifiers)
230
+    public function parsePhx($key, $value, $modifiers)
231 231
     {
232 232
         $modx = DocumentParser::getInstance();
233 233
         $lastKey = '';
234
-        $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true)));
235
-        if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
236
-        if(empty($modifiers)) return '';
234
+        $cacheKey = md5(sprintf('parsePhx#%s#%s#%s', $key, $value, print_r($modifiers, true)));
235
+        if (isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
236
+        if (empty($modifiers)) return '';
237 237
 
238
-        foreach($modifiers as $m)
238
+        foreach ($modifiers as $m)
239 239
         {
240 240
             $lastKey = strtolower($m['cmd']);
241 241
         }
242
-        $_ = explode(',',$this->condModifiers);
243
-        if(in_array($lastKey,$_))
242
+        $_ = explode(',', $this->condModifiers);
243
+        if (in_array($lastKey, $_))
244 244
         {
245
-            $modifiers[] = array('cmd'=>'then','opt'=>'1');
246
-            $modifiers[] = array('cmd'=>'else','opt'=>'0');
245
+            $modifiers[] = array('cmd'=>'then', 'opt'=>'1');
246
+            $modifiers[] = array('cmd'=>'else', 'opt'=>'0');
247 247
         }
248 248
 
249
-        foreach($modifiers as $i=>$a)
249
+        foreach ($modifiers as $i=>$a)
250 250
         {
251
-            $value = $this->Filter($key,$value, $a['cmd'], $a['opt']);
251
+            $value = $this->Filter($key, $value, $a['cmd'], $a['opt']);
252 252
         }
253 253
         $this->tmpCache[$cacheKey] = $value;
254 254
         return $value;
255 255
     }
256 256
 
257 257
     // Parser: modifier detection and eXtended processing if needed
258
-    public function Filter($key, $value, $cmd, $opt='')
258
+    public function Filter($key, $value, $cmd, $opt = '')
259 259
     {
260 260
         $modx = DocumentParser::getInstance();
261 261
 
262
-        if($key==='documentObject') $value = $modx->documentIdentifier;
262
+        if ($key === 'documentObject') $value = $modx->documentIdentifier;
263 263
         $cmd = $this->parseDocumentSource($cmd);
264
-        if(preg_match('@^[1-9][/0-9]*$@',$cmd))
264
+        if (preg_match('@^[1-9][/0-9]*$@', $cmd))
265 265
         {
266
-            if(strpos($cmd,'/')!==false)
267
-                $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
266
+            if (strpos($cmd, '/') !== false)
267
+                $cmd = $this->substr($cmd, strrpos($cmd, '/') + 1);
268 268
             $opt = $cmd;
269 269
             $cmd = 'id';
270 270
         }
271 271
 
272
-        if(isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
273
-        elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
272
+        if (isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
273
+        elseif (isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
274 274
         else                                           $this->elmName = '';
275 275
 
276 276
         $cmd = strtolower($cmd);
277
-        if($this->elmName!=='')
277
+        if ($this->elmName !== '')
278 278
             $value = $this->getValueFromElement($key, $value, $cmd, $opt);
279 279
         else
280 280
             $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
         return $value;
285 285
     }
286 286
 
287
-    public function isEmpty($cmd,$value)
287
+    public function isEmpty($cmd, $value)
288 288
     {
289
-        if($value!=='') return false;
289
+        if ($value !== '') return false;
290 290
 
291
-        $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
292
-        if(in_array($cmd,$_)) return false;
291
+        $_ = explode(',', $this->condModifiers.',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
292
+        if (in_array($cmd, $_)) return false;
293 293
         else                  return true;
294 294
     }
295 295
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     {
298 298
         $modx = DocumentParser::getInstance();
299 299
 
300
-        if($this->isEmpty($cmd,$value)) return '';
300
+        if ($this->isEmpty($cmd, $value)) return '';
301 301
 
302 302
         $this->key = $key;
303 303
         $this->value  = $value;
@@ -308,83 +308,83 @@  discard block
 block discarded – undo
308 308
             #####  Conditional Modifiers
309 309
             case 'input':
310 310
             case 'if':
311
-                if(!$opt) return $value;
311
+                if (!$opt) return $value;
312 312
                 return $opt;
313 313
             case '=':
314 314
             case 'eq':
315 315
             case 'is':
316 316
             case 'equals':
317
-                $this->condition[] = (int)($value == $opt); break;
317
+                $this->condition[] = (int) ($value == $opt); break;
318 318
             case 'neq':
319 319
             case 'ne':
320 320
             case 'notequals':
321 321
             case 'isnot':
322 322
             case 'isnt':
323 323
             case 'not':
324
-                $this->condition[] = (int)($value != $opt);break;
324
+                $this->condition[] = (int) ($value != $opt); break;
325 325
             case '%':
326
-                $this->condition[] = (int)($value%$opt==0);break;
326
+                $this->condition[] = (int) ($value % $opt == 0); break;
327 327
             case 'isempty':
328
-                $this->condition[] = (int)(empty($value)); break;
328
+                $this->condition[] = (int) (empty($value)); break;
329 329
             case 'isntempty':
330 330
             case 'isnotempty':
331
-                $this->condition[] = (int)(!empty($value)); break;
331
+                $this->condition[] = (int) (!empty($value)); break;
332 332
             case '>=':
333 333
             case 'gte':
334 334
             case 'eg':
335 335
             case 'isgte':
336
-                $this->condition[] = (int)($value >= $opt);break;
336
+                $this->condition[] = (int) ($value >= $opt); break;
337 337
             case '<=':
338 338
             case 'lte':
339 339
             case 'el':
340 340
             case 'islte':
341
-                $this->condition[] = (int)($value <= $opt);break;
341
+                $this->condition[] = (int) ($value <= $opt); break;
342 342
             case '>':
343 343
             case 'gt':
344 344
             case 'greaterthan':
345 345
             case 'isgreaterthan':
346 346
             case 'isgt':
347
-                $this->condition[] = (int)($value > $opt);break;
347
+                $this->condition[] = (int) ($value > $opt); break;
348 348
             case '<':
349 349
             case 'lt':
350 350
             case 'lowerthan':
351 351
             case 'islowerthan':
352 352
             case 'islt':
353
-                $this->condition[] = (int)($value < $opt);break;
353
+                $this->condition[] = (int) ($value < $opt); break;
354 354
             case 'find':
355
-                $this->condition[] = (int)(strpos($value, $opt)!==false);break;
355
+                $this->condition[] = (int) (strpos($value, $opt) !== false); break;
356 356
             case 'inarray':
357 357
             case 'in_array':
358 358
             case 'in':
359 359
                 $opt = explode(',', $opt);
360
-                $this->condition[] = (int)(in_array($value, $opt)!==false);break;
360
+                $this->condition[] = (int) (in_array($value, $opt) !== false); break;
361 361
             case 'wildcard_match':
362 362
             case 'wcard_match':
363 363
             case 'wildcard':
364 364
             case 'wcard':
365 365
             case 'fnmatch':
366
-                $this->condition[] = (int)(fnmatch($opt, $value)!==false);break;
366
+                $this->condition[] = (int) (fnmatch($opt, $value) !== false); break;
367 367
             case 'is_file':
368 368
             case 'is_dir':
369 369
             case 'file_exists':
370 370
             case 'is_readable':
371 371
             case 'is_writable':
372
-                if(!$opt) $path = $value;
372
+                if (!$opt) $path = $value;
373 373
                 else      $path = $opt;
374
-                if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path');
375
-                if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/');
376
-                $this->condition[] = (int)($cmd($path)!==false);break;
374
+                if (strpos($path, MODX_MANAGER_PATH) !== false) exit('Can not read core path');
375
+                if (strpos($path, $modx->config['base_path']) === false) $path = ltrim($path, '/');
376
+                $this->condition[] = (int) ($cmd($path) !== false); break;
377 377
             case 'is_image':
378
-                if(!$opt) $path = $value;
378
+                if (!$opt) $path = $value;
379 379
                 else      $path = $opt;
380
-                if(!is_file($path)) {$this->condition[]='0';break;}
380
+                if (!is_file($path)) {$this->condition[] = '0'; break; }
381 381
                 $_ = getimagesize($path);
382
-                $this->condition[] = (int)($_[0]);break;
382
+                $this->condition[] = (int) ($_[0]); break;
383 383
             case 'regex':
384 384
             case 'preg':
385 385
             case 'preg_match':
386 386
             case 'isinrole':
387
-            $this->condition[] = (int)(preg_match($opt,$value));break;
387
+            $this->condition[] = (int) (preg_match($opt, $value)); break;
388 388
             case 'ir':
389 389
             case 'memberof':
390 390
             case 'mo':
@@ -392,50 +392,50 @@  discard block
 block discarded – undo
392 392
                 $this->condition[] = $this->includeMdfFile('memberof');
393 393
                 break;
394 394
             case 'or':
395
-                $this->condition[] = '||';break;
395
+                $this->condition[] = '||'; break;
396 396
             case 'and':
397
-                $this->condition[] = '&&';break;
397
+                $this->condition[] = '&&'; break;
398 398
             case 'show':
399 399
             case 'this':
400
-                $conditional = implode(' ',$this->condition);
401
-                $isvalid = (int)(eval("return ({$conditional});"));
400
+                $conditional = implode(' ', $this->condition);
401
+                $isvalid = (int) (eval("return ({$conditional});"));
402 402
                 if ($isvalid) return $this->srcValue;
403 403
                 return NULL;
404 404
             case 'then':
405
-                $conditional = implode(' ',$this->condition);
406
-                $isvalid = (int)eval("return ({$conditional});");
405
+                $conditional = implode(' ', $this->condition);
406
+                $isvalid = (int) eval("return ({$conditional});");
407 407
                 if ($isvalid)  return $opt;
408 408
                 return null;
409 409
             case 'else':
410
-                $conditional = implode(' ',$this->condition);
411
-                $isvalid = (int)eval("return ({$conditional});");
410
+                $conditional = implode(' ', $this->condition);
411
+                $isvalid = (int) eval("return ({$conditional});");
412 412
                 if (!$isvalid) return $opt;
413 413
                 break;
414 414
             case 'select':
415 415
             case 'switch':
416
-                $raw = explode('&',$opt);
416
+                $raw = explode('&', $opt);
417 417
                 $map = array();
418 418
                 $c = count($raw);
419
-                for($m=0; $m<$c; $m++) {
420
-                    $mi = explode('=',$raw[$m],2);
419
+                for ($m = 0; $m < $c; $m++) {
420
+                    $mi = explode('=', $raw[$m], 2);
421 421
                     $map[$mi[0]] = $mi[1];
422 422
                 }
423
-                if(isset($map[$value])) return $map[$value];
423
+                if (isset($map[$value])) return $map[$value];
424 424
                 else                    return '';
425 425
             ##### End of Conditional Modifiers
426 426
 
427 427
             #####  Encode / Decode / Hash / Escape
428 428
             case 'htmlent':
429 429
             case 'htmlentities':
430
-                return htmlentities($value,ENT_QUOTES,$modx->config['modx_charset']);
430
+                return htmlentities($value, ENT_QUOTES, $modx->config['modx_charset']);
431 431
             case 'html_entity_decode':
432 432
             case 'decode_html':
433 433
             case 'html_decode':
434
-                return html_entity_decode($value,ENT_QUOTES,$modx->config['modx_charset']);
434
+                return html_entity_decode($value, ENT_QUOTES, $modx->config['modx_charset']);
435 435
             case 'esc':
436 436
             case 'escape':
437 437
                 $value = preg_replace('/&amp;(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset']));
438
-                return str_replace(array('[', ']', '`'),array('&#91;', '&#93;', '&#96;'),$value);
438
+                return str_replace(array('[', ']', '`'), array('&#91;', '&#93;', '&#96;'), $value);
439 439
             case 'sql_escape':
440 440
             case 'encode_js':
441 441
                 return $modx->db->escape($value);
@@ -445,39 +445,39 @@  discard block
 block discarded – undo
445 445
             case 'html_encode':
446 446
                 return preg_replace('/&amp;(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset']));
447 447
             case 'spam_protect':
448
-                return str_replace(array('@','.'),array('&#64;','&#46;'),$value);
448
+                return str_replace(array('@', '.'), array('&#64;', '&#46;'), $value);
449 449
             case 'strip':
450
-                if($opt==='') $opt = ' ';
450
+                if ($opt === '') $opt = ' ';
451 451
                 return preg_replace('/[\n\r\t\s]+/', $opt, $value);
452 452
             case 'strip_linefeeds':
453
-                return str_replace(array("\n","\r"), '', $value);
453
+                return str_replace(array("\n", "\r"), '', $value);
454 454
             case 'notags':
455 455
             case 'strip_tags':
456 456
             case 'remove_html':
457
-                if($opt!=='')
457
+                if ($opt !== '')
458 458
                 {
459 459
                     $param = array();
460
-                    foreach(explode(',',$opt) as $v)
460
+                    foreach (explode(',', $opt) as $v)
461 461
                     {
462
-                        $v = trim($v,'</> ');
462
+                        $v = trim($v, '</> ');
463 463
                         $param[] = "<{$v}>";
464 464
                     }
465
-                    $params = implode(',',$param);
465
+                    $params = implode(',', $param);
466 466
                 }
467 467
                 else $params = '';
468
-                if(!strpos($params,'<br>')===false) {
469
-                    $value = preg_replace('@(<br[ /]*>)\n@','$1',$value);
470
-                    $value = preg_replace('@<br[ /]*>@',"\n",$value);
468
+                if (!strpos($params, '<br>') === false) {
469
+                    $value = preg_replace('@(<br[ /]*>)\n@', '$1', $value);
470
+                    $value = preg_replace('@<br[ /]*>@', "\n", $value);
471 471
                 }
472
-                return $this->strip_tags($value,$params);
472
+                return $this->strip_tags($value, $params);
473 473
             case 'urlencode':
474 474
             case 'url_encode':
475 475
             case 'encode_url':
476 476
                 return urlencode($value);
477 477
             case 'base64_decode':
478
-                if($opt!=='false') $opt = true;
478
+                if ($opt !== 'false') $opt = true;
479 479
                 else               $opt = false;
480
-                return base64_decode($value,$opt);
480
+                return base64_decode($value, $opt);
481 481
             case 'encode_sha1': $cmd = 'sha1';
482 482
             case 'addslashes':
483 483
             case 'urldecode':
@@ -501,18 +501,18 @@  discard block
 block discarded – undo
501 501
             case 'upper_case':
502 502
                 return $this->strtoupper($value);
503 503
             case 'capitalize':
504
-                $_ = explode(' ',$value);
505
-                foreach($_ as $i=>$v)
504
+                $_ = explode(' ', $value);
505
+                foreach ($_ as $i=>$v)
506 506
                 {
507 507
                     $_[$i] = ucfirst($v);
508 508
                 }
509
-                return implode(' ',$_);
509
+                return implode(' ', $_);
510 510
             case 'zenhan':
511
-                if(empty($opt)) $opt='VKas';
512
-                return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
511
+                if (empty($opt)) $opt = 'VKas';
512
+                return mb_convert_kana($value, $opt, $modx->config['modx_charset']);
513 513
             case 'hanzen':
514
-                if(empty($opt)) $opt='VKAS';
515
-                return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
514
+                if (empty($opt)) $opt = 'VKAS';
515
+                return mb_convert_kana($value, $opt, $modx->config['modx_charset']);
516 516
             case 'str_shuffle':
517 517
             case 'shuffle':
518 518
                 return $this->str_shuffle($value);
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
                 return $this->strlen($value);
527 527
             case 'count_words':
528 528
                 $value = trim($value);
529
-                return count(preg_split('/\s+/',$value));
529
+                return count(preg_split('/\s+/', $value));
530 530
             case 'str_word_count':
531 531
             case 'word_count':
532 532
             case 'wordcount':
@@ -534,55 +534,55 @@  discard block
 block discarded – undo
534 534
             case 'count_paragraphs':
535 535
                 $value = trim($value);
536 536
                 $value = preg_replace('/\r/', '', $value);
537
-                return count(preg_split('/\n+/',$value));
537
+                return count(preg_split('/\n+/', $value));
538 538
             case 'strpos':
539
-                if($opt!=0&&empty($opt)) return $value;
540
-                return $this->strpos($value,$opt);
539
+                if ($opt != 0 && empty($opt)) return $value;
540
+                return $this->strpos($value, $opt);
541 541
             case 'wordwrap':
542 542
                 // default: 70
543
-                  $wrapat = (int)$opt > 0 ? (int)$opt : 70;
543
+                  $wrapat = (int) $opt > 0 ? (int) $opt : 70;
544 544
                 if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap');
545
-                else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
545
+                else return preg_replace("@(\b\w+\b)@e", "wordwrap('\\1',\$wrapat,' ',1)", $value);
546 546
             case 'wrap_text':
547
-                $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70;
548
-                if($modx->config['manager_language']==='japanese-utf8') {
547
+                $width = preg_match('/^[1-9][0-9]*$/', $opt) ? $opt : 70;
548
+                if ($modx->config['manager_language'] === 'japanese-utf8') {
549 549
                     $chunk = array();
550
-                    $bt='';
551
-                    while($bt!=$value) {
550
+                    $bt = '';
551
+                    while ($bt != $value) {
552 552
                         $bt = $value;
553
-                        if($this->strlen($value)<$width) {
553
+                        if ($this->strlen($value) < $width) {
554 554
                             $chunk[] = $value;
555 555
                             break;
556 556
                         }
557
-                        $chunk[] = $this->substr($value,0,$width);
558
-                        $value = $this->substr($value,$width);
557
+                        $chunk[] = $this->substr($value, 0, $width);
558
+                        $value = $this->substr($value, $width);
559 559
                     }
560
-                    return implode("\n",$chunk);
560
+                    return implode("\n", $chunk);
561 561
                 }
562 562
                 else
563
-                    return wordwrap($value,$width,"\n",true);
563
+                    return wordwrap($value, $width, "\n", true);
564 564
             case 'substr':
565
-                if(empty($opt)) break;
566
-                if(strpos($opt,',')!==false) {
567
-                    list($b,$e) = explode(',',$opt,2);
568
-                    return $this->substr($value,$b,(int)$e);
565
+                if (empty($opt)) break;
566
+                if (strpos($opt, ',') !== false) {
567
+                    list($b, $e) = explode(',', $opt, 2);
568
+                    return $this->substr($value, $b, (int) $e);
569 569
                 }
570
-                else return $this->substr($value,$opt);
570
+                else return $this->substr($value, $opt);
571 571
             case 'limit':
572 572
             case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html
573
-                if(strpos($opt,'+')!==false)
574
-                    list($len,$str) = explode('+',$opt,2);
573
+                if (strpos($opt, '+') !== false)
574
+                    list($len, $str) = explode('+', $opt, 2);
575 575
                 else {
576 576
                     $len = $opt;
577 577
                     $str = '';
578 578
                 }
579
-                if($len==='') $len = 100;
580
-                if(abs($len) > $this->strlen($value)) $str ='';
581
-                if(preg_match('/^[1-9][0-9]*$/',$len)) {
582
-                    return $this->substr($value,0,$len) . $str;
579
+                if ($len === '') $len = 100;
580
+                if (abs($len) > $this->strlen($value)) $str = '';
581
+                if (preg_match('/^[1-9][0-9]*$/', $len)) {
582
+                    return $this->substr($value, 0, $len).$str;
583 583
                 }
584
-                elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
585
-                    return $str . $this->substr($value,$len);
584
+                elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) {
585
+                    return $str.$this->substr($value, $len);
586 586
                 }
587 587
                 break;
588 588
             case 'summary':
@@ -591,81 +591,81 @@  discard block
 block discarded – undo
591 591
                 return $this->includeMdfFile('summary');
592 592
             case 'replace':
593 593
             case 'str_replace':
594
-                if(empty($opt) || strpos($opt,',')===false) break;
595
-                if    (substr_count($opt, ',') ==1) $delim = ',';
596
-                elseif(substr_count($opt, '|') ==1) $delim = '|';
597
-                elseif(substr_count($opt, '=>')==1) $delim = '=>';
598
-                elseif(substr_count($opt, '/') ==1) $delim = '/';
594
+                if (empty($opt) || strpos($opt, ',') === false) break;
595
+                if (substr_count($opt, ',') == 1) $delim = ',';
596
+                elseif (substr_count($opt, '|') == 1) $delim = '|';
597
+                elseif (substr_count($opt, '=>') == 1) $delim = '=>';
598
+                elseif (substr_count($opt, '/') == 1) $delim = '/';
599 599
                 else break;
600
-                list($s,$r) = explode($delim,$opt);
601
-                if($value!=='') return str_replace($s,$r,$value);
600
+                list($s, $r) = explode($delim, $opt);
601
+                if ($value !== '') return str_replace($s, $r, $value);
602 602
                 break;
603 603
             case 'replace_to':
604 604
             case 'tpl':
605
-                if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
605
+                if ($value !== '') return str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $value, $opt);
606 606
                 break;
607 607
             case 'eachtpl':
608
-                $value = explode('||',$value);
608
+                $value = explode('||', $value);
609 609
                 $_ = array();
610
-                foreach($value as $v) {
611
-                    $_[] = str_replace(array('[+value+]','[+output+]','{value}','%s'),$v,$opt);
610
+                foreach ($value as $v) {
611
+                    $_[] = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $v, $opt);
612 612
                 }
613 613
                 return implode("\n", $_);
614 614
             case 'array_pop':
615 615
             case 'array_shift':
616
-                if(strpos($value,'||')!==false) $delim = '||';
616
+                if (strpos($value, '||') !== false) $delim = '||';
617 617
                 else                            $delim = ',';
618
-                return $cmd(explode($delim,$value));
618
+                return $cmd(explode($delim, $value));
619 619
             case 'preg_replace':
620 620
             case 'regex_replace':
621
-                if(empty($opt) || strpos($opt,',')===false) break;
622
-                list($s,$r) = explode(',',$opt,2);
623
-                if($value!=='') return preg_replace($s,$r,$value);
621
+                if (empty($opt) || strpos($opt, ',') === false) break;
622
+                list($s, $r) = explode(',', $opt, 2);
623
+                if ($value !== '') return preg_replace($s, $r, $value);
624 624
                 break;
625 625
             case 'cat':
626 626
             case 'concatenate':
627 627
             case '.':
628
-                if($value!=='') return $value . $opt;
628
+                if ($value !== '') return $value.$opt;
629 629
                 break;
630 630
             case 'sprintf':
631 631
             case 'string_format':
632
-                if($value!=='') return sprintf($opt,$value);
632
+                if ($value !== '') return sprintf($opt, $value);
633 633
                 break;
634 634
             case 'number_format':
635
-                    if($opt=='') $opt = 0;
636
-                    return number_format($value,$opt);
635
+                    if ($opt == '') $opt = 0;
636
+                    return number_format($value, $opt);
637 637
             case 'money_format':
638
-                    setlocale(LC_MONETARY,setlocale(LC_TIME,0));
639
-                    if($value!=='') return money_format($opt,(double)$value);
638
+                    setlocale(LC_MONETARY, setlocale(LC_TIME, 0));
639
+                    if ($value !== '') return money_format($opt, (double) $value);
640 640
                     break;
641 641
             case 'tobool':
642 642
                 return boolval($value);
643 643
             case 'nl2lf':
644
-                if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value);
644
+                if ($value !== '') return str_replace(array("\r\n", "\n", "\r"), '\n', $value);
645 645
                 break;
646 646
             case 'br2nl':
647 647
                 return preg_replace('@<br[\s/]*>@i', "\n", $value);
648 648
             case 'nl2br':
649 649
                 if (version_compare(PHP_VERSION, '5.3.0', '<'))
650 650
                     return nl2br($value);
651
-                if($opt!=='')
651
+                if ($opt !== '')
652 652
                 {
653 653
                     $opt = trim($opt);
654 654
                     $opt = strtolower($opt);
655
-                    if($opt==='false') $opt = false;
656
-                    elseif($opt==='0') $opt = false;
655
+                    if ($opt === 'false') $opt = false;
656
+                    elseif ($opt === '0') $opt = false;
657 657
                     else               $opt = true;
658 658
                 }
659
-                elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html')
659
+                elseif (isset($modx->config['mce_element_format']) && $modx->config['mce_element_format'] === 'html')
660 660
                                        $opt = false;
661 661
                 else                   $opt = true;
662
-                return nl2br($value,$opt);
662
+                return nl2br($value, $opt);
663 663
             case 'ltrim':
664 664
             case 'rtrim':
665 665
             case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html
666
-                if($opt==='')
666
+                if ($opt === '')
667 667
                     return $cmd($value);
668
-                else return $cmd($value,$opt);
668
+                else return $cmd($value, $opt);
669 669
             // These are all straight wrappers for PHP functions
670 670
             case 'ucfirst':
671 671
             case 'lcfirst':
@@ -676,58 +676,58 @@  discard block
 block discarded – undo
676 676
             case 'strftime':
677 677
             case 'date':
678 678
             case 'dateformat':
679
-                if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
680
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
681
-                if(strpos($opt,'%')!==false)
682
-                    return strftime($opt,0+$value);
679
+                if (empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
680
+                if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value);
681
+                if (strpos($opt, '%') !== false)
682
+                    return strftime($opt, 0 + $value);
683 683
                 else
684
-                    return date($opt,0+$value);
684
+                    return date($opt, 0 + $value);
685 685
             case 'time':
686
-                if(empty($opt)) $opt = '%H:%M';
687
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
688
-                return strftime($opt,0+$value);
686
+                if (empty($opt)) $opt = '%H:%M';
687
+                if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value);
688
+                return strftime($opt, 0 + $value);
689 689
             case 'strtotime':
690 690
                 return strtotime($value);
691 691
             #####  mathematical function
692 692
             case 'toint':
693
-                return (int)$value;
693
+                return (int) $value;
694 694
             case 'tofloat':
695 695
                 return floatval($value);
696 696
             case 'round':
697
-                if(!$opt) $opt = 0;
698
-                return $cmd($value,$opt);
697
+                if (!$opt) $opt = 0;
698
+                return $cmd($value, $opt);
699 699
             case 'max':
700 700
             case 'min':
701
-                return $cmd(explode(',',$value));
701
+                return $cmd(explode(',', $value));
702 702
             case 'floor':
703 703
             case 'ceil':
704 704
             case 'abs':
705 705
                 return $cmd($value);
706 706
             case 'math':
707 707
             case 'calc':
708
-                $value = (int)$value;
709
-                if(empty($value)) $value = '0';
710
-                $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt);
711
-                $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter);
712
-                if(strpos($filter,'?')===false) $filter = "?{$filter}";
713
-                $filter = str_replace('?',$value,$filter);
708
+                $value = (int) $value;
709
+                if (empty($value)) $value = '0';
710
+                $filter = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), '?', $opt);
711
+                $filter = preg_replace('@([a-zA-Z\n\r\t\s])@', '', $filter);
712
+                if (strpos($filter, '?') === false) $filter = "?{$filter}";
713
+                $filter = str_replace('?', $value, $filter);
714 714
                 return eval("return {$filter};");
715 715
             case 'count':
716
-                if($value=='') return 0;
717
-                $value = explode(',',$value);
716
+                if ($value == '') return 0;
717
+                $value = explode(',', $value);
718 718
                 return count($value);
719 719
             case 'sort':
720 720
             case 'rsort':
721
-                if(strpos($value,"\n")!==false) $delim="\n";
721
+                if (strpos($value, "\n") !== false) $delim = "\n";
722 722
                 else $delim = ',';
723
-                $swap = explode($delim,$value);
724
-                if(!$opt) $opt = SORT_REGULAR;
723
+                $swap = explode($delim, $value);
724
+                if (!$opt) $opt = SORT_REGULAR;
725 725
                 else      $opt = constant($opt);
726
-                $cmd($swap,$opt);
727
-                return implode($delim,$swap);
726
+                $cmd($swap, $opt);
727
+                return implode($delim, $swap);
728 728
             #####  Resource fields
729 729
             case 'id':
730
-                if($opt) return $this->getDocumentObject($opt,$key);
730
+                if ($opt) return $this->getDocumentObject($opt, $key);
731 731
                 break;
732 732
             case 'type':
733 733
             case 'contenttype':
@@ -764,36 +764,36 @@  discard block
 block discarded – undo
764 764
             case 'privatemgr':
765 765
             case 'content_dispo':
766 766
             case 'hidemenu':
767
-                if($cmd==='contenttype') $cmd = 'contentType';
768
-                return $this->getDocumentObject($value,$cmd);
767
+                if ($cmd === 'contenttype') $cmd = 'contentType';
768
+                return $this->getDocumentObject($value, $cmd);
769 769
             case 'title':
770
-                $pagetitle = $this->getDocumentObject($value,'pagetitle');
771
-                $longtitle = $this->getDocumentObject($value,'longtitle');
770
+                $pagetitle = $this->getDocumentObject($value, 'pagetitle');
771
+                $longtitle = $this->getDocumentObject($value, 'longtitle');
772 772
                 return $longtitle ? $longtitle : $pagetitle;
773 773
             case 'shorttitle':
774
-                $pagetitle = $this->getDocumentObject($value,'pagetitle');
775
-                $menutitle = $this->getDocumentObject($value,'menutitle');
774
+                $pagetitle = $this->getDocumentObject($value, 'pagetitle');
775
+                $menutitle = $this->getDocumentObject($value, 'menutitle');
776 776
                 return $menutitle ? $menutitle : $pagetitle;
777 777
             case 'templatename':
778
-                $rs = $modx->db->select('templatename','[+prefix+]site_templates',"id='{$value}'");
778
+                $rs = $modx->db->select('templatename', '[+prefix+]site_templates', "id='{$value}'");
779 779
                 $templateName = $modx->db->getValue($rs);
780 780
                 return !$templateName ? '(blank)' : $templateName;
781 781
             case 'getfield':
782
-                if(!$opt) $opt = 'content';
783
-                return $modx->getField($opt,$value);
782
+                if (!$opt) $opt = 'content';
783
+                return $modx->getField($opt, $value);
784 784
             case 'children':
785 785
             case 'childids':
786
-                if($value=='') $value = 0; // 値がない場合はルートと見なす
786
+                if ($value == '') $value = 0; // 値がない場合はルートと見なす
787 787
                 $published = 1;
788
-                if($opt=='') $opt = 'page';
789
-                $_ = explode(',',$opt);
788
+                if ($opt == '') $opt = 'page';
789
+                $_ = explode(',', $opt);
790 790
                 $where = array();
791
-                foreach($_ as $opt) {
792
-                    switch(trim($opt)) {
791
+                foreach ($_ as $opt) {
792
+                    switch (trim($opt)) {
793 793
                         case 'page'; case '!folder'; case '!isfolder': $where[] = 'sc.isfolder=0'; break;
794 794
                         case 'folder'; case 'isfolder':                $where[] = 'sc.isfolder=1'; break;
795
-                        case  'menu';  case  'show_menu':              $where[] = 'sc.hidemenu=0'; break;
796
-                        case '!menu';  case '!show_menu':              $where[] = 'sc.hidemenu=1'; break;
795
+                        case  'menu'; case  'show_menu':              $where[] = 'sc.hidemenu=0'; break;
796
+                        case '!menu'; case '!show_menu':              $where[] = 'sc.hidemenu=1'; break;
797 797
                         case  'published':                             $published = 1; break;
798 798
                         case '!published':                             $published = 0; break;
799 799
                     }
@@ -801,69 +801,69 @@  discard block
 block discarded – undo
801 801
                 $where = implode(' AND ', $where);
802 802
                 $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where);
803 803
                 $result = array();
804
-                foreach((array)$children as $child){
804
+                foreach ((array) $children as $child) {
805 805
                     $result[] = $child['id'];
806 806
                 }
807 807
                 return implode(',', $result);
808 808
             case 'fullurl':
809
-                if(!is_numeric($value)) return $value;
809
+                if (!is_numeric($value)) return $value;
810 810
                 return $modx->makeUrl($value);
811 811
             case 'makeurl':
812
-                if(!is_numeric($value)) return $value;
813
-                if(!$opt) $opt = 'full';
814
-                return $modx->makeUrl($value,'','',$opt);
812
+                if (!is_numeric($value)) return $value;
813
+                if (!$opt) $opt = 'full';
814
+                return $modx->makeUrl($value, '', '', $opt);
815 815
 
816 816
             #####  File system
817 817
             case 'getimageinfo':
818 818
             case 'imageinfo':
819
-                if(!is_file($value)) return '';
819
+                if (!is_file($value)) return '';
820 820
                 $_ = getimagesize($value);
821
-                if(!$_[0]) return '';
821
+                if (!$_[0]) return '';
822 822
                 $info['width']  = $_[0];
823 823
                 $info['height'] = $_[1];
824
-                if    ($_[0] > $_[1]) $info['aspect'] = 'landscape';
825
-                elseif($_[0] < $_[1]) $info['aspect'] = 'portrait';
824
+                if ($_[0] > $_[1]) $info['aspect'] = 'landscape';
825
+                elseif ($_[0] < $_[1]) $info['aspect'] = 'portrait';
826 826
                 else                  $info['aspect'] = 'square';
827
-                switch($_[2]) {
827
+                switch ($_[2]) {
828 828
                     case IMAGETYPE_GIF  : $info['type'] = 'gif'; break;
829 829
                     case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break;
830 830
                     case IMAGETYPE_PNG  : $info['type'] = 'png'; break;
831 831
                     default             : $info['type'] = 'unknown';
832 832
                 }
833 833
                 $info['attrib'] = $_[3];
834
-                switch($opt) {
834
+                switch ($opt) {
835 835
                     case 'width' : return $info['width'];
836 836
                     case 'height': return $info['height'];
837 837
                     case 'aspect': return $info['aspect'];
838 838
                     case 'type'  : return $info['type'];
839 839
                     case 'attrib': return $info['attrib'];
840
-                    default      : return print_r($info,true);
840
+                    default      : return print_r($info, true);
841 841
                 }
842 842
 
843 843
             case 'file_get_contents':
844 844
             case 'readfile':
845
-                if(!is_file($value)) return $value;
845
+                if (!is_file($value)) return $value;
846 846
                 $value = realpath($value);
847
-                if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file');
848
-                $ext = strtolower(substr($value,-4));
849
-                if($ext==='.php') exit('Can not read php file');
850
-                if($ext==='.cgi') exit('Can not read cgi file');
847
+                if (strpos($value, MODX_MANAGER_PATH) !== false) exit('Can not read core file');
848
+                $ext = strtolower(substr($value, -4));
849
+                if ($ext === '.php') exit('Can not read php file');
850
+                if ($ext === '.cgi') exit('Can not read cgi file');
851 851
                 return file_get_contents($value);
852 852
             case 'filesize':
853
-                if($value == '') return '';
853
+                if ($value == '') return '';
854 854
                 $filename = $value;
855 855
 
856 856
                 $site_url = $modx->config['site_url'];
857
-                if(strpos($filename,$site_url) === 0)
858
-                    $filename = substr($filename,0,strlen($site_url));
859
-                $filename = trim($filename,'/');
857
+                if (strpos($filename, $site_url) === 0)
858
+                    $filename = substr($filename, 0, strlen($site_url));
859
+                $filename = trim($filename, '/');
860 860
 
861
-                $opt = trim($opt,'/');
862
-                if($opt!=='') $opt .= '/';
861
+                $opt = trim($opt, '/');
862
+                if ($opt !== '') $opt .= '/';
863 863
 
864 864
                 $filename = MODX_BASE_PATH.$opt.$filename;
865 865
 
866
-                if(is_file($filename)){
866
+                if (is_file($filename)) {
867 867
                     clearstatcache();
868 868
                     $size = filesize($filename);
869 869
                     return $size;
@@ -896,10 +896,10 @@  discard block
 block discarded – undo
896 896
                 $this->opt = $cmd;
897 897
                 return $this->includeMdfFile('moduser');
898 898
             case 'userinfo':
899
-                if(empty($opt)) $this->opt = 'username';
899
+                if (empty($opt)) $this->opt = 'username';
900 900
                 return $this->includeMdfFile('moduser');
901 901
             case 'webuserinfo':
902
-                if(empty($opt)) $this->opt = 'username';
902
+                if (empty($opt)) $this->opt = 'username';
903 903
                 $this->value = -$value;
904 904
                 return $this->includeMdfFile('moduser');
905 905
             #####  Special functions
@@ -910,27 +910,27 @@  discard block
 block discarded – undo
910 910
             case 'ifnotempty':
911 911
                 if (!empty($value)) return $opt; break;
912 912
             case 'datagrid':
913
-                include_once(MODX_CORE_PATH . 'controls/datagrid.class.php');
913
+                include_once(MODX_CORE_PATH.'controls/datagrid.class.php');
914 914
                 $grd = new DataGrid(null, trim($value));
915 915
                 $grd->itemStyle = '';
916 916
                 $grd->altItemStyle = '';
917
-                $pos = strpos($value,"\n");
918
-                if($pos) $_ = substr($value,0,$pos);
917
+                $pos = strpos($value, "\n");
918
+                if ($pos) $_ = substr($value, 0, $pos);
919 919
                 else $_ = $pos;
920
-                $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ',';
920
+                $grd->cdelim = strpos($_, "\t") !== false ? 'tab' : ',';
921 921
                 return $grd->render();
922 922
             case 'rotate':
923 923
             case 'evenodd':
924
-                if(strpos($opt,',')===false) $opt = 'odd,even';
924
+                if (strpos($opt, ',') === false) $opt = 'odd,even';
925 925
                 $_ = explode(',', $opt);
926 926
                 $c = count($_);
927 927
                 $i = $value + $c;
928 928
                 $i = $i % $c;
929 929
                 return $_[$i];
930 930
             case 'takeval':
931
-                $arr = explode(",",$opt);
931
+                $arr = explode(",", $opt);
932 932
                 $idx = $value;
933
-                if(!is_numeric($idx)) return $value;
933
+                if (!is_numeric($idx)) return $value;
934 934
                 return $arr[$idx];
935 935
             case 'getimage':
936 936
                 return $this->includeMdfFile('getimage');
@@ -938,17 +938,17 @@  discard block
 block discarded – undo
938 938
                     return $modx->nicesize($value);
939 939
             case 'googlemap':
940 940
             case 'googlemaps':
941
-                if(empty($opt)) $opt = 'border:none;width:500px;height:350px;';
941
+                if (empty($opt)) $opt = 'border:none;width:500px;height:350px;';
942 942
                 $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>';
943 943
                 $ph['style'] = $opt;
944 944
                 $ph['value'] = $value;
945
-                return $modx->parseText($tpl,$ph);
945
+                return $modx->parseText($tpl, $ph);
946 946
             case 'youtube':
947 947
             case 'youtube16x9':
948
-                if(empty($opt)) $opt = 560;
949
-                $h = round($opt*0.5625);
948
+                if (empty($opt)) $opt = 560;
949
+                $h = round($opt * 0.5625);
950 950
                 $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>';
951
-                return sprintf($tpl,$opt,$h,$value);
951
+                return sprintf($tpl, $opt, $h, $value);
952 952
             //case 'youtube4x3':%s*0.75+25
953 953
             case 'setvar':
954 954
                 $modx->placeholders[$opt] = $value;
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
         return $value;
979 979
     }
980 980
 
981
-    public function includeMdfFile($cmd) {
981
+    public function includeMdfFile($cmd){
982 982
         $modx = DocumentParser::getInstance();
983 983
         $key = $this->key;
984 984
         $value  = $this->value;
@@ -989,54 +989,54 @@  discard block
 block discarded – undo
989 989
     public function getValueFromElement($key, $value, $cmd, $opt)
990 990
     {
991 991
         $modx = DocumentParser::getInstance();
992
-        if( isset($modx->snippetCache[$this->elmName]) )
992
+        if (isset($modx->snippetCache[$this->elmName]))
993 993
         {
994 994
             $php = $modx->snippetCache[$this->elmName];
995 995
         }
996 996
         else
997 997
         {
998 998
             $esc_elmName = $modx->db->escape($this->elmName);
999
-            $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'");
999
+            $result = $modx->db->select('snippet', '[+prefix+]site_snippets', "name='{$esc_elmName}'");
1000 1000
             $total = $modx->db->getRecordCount($result);
1001
-            if($total == 1)
1001
+            if ($total == 1)
1002 1002
             {
1003 1003
                 $row = $modx->db->getRow($result);
1004 1004
                 $php = $row['snippet'];
1005 1005
             }
1006
-            elseif($total == 0)
1006
+            elseif ($total == 0)
1007 1007
             {
1008 1008
                 $assets_path = MODX_BASE_PATH.'assets/';
1009
-                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
1009
+                if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
1010 1010
                     $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1011
-                elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
1011
+                elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
1012 1012
                     $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1013
-                elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
1013
+                elseif (is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
1014 1014
                     $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1015 1015
                 else $modifiers_path = false;
1016 1016
 
1017
-                if($modifiers_path !== false) {
1017
+                if ($modifiers_path !== false) {
1018 1018
                     $php = @file_get_contents($modifiers_path);
1019 1019
                     $php = trim($php);
1020
-                    if(substr($php,0,5)==='<?php') $php = substr($php,6);
1021
-                    if(substr($php,0,2)==='<?')    $php = substr($php,3);
1022
-                    if(substr($php,-2)==='?>')     $php = substr($php,0,-2);
1023
-                    if($this->elmName!=='')
1020
+                    if (substr($php, 0, 5) === '<?php') $php = substr($php, 6);
1021
+                    if (substr($php, 0, 2) === '<?')    $php = substr($php, 3);
1022
+                    if (substr($php, -2) === '?>')     $php = substr($php, 0, -2);
1023
+                    if ($this->elmName !== '')
1024 1024
                         $modx->snippetCache[$this->elmName.'Props'] = '';
1025 1025
                 }
1026 1026
                 else
1027 1027
                     $php = false;
1028 1028
             }
1029 1029
             else $php = false;
1030
-            if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php;
1030
+            if ($this->elmName !== '') $modx->snippetCache[$this->elmName] = $php;
1031 1031
         }
1032
-        if($php==='') $php=false;
1032
+        if ($php === '') $php = false;
1033 1033
 
1034
-        if($php===false) $html = $modx->getChunk($this->elmName);
1034
+        if ($php === false) $html = $modx->getChunk($this->elmName);
1035 1035
         else             $html = false;
1036 1036
 
1037 1037
         $self = '[+output+]';
1038 1038
 
1039
-        if($php !== false)
1039
+        if ($php !== false)
1040 1040
         {
1041 1041
             ob_start();
1042 1042
             $options = $opt;
@@ -1049,71 +1049,71 @@  discard block
 block discarded – undo
1049 1049
             $this->vars['options'] = & $opt;
1050 1050
             $custom = eval($php);
1051 1051
             $msg = ob_get_contents();
1052
-            if($value===$this->bt) $value = $msg . $custom;
1052
+            if ($value === $this->bt) $value = $msg.$custom;
1053 1053
             ob_end_clean();
1054 1054
         }
1055
-        elseif($html!==false && isset($value) && $value!=='')
1055
+        elseif ($html !== false && isset($value) && $value !== '')
1056 1056
         {
1057
-            $html = str_replace(array($self,'[+value+]'), $value, $html);
1058
-            $value = str_replace(array('[+options+]','[+param+]'), $opt, $html);
1057
+            $html = str_replace(array($self, '[+value+]'), $value, $html);
1058
+            $value = str_replace(array('[+options+]', '[+param+]'), $opt, $html);
1059 1059
         }
1060 1060
         else return false;
1061 1061
 
1062
-        if($php===false && $html===false && $value!==''
1063
-           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false))
1062
+        if ($php === false && $html === false && $value !== ''
1063
+           && (strpos($cmd, '[+value+]') !== false || strpos($cmd, $self) !== false))
1064 1064
         {
1065
-            $value = str_replace(array('[+value+]',$self),$value,$cmd);
1065
+            $value = str_replace(array('[+value+]', $self), $value, $cmd);
1066 1066
         }
1067 1067
         return $value;
1068 1068
     }
1069 1069
 
1070
-    public function parseDocumentSource($content='')
1070
+    public function parseDocumentSource($content = '')
1071 1071
     {
1072 1072
         $modx = DocumentParser::getInstance();
1073 1073
 
1074
-        if(strpos($content,'[')===false && strpos($content,'{')===false) return $content;
1074
+        if (strpos($content, '[') === false && strpos($content, '{') === false) return $content;
1075 1075
 
1076
-        if(!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1077
-        $bt='';
1078
-        $i=0;
1079
-        while($bt!==$content)
1076
+        if (!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1077
+        $bt = '';
1078
+        $i = 0;
1079
+        while ($bt !== $content)
1080 1080
         {
1081 1081
             $bt = $content;
1082
-            if(strpos($content,'[*')!==false && $modx->documentIdentifier)
1082
+            if (strpos($content, '[*') !== false && $modx->documentIdentifier)
1083 1083
                                               $content = $modx->mergeDocumentContent($content);
1084
-            if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content);
1085
-            if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content);
1086
-            if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1087
-            if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content);
1084
+            if (strpos($content, '[(') !== false) $content = $modx->mergeSettingsContent($content);
1085
+            if (strpos($content, '{{') !== false) $content = $modx->mergeChunkContent($content);
1086
+            if (strpos($content, '[!') !== false) $content = str_replace(array('[!', '!]'), array('[[', ']]'), $content);
1087
+            if (strpos($content, '[[') !== false) $content = $modx->evalSnippets($content);
1088 1088
 
1089
-            if($content===$bt)              break;
1090
-            if($modx->maxParserPasses < $i) break;
1089
+            if ($content === $bt)              break;
1090
+            if ($modx->maxParserPasses < $i) break;
1091 1091
             $i++;
1092 1092
         }
1093 1093
         return $content;
1094 1094
     }
1095 1095
 
1096
-    public function getDocumentObject($target='',$field='pagetitle')
1096
+    public function getDocumentObject($target = '', $field = 'pagetitle')
1097 1097
     {
1098 1098
         $modx = DocumentParser::getInstance();
1099 1099
 
1100 1100
         $target = trim($target);
1101
-        if(empty($target)) $target = $modx->config['site_start'];
1102
-        if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id';
1101
+        if (empty($target)) $target = $modx->config['site_start'];
1102
+        if (preg_match('@^[1-9][0-9]*$@', $target)) $method = 'id';
1103 1103
         else $method = 'alias';
1104 1104
 
1105
-        if(!isset($this->documentObject[$target]))
1105
+        if (!isset($this->documentObject[$target]))
1106 1106
         {
1107
-            $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct');
1107
+            $this->documentObject[$target] = $modx->getDocumentObject($method, $target, 'direct');
1108 1108
         }
1109 1109
 
1110
-        if($this->documentObject[$target]['publishedon']==='0')
1110
+        if ($this->documentObject[$target]['publishedon'] === '0')
1111 1111
             return '';
1112
-        elseif(isset($this->documentObject[$target][$field]))
1112
+        elseif (isset($this->documentObject[$target][$field]))
1113 1113
         {
1114
-            if(is_array($this->documentObject[$target][$field]))
1114
+            if (is_array($this->documentObject[$target][$field]))
1115 1115
             {
1116
-                $a = $modx->getTemplateVarOutput($field,$target);
1116
+                $a = $modx->getTemplateVarOutput($field, $target);
1117 1117
                 $this->documentObject[$target][$field] = $a[$field];
1118 1118
             }
1119 1119
         }
@@ -1122,8 +1122,8 @@  discard block
 block discarded – undo
1122 1122
         return $this->documentObject[$target][$field];
1123 1123
     }
1124 1124
 
1125
-    public function setPlaceholders($value = '', $key = '', $path = '') {
1126
-        if($path!=='') $key = "{$path}.{$key}";
1125
+    public function setPlaceholders($value = '', $key = '', $path = ''){
1126
+        if ($path !== '') $key = "{$path}.{$key}";
1127 1127
         if (is_array($value)) {
1128 1128
             foreach ($value as $subkey => $subval) {
1129 1129
                 $this->setPlaceholders($subval, $subkey, $key);
@@ -1133,77 +1133,77 @@  discard block
 block discarded – undo
1133 1133
     }
1134 1134
 
1135 1135
     // Sets a placeholder variable which can only be access by Modifiers
1136
-    public function setModifiersVariable($key, $value) {
1136
+    public function setModifiersVariable($key, $value){
1137 1137
         if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1138 1138
     }
1139 1139
 
1140 1140
     //mbstring
1141
-    public function substr($str, $s, $l = null) {
1141
+    public function substr($str, $s, $l = null){
1142 1142
         $modx = DocumentParser::getInstance();
1143
-        if(is_null($l)) $l = $this->strlen($str);
1143
+        if (is_null($l)) $l = $this->strlen($str);
1144 1144
         if (function_exists('mb_substr'))
1145 1145
         {
1146
-            if(strpos($str,"\r")!==false)
1147
-                $str = str_replace(array("\r\n","\r"), "\n", $str);
1146
+            if (strpos($str, "\r") !== false)
1147
+                $str = str_replace(array("\r\n", "\r"), "\n", $str);
1148 1148
             return mb_substr($str, $s, $l, $modx->config['modx_charset']);
1149 1149
         }
1150 1150
         return substr($str, $s, $l);
1151 1151
     }
1152
-    public function strpos($haystack,$needle,$offset=0) {
1152
+    public function strpos($haystack, $needle, $offset = 0){
1153 1153
         $modx = DocumentParser::getInstance();
1154
-        if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1155
-        return strpos($haystack,$needle,$offset);
1154
+        if (function_exists('mb_strpos')) return mb_strpos($haystack, $needle, $offset, $modx->config['modx_charset']);
1155
+        return strpos($haystack, $needle, $offset);
1156 1156
     }
1157
-    public function strlen($str) {
1157
+    public function strlen($str){
1158 1158
         $modx = DocumentParser::getInstance();
1159
-        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1159
+        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str), $modx->config['modx_charset']);
1160 1160
         return strlen($str);
1161 1161
     }
1162
-    public function strtolower($str) {
1162
+    public function strtolower($str){
1163 1163
         if (function_exists('mb_strtolower')) return mb_strtolower($str);
1164 1164
         return strtolower($str);
1165 1165
     }
1166
-    public function strtoupper($str) {
1166
+    public function strtoupper($str){
1167 1167
         if (function_exists('mb_strtoupper')) return mb_strtoupper($str);
1168 1168
         return strtoupper($str);
1169 1169
     }
1170
-    public function ucfirst($str) {
1170
+    public function ucfirst($str){
1171 1171
         if (function_exists('mb_strtoupper'))
1172 1172
             return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1173 1173
         return ucfirst($str);
1174 1174
     }
1175
-    public function lcfirst($str) {
1175
+    public function lcfirst($str){
1176 1176
         if (function_exists('mb_strtolower'))
1177 1177
             return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1178 1178
         return lcfirst($str);
1179 1179
     }
1180
-    public function ucwords($str) {
1180
+    public function ucwords($str){
1181 1181
         if (function_exists('mb_convert_case'))
1182 1182
             return mb_convert_case($str, MB_CASE_TITLE);
1183 1183
         return ucwords($str);
1184 1184
     }
1185
-    public function strrev($str) {
1185
+    public function strrev($str){
1186 1186
         preg_match_all('/./us', $str, $ar);
1187 1187
         return implode(array_reverse($ar[0]));
1188 1188
     }
1189
-    public function str_shuffle($str) {
1189
+    public function str_shuffle($str){
1190 1190
         preg_match_all('/./us', $str, $ar);
1191 1191
         shuffle($ar[0]);
1192 1192
         return implode($ar[0]);
1193 1193
     }
1194
-    public function str_word_count($str) {
1195
-        return count(preg_split('~[^\p{L}\p{N}\']+~u',$str));
1194
+    public function str_word_count($str){
1195
+        return count(preg_split('~[^\p{L}\p{N}\']+~u', $str));
1196 1196
     }
1197
-    public function strip_tags($value,$params='') {
1197
+    public function strip_tags($value, $params = ''){
1198 1198
         $modx = DocumentParser::getInstance();
1199 1199
 
1200
-        if(stripos($params,'style')===false && stripos($value,'</style>')!==false) {
1200
+        if (stripos($params, 'style') === false && stripos($value, '</style>') !== false) {
1201 1201
             $value = preg_replace('@<style.*?>.*?</style>@is', '', $value);
1202 1202
         }
1203
-        if(stripos($params,'script')===false && stripos($value,'</script>')!==false) {
1203
+        if (stripos($params, 'script') === false && stripos($value, '</script>') !== false) {
1204 1204
             $value = preg_replace('@<script.*?>.*?</script>@is', '', $value);
1205 1205
         }
1206 1206
 
1207
-        return trim(strip_tags($value,$params));
1207
+        return trim(strip_tags($value, $params));
1208 1208
     }
1209 1209
 }
Please login to merge, or discard this patch.
Braces   +544 added lines, -282 removed lines patch added patch discarded remove patch
@@ -1,8 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
3
+if(!defined('MODX_CORE_PATH')) {
4
+    define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
5
+}
4 6
 
5
-class MODIFIERS {
7
+class MODIFIERS
8
+{
6 9
     /**
7 10
      * @var array
8 11
      */
@@ -60,7 +63,9 @@  discard block
 block discarded – undo
60 63
     public function __construct()
61 64
     {
62 65
         $modx = DocumentParser::getInstance();
63
-        if (function_exists('mb_internal_encoding')) mb_internal_encoding($modx->config['modx_charset']);
66
+        if (function_exists('mb_internal_encoding')) {
67
+            mb_internal_encoding($modx->config['modx_charset']);
68
+        }
64 69
         $this->condModifiers = '=,is,eq,equals,ne,neq,notequals,isnot,isnt,not,%,isempty,isnotempty,isntempty,>=,gte,eg,gte,greaterthan,>,gt,isgreaterthan,isgt,lowerthan,<,lt,<=,lte,islte,islowerthan,islt,el,find,in,inarray,in_array,fnmatch,wcard,wcard_match,wildcard,wildcard_match,is_file,is_dir,file_exists,is_readable,is_writable,is_image,regex,preg,preg_match,memberof,mo,isinrole,ir';
65 70
     }
66 71
 
@@ -73,7 +78,9 @@  discard block
 block discarded – undo
73 78
     public function phxFilter($key,$value,$modifiers)
74 79
     {
75 80
         $modx = DocumentParser::getInstance();
76
-        if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value);
81
+        if(substr($modifiers,0,3)!=='id(') {
82
+            $value = $this->parseDocumentSource($value);
83
+        }
77 84
         $this->srcValue = $value;
78 85
         $modifiers = trim($modifiers);
79 86
         $modifiers = ':'.trim($modifiers,':');
@@ -96,13 +103,18 @@  discard block
 block discarded – undo
96 103
      * @param string $modifiers
97 104
      * @return bool|string
98 105
      */
99
-    public function _getDelim($mode,$modifiers) {
106
+    public function _getDelim($mode,$modifiers)
107
+    {
100 108
         $c = substr($modifiers,0,1);
101
-        if(!in_array($c, array('"', "'", '`')) ) return false;
109
+        if(!in_array($c, array('"', "'", '`')) ) {
110
+            return false;
111
+        }
102 112
 
103 113
         $modifiers = substr($modifiers,1);
104 114
         $closure = $mode=='(' ? "{$c})" : $c;
105
-        if(strpos($modifiers, $closure)===false) return false;
115
+        if(strpos($modifiers, $closure)===false) {
116
+            return false;
117
+        }
106 118
 
107 119
         return  $c;
108 120
     }
@@ -113,52 +125,65 @@  discard block
 block discarded – undo
113 125
      * @param string $modifiers
114 126
      * @return bool|string
115 127
      */
116
-    public function _getOpt($mode,$delim,$modifiers) {
128
+    public function _getOpt($mode,$delim,$modifiers)
129
+    {
117 130
         if($delim) {
118
-            if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
131
+            if($mode=='(') {
132
+                return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
133
+            }
119 134
 
120 135
             return substr($modifiers,1,strpos($modifiers,$delim,1)-1);
121
-        }
122
-        else {
123
-            if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') );
136
+        } else {
137
+            if($mode=='(') {
138
+                return substr($modifiers,0,strpos($modifiers, ')') );
139
+            }
124 140
 
125 141
             $chars = str_split($modifiers);
126 142
             $opt='';
127 143
             foreach($chars as $c) {
128
-                if($c==':' || $c==')') break;
144
+                if($c==':' || $c==')') {
145
+                    break;
146
+                }
129 147
                 $opt .=$c;
130 148
             }
131 149
             return $opt;
132 150
         }
133 151
     }
134
-    public function _getRemainModifiers($mode,$delim,$modifiers) {
152
+    public function _getRemainModifiers($mode,$delim,$modifiers)
153
+    {
135 154
         if($delim) {
136
-            if($mode=='(')
137
-                return $this->_fetchContent($modifiers, $delim . ')');
138
-            else {
155
+            if($mode=='(') {
156
+                            return $this->_fetchContent($modifiers, $delim . ')');
157
+            } else {
139 158
                 $modifiers = trim($modifiers);
140 159
                 $modifiers = substr($modifiers,1);
141 160
                 return $this->_fetchContent($modifiers, $delim);
142 161
             }
143
-        }
144
-        else {
145
-            if($mode=='(') return $this->_fetchContent($modifiers, ')');
162
+        } else {
163
+            if($mode=='(') {
164
+                return $this->_fetchContent($modifiers, ')');
165
+            }
146 166
             $chars = str_split($modifiers);
147 167
             foreach($chars as $c) {
148
-                if($c==':') return $modifiers;
149
-                else $modifiers = substr($modifiers,1);
168
+                if($c==':') {
169
+                    return $modifiers;
170
+                } else {
171
+                    $modifiers = substr($modifiers,1);
172
+                }
150 173
             }
151 174
             return $modifiers;
152 175
         }
153 176
     }
154 177
 
155
-    public function _fetchContent($string,$delim) {
178
+    public function _fetchContent($string,$delim)
179
+    {
156 180
         $len = strlen($delim);
157 181
         $string = $this->parseDocumentSource($string);
158 182
         return substr($string,strpos($string, $delim)+$len);
159 183
     }
160 184
 
161
-    public function splitEachModifiers($modifiers) {
185
+    public function splitEachModifiers($modifiers)
186
+    {
162 187
         $modx = DocumentParser::getInstance();
163 188
 
164 189
         $cmd = '';
@@ -169,11 +194,15 @@  discard block
 block discarded – undo
169 194
             $c = substr($modifiers,0,1);
170 195
             $modifiers = substr($modifiers,1);
171 196
 
172
-            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
197
+            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) {
198
+// :=, :!=, :<=, :>=, :!<=, :!>=
173 199
                 $c = substr($modifiers,strlen($match[1]),1);
174 200
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
175
-                if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1);
176
-                else         $modifiers = substr($modifiers,strlen($match[1]));
201
+                if($c==='(') {
202
+                    $modifiers = substr($modifiers,strlen($match[1])+1);
203
+                } else {
204
+                    $modifiers = substr($modifiers,strlen($match[1]));
205
+                }
177 206
 
178 207
                 $delim     = $this->_getDelim($c,$modifiers);
179 208
                 $opt       = $this->_getOpt($c,$delim,$modifiers);
@@ -181,13 +210,12 @@  discard block
 block discarded – undo
181 210
 
182 211
                 $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
183 212
                 $cmd = '';
184
-            }
185
-            elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
213
+            } elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) {
214
+// :+3, :-3, :*3 ...
186 215
                 $modifiers = substr($modifiers,strlen($match[0]));
187 216
                 $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]);
188 217
                 $cmd = '';
189
-            }
190
-            elseif($c==='(' || $c==='=') {
218
+            } elseif($c==='(' || $c==='=') {
191 219
                 $modifiers = $m1 = trim($modifiers);
192 220
                 $delim     = $this->_getDelim($c,$modifiers);
193 221
                 $opt       = $this->_getOpt($c,$delim,$modifiers);
@@ -197,29 +225,29 @@  discard block
 block discarded – undo
197 225
                 $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo);
198 226
 
199 227
                 $cmd = '';
200
-            }
201
-            elseif($c==':') {
228
+            } elseif($c==':') {
202 229
                 $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]";
203
-                if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
230
+                if($cmd!=='') {
231
+                    $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
232
+                }
204 233
 
205 234
                 $cmd = '';
206
-            }
207
-            elseif(trim($modifiers)=='' && trim($cmd)!=='') {
235
+            } elseif(trim($modifiers)=='' && trim($cmd)!=='') {
208 236
                 $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]";
209 237
                 $cmd .= $c;
210 238
                 $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
211 239
 
212 240
                 break;
213
-            }
214
-            else {
241
+            } else {
215 242
                 $cmd .= $c;
216 243
             }
217 244
         }
218 245
 
219
-        if(empty($result)) return array();
246
+        if(empty($result)) {
247
+            return array();
248
+        }
220 249
 
221
-        foreach($result as $i=>$a)
222
-        {
250
+        foreach($result as $i=>$a) {
223 251
             $a['opt'] = $this->parseDocumentSource($a['opt']);
224 252
             $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders);
225 253
         }
@@ -232,22 +260,23 @@  discard block
 block discarded – undo
232 260
         $modx = DocumentParser::getInstance();
233 261
         $lastKey = '';
234 262
         $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true)));
235
-        if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
236
-        if(empty($modifiers)) return '';
263
+        if(isset($this->tmpCache[$cacheKey])) {
264
+            return $this->tmpCache[$cacheKey];
265
+        }
266
+        if(empty($modifiers)) {
267
+            return '';
268
+        }
237 269
 
238
-        foreach($modifiers as $m)
239
-        {
270
+        foreach($modifiers as $m) {
240 271
             $lastKey = strtolower($m['cmd']);
241 272
         }
242 273
         $_ = explode(',',$this->condModifiers);
243
-        if(in_array($lastKey,$_))
244
-        {
274
+        if(in_array($lastKey,$_)) {
245 275
             $modifiers[] = array('cmd'=>'then','opt'=>'1');
246 276
             $modifiers[] = array('cmd'=>'else','opt'=>'0');
247 277
         }
248 278
 
249
-        foreach($modifiers as $i=>$a)
250
-        {
279
+        foreach($modifiers as $i=>$a) {
251 280
             $value = $this->Filter($key,$value, $a['cmd'], $a['opt']);
252 281
         }
253 282
         $this->tmpCache[$cacheKey] = $value;
@@ -259,25 +288,32 @@  discard block
 block discarded – undo
259 288
     {
260 289
         $modx = DocumentParser::getInstance();
261 290
 
262
-        if($key==='documentObject') $value = $modx->documentIdentifier;
291
+        if($key==='documentObject') {
292
+            $value = $modx->documentIdentifier;
293
+        }
263 294
         $cmd = $this->parseDocumentSource($cmd);
264
-        if(preg_match('@^[1-9][/0-9]*$@',$cmd))
265
-        {
266
-            if(strpos($cmd,'/')!==false)
267
-                $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
295
+        if(preg_match('@^[1-9][/0-9]*$@',$cmd)) {
296
+            if(strpos($cmd,'/')!==false) {
297
+                            $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
298
+            }
268 299
             $opt = $cmd;
269 300
             $cmd = 'id';
270 301
         }
271 302
 
272
-        if(isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
273
-        elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
274
-        else                                           $this->elmName = '';
303
+        if(isset($modx->snippetCache["phx:{$cmd}"])) {
304
+            $this->elmName = "phx:{$cmd}";
305
+        } elseif(isset($modx->chunkCache["phx:{$cmd}"])) {
306
+            $this->elmName = "phx:{$cmd}";
307
+        } else {
308
+            $this->elmName = '';
309
+        }
275 310
 
276 311
         $cmd = strtolower($cmd);
277
-        if($this->elmName!=='')
278
-            $value = $this->getValueFromElement($key, $value, $cmd, $opt);
279
-        else
280
-            $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
312
+        if($this->elmName!=='') {
313
+                    $value = $this->getValueFromElement($key, $value, $cmd, $opt);
314
+        } else {
315
+                    $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
316
+        }
281 317
 
282 318
         $value = str_replace('[+key+]', $key, $value);
283 319
 
@@ -286,29 +322,37 @@  discard block
 block discarded – undo
286 322
 
287 323
     public function isEmpty($cmd,$value)
288 324
     {
289
-        if($value!=='') return false;
325
+        if($value!=='') {
326
+            return false;
327
+        }
290 328
 
291 329
         $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
292
-        if(in_array($cmd,$_)) return false;
293
-        else                  return true;
330
+        if(in_array($cmd,$_)) {
331
+            return false;
332
+        } else {
333
+            return true;
334
+        }
294 335
     }
295 336
 
296 337
     public function getValueFromPreset($key, $value, $cmd, $opt)
297 338
     {
298 339
         $modx = DocumentParser::getInstance();
299 340
 
300
-        if($this->isEmpty($cmd,$value)) return '';
341
+        if($this->isEmpty($cmd,$value)) {
342
+            return '';
343
+        }
301 344
 
302 345
         $this->key = $key;
303 346
         $this->value  = $value;
304 347
         $this->opt    = $opt;
305 348
 
306
-        switch ($cmd)
307
-        {
349
+        switch ($cmd) {
308 350
             #####  Conditional Modifiers
309 351
             case 'input':
310 352
             case 'if':
311
-                if(!$opt) return $value;
353
+                if(!$opt) {
354
+                    return $value;
355
+                }
312 356
                 return $opt;
313 357
             case '=':
314 358
             case 'eq':
@@ -369,14 +413,24 @@  discard block
 block discarded – undo
369 413
             case 'file_exists':
370 414
             case 'is_readable':
371 415
             case 'is_writable':
372
-                if(!$opt) $path = $value;
373
-                else      $path = $opt;
374
-                if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path');
375
-                if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/');
416
+                if(!$opt) {
417
+                    $path = $value;
418
+                } else {
419
+                    $path = $opt;
420
+                }
421
+                if(strpos($path,MODX_MANAGER_PATH)!==false) {
422
+                    exit('Can not read core path');
423
+                }
424
+                if(strpos($path,$modx->config['base_path'])===false) {
425
+                    $path = ltrim($path,'/');
426
+                }
376 427
                 $this->condition[] = (int)($cmd($path)!==false);break;
377 428
             case 'is_image':
378
-                if(!$opt) $path = $value;
379
-                else      $path = $opt;
429
+                if(!$opt) {
430
+                    $path = $value;
431
+                } else {
432
+                    $path = $opt;
433
+                }
380 434
                 if(!is_file($path)) {$this->condition[]='0';break;}
381 435
                 $_ = getimagesize($path);
382 436
                 $this->condition[] = (int)($_[0]);break;
@@ -399,17 +453,23 @@  discard block
 block discarded – undo
399 453
             case 'this':
400 454
                 $conditional = implode(' ',$this->condition);
401 455
                 $isvalid = (int)(eval("return ({$conditional});"));
402
-                if ($isvalid) return $this->srcValue;
456
+                if ($isvalid) {
457
+                    return $this->srcValue;
458
+                }
403 459
                 return NULL;
404 460
             case 'then':
405 461
                 $conditional = implode(' ',$this->condition);
406 462
                 $isvalid = (int)eval("return ({$conditional});");
407
-                if ($isvalid)  return $opt;
463
+                if ($isvalid) {
464
+                    return $opt;
465
+                }
408 466
                 return null;
409 467
             case 'else':
410 468
                 $conditional = implode(' ',$this->condition);
411 469
                 $isvalid = (int)eval("return ({$conditional});");
412
-                if (!$isvalid) return $opt;
470
+                if (!$isvalid) {
471
+                    return $opt;
472
+                }
413 473
                 break;
414 474
             case 'select':
415 475
             case 'switch':
@@ -420,8 +480,11 @@  discard block
 block discarded – undo
420 480
                     $mi = explode('=',$raw[$m],2);
421 481
                     $map[$mi[0]] = $mi[1];
422 482
                 }
423
-                if(isset($map[$value])) return $map[$value];
424
-                else                    return '';
483
+                if(isset($map[$value])) {
484
+                    return $map[$value];
485
+                } else {
486
+                    return '';
487
+                }
425 488
             ##### End of Conditional Modifiers
426 489
 
427 490
             #####  Encode / Decode / Hash / Escape
@@ -447,24 +510,25 @@  discard block
 block discarded – undo
447 510
             case 'spam_protect':
448 511
                 return str_replace(array('@','.'),array('&#64;','&#46;'),$value);
449 512
             case 'strip':
450
-                if($opt==='') $opt = ' ';
513
+                if($opt==='') {
514
+                    $opt = ' ';
515
+                }
451 516
                 return preg_replace('/[\n\r\t\s]+/', $opt, $value);
452 517
             case 'strip_linefeeds':
453 518
                 return str_replace(array("\n","\r"), '', $value);
454 519
             case 'notags':
455 520
             case 'strip_tags':
456 521
             case 'remove_html':
457
-                if($opt!=='')
458
-                {
522
+                if($opt!=='') {
459 523
                     $param = array();
460
-                    foreach(explode(',',$opt) as $v)
461
-                    {
524
+                    foreach(explode(',',$opt) as $v) {
462 525
                         $v = trim($v,'</> ');
463 526
                         $param[] = "<{$v}>";
464 527
                     }
465 528
                     $params = implode(',',$param);
529
+                } else {
530
+                    $params = '';
466 531
                 }
467
-                else $params = '';
468 532
                 if(!strpos($params,'<br>')===false) {
469 533
                     $value = preg_replace('@(<br[ /]*>)\n@','$1',$value);
470 534
                     $value = preg_replace('@<br[ /]*>@',"\n",$value);
@@ -475,8 +539,11 @@  discard block
 block discarded – undo
475 539
             case 'encode_url':
476 540
                 return urlencode($value);
477 541
             case 'base64_decode':
478
-                if($opt!=='false') $opt = true;
479
-                else               $opt = false;
542
+                if($opt!=='false') {
543
+                    $opt = true;
544
+                } else {
545
+                    $opt = false;
546
+                }
480 547
                 return base64_decode($value,$opt);
481 548
             case 'encode_sha1': $cmd = 'sha1';
482 549
             case 'addslashes':
@@ -502,16 +569,19 @@  discard block
 block discarded – undo
502 569
                 return $this->strtoupper($value);
503 570
             case 'capitalize':
504 571
                 $_ = explode(' ',$value);
505
-                foreach($_ as $i=>$v)
506
-                {
572
+                foreach($_ as $i=>$v) {
507 573
                     $_[$i] = ucfirst($v);
508 574
                 }
509 575
                 return implode(' ',$_);
510 576
             case 'zenhan':
511
-                if(empty($opt)) $opt='VKas';
577
+                if(empty($opt)) {
578
+                    $opt='VKas';
579
+                }
512 580
                 return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
513 581
             case 'hanzen':
514
-                if(empty($opt)) $opt='VKAS';
582
+                if(empty($opt)) {
583
+                    $opt='VKAS';
584
+                }
515 585
                 return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
516 586
             case 'str_shuffle':
517 587
             case 'shuffle':
@@ -536,13 +606,18 @@  discard block
 block discarded – undo
536 606
                 $value = preg_replace('/\r/', '', $value);
537 607
                 return count(preg_split('/\n+/',$value));
538 608
             case 'strpos':
539
-                if($opt!=0&&empty($opt)) return $value;
609
+                if($opt!=0&&empty($opt)) {
610
+                    return $value;
611
+                }
540 612
                 return $this->strpos($value,$opt);
541 613
             case 'wordwrap':
542 614
                 // default: 70
543 615
                   $wrapat = (int)$opt > 0 ? (int)$opt : 70;
544
-                if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap');
545
-                else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
616
+                if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
617
+                    return $this->includeMdfFile('wordwrap');
618
+                } else {
619
+                    return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
620
+                }
546 621
             case 'wrap_text':
547 622
                 $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70;
548 623
                 if($modx->config['manager_language']==='japanese-utf8') {
@@ -558,30 +633,36 @@  discard block
 block discarded – undo
558 633
                         $value = $this->substr($value,$width);
559 634
                     }
560 635
                     return implode("\n",$chunk);
636
+                } else {
637
+                                    return wordwrap($value,$width,"\n",true);
561 638
                 }
562
-                else
563
-                    return wordwrap($value,$width,"\n",true);
564 639
             case 'substr':
565
-                if(empty($opt)) break;
640
+                if(empty($opt)) {
641
+                    break;
642
+                }
566 643
                 if(strpos($opt,',')!==false) {
567 644
                     list($b,$e) = explode(',',$opt,2);
568 645
                     return $this->substr($value,$b,(int)$e);
646
+                } else {
647
+                    return $this->substr($value,$opt);
569 648
                 }
570
-                else return $this->substr($value,$opt);
571 649
             case 'limit':
572 650
             case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html
573
-                if(strpos($opt,'+')!==false)
574
-                    list($len,$str) = explode('+',$opt,2);
575
-                else {
651
+                if(strpos($opt,'+')!==false) {
652
+                                    list($len,$str) = explode('+',$opt,2);
653
+                } else {
576 654
                     $len = $opt;
577 655
                     $str = '';
578 656
                 }
579
-                if($len==='') $len = 100;
580
-                if(abs($len) > $this->strlen($value)) $str ='';
657
+                if($len==='') {
658
+                    $len = 100;
659
+                }
660
+                if(abs($len) > $this->strlen($value)) {
661
+                    $str ='';
662
+                }
581 663
                 if(preg_match('/^[1-9][0-9]*$/',$len)) {
582 664
                     return $this->substr($value,0,$len) . $str;
583
-                }
584
-                elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
665
+                } elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
585 666
                     return $str . $this->substr($value,$len);
586 667
                 }
587 668
                 break;
@@ -591,18 +672,30 @@  discard block
 block discarded – undo
591 672
                 return $this->includeMdfFile('summary');
592 673
             case 'replace':
593 674
             case 'str_replace':
594
-                if(empty($opt) || strpos($opt,',')===false) break;
595
-                if    (substr_count($opt, ',') ==1) $delim = ',';
596
-                elseif(substr_count($opt, '|') ==1) $delim = '|';
597
-                elseif(substr_count($opt, '=>')==1) $delim = '=>';
598
-                elseif(substr_count($opt, '/') ==1) $delim = '/';
599
-                else break;
675
+                if(empty($opt) || strpos($opt,',')===false) {
676
+                    break;
677
+                }
678
+                if    (substr_count($opt, ',') ==1) {
679
+                    $delim = ',';
680
+                } elseif(substr_count($opt, '|') ==1) {
681
+                    $delim = '|';
682
+                } elseif(substr_count($opt, '=>')==1) {
683
+                    $delim = '=>';
684
+                } elseif(substr_count($opt, '/') ==1) {
685
+                    $delim = '/';
686
+                } else {
687
+                    break;
688
+                }
600 689
                 list($s,$r) = explode($delim,$opt);
601
-                if($value!=='') return str_replace($s,$r,$value);
690
+                if($value!=='') {
691
+                    return str_replace($s,$r,$value);
692
+                }
602 693
                 break;
603 694
             case 'replace_to':
604 695
             case 'tpl':
605
-                if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
696
+                if($value!=='') {
697
+                    return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
698
+                }
606 699
                 break;
607 700
             case 'eachtpl':
608 701
                 $value = explode('||',$value);
@@ -613,59 +706,83 @@  discard block
 block discarded – undo
613 706
                 return implode("\n", $_);
614 707
             case 'array_pop':
615 708
             case 'array_shift':
616
-                if(strpos($value,'||')!==false) $delim = '||';
617
-                else                            $delim = ',';
709
+                if(strpos($value,'||')!==false) {
710
+                    $delim = '||';
711
+                } else {
712
+                    $delim = ',';
713
+                }
618 714
                 return $cmd(explode($delim,$value));
619 715
             case 'preg_replace':
620 716
             case 'regex_replace':
621
-                if(empty($opt) || strpos($opt,',')===false) break;
717
+                if(empty($opt) || strpos($opt,',')===false) {
718
+                    break;
719
+                }
622 720
                 list($s,$r) = explode(',',$opt,2);
623
-                if($value!=='') return preg_replace($s,$r,$value);
721
+                if($value!=='') {
722
+                    return preg_replace($s,$r,$value);
723
+                }
624 724
                 break;
625 725
             case 'cat':
626 726
             case 'concatenate':
627 727
             case '.':
628
-                if($value!=='') return $value . $opt;
728
+                if($value!=='') {
729
+                    return $value . $opt;
730
+                }
629 731
                 break;
630 732
             case 'sprintf':
631 733
             case 'string_format':
632
-                if($value!=='') return sprintf($opt,$value);
734
+                if($value!=='') {
735
+                    return sprintf($opt,$value);
736
+                }
633 737
                 break;
634 738
             case 'number_format':
635
-                    if($opt=='') $opt = 0;
739
+                    if($opt=='') {
740
+                        $opt = 0;
741
+                    }
636 742
                     return number_format($value,$opt);
637 743
             case 'money_format':
638 744
                     setlocale(LC_MONETARY,setlocale(LC_TIME,0));
639
-                    if($value!=='') return money_format($opt,(double)$value);
745
+                    if($value!=='') {
746
+                        return money_format($opt,(double)$value);
747
+                    }
640 748
                     break;
641 749
             case 'tobool':
642 750
                 return boolval($value);
643 751
             case 'nl2lf':
644
-                if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value);
752
+                if($value!=='') {
753
+                    return str_replace(array("\r\n","\n", "\r"), '\n', $value);
754
+                }
645 755
                 break;
646 756
             case 'br2nl':
647 757
                 return preg_replace('@<br[\s/]*>@i', "\n", $value);
648 758
             case 'nl2br':
649
-                if (version_compare(PHP_VERSION, '5.3.0', '<'))
650
-                    return nl2br($value);
651
-                if($opt!=='')
652
-                {
759
+                if (version_compare(PHP_VERSION, '5.3.0', '<')) {
760
+                                    return nl2br($value);
761
+                }
762
+                if($opt!=='') {
653 763
                     $opt = trim($opt);
654 764
                     $opt = strtolower($opt);
655
-                    if($opt==='false') $opt = false;
656
-                    elseif($opt==='0') $opt = false;
657
-                    else               $opt = true;
765
+                    if($opt==='false') {
766
+                        $opt = false;
767
+                    } elseif($opt==='0') {
768
+                        $opt = false;
769
+                    } else {
770
+                        $opt = true;
771
+                    }
772
+                } elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') {
773
+                                                       $opt = false;
774
+                } else {
775
+                    $opt = true;
658 776
                 }
659
-                elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html')
660
-                                       $opt = false;
661
-                else                   $opt = true;
662 777
                 return nl2br($value,$opt);
663 778
             case 'ltrim':
664 779
             case 'rtrim':
665 780
             case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html
666
-                if($opt==='')
667
-                    return $cmd($value);
668
-                else return $cmd($value,$opt);
781
+                if($opt==='') {
782
+                                    return $cmd($value);
783
+                } else {
784
+                    return $cmd($value,$opt);
785
+                }
669 786
             // These are all straight wrappers for PHP functions
670 787
             case 'ucfirst':
671 788
             case 'lcfirst':
@@ -676,15 +793,24 @@  discard block
 block discarded – undo
676 793
             case 'strftime':
677 794
             case 'date':
678 795
             case 'dateformat':
679
-                if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
680
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
681
-                if(strpos($opt,'%')!==false)
682
-                    return strftime($opt,0+$value);
683
-                else
684
-                    return date($opt,0+$value);
796
+                if(empty($opt)) {
797
+                    $opt = $modx->toDateFormat(null, 'formatOnly');
798
+                }
799
+                if(!preg_match('@^[0-9]+$@',$value)) {
800
+                    $value = strtotime($value);
801
+                }
802
+                if(strpos($opt,'%')!==false) {
803
+                                    return strftime($opt,0+$value);
804
+                } else {
805
+                                    return date($opt,0+$value);
806
+                }
685 807
             case 'time':
686
-                if(empty($opt)) $opt = '%H:%M';
687
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
808
+                if(empty($opt)) {
809
+                    $opt = '%H:%M';
810
+                }
811
+                if(!preg_match('@^[0-9]+$@',$value)) {
812
+                    $value = strtotime($value);
813
+                }
688 814
                 return strftime($opt,0+$value);
689 815
             case 'strtotime':
690 816
                 return strtotime($value);
@@ -694,7 +820,9 @@  discard block
 block discarded – undo
694 820
             case 'tofloat':
695 821
                 return floatval($value);
696 822
             case 'round':
697
-                if(!$opt) $opt = 0;
823
+                if(!$opt) {
824
+                    $opt = 0;
825
+                }
698 826
                 return $cmd($value,$opt);
699 827
             case 'max':
700 828
             case 'min':
@@ -706,28 +834,42 @@  discard block
 block discarded – undo
706 834
             case 'math':
707 835
             case 'calc':
708 836
                 $value = (int)$value;
709
-                if(empty($value)) $value = '0';
837
+                if(empty($value)) {
838
+                    $value = '0';
839
+                }
710 840
                 $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt);
711 841
                 $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter);
712
-                if(strpos($filter,'?')===false) $filter = "?{$filter}";
842
+                if(strpos($filter,'?')===false) {
843
+                    $filter = "?{$filter}";
844
+                }
713 845
                 $filter = str_replace('?',$value,$filter);
714 846
                 return eval("return {$filter};");
715 847
             case 'count':
716
-                if($value=='') return 0;
848
+                if($value=='') {
849
+                    return 0;
850
+                }
717 851
                 $value = explode(',',$value);
718 852
                 return count($value);
719 853
             case 'sort':
720 854
             case 'rsort':
721
-                if(strpos($value,"\n")!==false) $delim="\n";
722
-                else $delim = ',';
855
+                if(strpos($value,"\n")!==false) {
856
+                    $delim="\n";
857
+                } else {
858
+                    $delim = ',';
859
+                }
723 860
                 $swap = explode($delim,$value);
724
-                if(!$opt) $opt = SORT_REGULAR;
725
-                else      $opt = constant($opt);
861
+                if(!$opt) {
862
+                    $opt = SORT_REGULAR;
863
+                } else {
864
+                    $opt = constant($opt);
865
+                }
726 866
                 $cmd($swap,$opt);
727 867
                 return implode($delim,$swap);
728 868
             #####  Resource fields
729 869
             case 'id':
730
-                if($opt) return $this->getDocumentObject($opt,$key);
870
+                if($opt) {
871
+                    return $this->getDocumentObject($opt,$key);
872
+                }
731 873
                 break;
732 874
             case 'type':
733 875
             case 'contenttype':
@@ -764,7 +906,9 @@  discard block
 block discarded – undo
764 906
             case 'privatemgr':
765 907
             case 'content_dispo':
766 908
             case 'hidemenu':
767
-                if($cmd==='contenttype') $cmd = 'contentType';
909
+                if($cmd==='contenttype') {
910
+                    $cmd = 'contentType';
911
+                }
768 912
                 return $this->getDocumentObject($value,$cmd);
769 913
             case 'title':
770 914
                 $pagetitle = $this->getDocumentObject($value,'pagetitle');
@@ -779,13 +923,20 @@  discard block
 block discarded – undo
779 923
                 $templateName = $modx->db->getValue($rs);
780 924
                 return !$templateName ? '(blank)' : $templateName;
781 925
             case 'getfield':
782
-                if(!$opt) $opt = 'content';
926
+                if(!$opt) {
927
+                    $opt = 'content';
928
+                }
783 929
                 return $modx->getField($opt,$value);
784 930
             case 'children':
785 931
             case 'childids':
786
-                if($value=='') $value = 0; // 値がない場合はルートと見なす
932
+                if($value=='') {
933
+                    $value = 0;
934
+                }
935
+                // 値がない場合はルートと見なす
787 936
                 $published = 1;
788
-                if($opt=='') $opt = 'page';
937
+                if($opt=='') {
938
+                    $opt = 'page';
939
+                }
789 940
                 $_ = explode(',',$opt);
790 941
                 $where = array();
791 942
                 foreach($_ as $opt) {
@@ -801,29 +952,43 @@  discard block
 block discarded – undo
801 952
                 $where = implode(' AND ', $where);
802 953
                 $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where);
803 954
                 $result = array();
804
-                foreach((array)$children as $child){
955
+                foreach((array)$children as $child) {
805 956
                     $result[] = $child['id'];
806 957
                 }
807 958
                 return implode(',', $result);
808 959
             case 'fullurl':
809
-                if(!is_numeric($value)) return $value;
960
+                if(!is_numeric($value)) {
961
+                    return $value;
962
+                }
810 963
                 return $modx->makeUrl($value);
811 964
             case 'makeurl':
812
-                if(!is_numeric($value)) return $value;
813
-                if(!$opt) $opt = 'full';
965
+                if(!is_numeric($value)) {
966
+                    return $value;
967
+                }
968
+                if(!$opt) {
969
+                    $opt = 'full';
970
+                }
814 971
                 return $modx->makeUrl($value,'','',$opt);
815 972
 
816 973
             #####  File system
817 974
             case 'getimageinfo':
818 975
             case 'imageinfo':
819
-                if(!is_file($value)) return '';
976
+                if(!is_file($value)) {
977
+                    return '';
978
+                }
820 979
                 $_ = getimagesize($value);
821
-                if(!$_[0]) return '';
980
+                if(!$_[0]) {
981
+                    return '';
982
+                }
822 983
                 $info['width']  = $_[0];
823 984
                 $info['height'] = $_[1];
824
-                if    ($_[0] > $_[1]) $info['aspect'] = 'landscape';
825
-                elseif($_[0] < $_[1]) $info['aspect'] = 'portrait';
826
-                else                  $info['aspect'] = 'square';
985
+                if    ($_[0] > $_[1]) {
986
+                    $info['aspect'] = 'landscape';
987
+                } elseif($_[0] < $_[1]) {
988
+                    $info['aspect'] = 'portrait';
989
+                } else {
990
+                    $info['aspect'] = 'square';
991
+                }
827 992
                 switch($_[2]) {
828 993
                     case IMAGETYPE_GIF  : $info['type'] = 'gif'; break;
829 994
                     case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break;
@@ -842,33 +1007,47 @@  discard block
 block discarded – undo
842 1007
 
843 1008
             case 'file_get_contents':
844 1009
             case 'readfile':
845
-                if(!is_file($value)) return $value;
1010
+                if(!is_file($value)) {
1011
+                    return $value;
1012
+                }
846 1013
                 $value = realpath($value);
847
-                if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file');
1014
+                if(strpos($value,MODX_MANAGER_PATH)!==false) {
1015
+                    exit('Can not read core file');
1016
+                }
848 1017
                 $ext = strtolower(substr($value,-4));
849
-                if($ext==='.php') exit('Can not read php file');
850
-                if($ext==='.cgi') exit('Can not read cgi file');
1018
+                if($ext==='.php') {
1019
+                    exit('Can not read php file');
1020
+                }
1021
+                if($ext==='.cgi') {
1022
+                    exit('Can not read cgi file');
1023
+                }
851 1024
                 return file_get_contents($value);
852 1025
             case 'filesize':
853
-                if($value == '') return '';
1026
+                if($value == '') {
1027
+                    return '';
1028
+                }
854 1029
                 $filename = $value;
855 1030
 
856 1031
                 $site_url = $modx->config['site_url'];
857
-                if(strpos($filename,$site_url) === 0)
858
-                    $filename = substr($filename,0,strlen($site_url));
1032
+                if(strpos($filename,$site_url) === 0) {
1033
+                                    $filename = substr($filename,0,strlen($site_url));
1034
+                }
859 1035
                 $filename = trim($filename,'/');
860 1036
 
861 1037
                 $opt = trim($opt,'/');
862
-                if($opt!=='') $opt .= '/';
1038
+                if($opt!=='') {
1039
+                    $opt .= '/';
1040
+                }
863 1041
 
864 1042
                 $filename = MODX_BASE_PATH.$opt.$filename;
865 1043
 
866
-                if(is_file($filename)){
1044
+                if(is_file($filename)) {
867 1045
                     clearstatcache();
868 1046
                     $size = filesize($filename);
869 1047
                     return $size;
1048
+                } else {
1049
+                    return '';
870 1050
                 }
871
-                else return '';
872 1051
             #####  User info
873 1052
             case 'username':
874 1053
             case 'fullname':
@@ -896,32 +1075,47 @@  discard block
 block discarded – undo
896 1075
                 $this->opt = $cmd;
897 1076
                 return $this->includeMdfFile('moduser');
898 1077
             case 'userinfo':
899
-                if(empty($opt)) $this->opt = 'username';
1078
+                if(empty($opt)) {
1079
+                    $this->opt = 'username';
1080
+                }
900 1081
                 return $this->includeMdfFile('moduser');
901 1082
             case 'webuserinfo':
902
-                if(empty($opt)) $this->opt = 'username';
1083
+                if(empty($opt)) {
1084
+                    $this->opt = 'username';
1085
+                }
903 1086
                 $this->value = -$value;
904 1087
                 return $this->includeMdfFile('moduser');
905 1088
             #####  Special functions
906 1089
             case 'ifempty':
907 1090
             case '_default':
908 1091
             case 'default':
909
-                if (empty($value)) return $opt; break;
1092
+                if (empty($value)) {
1093
+                    return $opt;
1094
+                }
1095
+                break;
910 1096
             case 'ifnotempty':
911
-                if (!empty($value)) return $opt; break;
1097
+                if (!empty($value)) {
1098
+                    return $opt;
1099
+                }
1100
+                break;
912 1101
             case 'datagrid':
913 1102
                 include_once(MODX_CORE_PATH . 'controls/datagrid.class.php');
914 1103
                 $grd = new DataGrid(null, trim($value));
915 1104
                 $grd->itemStyle = '';
916 1105
                 $grd->altItemStyle = '';
917 1106
                 $pos = strpos($value,"\n");
918
-                if($pos) $_ = substr($value,0,$pos);
919
-                else $_ = $pos;
1107
+                if($pos) {
1108
+                    $_ = substr($value,0,$pos);
1109
+                } else {
1110
+                    $_ = $pos;
1111
+                }
920 1112
                 $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ',';
921 1113
                 return $grd->render();
922 1114
             case 'rotate':
923 1115
             case 'evenodd':
924
-                if(strpos($opt,',')===false) $opt = 'odd,even';
1116
+                if(strpos($opt,',')===false) {
1117
+                    $opt = 'odd,even';
1118
+                }
925 1119
                 $_ = explode(',', $opt);
926 1120
                 $c = count($_);
927 1121
                 $i = $value + $c;
@@ -930,7 +1124,9 @@  discard block
 block discarded – undo
930 1124
             case 'takeval':
931 1125
                 $arr = explode(",",$opt);
932 1126
                 $idx = $value;
933
-                if(!is_numeric($idx)) return $value;
1127
+                if(!is_numeric($idx)) {
1128
+                    return $value;
1129
+                }
934 1130
                 return $arr[$idx];
935 1131
             case 'getimage':
936 1132
                 return $this->includeMdfFile('getimage');
@@ -938,14 +1134,18 @@  discard block
 block discarded – undo
938 1134
                     return $modx->nicesize($value);
939 1135
             case 'googlemap':
940 1136
             case 'googlemaps':
941
-                if(empty($opt)) $opt = 'border:none;width:500px;height:350px;';
1137
+                if(empty($opt)) {
1138
+                    $opt = 'border:none;width:500px;height:350px;';
1139
+                }
942 1140
                 $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>';
943 1141
                 $ph['style'] = $opt;
944 1142
                 $ph['value'] = $value;
945 1143
                 return $modx->parseText($tpl,$ph);
946 1144
             case 'youtube':
947 1145
             case 'youtube16x9':
948
-                if(empty($opt)) $opt = 560;
1146
+                if(empty($opt)) {
1147
+                    $opt = 560;
1148
+                }
949 1149
                 $h = round($opt*0.5625);
950 1150
                 $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>';
951 1151
                 return sprintf($tpl,$opt,$h,$value);
@@ -978,7 +1178,8 @@  discard block
 block discarded – undo
978 1178
         return $value;
979 1179
     }
980 1180
 
981
-    public function includeMdfFile($cmd) {
1181
+    public function includeMdfFile($cmd)
1182
+    {
982 1183
         $modx = DocumentParser::getInstance();
983 1184
         $key = $this->key;
984 1185
         $value  = $this->value;
@@ -989,55 +1190,65 @@  discard block
 block discarded – undo
989 1190
     public function getValueFromElement($key, $value, $cmd, $opt)
990 1191
     {
991 1192
         $modx = DocumentParser::getInstance();
992
-        if( isset($modx->snippetCache[$this->elmName]) )
993
-        {
1193
+        if( isset($modx->snippetCache[$this->elmName]) ) {
994 1194
             $php = $modx->snippetCache[$this->elmName];
995
-        }
996
-        else
997
-        {
1195
+        } else {
998 1196
             $esc_elmName = $modx->db->escape($this->elmName);
999 1197
             $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'");
1000 1198
             $total = $modx->db->getRecordCount($result);
1001
-            if($total == 1)
1002
-            {
1199
+            if($total == 1) {
1003 1200
                 $row = $modx->db->getRow($result);
1004 1201
                 $php = $row['snippet'];
1005
-            }
1006
-            elseif($total == 0)
1007
-            {
1202
+            } elseif($total == 0) {
1008 1203
                 $assets_path = MODX_BASE_PATH.'assets/';
1009
-                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
1010
-                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1011
-                elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
1012
-                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1013
-                elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
1014
-                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1015
-                else $modifiers_path = false;
1204
+                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) {
1205
+                                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1206
+                } elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) {
1207
+                                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1208
+                } elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) {
1209
+                                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1210
+                } else {
1211
+                    $modifiers_path = false;
1212
+                }
1016 1213
 
1017 1214
                 if($modifiers_path !== false) {
1018 1215
                     $php = @file_get_contents($modifiers_path);
1019 1216
                     $php = trim($php);
1020
-                    if(substr($php,0,5)==='<?php') $php = substr($php,6);
1021
-                    if(substr($php,0,2)==='<?')    $php = substr($php,3);
1022
-                    if(substr($php,-2)==='?>')     $php = substr($php,0,-2);
1023
-                    if($this->elmName!=='')
1024
-                        $modx->snippetCache[$this->elmName.'Props'] = '';
1025
-                }
1026
-                else
1027
-                    $php = false;
1217
+                    if(substr($php,0,5)==='<?php') {
1218
+                        $php = substr($php,6);
1219
+                    }
1220
+                    if(substr($php,0,2)==='<?') {
1221
+                        $php = substr($php,3);
1222
+                    }
1223
+                    if(substr($php,-2)==='?>') {
1224
+                        $php = substr($php,0,-2);
1225
+                    }
1226
+                    if($this->elmName!=='') {
1227
+                                            $modx->snippetCache[$this->elmName.'Props'] = '';
1228
+                    }
1229
+                } else {
1230
+                                    $php = false;
1231
+                }
1232
+            } else {
1233
+                $php = false;
1234
+            }
1235
+            if($this->elmName!=='') {
1236
+                $modx->snippetCache[$this->elmName]= $php;
1028 1237
             }
1029
-            else $php = false;
1030
-            if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php;
1031 1238
         }
1032
-        if($php==='') $php=false;
1239
+        if($php==='') {
1240
+            $php=false;
1241
+        }
1033 1242
 
1034
-        if($php===false) $html = $modx->getChunk($this->elmName);
1035
-        else             $html = false;
1243
+        if($php===false) {
1244
+            $html = $modx->getChunk($this->elmName);
1245
+        } else {
1246
+            $html = false;
1247
+        }
1036 1248
 
1037 1249
         $self = '[+output+]';
1038 1250
 
1039
-        if($php !== false)
1040
-        {
1251
+        if($php !== false) {
1041 1252
             ob_start();
1042 1253
             $options = $opt;
1043 1254
             $output = $value;
@@ -1049,19 +1260,19 @@  discard block
 block discarded – undo
1049 1260
             $this->vars['options'] = & $opt;
1050 1261
             $custom = eval($php);
1051 1262
             $msg = ob_get_contents();
1052
-            if($value===$this->bt) $value = $msg . $custom;
1263
+            if($value===$this->bt) {
1264
+                $value = $msg . $custom;
1265
+            }
1053 1266
             ob_end_clean();
1054
-        }
1055
-        elseif($html!==false && isset($value) && $value!=='')
1056
-        {
1267
+        } elseif($html!==false && isset($value) && $value!=='') {
1057 1268
             $html = str_replace(array($self,'[+value+]'), $value, $html);
1058 1269
             $value = str_replace(array('[+options+]','[+param+]'), $opt, $html);
1270
+        } else {
1271
+            return false;
1059 1272
         }
1060
-        else return false;
1061 1273
 
1062 1274
         if($php===false && $html===false && $value!==''
1063
-           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false))
1064
-        {
1275
+           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) {
1065 1276
             $value = str_replace(array('[+value+]',$self),$value,$cmd);
1066 1277
         }
1067 1278
         return $value;
@@ -1071,23 +1282,39 @@  discard block
 block discarded – undo
1071 1282
     {
1072 1283
         $modx = DocumentParser::getInstance();
1073 1284
 
1074
-        if(strpos($content,'[')===false && strpos($content,'{')===false) return $content;
1285
+        if(strpos($content,'[')===false && strpos($content,'{')===false) {
1286
+            return $content;
1287
+        }
1075 1288
 
1076
-        if(!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1289
+        if(!$modx->maxParserPasses) {
1290
+            $modx->maxParserPasses = 10;
1291
+        }
1077 1292
         $bt='';
1078 1293
         $i=0;
1079
-        while($bt!==$content)
1080
-        {
1294
+        while($bt!==$content) {
1081 1295
             $bt = $content;
1082
-            if(strpos($content,'[*')!==false && $modx->documentIdentifier)
1083
-                                              $content = $modx->mergeDocumentContent($content);
1084
-            if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content);
1085
-            if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content);
1086
-            if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1087
-            if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content);
1088
-
1089
-            if($content===$bt)              break;
1090
-            if($modx->maxParserPasses < $i) break;
1296
+            if(strpos($content,'[*')!==false && $modx->documentIdentifier) {
1297
+                                                          $content = $modx->mergeDocumentContent($content);
1298
+            }
1299
+            if(strpos($content,'[(')!==false) {
1300
+                $content = $modx->mergeSettingsContent($content);
1301
+            }
1302
+            if(strpos($content,'{{')!==false) {
1303
+                $content = $modx->mergeChunkContent($content);
1304
+            }
1305
+            if(strpos($content,'[!')!==false) {
1306
+                $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1307
+            }
1308
+            if(strpos($content,'[[')!==false) {
1309
+                $content = $modx->evalSnippets($content);
1310
+            }
1311
+
1312
+            if($content===$bt) {
1313
+                break;
1314
+            }
1315
+            if($modx->maxParserPasses < $i) {
1316
+                break;
1317
+            }
1091 1318
             $i++;
1092 1319
         }
1093 1320
         return $content;
@@ -1098,103 +1325,138 @@  discard block
 block discarded – undo
1098 1325
         $modx = DocumentParser::getInstance();
1099 1326
 
1100 1327
         $target = trim($target);
1101
-        if(empty($target)) $target = $modx->config['site_start'];
1102
-        if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id';
1103
-        else $method = 'alias';
1328
+        if(empty($target)) {
1329
+            $target = $modx->config['site_start'];
1330
+        }
1331
+        if(preg_match('@^[1-9][0-9]*$@',$target)) {
1332
+            $method='id';
1333
+        } else {
1334
+            $method = 'alias';
1335
+        }
1104 1336
 
1105
-        if(!isset($this->documentObject[$target]))
1106
-        {
1337
+        if(!isset($this->documentObject[$target])) {
1107 1338
             $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct');
1108 1339
         }
1109 1340
 
1110
-        if($this->documentObject[$target]['publishedon']==='0')
1111
-            return '';
1112
-        elseif(isset($this->documentObject[$target][$field]))
1113
-        {
1114
-            if(is_array($this->documentObject[$target][$field]))
1115
-            {
1341
+        if($this->documentObject[$target]['publishedon']==='0') {
1342
+                    return '';
1343
+        } elseif(isset($this->documentObject[$target][$field])) {
1344
+            if(is_array($this->documentObject[$target][$field])) {
1116 1345
                 $a = $modx->getTemplateVarOutput($field,$target);
1117 1346
                 $this->documentObject[$target][$field] = $a[$field];
1118 1347
             }
1348
+        } else {
1349
+            $this->documentObject[$target][$field] = false;
1119 1350
         }
1120
-        else $this->documentObject[$target][$field] = false;
1121 1351
 
1122 1352
         return $this->documentObject[$target][$field];
1123 1353
     }
1124 1354
 
1125
-    public function setPlaceholders($value = '', $key = '', $path = '') {
1126
-        if($path!=='') $key = "{$path}.{$key}";
1355
+    public function setPlaceholders($value = '', $key = '', $path = '')
1356
+    {
1357
+        if($path!=='') {
1358
+            $key = "{$path}.{$key}";
1359
+        }
1127 1360
         if (is_array($value)) {
1128 1361
             foreach ($value as $subkey => $subval) {
1129 1362
                 $this->setPlaceholders($subval, $subkey, $key);
1130 1363
             }
1364
+        } else {
1365
+            $this->setModifiersVariable($key, $value);
1131 1366
         }
1132
-        else $this->setModifiersVariable($key, $value);
1133 1367
     }
1134 1368
 
1135 1369
     // Sets a placeholder variable which can only be access by Modifiers
1136
-    public function setModifiersVariable($key, $value) {
1137
-        if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1370
+    public function setModifiersVariable($key, $value)
1371
+    {
1372
+        if ($key != 'phx' && $key != 'dummy') {
1373
+            $this->placeholders[$key] = $value;
1374
+        }
1138 1375
     }
1139 1376
 
1140 1377
     //mbstring
1141
-    public function substr($str, $s, $l = null) {
1378
+    public function substr($str, $s, $l = null)
1379
+    {
1142 1380
         $modx = DocumentParser::getInstance();
1143
-        if(is_null($l)) $l = $this->strlen($str);
1144
-        if (function_exists('mb_substr'))
1145
-        {
1146
-            if(strpos($str,"\r")!==false)
1147
-                $str = str_replace(array("\r\n","\r"), "\n", $str);
1381
+        if(is_null($l)) {
1382
+            $l = $this->strlen($str);
1383
+        }
1384
+        if (function_exists('mb_substr')) {
1385
+            if(strpos($str,"\r")!==false) {
1386
+                            $str = str_replace(array("\r\n","\r"), "\n", $str);
1387
+            }
1148 1388
             return mb_substr($str, $s, $l, $modx->config['modx_charset']);
1149 1389
         }
1150 1390
         return substr($str, $s, $l);
1151 1391
     }
1152
-    public function strpos($haystack,$needle,$offset=0) {
1392
+    public function strpos($haystack,$needle,$offset=0)
1393
+    {
1153 1394
         $modx = DocumentParser::getInstance();
1154
-        if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1395
+        if (function_exists('mb_strpos')) {
1396
+            return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1397
+        }
1155 1398
         return strpos($haystack,$needle,$offset);
1156 1399
     }
1157
-    public function strlen($str) {
1400
+    public function strlen($str)
1401
+    {
1158 1402
         $modx = DocumentParser::getInstance();
1159
-        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1403
+        if (function_exists('mb_strlen')) {
1404
+            return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1405
+        }
1160 1406
         return strlen($str);
1161 1407
     }
1162
-    public function strtolower($str) {
1163
-        if (function_exists('mb_strtolower')) return mb_strtolower($str);
1408
+    public function strtolower($str)
1409
+    {
1410
+        if (function_exists('mb_strtolower')) {
1411
+            return mb_strtolower($str);
1412
+        }
1164 1413
         return strtolower($str);
1165 1414
     }
1166
-    public function strtoupper($str) {
1167
-        if (function_exists('mb_strtoupper')) return mb_strtoupper($str);
1415
+    public function strtoupper($str)
1416
+    {
1417
+        if (function_exists('mb_strtoupper')) {
1418
+            return mb_strtoupper($str);
1419
+        }
1168 1420
         return strtoupper($str);
1169 1421
     }
1170
-    public function ucfirst($str) {
1171
-        if (function_exists('mb_strtoupper'))
1172
-            return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1422
+    public function ucfirst($str)
1423
+    {
1424
+        if (function_exists('mb_strtoupper')) {
1425
+                    return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1426
+        }
1173 1427
         return ucfirst($str);
1174 1428
     }
1175
-    public function lcfirst($str) {
1176
-        if (function_exists('mb_strtolower'))
1177
-            return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1429
+    public function lcfirst($str)
1430
+    {
1431
+        if (function_exists('mb_strtolower')) {
1432
+                    return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1433
+        }
1178 1434
         return lcfirst($str);
1179 1435
     }
1180
-    public function ucwords($str) {
1181
-        if (function_exists('mb_convert_case'))
1182
-            return mb_convert_case($str, MB_CASE_TITLE);
1436
+    public function ucwords($str)
1437
+    {
1438
+        if (function_exists('mb_convert_case')) {
1439
+                    return mb_convert_case($str, MB_CASE_TITLE);
1440
+        }
1183 1441
         return ucwords($str);
1184 1442
     }
1185
-    public function strrev($str) {
1443
+    public function strrev($str)
1444
+    {
1186 1445
         preg_match_all('/./us', $str, $ar);
1187 1446
         return implode(array_reverse($ar[0]));
1188 1447
     }
1189
-    public function str_shuffle($str) {
1448
+    public function str_shuffle($str)
1449
+    {
1190 1450
         preg_match_all('/./us', $str, $ar);
1191 1451
         shuffle($ar[0]);
1192 1452
         return implode($ar[0]);
1193 1453
     }
1194
-    public function str_word_count($str) {
1454
+    public function str_word_count($str)
1455
+    {
1195 1456
         return count(preg_split('~[^\p{L}\p{N}\']+~u',$str));
1196 1457
     }
1197
-    public function strip_tags($value,$params='') {
1458
+    public function strip_tags($value,$params='')
1459
+    {
1198 1460
         $modx = DocumentParser::getInstance();
1199 1461
 
1200 1462
         if(stripos($params,'style')===false && stripos($value,'</style>')!==false) {
Please login to merge, or discard this patch.
manager/processors/move_document.processor.php 3 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('edit_document')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0;
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
 // check user has permission to move document to chosen location
26 26
 
27 27
 if ($use_udperms == 1) {
28
-	if ($oldparent != $newParentID) {
29
-		include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
30
-		$udperms = new udperms();
31
-		$udperms->user = $modx->getLoginUserID();
32
-		$udperms->document = $newParentID;
33
-		$udperms->role = $_SESSION['mgrRole'];
34
-
35
-		 if (!$udperms->checkPermissions()) {
36
-			$modx->webAlertAndQuit($_lang["access_permission_parent_denied"]);
37
-		 }
38
-	}
28
+    if ($oldparent != $newParentID) {
29
+        include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
30
+        $udperms = new udperms();
31
+        $udperms->user = $modx->getLoginUserID();
32
+        $udperms->document = $newParentID;
33
+        $udperms->role = $_SESSION['mgrRole'];
34
+
35
+            if (!$udperms->checkPermissions()) {
36
+            $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]);
37
+            }
38
+    }
39 39
 }
40 40
 
41 41
 /**
@@ -43,67 +43,67 @@  discard block
 block discarded – undo
43 43
  * @return array
44 44
  */
45 45
 function allChildren($currDocID) {
46
-	$modx = DocumentParser::getInstance();
47
-	$children= array();
48
-	$currDocID = $modx->db->escape($currDocID);
49
-	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'");
50
-	while ($child= $modx->db->getRow($rs)) {
51
-		$children[]= $child['id'];
52
-		$children= array_merge($children, allChildren($child['id']));
53
-	}
54
-	return $children;
46
+    $modx = DocumentParser::getInstance();
47
+    $children= array();
48
+    $currDocID = $modx->db->escape($currDocID);
49
+    $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'");
50
+    while ($child= $modx->db->getRow($rs)) {
51
+        $children[]= $child['id'];
52
+        $children= array_merge($children, allChildren($child['id']));
53
+    }
54
+    return $children;
55 55
 }
56 56
 
57 57
 $evtOut = $modx->invokeEvent("onBeforeMoveDocument", array (
58
-	"id_document" => $documentID,
59
-	"old_parent" => $oldparent,
60
-	"new_parent" => $newParentID
58
+    "id_document" => $documentID,
59
+    "old_parent" => $oldparent,
60
+    "new_parent" => $newParentID
61 61
 ));
62 62
 if (is_array($evtOut) && count($evtOut) > 0){
63
-	$newParent = array_pop($evtOut);
64
-	if($newParent == $oldparent) {
65
-		$modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
-	}else{
67
-		$newParentID = $newParent;
68
-	}
63
+    $newParent = array_pop($evtOut);
64
+    if($newParent == $oldparent) {
65
+        $modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
+    }else{
67
+        $newParentID = $newParent;
68
+    }
69 69
 }
70 70
 
71 71
 $children = allChildren($documentID);
72 72
 if (!array_search($newParentID, $children)) {
73
-	$modx->db->update(array(
74
-		'isfolder' => 1,
75
-	), $modx->getFullTableName('site_content'), "id='{$newParentID}'");
76
-
77
-	$modx->db->update(array(
78
-		'parent'   => $newParentID,
79
-		'editedby' => $modx->getLoginUserID(),
80
-		'editedon' => time(),
81
-	), $modx->getFullTableName('site_content'), "id='{$documentID}'");
82
-
83
-	// finished moving the document, now check to see if the old_parent should no longer be a folder.
84
-	$rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'");
85
-	$limit = $modx->db->getValue($rs);
86
-
87
-	if(!$limit>0) {
88
-		$modx->db->update(array(
89
-			'isfolder' => 0,
90
-		), $modx->getFullTableName('site_content'), "id='{$oldparent}'");
91
-	}
92
-	// Set the item name for logger
93
-	$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'"));
94
-	$_SESSION['itemname'] = $pagetitle;
95
-
96
-	$modx->invokeEvent("onAfterMoveDocument", array (
97
-		"id_document" => $documentID,
98
-		"old_parent" => $oldparent,
99
-		"new_parent" => $newParentID
100
-	));
101
-
102
-	// empty cache & sync site
103
-	$modx->clearCache('full');
104
-
105
-	$header="Location: index.php?a=3&id={$documentID}&r=9";
106
-	header($header);
73
+    $modx->db->update(array(
74
+        'isfolder' => 1,
75
+    ), $modx->getFullTableName('site_content'), "id='{$newParentID}'");
76
+
77
+    $modx->db->update(array(
78
+        'parent'   => $newParentID,
79
+        'editedby' => $modx->getLoginUserID(),
80
+        'editedon' => time(),
81
+    ), $modx->getFullTableName('site_content'), "id='{$documentID}'");
82
+
83
+    // finished moving the document, now check to see if the old_parent should no longer be a folder.
84
+    $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'");
85
+    $limit = $modx->db->getValue($rs);
86
+
87
+    if(!$limit>0) {
88
+        $modx->db->update(array(
89
+            'isfolder' => 0,
90
+        ), $modx->getFullTableName('site_content'), "id='{$oldparent}'");
91
+    }
92
+    // Set the item name for logger
93
+    $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'"));
94
+    $_SESSION['itemname'] = $pagetitle;
95
+
96
+    $modx->invokeEvent("onAfterMoveDocument", array (
97
+        "id_document" => $documentID,
98
+        "old_parent" => $oldparent,
99
+        "new_parent" => $newParentID
100
+    ));
101
+
102
+    // empty cache & sync site
103
+    $modx->clearCache('full');
104
+
105
+    $header="Location: index.php?a=3&id={$documentID}&r=9";
106
+    header($header);
107 107
 } else {
108
-	$modx->webAlertAndQuit("You cannot move a document to a child document!");
108
+    $modx->webAlertAndQuit("You cannot move a document to a child document!");
109 109
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('edit_document')) {
5
+if (!$modx->hasPermission('edit_document')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0;
10
-$documentID = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
9
+$newParentID = isset($_REQUEST['new_parent']) ? (int) $_REQUEST['new_parent'] : 0;
10
+$documentID = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
11 11
 
12 12
 // ok, two things to check.
13 13
 // first, document cannot be moved to itself
14 14
 // second, new parent must be a folder. If not, set it to folder.
15
-if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]);
16
-if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
17
-if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
15
+if ($documentID == $newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]);
16
+if ($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
17
+if ($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
18 18
 
19 19
 $parents = $modx->getParentIds($newParentID);
20 20
 if (in_array($documentID, $parents))  $modx->webAlertAndQuit($_lang["error_movedocument2"]);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 if ($use_udperms == 1) {
28 28
 	if ($oldparent != $newParentID) {
29
-		include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
29
+		include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
30 30
 		$udperms = new udperms();
31 31
 		$udperms->user = $modx->getLoginUserID();
32 32
 		$udperms->document = $newParentID;
@@ -42,28 +42,28 @@  discard block
 block discarded – undo
42 42
  * @param int $currDocID
43 43
  * @return array
44 44
  */
45
-function allChildren($currDocID) {
45
+function allChildren($currDocID){
46 46
 	$modx = DocumentParser::getInstance();
47
-	$children= array();
47
+	$children = array();
48 48
 	$currDocID = $modx->db->escape($currDocID);
49 49
 	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'");
50
-	while ($child= $modx->db->getRow($rs)) {
51
-		$children[]= $child['id'];
52
-		$children= array_merge($children, allChildren($child['id']));
50
+	while ($child = $modx->db->getRow($rs)) {
51
+		$children[] = $child['id'];
52
+		$children = array_merge($children, allChildren($child['id']));
53 53
 	}
54 54
 	return $children;
55 55
 }
56 56
 
57
-$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array (
57
+$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array(
58 58
 	"id_document" => $documentID,
59 59
 	"old_parent" => $oldparent,
60 60
 	"new_parent" => $newParentID
61 61
 ));
62
-if (is_array($evtOut) && count($evtOut) > 0){
62
+if (is_array($evtOut) && count($evtOut) > 0) {
63 63
 	$newParent = array_pop($evtOut);
64
-	if($newParent == $oldparent) {
64
+	if ($newParent == $oldparent) {
65 65
 		$modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
-	}else{
66
+	} else {
67 67
 		$newParentID = $newParent;
68 68
 	}
69 69
 }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	$rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'");
85 85
 	$limit = $modx->db->getValue($rs);
86 86
 
87
-	if(!$limit>0) {
87
+	if (!$limit > 0) {
88 88
 		$modx->db->update(array(
89 89
 			'isfolder' => 0,
90 90
 		), $modx->getFullTableName('site_content'), "id='{$oldparent}'");
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'"));
94 94
 	$_SESSION['itemname'] = $pagetitle;
95 95
 
96
-	$modx->invokeEvent("onAfterMoveDocument", array (
96
+	$modx->invokeEvent("onAfterMoveDocument", array(
97 97
 		"id_document" => $documentID,
98 98
 		"old_parent" => $oldparent,
99 99
 		"new_parent" => $newParentID
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	// empty cache & sync site
103 103
 	$modx->clearCache('full');
104 104
 
105
-	$header="Location: index.php?a=3&id={$documentID}&r=9";
105
+	$header = "Location: index.php?a=3&id={$documentID}&r=9";
106 106
 	header($header);
107 107
 } else {
108 108
 	$modx->webAlertAndQuit("You cannot move a document to a child document!");
Please login to merge, or discard this patch.
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,12 +12,20 @@  discard block
 block discarded – undo
12 12
 // ok, two things to check.
13 13
 // first, document cannot be moved to itself
14 14
 // second, new parent must be a folder. If not, set it to folder.
15
-if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]);
16
-if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
17
-if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
15
+if($documentID==$newParentID) {
16
+    $modx->webAlertAndQuit($_lang["error_movedocument1"]);
17
+}
18
+if($documentID <= 0) {
19
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
20
+}
21
+if($newParentID < 0) {
22
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
23
+}
18 24
 
19 25
 $parents = $modx->getParentIds($newParentID);
20
-if (in_array($documentID, $parents))  $modx->webAlertAndQuit($_lang["error_movedocument2"]);
26
+if (in_array($documentID, $parents)) {
27
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
28
+}
21 29
 
22 30
 $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'");
23 31
 $oldparent = $modx->db->getValue($rs);
@@ -42,7 +50,8 @@  discard block
 block discarded – undo
42 50
  * @param int $currDocID
43 51
  * @return array
44 52
  */
45
-function allChildren($currDocID) {
53
+function allChildren($currDocID)
54
+{
46 55
 	$modx = DocumentParser::getInstance();
47 56
 	$children= array();
48 57
 	$currDocID = $modx->db->escape($currDocID);
@@ -59,11 +68,11 @@  discard block
 block discarded – undo
59 68
 	"old_parent" => $oldparent,
60 69
 	"new_parent" => $newParentID
61 70
 ));
62
-if (is_array($evtOut) && count($evtOut) > 0){
71
+if (is_array($evtOut) && count($evtOut) > 0) {
63 72
 	$newParent = array_pop($evtOut);
64 73
 	if($newParent == $oldparent) {
65 74
 		$modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
-	}else{
75
+	} else {
67 76
 		$newParentID = $newParent;
68 77
 	}
69 78
 }
Please login to merge, or discard this patch.
manager/processors/save_plugin.processor.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.');
4 4
 }
5 5
 if (!$modx->hasPermission('save_plugin')) {
6 6
     $modx->webAlertAndQuit($_lang['error_no_privileges']);
7 7
 }
8 8
 
9
-$id = (int)$_POST['id'];
9
+$id = (int) $_POST['id'];
10 10
 $name = $modx->db->escape(trim($_POST['name']));
11 11
 $description = $modx->db->escape($_POST['description']);
12 12
 $locked = $_POST['locked'] == 'on' ? '1' : '0';
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
 
21 21
 //Kyle Jaebker - added category support
22 22
 if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
23
-    $categoryid = (int)$_POST['categoryid'];
23
+    $categoryid = (int) $_POST['categoryid'];
24 24
 } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
25 25
     $categoryid = 0;
26 26
 } else {
27
-    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
27
+    include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
28 28
     $categoryid = getCategory($_POST['newcategory']);
29 29
 }
30 30
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
     $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid;
41 41
 
42 42
     $description = isset($parsed['description']) ? $parsed['description'] : $description;
43
-    $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : '';
43
+    $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : '';
44 44
     if ($version) {
45
-        $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
45
+        $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
46 46
     }
47 47
     if (isset($parsed['modx_category'])) {
48
-        include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
48
+        include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
49 49
         $categoryid = getCategory($parsed['modx_category']);
50 50
     }
51 51
 }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         // finished emptying cache - redirect
104 104
         if ($_POST['stay'] != '') {
105 105
             $a = ($_POST['stay'] == '2') ? "102&id=$newid" : '101';
106
-            $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay'];
106
+            $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay'];
107 107
             header($header);
108 108
         } else {
109 109
             $header = 'Location: index.php?a=76&r=2';
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         // finished emptying cache - redirect
159 159
         if ($_POST['stay'] != '') {
160 160
             $a = ($_POST['stay'] == '2') ? "102&id=$id" : '101';
161
-            $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay'];
161
+            $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay'];
162 162
             header($header);
163 163
         } else {
164 164
             $modx->unlockElement(5, $id);
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     // save selected system events
178 178
     $formEventList = array();
179 179
     foreach ($sysevents as $evtId) {
180
-        if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId);
180
+        if (!preg_match('@^[1-9][0-9]*$@', $evtId)) $evtId = getEventIdByName($evtId);
181 181
         if ($mode == '101') {
182 182
             $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'");
183 183
         } else {
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
     $rs = $modx->db->select('*', '[+prefix+]site_plugin_events', sprintf("pluginid='%s'", $id));
203 203
     $dbEventList = array();
204 204
     $del = array();
205
-    while($row = $modx->db->getRow($rs)) {
206
-        if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid'];
205
+    while ($row = $modx->db->getRow($rs)) {
206
+        if (!in_array($row['evtid'], $evtids)) $del[] = $row['evtid'];
207 207
     }
208 208
 
209
-    if(empty($del)) return;
209
+    if (empty($del)) return;
210 210
 
211
-    foreach($del as $delid) {
211
+    foreach ($del as $delid) {
212 212
         $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id));
213 213
     }
214 214
 }
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 function getEventIdByName($name)
221 221
 {
222 222
     $modx = DocumentParser::getInstance();
223
-    static $eventIds=array();
223
+    static $eventIds = array();
224 224
 
225
-    if(isset($eventIds[$name])) return $eventIds[$name];
225
+    if (isset($eventIds[$name])) return $eventIds[$name];
226 226
 
227 227
     $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames');
228 228
     while ($row = $modx->db->getRow($rs)) {
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -177,7 +177,9 @@  discard block
 block discarded – undo
177 177
     // save selected system events
178 178
     $formEventList = array();
179 179
     foreach ($sysevents as $evtId) {
180
-        if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId);
180
+        if(!preg_match('@^[1-9][0-9]*$@',$evtId)) {
181
+            $evtId = getEventIdByName($evtId);
182
+        }
181 183
         if ($mode == '101') {
182 184
             $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'");
183 185
         } else {
@@ -203,10 +205,14 @@  discard block
 block discarded – undo
203 205
     $dbEventList = array();
204 206
     $del = array();
205 207
     while($row = $modx->db->getRow($rs)) {
206
-        if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid'];
208
+        if(!in_array($row['evtid'], $evtids)) {
209
+            $del[] = $row['evtid'];
210
+        }
207 211
     }
208 212
 
209
-    if(empty($del)) return;
213
+    if(empty($del)) {
214
+        return;
215
+    }
210 216
 
211 217
     foreach($del as $delid) {
212 218
         $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id));
@@ -222,7 +228,9 @@  discard block
 block discarded – undo
222 228
     $modx = DocumentParser::getInstance();
223 229
     static $eventIds=array();
224 230
 
225
-    if(isset($eventIds[$name])) return $eventIds[$name];
231
+    if(isset($eventIds[$name])) {
232
+        return $eventIds[$name];
233
+    }
226 234
 
227 235
     $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames');
228 236
     while ($row = $modx->db->getRow($rs)) {
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 3 patches
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+    die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('save_web_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $tbl_web_users = $modx->getFullTableName('web_users');
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 $input = $_POST;
14 14
 foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
16
-		$v = sanitize($v);
17
-	}
18
-	$input[$k] = $v;
15
+    if($k !== 'comment') {
16
+        $v = sanitize($v);
17
+    }
18
+    $input[$k] = $v;
19 19
 }
20 20
 
21 21
 $id = (int)$input['id'];
@@ -51,80 +51,80 @@  discard block
 block discarded – undo
51 51
 
52 52
 // verify password
53 53
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54
-	webAlertAndQuit("Password typed is mismatched");
54
+    webAlertAndQuit("Password typed is mismatched");
55 55
 }
56 56
 
57 57
 // verify email
58 58
 if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59
-	webAlertAndQuit("E-mail address doesn't seem to be valid!");
59
+    webAlertAndQuit("E-mail address doesn't seem to be valid!");
60 60
 }
61 61
 
62 62
 switch($input['mode']) {
63
-	case '87' : // new user
64
-		// check if this user name already exist
65
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
-		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
68
-			webAlertAndQuit("User name is already in use!");
69
-		}
70
-
71
-		// check if the email address already exist
72
-		$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
-		$limit = $modx->db->getValue($rs);
74
-		if($limit > 0) {
75
-			webAlertAndQuit("Email is already in use!");
76
-		}
77
-
78
-		// generate a new password for this user
79
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
-			if(strlen($specifiedpassword) < 6) {
81
-				webAlertAndQuit("Password is too short!");
82
-			} else {
83
-				$newpassword = $specifiedpassword;
84
-			}
85
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
-			webAlertAndQuit("You didn't specify a password for this user!");
87
-		} elseif($passwordgenmethod == 'g') {
88
-			$newpassword = generate_password(8);
89
-		} else {
90
-			webAlertAndQuit("No password generation method specified!");
91
-		}
92
-
93
-		// invoke OnBeforeWUsrFormSave event
94
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
-			"mode" => "new",
96
-		));
97
-
98
-		// create the user account
99
-		$field = array();
100
-		$field['username'] = $esc_newusername;
101
-		$field['password'] = md5($newpassword);
102
-		$internalKey = $modx->db->insert($field, $tbl_web_users);
103
-
104
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
-		$field = $modx->db->escape($field);
106
-		$modx->db->insert($field, $tbl_web_user_attributes);
107
-
108
-		// Save User Settings
109
-		saveUserSettings($internalKey);
110
-
111
-		// Set the item name for logger
112
-		$_SESSION['itemname'] = $newusername;
113
-
114
-		/*******************************************************************************/
115
-		// put the user in the user_groups he/ she should be in
116
-		// first, check that up_perms are switched on!
117
-		if($use_udperms == 1) {
118
-			if(!empty($user_groups)) {
119
-				for($i = 0; $i < count($user_groups); $i++) {
120
-					$f = array();
121
-					$f['webgroup'] = (int)$user_groups[$i];
122
-					$f['webuser'] = $internalKey;
123
-					$modx->db->insert($f, $tbl_web_groups);
124
-				}
125
-			}
126
-		}
127
-		// end of user_groups stuff!
63
+    case '87' : // new user
64
+        // check if this user name already exist
65
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
+        $limit = $modx->db->getValue($rs);
67
+        if($limit > 0) {
68
+            webAlertAndQuit("User name is already in use!");
69
+        }
70
+
71
+        // check if the email address already exist
72
+        $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
+        $limit = $modx->db->getValue($rs);
74
+        if($limit > 0) {
75
+            webAlertAndQuit("Email is already in use!");
76
+        }
77
+
78
+        // generate a new password for this user
79
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
+            if(strlen($specifiedpassword) < 6) {
81
+                webAlertAndQuit("Password is too short!");
82
+            } else {
83
+                $newpassword = $specifiedpassword;
84
+            }
85
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
+            webAlertAndQuit("You didn't specify a password for this user!");
87
+        } elseif($passwordgenmethod == 'g') {
88
+            $newpassword = generate_password(8);
89
+        } else {
90
+            webAlertAndQuit("No password generation method specified!");
91
+        }
92
+
93
+        // invoke OnBeforeWUsrFormSave event
94
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
+            "mode" => "new",
96
+        ));
97
+
98
+        // create the user account
99
+        $field = array();
100
+        $field['username'] = $esc_newusername;
101
+        $field['password'] = md5($newpassword);
102
+        $internalKey = $modx->db->insert($field, $tbl_web_users);
103
+
104
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
+        $field = $modx->db->escape($field);
106
+        $modx->db->insert($field, $tbl_web_user_attributes);
107
+
108
+        // Save User Settings
109
+        saveUserSettings($internalKey);
110
+
111
+        // Set the item name for logger
112
+        $_SESSION['itemname'] = $newusername;
113
+
114
+        /*******************************************************************************/
115
+        // put the user in the user_groups he/ she should be in
116
+        // first, check that up_perms are switched on!
117
+        if($use_udperms == 1) {
118
+            if(!empty($user_groups)) {
119
+                for($i = 0; $i < count($user_groups); $i++) {
120
+                    $f = array();
121
+                    $f['webgroup'] = (int)$user_groups[$i];
122
+                    $f['webuser'] = $internalKey;
123
+                    $modx->db->insert($f, $tbl_web_groups);
124
+                }
125
+            }
126
+        }
127
+        // end of user_groups stuff!
128 128
 
129 129
         // invoke OnWebSaveUser event
130 130
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -142,26 +142,26 @@  discard block
 block discarded – undo
142 142
             "id" => $internalKey
143 143
         ));
144 144
 
145
-		if($passwordnotifymethod == 'e') {
146
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
147
-			if($input['stay'] != '') {
148
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
-				header($header);
151
-			} else {
152
-				$header = "Location: index.php?a=99&r=2";
153
-				header($header);
154
-			}
155
-		} else {
156
-			if($input['stay'] != '') {
157
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
-			} else {
160
-				$stayUrl = "index.php?a=99&r=2";
161
-			}
162
-
163
-			include_once "header.inc.php";
164
-			?>
145
+        if($passwordnotifymethod == 'e') {
146
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
147
+            if($input['stay'] != '') {
148
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
+                header($header);
151
+            } else {
152
+                $header = "Location: index.php?a=99&r=2";
153
+                header($header);
154
+            }
155
+        } else {
156
+            if($input['stay'] != '') {
157
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
+            } else {
160
+                $stayUrl = "index.php?a=99&r=2";
161
+            }
162
+
163
+            include_once "header.inc.php";
164
+            ?>
165 165
 
166 166
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
167 167
 
@@ -183,84 +183,84 @@  discard block
 block discarded – undo
183 183
 			</div>
184 184
 			<?php
185 185
 
186
-			include_once "footer.inc.php";
187
-		}
188
-		break;
189
-	case '88' : // edit user
190
-		// generate a new password for this user
191
-		if($genpassword == 1) {
192
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
-				if(strlen($specifiedpassword) < 6) {
194
-					webAlertAndQuit("Password is too short!");
195
-				} else {
196
-					$newpassword = $specifiedpassword;
197
-				}
198
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
-				webAlertAndQuit("You didn't specify a password for this user!");
200
-			} elseif($passwordgenmethod == 'g') {
201
-				$newpassword = generate_password(8);
202
-			} else {
203
-				webAlertAndQuit("No password generation method specified!");
204
-			}
205
-		}
206
-		if($passwordnotifymethod == 'e') {
207
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
208
-		}
209
-
210
-		// check if the username already exist
211
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
-		$limit = $modx->db->getValue($rs);
213
-		if($limit > 0) {
214
-			webAlertAndQuit("User name is already in use!");
215
-		}
216
-
217
-		// check if the email address already exists
218
-		$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
-		$limit = $modx->db->getValue($rs);
220
-		if($limit > 0) {
221
-			webAlertAndQuit("Email is already in use!");
222
-		}
223
-
224
-		// invoke OnBeforeWUsrFormSave event
225
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
-			"mode" => "upd",
227
-			"id" => $id
228
-		));
229
-
230
-		// update user name and password
231
-		$field = array();
232
-		$field['username'] = $esc_newusername;
233
-		if($genpassword == 1) {
234
-			$field['password'] = md5($newpassword);
235
-		}
236
-		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
-		$field = $modx->db->escape($field);
239
-		$modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
-
241
-		// Save User Settings
242
-		saveUserSettings($id);
243
-
244
-		// Set the item name for logger
245
-		$_SESSION['itemname'] = $newusername;
246
-
247
-		/*******************************************************************************/
248
-		// put the user in the user_groups he/ she should be in
249
-		// first, check that up_perms are switched on!
250
-		if($use_udperms == 1) {
251
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
-			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
-			if(!empty($user_groups)) {
254
-				for($i = 0; $i < count($user_groups); $i++) {
255
-					$field = array();
256
-					$field['webgroup'] = (int)$user_groups[$i];
257
-					$field['webuser'] = $id;
258
-					$modx->db->insert($field, $tbl_web_groups);
259
-				}
260
-			}
261
-		}
262
-		// end of user_groups stuff!
263
-		/*******************************************************************************/
186
+            include_once "footer.inc.php";
187
+        }
188
+        break;
189
+    case '88' : // edit user
190
+        // generate a new password for this user
191
+        if($genpassword == 1) {
192
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
+                if(strlen($specifiedpassword) < 6) {
194
+                    webAlertAndQuit("Password is too short!");
195
+                } else {
196
+                    $newpassword = $specifiedpassword;
197
+                }
198
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
+                webAlertAndQuit("You didn't specify a password for this user!");
200
+            } elseif($passwordgenmethod == 'g') {
201
+                $newpassword = generate_password(8);
202
+            } else {
203
+                webAlertAndQuit("No password generation method specified!");
204
+            }
205
+        }
206
+        if($passwordnotifymethod == 'e') {
207
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
208
+        }
209
+
210
+        // check if the username already exist
211
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
+        $limit = $modx->db->getValue($rs);
213
+        if($limit > 0) {
214
+            webAlertAndQuit("User name is already in use!");
215
+        }
216
+
217
+        // check if the email address already exists
218
+        $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
+        $limit = $modx->db->getValue($rs);
220
+        if($limit > 0) {
221
+            webAlertAndQuit("Email is already in use!");
222
+        }
223
+
224
+        // invoke OnBeforeWUsrFormSave event
225
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
+            "mode" => "upd",
227
+            "id" => $id
228
+        ));
229
+
230
+        // update user name and password
231
+        $field = array();
232
+        $field['username'] = $esc_newusername;
233
+        if($genpassword == 1) {
234
+            $field['password'] = md5($newpassword);
235
+        }
236
+        $modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
+        $field = $modx->db->escape($field);
239
+        $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
+
241
+        // Save User Settings
242
+        saveUserSettings($id);
243
+
244
+        // Set the item name for logger
245
+        $_SESSION['itemname'] = $newusername;
246
+
247
+        /*******************************************************************************/
248
+        // put the user in the user_groups he/ she should be in
249
+        // first, check that up_perms are switched on!
250
+        if($use_udperms == 1) {
251
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
+            $modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
+            if(!empty($user_groups)) {
254
+                for($i = 0; $i < count($user_groups); $i++) {
255
+                    $field = array();
256
+                    $field['webgroup'] = (int)$user_groups[$i];
257
+                    $field['webuser'] = $id;
258
+                    $modx->db->insert($field, $tbl_web_groups);
259
+                }
260
+            }
261
+        }
262
+        // end of user_groups stuff!
263
+        /*******************************************************************************/
264 264
 
265 265
         // invoke OnWebSaveUser event
266 266
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -289,16 +289,16 @@  discard block
 block discarded – undo
289 289
             "id" => $id
290 290
         ));
291 291
 
292
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
293
-			if($input['stay'] != '') {
294
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
-			} else {
297
-				$stayUrl = "index.php?a=99&r=2";
298
-			}
292
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
293
+            if($input['stay'] != '') {
294
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
+            } else {
297
+                $stayUrl = "index.php?a=99&r=2";
298
+            }
299 299
 
300
-			include_once "header.inc.php";
301
-			?>
300
+            include_once "header.inc.php";
301
+            ?>
302 302
 
303 303
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
304 304
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 			</div>
319 319
 			<?php
320 320
 
321
-			include_once "footer.inc.php";
322
-		} else {
323
-			if($input['stay'] != '') {
324
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
-				header($header);
327
-			} else {
328
-				$header = "Location: index.php?a=99&r=2";
329
-				header($header);
330
-			}
331
-		}
332
-		break;
333
-	default :
334
-		webAlertAndQuit("No operation set in request.");
321
+            include_once "footer.inc.php";
322
+        } else {
323
+            if($input['stay'] != '') {
324
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
+                header($header);
327
+            } else {
328
+                $header = "Location: index.php?a=99&r=2";
329
+                header($header);
330
+            }
331
+        }
332
+        break;
333
+    default :
334
+        webAlertAndQuit("No operation set in request.");
335 335
 }
336 336
 
337 337
 /**
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
  * @return string
342 342
  */
343 343
 function save_user_quoted_printable($string) {
344
-	$crlf = "\n";
345
-	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
346
-	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
347
-	$r[] = "'=' . sprintf('%02X', ord('\\1'))";
348
-	$f[] = '/([\011\040])' . $crlf . '/e';
349
-	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
350
-	$string = preg_replace($f, $r, $string);
351
-	return trim(wordwrap($string, 70, ' =' . $crlf));
344
+    $crlf = "\n";
345
+    $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
346
+    $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
347
+    $r[] = "'=' . sprintf('%02X', ord('\\1'))";
348
+    $f[] = '/([\011\040])' . $crlf . '/e';
349
+    $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
350
+    $string = preg_replace($f, $r, $string);
351
+    return trim(wordwrap($string, 70, ' =' . $crlf));
352 352
 }
353 353
 
354 354
 /**
@@ -360,94 +360,94 @@  discard block
 block discarded – undo
360 360
  * @param string $ufn
361 361
  */
362 362
 function sendMailMessage($email, $uid, $pwd, $ufn) {
363
-	$modx = DocumentParser::getInstance(); global $_lang, $websignupemail_message;
364
-	global $emailsubject, $emailsender;
365
-	global $site_name, $site_url;
366
-	$message = sprintf($websignupemail_message, $uid, $pwd); // use old method
367
-	// replace placeholders
368
-	$message = str_replace("[+uid+]", $uid, $message);
369
-	$message = str_replace("[+pwd+]", $pwd, $message);
370
-	$message = str_replace("[+ufn+]", $ufn, $message);
371
-	$message = str_replace("[+sname+]", $site_name, $message);
372
-	$message = str_replace("[+saddr+]", $emailsender, $message);
373
-	$message = str_replace("[+semail+]", $emailsender, $message);
374
-	$message = str_replace("[+surl+]", $site_url, $message);
375
-
376
-	$param = array();
377
-	$param['from'] = "{$site_name}<{$emailsender}>";
378
-	$param['subject'] = $emailsubject;
379
-	$param['body'] = $message;
380
-	$param['to'] = $email;
381
-	$param['type'] = 'text';
382
-	$rs = $modx->sendmail($param);
383
-	if(!$rs) {
384
-		$modx->manager->saveFormValues();
385
-		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
386
-	}
363
+    $modx = DocumentParser::getInstance(); global $_lang, $websignupemail_message;
364
+    global $emailsubject, $emailsender;
365
+    global $site_name, $site_url;
366
+    $message = sprintf($websignupemail_message, $uid, $pwd); // use old method
367
+    // replace placeholders
368
+    $message = str_replace("[+uid+]", $uid, $message);
369
+    $message = str_replace("[+pwd+]", $pwd, $message);
370
+    $message = str_replace("[+ufn+]", $ufn, $message);
371
+    $message = str_replace("[+sname+]", $site_name, $message);
372
+    $message = str_replace("[+saddr+]", $emailsender, $message);
373
+    $message = str_replace("[+semail+]", $emailsender, $message);
374
+    $message = str_replace("[+surl+]", $site_url, $message);
375
+
376
+    $param = array();
377
+    $param['from'] = "{$site_name}<{$emailsender}>";
378
+    $param['subject'] = $emailsubject;
379
+    $param['body'] = $message;
380
+    $param['to'] = $email;
381
+    $param['type'] = 'text';
382
+    $rs = $modx->sendmail($param);
383
+    if(!$rs) {
384
+        $modx->manager->saveFormValues();
385
+        $modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
386
+    }
387 387
 }
388 388
 
389 389
 // Save User Settings
390 390
 function saveUserSettings($id) {
391
-	$modx = DocumentParser::getInstance();
392
-	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393
-
394
-	$settings = array(
395
-		"login_home",
396
-		"allowed_ip",
397
-		"allowed_days"
398
-	);
399
-
400
-	$modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
401
-
402
-	foreach($settings as $n) {
403
-		$vl = $_POST[$n];
404
-		if(is_array($vl)) {
405
-			$vl = implode(",", $vl);
406
-		}
407
-		if($vl != '') {
408
-			$f = array();
409
-			$f['webuser'] = $id;
410
-			$f['setting_name'] = $n;
411
-			$f['setting_value'] = $vl;
412
-			$f = $modx->db->escape($f);
413
-			$modx->db->insert($f, $tbl_web_user_settings);
414
-		}
415
-	}
391
+    $modx = DocumentParser::getInstance();
392
+    $tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393
+
394
+    $settings = array(
395
+        "login_home",
396
+        "allowed_ip",
397
+        "allowed_days"
398
+    );
399
+
400
+    $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
401
+
402
+    foreach($settings as $n) {
403
+        $vl = $_POST[$n];
404
+        if(is_array($vl)) {
405
+            $vl = implode(",", $vl);
406
+        }
407
+        if($vl != '') {
408
+            $f = array();
409
+            $f['webuser'] = $id;
410
+            $f['setting_name'] = $n;
411
+            $f['setting_value'] = $vl;
412
+            $f = $modx->db->escape($f);
413
+            $modx->db->insert($f, $tbl_web_user_settings);
414
+        }
415
+    }
416 416
 }
417 417
 
418 418
 // Web alert -  sends an alert to web browser
419 419
 function webAlertAndQuit($msg) {
420
-	global $id, $modx;
421
-	$mode = $_POST['mode'];
422
-	$modx->manager->saveFormValues($mode);
423
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
420
+    global $id, $modx;
421
+    $mode = $_POST['mode'];
422
+    $modx->manager->saveFormValues($mode);
423
+    $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
424 424
 }
425 425
 
426 426
 // Generate password
427 427
 function generate_password($length = 10) {
428
-	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429
-	$ps_len = strlen($allowable_characters);
430
-	mt_srand((double) microtime() * 1000000);
431
-	$pass = "";
432
-	for($i = 0; $i < $length; $i++) {
433
-		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
434
-	}
435
-	return $pass;
428
+    $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429
+    $ps_len = strlen($allowable_characters);
430
+    mt_srand((double) microtime() * 1000000);
431
+    $pass = "";
432
+    for($i = 0; $i < $length; $i++) {
433
+        $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
434
+    }
435
+    return $pass;
436 436
 }
437 437
 
438 438
 function sanitize($str = '', $safecount = 0) {
439
-	$modx = DocumentParser::getInstance();
440
-	$safecount++;
441
-	if(1000 < $safecount) {
442
-		exit("error too many loops '{$safecount}'");
443
-	}
444
-	if(is_array($str)) {
445
-		foreach($str as $i => $v) {
446
-			$str[$i] = sanitize($v, $safecount);
447
-		}
448
-	} else {
449
-		// $str = strip_tags($str); // LEAVE < and > intact
450
-		$str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']);
451
-	}
452
-	return $str;
439
+    $modx = DocumentParser::getInstance();
440
+    $safecount++;
441
+    if(1000 < $safecount) {
442
+        exit("error too many loops '{$safecount}'");
443
+    }
444
+    if(is_array($str)) {
445
+        foreach($str as $i => $v) {
446
+            $str[$i] = sanitize($v, $safecount);
447
+        }
448
+    } else {
449
+        // $str = strip_tags($str); // LEAVE < and > intact
450
+        $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']);
451
+    }
452
+    return $str;
453 453
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
 	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('save_web_user')) {
5
+if (!$modx->hasPermission('save_web_user')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 $tbl_web_groups = $modx->getFullTableName('web_groups');
12 12
 
13 13
 $input = $_POST;
14
-foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
14
+foreach ($input as $k => $v) {
15
+	if ($k !== 'comment') {
16 16
 		$v = sanitize($v);
17 17
 	}
18 18
 	$input[$k] = $v;
19 19
 }
20 20
 
21
-$id = (int)$input['id'];
21
+$id = (int) $input['id'];
22 22
 $oldusername = $input['oldusername'];
23 23
 $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User";
24 24
 $esc_newusername = $modx->db->escape($newusername);
@@ -50,41 +50,41 @@  discard block
 block discarded – undo
50 50
 $user_groups = $input['user_groups'];
51 51
 
52 52
 // verify password
53
-if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
53
+if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54 54
 	webAlertAndQuit("Password typed is mismatched");
55 55
 }
56 56
 
57 57
 // verify email
58
-if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
58
+if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59 59
 	webAlertAndQuit("E-mail address doesn't seem to be valid!");
60 60
 }
61 61
 
62
-switch($input['mode']) {
62
+switch ($input['mode']) {
63 63
 	case '87' : // new user
64 64
 		// check if this user name already exist
65 65
 		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66 66
 		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
67
+		if ($limit > 0) {
68 68
 			webAlertAndQuit("User name is already in use!");
69 69
 		}
70 70
 
71 71
 		// check if the email address already exist
72 72
 		$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73 73
 		$limit = $modx->db->getValue($rs);
74
-		if($limit > 0) {
74
+		if ($limit > 0) {
75 75
 			webAlertAndQuit("Email is already in use!");
76 76
 		}
77 77
 
78 78
 		// generate a new password for this user
79
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
-			if(strlen($specifiedpassword) < 6) {
79
+		if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
+			if (strlen($specifiedpassword) < 6) {
81 81
 				webAlertAndQuit("Password is too short!");
82 82
 			} else {
83 83
 				$newpassword = $specifiedpassword;
84 84
 			}
85
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
85
+		} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
86 86
 			webAlertAndQuit("You didn't specify a password for this user!");
87
-		} elseif($passwordgenmethod == 'g') {
87
+		} elseif ($passwordgenmethod == 'g') {
88 88
 			$newpassword = generate_password(8);
89 89
 		} else {
90 90
 			webAlertAndQuit("No password generation method specified!");
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 		/*******************************************************************************/
115 115
 		// put the user in the user_groups he/ she should be in
116 116
 		// first, check that up_perms are switched on!
117
-		if($use_udperms == 1) {
118
-			if(!empty($user_groups)) {
119
-				for($i = 0; $i < count($user_groups); $i++) {
117
+		if ($use_udperms == 1) {
118
+			if (!empty($user_groups)) {
119
+				for ($i = 0; $i < count($user_groups); $i++) {
120 120
 					$f = array();
121
-					$f['webgroup'] = (int)$user_groups[$i];
121
+					$f['webgroup'] = (int) $user_groups[$i];
122 122
 					$f['webuser'] = $internalKey;
123 123
 					$modx->db->insert($f, $tbl_web_groups);
124 124
 				}
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
             "id" => $internalKey
143 143
         ));
144 144
 
145
-		if($passwordnotifymethod == 'e') {
145
+		if ($passwordnotifymethod == 'e') {
146 146
 			sendMailMessage($email, $newusername, $newpassword, $fullname);
147
-			if($input['stay'] != '') {
147
+			if ($input['stay'] != '') {
148 148
 				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
149
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
150 150
 				header($header);
151 151
 			} else {
152 152
 				$header = "Location: index.php?a=99&r=2";
153 153
 				header($header);
154 154
 			}
155 155
 		} else {
156
-			if($input['stay'] != '') {
156
+			if ($input['stay'] != '') {
157 157
 				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
158
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
159 159
 			} else {
160 160
 				$stayUrl = "index.php?a=99&r=2";
161 161
 			}
@@ -188,36 +188,36 @@  discard block
 block discarded – undo
188 188
 		break;
189 189
 	case '88' : // edit user
190 190
 		// generate a new password for this user
191
-		if($genpassword == 1) {
192
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
-				if(strlen($specifiedpassword) < 6) {
191
+		if ($genpassword == 1) {
192
+			if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
+				if (strlen($specifiedpassword) < 6) {
194 194
 					webAlertAndQuit("Password is too short!");
195 195
 				} else {
196 196
 					$newpassword = $specifiedpassword;
197 197
 				}
198
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
198
+			} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
199 199
 				webAlertAndQuit("You didn't specify a password for this user!");
200
-			} elseif($passwordgenmethod == 'g') {
200
+			} elseif ($passwordgenmethod == 'g') {
201 201
 				$newpassword = generate_password(8);
202 202
 			} else {
203 203
 				webAlertAndQuit("No password generation method specified!");
204 204
 			}
205 205
 		}
206
-		if($passwordnotifymethod == 'e') {
206
+		if ($passwordnotifymethod == 'e') {
207 207
 			sendMailMessage($email, $newusername, $newpassword, $fullname);
208 208
 		}
209 209
 
210 210
 		// check if the username already exist
211 211
 		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212 212
 		$limit = $modx->db->getValue($rs);
213
-		if($limit > 0) {
213
+		if ($limit > 0) {
214 214
 			webAlertAndQuit("User name is already in use!");
215 215
 		}
216 216
 
217 217
 		// check if the email address already exists
218 218
 		$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219 219
 		$limit = $modx->db->getValue($rs);
220
-		if($limit > 0) {
220
+		if ($limit > 0) {
221 221
 			webAlertAndQuit("Email is already in use!");
222 222
 		}
223 223
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		// update user name and password
231 231
 		$field = array();
232 232
 		$field['username'] = $esc_newusername;
233
-		if($genpassword == 1) {
233
+		if ($genpassword == 1) {
234 234
 			$field['password'] = md5($newpassword);
235 235
 		}
236 236
 		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
 		/*******************************************************************************/
248 248
 		// put the user in the user_groups he/ she should be in
249 249
 		// first, check that up_perms are switched on!
250
-		if($use_udperms == 1) {
250
+		if ($use_udperms == 1) {
251 251
 			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
252 252
 			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
-			if(!empty($user_groups)) {
254
-				for($i = 0; $i < count($user_groups); $i++) {
253
+			if (!empty($user_groups)) {
254
+				for ($i = 0; $i < count($user_groups); $i++) {
255 255
 					$field = array();
256
-					$field['webgroup'] = (int)$user_groups[$i];
256
+					$field['webgroup'] = (int) $user_groups[$i];
257 257
 					$field['webuser'] = $id;
258 258
 					$modx->db->insert($field, $tbl_web_groups);
259 259
 				}
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         ));
276 276
 
277 277
         // invoke OnWebChangePassword event
278
-        if($genpassword == 1) {
278
+        if ($genpassword == 1) {
279 279
             $modx->invokeEvent("OnWebChangePassword", array(
280 280
                 "userid" => $id,
281 281
                 "username" => $newusername,
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
             "id" => $id
290 290
         ));
291 291
 
292
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
293
-			if($input['stay'] != '') {
292
+		if ($genpassword == 1 && $passwordnotifymethod == 's') {
293
+			if ($input['stay'] != '') {
294 294
 				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
295
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
296 296
 			} else {
297 297
 				$stayUrl = "index.php?a=99&r=2";
298 298
 			}
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
 
321 321
 			include_once "footer.inc.php";
322 322
 		} else {
323
-			if($input['stay'] != '') {
323
+			if ($input['stay'] != '') {
324 324
 				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
325
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
326 326
 				header($header);
327 327
 			} else {
328 328
 				$header = "Location: index.php?a=99&r=2";
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
  * @param string $string
341 341
  * @return string
342 342
  */
343
-function save_user_quoted_printable($string) {
343
+function save_user_quoted_printable($string){
344 344
 	$crlf = "\n";
345
-	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
345
+	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string).$crlf;
346 346
 	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
347 347
 	$r[] = "'=' . sprintf('%02X', ord('\\1'))";
348
-	$f[] = '/([\011\040])' . $crlf . '/e';
349
-	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
348
+	$f[] = '/([\011\040])'.$crlf.'/e';
349
+	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '".$crlf."'";
350 350
 	$string = preg_replace($f, $r, $string);
351
-	return trim(wordwrap($string, 70, ' =' . $crlf));
351
+	return trim(wordwrap($string, 70, ' ='.$crlf));
352 352
 }
353 353
 
354 354
 /**
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
  * @param string $pwd
360 360
  * @param string $ufn
361 361
  */
362
-function sendMailMessage($email, $uid, $pwd, $ufn) {
362
+function sendMailMessage($email, $uid, $pwd, $ufn){
363 363
 	$modx = DocumentParser::getInstance(); global $_lang, $websignupemail_message;
364 364
 	global $emailsubject, $emailsender;
365 365
 	global $site_name, $site_url;
@@ -380,14 +380,14 @@  discard block
 block discarded – undo
380 380
 	$param['to'] = $email;
381 381
 	$param['type'] = 'text';
382 382
 	$rs = $modx->sendmail($param);
383
-	if(!$rs) {
383
+	if (!$rs) {
384 384
 		$modx->manager->saveFormValues();
385 385
 		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
386 386
 	}
387 387
 }
388 388
 
389 389
 // Save User Settings
390
-function saveUserSettings($id) {
390
+function saveUserSettings($id){
391 391
 	$modx = DocumentParser::getInstance();
392 392
 	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393 393
 
@@ -399,12 +399,12 @@  discard block
 block discarded – undo
399 399
 
400 400
 	$modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
401 401
 
402
-	foreach($settings as $n) {
402
+	foreach ($settings as $n) {
403 403
 		$vl = $_POST[$n];
404
-		if(is_array($vl)) {
404
+		if (is_array($vl)) {
405 405
 			$vl = implode(",", $vl);
406 406
 		}
407
-		if($vl != '') {
407
+		if ($vl != '') {
408 408
 			$f = array();
409 409
 			$f['webuser'] = $id;
410 410
 			$f['setting_name'] = $n;
@@ -416,33 +416,33 @@  discard block
 block discarded – undo
416 416
 }
417 417
 
418 418
 // Web alert -  sends an alert to web browser
419
-function webAlertAndQuit($msg) {
419
+function webAlertAndQuit($msg){
420 420
 	global $id, $modx;
421 421
 	$mode = $_POST['mode'];
422 422
 	$modx->manager->saveFormValues($mode);
423
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
423
+	$modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '88' ? "&id={$id}" : ''));
424 424
 }
425 425
 
426 426
 // Generate password
427
-function generate_password($length = 10) {
427
+function generate_password($length = 10){
428 428
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429 429
 	$ps_len = strlen($allowable_characters);
430 430
 	mt_srand((double) microtime() * 1000000);
431 431
 	$pass = "";
432
-	for($i = 0; $i < $length; $i++) {
432
+	for ($i = 0; $i < $length; $i++) {
433 433
 		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
434 434
 	}
435 435
 	return $pass;
436 436
 }
437 437
 
438
-function sanitize($str = '', $safecount = 0) {
438
+function sanitize($str = '', $safecount = 0){
439 439
 	$modx = DocumentParser::getInstance();
440 440
 	$safecount++;
441
-	if(1000 < $safecount) {
441
+	if (1000 < $safecount) {
442 442
 		exit("error too many loops '{$safecount}'");
443 443
 	}
444
-	if(is_array($str)) {
445
-		foreach($str as $i => $v) {
444
+	if (is_array($str)) {
445
+		foreach ($str as $i => $v) {
446 446
 			$str[$i] = sanitize($v, $safecount);
447 447
 		}
448 448
 	} else {
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -340,7 +340,8 @@  discard block
 block discarded – undo
340 340
  * @param string $string
341 341
  * @return string
342 342
  */
343
-function save_user_quoted_printable($string) {
343
+function save_user_quoted_printable($string)
344
+{
344 345
 	$crlf = "\n";
345 346
 	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
346 347
 	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
@@ -359,7 +360,8 @@  discard block
 block discarded – undo
359 360
  * @param string $pwd
360 361
  * @param string $ufn
361 362
  */
362
-function sendMailMessage($email, $uid, $pwd, $ufn) {
363
+function sendMailMessage($email, $uid, $pwd, $ufn)
364
+{
363 365
 	$modx = DocumentParser::getInstance(); global $_lang, $websignupemail_message;
364 366
 	global $emailsubject, $emailsender;
365 367
 	global $site_name, $site_url;
@@ -387,7 +389,8 @@  discard block
 block discarded – undo
387 389
 }
388 390
 
389 391
 // Save User Settings
390
-function saveUserSettings($id) {
392
+function saveUserSettings($id)
393
+{
391 394
 	$modx = DocumentParser::getInstance();
392 395
 	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393 396
 
@@ -416,7 +419,8 @@  discard block
 block discarded – undo
416 419
 }
417 420
 
418 421
 // Web alert -  sends an alert to web browser
419
-function webAlertAndQuit($msg) {
422
+function webAlertAndQuit($msg)
423
+{
420 424
 	global $id, $modx;
421 425
 	$mode = $_POST['mode'];
422 426
 	$modx->manager->saveFormValues($mode);
@@ -424,7 +428,8 @@  discard block
 block discarded – undo
424 428
 }
425 429
 
426 430
 // Generate password
427
-function generate_password($length = 10) {
431
+function generate_password($length = 10)
432
+{
428 433
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429 434
 	$ps_len = strlen($allowable_characters);
430 435
 	mt_srand((double) microtime() * 1000000);
@@ -435,7 +440,8 @@  discard block
 block discarded – undo
435 440
 	return $pass;
436 441
 }
437 442
 
438
-function sanitize($str = '', $safecount = 0) {
443
+function sanitize($str = '', $safecount = 0)
444
+{
439 445
 	$modx = DocumentParser::getInstance();
440 446
 	$safecount++;
441 447
 	if(1000 < $safecount) {
Please login to merge, or discard this patch.
manager/processors/duplicate_content.processor.php 3 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 $children = array();
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $udperms->duplicateDoc = true;
23 23
 
24 24
 if(!$udperms->checkPermissions()) {
25
-	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
25
+    $modx->webAlertAndQuit($_lang["access_permission_denied"]);
26 26
 }
27 27
 
28 28
 // Run the duplicator
@@ -43,103 +43,103 @@  discard block
 block discarded – undo
43 43
  * @return int
44 44
  */
45 45
 function duplicateDocument($docid, $parent=null, $_toplevel=0) {
46
-	$modx = DocumentParser::getInstance(); global $_lang;
47
-
48
-	// invoke OnBeforeDocDuplicate event
49
-	$evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array(
50
-		'id' => $docid
51
-	));
52
-
53
-	// if( !in_array( 'false', array_values( $evtOut ) ) ){}
54
-	// TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication
55
-	// [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false');
56
-
57
-	$userID = $modx->getLoginUserID();
58
-
59
-	$tblsc = $modx->getFullTableName('site_content');
60
-
61
-	// Grab the original document
62
-	$rs = $modx->db->select('*', $tblsc, "id='{$docid}'");
63
-	$content = $modx->db->getRow($rs);
64
-
65
-	// Handle incremental ID
66
-	switch($modx->config['docid_incrmnt_method'])
67
-	{
68
-		case '1':
69
-			$from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
70
-			$rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
71
-			$content['id'] = $modx->db->getValue($rs);
72
-			break;
73
-		case '2':
74
-			$rs = $modx->db->select('MAX(id)+1',$tblsc);
75
-			$content['id'] = $modx->db->getValue($rs);
76
-			break;
77
-
78
-		default:
79
-			unset($content['id']); // remove the current id.
80
-	}
81
-
82
-	// Once we've grabbed the document object, start doing some modifications
83
-	if ($_toplevel == 0) {
84
-		// count duplicates
85
-		$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86
-		$pagetitle = $modx->db->escape($pagetitle);
87
-		$count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'"));
88
-		if($count>=1) $count = ' '.($count+1);
89
-		else $count = '';
90
-
91
-		$content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92
-		$content['alias'] = null;
93
-	} elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94
-		$content['alias'] = null;
95
-	}
96
-
97
-	// change the parent accordingly
98
-	if ($parent !== null) $content['parent'] = $parent;
99
-
100
-	// Change the author
101
-	$content['createdby'] = $userID;
102
-	$content['createdon'] = time();
103
-	// Remove other modification times
104
-	$content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0;
105
-
106
-	// [FS#922] Should the published status be honored? - sirlancelot
46
+    $modx = DocumentParser::getInstance(); global $_lang;
47
+
48
+    // invoke OnBeforeDocDuplicate event
49
+    $evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array(
50
+        'id' => $docid
51
+    ));
52
+
53
+    // if( !in_array( 'false', array_values( $evtOut ) ) ){}
54
+    // TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication
55
+    // [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false');
56
+
57
+    $userID = $modx->getLoginUserID();
58
+
59
+    $tblsc = $modx->getFullTableName('site_content');
60
+
61
+    // Grab the original document
62
+    $rs = $modx->db->select('*', $tblsc, "id='{$docid}'");
63
+    $content = $modx->db->getRow($rs);
64
+
65
+    // Handle incremental ID
66
+    switch($modx->config['docid_incrmnt_method'])
67
+    {
68
+        case '1':
69
+            $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
70
+            $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
71
+            $content['id'] = $modx->db->getValue($rs);
72
+            break;
73
+        case '2':
74
+            $rs = $modx->db->select('MAX(id)+1',$tblsc);
75
+            $content['id'] = $modx->db->getValue($rs);
76
+            break;
77
+
78
+        default:
79
+            unset($content['id']); // remove the current id.
80
+    }
81
+
82
+    // Once we've grabbed the document object, start doing some modifications
83
+    if ($_toplevel == 0) {
84
+        // count duplicates
85
+        $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86
+        $pagetitle = $modx->db->escape($pagetitle);
87
+        $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'"));
88
+        if($count>=1) $count = ' '.($count+1);
89
+        else $count = '';
90
+
91
+        $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92
+        $content['alias'] = null;
93
+    } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94
+        $content['alias'] = null;
95
+    }
96
+
97
+    // change the parent accordingly
98
+    if ($parent !== null) $content['parent'] = $parent;
99
+
100
+    // Change the author
101
+    $content['createdby'] = $userID;
102
+    $content['createdon'] = time();
103
+    // Remove other modification times
104
+    $content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0;
105
+
106
+    // [FS#922] Should the published status be honored? - sirlancelot
107 107
 //	if ($modx->hasPermission('publish_document')) {
108 108
 //		if ($modx->config['publish_default'])
109 109
 //			$content['pub_date'] = $content['pub_date']; // should this be changed to 1?
110 110
 //		else	$content['pub_date'] = 0;
111 111
 //	} else {
112
-		// User can't publish documents
112
+        // User can't publish documents
113 113
 //		$content['published'] = $content['pub_date'] = 0;
114 114
 //	}
115 115
 
116 116
     // Set the published status to unpublished by default (see above ... commit #3388)
117 117
     $content['published'] = $content['pub_date'] = 0;
118 118
 
119
-	// Escape the proper strings
120
-	$content = $modx->db->escape($content);
119
+    // Escape the proper strings
120
+    $content = $modx->db->escape($content);
121 121
 
122
-	// Duplicate the Document
123
-	$newparent = $modx->db->insert($content, $tblsc);
122
+    // Duplicate the Document
123
+    $newparent = $modx->db->insert($content, $tblsc);
124 124
 
125
-	// duplicate document's TVs
126
-	duplicateTVs($docid, $newparent);
127
-	duplicateAccess($docid, $newparent);
125
+    // duplicate document's TVs
126
+    duplicateTVs($docid, $newparent);
127
+    duplicateAccess($docid, $newparent);
128 128
 
129
-	// invoke OnDocDuplicate event
130
-	$evtOut = $modx->invokeEvent('OnDocDuplicate', array(
131
-		'id' => $docid,
132
-		'new_id' => $newparent
133
-	));
129
+    // invoke OnDocDuplicate event
130
+    $evtOut = $modx->invokeEvent('OnDocDuplicate', array(
131
+        'id' => $docid,
132
+        'new_id' => $newparent
133
+    ));
134 134
 
135
-	// Start duplicating all the child documents that aren't deleted.
136
-	$_toplevel++;
137
-	$rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC');
138
-		while ($row = $modx->db->getRow($rs))
139
-			duplicateDocument($row['id'], $newparent, $_toplevel);
135
+    // Start duplicating all the child documents that aren't deleted.
136
+    $_toplevel++;
137
+    $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC');
138
+        while ($row = $modx->db->getRow($rs))
139
+            duplicateDocument($row['id'], $newparent, $_toplevel);
140 140
 
141
-	// return the new doc id
142
-	return $newparent;
141
+    // return the new doc id
142
+    return $newparent;
143 143
 }
144 144
 
145 145
 /**
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
  * @param int $newid
150 150
  */
151 151
 function duplicateTVs($oldid, $newid){
152
-	$modx = DocumentParser::getInstance();
152
+    $modx = DocumentParser::getInstance();
153 153
 
154
-	$tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
154
+    $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
155 155
 
156 156
     $newid = (int)$newid;
157 157
     $oldid = (int)$oldid;
158 158
 
159 159
     $modx->db->insert(
160
-		array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
161
-		"{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from
162
-	);
160
+        array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
161
+        "{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from
162
+    );
163 163
 }
164 164
 
165 165
 /**
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
  * @param int $newid
170 170
  */
171 171
 function duplicateAccess($oldid, $newid){
172
-	$modx = DocumentParser::getInstance();
172
+    $modx = DocumentParser::getInstance();
173 173
 
174
-	$tbldg = $modx->getFullTableName('document_groups');
174
+    $tbldg = $modx->getFullTableName('document_groups');
175 175
 
176 176
     $newid = (int)$newid;
177 177
     $oldid = (int)$oldid;
178 178
 
179 179
     $modx->db->insert(
180
-		array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
181
-		"{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from
182
-	);
180
+        array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
181
+        "{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from
182
+    );
183 183
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) {
5
+if (!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 $children = array();
15 15
 
16 16
 // check permissions on the document
17
-include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
17
+include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
18 18
 $udperms = new udperms();
19 19
 $udperms->user = $modx->getLoginUserID();
20 20
 $udperms->document = $id;
21 21
 $udperms->role = $_SESSION['mgrRole'];
22 22
 $udperms->duplicateDoc = true;
23 23
 
24
-if(!$udperms->checkPermissions()) {
24
+if (!$udperms->checkPermissions()) {
25 25
 	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
26 26
 }
27 27
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 $_SESSION['itemname'] = $name;
34 34
 
35 35
 // finish cloning - redirect
36
-$header="Location: index.php?r=1&a=3&id=$id";
36
+$header = "Location: index.php?r=1&a=3&id=$id";
37 37
 header($header);
38 38
 
39 39
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  * @param int $_toplevel
43 43
  * @return int
44 44
  */
45
-function duplicateDocument($docid, $parent=null, $_toplevel=0) {
45
+function duplicateDocument($docid, $parent = null, $_toplevel = 0){
46 46
 	$modx = DocumentParser::getInstance(); global $_lang;
47 47
 
48 48
 	// invoke OnBeforeDocDuplicate event
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	$content = $modx->db->getRow($rs);
64 64
 
65 65
 	// Handle incremental ID
66
-	switch($modx->config['docid_incrmnt_method'])
66
+	switch ($modx->config['docid_incrmnt_method'])
67 67
 	{
68 68
 		case '1':
69 69
 			$from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			$content['id'] = $modx->db->getValue($rs);
72 72
 			break;
73 73
 		case '2':
74
-			$rs = $modx->db->select('MAX(id)+1',$tblsc);
74
+			$rs = $modx->db->select('MAX(id)+1', $tblsc);
75 75
 			$content['id'] = $modx->db->getValue($rs);
76 76
 			break;
77 77
 
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 		$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86 86
 		$pagetitle = $modx->db->escape($pagetitle);
87 87
 		$count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'"));
88
-		if($count>=1) $count = ' '.($count+1);
88
+		if ($count >= 1) $count = ' '.($count + 1);
89 89
 		else $count = '';
90 90
 
91 91
 		$content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92 92
 		$content['alias'] = null;
93
-	} elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
93
+	} elseif ($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94 94
 		$content['alias'] = null;
95 95
 	}
96 96
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 
154 154
 	$tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
155 155
 
156
-    $newid = (int)$newid;
157
-    $oldid = (int)$oldid;
156
+    $newid = (int) $newid;
157
+    $oldid = (int) $oldid;
158 158
 
159 159
     $modx->db->insert(
160 160
 		array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 
174 174
 	$tbldg = $modx->getFullTableName('document_groups');
175 175
 
176
-    $newid = (int)$newid;
177
-    $oldid = (int)$oldid;
176
+    $newid = (int) $newid;
177
+    $oldid = (int) $oldid;
178 178
 
179 179
     $modx->db->insert(
180 180
 		array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
Please login to merge, or discard this patch.
Braces   +18 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,7 +42,8 @@  discard block
 block discarded – undo
42 42
  * @param int $_toplevel
43 43
  * @return int
44 44
  */
45
-function duplicateDocument($docid, $parent=null, $_toplevel=0) {
45
+function duplicateDocument($docid, $parent=null, $_toplevel=0)
46
+{
46 47
 	$modx = DocumentParser::getInstance(); global $_lang;
47 48
 
48 49
 	// invoke OnBeforeDocDuplicate event
@@ -63,8 +64,7 @@  discard block
 block discarded – undo
63 64
 	$content = $modx->db->getRow($rs);
64 65
 
65 66
 	// Handle incremental ID
66
-	switch($modx->config['docid_incrmnt_method'])
67
-	{
67
+	switch($modx->config['docid_incrmnt_method']) {
68 68
 		case '1':
69 69
 			$from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
70 70
 			$rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
@@ -85,8 +85,11 @@  discard block
 block discarded – undo
85 85
 		$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86 86
 		$pagetitle = $modx->db->escape($pagetitle);
87 87
 		$count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'"));
88
-		if($count>=1) $count = ' '.($count+1);
89
-		else $count = '';
88
+		if($count>=1) {
89
+		    $count = ' '.($count+1);
90
+		} else {
91
+		    $count = '';
92
+		}
90 93
 
91 94
 		$content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92 95
 		$content['alias'] = null;
@@ -95,7 +98,9 @@  discard block
 block discarded – undo
95 98
 	}
96 99
 
97 100
 	// change the parent accordingly
98
-	if ($parent !== null) $content['parent'] = $parent;
101
+	if ($parent !== null) {
102
+	    $content['parent'] = $parent;
103
+	}
99 104
 
100 105
 	// Change the author
101 106
 	$content['createdby'] = $userID;
@@ -135,8 +140,9 @@  discard block
 block discarded – undo
135 140
 	// Start duplicating all the child documents that aren't deleted.
136 141
 	$_toplevel++;
137 142
 	$rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC');
138
-		while ($row = $modx->db->getRow($rs))
139
-			duplicateDocument($row['id'], $newparent, $_toplevel);
143
+		while ($row = $modx->db->getRow($rs)) {
144
+					duplicateDocument($row['id'], $newparent, $_toplevel);
145
+		}
140 146
 
141 147
 	// return the new doc id
142 148
 	return $newparent;
@@ -148,7 +154,8 @@  discard block
 block discarded – undo
148 154
  * @param int $oldid
149 155
  * @param int $newid
150 156
  */
151
-function duplicateTVs($oldid, $newid){
157
+function duplicateTVs($oldid, $newid)
158
+{
152 159
 	$modx = DocumentParser::getInstance();
153 160
 
154 161
 	$tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
@@ -168,7 +175,8 @@  discard block
 block discarded – undo
168 175
  * @param int $oldid
169 176
  * @param int $newid
170 177
  */
171
-function duplicateAccess($oldid, $newid){
178
+function duplicateAccess($oldid, $newid)
179
+{
172 180
 	$modx = DocumentParser::getInstance();
173 181
 
174 182
 	$tbldg = $modx->getFullTableName('document_groups');
Please login to merge, or discard this patch.