Completed
Pull Request — develop (#547)
by Maxim
09:14 queued 03:38
created
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 = evolutionCMS();
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 = evolutionCMS();
182 183
 
183 184
         return $modx->getChunk($chunkName);
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 $autoloader = __DIR__.'/vendor/autoload.php';
49 49
 if (file_exists($autoloader) && is_readable($autoloader)) {
50
-	include_once($autoloader);
50
+    include_once($autoloader);
51 51
 }
52 52
 
53 53
 if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 if(is_file($base_path . 'assets/cache/siteManager.php'))
57 57
     include_once($base_path . 'assets/cache/siteManager.php');
58 58
 if(!defined('MGR_DIR') && is_dir("{$base_path}manager"))
59
-	define('MGR_DIR', 'manager');
59
+    define('MGR_DIR', 'manager');
60 60
 if(is_file($base_path . 'assets/cache/siteHostnames.php'))
61 61
     include_once($base_path . 'assets/cache/siteHostnames.php');
62 62
 if(!defined('MODX_SITE_HOSTNAMES'))
63
-	define('MODX_SITE_HOSTNAMES', '');
63
+    define('MODX_SITE_HOSTNAMES', '');
64 64
 
65 65
 // get start time
66 66
 $mstart = memory_get_usage();
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 define('IN_PARSER_MODE', true);
86 86
 if ( ! defined('IN_MANAGER_MODE')) {
87
-	define('IN_MANAGER_MODE', false);
87
+    define('IN_MANAGER_MODE', false);
88 88
 }
89 89
 if (!defined('MODX_API_MODE')) {
90 90
     define('MODX_API_MODE', false);
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 
93 93
 // get the required includes
94 94
 if(!isset($database_user) || $database_user=="") {
95
-	$rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php');
96
-	// Be sure config.inc.php is there and that it contains some important values
97
-	if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) {
98
-		readfile('install/not_installed.tpl');
99
-		exit;
100
-	}
95
+    $rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php');
96
+    // Be sure config.inc.php is there and that it contains some important values
97
+    if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) {
98
+        readfile('install/not_installed.tpl');
99
+        exit;
100
+    }
101 101
 }
102 102
 
103 103
 // start session
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 
106 106
 // initiate a new document parser
107 107
 if (isset($coreClass) && class_exists($coreClass)) {
108
-	$modx = new $coreClass;
108
+    $modx = new $coreClass;
109 109
 }
110 110
 if (!isset($modx) || !($modx instanceof \DocumentParser)) {
111
-	include_once(MODX_MANAGER_PATH.'includes/document.parser.class.inc.php');
112
-	$modx = DocumentParser::getInstance();
111
+    include_once(MODX_MANAGER_PATH.'includes/document.parser.class.inc.php');
112
+    $modx = DocumentParser::getInstance();
113 113
 }
114 114
 
115 115
 // set some parser options
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 = evolutionCMS();
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 = evolutionCMS();
@@ -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 = evolutionCMS();
@@ -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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
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 = evolutionCMS();
1199 1461
 
1200 1462
         if(stripos($params,'style')===false && stripos($value,'</style>')!==false) {
Please login to merge, or discard this patch.
manager/frames/nodes.functions.inc.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
         case 'publishedon':
39 39
         case 'pub_date':
40 40
         case 'unpub_date':
41
-            $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']);
41
+            $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.'.$_SESSION['tree_sortby'], 'sc.'.$_SESSION['tree_sortby']);
42 42
             break;
43 43
         default:
44
-            $sortby = 'sc.' . $_SESSION['tree_sortby'];
44
+            $sortby = 'sc.'.$_SESSION['tree_sortby'];
45 45
     };
46 46
 
47
-    $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']);
47
+    $orderby = $modx->db->escape($sortby.' '.$_SESSION['tree_sortdir']);
48 48
 
49 49
     // Folder sorting gets special setup ;) Add menuindex and pagetitle
50 50
     if ($_SESSION['tree_sortby'] == 'isfolder') {
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
     $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
59 59
     $showProtected = false;
60 60
     if (isset ($modx->config['tree_show_protected'])) {
61
-        $showProtected = (boolean)$modx->config['tree_show_protected'];
61
+        $showProtected = (boolean) $modx->config['tree_show_protected'];
62 62
     }
63
-    $mgrRole = (isset ($_SESSION['mgrRole']) && (string)$_SESSION['mgrRole'] === '1') ? '1' : '0';
63
+    $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0';
64 64
     if ($showProtected == false) {
65
-        $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))");
65
+        $access = "AND (1={$mgrRole} OR sc.privatemgr=0".(!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))");
66 66
     } else {
67 67
         $access = '';
68 68
     }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         }
99 99
 
100 100
         $weblinkDisplay = $row['type'] == 'reference' ? sprintf('&nbsp;%s', $_style['tree_linkgo']) : '';
101
-        $pageIdDisplay = '<small>(' . ($modx_textdir ? '&rlm;' : '') . $row['id'] . ')</small>';
101
+        $pageIdDisplay = '<small>('.($modx_textdir ? '&rlm;' : '').$row['id'].')</small>';
102 102
 
103 103
         // Prepare displaying user-locks
104 104
         $lockedByUser = '';
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                     'element_type' => $_lang["lock_element_type_7"],
110 110
                     'lasthit_df' => $rowLock['lasthit_df']
111 111
                 ));
112
-                $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>';
112
+                $lockedByUser = '<span title="'.$title.'" class="editResource">'.$_style['tree_preview_resource'].'</span>';
113 113
             } else {
114 114
                 $title = $modx->parseText($_lang["lock_element_locked_by"], array(
115 115
                     'element_type' => $_lang["lock_element_type_7"],
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
                     'lasthit_df' => $rowLock['lasthit_df']
118 118
                 ));
119 119
                 if ($modx->hasPermission('remove_locks')) {
120
-                    $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>';
120
+                    $lockedByUser = '<span onclick="modx.tree.unlockElement(7, '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>';
121 121
                 } else {
122
-                    $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>';
122
+                    $lockedByUser = '<span title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>';
123 123
                 }
124 124
             }
125 125
         }
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
 
129 129
         $title = '';
130 130
         if (isDateNode($nodeNameSource)) {
131
-            $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]';
131
+            $title = $_lang['pagetitle'].': '.$row['pagetitle'].'[+lf+]';
132 132
         }
133
-        $title .= $_lang['id'] . ': ' . $row['id'];
134
-        $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle'];
135
-        $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex'];
136
-        $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-');
137
-        $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename'];
138
-        $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']);
139
-        $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']);
140
-        $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']);
141
-        $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']);
142
-        $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']);
143
-        $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']);
144
-        $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']);
133
+        $title .= $_lang['id'].': '.$row['id'];
134
+        $title .= '[+lf+]'.$_lang['resource_opt_menu_title'].': '.$row['menutitle'];
135
+        $title .= '[+lf+]'.$_lang['resource_opt_menu_index'].': '.$row['menuindex'];
136
+        $title .= '[+lf+]'.$_lang['alias'].': '.(!empty($row['alias']) ? $row['alias'] : '-');
137
+        $title .= '[+lf+]'.$_lang['template'].': '.$row['templatename'];
138
+        $title .= '[+lf+]'.$_lang['publish_date'].': '.$modx->toDateFormat($row['pub_date']);
139
+        $title .= '[+lf+]'.$_lang['unpublish_date'].': '.$modx->toDateFormat($row['unpub_date']);
140
+        $title .= '[+lf+]'.$_lang['page_data_web_access'].': '.($row['privateweb'] ? $_lang['private'] : $_lang['public']);
141
+        $title .= '[+lf+]'.$_lang['page_data_mgr_access'].': '.($row['privatemgr'] ? $_lang['private'] : $_lang['public']);
142
+        $title .= '[+lf+]'.$_lang['resource_opt_richtext'].': '.($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']);
143
+        $title .= '[+lf+]'.$_lang['page_data_searchable'].': '.($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']);
144
+        $title .= '[+lf+]'.$_lang['page_data_cacheable'].': '.($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']);
145 145
         $title = $modx->htmlspecialchars($title);
146
-        $title = str_replace('[+lf+]', ' &#13;', $title);   // replace line-breaks with empty space as fall-back
146
+        $title = str_replace('[+lf+]', ' &#13;', $title); // replace line-breaks with empty space as fall-back
147 147
 
148 148
         $data = array(
149 149
             'id' => $row['id'],
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
             }
228 228
 
229 229
             if ($ph['contextmenu']) {
230
-                $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
230
+                $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"';
231 231
             }
232 232
 
233 233
             if ($_SESSION['tree_show_only_folders']) {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
                     }
286 286
 
287 287
                     if ($ph['contextmenu']) {
288
-                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
288
+                        $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"';
289 289
                     }
290 290
 
291 291
                     $node .= $modx->parseText($tpl, $ph);
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
                     }
324 324
 
325 325
                     if ($ph['contextmenu']) {
326
-                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
326
+                        $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"';
327 327
                     }
328 328
 
329 329
                     $node .= $modx->parseText($tpl, $ph);
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
                     }
375 375
 
376 376
                     if ($ph['contextmenu']) {
377
-                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
377
+                        $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"';
378 378
                     }
379 379
 
380 380
                     $node .= $modx->parseText($tpl, $ph);
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
                     }
417 417
 
418 418
                     if ($ph['contextmenu']) {
419
-                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
419
+                        $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"';
420 420
                     }
421 421
 
422 422
                     $node .= $modx->parseText($tpl, $ph);
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
                     $nodetitle .= $modx->config['friendly_url_suffix'];
494 494
                 }
495 495
             }
496
-            $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle;
496
+            $nodetitle = $modx->config['friendly_url_prefix'].$nodetitle;
497 497
             break;
498 498
         case 'pagetitle':
499 499
             $nodetitle = $row['pagetitle'];
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 {
554 554
     $modx = evolutionCMS();
555 555
 
556
-    return (int)$modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' '));
556
+    return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM '.$modx->getFullTableName('site_content').' WHERE parent='.$parent.' AND isfolder='.$isfolder.' '));
557 557
 }
558 558
 
559 559
 /**
Please login to merge, or discard this patch.
manager/actions/welcome.static.php 3 patches
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  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
 
6 6
 unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes
7 7
 
8 8
 if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
9
-	// seems to be a new install - send the user to the configuration page
10
-	exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
9
+    // seems to be a new install - send the user to the configuration page
10
+    exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
11 11
 }
12 12
 
13 13
 // set placeholders
@@ -17,70 +17,70 @@  discard block
 block discarded – undo
17 17
 
18 18
 // setup message info
19 19
 if($modx->hasPermission('messages')) {
20
-	include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php');
21
-	$_SESSION['nrtotalmessages'] = $nrtotalmessages;
22
-	$_SESSION['nrnewmessages'] = $nrnewmessages;
23
-
24
-	$msg = array();
25
-	$msg[] = sprintf('<a href="index.php?a=10" target="main"><img src="%s" /></a>', $_style['icons_mail_large']);
26
-	$nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">' . $_SESSION['nrnewmessages'] . '</span>)' : '';
27
-	$msg[] = sprintf('<span style="color:#909090;font-size:15px;font-weight:bold">&nbsp;<a class="wm_messages_inbox_link" href="index.php?a=10" target="main">[%%inbox%%]</a>%s</span><br />', $nrnewmessages);
28
-	$nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">' . $_SESSION['nrnewmessages'] . '</span>' : '0';
29
-	$welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages);
30
-	$msg[] = sprintf('<span class="comment">%s</span>', $welcome_messages);
31
-	$ph['MessageInfo'] = implode("\n", $msg);
20
+    include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php');
21
+    $_SESSION['nrtotalmessages'] = $nrtotalmessages;
22
+    $_SESSION['nrnewmessages'] = $nrnewmessages;
23
+
24
+    $msg = array();
25
+    $msg[] = sprintf('<a href="index.php?a=10" target="main"><img src="%s" /></a>', $_style['icons_mail_large']);
26
+    $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">' . $_SESSION['nrnewmessages'] . '</span>)' : '';
27
+    $msg[] = sprintf('<span style="color:#909090;font-size:15px;font-weight:bold">&nbsp;<a class="wm_messages_inbox_link" href="index.php?a=10" target="main">[%%inbox%%]</a>%s</span><br />', $nrnewmessages);
28
+    $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">' . $_SESSION['nrnewmessages'] . '</span>' : '0';
29
+    $welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages);
30
+    $msg[] = sprintf('<span class="comment">%s</span>', $welcome_messages);
31
+    $ph['MessageInfo'] = implode("\n", $msg);
32 32
 }
33 33
 
34 34
 // setup icons
35 35
 if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
36
-	$icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]';
37
-	$ph['SecurityIcon'] = wrapIcon($icon, 75);
36
+    $icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]';
37
+    $ph['SecurityIcon'] = wrapIcon($icon, 75);
38 38
 }
39 39
 if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
40
-	$icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]';
41
-	$ph['WebUserIcon'] = wrapIcon($icon, 99);
40
+    $icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]';
41
+    $ph['WebUserIcon'] = wrapIcon($icon, 99);
42 42
 }
43 43
 if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
44
-	$icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]';
45
-	$ph['ModulesIcon'] = wrapIcon($icon, 106);
44
+    $icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]';
45
+    $ph['ModulesIcon'] = wrapIcon($icon, 106);
46 46
 }
47 47
 if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
48
-	$icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]';
49
-	$ph['ResourcesIcon'] = wrapIcon($icon, 76);
48
+    $icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]';
49
+    $ph['ResourcesIcon'] = wrapIcon($icon, 76);
50 50
 }
51 51
 if($modx->hasPermission('bk_manager')) {
52
-	$icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]';
53
-	$ph['BackupIcon'] = wrapIcon($icon, 93);
52
+    $icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]';
53
+    $ph['BackupIcon'] = wrapIcon($icon, 93);
54 54
 }
55 55
 if($modx->hasPermission('help')) {
56
-	$icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]';
57
-	$ph['HelpIcon'] = wrapIcon($icon, 9);
56
+    $icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]';
57
+    $ph['HelpIcon'] = wrapIcon($icon, 9);
58 58
 }
59 59
 // do some config checks
60 60
 if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
61
-	include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php');
62
-	if($config_check_results != $_lang['configcheck_ok']) {
63
-		$ph['config_check_results'] = $config_check_results;
64
-		$ph['config_display'] = 'block';
65
-	} else {
66
-		$ph['config_display'] = 'none';
67
-	}
61
+    include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php');
62
+    if($config_check_results != $_lang['configcheck_ok']) {
63
+        $ph['config_check_results'] = $config_check_results;
64
+        $ph['config_display'] = 'block';
65
+    } else {
66
+        $ph['config_display'] = 'none';
67
+    }
68 68
 } else {
69
-	$ph['config_display'] = 'none';
69
+    $ph['config_display'] = 'none';
70 70
 }
71 71
 
72 72
 // Check logout-reminder
73 73
 if(isset($_SESSION['show_logout_reminder'])) {
74
-	switch($_SESSION['show_logout_reminder']['type']) {
75
-		case 'logout_reminder':
76
-			$date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly');
77
-			$ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
78
-			break;
79
-	}
80
-	$ph['show_logout_reminder'] = 'block';
81
-	unset($_SESSION['show_logout_reminder']);
74
+    switch($_SESSION['show_logout_reminder']['type']) {
75
+        case 'logout_reminder':
76
+            $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly');
77
+            $ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
78
+            break;
79
+    }
80
+    $ph['show_logout_reminder'] = 'block';
81
+    unset($_SESSION['show_logout_reminder']);
82 82
 } else {
83
-	$ph['show_logout_reminder'] = 'none';
83
+    $ph['show_logout_reminder'] = 'none';
84 84
 }
85 85
 
86 86
 // Check multiple sessions
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 $nrnewmessages = '<span class="text-danger">' . $_SESSION['nrnewmessages'] . '</span>';
129 129
 
130 130
 $ph['UserInfo'] = $modx->parseText($tpl, array(
131
-	'username' => $modx->getLoginUserName(),
132
-	'role' => $_SESSION['mgrPermissions']['name'],
133
-	'lastlogin' => $modx->toDateFormat($_SESSION['mgrLastlogin'] + $server_offset_time),
134
-	'logincount' => $_SESSION['mgrLogincount'] + 1,
135
-	'msginfo' => sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages)
131
+    'username' => $modx->getLoginUserName(),
132
+    'role' => $_SESSION['mgrPermissions']['name'],
133
+    'lastlogin' => $modx->toDateFormat($_SESSION['mgrLastlogin'] + $server_offset_time),
134
+    'logincount' => $_SESSION['mgrLogincount'] + 1,
135
+    'msginfo' => sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages)
136 136
 ));
137 137
 
138 138
 $from = array();
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
142 142
 
143 143
 if($modx->db->getRecordCount($rs) < 1) {
144
-	$html = '<p>[%no_active_users_found%]</p>';
144
+    $html = '<p>[%no_active_users_found%]</p>';
145 145
 } else {
146
-	include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
147
-	$now = $_SERVER['REQUEST_TIME'] + $server_offset_time;
148
-	$ph['now'] = strftime('%H:%M:%S', $now);
149
-	$timetocheck = ($now - (60 * 20)); //+$server_offset_time;
150
-	$html = '
146
+    include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
147
+    $now = $_SERVER['REQUEST_TIME'] + $server_offset_time;
148
+    $ph['now'] = strftime('%H:%M:%S', $now);
149
+    $timetocheck = ($now - (60 * 20)); //+$server_offset_time;
150
+    $html = '
151 151
 	<div class="card-body">
152 152
 		[%onlineusers_message%] 
153 153
 		<b>[+now+]</b>):
@@ -165,33 +165,33 @@  discard block
 block discarded – undo
165 165
 	</thead>
166 166
 	<tbody>';
167 167
 
168
-	$userList = array();
169
-	$userCount = array();
170
-	// Create userlist with session-count first before output
171
-	while($activeusers = $modx->db->getRow($rs)) {
172
-		$userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1;
173
-
174
-		$idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : '';
175
-		$webicon = $activeusers['internalKey'] < 0 ? '<img src="[&tree_globe&]" alt="Web user" />&nbsp;' : '';
176
-		$ip = $activeusers['ip'] === '::1' ? '127.0.0.1' : $activeusers['ip'];
177
-		$currentaction = getAction($activeusers['action'], $activeusers['id']);
178
-		$userList[] = array(
179
-			$idle,
180
-			'',
181
-			$activeusers['username'],
182
-			$webicon,
183
-			abs($activeusers['internalKey']),
184
-			$ip,
185
-			strftime('%H:%M:%S', $activeusers['lasthit'] + $server_offset_time),
186
-			$currentaction
187
-		);
188
-	}
189
-	foreach($userList as $params) {
190
-		$params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : '';
191
-		$html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
192
-	}
193
-
194
-	$html .= '
168
+    $userList = array();
169
+    $userCount = array();
170
+    // Create userlist with session-count first before output
171
+    while($activeusers = $modx->db->getRow($rs)) {
172
+        $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1;
173
+
174
+        $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : '';
175
+        $webicon = $activeusers['internalKey'] < 0 ? '<img src="[&tree_globe&]" alt="Web user" />&nbsp;' : '';
176
+        $ip = $activeusers['ip'] === '::1' ? '127.0.0.1' : $activeusers['ip'];
177
+        $currentaction = getAction($activeusers['action'], $activeusers['id']);
178
+        $userList[] = array(
179
+            $idle,
180
+            '',
181
+            $activeusers['username'],
182
+            $webicon,
183
+            abs($activeusers['internalKey']),
184
+            $ip,
185
+            strftime('%H:%M:%S', $activeusers['lasthit'] + $server_offset_time),
186
+            $currentaction
187
+        );
188
+    }
189
+    foreach($userList as $params) {
190
+        $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : '';
191
+        $html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
192
+    }
193
+
194
+    $html .= '
195 195
 	</tbody>
196 196
 	</table>
197 197
 </div>
@@ -232,17 +232,17 @@  discard block
 block discarded – undo
232 232
 // invoke event OnManagerWelcomePrerender
233 233
 $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
234 234
 if(is_array($evtOut)) {
235
-	$output = implode('', $evtOut);
236
-	$ph['OnManagerWelcomePrerender'] = $output;
235
+    $output = implode('', $evtOut);
236
+    $ph['OnManagerWelcomePrerender'] = $output;
237 237
 }
238 238
 
239 239
 $widgets['welcome'] = array(
240
-	'menuindex' => '10',
241
-	'id' => 'welcome',
242
-	'cols' => 'col-sm-6',
243
-	'icon' => 'fa-home',
244
-	'title' => '[%welcome_title%]',
245
-	'body' => '
240
+    'menuindex' => '10',
241
+    'id' => 'welcome',
242
+    'cols' => 'col-sm-6',
243
+    'icon' => 'fa-home',
244
+    'title' => '[%welcome_title%]',
245
+    'body' => '
246 246
 				<div class="wm_buttons card-body"> 
247 247
 					<!--@IF:[[#hasPermission?key=new_user]] OR [[#hasPermission?key=edit_user]]--> 
248 248
 					<span class="wm_button">
@@ -320,25 +320,25 @@  discard block
 block discarded – undo
320 320
 					</table>
321 321
 				</div>
322 322
 		',
323
-	'hide'=>'0'
323
+    'hide'=>'0'
324 324
 );
325 325
 $widgets['onlineinfo'] = array(
326
-	'menuindex' => '20',
327
-	'id' => 'onlineinfo',
328
-	'cols' => 'col-sm-6',
329
-	'icon' => 'fa-user',
330
-	'title' => '[%onlineusers_title%]',
331
-	'body' => '<div class="userstable">[+OnlineInfo+]</div>',
332
-	'hide'=>'0'
326
+    'menuindex' => '20',
327
+    'id' => 'onlineinfo',
328
+    'cols' => 'col-sm-6',
329
+    'icon' => 'fa-user',
330
+    'title' => '[%onlineusers_title%]',
331
+    'body' => '<div class="userstable">[+OnlineInfo+]</div>',
332
+    'hide'=>'0'
333 333
 );
334 334
 $widgets['recentinfo'] = array(
335
-	'menuindex' => '30',
336
-	'id' => 'modxrecent_widget',
337
-	'cols' => 'col-sm-12',
338
-	'icon' => 'fa-pencil-square-o',
339
-	'title' => '[%activity_title%]',
340
-	'body' => '<div class="widget-stage">[+RecentInfo+]</div>',
341
-	'hide'=>'0'
335
+    'menuindex' => '30',
336
+    'id' => 'modxrecent_widget',
337
+    'cols' => 'col-sm-12',
338
+    'icon' => 'fa-pencil-square-o',
339
+    'title' => '[%activity_title%]',
340
+    'body' => '<div class="widget-stage">[+RecentInfo+]</div>',
341
+    'hide'=>'0'
342 342
 );
343 343
 if ($modx->config['rss_url_news']) {
344 344
     $widgets['news'] = array(
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 // invoke OnManagerWelcomeHome event
367 367
 $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
368 368
 if(is_array($sitewidgets)) {
369
-	$newwidgets = array();
369
+    $newwidgets = array();
370 370
     foreach($sitewidgets as $widget){
371 371
         $newwidgets = array_merge($newwidgets, unserialize($widget));
372 372
     }
@@ -374,21 +374,21 @@  discard block
 block discarded – undo
374 374
 }
375 375
 
376 376
 usort($widgets, function ($a, $b) {
377
-	return $a['menuindex'] - $b['menuindex'];
377
+    return $a['menuindex'] - $b['menuindex'];
378 378
 });
379 379
 
380 380
 $tpl = getTplWidget();
381 381
 $output = '';
382 382
 foreach($widgets as $widget) {
383
-	if ($widget['hide'] != '1'){
384
-		$output .= $modx->parseText($tpl, $widget);
385
-	}
383
+    if ($widget['hide'] != '1'){
384
+        $output .= $modx->parseText($tpl, $widget);
385
+    }
386 386
 }
387 387
 $ph['widgets'] = $output;
388 388
 
389 389
 // load template
390 390
 if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
391
-	$modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl';
391
+    $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl';
392 392
 }
393 393
 
394 394
 $target = $modx->config['manager_welcome_tpl'];
@@ -396,27 +396,27 @@  discard block
 block discarded – undo
396 396
 $target = $modx->mergeSettingsContent($target);
397 397
 
398 398
 if(substr($target, 0, 1) === '@') {
399
-	if(substr($target, 0, 6) === '@CHUNK') {
400
-		$content = $modx->getChunk(trim(substr($target, 7)));
401
-	} elseif(substr($target, 0, 5) === '@FILE') {
402
-		$content = file_get_contents(trim(substr($target, 6)));
403
-	} else {
404
-		$content = '';
405
-	}
399
+    if(substr($target, 0, 6) === '@CHUNK') {
400
+        $content = $modx->getChunk(trim(substr($target, 7)));
401
+    } elseif(substr($target, 0, 5) === '@FILE') {
402
+        $content = file_get_contents(trim(substr($target, 6)));
403
+    } else {
404
+        $content = '';
405
+    }
406 406
 } else {
407
-	$chunk = $modx->getChunk($target);
408
-	if($chunk !== false && !empty($chunk)) {
409
-		$content = $chunk;
410
-	} elseif(is_file(MODX_BASE_PATH . $target)) {
411
-		$content = file_get_contents(MODX_BASE_PATH . $target);
412
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
413
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl');
414
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible
415
-	{
416
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
417
-	} else {
418
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl');
419
-	}
407
+    $chunk = $modx->getChunk($target);
408
+    if($chunk !== false && !empty($chunk)) {
409
+        $content = $chunk;
410
+    } elseif(is_file(MODX_BASE_PATH . $target)) {
411
+        $content = file_get_contents(MODX_BASE_PATH . $target);
412
+    } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
413
+        $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl');
414
+    } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible
415
+    {
416
+        $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
417
+    } else {
418
+        $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl');
419
+    }
420 420
 }
421 421
 
422 422
 // merge placeholders
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 $content = $modx->mergeSettingsContent($content);
425 425
 $content = $modx->parseText($content, $ph);
426 426
 if(strpos($content, '[+') !== false) {
427
-	$modx->toPlaceholders($ph);
428
-	$content = $modx->mergePlaceholderContent($content);
427
+    $modx->toPlaceholders($ph);
428
+    $content = $modx->mergePlaceholderContent($content);
429 429
 }
430 430
 $content = $modx->parseDocumentSource($content);
431 431
 $content = $modx->parseText($content, $_lang, '[%', '%]');
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 $content = $modx->cleanUpMODXTags($content); //cleanup
434 434
 
435 435
 if($js = $modx->getRegisteredClientScripts()) {
436
-	$content .= $js;
436
+    $content .= $js;
437 437
 }
438 438
 
439 439
 echo $content;
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 //  <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a>
444 444
 //</span>
445 445
 function getTplWidget() { // recent document info
446
-	return '
446
+    return '
447 447
 		<div class="[+cols+]" id="[+id+]">
448 448
 			<div class="card"[+cardAttr+]>
449 449
 				<div class="card-header"[+headAttr+]> <i class="fa [+icon+]"></i> [+title+] </div>
@@ -454,11 +454,11 @@  discard block
 block discarded – undo
454 454
 }
455 455
 
456 456
 function getRecentInfo() { // recent document info
457
-	$modx = evolutionCMS();
457
+    $modx = evolutionCMS();
458 458
 
459
-	$modx->addSnippet('recentInfoList', 'getRecentInfoList');
459
+    $modx->addSnippet('recentInfoList', 'getRecentInfoList');
460 460
 
461
-	$html = '
461
+    $html = '
462 462
 			<div class="table-responsive">
463 463
 				<table class="table data">
464 464
 					<thead>
@@ -476,96 +476,96 @@  discard block
 block discarded – undo
476 476
 				</table>
477 477
 			</div>
478 478
 ';
479
-	return $html;
479
+    return $html;
480 480
 }
481 481
 
482 482
 function getRecentInfoList() {
483
-	$modx = evolutionCMS();
484
-
485
-	$rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
486
-
487
-	if($modx->db->getRecordCount($rs) < 1) {
488
-		return '<tr><td>[%no_activity_message%]</td></tr>';
489
-	}
490
-
491
-	$tpl = getRecentInfoRowTpl();
492
-
493
-	$btntpl['edit'] = '<a title="[%edit_resource%]" href="index.php?a=27&amp;id=[+id+]" target="main"><i class="fa fa-edit fa-fw"></i></a> ';
494
-	$btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&amp;id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> ';
495
-
496
-	$output = array();
497
-	while($ph = $modx->db->getRow($rs)) {
498
-		$docid = $ph['id'];
499
-		$_ = $modx->getUserInfo($ph['editedby']);
500
-		$ph['username'] = $_['username'];
501
-
502
-		if($ph['deleted'] == 1) {
503
-			$ph['status'] = 'deleted text-danger';
504
-		} elseif($ph['published'] == 0) {
505
-			$ph['status'] = 'unpublished font-italic text-muted';
506
-		} else {
507
-			$ph['status'] = 'published';
508
-		}
509
-
510
-		if($modx->hasPermission('edit_document')) {
511
-			$ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
512
-		} else {
513
-			$ph['edit_btn'] = '';
514
-		}
515
-
516
-		$preview_disabled = ($ph['deleted'] == 1) ? 'disabled' : '';
517
-		$ph['preview_btn'] = str_replace(array(
518
-			'[+id+]',
519
-			'[+preview_disabled+]'
520
-		), array(
521
-			$docid,
522
-			$preview_disabled
523
-		), $btntpl['preview_btn']);
524
-
525
-		if($modx->hasPermission('delete_document')) {
526
-			if($ph['deleted'] == 0) {
527
-				$delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&amp;id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> ';
528
-			} else {
529
-				$delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&amp;id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> ';
530
-			}
531
-			$ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
532
-		} else {
533
-			$ph['delete_btn'] = '';
534
-		}
535
-
536
-		if($ph['deleted'] == 1 && $ph['published'] == 0) {
537
-			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
538
-		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
539
-			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
540
-		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
541
-			$publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
542
-		} else {
543
-			$publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
544
-		}
545
-		$ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
546
-
547
-		$ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
548
-
549
-		if($ph['longtitle'] == '') {
550
-			$ph['longtitle'] = '(<i>[%not_set%]</i>)';
551
-		}
552
-		if($ph['description'] == '') {
553
-			$ph['description'] = '(<i>[%not_set%]</i>)';
554
-		}
555
-		if($ph['introtext'] == '') {
556
-			$ph['introtext'] = '(<i>[%not_set%]</i>)';
557
-		}
558
-		if($ph['alias'] == '') {
559
-			$ph['alias'] = '(<i>[%not_set%]</i>)';
560
-		}
561
-
562
-		$output[] = $modx->parseText($tpl, $ph);
563
-	}
564
-	return implode("\n", $output);
483
+    $modx = evolutionCMS();
484
+
485
+    $rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
486
+
487
+    if($modx->db->getRecordCount($rs) < 1) {
488
+        return '<tr><td>[%no_activity_message%]</td></tr>';
489
+    }
490
+
491
+    $tpl = getRecentInfoRowTpl();
492
+
493
+    $btntpl['edit'] = '<a title="[%edit_resource%]" href="index.php?a=27&amp;id=[+id+]" target="main"><i class="fa fa-edit fa-fw"></i></a> ';
494
+    $btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&amp;id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> ';
495
+
496
+    $output = array();
497
+    while($ph = $modx->db->getRow($rs)) {
498
+        $docid = $ph['id'];
499
+        $_ = $modx->getUserInfo($ph['editedby']);
500
+        $ph['username'] = $_['username'];
501
+
502
+        if($ph['deleted'] == 1) {
503
+            $ph['status'] = 'deleted text-danger';
504
+        } elseif($ph['published'] == 0) {
505
+            $ph['status'] = 'unpublished font-italic text-muted';
506
+        } else {
507
+            $ph['status'] = 'published';
508
+        }
509
+
510
+        if($modx->hasPermission('edit_document')) {
511
+            $ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
512
+        } else {
513
+            $ph['edit_btn'] = '';
514
+        }
515
+
516
+        $preview_disabled = ($ph['deleted'] == 1) ? 'disabled' : '';
517
+        $ph['preview_btn'] = str_replace(array(
518
+            '[+id+]',
519
+            '[+preview_disabled+]'
520
+        ), array(
521
+            $docid,
522
+            $preview_disabled
523
+        ), $btntpl['preview_btn']);
524
+
525
+        if($modx->hasPermission('delete_document')) {
526
+            if($ph['deleted'] == 0) {
527
+                $delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&amp;id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> ';
528
+            } else {
529
+                $delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&amp;id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> ';
530
+            }
531
+            $ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
532
+        } else {
533
+            $ph['delete_btn'] = '';
534
+        }
535
+
536
+        if($ph['deleted'] == 1 && $ph['published'] == 0) {
537
+            $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
538
+        } elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
539
+            $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
540
+        } elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
541
+            $publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
542
+        } else {
543
+            $publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
544
+        }
545
+        $ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
546
+
547
+        $ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
548
+
549
+        if($ph['longtitle'] == '') {
550
+            $ph['longtitle'] = '(<i>[%not_set%]</i>)';
551
+        }
552
+        if($ph['description'] == '') {
553
+            $ph['description'] = '(<i>[%not_set%]</i>)';
554
+        }
555
+        if($ph['introtext'] == '') {
556
+            $ph['introtext'] = '(<i>[%not_set%]</i>)';
557
+        }
558
+        if($ph['alias'] == '') {
559
+            $ph['alias'] = '(<i>[%not_set%]</i>)';
560
+        }
561
+
562
+        $output[] = $modx->parseText($tpl, $ph);
563
+    }
564
+    return implode("\n", $output);
565 565
 }
566 566
 
567 567
 function getRecentInfoRowTpl() {
568
-	$tpl = '
568
+    $tpl = '
569 569
 						<tr>
570 570
 							<td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td>
571 571
 							<td data-toggle="collapse" data-target=".collapse[+id+]"><a class="[+status+]" title="[%edit_resource%]" href="index.php?a=3&amp;id=[+id+]" target="main">[+pagetitle+]</a></td>
@@ -589,16 +589,16 @@  discard block
 block discarded – undo
589 589
 								</div>
590 590
 							</td>
591 591
 						</tr>';
592
-	return $tpl;
592
+    return $tpl;
593 593
 }
594 594
 
595 595
 // setup icons
596 596
 function wrapIcon($i, $action) {
597
-	return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
597
+    return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
598 598
 }
599 599
 
600 600
 function getStartUpScript() {
601
-	$script = '
601
+    $script = '
602 602
         <script type="text/javascript">
603 603
         function hideConfigCheckWarning(key) {
604 604
         	var xhr = new XMLHttpRequest();
@@ -622,5 +622,5 @@  discard block
 block discarded – undo
622 622
 		})(jQuery);        
623 623
         </script>
624 624
 ';
625
-	return $script;
625
+    return $script;
626 626
 }
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  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
 
6 6
 unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes
7 7
 
8
-if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
8
+if ($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
9 9
 	// seems to be a new install - send the user to the configuration page
10 10
 	exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
11 11
 }
@@ -16,50 +16,50 @@  discard block
 block discarded – undo
16 16
 $_SESSION['nrnewmessages'] = 0;
17 17
 
18 18
 // setup message info
19
-if($modx->hasPermission('messages')) {
20
-	include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php');
19
+if ($modx->hasPermission('messages')) {
20
+	include_once(MODX_MANAGER_PATH.'includes/messageCount.inc.php');
21 21
 	$_SESSION['nrtotalmessages'] = $nrtotalmessages;
22 22
 	$_SESSION['nrnewmessages'] = $nrnewmessages;
23 23
 
24 24
 	$msg = array();
25 25
 	$msg[] = sprintf('<a href="index.php?a=10" target="main"><img src="%s" /></a>', $_style['icons_mail_large']);
26
-	$nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">' . $_SESSION['nrnewmessages'] . '</span>)' : '';
26
+	$nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">'.$_SESSION['nrnewmessages'].'</span>)' : '';
27 27
 	$msg[] = sprintf('<span style="color:#909090;font-size:15px;font-weight:bold">&nbsp;<a class="wm_messages_inbox_link" href="index.php?a=10" target="main">[%%inbox%%]</a>%s</span><br />', $nrnewmessages);
28
-	$nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">' . $_SESSION['nrnewmessages'] . '</span>' : '0';
28
+	$nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">'.$_SESSION['nrnewmessages'].'</span>' : '0';
29 29
 	$welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages);
30 30
 	$msg[] = sprintf('<span class="comment">%s</span>', $welcome_messages);
31 31
 	$ph['MessageInfo'] = implode("\n", $msg);
32 32
 }
33 33
 
34 34
 // setup icons
35
-if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
35
+if ($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
36 36
 	$icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]';
37 37
 	$ph['SecurityIcon'] = wrapIcon($icon, 75);
38 38
 }
39
-if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
39
+if ($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
40 40
 	$icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]';
41 41
 	$ph['WebUserIcon'] = wrapIcon($icon, 99);
42 42
 }
43
-if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
43
+if ($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
44 44
 	$icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]';
45 45
 	$ph['ModulesIcon'] = wrapIcon($icon, 106);
46 46
 }
47
-if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
47
+if ($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
48 48
 	$icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]';
49 49
 	$ph['ResourcesIcon'] = wrapIcon($icon, 76);
50 50
 }
51
-if($modx->hasPermission('bk_manager')) {
51
+if ($modx->hasPermission('bk_manager')) {
52 52
 	$icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]';
53 53
 	$ph['BackupIcon'] = wrapIcon($icon, 93);
54 54
 }
55
-if($modx->hasPermission('help')) {
55
+if ($modx->hasPermission('help')) {
56 56
 	$icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]';
57 57
 	$ph['HelpIcon'] = wrapIcon($icon, 9);
58 58
 }
59 59
 // do some config checks
60
-if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
61
-	include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php');
62
-	if($config_check_results != $_lang['configcheck_ok']) {
60
+if (($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
61
+	include_once(MODX_MANAGER_PATH.'includes/config_check.inc.php');
62
+	if ($config_check_results != $_lang['configcheck_ok']) {
63 63
 		$ph['config_check_results'] = $config_check_results;
64 64
 		$ph['config_display'] = 'block';
65 65
 	} else {
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 }
71 71
 
72 72
 // Check logout-reminder
73
-if(isset($_SESSION['show_logout_reminder'])) {
74
-	switch($_SESSION['show_logout_reminder']['type']) {
73
+if (isset($_SESSION['show_logout_reminder'])) {
74
+	switch ($_SESSION['show_logout_reminder']['type']) {
75 75
 		case 'logout_reminder':
76 76
 			$date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly');
77 77
 			$ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	</tr>
126 126
 </table>';
127 127
 
128
-$nrnewmessages = '<span class="text-danger">' . $_SESSION['nrnewmessages'] . '</span>';
128
+$nrnewmessages = '<span class="text-danger">'.$_SESSION['nrnewmessages'].'</span>';
129 129
 
130 130
 $ph['UserInfo'] = $modx->parseText($tpl, array(
131 131
 	'username' => $modx->getLoginUserName(),
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 $from[] = " us LEFT JOIN [+prefix+]active_users au ON au.sid=us.sid WHERE au.action <> '8'";
141 141
 $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
142 142
 
143
-if($modx->db->getRecordCount($rs) < 1) {
143
+if ($modx->db->getRecordCount($rs) < 1) {
144 144
 	$html = '<p>[%no_active_users_found%]</p>';
145 145
 } else {
146
-	include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
146
+	include_once(MODX_MANAGER_PATH.'includes/actionlist.inc.php');
147 147
 	$now = $_SERVER['REQUEST_TIME'] + $server_offset_time;
148 148
 	$ph['now'] = strftime('%H:%M:%S', $now);
149 149
 	$timetocheck = ($now - (60 * 20)); //+$server_offset_time;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	$userList = array();
169 169
 	$userCount = array();
170 170
 	// Create userlist with session-count first before output
171
-	while($activeusers = $modx->db->getRow($rs)) {
171
+	while ($activeusers = $modx->db->getRow($rs)) {
172 172
 		$userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1;
173 173
 
174 174
 		$idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : '';
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
 			$currentaction
187 187
 		);
188 188
 	}
189
-	foreach($userList as $params) {
189
+	foreach ($userList as $params) {
190 190
 		$params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : '';
191
-		$html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
191
+		$html .= "\n\t\t".vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
192 192
 	}
193 193
 
194 194
 	$html .= '
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 $ph['OnlineInfo'] = $html;
201 201
 
202 202
 // include rss feeds for important forum topics
203
-include_once(MODX_MANAGER_PATH . 'includes/rss.inc.php');
203
+include_once(MODX_MANAGER_PATH.'includes/rss.inc.php');
204 204
 $ph['modx_security_notices_content'] = $feedData['modx_security_notices_content'];
205 205
 $ph['modx_news_content'] = $feedData['modx_news_content'];
206 206
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 // invoke event OnManagerWelcomePrerender
233 233
 $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
234
-if(is_array($evtOut)) {
234
+if (is_array($evtOut)) {
235 235
 	$output = implode('', $evtOut);
236 236
 	$ph['OnManagerWelcomePrerender'] = $output;
237 237
 }
@@ -365,57 +365,57 @@  discard block
 block discarded – undo
365 365
 
366 366
 // invoke OnManagerWelcomeHome event
367 367
 $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
368
-if(is_array($sitewidgets)) {
368
+if (is_array($sitewidgets)) {
369 369
 	$newwidgets = array();
370
-    foreach($sitewidgets as $widget){
370
+    foreach ($sitewidgets as $widget) {
371 371
         $newwidgets = array_merge($newwidgets, unserialize($widget));
372 372
     }
373 373
     $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets;
374 374
 }
375 375
 
376
-usort($widgets, function ($a, $b) {
376
+usort($widgets, function($a, $b){
377 377
 	return $a['menuindex'] - $b['menuindex'];
378 378
 });
379 379
 
380 380
 $tpl = getTplWidget();
381 381
 $output = '';
382
-foreach($widgets as $widget) {
383
-	if ($widget['hide'] != '1'){
382
+foreach ($widgets as $widget) {
383
+	if ($widget['hide'] != '1') {
384 384
 		$output .= $modx->parseText($tpl, $widget);
385 385
 	}
386 386
 }
387 387
 $ph['widgets'] = $output;
388 388
 
389 389
 // load template
390
-if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
391
-	$modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl';
390
+if (!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
391
+	$modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH.'media/style/common/welcome.tpl';
392 392
 }
393 393
 
394 394
 $target = $modx->config['manager_welcome_tpl'];
395 395
 $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target);
396 396
 $target = $modx->mergeSettingsContent($target);
397 397
 
398
-if(substr($target, 0, 1) === '@') {
399
-	if(substr($target, 0, 6) === '@CHUNK') {
398
+if (substr($target, 0, 1) === '@') {
399
+	if (substr($target, 0, 6) === '@CHUNK') {
400 400
 		$content = $modx->getChunk(trim(substr($target, 7)));
401
-	} elseif(substr($target, 0, 5) === '@FILE') {
401
+	} elseif (substr($target, 0, 5) === '@FILE') {
402 402
 		$content = file_get_contents(trim(substr($target, 6)));
403 403
 	} else {
404 404
 		$content = '';
405 405
 	}
406 406
 } else {
407 407
 	$chunk = $modx->getChunk($target);
408
-	if($chunk !== false && !empty($chunk)) {
408
+	if ($chunk !== false && !empty($chunk)) {
409 409
 		$content = $chunk;
410
-	} elseif(is_file(MODX_BASE_PATH . $target)) {
411
-		$content = file_get_contents(MODX_BASE_PATH . $target);
412
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
413
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl');
414
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible
410
+	} elseif (is_file(MODX_BASE_PATH.$target)) {
411
+		$content = file_get_contents(MODX_BASE_PATH.$target);
412
+	} elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/welcome.tpl')) {
413
+		$content = file_get_contents(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/welcome.tpl');
414
+	} elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/html/welcome.html')) // ClipperCMS compatible
415 415
 	{
416
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
416
+		$content = file_get_contents(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/html/welcome.html');
417 417
 	} else {
418
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl');
418
+		$content = file_get_contents(MODX_MANAGER_PATH.'media/style/common/welcome.tpl');
419 419
 	}
420 420
 }
421 421
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 $content = $modx->mergeConditionalTagsContent($content);
424 424
 $content = $modx->mergeSettingsContent($content);
425 425
 $content = $modx->parseText($content, $ph);
426
-if(strpos($content, '[+') !== false) {
426
+if (strpos($content, '[+') !== false) {
427 427
 	$modx->toPlaceholders($ph);
428 428
 	$content = $modx->mergePlaceholderContent($content);
429 429
 }
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 $content = $modx->parseText($content, $_style, '[&', '&]');
433 433
 $content = $modx->cleanUpMODXTags($content); //cleanup
434 434
 
435
-if($js = $modx->getRegisteredClientScripts()) {
435
+if ($js = $modx->getRegisteredClientScripts()) {
436 436
 	$content .= $js;
437 437
 }
438 438
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 //	<a href="javascript:;" class="setting"><i class="fa fa-cog"></i></a>
443 443
 //  <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a>
444 444
 //</span>
445
-function getTplWidget() { // recent document info
445
+function getTplWidget(){ // recent document info
446 446
 	return '
447 447
 		<div class="[+cols+]" id="[+id+]">
448 448
 			<div class="card"[+cardAttr+]>
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 ';
454 454
 }
455 455
 
456
-function getRecentInfo() { // recent document info
456
+function getRecentInfo(){ // recent document info
457 457
 	$modx = evolutionCMS();
458 458
 
459 459
 	$modx->addSnippet('recentInfoList', 'getRecentInfoList');
@@ -479,12 +479,12 @@  discard block
 block discarded – undo
479 479
 	return $html;
480 480
 }
481 481
 
482
-function getRecentInfoList() {
482
+function getRecentInfoList(){
483 483
 	$modx = evolutionCMS();
484 484
 
485 485
 	$rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
486 486
 
487
-	if($modx->db->getRecordCount($rs) < 1) {
487
+	if ($modx->db->getRecordCount($rs) < 1) {
488 488
 		return '<tr><td>[%no_activity_message%]</td></tr>';
489 489
 	}
490 490
 
@@ -494,20 +494,20 @@  discard block
 block discarded – undo
494 494
 	$btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&amp;id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> ';
495 495
 
496 496
 	$output = array();
497
-	while($ph = $modx->db->getRow($rs)) {
497
+	while ($ph = $modx->db->getRow($rs)) {
498 498
 		$docid = $ph['id'];
499 499
 		$_ = $modx->getUserInfo($ph['editedby']);
500 500
 		$ph['username'] = $_['username'];
501 501
 
502
-		if($ph['deleted'] == 1) {
502
+		if ($ph['deleted'] == 1) {
503 503
 			$ph['status'] = 'deleted text-danger';
504
-		} elseif($ph['published'] == 0) {
504
+		} elseif ($ph['published'] == 0) {
505 505
 			$ph['status'] = 'unpublished font-italic text-muted';
506 506
 		} else {
507 507
 			$ph['status'] = 'published';
508 508
 		}
509 509
 
510
-		if($modx->hasPermission('edit_document')) {
510
+		if ($modx->hasPermission('edit_document')) {
511 511
 			$ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
512 512
 		} else {
513 513
 			$ph['edit_btn'] = '';
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
 			$preview_disabled
523 523
 		), $btntpl['preview_btn']);
524 524
 
525
-		if($modx->hasPermission('delete_document')) {
526
-			if($ph['deleted'] == 0) {
525
+		if ($modx->hasPermission('delete_document')) {
526
+			if ($ph['deleted'] == 0) {
527 527
 				$delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&amp;id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> ';
528 528
 			} else {
529 529
 				$delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&amp;id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> ';
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 			$ph['delete_btn'] = '';
534 534
 		}
535 535
 
536
-		if($ph['deleted'] == 1 && $ph['published'] == 0) {
536
+		if ($ph['deleted'] == 1 && $ph['published'] == 0) {
537 537
 			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
538
-		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
538
+		} elseif ($ph['deleted'] == 1 && $ph['published'] == 1) {
539 539
 			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
540
-		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
540
+		} elseif ($ph['deleted'] == 0 && $ph['published'] == 0) {
541 541
 			$publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
542 542
 		} else {
543 543
 			$publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
@@ -546,16 +546,16 @@  discard block
 block discarded – undo
546 546
 
547 547
 		$ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
548 548
 
549
-		if($ph['longtitle'] == '') {
549
+		if ($ph['longtitle'] == '') {
550 550
 			$ph['longtitle'] = '(<i>[%not_set%]</i>)';
551 551
 		}
552
-		if($ph['description'] == '') {
552
+		if ($ph['description'] == '') {
553 553
 			$ph['description'] = '(<i>[%not_set%]</i>)';
554 554
 		}
555
-		if($ph['introtext'] == '') {
555
+		if ($ph['introtext'] == '') {
556 556
 			$ph['introtext'] = '(<i>[%not_set%]</i>)';
557 557
 		}
558
-		if($ph['alias'] == '') {
558
+		if ($ph['alias'] == '') {
559 559
 			$ph['alias'] = '(<i>[%not_set%]</i>)';
560 560
 		}
561 561
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 	return implode("\n", $output);
565 565
 }
566 566
 
567
-function getRecentInfoRowTpl() {
567
+function getRecentInfoRowTpl(){
568 568
 	$tpl = '
569 569
 						<tr>
570 570
 							<td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td>
@@ -593,11 +593,11 @@  discard block
 block discarded – undo
593 593
 }
594 594
 
595 595
 // setup icons
596
-function wrapIcon($i, $action) {
596
+function wrapIcon($i, $action){
597 597
 	return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
598 598
 }
599 599
 
600
-function getStartUpScript() {
600
+function getStartUpScript(){
601 601
 	$script = '
602 602
         <script type="text/javascript">
603 603
         function hideConfigCheckWarning(key) {
Please login to merge, or discard this patch.
Braces   +77 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  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
 
6 6
 unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes
7 7
 
8
-if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
8
+if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
9 9
 	// seems to be a new install - send the user to the configuration page
10 10
 	exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
11 11
 }
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 $_SESSION['nrnewmessages'] = 0;
17 17
 
18 18
 // setup message info
19
-if($modx->hasPermission('messages')) {
19
+if($modx->hasPermission('messages')) {
20 20
 	include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php');
21 21
 	$_SESSION['nrtotalmessages'] = $nrtotalmessages;
22 22
 	$_SESSION['nrnewmessages'] = $nrnewmessages;
@@ -32,46 +32,46 @@  discard block
 block discarded – undo
32 32
 }
33 33
 
34 34
 // setup icons
35
-if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
35
+if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
36 36
 	$icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]';
37 37
 	$ph['SecurityIcon'] = wrapIcon($icon, 75);
38 38
 }
39
-if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
39
+if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
40 40
 	$icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]';
41 41
 	$ph['WebUserIcon'] = wrapIcon($icon, 99);
42 42
 }
43
-if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
43
+if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
44 44
 	$icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]';
45 45
 	$ph['ModulesIcon'] = wrapIcon($icon, 106);
46 46
 }
47
-if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
47
+if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
48 48
 	$icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]';
49 49
 	$ph['ResourcesIcon'] = wrapIcon($icon, 76);
50 50
 }
51
-if($modx->hasPermission('bk_manager')) {
51
+if($modx->hasPermission('bk_manager')) {
52 52
 	$icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]';
53 53
 	$ph['BackupIcon'] = wrapIcon($icon, 93);
54 54
 }
55
-if($modx->hasPermission('help')) {
55
+if($modx->hasPermission('help')) {
56 56
 	$icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]';
57 57
 	$ph['HelpIcon'] = wrapIcon($icon, 9);
58 58
 }
59 59
 // do some config checks
60
-if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
60
+if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
61 61
 	include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php');
62
-	if($config_check_results != $_lang['configcheck_ok']) {
62
+	if($config_check_results != $_lang['configcheck_ok']) {
63 63
 		$ph['config_check_results'] = $config_check_results;
64 64
 		$ph['config_display'] = 'block';
65
-	} else {
65
+	} else {
66 66
 		$ph['config_display'] = 'none';
67 67
 	}
68
-} else {
68
+} else {
69 69
 	$ph['config_display'] = 'none';
70 70
 }
71 71
 
72 72
 // Check logout-reminder
73
-if(isset($_SESSION['show_logout_reminder'])) {
74
-	switch($_SESSION['show_logout_reminder']['type']) {
73
+if(isset($_SESSION['show_logout_reminder'])) {
74
+	switch($_SESSION['show_logout_reminder']['type']) {
75 75
 		case 'logout_reminder':
76 76
 			$date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly');
77 77
 			$ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	}
80 80
 	$ph['show_logout_reminder'] = 'block';
81 81
 	unset($_SESSION['show_logout_reminder']);
82
-} else {
82
+} else {
83 83
 	$ph['show_logout_reminder'] = 'none';
84 84
 }
85 85
 
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 $from[] = " us LEFT JOIN [+prefix+]active_users au ON au.sid=us.sid WHERE au.action <> '8'";
141 141
 $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
142 142
 
143
-if($modx->db->getRecordCount($rs) < 1) {
143
+if($modx->db->getRecordCount($rs) < 1) {
144 144
 	$html = '<p>[%no_active_users_found%]</p>';
145
-} else {
145
+} else {
146 146
 	include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
147 147
 	$now = $_SERVER['REQUEST_TIME'] + $server_offset_time;
148 148
 	$ph['now'] = strftime('%H:%M:%S', $now);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	$userList = array();
169 169
 	$userCount = array();
170 170
 	// Create userlist with session-count first before output
171
-	while($activeusers = $modx->db->getRow($rs)) {
171
+	while($activeusers = $modx->db->getRow($rs)) {
172 172
 		$userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1;
173 173
 
174 174
 		$idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : '';
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 			$currentaction
187 187
 		);
188 188
 	}
189
-	foreach($userList as $params) {
189
+	foreach($userList as $params) {
190 190
 		$params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : '';
191 191
 		$html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
192 192
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 // invoke event OnManagerWelcomePrerender
233 233
 $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
234
-if(is_array($evtOut)) {
234
+if(is_array($evtOut)) {
235 235
 	$output = implode('', $evtOut);
236 236
 	$ph['OnManagerWelcomePrerender'] = $output;
237 237
 }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	'body' => '<div class="widget-stage">[+RecentInfo+]</div>',
341 341
 	'hide'=>'0'
342 342
 );
343
-if ($modx->config['rss_url_news']) {
343
+if ($modx->config['rss_url_news']) {
344 344
     $widgets['news'] = array(
345 345
         'menuindex' => '40',
346 346
         'id' => 'news',
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
         'hide'=>'0'
352 352
     );
353 353
 }
354
-if ($modx->config['rss_url_security']) {
354
+if ($modx->config['rss_url_security']) {
355 355
     $widgets['security'] = array(
356 356
         'menuindex' => '50',
357 357
         'id' => 'security',
@@ -365,29 +365,29 @@  discard block
 block discarded – undo
365 365
 
366 366
 // invoke OnManagerWelcomeHome event
367 367
 $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
368
-if(is_array($sitewidgets)) {
368
+if(is_array($sitewidgets)) {
369 369
 	$newwidgets = array();
370
-    foreach($sitewidgets as $widget){
370
+    foreach($sitewidgets as $widget) {
371 371
         $newwidgets = array_merge($newwidgets, unserialize($widget));
372 372
     }
373 373
     $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets;
374 374
 }
375 375
 
376
-usort($widgets, function ($a, $b) {
376
+usort($widgets, function ($a, $b){
377 377
 	return $a['menuindex'] - $b['menuindex'];
378 378
 });
379 379
 
380 380
 $tpl = getTplWidget();
381 381
 $output = '';
382
-foreach($widgets as $widget) {
383
-	if ($widget['hide'] != '1'){
382
+foreach($widgets as $widget) {
383
+	if ($widget['hide'] != '1') {
384 384
 		$output .= $modx->parseText($tpl, $widget);
385 385
 	}
386 386
 }
387 387
 $ph['widgets'] = $output;
388 388
 
389 389
 // load template
390
-if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
390
+if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
391 391
 	$modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl';
392 392
 }
393 393
 
@@ -395,26 +395,28 @@  discard block
 block discarded – undo
395 395
 $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target);
396 396
 $target = $modx->mergeSettingsContent($target);
397 397
 
398
-if(substr($target, 0, 1) === '@') {
399
-	if(substr($target, 0, 6) === '@CHUNK') {
398
+if(substr($target, 0, 1) === '@') {
399
+	if(substr($target, 0, 6) === '@CHUNK') {
400 400
 		$content = $modx->getChunk(trim(substr($target, 7)));
401
-	} elseif(substr($target, 0, 5) === '@FILE') {
401
+	} elseif(substr($target, 0, 5) === '@FILE') {
402 402
 		$content = file_get_contents(trim(substr($target, 6)));
403
-	} else {
403
+	} else {
404 404
 		$content = '';
405 405
 	}
406
-} else {
406
+} else {
407 407
 	$chunk = $modx->getChunk($target);
408
-	if($chunk !== false && !empty($chunk)) {
408
+	if($chunk !== false && !empty($chunk)) {
409 409
 		$content = $chunk;
410
-	} elseif(is_file(MODX_BASE_PATH . $target)) {
410
+	} elseif(is_file(MODX_BASE_PATH . $target)) {
411 411
 		$content = file_get_contents(MODX_BASE_PATH . $target);
412
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
412
+	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
413 413
 		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl');
414
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible
414
+	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) {
415
+	    // ClipperCMS compatible
415 416
 	{
416
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
417
-	} else {
417
+		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
418
+	}
419
+	} else {
418 420
 		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl');
419 421
 	}
420 422
 }
@@ -423,7 +425,7 @@  discard block
 block discarded – undo
423 425
 $content = $modx->mergeConditionalTagsContent($content);
424 426
 $content = $modx->mergeSettingsContent($content);
425 427
 $content = $modx->parseText($content, $ph);
426
-if(strpos($content, '[+') !== false) {
428
+if(strpos($content, '[+') !== false) {
427 429
 	$modx->toPlaceholders($ph);
428 430
 	$content = $modx->mergePlaceholderContent($content);
429 431
 }
@@ -432,7 +434,7 @@  discard block
 block discarded – undo
432 434
 $content = $modx->parseText($content, $_style, '[&', '&]');
433 435
 $content = $modx->cleanUpMODXTags($content); //cleanup
434 436
 
435
-if($js = $modx->getRegisteredClientScripts()) {
437
+if($js = $modx->getRegisteredClientScripts()) {
436 438
 	$content .= $js;
437 439
 }
438 440
 
@@ -442,7 +444,9 @@  discard block
 block discarded – undo
442 444
 //	<a href="javascript:;" class="setting"><i class="fa fa-cog"></i></a>
443 445
 //  <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a>
444 446
 //</span>
445
-function getTplWidget() { // recent document info
447
+function getTplWidget()
448
+{
449
+// recent document info
446 450
 	return '
447 451
 		<div class="[+cols+]" id="[+id+]">
448 452
 			<div class="card"[+cardAttr+]>
@@ -453,7 +457,9 @@  discard block
 block discarded – undo
453 457
 ';
454 458
 }
455 459
 
456
-function getRecentInfo() { // recent document info
460
+function getRecentInfo()
461
+{
462
+// recent document info
457 463
 	$modx = evolutionCMS();
458 464
 
459 465
 	$modx->addSnippet('recentInfoList', 'getRecentInfoList');
@@ -479,12 +485,13 @@  discard block
 block discarded – undo
479 485
 	return $html;
480 486
 }
481 487
 
482
-function getRecentInfoList() {
488
+function getRecentInfoList()
489
+{
483 490
 	$modx = evolutionCMS();
484 491
 
485 492
 	$rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
486 493
 
487
-	if($modx->db->getRecordCount($rs) < 1) {
494
+	if($modx->db->getRecordCount($rs) < 1) {
488 495
 		return '<tr><td>[%no_activity_message%]</td></tr>';
489 496
 	}
490 497
 
@@ -494,22 +501,22 @@  discard block
 block discarded – undo
494 501
 	$btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&amp;id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> ';
495 502
 
496 503
 	$output = array();
497
-	while($ph = $modx->db->getRow($rs)) {
504
+	while($ph = $modx->db->getRow($rs)) {
498 505
 		$docid = $ph['id'];
499 506
 		$_ = $modx->getUserInfo($ph['editedby']);
500 507
 		$ph['username'] = $_['username'];
501 508
 
502
-		if($ph['deleted'] == 1) {
509
+		if($ph['deleted'] == 1) {
503 510
 			$ph['status'] = 'deleted text-danger';
504
-		} elseif($ph['published'] == 0) {
511
+		} elseif($ph['published'] == 0) {
505 512
 			$ph['status'] = 'unpublished font-italic text-muted';
506
-		} else {
513
+		} else {
507 514
 			$ph['status'] = 'published';
508 515
 		}
509 516
 
510
-		if($modx->hasPermission('edit_document')) {
517
+		if($modx->hasPermission('edit_document')) {
511 518
 			$ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
512
-		} else {
519
+		} else {
513 520
 			$ph['edit_btn'] = '';
514 521
 		}
515 522
 
@@ -522,40 +529,40 @@  discard block
 block discarded – undo
522 529
 			$preview_disabled
523 530
 		), $btntpl['preview_btn']);
524 531
 
525
-		if($modx->hasPermission('delete_document')) {
526
-			if($ph['deleted'] == 0) {
532
+		if($modx->hasPermission('delete_document')) {
533
+			if($ph['deleted'] == 0) {
527 534
 				$delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&amp;id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> ';
528
-			} else {
535
+			} else {
529 536
 				$delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&amp;id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> ';
530 537
 			}
531 538
 			$ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
532
-		} else {
539
+		} else {
533 540
 			$ph['delete_btn'] = '';
534 541
 		}
535 542
 
536
-		if($ph['deleted'] == 1 && $ph['published'] == 0) {
543
+		if($ph['deleted'] == 1 && $ph['published'] == 0) {
537 544
 			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
538
-		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
545
+		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
539 546
 			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
540
-		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
547
+		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
541 548
 			$publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
542
-		} else {
549
+		} else {
543 550
 			$publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
544 551
 		}
545 552
 		$ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
546 553
 
547 554
 		$ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
548 555
 
549
-		if($ph['longtitle'] == '') {
556
+		if($ph['longtitle'] == '') {
550 557
 			$ph['longtitle'] = '(<i>[%not_set%]</i>)';
551 558
 		}
552
-		if($ph['description'] == '') {
559
+		if($ph['description'] == '') {
553 560
 			$ph['description'] = '(<i>[%not_set%]</i>)';
554 561
 		}
555
-		if($ph['introtext'] == '') {
562
+		if($ph['introtext'] == '') {
556 563
 			$ph['introtext'] = '(<i>[%not_set%]</i>)';
557 564
 		}
558
-		if($ph['alias'] == '') {
565
+		if($ph['alias'] == '') {
559 566
 			$ph['alias'] = '(<i>[%not_set%]</i>)';
560 567
 		}
561 568
 
@@ -564,7 +571,8 @@  discard block
 block discarded – undo
564 571
 	return implode("\n", $output);
565 572
 }
566 573
 
567
-function getRecentInfoRowTpl() {
574
+function getRecentInfoRowTpl()
575
+{
568 576
 	$tpl = '
569 577
 						<tr>
570 578
 							<td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td>
@@ -593,11 +601,13 @@  discard block
 block discarded – undo
593 601
 }
594 602
 
595 603
 // setup icons
596
-function wrapIcon($i, $action) {
604
+function wrapIcon($i, $action)
605
+{
597 606
 	return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
598 607
 }
599 608
 
600
-function getStartUpScript() {
609
+function getStartUpScript()
610
+{
601 611
 	$script = '
602 612
         <script type="text/javascript">
603 613
         function hideConfigCheckWarning(key) {
Please login to merge, or discard this patch.
manager/actions/import_site.static.php 3 patches
Indentation   +333 added lines, -333 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  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('import_static')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 // Files to upload
10 10
 $allowedfiles = array(
11
-	'html',
12
-	'htm',
13
-	'shtml',
14
-	'xml'
11
+    'html',
12
+    'htm',
13
+    'shtml',
14
+    'xml'
15 15
 );
16 16
 ?>
17 17
 	<script language="javascript">
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	<div class="tab-page">
44 44
 		<div class="container container-body">
45 45
 			<?php
46
-			if(!isset($_POST['import'])) {
47
-				echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>";
48
-				?>
46
+            if(!isset($_POST['import'])) {
47
+                echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>";
48
+                ?>
49 49
 				<form action="index.php" method="post" name="importFrm">
50 50
 					<input type="hidden" name="import" value="import" />
51 51
 					<input type="hidden" name="a" value="95" />
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
 					<a href="javascript:;" class="btn btn-primary" onclick="window.importFrm.submit();"><i class="<?= $_style["actions_save"] ?>"></i> <?= $_lang["import_site_start"] ?></a>
86 86
 				</form>
87 87
 			<?php
88
-			} else {
89
-			run();
90
-			$modx->clearCache('full');
91
-			?>
88
+            } else {
89
+            run();
90
+            $modx->clearCache('full');
91
+            ?>
92 92
 				<a href="javascript:;" class="btn btn-primary" onclick="window.location.href='index.php?a=2';"><i class="<?= $_style["actions_close"] ?>"></i> <?= $_lang["close"] ?></a>
93 93
 				<script type="text/javascript">
94 94
 					top.mainMenu.reloadtree();
95 95
 					parent.tree.ca = 'open';
96 96
 				</script>
97 97
 				<?php
98
-			}
99
-			?>
98
+            }
99
+            ?>
100 100
 		</div>
101 101
 	</div>
102 102
 
@@ -105,64 +105,64 @@  discard block
 block discarded – undo
105 105
  * @return string
106 106
  */
107 107
 function run() {
108
-	$modx = evolutionCMS(); global $_lang;
108
+    $modx = evolutionCMS(); global $_lang;
109 109
 
110
-	$tbl_site_content = $modx->getFullTableName('site_content');
111
-	$output = '';
112
-	$maxtime = $_POST['maxtime'];
110
+    $tbl_site_content = $modx->getFullTableName('site_content');
111
+    $output = '';
112
+    $maxtime = $_POST['maxtime'];
113 113
 
114
-	if(!is_numeric($maxtime)) {
115
-		$maxtime = 30;
116
-	}
114
+    if(!is_numeric($maxtime)) {
115
+        $maxtime = 30;
116
+    }
117 117
 
118
-	@set_time_limit($maxtime);
118
+    @set_time_limit($maxtime);
119 119
 
120
-	$mtime = microtime();
121
-	$mtime = explode(' ', $mtime);
122
-	$mtime = $mtime[1] + $mtime[0];
123
-	$importstart = $mtime;
120
+    $mtime = microtime();
121
+    $mtime = explode(' ', $mtime);
122
+    $mtime = $mtime[1] + $mtime[0];
123
+    $importstart = $mtime;
124 124
 
125
-	if($_POST['reset'] == 'on') {
126
-		$modx->db->truncate($tbl_site_content);
127
-		$modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
128
-	}
125
+    if($_POST['reset'] == 'on') {
126
+        $modx->db->truncate($tbl_site_content);
127
+        $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
128
+    }
129 129
 
130
-	$parent = (int)$_POST['parent'];
130
+    $parent = (int)$_POST['parent'];
131 131
 
132
-	if(is_dir(MODX_BASE_PATH . 'temp/import')) {
133
-		$filedir = MODX_BASE_PATH . 'temp/import/';
134
-	} elseif(is_dir(MODX_BASE_PATH . 'assets/import')) {
135
-		$filedir = MODX_BASE_PATH . 'assets/import/';
136
-	} else {
132
+    if(is_dir(MODX_BASE_PATH . 'temp/import')) {
133
+        $filedir = MODX_BASE_PATH . 'temp/import/';
134
+    } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) {
135
+        $filedir = MODX_BASE_PATH . 'assets/import/';
136
+    } else {
137 137
         $filedir = '';
138 138
     }
139 139
 
140
-	$filesfound = 0;
140
+    $filesfound = 0;
141 141
 
142
-	$files = getFiles($filedir);
143
-	$files = pop_index($files);
142
+    $files = getFiles($filedir);
143
+    $files = pop_index($files);
144 144
 
145
-	// no. of files to import
146
-	$output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
145
+    // no. of files to import
146
+    $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
147 147
 
148
-	// import files
149
-	if(0 < count($files)) {
150
-		$modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'");
151
-		importFiles($parent, $filedir, $files, 'root');
152
-	}
148
+    // import files
149
+    if(0 < count($files)) {
150
+        $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'");
151
+        importFiles($parent, $filedir, $files, 'root');
152
+    }
153 153
 
154
-	$mtime = microtime();
155
-	$mtime = explode(' ', $mtime);
156
-	$mtime = $mtime[1] + $mtime[0];
157
-	$importend = $mtime;
158
-	$totaltime = ($importend - $importstart);
159
-	$output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
154
+    $mtime = microtime();
155
+    $mtime = explode(' ', $mtime);
156
+    $mtime = $mtime[1] + $mtime[0];
157
+    $importend = $mtime;
158
+    $totaltime = ($importend - $importstart);
159
+    $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
160 160
 
161
-	if($_POST['convert_link'] == 'on') {
162
-		convertLink();
163
-	}
161
+    if($_POST['convert_link'] == 'on') {
162
+        convertLink();
163
+    }
164 164
 
165
-	return $output;
165
+    return $output;
166 166
 }
167 167
 
168 168
 /**
@@ -172,144 +172,144 @@  discard block
 block discarded – undo
172 172
  * @param string $mode
173 173
  */
174 174
 function importFiles($parent, $filedir, $files, $mode) {
175
-	$modx = evolutionCMS();
176
-	global $_lang, $allowedfiles;
177
-	global $search_default, $cache_default, $publish_default;
178
-
179
-	$tbl_site_content = $modx->getFullTableName('site_content');
180
-	$tbl_system_settings = $modx->getFullTableName('system_settings');
181
-
182
-	$createdby = $modx->getLoginUserID();
183
-	if(!is_array($files)) {
184
-		return;
185
-	}
186
-	if($_POST['object'] === 'all') {
187
-		$modx->config['default_template'] = '0';
188
-		$richtext = '0';
189
-	} else {
190
-		$richtext = '1';
191
-	}
192
-
193
-	foreach($files as $id => $value) {
194
-		if(is_array($value)) {
195
-			// create folder
196
-			$alias = $id;
197
-			printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
198
-			$field = array();
199
-			$field['type'] = 'document';
200
-			$field['contentType'] = 'text/html';
201
-			$field['published'] = $publish_default;
202
-			$field['parent'] = $parent;
203
-			$field['alias'] = $modx->stripAlias($alias);
204
-			$field['richtext'] = $richtext;
205
-			$field['template'] = $modx->config['default_template'];
206
-			$field['searchable'] = $search_default;
207
-			$field['cacheable'] = $cache_default;
208
-			$field['createdby'] = $createdby;
209
-			$field['isfolder'] = 1;
210
-			$field['menuindex'] = 1;
211
-			$find = false;
212
-			foreach(array(
213
-						'index.html',
214
-						'index.htm'
215
-					) as $filename) {
216
-				$filepath = $filedir . $alias . '/' . $filename;
217
-				if($find === false && file_exists($filepath)) {
218
-					$file = getFileContent($filepath);
219
-					list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
220
-
221
-					$date = filemtime($filepath);
222
-					$field['pagetitle'] = $pagetitle;
223
-					$field['longtitle'] = $pagetitle;
224
-					$field['description'] = $description;
225
-					$field['content'] = $modx->db->escape($content);
226
-					$field['createdon'] = $date;
227
-					$field['editedon'] = $date;
228
-					$newid = $modx->db->insert($field, $tbl_site_content);
229
-					if($newid) {
230
-						$find = true;
231
-						echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
232
-						importFiles($newid, $filedir . $alias . '/', $value, 'sub');
233
-					} else {
234
-						echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
235
-						exit;
236
-					}
237
-				}
238
-			}
239
-			if($find === false) {
240
-				$date = time();
241
-				$field['pagetitle'] = '---';
242
-				$field['content'] = '';
243
-				$field['createdon'] = $date;
244
-				$field['editedon'] = $date;
245
-				$field['hidemenu'] = '1';
246
-				$newid = $modx->db->insert($field, $tbl_site_content);
247
-				if($newid) {
248
-					$find = true;
249
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
250
-					importFiles($newid, $filedir . $alias . '/', $value, 'sub');
251
-				} else {
252
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
253
-					exit;
254
-				}
255
-			}
256
-		} else {
257
-			// create document
258
-			if($mode == 'sub' && $value == 'index.html') {
259
-				continue;
260
-			}
261
-			$filename = $value;
262
-			$fparts = explode('.', $value);
263
-			$alias = $fparts[0];
264
-			$ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
265
-			printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
266
-
267
-			if(!in_array($ext, $allowedfiles)) {
268
-				echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
269
-			} else {
270
-				$filepath = $filedir . $filename;
271
-				$file = getFileContent($filepath);
272
-				list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
273
-
274
-				$date = filemtime($filepath);
275
-				$field = array();
276
-				$field['type'] = 'document';
277
-				$field['contentType'] = 'text/html';
278
-				$field['pagetitle'] = $pagetitle;
279
-				$field['longtitle'] = $pagetitle;
280
-				$field['description'] = $description;
281
-				$field['alias'] = $modx->stripAlias($alias);
282
-				$field['published'] = $publish_default;
283
-				$field['parent'] = $parent;
284
-				$field['content'] = $modx->db->escape($content);
285
-				$field['richtext'] = $richtext;
286
-				$field['template'] = $modx->config['default_template'];
287
-				$field['searchable'] = $search_default;
288
-				$field['cacheable'] = $cache_default;
289
-				$field['createdby'] = $createdby;
290
-				$field['createdon'] = $date;
291
-				$field['editedon'] = $date;
292
-				$field['isfolder'] = 0;
293
-				$field['menuindex'] = ($alias == 'index') ? 0 : 2;
294
-				$newid = $modx->db->insert($field, $tbl_site_content);
295
-				if($newid) {
296
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
297
-				} else {
298
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
299
-					exit;
300
-				}
301
-
302
-				$is_site_start = false;
303
-				if($filename == 'index.html') {
304
-					$is_site_start = true;
305
-				}
306
-				if($is_site_start == true && $_POST['reset'] == 'on') {
307
-					$modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'");
308
-					$modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'");
309
-				}
310
-			}
311
-		}
312
-	}
175
+    $modx = evolutionCMS();
176
+    global $_lang, $allowedfiles;
177
+    global $search_default, $cache_default, $publish_default;
178
+
179
+    $tbl_site_content = $modx->getFullTableName('site_content');
180
+    $tbl_system_settings = $modx->getFullTableName('system_settings');
181
+
182
+    $createdby = $modx->getLoginUserID();
183
+    if(!is_array($files)) {
184
+        return;
185
+    }
186
+    if($_POST['object'] === 'all') {
187
+        $modx->config['default_template'] = '0';
188
+        $richtext = '0';
189
+    } else {
190
+        $richtext = '1';
191
+    }
192
+
193
+    foreach($files as $id => $value) {
194
+        if(is_array($value)) {
195
+            // create folder
196
+            $alias = $id;
197
+            printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
198
+            $field = array();
199
+            $field['type'] = 'document';
200
+            $field['contentType'] = 'text/html';
201
+            $field['published'] = $publish_default;
202
+            $field['parent'] = $parent;
203
+            $field['alias'] = $modx->stripAlias($alias);
204
+            $field['richtext'] = $richtext;
205
+            $field['template'] = $modx->config['default_template'];
206
+            $field['searchable'] = $search_default;
207
+            $field['cacheable'] = $cache_default;
208
+            $field['createdby'] = $createdby;
209
+            $field['isfolder'] = 1;
210
+            $field['menuindex'] = 1;
211
+            $find = false;
212
+            foreach(array(
213
+                        'index.html',
214
+                        'index.htm'
215
+                    ) as $filename) {
216
+                $filepath = $filedir . $alias . '/' . $filename;
217
+                if($find === false && file_exists($filepath)) {
218
+                    $file = getFileContent($filepath);
219
+                    list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
220
+
221
+                    $date = filemtime($filepath);
222
+                    $field['pagetitle'] = $pagetitle;
223
+                    $field['longtitle'] = $pagetitle;
224
+                    $field['description'] = $description;
225
+                    $field['content'] = $modx->db->escape($content);
226
+                    $field['createdon'] = $date;
227
+                    $field['editedon'] = $date;
228
+                    $newid = $modx->db->insert($field, $tbl_site_content);
229
+                    if($newid) {
230
+                        $find = true;
231
+                        echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
232
+                        importFiles($newid, $filedir . $alias . '/', $value, 'sub');
233
+                    } else {
234
+                        echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
235
+                        exit;
236
+                    }
237
+                }
238
+            }
239
+            if($find === false) {
240
+                $date = time();
241
+                $field['pagetitle'] = '---';
242
+                $field['content'] = '';
243
+                $field['createdon'] = $date;
244
+                $field['editedon'] = $date;
245
+                $field['hidemenu'] = '1';
246
+                $newid = $modx->db->insert($field, $tbl_site_content);
247
+                if($newid) {
248
+                    $find = true;
249
+                    echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
250
+                    importFiles($newid, $filedir . $alias . '/', $value, 'sub');
251
+                } else {
252
+                    echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
253
+                    exit;
254
+                }
255
+            }
256
+        } else {
257
+            // create document
258
+            if($mode == 'sub' && $value == 'index.html') {
259
+                continue;
260
+            }
261
+            $filename = $value;
262
+            $fparts = explode('.', $value);
263
+            $alias = $fparts[0];
264
+            $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
265
+            printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
266
+
267
+            if(!in_array($ext, $allowedfiles)) {
268
+                echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
269
+            } else {
270
+                $filepath = $filedir . $filename;
271
+                $file = getFileContent($filepath);
272
+                list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
273
+
274
+                $date = filemtime($filepath);
275
+                $field = array();
276
+                $field['type'] = 'document';
277
+                $field['contentType'] = 'text/html';
278
+                $field['pagetitle'] = $pagetitle;
279
+                $field['longtitle'] = $pagetitle;
280
+                $field['description'] = $description;
281
+                $field['alias'] = $modx->stripAlias($alias);
282
+                $field['published'] = $publish_default;
283
+                $field['parent'] = $parent;
284
+                $field['content'] = $modx->db->escape($content);
285
+                $field['richtext'] = $richtext;
286
+                $field['template'] = $modx->config['default_template'];
287
+                $field['searchable'] = $search_default;
288
+                $field['cacheable'] = $cache_default;
289
+                $field['createdby'] = $createdby;
290
+                $field['createdon'] = $date;
291
+                $field['editedon'] = $date;
292
+                $field['isfolder'] = 0;
293
+                $field['menuindex'] = ($alias == 'index') ? 0 : 2;
294
+                $newid = $modx->db->insert($field, $tbl_site_content);
295
+                if($newid) {
296
+                    echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
297
+                } else {
298
+                    echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
299
+                    exit;
300
+                }
301
+
302
+                $is_site_start = false;
303
+                if($filename == 'index.html') {
304
+                    $is_site_start = true;
305
+                }
306
+                if($is_site_start == true && $_POST['reset'] == 'on') {
307
+                    $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'");
308
+                    $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'");
309
+                }
310
+            }
311
+        }
312
+    }
313 313
 }
314 314
 
315 315
 /**
@@ -319,27 +319,27 @@  discard block
 block discarded – undo
319 319
  * @return array
320 320
  */
321 321
 function getFiles($directory, $listing = array(), $count = 0) {
322
-	global $_lang;
323
-	global $filesfound;
324
-	$dummy = $count;
325
-	if( ! empty($directory) && $files = scandir($directory)) {
326
-		foreach($files as $file) {
327
-			if($file == '.' || $file == '..') {
328
-				continue;
329
-			} elseif($h = @opendir($directory . $file . "/")) {
330
-				closedir($h);
331
-				$count = -1;
332
-				$listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
333
-			} elseif(strpos($file, '.htm') !== false) {
334
-				$listing[$dummy] = $file;
335
-				$dummy = $dummy + 1;
336
-				$filesfound++;
337
-			}
338
-		}
339
-	} else {
340
-		echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
341
-	}
342
-	return ($listing);
322
+    global $_lang;
323
+    global $filesfound;
324
+    $dummy = $count;
325
+    if( ! empty($directory) && $files = scandir($directory)) {
326
+        foreach($files as $file) {
327
+            if($file == '.' || $file == '..') {
328
+                continue;
329
+            } elseif($h = @opendir($directory . $file . "/")) {
330
+                closedir($h);
331
+                $count = -1;
332
+                $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
333
+            } elseif(strpos($file, '.htm') !== false) {
334
+                $listing[$dummy] = $file;
335
+                $dummy = $dummy + 1;
336
+                $filesfound++;
337
+            }
338
+        }
339
+    } else {
340
+        echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
341
+    }
342
+    return ($listing);
343 343
 }
344 344
 
345 345
 /**
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
  * @return bool|string
348 348
  */
349 349
 function getFileContent($filepath) {
350
-	global $_lang;
351
-	// get the file
352
-	if(!$buffer = file_get_contents($filepath)) {
353
-		echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
354
-	} else {
355
-		return $buffer;
356
-	}
350
+    global $_lang;
351
+    // get the file
352
+    if(!$buffer = file_get_contents($filepath)) {
353
+        echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
354
+    } else {
355
+        return $buffer;
356
+    }
357 357
 }
358 358
 
359 359
 /**
@@ -361,20 +361,20 @@  discard block
 block discarded – undo
361 361
  * @return array
362 362
  */
363 363
 function pop_index($array) {
364
-	$new_array = array();
365
-	foreach($array as $k => $v) {
366
-		if($v !== 'index.html' && $v !== 'index.htm') {
367
-			$new_array[$k] = $v;
368
-		} else {
369
-			array_unshift($new_array, $v);
370
-		}
371
-	}
372
-	foreach($array as $k => $v) {
373
-		if(is_array($v)) {
374
-			$new_array[$k] = $v;
375
-		}
376
-	}
377
-	return $new_array;
364
+    $new_array = array();
365
+    foreach($array as $k => $v) {
366
+        if($v !== 'index.html' && $v !== 'index.htm') {
367
+            $new_array[$k] = $v;
368
+        } else {
369
+            array_unshift($new_array, $v);
370
+        }
371
+    }
372
+    foreach($array as $k => $v) {
373
+        if(is_array($v)) {
374
+            $new_array[$k] = $v;
375
+        }
376
+    }
377
+    return $new_array;
378 378
 }
379 379
 
380 380
 /**
@@ -384,108 +384,108 @@  discard block
 block discarded – undo
384 384
  * @return array
385 385
  */
386 386
 function treatContent($src, $filename, $alias) {
387
-	$modx = evolutionCMS();
388
-
389
-	$src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
390
-
391
-	if(preg_match("@<title>(.*)</title>@i", $src, $matches)) {
392
-		$pagetitle = ($matches[1] !== '') ? $matches[1] : $filename;
393
-		$pagetitle = str_replace('[*pagetitle*]', '', $pagetitle);
394
-	} else {
395
-		$pagetitle = $alias;
396
-	}
397
-	if(!$pagetitle) {
398
-		$pagetitle = $alias;
399
-	}
400
-
401
-	if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
402
-		$description = ($matches[1] !== '') ? $matches[1] : $filename;
403
-		$description = str_replace('[*description*]', '', $description);
404
-	} else {
405
-		$description = '';
406
-	}
407
-
408
-	if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
409
-		$content = $matches[1];
410
-	} else {
411
-		$content = $src;
412
-		$s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
413
-		$r = '$1' . $modx->config['modx_charset'] . '$2';
414
-		$content = preg_replace($s, $r, $content);
415
-		$content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
416
-	}
417
-	$content = str_replace('[*content*]', '[ *content* ]', $content);
418
-	$content = trim($content);
419
-	$pagetitle = $modx->db->escape($pagetitle);
420
-	return array(
421
-		$pagetitle,
422
-		$content,
423
-		$description
424
-	);
387
+    $modx = evolutionCMS();
388
+
389
+    $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
390
+
391
+    if(preg_match("@<title>(.*)</title>@i", $src, $matches)) {
392
+        $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename;
393
+        $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle);
394
+    } else {
395
+        $pagetitle = $alias;
396
+    }
397
+    if(!$pagetitle) {
398
+        $pagetitle = $alias;
399
+    }
400
+
401
+    if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
402
+        $description = ($matches[1] !== '') ? $matches[1] : $filename;
403
+        $description = str_replace('[*description*]', '', $description);
404
+    } else {
405
+        $description = '';
406
+    }
407
+
408
+    if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
409
+        $content = $matches[1];
410
+    } else {
411
+        $content = $src;
412
+        $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
413
+        $r = '$1' . $modx->config['modx_charset'] . '$2';
414
+        $content = preg_replace($s, $r, $content);
415
+        $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
416
+    }
417
+    $content = str_replace('[*content*]', '[ *content* ]', $content);
418
+    $content = trim($content);
419
+    $pagetitle = $modx->db->escape($pagetitle);
420
+    return array(
421
+        $pagetitle,
422
+        $content,
423
+        $description
424
+    );
425 425
 }
426 426
 
427 427
 /**
428 428
  * @return void
429 429
  */
430 430
 function convertLink() {
431
-	$modx = evolutionCMS();
432
-	$tbl_site_content = $modx->getFullTableName('site_content');
431
+    $modx = evolutionCMS();
432
+    $tbl_site_content = $modx->getFullTableName('site_content');
433 433
 
434
-	$rs = $modx->db->select('id,content', $tbl_site_content);
435
-	$p = array();
434
+    $rs = $modx->db->select('id,content', $tbl_site_content);
435
+    $p = array();
436 436
     $target = array();
437
-	$dir = '';
438
-	while($row = $modx->db->getRow($rs)) {
439
-		$id = $row['id'];
440
-		$array = explode('<a href=', $row['content']);
441
-		$c = 0;
442
-		foreach($array as $v) {
443
-			if($v[0] === '"') {
444
-				$v = substr($v, 1);
445
-				list($href, $v) = explode('"', $v, 2);
446
-				$_ = $href;
447
-				if(strpos($_, $modx->config['site_url']) !== false) {
448
-					$_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
449
-				}
450
-				if($_[0] === '/') {
451
-					$_ = substr($_, 1);
452
-				}
453
-				$_ = str_replace('/index.html', '.html', $_);
454
-				$level = substr_count($_, '../');
455
-				if(1 < $level) {
456
-					if(!isset($p[$id])) {
457
-						$p[$id] = $modx->getParentIds($id);
458
-					}
459
-					$k = array_keys($p[$id]);
460
-					while(0 < $level) {
461
-						$dir = array_shift($k);
462
-						$level--;
463
-					}
464
-					if($dir != '') {
465
-						$dir .= '/';
466
-					}
467
-				} else {
468
-					$dir = '';
469
-				}
470
-
471
-				$_ = trim($_, './');
472
-				if(strpos($_, '/') !== false) {
473
-					$_ = substr($_, strrpos($_, '/'));
474
-				}
475
-				$_ = $dir . str_replace('.html', '', $_);
476
-				if(!isset($target[$_])) {
477
-					$target[$_] = $modx->getIdFromAlias($_);
478
-				}
479
-				$target[$_] = trim($target[$_]);
480
-				if(!empty($target[$_])) {
481
-					$href = '[~' . $target[$_] . '~]';
482
-				}
483
-				$array[$c] = '<a href="' . $href . '"' . $v;
484
-			}
485
-			$c++;
486
-		}
487
-		$content = implode('', $array);
488
-		$f['content'] = $modx->db->escape($content);
489
-		$modx->db->update($f, $tbl_site_content, "id='{$id}'");
490
-	}
437
+    $dir = '';
438
+    while($row = $modx->db->getRow($rs)) {
439
+        $id = $row['id'];
440
+        $array = explode('<a href=', $row['content']);
441
+        $c = 0;
442
+        foreach($array as $v) {
443
+            if($v[0] === '"') {
444
+                $v = substr($v, 1);
445
+                list($href, $v) = explode('"', $v, 2);
446
+                $_ = $href;
447
+                if(strpos($_, $modx->config['site_url']) !== false) {
448
+                    $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
449
+                }
450
+                if($_[0] === '/') {
451
+                    $_ = substr($_, 1);
452
+                }
453
+                $_ = str_replace('/index.html', '.html', $_);
454
+                $level = substr_count($_, '../');
455
+                if(1 < $level) {
456
+                    if(!isset($p[$id])) {
457
+                        $p[$id] = $modx->getParentIds($id);
458
+                    }
459
+                    $k = array_keys($p[$id]);
460
+                    while(0 < $level) {
461
+                        $dir = array_shift($k);
462
+                        $level--;
463
+                    }
464
+                    if($dir != '') {
465
+                        $dir .= '/';
466
+                    }
467
+                } else {
468
+                    $dir = '';
469
+                }
470
+
471
+                $_ = trim($_, './');
472
+                if(strpos($_, '/') !== false) {
473
+                    $_ = substr($_, strrpos($_, '/'));
474
+                }
475
+                $_ = $dir . str_replace('.html', '', $_);
476
+                if(!isset($target[$_])) {
477
+                    $target[$_] = $modx->getIdFromAlias($_);
478
+                }
479
+                $target[$_] = trim($target[$_]);
480
+                if(!empty($target[$_])) {
481
+                    $href = '[~' . $target[$_] . '~]';
482
+                }
483
+                $array[$c] = '<a href="' . $href . '"' . $v;
484
+            }
485
+            $c++;
486
+        }
487
+        $content = implode('', $array);
488
+        $f['content'] = $modx->db->escape($content);
489
+        $modx->db->update($f, $tbl_site_content, "id='{$id}'");
490
+    }
491 491
 }
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 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('import_static')) {
5
+if (!$modx->hasPermission('import_static')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	<div class="tab-page">
44 44
 		<div class="container container-body">
45 45
 			<?php
46
-			if(!isset($_POST['import'])) {
47
-				echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>";
46
+			if (!isset($_POST['import'])) {
47
+				echo "<div class=\"element-edit-message\">".$_lang['import_site_message']."</div>";
48 48
 				?>
49 49
 				<form action="index.php" method="post" name="importFrm">
50 50
 					<input type="hidden" name="import" value="import" />
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 /**
105 105
  * @return string
106 106
  */
107
-function run() {
107
+function run(){
108 108
 	$modx = evolutionCMS(); global $_lang;
109 109
 
110 110
 	$tbl_site_content = $modx->getFullTableName('site_content');
111 111
 	$output = '';
112 112
 	$maxtime = $_POST['maxtime'];
113 113
 
114
-	if(!is_numeric($maxtime)) {
114
+	if (!is_numeric($maxtime)) {
115 115
 		$maxtime = 30;
116 116
 	}
117 117
 
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
 	$mtime = $mtime[1] + $mtime[0];
123 123
 	$importstart = $mtime;
124 124
 
125
-	if($_POST['reset'] == 'on') {
125
+	if ($_POST['reset'] == 'on') {
126 126
 		$modx->db->truncate($tbl_site_content);
127 127
 		$modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
128 128
 	}
129 129
 
130
-	$parent = (int)$_POST['parent'];
130
+	$parent = (int) $_POST['parent'];
131 131
 
132
-	if(is_dir(MODX_BASE_PATH . 'temp/import')) {
133
-		$filedir = MODX_BASE_PATH . 'temp/import/';
134
-	} elseif(is_dir(MODX_BASE_PATH . 'assets/import')) {
135
-		$filedir = MODX_BASE_PATH . 'assets/import/';
132
+	if (is_dir(MODX_BASE_PATH.'temp/import')) {
133
+		$filedir = MODX_BASE_PATH.'temp/import/';
134
+	} elseif (is_dir(MODX_BASE_PATH.'assets/import')) {
135
+		$filedir = MODX_BASE_PATH.'assets/import/';
136 136
 	} else {
137 137
         $filedir = '';
138 138
     }
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 	$files = pop_index($files);
144 144
 
145 145
 	// no. of files to import
146
-	$output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
146
+	$output .= sprintf('<p>'.$_lang['import_files_found'].'</p>', $filesfound);
147 147
 
148 148
 	// import files
149
-	if(0 < count($files)) {
149
+	if (0 < count($files)) {
150 150
 		$modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'");
151 151
 		importFiles($parent, $filedir, $files, 'root');
152 152
 	}
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 	$mtime = $mtime[1] + $mtime[0];
157 157
 	$importend = $mtime;
158 158
 	$totaltime = ($importend - $importstart);
159
-	$output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
159
+	$output .= sprintf('<p>'.$_lang['import_site_time'].'</p>', round($totaltime, 3));
160 160
 
161
-	if($_POST['convert_link'] == 'on') {
161
+	if ($_POST['convert_link'] == 'on') {
162 162
 		convertLink();
163 163
 	}
164 164
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  * @param array $files
172 172
  * @param string $mode
173 173
  */
174
-function importFiles($parent, $filedir, $files, $mode) {
174
+function importFiles($parent, $filedir, $files, $mode){
175 175
 	$modx = evolutionCMS();
176 176
 	global $_lang, $allowedfiles;
177 177
 	global $search_default, $cache_default, $publish_default;
@@ -180,21 +180,21 @@  discard block
 block discarded – undo
180 180
 	$tbl_system_settings = $modx->getFullTableName('system_settings');
181 181
 
182 182
 	$createdby = $modx->getLoginUserID();
183
-	if(!is_array($files)) {
183
+	if (!is_array($files)) {
184 184
 		return;
185 185
 	}
186
-	if($_POST['object'] === 'all') {
186
+	if ($_POST['object'] === 'all') {
187 187
 		$modx->config['default_template'] = '0';
188 188
 		$richtext = '0';
189 189
 	} else {
190 190
 		$richtext = '1';
191 191
 	}
192 192
 
193
-	foreach($files as $id => $value) {
194
-		if(is_array($value)) {
193
+	foreach ($files as $id => $value) {
194
+		if (is_array($value)) {
195 195
 			// create folder
196 196
 			$alias = $id;
197
-			printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
197
+			printf('<span>'.$_lang['import_site_importing_document'].'</span>', $alias);
198 198
 			$field = array();
199 199
 			$field['type'] = 'document';
200 200
 			$field['contentType'] = 'text/html';
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 			$field['isfolder'] = 1;
210 210
 			$field['menuindex'] = 1;
211 211
 			$find = false;
212
-			foreach(array(
212
+			foreach (array(
213 213
 						'index.html',
214 214
 						'index.htm'
215 215
 					) as $filename) {
216
-				$filepath = $filedir . $alias . '/' . $filename;
217
-				if($find === false && file_exists($filepath)) {
216
+				$filepath = $filedir.$alias.'/'.$filename;
217
+				if ($find === false && file_exists($filepath)) {
218 218
 					$file = getFileContent($filepath);
219 219
 					list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
220 220
 
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 					$field['createdon'] = $date;
227 227
 					$field['editedon'] = $date;
228 228
 					$newid = $modx->db->insert($field, $tbl_site_content);
229
-					if($newid) {
229
+					if ($newid) {
230 230
 						$find = true;
231
-						echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
232
-						importFiles($newid, $filedir . $alias . '/', $value, 'sub');
231
+						echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
232
+						importFiles($newid, $filedir.$alias.'/', $value, 'sub');
233 233
 					} else {
234
-						echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
234
+						echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
235 235
 						exit;
236 236
 					}
237 237
 				}
238 238
 			}
239
-			if($find === false) {
239
+			if ($find === false) {
240 240
 				$date = time();
241 241
 				$field['pagetitle'] = '---';
242 242
 				$field['content'] = '';
@@ -244,30 +244,30 @@  discard block
 block discarded – undo
244 244
 				$field['editedon'] = $date;
245 245
 				$field['hidemenu'] = '1';
246 246
 				$newid = $modx->db->insert($field, $tbl_site_content);
247
-				if($newid) {
247
+				if ($newid) {
248 248
 					$find = true;
249
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
250
-					importFiles($newid, $filedir . $alias . '/', $value, 'sub');
249
+					echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
250
+					importFiles($newid, $filedir.$alias.'/', $value, 'sub');
251 251
 				} else {
252
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
252
+					echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
253 253
 					exit;
254 254
 				}
255 255
 			}
256 256
 		} else {
257 257
 			// create document
258
-			if($mode == 'sub' && $value == 'index.html') {
258
+			if ($mode == 'sub' && $value == 'index.html') {
259 259
 				continue;
260 260
 			}
261 261
 			$filename = $value;
262 262
 			$fparts = explode('.', $value);
263 263
 			$alias = $fparts[0];
264 264
 			$ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
265
-			printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
265
+			printf("<span>".$_lang['import_site_importing_document']."</span>", $filename);
266 266
 
267
-			if(!in_array($ext, $allowedfiles)) {
268
-				echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
267
+			if (!in_array($ext, $allowedfiles)) {
268
+				echo ' - <span class="fail">'.$_lang["import_site_skip"].'</span><br />'."\n";
269 269
 			} else {
270
-				$filepath = $filedir . $filename;
270
+				$filepath = $filedir.$filename;
271 271
 				$file = getFileContent($filepath);
272 272
 				list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
273 273
 
@@ -292,18 +292,18 @@  discard block
 block discarded – undo
292 292
 				$field['isfolder'] = 0;
293 293
 				$field['menuindex'] = ($alias == 'index') ? 0 : 2;
294 294
 				$newid = $modx->db->insert($field, $tbl_site_content);
295
-				if($newid) {
296
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
295
+				if ($newid) {
296
+					echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
297 297
 				} else {
298
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
298
+					echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
299 299
 					exit;
300 300
 				}
301 301
 
302 302
 				$is_site_start = false;
303
-				if($filename == 'index.html') {
303
+				if ($filename == 'index.html') {
304 304
 					$is_site_start = true;
305 305
 				}
306
-				if($is_site_start == true && $_POST['reset'] == 'on') {
306
+				if ($is_site_start == true && $_POST['reset'] == 'on') {
307 307
 					$modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'");
308 308
 					$modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'");
309 309
 				}
@@ -318,26 +318,26 @@  discard block
 block discarded – undo
318 318
  * @param int $count
319 319
  * @return array
320 320
  */
321
-function getFiles($directory, $listing = array(), $count = 0) {
321
+function getFiles($directory, $listing = array(), $count = 0){
322 322
 	global $_lang;
323 323
 	global $filesfound;
324 324
 	$dummy = $count;
325
-	if( ! empty($directory) && $files = scandir($directory)) {
326
-		foreach($files as $file) {
327
-			if($file == '.' || $file == '..') {
325
+	if (!empty($directory) && $files = scandir($directory)) {
326
+		foreach ($files as $file) {
327
+			if ($file == '.' || $file == '..') {
328 328
 				continue;
329
-			} elseif($h = @opendir($directory . $file . "/")) {
329
+			} elseif ($h = @opendir($directory.$file."/")) {
330 330
 				closedir($h);
331 331
 				$count = -1;
332
-				$listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
333
-			} elseif(strpos($file, '.htm') !== false) {
332
+				$listing[$file] = getFiles($directory.$file."/", array(), $count + 1);
333
+			} elseif (strpos($file, '.htm') !== false) {
334 334
 				$listing[$dummy] = $file;
335 335
 				$dummy = $dummy + 1;
336 336
 				$filesfound++;
337 337
 			}
338 338
 		}
339 339
 	} else {
340
-		echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
340
+		echo '<p><span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_no_open_dir"].$directory.".</p>";
341 341
 	}
342 342
 	return ($listing);
343 343
 }
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
  * @param string $filepath
347 347
  * @return bool|string
348 348
  */
349
-function getFileContent($filepath) {
349
+function getFileContent($filepath){
350 350
 	global $_lang;
351 351
 	// get the file
352
-	if(!$buffer = file_get_contents($filepath)) {
353
-		echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
352
+	if (!$buffer = file_get_contents($filepath)) {
353
+		echo '<p><span class="fail">'.$_lang['import_site_failed']."</span> ".$_lang["import_site_failed_no_retrieve_file"].$filepath.".</p>";
354 354
 	} else {
355 355
 		return $buffer;
356 356
 	}
@@ -360,17 +360,17 @@  discard block
 block discarded – undo
360 360
  * @param array $array
361 361
  * @return array
362 362
  */
363
-function pop_index($array) {
363
+function pop_index($array){
364 364
 	$new_array = array();
365
-	foreach($array as $k => $v) {
366
-		if($v !== 'index.html' && $v !== 'index.htm') {
365
+	foreach ($array as $k => $v) {
366
+		if ($v !== 'index.html' && $v !== 'index.htm') {
367 367
 			$new_array[$k] = $v;
368 368
 		} else {
369 369
 			array_unshift($new_array, $v);
370 370
 		}
371 371
 	}
372
-	foreach($array as $k => $v) {
373
-		if(is_array($v)) {
372
+	foreach ($array as $k => $v) {
373
+		if (is_array($v)) {
374 374
 			$new_array[$k] = $v;
375 375
 		}
376 376
 	}
@@ -383,34 +383,34 @@  discard block
 block discarded – undo
383 383
  * @param string $alias
384 384
  * @return array
385 385
  */
386
-function treatContent($src, $filename, $alias) {
386
+function treatContent($src, $filename, $alias){
387 387
 	$modx = evolutionCMS();
388 388
 
389 389
 	$src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
390 390
 
391
-	if(preg_match("@<title>(.*)</title>@i", $src, $matches)) {
391
+	if (preg_match("@<title>(.*)</title>@i", $src, $matches)) {
392 392
 		$pagetitle = ($matches[1] !== '') ? $matches[1] : $filename;
393 393
 		$pagetitle = str_replace('[*pagetitle*]', '', $pagetitle);
394 394
 	} else {
395 395
 		$pagetitle = $alias;
396 396
 	}
397
-	if(!$pagetitle) {
397
+	if (!$pagetitle) {
398 398
 		$pagetitle = $alias;
399 399
 	}
400 400
 
401
-	if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
401
+	if (preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
402 402
 		$description = ($matches[1] !== '') ? $matches[1] : $filename;
403 403
 		$description = str_replace('[*description*]', '', $description);
404 404
 	} else {
405 405
 		$description = '';
406 406
 	}
407 407
 
408
-	if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
408
+	if ((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
409 409
 		$content = $matches[1];
410 410
 	} else {
411 411
 		$content = $src;
412 412
 		$s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
413
-		$r = '$1' . $modx->config['modx_charset'] . '$2';
413
+		$r = '$1'.$modx->config['modx_charset'].'$2';
414 414
 		$content = preg_replace($s, $r, $content);
415 415
 		$content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
416 416
 	}
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 /**
428 428
  * @return void
429 429
  */
430
-function convertLink() {
430
+function convertLink(){
431 431
 	$modx = evolutionCMS();
432 432
 	$tbl_site_content = $modx->getFullTableName('site_content');
433 433
 
@@ -435,33 +435,33 @@  discard block
 block discarded – undo
435 435
 	$p = array();
436 436
     $target = array();
437 437
 	$dir = '';
438
-	while($row = $modx->db->getRow($rs)) {
438
+	while ($row = $modx->db->getRow($rs)) {
439 439
 		$id = $row['id'];
440 440
 		$array = explode('<a href=', $row['content']);
441 441
 		$c = 0;
442
-		foreach($array as $v) {
443
-			if($v[0] === '"') {
442
+		foreach ($array as $v) {
443
+			if ($v[0] === '"') {
444 444
 				$v = substr($v, 1);
445 445
 				list($href, $v) = explode('"', $v, 2);
446 446
 				$_ = $href;
447
-				if(strpos($_, $modx->config['site_url']) !== false) {
448
-					$_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
447
+				if (strpos($_, $modx->config['site_url']) !== false) {
448
+					$_ = $modx->config['base_url'].str_replace($modx->config['site_url'], '', $_);
449 449
 				}
450
-				if($_[0] === '/') {
450
+				if ($_[0] === '/') {
451 451
 					$_ = substr($_, 1);
452 452
 				}
453 453
 				$_ = str_replace('/index.html', '.html', $_);
454 454
 				$level = substr_count($_, '../');
455
-				if(1 < $level) {
456
-					if(!isset($p[$id])) {
455
+				if (1 < $level) {
456
+					if (!isset($p[$id])) {
457 457
 						$p[$id] = $modx->getParentIds($id);
458 458
 					}
459 459
 					$k = array_keys($p[$id]);
460
-					while(0 < $level) {
460
+					while (0 < $level) {
461 461
 						$dir = array_shift($k);
462 462
 						$level--;
463 463
 					}
464
-					if($dir != '') {
464
+					if ($dir != '') {
465 465
 						$dir .= '/';
466 466
 					}
467 467
 				} else {
@@ -469,18 +469,18 @@  discard block
 block discarded – undo
469 469
 				}
470 470
 
471 471
 				$_ = trim($_, './');
472
-				if(strpos($_, '/') !== false) {
472
+				if (strpos($_, '/') !== false) {
473 473
 					$_ = substr($_, strrpos($_, '/'));
474 474
 				}
475
-				$_ = $dir . str_replace('.html', '', $_);
476
-				if(!isset($target[$_])) {
475
+				$_ = $dir.str_replace('.html', '', $_);
476
+				if (!isset($target[$_])) {
477 477
 					$target[$_] = $modx->getIdFromAlias($_);
478 478
 				}
479 479
 				$target[$_] = trim($target[$_]);
480
-				if(!empty($target[$_])) {
481
-					$href = '[~' . $target[$_] . '~]';
480
+				if (!empty($target[$_])) {
481
+					$href = '[~'.$target[$_].'~]';
482 482
 				}
483
-				$array[$c] = '<a href="' . $href . '"' . $v;
483
+				$array[$c] = '<a href="'.$href.'"'.$v;
484 484
 			}
485 485
 			$c++;
486 486
 		}
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -104,7 +104,8 @@  discard block
 block discarded – undo
104 104
 /**
105 105
  * @return string
106 106
  */
107
-function run() {
107
+function run()
108
+{
108 109
 	$modx = evolutionCMS(); global $_lang;
109 110
 
110 111
 	$tbl_site_content = $modx->getFullTableName('site_content');
@@ -171,7 +172,8 @@  discard block
 block discarded – undo
171 172
  * @param array $files
172 173
  * @param string $mode
173 174
  */
174
-function importFiles($parent, $filedir, $files, $mode) {
175
+function importFiles($parent, $filedir, $files, $mode)
176
+{
175 177
 	$modx = evolutionCMS();
176 178
 	global $_lang, $allowedfiles;
177 179
 	global $search_default, $cache_default, $publish_default;
@@ -318,7 +320,8 @@  discard block
 block discarded – undo
318 320
  * @param int $count
319 321
  * @return array
320 322
  */
321
-function getFiles($directory, $listing = array(), $count = 0) {
323
+function getFiles($directory, $listing = array(), $count = 0)
324
+{
322 325
 	global $_lang;
323 326
 	global $filesfound;
324 327
 	$dummy = $count;
@@ -346,7 +349,8 @@  discard block
 block discarded – undo
346 349
  * @param string $filepath
347 350
  * @return bool|string
348 351
  */
349
-function getFileContent($filepath) {
352
+function getFileContent($filepath)
353
+{
350 354
 	global $_lang;
351 355
 	// get the file
352 356
 	if(!$buffer = file_get_contents($filepath)) {
@@ -360,7 +364,8 @@  discard block
 block discarded – undo
360 364
  * @param array $array
361 365
  * @return array
362 366
  */
363
-function pop_index($array) {
367
+function pop_index($array)
368
+{
364 369
 	$new_array = array();
365 370
 	foreach($array as $k => $v) {
366 371
 		if($v !== 'index.html' && $v !== 'index.htm') {
@@ -383,7 +388,8 @@  discard block
 block discarded – undo
383 388
  * @param string $alias
384 389
  * @return array
385 390
  */
386
-function treatContent($src, $filename, $alias) {
391
+function treatContent($src, $filename, $alias)
392
+{
387 393
 	$modx = evolutionCMS();
388 394
 
389 395
 	$src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
@@ -427,7 +433,8 @@  discard block
 block discarded – undo
427 433
 /**
428 434
  * @return void
429 435
  */
430
-function convertLink() {
436
+function convertLink()
437
+{
431 438
 	$modx = evolutionCMS();
432 439
 	$tbl_site_content = $modx->getFullTableName('site_content');
433 440
 
Please login to merge, or discard this patch.
manager/actions/mutate_content.dynamic.php 3 patches
Indentation   +411 added lines, -411 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  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
 
6 6
 /********************/
@@ -12,30 +12,30 @@  discard block
 block discarded – undo
12 12
 
13 13
 // check permissions
14 14
 switch($modx->manager->action) {
15
-	case 27:
16
-		if(!$modx->hasPermission('edit_document')) {
17
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
18
-		}
19
-		break;
20
-	case 85:
21
-	case 72:
22
-	case 4:
23
-		if(!$modx->hasPermission('new_document')) {
24
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
25
-		} elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') {
26
-			// check user has permissions for parent
27
-			include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
28
-			$udperms = new udperms();
29
-			$udperms->user = $modx->getLoginUserID();
30
-			$udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid'];
31
-			$udperms->role = $_SESSION['mgrRole'];
32
-			if(!$udperms->checkPermissions()) {
33
-				$modx->webAlertAndQuit($_lang["access_permission_denied"]);
34
-			}
35
-		}
36
-		break;
37
-	default:
38
-		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
+    case 27:
16
+        if(!$modx->hasPermission('edit_document')) {
17
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
18
+        }
19
+        break;
20
+    case 85:
21
+    case 72:
22
+    case 4:
23
+        if(!$modx->hasPermission('new_document')) {
24
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
25
+        } elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') {
26
+            // check user has permissions for parent
27
+            include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
28
+            $udperms = new udperms();
29
+            $udperms->user = $modx->getLoginUserID();
30
+            $udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid'];
31
+            $udperms->role = $_SESSION['mgrRole'];
32
+            if(!$udperms->checkPermissions()) {
33
+                $modx->webAlertAndQuit($_lang["access_permission_denied"]);
34
+            }
35
+        }
36
+        break;
37
+    default:
38
+        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
39 39
 }
40 40
 
41 41
 $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
 $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars');
55 55
 
56 56
 if($modx->manager->action == 27) {
57
-	//editing an existing document
58
-	// check permissions on the document
59
-	include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
60
-	$udperms = new udperms();
61
-	$udperms->user = $modx->getLoginUserID();
62
-	$udperms->document = $id;
63
-	$udperms->role = $_SESSION['mgrRole'];
64
-
65
-	if(!$udperms->checkPermissions()) {
66
-		$modx->webAlertAndQuit($_lang["access_permission_denied"]);
67
-	}
57
+    //editing an existing document
58
+    // check permissions on the document
59
+    include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
60
+    $udperms = new udperms();
61
+    $udperms->user = $modx->getLoginUserID();
62
+    $udperms->document = $id;
63
+    $udperms->role = $_SESSION['mgrRole'];
64
+
65
+    if(!$udperms->checkPermissions()) {
66
+        $modx->webAlertAndQuit($_lang["access_permission_denied"]);
67
+    }
68 68
 }
69 69
 
70 70
 // check to see if resource isn't locked
71 71
 if($lockedEl = $modx->elementIsLocked(7, $id)) {
72
-	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource']));
72
+    $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource']));
73 73
 }
74 74
 // end check for lock
75 75
 
@@ -78,74 +78,74 @@  discard block
 block discarded – undo
78 78
 
79 79
 // get document groups for current user
80 80
 if($_SESSION['mgrDocgroups']) {
81
-	$docgrp = implode(',', $_SESSION['mgrDocgroups']);
81
+    $docgrp = implode(',', $_SESSION['mgrDocgroups']);
82 82
 }
83 83
 
84 84
 if(!empty ($id)) {
85
-	$access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']);
86
-	if($docgrp) {
87
-		$access .= " OR dg.document_group IN ({$docgrp})";
88
-	}
89
-	$rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})");
90
-	$content = array();
91
-	$content = $modx->db->getRow($rs);
92
-	$modx->documentObject = &$content;
93
-	if(!$content) {
94
-		$modx->webAlertAndQuit($_lang["access_permission_denied"]);
95
-	}
96
-	$_SESSION['itemname'] = $content['pagetitle'];
85
+    $access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']);
86
+    if($docgrp) {
87
+        $access .= " OR dg.document_group IN ({$docgrp})";
88
+    }
89
+    $rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})");
90
+    $content = array();
91
+    $content = $modx->db->getRow($rs);
92
+    $modx->documentObject = &$content;
93
+    if(!$content) {
94
+        $modx->webAlertAndQuit($_lang["access_permission_denied"]);
95
+    }
96
+    $_SESSION['itemname'] = $content['pagetitle'];
97 97
 } else {
98
-	$content = array();
98
+    $content = array();
99 99
 
100
-	if(isset($_REQUEST['newtemplate'])) {
101
-		$content['template'] = $_REQUEST['newtemplate'];
102
-	} else {
103
-		$content['template'] = getDefaultTemplate();
104
-	}
100
+    if(isset($_REQUEST['newtemplate'])) {
101
+        $content['template'] = $_REQUEST['newtemplate'];
102
+    } else {
103
+        $content['template'] = getDefaultTemplate();
104
+    }
105 105
 
106
-	$_SESSION['itemname'] = $_lang["new_resource"];
106
+    $_SESSION['itemname'] = $_lang["new_resource"];
107 107
 }
108 108
 
109 109
 // restore saved form
110 110
 $formRestored = $modx->manager->loadFormValues();
111 111
 if(isset($_REQUEST['newtemplate'])) {
112
-	$formRestored = true;
112
+    $formRestored = true;
113 113
 }
114 114
 
115 115
 // retain form values if template was changed
116 116
 // edited to convert pub_date and unpub_date
117 117
 // sottwell 02-09-2006
118 118
 if($formRestored == true) {
119
-	$content = array_merge($content, $_POST);
120
-	$content['content'] = $_POST['ta'];
121
-	if(empty ($content['pub_date'])) {
122
-		unset ($content['pub_date']);
123
-	} else {
124
-		$content['pub_date'] = $modx->toTimeStamp($content['pub_date']);
125
-	}
126
-	if(empty ($content['unpub_date'])) {
127
-		unset ($content['unpub_date']);
128
-	} else {
129
-		$content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']);
130
-	}
119
+    $content = array_merge($content, $_POST);
120
+    $content['content'] = $_POST['ta'];
121
+    if(empty ($content['pub_date'])) {
122
+        unset ($content['pub_date']);
123
+    } else {
124
+        $content['pub_date'] = $modx->toTimeStamp($content['pub_date']);
125
+    }
126
+    if(empty ($content['unpub_date'])) {
127
+        unset ($content['unpub_date']);
128
+    } else {
129
+        $content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']);
130
+    }
131 131
 }
132 132
 
133 133
 // increase menu index if this is a new document
134 134
 if(!isset ($_REQUEST['id'])) {
135
-	if(!isset ($modx->config['auto_menuindex'])) {
136
-		$modx->config['auto_menuindex'] = 1;
137
-	}
138
-	if($modx->config['auto_menuindex']) {
139
-		$pid = (int)$_REQUEST['pid'];
140
-		$rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'");
141
-		$content['menuindex'] = $modx->db->getValue($rs);
142
-	} else {
143
-		$content['menuindex'] = 0;
144
-	}
135
+    if(!isset ($modx->config['auto_menuindex'])) {
136
+        $modx->config['auto_menuindex'] = 1;
137
+    }
138
+    if($modx->config['auto_menuindex']) {
139
+        $pid = (int)$_REQUEST['pid'];
140
+        $rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'");
141
+        $content['menuindex'] = $modx->db->getValue($rs);
142
+    } else {
143
+        $content['menuindex'] = 0;
144
+    }
145 145
 }
146 146
 
147 147
 if(isset ($_POST['which_editor'])) {
148
-	$modx->config['which_editor'] = $_POST['which_editor'];
148
+    $modx->config['which_editor'] = $_POST['which_editor'];
149 149
 }
150 150
 
151 151
 // Add lock-element JS-Script
@@ -545,23 +545,23 @@  discard block
 block discarded – undo
545 545
 
546 546
 	<form name="mutate" id="mutate" class="content" method="post" enctype="multipart/form-data" action="index.php" onsubmit="documentDirty=false;">
547 547
 		<?php
548
-		// invoke OnDocFormPrerender event
549
-		$evtOut = $modx->invokeEvent('OnDocFormPrerender', array(
550
-			'id' => $id,
551
-			'template' => $content['template']
552
-		));
553
-
554
-		if(is_array($evtOut)) {
555
-			echo implode('', $evtOut);
556
-		}
557
-
558
-		/*************************/
559
-		$dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : '';
560
-		$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon';
561
-		$page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : '';
562
-		/*************************/
563
-
564
-		?>
548
+        // invoke OnDocFormPrerender event
549
+        $evtOut = $modx->invokeEvent('OnDocFormPrerender', array(
550
+            'id' => $id,
551
+            'template' => $content['template']
552
+        ));
553
+
554
+        if(is_array($evtOut)) {
555
+            echo implode('', $evtOut);
556
+        }
557
+
558
+        /*************************/
559
+        $dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : '';
560
+        $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon';
561
+        $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : '';
562
+        /*************************/
563
+
564
+        ?>
565 565
 		<input type="hidden" name="a" value="5" />
566 566
 		<input type="hidden" name="id" value="<?= $content['id'] ?>" />
567 567
 		<input type="hidden" name="mode" value="<?= $modx->manager->action ?>" />
@@ -576,54 +576,54 @@  discard block
 block discarded – undo
576 576
 
577 577
 			<h1>
578 578
 				<i class="fa fa-pencil-square-o"></i><?php if(isset($_REQUEST['id'])) {
579
-					echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>';
580
-				} else {
581
-				    if ($modx->manager->action == '4') {
579
+                    echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>';
580
+                } else {
581
+                    if ($modx->manager->action == '4') {
582 582
                         echo $_lang['add_resource'];
583 583
                     } else if ($modx->manager->action == '72') {
584 584
                         echo $_lang['add_weblink'];
585 585
                     } else {
586 586
                         echo $_lang['create_resource_title'];
587 587
                     }
588
-				} ?>
588
+                } ?>
589 589
 			</h1>
590 590
 
591 591
 			<?= $_style['actionbuttons']['dynamic']['document'] ?>
592 592
 
593 593
 			<?php
594
-			// breadcrumbs
595
-			if($modx->config['use_breadcrumbs']) {
596
-				$temp = array();
597
-				$title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title'];
598
-
599
-				if(isset($_REQUEST['id']) && $content['parent'] != 0) {
600
-					$bID = (int) $_REQUEST['id'];
601
-					$temp = $modx->getParentIds($bID);
602
-				} else if(isset($_REQUEST['pid'])) {
603
-					$bID = (int) $_REQUEST['pid'];
604
-					$temp = $modx->getParentIds($bID);
605
-					array_unshift($temp, $bID);
606
-				}
607
-
608
-				if($temp) {
609
-					$parents = implode(',', $temp);
610
-
611
-					if(!empty($parents)) {
612
-						$where = "FIND_IN_SET(id,'{$parents}') DESC";
613
-						$rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where);
614
-						while($row = $modx->db->getRow($rs)) {
615
-							$out .= '<li class="breadcrumbs__li">
594
+            // breadcrumbs
595
+            if($modx->config['use_breadcrumbs']) {
596
+                $temp = array();
597
+                $title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title'];
598
+
599
+                if(isset($_REQUEST['id']) && $content['parent'] != 0) {
600
+                    $bID = (int) $_REQUEST['id'];
601
+                    $temp = $modx->getParentIds($bID);
602
+                } else if(isset($_REQUEST['pid'])) {
603
+                    $bID = (int) $_REQUEST['pid'];
604
+                    $temp = $modx->getParentIds($bID);
605
+                    array_unshift($temp, $bID);
606
+                }
607
+
608
+                if($temp) {
609
+                    $parents = implode(',', $temp);
610
+
611
+                    if(!empty($parents)) {
612
+                        $where = "FIND_IN_SET(id,'{$parents}') DESC";
613
+                        $rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where);
614
+                        while($row = $modx->db->getRow($rs)) {
615
+                            $out .= '<li class="breadcrumbs__li">
616 616
                                 <a href="index.php?a=27&id=' . $row['id'] . '" class="breadcrumbs__a">' . htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']) . '</a>
617 617
                                 <span class="breadcrumbs__sep">&gt;</span>
618 618
                             </li>';
619
-						}
620
-					}
621
-				}
619
+                        }
620
+                    }
621
+                }
622 622
 
623
-				$out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>';
624
-				echo '<ul class="breadcrumbs">' . $out . '</ul>';
625
-			}
626
-			?>
623
+                $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>';
624
+                echo '<ul class="breadcrumbs">' . $out . '</ul>';
625
+            }
626
+            ?>
627 627
 
628 628
 			<!-- start main wrapper -->
629 629
 			<div class="sectionBody">
@@ -635,13 +635,13 @@  discard block
 block discarded – undo
635 635
 
636 636
 					<!-- General -->
637 637
 					<?php
638
-					$evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array(
639
-						'id' => $id
640
-					));
641
-					if(is_array($evtOut)) {
642
-						echo implode('', $evtOut);
643
-					} else {
644
-						?>
638
+                    $evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array(
639
+                        'id' => $id
640
+                    ));
641
+                    if(is_array($evtOut)) {
642
+                        echo implode('', $evtOut);
643
+                    } else {
644
+                        ?>
645 645
 						<div class="tab-page" id="tabGeneral">
646 646
 							<h2 class="tab"><?= $_lang['settings_general'] ?></h2>
647 647
 							<script type="text/javascript">tpSettings.addTabPage(document.getElementById("tabGeneral"));</script>
@@ -726,36 +726,36 @@  discard block
 block discarded – undo
726 726
 										<select id="template" name="template" class="inputBox" onchange="templateWarning();">
727 727
 											<option value="0">(blank)</option>
728 728
 											<?php
729
-											$field = "t.templatename, t.selectable, t.id, c.category";
730
-											$from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id";
731
-											$rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC');
732
-											$currentCategory = '';
733
-											while($row = $modx->db->getRow($rs)) {
734
-												if($row['selectable'] != 1 && $row['id'] != $content['template']) {
735
-													continue;
736
-												};
737
-												// Skip if not selectable but show if selected!
738
-												$thisCategory = $row['category'];
739
-												if($thisCategory == null) {
740
-													$thisCategory = $_lang["no_category"];
741
-												}
742
-												if($thisCategory != $currentCategory) {
743
-													if($closeOptGroup) {
744
-														echo "\t\t\t\t\t</optgroup>\n";
745
-													}
746
-													echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n";
747
-													$closeOptGroup = true;
748
-												}
729
+                                            $field = "t.templatename, t.selectable, t.id, c.category";
730
+                                            $from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id";
731
+                                            $rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC');
732
+                                            $currentCategory = '';
733
+                                            while($row = $modx->db->getRow($rs)) {
734
+                                                if($row['selectable'] != 1 && $row['id'] != $content['template']) {
735
+                                                    continue;
736
+                                                };
737
+                                                // Skip if not selectable but show if selected!
738
+                                                $thisCategory = $row['category'];
739
+                                                if($thisCategory == null) {
740
+                                                    $thisCategory = $_lang["no_category"];
741
+                                                }
742
+                                                if($thisCategory != $currentCategory) {
743
+                                                    if($closeOptGroup) {
744
+                                                        echo "\t\t\t\t\t</optgroup>\n";
745
+                                                    }
746
+                                                    echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n";
747
+                                                    $closeOptGroup = true;
748
+                                                }
749 749
 
750
-												$selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : '';
750
+                                                $selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : '';
751 751
 
752
-												echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n";
753
-												$currentCategory = $thisCategory;
754
-											}
755
-											if($thisCategory != '') {
756
-												echo "\t\t\t\t\t</optgroup>\n";
757
-											}
758
-											?>
752
+                                                echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n";
753
+                                                $currentCategory = $thisCategory;
754
+                                            }
755
+                                            if($thisCategory != '') {
756
+                                                echo "\t\t\t\t\t</optgroup>\n";
757
+                                            }
758
+                                            ?>
759 759
 										</select>
760 760
 									</td>
761 761
 								</tr>
@@ -795,37 +795,37 @@  discard block
 block discarded – undo
795 795
 									</td>
796 796
 									<td valign="top">
797 797
 										<?php
798
-										$parentlookup = false;
799
-										if(isset ($_REQUEST['id'])) {
800
-											if($content['parent'] == 0) {
801
-												$parentname = $site_name;
802
-											} else {
803
-												$parentlookup = $content['parent'];
804
-											}
805
-										} elseif(isset ($_REQUEST['pid'])) {
806
-											if($_REQUEST['pid'] == 0) {
807
-												$parentname = $site_name;
808
-											} else {
809
-												$parentlookup = $_REQUEST['pid'];
810
-											}
811
-										} elseif(isset($_POST['parent'])) {
812
-											if($_POST['parent'] == 0) {
813
-												$parentname = $site_name;
814
-											} else {
815
-												$parentlookup = $_POST['parent'];
816
-											}
817
-										} else {
818
-											$parentname = $site_name;
819
-											$content['parent'] = 0;
820
-										}
821
-										if($parentlookup !== false && is_numeric($parentlookup)) {
822
-											$rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'");
823
-											$parentname = $modx->db->getValue($rs);
824
-											if(!$parentname) {
825
-												$modx->webAlertAndQuit($_lang["error_no_parent"]);
826
-											}
827
-										}
828
-										?>
798
+                                        $parentlookup = false;
799
+                                        if(isset ($_REQUEST['id'])) {
800
+                                            if($content['parent'] == 0) {
801
+                                                $parentname = $site_name;
802
+                                            } else {
803
+                                                $parentlookup = $content['parent'];
804
+                                            }
805
+                                        } elseif(isset ($_REQUEST['pid'])) {
806
+                                            if($_REQUEST['pid'] == 0) {
807
+                                                $parentname = $site_name;
808
+                                            } else {
809
+                                                $parentlookup = $_REQUEST['pid'];
810
+                                            }
811
+                                        } elseif(isset($_POST['parent'])) {
812
+                                            if($_POST['parent'] == 0) {
813
+                                                $parentname = $site_name;
814
+                                            } else {
815
+                                                $parentlookup = $_POST['parent'];
816
+                                            }
817
+                                        } else {
818
+                                            $parentname = $site_name;
819
+                                            $content['parent'] = 0;
820
+                                        }
821
+                                        if($parentlookup !== false && is_numeric($parentlookup)) {
822
+                                            $rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'");
823
+                                            $parentname = $modx->db->getValue($rs);
824
+                                            if(!$parentname) {
825
+                                                $modx->webAlertAndQuit($_lang["error_no_parent"]);
826
+                                            }
827
+                                        }
828
+                                        ?>
829 829
 										<i id="plock" class="<?= $_style["actions_folder"] ?>" onclick="enableParentSelection(!allowParentSelection);"></i>
830 830
 										<b><span id="parentName"><?= (isset($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']) ?> (<?= $parentname ?>)</span></b>
831 831
 										<input type="hidden" name="parent" value="<?= (isset($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']) ?>" onchange="documentDirty=true;" />
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 								</tr>
834 834
 								<tr></tr>
835 835
 								<?php
836
-								/*
836
+                                /*
837 837
 								if($content['type'] == 'reference' || $modx->manager->action == '72') {
838 838
 									?>
839 839
 									<tr>
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 									</tr>
862 862
 									<?php
863 863
 								}*/
864
-								?>
864
+                                ?>
865 865
 
866 866
 								<?php if($content['type'] == 'document' || $modx->manager->action == '4') { ?>
867 867
 									<tr>
@@ -874,36 +874,36 @@  discard block
 block discarded – undo
874 874
 													<select id="which_editor" class="form-control form-control-sm" size="1" name="which_editor" onchange="changeRTE();">
875 875
 													<option value="none"><?= $_lang['none'] ?></option>
876 876
 														<?php
877
-														// invoke OnRichTextEditorRegister event
878
-														$evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
879
-														if(is_array($evtOut)) {
880
-															for($i = 0; $i < count($evtOut); $i++) {
881
-																$editor = $evtOut[$i];
882
-																echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n";
883
-															}
884
-														}
885
-														?>
877
+                                                        // invoke OnRichTextEditorRegister event
878
+                                                        $evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
879
+                                                        if(is_array($evtOut)) {
880
+                                                            for($i = 0; $i < count($evtOut); $i++) {
881
+                                                                $editor = $evtOut[$i];
882
+                                                                echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n";
883
+                                                            }
884
+                                                        }
885
+                                                        ?>
886 886
 													</select>
887 887
 												</label>
888 888
 											</div>
889 889
 											<div id="content_body">
890 890
 												<?php
891
-												if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) {
892
-													$htmlContent = $content['content'];
893
-													?>
891
+                                                if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) {
892
+                                                    $htmlContent = $content['content'];
893
+                                                    ?>
894 894
 													<div class="section-editor clearfix">
895 895
 														<textarea id="ta" name="ta" onchange="documentDirty=true;"><?= $modx->htmlspecialchars($htmlContent) ?></textarea>
896 896
 													</div>
897 897
 													<?php
898
-													// Richtext-[*content*]
899
-													$richtexteditorIds = array();
900
-													$richtexteditorOptions = array();
901
-													$richtexteditorIds[$modx->config['which_editor']][] = 'ta';
902
-													$richtexteditorOptions[$modx->config['which_editor']]['ta'] = '';
903
-												} else {
904
-													echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n";
905
-												}
906
-												?>
898
+                                                    // Richtext-[*content*]
899
+                                                    $richtexteditorIds = array();
900
+                                                    $richtexteditorOptions = array();
901
+                                                    $richtexteditorIds[$modx->config['which_editor']][] = 'ta';
902
+                                                    $richtexteditorOptions[$modx->config['which_editor']]['ta'] = '';
903
+                                                } else {
904
+                                                    echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n";
905
+                                                }
906
+                                                ?>
907 907
 											</div>
908 908
 										</td>
909 909
 									</tr>
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
 								<?php
1192 1192
 
1193
-								if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) {
1194
-									?>
1193
+                                if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) {
1194
+                                    ?>
1195 1195
 									<tr>
1196 1196
 										<td>
1197 1197
 											<span class="warning"><?= $_lang['resource_type'] ?></span>
@@ -1213,15 +1213,15 @@  discard block
 block discarded – undo
1213 1213
 										<td>
1214 1214
 											<select name="contentType" class="inputBox" onchange="documentDirty=true;">
1215 1215
 												<?php
1216
-												if(!$content['contentType']) {
1217
-													$content['contentType'] = 'text/html';
1218
-												}
1219
-												$custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml");
1220
-												$ct = explode(",", $custom_contenttype);
1221
-												for($i = 0; $i < count($ct); $i++) {
1222
-													echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n";
1223
-												}
1224
-												?>
1216
+                                                if(!$content['contentType']) {
1217
+                                                    $content['contentType'] = 'text/html';
1218
+                                                }
1219
+                                                $custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml");
1220
+                                                $ct = explode(",", $custom_contenttype);
1221
+                                                for($i = 0; $i < count($ct); $i++) {
1222
+                                                    echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n";
1223
+                                                }
1224
+                                                ?>
1225 1225
 											</select>
1226 1226
 										</td>
1227 1227
 									</tr>
@@ -1244,23 +1244,23 @@  discard block
 block discarded – undo
1244 1244
 										</td>
1245 1245
 									</tr>
1246 1246
 									<?php
1247
-								} else {
1248
-									if($content['type'] != 'reference' && $modx->manager->action != '72') {
1249
-										// non-admin managers creating or editing a document resource
1250
-										?>
1247
+                                } else {
1248
+                                    if($content['type'] != 'reference' && $modx->manager->action != '72') {
1249
+                                        // non-admin managers creating or editing a document resource
1250
+                                        ?>
1251 1251
 										<input type="hidden" name="contentType" value="<?= (isset($content['contentType']) ? $content['contentType'] : "text/html") ?>" />
1252 1252
 										<input type="hidden" name="type" value="document" />
1253 1253
 										<input type="hidden" name="content_dispo" value="<?= (isset($content['content_dispo']) ? $content['content_dispo'] : '0') ?>" />
1254 1254
 										<?php
1255
-									} else {
1256
-										// non-admin managers creating or editing a reference (weblink) resource
1257
-										?>
1255
+                                    } else {
1256
+                                        // non-admin managers creating or editing a reference (weblink) resource
1257
+                                        ?>
1258 1258
 										<input type="hidden" name="type" value="reference" />
1259 1259
 										<input type="hidden" name="contentType" value="text/html" />
1260 1260
 										<?php
1261
-									}
1262
-								}//if mgrRole
1263
-								?>
1261
+                                    }
1262
+                                }//if mgrRole
1263
+                                ?>
1264 1264
 
1265 1265
 								<tr>
1266 1266
 									<td>
@@ -1343,112 +1343,112 @@  discard block
 block discarded – undo
1343 1343
                     ?>
1344 1344
 
1345 1345
 						<?php
1346
-					/*******************************
1346
+                    /*******************************
1347 1347
 					 * Document Access Permissions */
1348
-					if($use_udperms == 1) {
1349
-						$groupsarray = array();
1350
-						$sql = '';
1351
-
1352
-						$documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']));
1353
-						if($documentId > 0) {
1354
-							// Load up, the permissions from the parent (if new document) or existing document
1355
-							$rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'");
1356
-							while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1357
-
1358
-							// Load up the current permissions and names
1359
-							$vs = array(
1360
-								$tbl_document_group_names,
1361
-								$tbl_document_groups,
1362
-								$documentId
1363
-							);
1364
-							$from = vsprintf("%s AS dgn LEFT JOIN %s AS groups ON groups.document_group=dgn.id AND groups.document='%s'", $vs);
1365
-							$rs = $modx->db->select('dgn.*, groups.id AS link_id', $from, '', 'name');
1366
-						} else {
1367
-							// Just load up the names, we're starting clean
1368
-							$rs = $modx->db->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name');
1369
-						}
1370
-
1371
-						// retain selected doc groups between post
1372
-						if(isset($_POST['docgroups'])) {
1373
-							$groupsarray = array_merge($groupsarray, $_POST['docgroups']);
1374
-						}
1348
+                    if($use_udperms == 1) {
1349
+                        $groupsarray = array();
1350
+                        $sql = '';
1351
+
1352
+                        $documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']));
1353
+                        if($documentId > 0) {
1354
+                            // Load up, the permissions from the parent (if new document) or existing document
1355
+                            $rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'");
1356
+                            while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1357
+
1358
+                            // Load up the current permissions and names
1359
+                            $vs = array(
1360
+                                $tbl_document_group_names,
1361
+                                $tbl_document_groups,
1362
+                                $documentId
1363
+                            );
1364
+                            $from = vsprintf("%s AS dgn LEFT JOIN %s AS groups ON groups.document_group=dgn.id AND groups.document='%s'", $vs);
1365
+                            $rs = $modx->db->select('dgn.*, groups.id AS link_id', $from, '', 'name');
1366
+                        } else {
1367
+                            // Just load up the names, we're starting clean
1368
+                            $rs = $modx->db->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name');
1369
+                        }
1370
+
1371
+                        // retain selected doc groups between post
1372
+                        if(isset($_POST['docgroups'])) {
1373
+                            $groupsarray = array_merge($groupsarray, $_POST['docgroups']);
1374
+                        }
1375
+
1376
+                        $isManager = $modx->hasPermission('access_permissions');
1377
+                        $isWeb = $modx->hasPermission('web_access_permissions');
1378
+
1379
+                        // Setup Basic attributes for each Input box
1380
+                        $inputAttributes = array(
1381
+                            'type' => 'checkbox',
1382
+                            'class' => 'checkbox',
1383
+                            'name' => 'docgroups[]',
1384
+                            'onclick' => 'makePublic(false);',
1385
+                        );
1386
+                        $permissions = array(); // New Permissions array list (this contains the HTML)
1387
+                        $permissions_yes = 0; // count permissions the current mgr user has
1388
+                        $permissions_no = 0; // count permissions the current mgr user doesn't have
1389
+
1390
+                        // Loop through the permissions list
1391
+                        while($row = $modx->db->getRow($rs)) {
1392
+
1393
+                            // Create an inputValue pair (group ID and group link (if it exists))
1394
+                            $inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new');
1395
+                            $inputId = 'group-' . $row['id'];
1396
+
1397
+                            $checked = in_array($inputValue, $groupsarray);
1398
+                            if($checked) {
1399
+                                $notPublic = true;
1400
+                            } // Mark as private access (either web or manager)
1401
+
1402
+                            // Skip the access permission if the user doesn't have access...
1403
+                            if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) {
1404
+                                continue;
1405
+                            }
1375 1406
 
1376
-						$isManager = $modx->hasPermission('access_permissions');
1377
-						$isWeb = $modx->hasPermission('web_access_permissions');
1378
-
1379
-						// Setup Basic attributes for each Input box
1380
-						$inputAttributes = array(
1381
-							'type' => 'checkbox',
1382
-							'class' => 'checkbox',
1383
-							'name' => 'docgroups[]',
1384
-							'onclick' => 'makePublic(false);',
1385
-						);
1386
-						$permissions = array(); // New Permissions array list (this contains the HTML)
1387
-						$permissions_yes = 0; // count permissions the current mgr user has
1388
-						$permissions_no = 0; // count permissions the current mgr user doesn't have
1389
-
1390
-						// Loop through the permissions list
1391
-						while($row = $modx->db->getRow($rs)) {
1392
-
1393
-							// Create an inputValue pair (group ID and group link (if it exists))
1394
-							$inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new');
1395
-							$inputId = 'group-' . $row['id'];
1396
-
1397
-							$checked = in_array($inputValue, $groupsarray);
1398
-							if($checked) {
1399
-								$notPublic = true;
1400
-							} // Mark as private access (either web or manager)
1401
-
1402
-							// Skip the access permission if the user doesn't have access...
1403
-							if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) {
1404
-								continue;
1405
-							}
1406
-
1407
-							// Setup attributes for this Input box
1408
-							$inputAttributes['id'] = $inputId;
1409
-							$inputAttributes['value'] = $inputValue;
1410
-							if($checked) {
1411
-								$inputAttributes['checked'] = 'checked';
1412
-							} else {
1413
-								unset($inputAttributes['checked']);
1414
-							}
1415
-
1416
-							// Create attribute string list
1417
-							$inputString = array();
1418
-							foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"';
1419
-
1420
-							// Make the <input> HTML
1421
-							$inputHTML = '<input ' . implode(' ', $inputString) . ' />';
1422
-
1423
-							// does user have this permission?
1424
-							$from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg";
1425
-							$vs = array(
1426
-								$row['id'],
1427
-								$_SESSION['mgrInternalKey']
1428
-							);
1429
-							$where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs);
1430
-							$rsp = $modx->db->select('COUNT(mg.id)', $from, $where);
1431
-							$count = $modx->db->getValue($rsp);
1432
-							if($count > 0) {
1433
-								++$permissions_yes;
1434
-							} else {
1435
-								++$permissions_no;
1436
-							}
1437
-							$permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>';
1438
-						}
1439
-						// if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public
1440
-						if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) {
1441
-							$permissions = array();
1442
-						}
1407
+                            // Setup attributes for this Input box
1408
+                            $inputAttributes['id'] = $inputId;
1409
+                            $inputAttributes['value'] = $inputValue;
1410
+                            if($checked) {
1411
+                                $inputAttributes['checked'] = 'checked';
1412
+                            } else {
1413
+                                unset($inputAttributes['checked']);
1414
+                            }
1443 1415
 
1444
-						// See if the Access Permissions section is worth displaying...
1445
-						if(!empty($permissions)) {
1446
-							// Add the "All Document Groups" item if we have rights in both contexts
1447
-							if($isManager && $isWeb) {
1448
-								array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>');
1449
-							}
1450
-							// Output the permissions list...
1451
-							?>
1416
+                            // Create attribute string list
1417
+                            $inputString = array();
1418
+                            foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"';
1419
+
1420
+                            // Make the <input> HTML
1421
+                            $inputHTML = '<input ' . implode(' ', $inputString) . ' />';
1422
+
1423
+                            // does user have this permission?
1424
+                            $from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg";
1425
+                            $vs = array(
1426
+                                $row['id'],
1427
+                                $_SESSION['mgrInternalKey']
1428
+                            );
1429
+                            $where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs);
1430
+                            $rsp = $modx->db->select('COUNT(mg.id)', $from, $where);
1431
+                            $count = $modx->db->getValue($rsp);
1432
+                            if($count > 0) {
1433
+                                ++$permissions_yes;
1434
+                            } else {
1435
+                                ++$permissions_no;
1436
+                            }
1437
+                            $permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>';
1438
+                        }
1439
+                        // if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public
1440
+                        if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) {
1441
+                            $permissions = array();
1442
+                        }
1443
+
1444
+                        // See if the Access Permissions section is worth displaying...
1445
+                        if(!empty($permissions)) {
1446
+                            // Add the "All Document Groups" item if we have rights in both contexts
1447
+                            if($isManager && $isWeb) {
1448
+                                array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>');
1449
+                            }
1450
+                            // Output the permissions list...
1451
+                            ?>
1452 1452
 							<!-- Access Permissions -->
1453 1453
 							<div class="tab-page" id="tabAccess">
1454 1454
 								<h2 class="tab" id="tab_access_header"><?= $_lang['access_permissions'] ?></h2>
@@ -1482,31 +1482,31 @@  discard block
 block discarded – undo
1482 1482
 								</ul>
1483 1483
 							</div><!--div class="tab-page" id="tabAccess"-->
1484 1484
 							<?php
1485
-						} // !empty($permissions)
1486
-						elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) {
1487
-							?>
1485
+                        } // !empty($permissions)
1486
+                        elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) {
1487
+                            ?>
1488 1488
 							<p><?= $_lang["access_permissions_docs_collision"] ?></p>
1489 1489
 							<?php
1490 1490
 
1491
-						}
1492
-					}
1493
-					/* End Document Access Permissions *
1491
+                        }
1492
+                    }
1493
+                    /* End Document Access Permissions *
1494 1494
 					 ***********************************/
1495
-					?>
1495
+                    ?>
1496 1496
 
1497 1497
 					<input type="submit" name="save" style="display:none" />
1498 1498
 					<?php
1499 1499
 
1500
-					// invoke OnDocFormRender event
1501
-					$evtOut = $modx->invokeEvent('OnDocFormRender', array(
1502
-						'id' => $id,
1503
-						'template' => $content['template']
1504
-					));
1500
+                    // invoke OnDocFormRender event
1501
+                    $evtOut = $modx->invokeEvent('OnDocFormRender', array(
1502
+                        'id' => $id,
1503
+                        'template' => $content['template']
1504
+                    ));
1505 1505
 
1506
-					if(is_array($evtOut)) {
1507
-						echo implode('', $evtOut);
1508
-					}
1509
-					?>
1506
+                    if(is_array($evtOut)) {
1507
+                        echo implode('', $evtOut);
1508
+                    }
1509
+                    ?>
1510 1510
 				</div><!--div class="tab-pane" id="documentPane"-->
1511 1511
 			</div><!--div class="sectionBody"-->
1512 1512
 		</fieldset>
@@ -1517,63 +1517,63 @@  discard block
 block discarded – undo
1517 1517
 	</script>
1518 1518
 <?php
1519 1519
 if(($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) {
1520
-	if(is_array($richtexteditorIds)) {
1521
-		foreach($richtexteditorIds as $editor => $elements) {
1522
-			// invoke OnRichTextEditorInit event
1523
-			$evtOut = $modx->invokeEvent('OnRichTextEditorInit', array(
1524
-				'editor' => $editor,
1525
-				'elements' => $elements,
1526
-				'options' => $richtexteditorOptions[$editor]
1527
-			));
1528
-			if(is_array($evtOut)) {
1529
-				echo implode('', $evtOut);
1530
-			}
1531
-		}
1532
-	}
1520
+    if(is_array($richtexteditorIds)) {
1521
+        foreach($richtexteditorIds as $editor => $elements) {
1522
+            // invoke OnRichTextEditorInit event
1523
+            $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array(
1524
+                'editor' => $editor,
1525
+                'elements' => $elements,
1526
+                'options' => $richtexteditorOptions[$editor]
1527
+            ));
1528
+            if(is_array($evtOut)) {
1529
+                echo implode('', $evtOut);
1530
+            }
1531
+        }
1532
+    }
1533 1533
 }
1534 1534
 
1535 1535
 /**
1536 1536
  * @return string
1537 1537
  */
1538 1538
 function getDefaultTemplate() {
1539
-	$modx = evolutionCMS();
1539
+    $modx = evolutionCMS();
1540 1540
 
1541 1541
     $default_template = '';
1542
-	switch($modx->config['auto_template_logic']) {
1543
-		case 'sibling':
1544
-			if(!isset($_GET['pid']) || empty($_GET['pid'])) {
1545
-				$site_start = $modx->config['site_start'];
1546
-				$where = "sc.isfolder=0 AND sc.id!='{$site_start}'";
1547
-				$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1);
1548
-				if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1549
-					$default_template = $sibl[0]['template'];
1550
-				}
1551
-			} else {
1552
-				$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1553
-				if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1554
-					$default_template = $sibl[0]['template'];
1555
-				} else {
1556
-					$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1557
-					if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1558
-						$default_template = $sibl[0]['template'];
1559
-					}
1560
-				}
1561
-			}
1562
-			if(isset($default_template)) {
1563
-				break;
1564
-			} // If $default_template could not be determined, fall back / through to "parent"-mode
1565
-		case 'parent':
1566
-			if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) {
1567
-				$parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template');
1568
-				if(isset($parent['template'])) {
1569
-					$default_template = $parent['template'];
1570
-				}
1571
-			}
1572
-			break;
1573
-		case 'system':
1574
-		default: // default_template is already set
1575
-			$default_template = $modx->config['default_template'];
1576
-	}
1577
-
1578
-	return empty($default_template) ? $modx->config['default_template'] : $default_template;
1542
+    switch($modx->config['auto_template_logic']) {
1543
+        case 'sibling':
1544
+            if(!isset($_GET['pid']) || empty($_GET['pid'])) {
1545
+                $site_start = $modx->config['site_start'];
1546
+                $where = "sc.isfolder=0 AND sc.id!='{$site_start}'";
1547
+                $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1);
1548
+                if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1549
+                    $default_template = $sibl[0]['template'];
1550
+                }
1551
+            } else {
1552
+                $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1553
+                if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1554
+                    $default_template = $sibl[0]['template'];
1555
+                } else {
1556
+                    $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1557
+                    if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1558
+                        $default_template = $sibl[0]['template'];
1559
+                    }
1560
+                }
1561
+            }
1562
+            if(isset($default_template)) {
1563
+                break;
1564
+            } // If $default_template could not be determined, fall back / through to "parent"-mode
1565
+        case 'parent':
1566
+            if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) {
1567
+                $parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template');
1568
+                if(isset($parent['template'])) {
1569
+                    $default_template = $parent['template'];
1570
+                }
1571
+            }
1572
+            break;
1573
+        case 'system':
1574
+        default: // default_template is already set
1575
+            $default_template = $modx->config['default_template'];
1576
+    }
1577
+
1578
+    return empty($default_template) ? $modx->config['default_template'] : $default_template;
1579 1579
 }
Please login to merge, or discard this patch.
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -1,35 +1,35 @@  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
 
6 6
 /********************/
7
-$sd = isset($_REQUEST['dir']) ? '&dir=' . $_REQUEST['dir'] : '&dir=DESC';
8
-$sb = isset($_REQUEST['sort']) ? '&sort=' . $_REQUEST['sort'] : '&sort=createdon';
9
-$pg = isset($_REQUEST['page']) ? '&page=' . (int) $_REQUEST['page'] : '';
10
-$add_path = $sd . $sb . $pg;
7
+$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC';
8
+$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon';
9
+$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : '';
10
+$add_path = $sd.$sb.$pg;
11 11
 /*******************/
12 12
 
13 13
 // check permissions
14
-switch($modx->manager->action) {
14
+switch ($modx->manager->action) {
15 15
 	case 27:
16
-		if(!$modx->hasPermission('edit_document')) {
16
+		if (!$modx->hasPermission('edit_document')) {
17 17
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
18 18
 		}
19 19
 		break;
20 20
 	case 85:
21 21
 	case 72:
22 22
 	case 4:
23
-		if(!$modx->hasPermission('new_document')) {
23
+		if (!$modx->hasPermission('new_document')) {
24 24
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
25
-		} elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') {
25
+		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') {
26 26
 			// check user has permissions for parent
27
-			include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
27
+			include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php');
28 28
 			$udperms = new udperms();
29 29
 			$udperms->user = $modx->getLoginUserID();
30 30
 			$udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid'];
31 31
 			$udperms->role = $_SESSION['mgrRole'];
32
-			if(!$udperms->checkPermissions()) {
32
+			if (!$udperms->checkPermissions()) {
33 33
 				$modx->webAlertAndQuit($_lang["access_permission_denied"]);
34 34
 			}
35 35
 		}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
39 39
 }
40 40
 
41
-$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
41
+$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
42 42
 
43 43
 // Get table names (alphabetical)
44 44
 $tbl_categories = $modx->getFullTableName('categories');
@@ -53,22 +53,22 @@  discard block
 block discarded – undo
53 53
 $tbl_site_tmplvar_templates = $modx->getFullTableName('site_tmplvar_templates');
54 54
 $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars');
55 55
 
56
-if($modx->manager->action == 27) {
56
+if ($modx->manager->action == 27) {
57 57
 	//editing an existing document
58 58
 	// check permissions on the document
59
-	include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
59
+	include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php');
60 60
 	$udperms = new udperms();
61 61
 	$udperms->user = $modx->getLoginUserID();
62 62
 	$udperms->document = $id;
63 63
 	$udperms->role = $_SESSION['mgrRole'];
64 64
 
65
-	if(!$udperms->checkPermissions()) {
65
+	if (!$udperms->checkPermissions()) {
66 66
 		$modx->webAlertAndQuit($_lang["access_permission_denied"]);
67 67
 	}
68 68
 }
69 69
 
70 70
 // check to see if resource isn't locked
71
-if($lockedEl = $modx->elementIsLocked(7, $id)) {
71
+if ($lockedEl = $modx->elementIsLocked(7, $id)) {
72 72
 	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource']));
73 73
 }
74 74
 // end check for lock
@@ -77,27 +77,27 @@  discard block
 block discarded – undo
77 77
 $modx->lockElement(7, $id);
78 78
 
79 79
 // get document groups for current user
80
-if($_SESSION['mgrDocgroups']) {
80
+if ($_SESSION['mgrDocgroups']) {
81 81
 	$docgrp = implode(',', $_SESSION['mgrDocgroups']);
82 82
 }
83 83
 
84
-if(!empty ($id)) {
84
+if (!empty ($id)) {
85 85
 	$access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']);
86
-	if($docgrp) {
86
+	if ($docgrp) {
87 87
 		$access .= " OR dg.document_group IN ({$docgrp})";
88 88
 	}
89 89
 	$rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})");
90 90
 	$content = array();
91 91
 	$content = $modx->db->getRow($rs);
92 92
 	$modx->documentObject = &$content;
93
-	if(!$content) {
93
+	if (!$content) {
94 94
 		$modx->webAlertAndQuit($_lang["access_permission_denied"]);
95 95
 	}
96 96
 	$_SESSION['itemname'] = $content['pagetitle'];
97 97
 } else {
98 98
 	$content = array();
99 99
 
100
-	if(isset($_REQUEST['newtemplate'])) {
100
+	if (isset($_REQUEST['newtemplate'])) {
101 101
 		$content['template'] = $_REQUEST['newtemplate'];
102 102
 	} else {
103 103
 		$content['template'] = getDefaultTemplate();
@@ -108,22 +108,22 @@  discard block
 block discarded – undo
108 108
 
109 109
 // restore saved form
110 110
 $formRestored = $modx->manager->loadFormValues();
111
-if(isset($_REQUEST['newtemplate'])) {
111
+if (isset($_REQUEST['newtemplate'])) {
112 112
 	$formRestored = true;
113 113
 }
114 114
 
115 115
 // retain form values if template was changed
116 116
 // edited to convert pub_date and unpub_date
117 117
 // sottwell 02-09-2006
118
-if($formRestored == true) {
118
+if ($formRestored == true) {
119 119
 	$content = array_merge($content, $_POST);
120 120
 	$content['content'] = $_POST['ta'];
121
-	if(empty ($content['pub_date'])) {
121
+	if (empty ($content['pub_date'])) {
122 122
 		unset ($content['pub_date']);
123 123
 	} else {
124 124
 		$content['pub_date'] = $modx->toTimeStamp($content['pub_date']);
125 125
 	}
126
-	if(empty ($content['unpub_date'])) {
126
+	if (empty ($content['unpub_date'])) {
127 127
 		unset ($content['unpub_date']);
128 128
 	} else {
129 129
 		$content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']);
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 }
132 132
 
133 133
 // increase menu index if this is a new document
134
-if(!isset ($_REQUEST['id'])) {
135
-	if(!isset ($modx->config['auto_menuindex'])) {
134
+if (!isset ($_REQUEST['id'])) {
135
+	if (!isset ($modx->config['auto_menuindex'])) {
136 136
 		$modx->config['auto_menuindex'] = 1;
137 137
 	}
138
-	if($modx->config['auto_menuindex']) {
139
-		$pid = (int)$_REQUEST['pid'];
138
+	if ($modx->config['auto_menuindex']) {
139
+		$pid = (int) $_REQUEST['pid'];
140 140
 		$rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'");
141 141
 		$content['menuindex'] = $modx->db->getValue($rs);
142 142
 	} else {
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 }
146 146
 
147
-if(isset ($_POST['which_editor'])) {
147
+if (isset ($_POST['which_editor'])) {
148 148
 	$modx->config['which_editor'] = $_POST['which_editor'];
149 149
 }
150 150
 
151 151
 // Add lock-element JS-Script
152 152
 $lockElementId = $id;
153 153
 $lockElementType = 7;
154
-require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php');
154
+require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php');
155 155
 ?>
156 156
 	<script type="text/javascript">
157 157
 		/* <![CDATA[ */
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			},
182 182
 			cancel: function() {
183 183
 				documentDirty = false;
184
-				document.location.href = 'index.php?<?=($id == 0 ? 'a=2' : 'a=3&r=1&id=' . $id . $add_path) ?>';
184
+				document.location.href = 'index.php?<?=($id == 0 ? 'a=2' : 'a=3&r=1&id='.$id.$add_path) ?>';
185 185
 			},
186 186
 			duplicate: function() {
187 187
 				if(confirm("<?= $_lang['confirm_resource_duplicate']?>") === true) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				}
190 190
 			},
191 191
 			view: function() {
192
-				window.open('<?= ($modx->config['friendly_urls'] == '1') ? $modx->makeUrl($id) : $modx->config['site_url'] . 'index.php?id=' . $id ?>', 'previeWin');
192
+				window.open('<?= ($modx->config['friendly_urls'] == '1') ? $modx->makeUrl($id) : $modx->config['site_url'].'index.php?id='.$id ?>', 'previeWin');
193 193
 			}
194 194
 		};
195 195
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 			'template' => $content['template']
552 552
 		));
553 553
 
554
-		if(is_array($evtOut)) {
554
+		if (is_array($evtOut)) {
555 555
 			echo implode('', $evtOut);
556 556
 		}
557 557
 
@@ -575,8 +575,8 @@  discard block
 block discarded – undo
575 575
 		<fieldset id="create_edit">
576 576
 
577 577
 			<h1>
578
-				<i class="fa fa-pencil-square-o"></i><?php if(isset($_REQUEST['id'])) {
579
-					echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>';
578
+				<i class="fa fa-pencil-square-o"></i><?php if (isset($_REQUEST['id'])) {
579
+					echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']).(iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '').'<small>('.$_REQUEST['id'].')</small>';
580 580
 				} else {
581 581
 				    if ($modx->manager->action == '4') {
582 582
                         echo $_lang['add_resource'];
@@ -592,36 +592,36 @@  discard block
 block discarded – undo
592 592
 
593 593
 			<?php
594 594
 			// breadcrumbs
595
-			if($modx->config['use_breadcrumbs']) {
595
+			if ($modx->config['use_breadcrumbs']) {
596 596
 				$temp = array();
597 597
 				$title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title'];
598 598
 
599
-				if(isset($_REQUEST['id']) && $content['parent'] != 0) {
599
+				if (isset($_REQUEST['id']) && $content['parent'] != 0) {
600 600
 					$bID = (int) $_REQUEST['id'];
601 601
 					$temp = $modx->getParentIds($bID);
602
-				} else if(isset($_REQUEST['pid'])) {
602
+				} else if (isset($_REQUEST['pid'])) {
603 603
 					$bID = (int) $_REQUEST['pid'];
604 604
 					$temp = $modx->getParentIds($bID);
605 605
 					array_unshift($temp, $bID);
606 606
 				}
607 607
 
608
-				if($temp) {
608
+				if ($temp) {
609 609
 					$parents = implode(',', $temp);
610 610
 
611
-					if(!empty($parents)) {
611
+					if (!empty($parents)) {
612 612
 						$where = "FIND_IN_SET(id,'{$parents}') DESC";
613 613
 						$rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where);
614
-						while($row = $modx->db->getRow($rs)) {
614
+						while ($row = $modx->db->getRow($rs)) {
615 615
 							$out .= '<li class="breadcrumbs__li">
616
-                                <a href="index.php?a=27&id=' . $row['id'] . '" class="breadcrumbs__a">' . htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']) . '</a>
616
+                                <a href="index.php?a=27&id=' . $row['id'].'" class="breadcrumbs__a">'.htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']).'</a>
617 617
                                 <span class="breadcrumbs__sep">&gt;</span>
618 618
                             </li>';
619 619
 						}
620 620
 					}
621 621
 				}
622 622
 
623
-				$out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>';
624
-				echo '<ul class="breadcrumbs">' . $out . '</ul>';
623
+				$out .= '<li class="breadcrumbs__li breadcrumbs__li_current">'.$title.'</li>';
624
+				echo '<ul class="breadcrumbs">'.$out.'</ul>';
625 625
 			}
626 626
 			?>
627 627
 
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 					$evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array(
639 639
 						'id' => $id
640 640
 					));
641
-					if(is_array($evtOut)) {
641
+					if (is_array($evtOut)) {
642 642
 						echo implode('', $evtOut);
643 643
 					} else {
644 644
 						?>
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 									</td>
695 695
 								</tr>
696 696
 
697
-								<?php if($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?>
697
+								<?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?>
698 698
 
699 699
 									<tr>
700 700
 										<td><span class="warning"><?= $_lang['weblink'] ?></span>
@@ -730,17 +730,17 @@  discard block
 block discarded – undo
730 730
 											$from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id";
731 731
 											$rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC');
732 732
 											$currentCategory = '';
733
-											while($row = $modx->db->getRow($rs)) {
734
-												if($row['selectable'] != 1 && $row['id'] != $content['template']) {
733
+											while ($row = $modx->db->getRow($rs)) {
734
+												if ($row['selectable'] != 1 && $row['id'] != $content['template']) {
735 735
 													continue;
736 736
 												};
737 737
 												// Skip if not selectable but show if selected!
738 738
 												$thisCategory = $row['category'];
739
-												if($thisCategory == null) {
739
+												if ($thisCategory == null) {
740 740
 													$thisCategory = $_lang["no_category"];
741 741
 												}
742
-												if($thisCategory != $currentCategory) {
743
-													if($closeOptGroup) {
742
+												if ($thisCategory != $currentCategory) {
743
+													if ($closeOptGroup) {
744 744
 														echo "\t\t\t\t\t</optgroup>\n";
745 745
 													}
746 746
 													echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n";
@@ -749,10 +749,10 @@  discard block
 block discarded – undo
749 749
 
750 750
 												$selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : '';
751 751
 
752
-												echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n";
752
+												echo "\t\t\t\t\t".'<option value="'.$row['id'].'"'.$selectedtext.'>'.$row['templatename']."</option>\n";
753 753
 												$currentCategory = $thisCategory;
754 754
 											}
755
-											if($thisCategory != '') {
755
+											if ($thisCategory != '') {
756 756
 												echo "\t\t\t\t\t</optgroup>\n";
757 757
 											}
758 758
 											?>
@@ -796,20 +796,20 @@  discard block
 block discarded – undo
796 796
 									<td valign="top">
797 797
 										<?php
798 798
 										$parentlookup = false;
799
-										if(isset ($_REQUEST['id'])) {
800
-											if($content['parent'] == 0) {
799
+										if (isset ($_REQUEST['id'])) {
800
+											if ($content['parent'] == 0) {
801 801
 												$parentname = $site_name;
802 802
 											} else {
803 803
 												$parentlookup = $content['parent'];
804 804
 											}
805
-										} elseif(isset ($_REQUEST['pid'])) {
806
-											if($_REQUEST['pid'] == 0) {
805
+										} elseif (isset ($_REQUEST['pid'])) {
806
+											if ($_REQUEST['pid'] == 0) {
807 807
 												$parentname = $site_name;
808 808
 											} else {
809 809
 												$parentlookup = $_REQUEST['pid'];
810 810
 											}
811
-										} elseif(isset($_POST['parent'])) {
812
-											if($_POST['parent'] == 0) {
811
+										} elseif (isset($_POST['parent'])) {
812
+											if ($_POST['parent'] == 0) {
813 813
 												$parentname = $site_name;
814 814
 											} else {
815 815
 												$parentlookup = $_POST['parent'];
@@ -818,10 +818,10 @@  discard block
 block discarded – undo
818 818
 											$parentname = $site_name;
819 819
 											$content['parent'] = 0;
820 820
 										}
821
-										if($parentlookup !== false && is_numeric($parentlookup)) {
821
+										if ($parentlookup !== false && is_numeric($parentlookup)) {
822 822
 											$rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'");
823 823
 											$parentname = $modx->db->getValue($rs);
824
-											if(!$parentname) {
824
+											if (!$parentname) {
825 825
 												$modx->webAlertAndQuit($_lang["error_no_parent"]);
826 826
 											}
827 827
 										}
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 								}*/
864 864
 								?>
865 865
 
866
-								<?php if($content['type'] == 'document' || $modx->manager->action == '4') { ?>
866
+								<?php if ($content['type'] == 'document' || $modx->manager->action == '4') { ?>
867 867
 									<tr>
868 868
 										<td colspan="2">
869 869
 											<hr>
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 														<?php
877 877
 														// invoke OnRichTextEditorRegister event
878 878
 														$evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
879
-														if(is_array($evtOut)) {
880
-															for($i = 0; $i < count($evtOut); $i++) {
879
+														if (is_array($evtOut)) {
880
+															for ($i = 0; $i < count($evtOut); $i++) {
881 881
 																$editor = $evtOut[$i];
882 882
 																echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n";
883 883
 															}
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 											</div>
889 889
 											<div id="content_body">
890 890
 												<?php
891
-												if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) {
891
+												if (($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) {
892 892
 													$htmlContent = $content['content'];
893 893
 													?>
894 894
 													<div class="section-editor clearfix">
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 													$richtexteditorIds[$modx->config['which_editor']][] = 'ta';
902 902
 													$richtexteditorOptions[$modx->config['which_editor']]['ta'] = '';
903 903
 												} else {
904
-													echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n";
904
+													echo "\t".'<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>'."\n";
905 905
 												}
906 906
 												?>
907 907
 											</div>
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 
918 918
                             if (($content['type'] == 'document' || $modx->manager->action == '4') || ($content['type'] == 'reference' || $modx->manager->action == 72)) {
919 919
                                 $template = $default_template;
920
-                                $group_tvs = empty($modx->config['group_tvs']) ? 0 : (int)$modx->config['group_tvs'];
920
+                                $group_tvs = empty($modx->config['group_tvs']) ? 0 : (int) $modx->config['group_tvs'];
921 921
                                 if (isset ($_REQUEST['newtemplate'])) {
922 922
                                     $template = $_REQUEST['newtemplate'];
923 923
                                 } else {
@@ -945,10 +945,10 @@  discard block
 block discarded – undo
945 945
                                 );
946 946
                                 $sort = 'tvtpl.rank,tv.rank, tv.id';
947 947
                                 if ($group_tvs) {
948
-                                    $field .= ', IFNULL(tv.category,0) as category_id, IFNULL(cat.category,"' . $_lang['no_category'] . '") AS category, IFNULL(cat.rank,0) AS category_rank';
948
+                                    $field .= ', IFNULL(tv.category,0) as category_id, IFNULL(cat.category,"'.$_lang['no_category'].'") AS category, IFNULL(cat.rank,0) AS category_rank';
949 949
                                     $from .= '
950
-                                    LEFT JOIN ' . $tbl_categories . ' AS cat ON cat.id=tv.category';
951
-                                    $sort = 'cat.rank,cat.id,' . $sort;
950
+                                    LEFT JOIN ' . $tbl_categories.' AS cat ON cat.id=tv.category';
951
+                                    $sort = 'cat.rank,cat.id,'.$sort;
952 952
                                 }
953 953
                                 $where = vsprintf("tvtpl.templateid='%s' AND (1='%s' OR ISNULL(tva.documentgroup) %s)", $vs);
954 954
                                 $rs = $modx->db->select($field, $from, $where, $sort);
@@ -957,37 +957,37 @@  discard block
 block discarded – undo
957 957
                         <!-- Template Variables -->' . "\n";
958 958
                                     if (!$group_tvs) {
959 959
                                         $templateVariables .= '
960
-                                    <div class="sectionHeader" id="tv_header">' . $_lang['settings_templvars'] . '</div>
960
+                                    <div class="sectionHeader" id="tv_header">' . $_lang['settings_templvars'].'</div>
961 961
                                         <div class="sectionBody tmplvars">
962 962
                                             <table>';
963 963
                                     } else if ($group_tvs == 2) {
964 964
                                         $templateVariables .= '
965 965
                     <div class="tab-section">
966
-                        <div class="tab-header" id="tv_header">' . $_lang['settings_templvars'] . '</div>
966
+                        <div class="tab-header" id="tv_header">' . $_lang['settings_templvars'].'</div>
967 967
                         <div class="tab-pane" id="paneTemplateVariables">
968 968
                             <script type="text/javascript">
969
-                                tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
969
+                                tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').');
970 970
                             </script>';
971 971
                                     } else if ($group_tvs == 3) {
972 972
                                         $templateVariables .= '
973 973
                         <div id="templateVariables" class="tab-page tmplvars">
974
-                            <h2 class="tab">' . $_lang['settings_templvars'] . '</h2>
974
+                            <h2 class="tab">' . $_lang['settings_templvars'].'</h2>
975 975
                             <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'templateVariables\'));</script>';
976 976
                                     } else if ($group_tvs == 4) {
977 977
                                         $templateVariables .= '
978 978
                     <div id="templateVariables" class="tab-page tmplvars">
979
-                        <h2 class="tab">' . $_lang['settings_templvars'] . '</h2>
979
+                        <h2 class="tab">' . $_lang['settings_templvars'].'</h2>
980 980
                         <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'templateVariables\'));</script>
981 981
                         
982 982
                         <div class="tab-pane" id="paneTemplateVariables">
983 983
                             <script type="text/javascript">
984
-                                tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
984
+                                tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').');
985 985
                             </script>';
986 986
                                     }
987 987
 
988 988
                                     $tvsArray = $modx->db->makeArray($rs, 'name');
989
-                                    require_once(MODX_MANAGER_PATH . 'includes/tmplvars.inc.php');
990
-                                    require_once(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php');
989
+                                    require_once(MODX_MANAGER_PATH.'includes/tmplvars.inc.php');
990
+                                    require_once(MODX_MANAGER_PATH.'includes/tmplvars.commands.inc.php');
991 991
                                     $i = 0;
992 992
                                     $tab = '';
993 993
                                     foreach ($tvsArray as $row) {
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
                                             if ($group_tvs == 1 || $group_tvs == 3) {
996 996
                                                 if ($i === 0) {
997 997
                                                     $templateVariables .= '
998
-                            <div class="tab-section" id="tabTV_' . $row['category_id'] . '">
999
-                                <div class="tab-header">' . $row['category'] . '</div>
998
+                            <div class="tab-section" id="tabTV_' . $row['category_id'].'">
999
+                                <div class="tab-header">' . $row['category'].'</div>
1000 1000
                                 <div class="tab-body tmplvars">
1001 1001
                                     <table>' . "\n";
1002 1002
                                                 } else {
@@ -1005,17 +1005,17 @@  discard block
 block discarded – undo
1005 1005
                                 </div>
1006 1006
                             </div>
1007 1007
                             
1008
-                            <div class="tab-section" id="tabTV_' . $row['category_id'] . '">
1009
-                                <div class="tab-header">' . $row['category'] . '</div>
1008
+                            <div class="tab-section" id="tabTV_' . $row['category_id'].'">
1009
+                                <div class="tab-header">' . $row['category'].'</div>
1010 1010
                                 <div class="tab-body tmplvars">
1011 1011
                                     <table>';
1012 1012
                                                 }
1013 1013
                                             } else if ($group_tvs == 2 || $group_tvs == 4) {
1014 1014
                                                 if ($i === 0) {
1015 1015
                                                     $templateVariables .= '
1016
-                            <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars">
1017
-                                <h2 class="tab">' . $row['category'] . '</h2>
1018
-                                <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script>
1016
+                            <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars">
1017
+                                <h2 class="tab">' . $row['category'].'</h2>
1018
+                                <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script>
1019 1019
                                 
1020 1020
                                 <div class="tab-body tmplvars">
1021 1021
                                     <table>';
@@ -1025,9 +1025,9 @@  discard block
 block discarded – undo
1025 1025
                                 </div>
1026 1026
                             </div>
1027 1027
                             
1028
-                            <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars">
1029
-                                <h2 class="tab">' . $row['category'] . '</h2>
1030
-                                <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script>
1028
+                            <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars">
1029
+                                <h2 class="tab">' . $row['category'].'</h2>
1030
+                                <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script>
1031 1031
                                 
1032 1032
                                 <div class="tab-body tmplvars">
1033 1033
                                     <table>';
@@ -1035,18 +1035,18 @@  discard block
 block discarded – undo
1035 1035
                                             } else if ($group_tvs == 5) {
1036 1036
                                                 if ($i === 0) {
1037 1037
                                                     $templateVariables .= '
1038
-                                <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars">
1039
-                                    <h2 class="tab">' . $row['category'] . '</h2>
1040
-                                    <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script>
1038
+                                <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars">
1039
+                                    <h2 class="tab">' . $row['category'].'</h2>
1040
+                                    <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script>
1041 1041
                                     <table>';
1042 1042
                                                 } else {
1043 1043
                                                     $templateVariables .= '
1044 1044
                                     </table>
1045 1045
                                 </div>
1046 1046
                                 
1047
-                                <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars">
1048
-                                    <h2 class="tab">' . $row['category'] . '</h2>
1049
-                                    <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script>
1047
+                                <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars">
1048
+                                    <h2 class="tab">' . $row['category'].'</h2>
1049
+                                    <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script>
1050 1050
                                     
1051 1051
                                     <table>';
1052 1052
                                                 }
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
                                                 $editor = isset($tvOptions['editor']) ? $tvOptions['editor'] : $modx->config['which_editor'];
1065 1065
                                             };
1066 1066
                                             // Add richtext editor to the list
1067
-                                            $richtexteditorIds[$editor][] = "tv" . $row['id'];
1068
-                                            $richtexteditorOptions[$editor]["tv" . $row['id']] = $tvOptions;
1067
+                                            $richtexteditorIds[$editor][] = "tv".$row['id'];
1068
+                                            $richtexteditorOptions[$editor]["tv".$row['id']] = $tvOptions;
1069 1069
                                         }
1070 1070
                                         // splitter
1071 1071
                                         if ($group_tvs) {
@@ -1079,24 +1079,24 @@  discard block
 block discarded – undo
1079 1079
                                         }
1080 1080
 
1081 1081
                                         // post back value
1082
-                                        if (array_key_exists('tv' . $row['id'], $_POST)) {
1083
-                                            if (is_array($_POST['tv' . $row['id']])) {
1084
-                                                $tvPBV = implode('||', $_POST['tv' . $row['id']]);
1082
+                                        if (array_key_exists('tv'.$row['id'], $_POST)) {
1083
+                                            if (is_array($_POST['tv'.$row['id']])) {
1084
+                                                $tvPBV = implode('||', $_POST['tv'.$row['id']]);
1085 1085
                                             } else {
1086
-                                                $tvPBV = $_POST['tv' . $row['id']];
1086
+                                                $tvPBV = $_POST['tv'.$row['id']];
1087 1087
                                             }
1088 1088
                                         } else {
1089 1089
                                             $tvPBV = $row['value'];
1090 1090
                                         }
1091 1091
 
1092
-                                        $tvDescription = (!empty($row['description'])) ? '<br /><span class="comment">' . $row['description'] . '</span>' : '';
1093
-                                        $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '<br /><span class="comment inherited">(' . $_lang['tmplvars_inherited'] . ')</span>' : '';
1094
-                                        $tvName = $modx->hasPermission('edit_template') ? '<br/><small class="protectedNode">[*' . $row['name'] . '*]</small>' : '';
1092
+                                        $tvDescription = (!empty($row['description'])) ? '<br /><span class="comment">'.$row['description'].'</span>' : '';
1093
+                                        $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '<br /><span class="comment inherited">('.$_lang['tmplvars_inherited'].')</span>' : '';
1094
+                                        $tvName = $modx->hasPermission('edit_template') ? '<br/><small class="protectedNode">[*'.$row['name'].'*]</small>' : '';
1095 1095
 
1096 1096
                                         $templateVariables .= '
1097 1097
                                         <tr>
1098
-                                            <td><span class="warning">' . $row['caption'] . $tvName . '</span>' . $tvDescription . $tvInherited . '</td>
1099
-                                            <td><div style="position:relative;' . ($row['type'] == 'date' ? '' : '') . '">' . renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray) . '</div></td>
1098
+                                            <td><span class="warning">' . $row['caption'].$tvName.'</span>'.$tvDescription.$tvInherited.'</td>
1099
+                                            <td><div style="position:relative;' . ($row['type'] == 'date' ? '' : '').'">'.renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray).'</div></td>
1100 1100
                                         </tr>';
1101 1101
 
1102 1102
                                         $tab = $row['category_id'];
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
 								<?php
1192 1192
 
1193
-								if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) {
1193
+								if ($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) {
1194 1194
 									?>
1195 1195
 									<tr>
1196 1196
 										<td>
@@ -1213,13 +1213,13 @@  discard block
 block discarded – undo
1213 1213
 										<td>
1214 1214
 											<select name="contentType" class="inputBox" onchange="documentDirty=true;">
1215 1215
 												<?php
1216
-												if(!$content['contentType']) {
1216
+												if (!$content['contentType']) {
1217 1217
 													$content['contentType'] = 'text/html';
1218 1218
 												}
1219 1219
 												$custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml");
1220 1220
 												$ct = explode(",", $custom_contenttype);
1221
-												for($i = 0; $i < count($ct); $i++) {
1222
-													echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n";
1221
+												for ($i = 0; $i < count($ct); $i++) {
1222
+													echo "\t\t\t\t\t".'<option value="'.$ct[$i].'"'.($content['contentType'] == $ct[$i] ? ' selected="selected"' : '').'>'.$ct[$i]."</option>\n";
1223 1223
 												}
1224 1224
 												?>
1225 1225
 											</select>
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 									</tr>
1246 1246
 									<?php
1247 1247
 								} else {
1248
-									if($content['type'] != 'reference' && $modx->manager->action != '72') {
1248
+									if ($content['type'] != 'reference' && $modx->manager->action != '72') {
1249 1249
 										// non-admin managers creating or editing a document resource
1250 1250
 										?>
1251 1251
 										<input type="hidden" name="contentType" value="<?= (isset($content['contentType']) ? $content['contentType'] : "text/html") ?>" />
@@ -1345,15 +1345,15 @@  discard block
 block discarded – undo
1345 1345
 						<?php
1346 1346
 					/*******************************
1347 1347
 					 * Document Access Permissions */
1348
-					if($use_udperms == 1) {
1348
+					if ($use_udperms == 1) {
1349 1349
 						$groupsarray = array();
1350 1350
 						$sql = '';
1351 1351
 
1352 1352
 						$documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']));
1353
-						if($documentId > 0) {
1353
+						if ($documentId > 0) {
1354 1354
 							// Load up, the permissions from the parent (if new document) or existing document
1355 1355
 							$rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'");
1356
-							while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1356
+							while ($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'].','.$currentgroup['id'];
1357 1357
 
1358 1358
 							// Load up the current permissions and names
1359 1359
 							$vs = array(
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
 						}
1370 1370
 
1371 1371
 						// retain selected doc groups between post
1372
-						if(isset($_POST['docgroups'])) {
1372
+						if (isset($_POST['docgroups'])) {
1373 1373
 							$groupsarray = array_merge($groupsarray, $_POST['docgroups']);
1374 1374
 						}
1375 1375
 
@@ -1388,26 +1388,26 @@  discard block
 block discarded – undo
1388 1388
 						$permissions_no = 0; // count permissions the current mgr user doesn't have
1389 1389
 
1390 1390
 						// Loop through the permissions list
1391
-						while($row = $modx->db->getRow($rs)) {
1391
+						while ($row = $modx->db->getRow($rs)) {
1392 1392
 
1393 1393
 							// Create an inputValue pair (group ID and group link (if it exists))
1394
-							$inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new');
1395
-							$inputId = 'group-' . $row['id'];
1394
+							$inputValue = $row['id'].','.($row['link_id'] ? $row['link_id'] : 'new');
1395
+							$inputId = 'group-'.$row['id'];
1396 1396
 
1397 1397
 							$checked = in_array($inputValue, $groupsarray);
1398
-							if($checked) {
1398
+							if ($checked) {
1399 1399
 								$notPublic = true;
1400 1400
 							} // Mark as private access (either web or manager)
1401 1401
 
1402 1402
 							// Skip the access permission if the user doesn't have access...
1403
-							if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) {
1403
+							if ((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) {
1404 1404
 								continue;
1405 1405
 							}
1406 1406
 
1407 1407
 							// Setup attributes for this Input box
1408 1408
 							$inputAttributes['id'] = $inputId;
1409 1409
 							$inputAttributes['value'] = $inputValue;
1410
-							if($checked) {
1410
+							if ($checked) {
1411 1411
 								$inputAttributes['checked'] = 'checked';
1412 1412
 							} else {
1413 1413
 								unset($inputAttributes['checked']);
@@ -1415,10 +1415,10 @@  discard block
 block discarded – undo
1415 1415
 
1416 1416
 							// Create attribute string list
1417 1417
 							$inputString = array();
1418
-							foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"';
1418
+							foreach ($inputAttributes as $k => $v) $inputString[] = $k.'="'.$v.'"';
1419 1419
 
1420 1420
 							// Make the <input> HTML
1421
-							$inputHTML = '<input ' . implode(' ', $inputString) . ' />';
1421
+							$inputHTML = '<input '.implode(' ', $inputString).' />';
1422 1422
 
1423 1423
 							// does user have this permission?
1424 1424
 							$from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg";
@@ -1429,23 +1429,23 @@  discard block
 block discarded – undo
1429 1429
 							$where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs);
1430 1430
 							$rsp = $modx->db->select('COUNT(mg.id)', $from, $where);
1431 1431
 							$count = $modx->db->getValue($rsp);
1432
-							if($count > 0) {
1432
+							if ($count > 0) {
1433 1433
 								++$permissions_yes;
1434 1434
 							} else {
1435 1435
 								++$permissions_no;
1436 1436
 							}
1437
-							$permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>';
1437
+							$permissions[] = "\t\t".'<li>'.$inputHTML.'<label for="'.$inputId.'">'.$row['name'].'</label></li>';
1438 1438
 						}
1439 1439
 						// if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public
1440
-						if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) {
1440
+						if ($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) {
1441 1441
 							$permissions = array();
1442 1442
 						}
1443 1443
 
1444 1444
 						// See if the Access Permissions section is worth displaying...
1445
-						if(!empty($permissions)) {
1445
+						if (!empty($permissions)) {
1446 1446
 							// Add the "All Document Groups" item if we have rights in both contexts
1447
-							if($isManager && $isWeb) {
1448
-								array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>');
1447
+							if ($isManager && $isWeb) {
1448
+								array_unshift($permissions, "\t\t".'<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"'.(!$notPublic ? ' checked="checked"' : '').' onclick="makePublic(true);" /><label for="groupall" class="warning">'.$_lang['all_doc_groups'].'</label></li>');
1449 1449
 							}
1450 1450
 							// Output the permissions list...
1451 1451
 							?>
@@ -1478,12 +1478,12 @@  discard block
 block discarded – undo
1478 1478
 								</script>
1479 1479
 								<p><?= $_lang['access_permissions_docs_message'] ?></p>
1480 1480
 								<ul>
1481
-									<?= implode("\n", $permissions) . "\n" ?>
1481
+									<?= implode("\n", $permissions)."\n" ?>
1482 1482
 								</ul>
1483 1483
 							</div><!--div class="tab-page" id="tabAccess"-->
1484 1484
 							<?php
1485 1485
 						} // !empty($permissions)
1486
-						elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) {
1486
+						elseif ($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) {
1487 1487
 							?>
1488 1488
 							<p><?= $_lang["access_permissions_docs_collision"] ?></p>
1489 1489
 							<?php
@@ -1503,7 +1503,7 @@  discard block
 block discarded – undo
1503 1503
 						'template' => $content['template']
1504 1504
 					));
1505 1505
 
1506
-					if(is_array($evtOut)) {
1506
+					if (is_array($evtOut)) {
1507 1507
 						echo implode('', $evtOut);
1508 1508
 					}
1509 1509
 					?>
@@ -1516,16 +1516,16 @@  discard block
 block discarded – undo
1516 1516
 		storeCurTemplate();
1517 1517
 	</script>
1518 1518
 <?php
1519
-if(($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) {
1520
-	if(is_array($richtexteditorIds)) {
1521
-		foreach($richtexteditorIds as $editor => $elements) {
1519
+if (($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) {
1520
+	if (is_array($richtexteditorIds)) {
1521
+		foreach ($richtexteditorIds as $editor => $elements) {
1522 1522
 			// invoke OnRichTextEditorInit event
1523 1523
 			$evtOut = $modx->invokeEvent('OnRichTextEditorInit', array(
1524 1524
 				'editor' => $editor,
1525 1525
 				'elements' => $elements,
1526 1526
 				'options' => $richtexteditorOptions[$editor]
1527 1527
 			));
1528
-			if(is_array($evtOut)) {
1528
+			if (is_array($evtOut)) {
1529 1529
 				echo implode('', $evtOut);
1530 1530
 			}
1531 1531
 		}
@@ -1535,37 +1535,37 @@  discard block
 block discarded – undo
1535 1535
 /**
1536 1536
  * @return string
1537 1537
  */
1538
-function getDefaultTemplate() {
1538
+function getDefaultTemplate(){
1539 1539
 	$modx = evolutionCMS();
1540 1540
 
1541 1541
     $default_template = '';
1542
-	switch($modx->config['auto_template_logic']) {
1542
+	switch ($modx->config['auto_template_logic']) {
1543 1543
 		case 'sibling':
1544
-			if(!isset($_GET['pid']) || empty($_GET['pid'])) {
1544
+			if (!isset($_GET['pid']) || empty($_GET['pid'])) {
1545 1545
 				$site_start = $modx->config['site_start'];
1546 1546
 				$where = "sc.isfolder=0 AND sc.id!='{$site_start}'";
1547 1547
 				$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1);
1548
-				if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1548
+				if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1549 1549
 					$default_template = $sibl[0]['template'];
1550 1550
 				}
1551 1551
 			} else {
1552 1552
 				$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1553
-				if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1553
+				if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1554 1554
 					$default_template = $sibl[0]['template'];
1555 1555
 				} else {
1556 1556
 					$sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1);
1557
-					if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1557
+					if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') {
1558 1558
 						$default_template = $sibl[0]['template'];
1559 1559
 					}
1560 1560
 				}
1561 1561
 			}
1562
-			if(isset($default_template)) {
1562
+			if (isset($default_template)) {
1563 1563
 				break;
1564 1564
 			} // If $default_template could not be determined, fall back / through to "parent"-mode
1565 1565
 		case 'parent':
1566
-			if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) {
1566
+			if (isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) {
1567 1567
 				$parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template');
1568
-				if(isset($parent['template'])) {
1568
+				if (isset($parent['template'])) {
1569 1569
 					$default_template = $parent['template'];
1570 1570
 				}
1571 1571
 			}
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -478,7 +478,8 @@  discard block
 block discarded – undo
478 478
 			return s;
479 479
 		}
480 480
 
481
-		<?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?>
481
+		<?php if ($content['type'] == 'reference' || $modx->manager->action == '72') {
482
+// Web Link specific ?>
482 483
 		var lastImageCtrl;
483 484
 		var lastFileCtrl;
484 485
 
@@ -694,7 +695,8 @@  discard block
 block discarded – undo
694 695
 									</td>
695 696
 								</tr>
696 697
 
697
-								<?php if($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?>
698
+								<?php if($content['type'] == 'reference' || $modx->manager->action == '72') {
699
+// Web Link specific ?>
698 700
 
699 701
 									<tr>
700 702
 										<td><span class="warning"><?= $_lang['weblink'] ?></span>
@@ -1353,7 +1355,9 @@  discard block
 block discarded – undo
1353 1355
 						if($documentId > 0) {
1354 1356
 							// Load up, the permissions from the parent (if new document) or existing document
1355 1357
 							$rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'");
1356
-							while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1358
+							while($currentgroup = $modx->db->getRow($rs)) {
1359
+							    $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1360
+							}
1357 1361
 
1358 1362
 							// Load up the current permissions and names
1359 1363
 							$vs = array(
@@ -1415,7 +1419,9 @@  discard block
 block discarded – undo
1415 1419
 
1416 1420
 							// Create attribute string list
1417 1421
 							$inputString = array();
1418
-							foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"';
1422
+							foreach($inputAttributes as $k => $v) {
1423
+							    $inputString[] = $k . '="' . $v . '"';
1424
+							}
1419 1425
 
1420 1426
 							// Make the <input> HTML
1421 1427
 							$inputHTML = '<input ' . implode(' ', $inputString) . ' />';
@@ -1535,7 +1541,8 @@  discard block
 block discarded – undo
1535 1541
 /**
1536 1542
  * @return string
1537 1543
  */
1538
-function getDefaultTemplate() {
1544
+function getDefaultTemplate()
1545
+{
1539 1546
 	$modx = evolutionCMS();
1540 1547
 
1541 1548
     $default_template = '';
Please login to merge, or discard this patch.