Completed
Pull Request — develop (#725)
by Agel_Nash
08:07
created
manager/includes/manager.lockout.inc.php 1 patch
Braces   +8 added lines, -13 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 
6
-if($modx->getManagerApi()->action!='8' && isset($_SESSION['mgrValidated'])){
6
+if($modx->getManagerApi()->action!='8' && isset($_SESSION['mgrValidated'])) {
7 7
 
8 8
     $homeurl = $modx->makeUrl($manager_login_startup>0 ? $manager_login_startup:$site_start);
9 9
     $logouturl = MODX_MANAGER_URL.'index.php?a=8';
@@ -35,8 +35,7 @@  discard block
 block discarded – undo
35 35
     	if(substr($target,0,6)==='@CHUNK') {
36 36
     		$target = trim(substr($target,7));
37 37
     		$lockout_tpl = $modx->getChunk($target);
38
-    	}
39
-    	elseif(substr($target,0,5)==='@FILE') {
38
+    	} elseif(substr($target,0,5)==='@FILE') {
40 39
     		$target = trim(substr($target,6));
41 40
     		$lockout_tpl = file_get_contents($target);
42 41
     	}
@@ -44,24 +43,20 @@  discard block
 block discarded – undo
44 43
     	$chunk = $modx->getChunk($target);
45 44
     	if($chunk!==false && !empty($chunk)) {
46 45
     		$lockout_tpl = $chunk;
47
-    	}
48
-    	elseif(is_file(MODX_BASE_PATH . $target)) {
46
+    	} elseif(is_file(MODX_BASE_PATH . $target)) {
49 47
     		$target = MODX_BASE_PATH . $target;
50 48
     		$lockout_tpl = file_get_contents($target);
51
-    	}
52
-    	elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl')) {
49
+    	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl')) {
53 50
     		$target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl';
54 51
     		$lockout_tpl = file_get_contents($target);
55
-    	}
56
-	elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl')) {
52
+    	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl')) {
57 53
 		$target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl';
58 54
 		$login_tpl = file_get_contents($target);
59
-	}
60
-    	elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html')) { // ClipperCMS compatible
55
+	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html')) {
56
+// ClipperCMS compatible
61 57
     		$target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html';
62 58
     		$lockout_tpl = file_get_contents($target);
63
-    	}
64
-    	else {
59
+    	} else {
65 60
     		$target = MODX_MANAGER_PATH . 'media/style/common/manager.lockout.tpl';
66 61
     		$lockout_tpl = file_get_contents($target);
67 62
     	}
Please login to merge, or discard this patch.
manager/includes/config_check.inc.php 1 patch
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 $warningspresent = 0;
20 20
 
21 21
 $sysfiles_check = $modx->getManagerApi()->checkSystemChecksum();
22
-if ($sysfiles_check!=='0'){
22
+if ($sysfiles_check!=='0') {
23 23
       $warningspresent = 1;
24 24
       $warnings[] = array($_lang['configcheck_sysfiles_mod']);
25 25
 }
26 26
 
27
-if (is_writable("includes/config.inc.php")){
27
+if (is_writable("includes/config.inc.php")) {
28 28
     // Warn if world writable
29 29
     if(@fileperms('includes/config.inc.php') & 0x0002) {
30 30
       $warningspresent = 1;
@@ -120,7 +120,8 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * @return bool
122 122
      */
123
-    function checkSiteCache() {
123
+    function checkSiteCache()
124
+    {
124 125
         $modx = evolutionCMS();
125 126
         $checked= true;
126 127
         if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) {
@@ -159,26 +160,36 @@  discard block
 block discarded – undo
159 160
 
160 161
 if ($warningspresent==1) {
161 162
 
162
-if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3';
163
+if(!isset($modx->config['send_errormail'])) {
164
+    $modx->config['send_errormail']='3';
165
+}
163 166
 $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>";
164 167
 
165 168
 for ($i=0;$i<count($warnings);$i++) {
166 169
     switch ($warnings[$i][0]) {
167 170
         case $_lang['configcheck_configinc'];
168 171
             $warnings[$i][1] = $_lang['configcheck_configinc_msg'];
169
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
172
+            if(!$_SESSION["mgrConfigCheck"]) {
173
+                $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
174
+            }
170 175
             break;
171 176
         case $_lang['configcheck_installer'] :
172 177
             $warnings[$i][1] = $_lang['configcheck_installer_msg'];
173
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
178
+            if(!$_SESSION["mgrConfigCheck"]) {
179
+                $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
180
+            }
174 181
             break;
175 182
         case $_lang['configcheck_cache'] :
176 183
             $warnings[$i][1] = $_lang['configcheck_cache_msg'];
177
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
184
+            if(!$_SESSION["mgrConfigCheck"]) {
185
+                $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
186
+            }
178 187
             break;
179 188
         case $_lang['configcheck_images'] :
180 189
             $warnings[$i][1] = $_lang['configcheck_images_msg'];
181
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
190
+            if(!$_SESSION["mgrConfigCheck"]) {
191
+                $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
192
+            }
182 193
             break;
183 194
         case $_lang['configcheck_sysfiles_mod']:
184 195
             $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"];
@@ -186,7 +197,9 @@  discard block
 block discarded – undo
186 197
 			if($modx->hasPermission('settings')) {
187 198
 				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>';
188 199
 			}
189
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
200
+            if(!$_SESSION["mgrConfigCheck"]) {
201
+                $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
202
+            }
190 203
             break;
191 204
         case $_lang['configcheck_lang_difference'] :
192 205
             $warnings[$i][1] = $_lang['configcheck_lang_difference_msg'];
Please login to merge, or discard this patch.
manager/includes/src/Legacy/mgrResources.php 1 patch
Braces   +23 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php namespace EvolutionCMS\Legacy;
2 2
 
3
-class mgrResources {
3
+class mgrResources
4
+{
4 5
     /**
5 6
      * @var array
6 7
      */
@@ -21,7 +22,8 @@  discard block
 block discarded – undo
21 22
     /**
22 23
      * mgrResources constructor.
23 24
      */
24
-    public function __construct() {
25
+    public function __construct()
26
+    {
25 27
         $this->setTypes();
26 28
         $this->queryItemsFromDB();
27 29
         $this->prepareCategoryArrays();
@@ -30,7 +32,8 @@  discard block
 block discarded – undo
30 32
     /**
31 33
      * @return void
32 34
      */
33
-    public function setTypes() {
35
+    public function setTypes()
36
+    {
34 37
         global $_lang;
35 38
         $this->types['site_templates']    = array(
36 39
             'title'=>$_lang["manage_templates"],
@@ -68,7 +71,8 @@  discard block
 block discarded – undo
68 71
     /**
69 72
      * @return void
70 73
      */
71
-    public function queryItemsFromDB() {
74
+    public function queryItemsFromDB()
75
+    {
72 76
         foreach($this->types as $resourceTable=>$type) {
73 77
             if($this->hasAnyPermissions($type['permissions'])) {
74 78
                 $nameField = isset($type['name']) ? $type['name'] : 'name';
@@ -81,11 +85,13 @@  discard block
 block discarded – undo
81 85
      * @param array $permissions
82 86
      * @return bool
83 87
      */
84
-    public function hasAnyPermissions($permissions) {
88
+    public function hasAnyPermissions($permissions)
89
+    {
85 90
         $modx = evolutionCMS();
86 91
 
87
-        foreach($permissions as $p)
88
-            if($modx->hasPermission($p)) return true;
92
+        foreach($permissions as $p) {
93
+                    if($modx->hasPermission($p)) return true;
94
+        }
89 95
 
90 96
         return false;
91 97
     }
@@ -95,7 +101,8 @@  discard block
 block discarded – undo
95 101
      * @param string $nameField
96 102
      * @return array|bool
97 103
      */
98
-    public function queryResources($resourceTable, $nameField = 'name') {
104
+    public function queryResources($resourceTable, $nameField = 'name')
105
+    {
99 106
         $modx = evolutionCMS(); global $_lang;
100 107
 
101 108
         $allowed = array(
@@ -112,8 +119,9 @@  discard block
 block discarded – undo
112 119
             $tvsql    = 'site_tmplvars.caption, ';
113 120
             $tvjoin   = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates'));
114 121
             $sttfield = 'IF(stt.templateid,1,0) AS reltpl,';
122
+        } else {
123
+            $sttfield = '';
115 124
         }
116
-        else $sttfield = '';
117 125
 
118 126
         $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : "";
119 127
 
@@ -126,7 +134,9 @@  discard block
 block discarded – undo
126 134
         );
127 135
         $limit = $modx->getDatabase()->getRecordCount($rs);
128 136
 
129
-        if($limit < 1) return false;
137
+        if($limit < 1) {
138
+            return false;
139
+        }
130 140
 
131 141
         $result = array();
132 142
         while ($row = $modx->getDatabase()->getRow($rs)) {
@@ -138,7 +148,8 @@  discard block
 block discarded – undo
138 148
     /**
139 149
      * @return void
140 150
      */
141
-    public function prepareCategoryArrays() {
151
+    public function prepareCategoryArrays()
152
+    {
142 153
         foreach($this->items as $type=>$items) {
143 154
             foreach((array)$items as $item) {
144 155
                 $catid = $item['catid'] ? $item['catid'] : 0;
@@ -154,7 +165,7 @@  discard block
 block discarded – undo
154 165
 
155 166
         // Now sort by name
156 167
         foreach($this->itemsPerCategory as $catid=>$items) {
157
-            usort($this->itemsPerCategory[$catid], function ($a, $b) {
168
+            usort($this->itemsPerCategory[$catid], function ($a, $b){
158 169
                 return strcasecmp($a['name'], $b['name']);
159 170
             });
160 171
         }
Please login to merge, or discard this patch.
manager/includes/src/Legacy/Modifiers.php 1 patch
Braces   +541 added lines, -281 removed lines patch added patch discarded remove patch
@@ -3,7 +3,8 @@  discard block
 block discarded – undo
3 3
 use EvolutionCMS\Interfaces\ModifiersInterface;
4 4
 use DataGrid;
5 5
 
6
-class Modifiers implements ModifiersInterface{
6
+class Modifiers implements ModifiersInterface
7
+{
7 8
     /**
8 9
      * @var array
9 10
      */
@@ -61,7 +62,9 @@  discard block
 block discarded – undo
61 62
     public function __construct()
62 63
     {
63 64
         $modx = evolutionCMS();
64
-        if (function_exists('mb_internal_encoding')) mb_internal_encoding($modx->config['modx_charset']);
65
+        if (function_exists('mb_internal_encoding')) {
66
+            mb_internal_encoding($modx->config['modx_charset']);
67
+        }
65 68
         $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';
66 69
     }
67 70
 
@@ -74,7 +77,9 @@  discard block
 block discarded – undo
74 77
     public function phxFilter($key,$value,$modifiers)
75 78
     {
76 79
         $modx = evolutionCMS();
77
-        if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value);
80
+        if(substr($modifiers,0,3)!=='id(') {
81
+            $value = $this->parseDocumentSource($value);
82
+        }
78 83
         $this->srcValue = $value;
79 84
         $modifiers = trim($modifiers);
80 85
         $modifiers = ':'.trim($modifiers,':');
@@ -97,13 +102,18 @@  discard block
 block discarded – undo
97 102
      * @param string $modifiers
98 103
      * @return bool|string
99 104
      */
100
-    public function _getDelim($mode,$modifiers) {
105
+    public function _getDelim($mode,$modifiers)
106
+    {
101 107
         $c = substr($modifiers,0,1);
102
-        if(!in_array($c, array('"', "'", '`')) ) return false;
108
+        if(!in_array($c, array('"', "'", '`')) ) {
109
+            return false;
110
+        }
103 111
 
104 112
         $modifiers = substr($modifiers,1);
105 113
         $closure = $mode=='(' ? "{$c})" : $c;
106
-        if(strpos($modifiers, $closure)===false) return false;
114
+        if(strpos($modifiers, $closure)===false) {
115
+            return false;
116
+        }
107 117
 
108 118
         return  $c;
109 119
     }
@@ -114,52 +124,65 @@  discard block
 block discarded – undo
114 124
      * @param string $modifiers
115 125
      * @return bool|string
116 126
      */
117
-    public function _getOpt($mode,$delim,$modifiers) {
127
+    public function _getOpt($mode,$delim,$modifiers)
128
+    {
118 129
         if($delim) {
119
-            if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
130
+            if($mode=='(') {
131
+                return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
132
+            }
120 133
 
121 134
             return substr($modifiers,1,strpos($modifiers,$delim,1)-1);
122
-        }
123
-        else {
124
-            if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') );
135
+        } else {
136
+            if($mode=='(') {
137
+                return substr($modifiers,0,strpos($modifiers, ')') );
138
+            }
125 139
 
126 140
             $chars = str_split($modifiers);
127 141
             $opt='';
128 142
             foreach($chars as $c) {
129
-                if($c==':' || $c==')') break;
143
+                if($c==':' || $c==')') {
144
+                    break;
145
+                }
130 146
                 $opt .=$c;
131 147
             }
132 148
             return $opt;
133 149
         }
134 150
     }
135
-    public function _getRemainModifiers($mode,$delim,$modifiers) {
151
+    public function _getRemainModifiers($mode,$delim,$modifiers)
152
+    {
136 153
         if($delim) {
137
-            if($mode=='(')
138
-                return $this->_fetchContent($modifiers, $delim . ')');
139
-            else {
154
+            if($mode=='(') {
155
+                            return $this->_fetchContent($modifiers, $delim . ')');
156
+            } else {
140 157
                 $modifiers = trim($modifiers);
141 158
                 $modifiers = substr($modifiers,1);
142 159
                 return $this->_fetchContent($modifiers, $delim);
143 160
             }
144
-        }
145
-        else {
146
-            if($mode=='(') return $this->_fetchContent($modifiers, ')');
161
+        } else {
162
+            if($mode=='(') {
163
+                return $this->_fetchContent($modifiers, ')');
164
+            }
147 165
             $chars = str_split($modifiers);
148 166
             foreach($chars as $c) {
149
-                if($c==':') return $modifiers;
150
-                else $modifiers = substr($modifiers,1);
167
+                if($c==':') {
168
+                    return $modifiers;
169
+                } else {
170
+                    $modifiers = substr($modifiers,1);
171
+                }
151 172
             }
152 173
             return $modifiers;
153 174
         }
154 175
     }
155 176
 
156
-    public function _fetchContent($string,$delim) {
177
+    public function _fetchContent($string,$delim)
178
+    {
157 179
         $len = strlen($delim);
158 180
         $string = $this->parseDocumentSource($string);
159 181
         return substr($string,strpos($string, $delim)+$len);
160 182
     }
161 183
 
162
-    public function splitEachModifiers($modifiers) {
184
+    public function splitEachModifiers($modifiers)
185
+    {
163 186
         $modx = evolutionCMS();
164 187
 
165 188
         $cmd = '';
@@ -170,11 +193,15 @@  discard block
 block discarded – undo
170 193
             $c = substr($modifiers,0,1);
171 194
             $modifiers = substr($modifiers,1);
172 195
 
173
-            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
196
+            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) {
197
+// :=, :!=, :<=, :>=, :!<=, :!>=
174 198
                 $c = substr($modifiers,strlen($match[1]),1);
175 199
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
176
-                if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1);
177
-                else         $modifiers = substr($modifiers,strlen($match[1]));
200
+                if($c==='(') {
201
+                    $modifiers = substr($modifiers,strlen($match[1])+1);
202
+                } else {
203
+                    $modifiers = substr($modifiers,strlen($match[1]));
204
+                }
178 205
 
179 206
                 $delim     = $this->_getDelim($c,$modifiers);
180 207
                 $opt       = $this->_getOpt($c,$delim,$modifiers);
@@ -182,13 +209,12 @@  discard block
 block discarded – undo
182 209
 
183 210
                 $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
184 211
                 $cmd = '';
185
-            }
186
-            elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
212
+            } elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) {
213
+// :+3, :-3, :*3 ...
187 214
                 $modifiers = substr($modifiers,strlen($match[0]));
188 215
                 $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]);
189 216
                 $cmd = '';
190
-            }
191
-            elseif($c==='(' || $c==='=') {
217
+            } elseif($c==='(' || $c==='=') {
192 218
                 $modifiers = $m1 = trim($modifiers);
193 219
                 $delim     = $this->_getDelim($c,$modifiers);
194 220
                 $opt       = $this->_getOpt($c,$delim,$modifiers);
@@ -198,29 +224,29 @@  discard block
 block discarded – undo
198 224
                 $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo);
199 225
 
200 226
                 $cmd = '';
201
-            }
202
-            elseif($c==':') {
227
+            } elseif($c==':') {
203 228
                 $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]";
204
-                if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
229
+                if($cmd!=='') {
230
+                    $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
231
+                }
205 232
 
206 233
                 $cmd = '';
207
-            }
208
-            elseif(trim($modifiers)=='' && trim($cmd)!=='') {
234
+            } elseif(trim($modifiers)=='' && trim($cmd)!=='') {
209 235
                 $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]";
210 236
                 $cmd .= $c;
211 237
                 $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
212 238
 
213 239
                 break;
214
-            }
215
-            else {
240
+            } else {
216 241
                 $cmd .= $c;
217 242
             }
218 243
         }
219 244
 
220
-        if(empty($result)) return array();
245
+        if(empty($result)) {
246
+            return array();
247
+        }
221 248
 
222
-        foreach($result as $i=>$a)
223
-        {
249
+        foreach($result as $i=>$a) {
224 250
             $a['opt'] = $this->parseDocumentSource($a['opt']);
225 251
             $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders);
226 252
         }
@@ -233,22 +259,23 @@  discard block
 block discarded – undo
233 259
         $modx = evolutionCMS();
234 260
         $lastKey = '';
235 261
         $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true)));
236
-        if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
237
-        if(empty($modifiers)) return '';
262
+        if(isset($this->tmpCache[$cacheKey])) {
263
+            return $this->tmpCache[$cacheKey];
264
+        }
265
+        if(empty($modifiers)) {
266
+            return '';
267
+        }
238 268
 
239
-        foreach($modifiers as $m)
240
-        {
269
+        foreach($modifiers as $m) {
241 270
             $lastKey = strtolower($m['cmd']);
242 271
         }
243 272
         $_ = explode(',',$this->condModifiers);
244
-        if(in_array($lastKey,$_))
245
-        {
273
+        if(in_array($lastKey,$_)) {
246 274
             $modifiers[] = array('cmd'=>'then','opt'=>'1');
247 275
             $modifiers[] = array('cmd'=>'else','opt'=>'0');
248 276
         }
249 277
 
250
-        foreach($modifiers as $i=>$a)
251
-        {
278
+        foreach($modifiers as $i=>$a) {
252 279
             $value = $this->Filter($key,$value, $a['cmd'], $a['opt']);
253 280
         }
254 281
         $this->tmpCache[$cacheKey] = $value;
@@ -260,25 +287,32 @@  discard block
 block discarded – undo
260 287
     {
261 288
         $modx = evolutionCMS();
262 289
 
263
-        if($key==='documentObject') $value = $modx->documentIdentifier;
290
+        if($key==='documentObject') {
291
+            $value = $modx->documentIdentifier;
292
+        }
264 293
         $cmd = $this->parseDocumentSource($cmd);
265
-        if(preg_match('@^[1-9][/0-9]*$@',$cmd))
266
-        {
267
-            if(strpos($cmd,'/')!==false)
268
-                $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
294
+        if(preg_match('@^[1-9][/0-9]*$@',$cmd)) {
295
+            if(strpos($cmd,'/')!==false) {
296
+                            $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
297
+            }
269 298
             $opt = $cmd;
270 299
             $cmd = 'id';
271 300
         }
272 301
 
273
-        if(isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
274
-        elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
275
-        else                                           $this->elmName = '';
302
+        if(isset($modx->snippetCache["phx:{$cmd}"])) {
303
+            $this->elmName = "phx:{$cmd}";
304
+        } elseif(isset($modx->chunkCache["phx:{$cmd}"])) {
305
+            $this->elmName = "phx:{$cmd}";
306
+        } else {
307
+            $this->elmName = '';
308
+        }
276 309
 
277 310
         $cmd = strtolower($cmd);
278
-        if($this->elmName!=='')
279
-            $value = $this->getValueFromElement($key, $value, $cmd, $opt);
280
-        else
281
-            $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
311
+        if($this->elmName!=='') {
312
+                    $value = $this->getValueFromElement($key, $value, $cmd, $opt);
313
+        } else {
314
+                    $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
315
+        }
282 316
 
283 317
         $value = str_replace('[+key+]', $key, $value);
284 318
 
@@ -287,29 +321,37 @@  discard block
 block discarded – undo
287 321
 
288 322
     public function isEmpty($cmd,$value)
289 323
     {
290
-        if($value!=='') return false;
324
+        if($value!=='') {
325
+            return false;
326
+        }
291 327
 
292 328
         $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
293
-        if(in_array($cmd,$_)) return false;
294
-        else                  return true;
329
+        if(in_array($cmd,$_)) {
330
+            return false;
331
+        } else {
332
+            return true;
333
+        }
295 334
     }
296 335
 
297 336
     public function getValueFromPreset($key, $value, $cmd, $opt)
298 337
     {
299 338
         $modx = evolutionCMS();
300 339
 
301
-        if($this->isEmpty($cmd,$value)) return '';
340
+        if($this->isEmpty($cmd,$value)) {
341
+            return '';
342
+        }
302 343
 
303 344
         $this->key = $key;
304 345
         $this->value  = $value;
305 346
         $this->opt    = $opt;
306 347
 
307
-        switch ($cmd)
308
-        {
348
+        switch ($cmd) {
309 349
             #####  Conditional Modifiers
310 350
             case 'input':
311 351
             case 'if':
312
-                if(!$opt) return $value;
352
+                if(!$opt) {
353
+                    return $value;
354
+                }
313 355
                 return $opt;
314 356
             case '=':
315 357
             case 'eq':
@@ -370,14 +412,24 @@  discard block
 block discarded – undo
370 412
             case 'file_exists':
371 413
             case 'is_readable':
372 414
             case 'is_writable':
373
-                if(!$opt) $path = $value;
374
-                else      $path = $opt;
375
-                if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path');
376
-                if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/');
415
+                if(!$opt) {
416
+                    $path = $value;
417
+                } else {
418
+                    $path = $opt;
419
+                }
420
+                if(strpos($path,MODX_MANAGER_PATH)!==false) {
421
+                    exit('Can not read core path');
422
+                }
423
+                if(strpos($path,$modx->config['base_path'])===false) {
424
+                    $path = ltrim($path,'/');
425
+                }
377 426
                 $this->condition[] = (int)($cmd($path)!==false);break;
378 427
             case 'is_image':
379
-                if(!$opt) $path = $value;
380
-                else      $path = $opt;
428
+                if(!$opt) {
429
+                    $path = $value;
430
+                } else {
431
+                    $path = $opt;
432
+                }
381 433
                 if(!is_file($path)) {$this->condition[]='0';break;}
382 434
                 $_ = getimagesize($path);
383 435
                 $this->condition[] = (int)($_[0]);break;
@@ -400,17 +452,23 @@  discard block
 block discarded – undo
400 452
             case 'this':
401 453
                 $conditional = implode(' ',$this->condition);
402 454
                 $isvalid = (int)(eval("return ({$conditional});"));
403
-                if ($isvalid) return $this->srcValue;
455
+                if ($isvalid) {
456
+                    return $this->srcValue;
457
+                }
404 458
                 return NULL;
405 459
             case 'then':
406 460
                 $conditional = implode(' ',$this->condition);
407 461
                 $isvalid = (int)eval("return ({$conditional});");
408
-                if ($isvalid)  return $opt;
462
+                if ($isvalid) {
463
+                    return $opt;
464
+                }
409 465
                 return null;
410 466
             case 'else':
411 467
                 $conditional = implode(' ',$this->condition);
412 468
                 $isvalid = (int)eval("return ({$conditional});");
413
-                if (!$isvalid) return $opt;
469
+                if (!$isvalid) {
470
+                    return $opt;
471
+                }
414 472
                 break;
415 473
             case 'select':
416 474
             case 'switch':
@@ -421,8 +479,11 @@  discard block
 block discarded – undo
421 479
                     $mi = explode('=',$raw[$m],2);
422 480
                     $map[$mi[0]] = $mi[1];
423 481
                 }
424
-                if(isset($map[$value])) return $map[$value];
425
-                else                    return '';
482
+                if(isset($map[$value])) {
483
+                    return $map[$value];
484
+                } else {
485
+                    return '';
486
+                }
426 487
             ##### End of Conditional Modifiers
427 488
 
428 489
             #####  Encode / Decode / Hash / Escape
@@ -448,24 +509,25 @@  discard block
 block discarded – undo
448 509
             case 'spam_protect':
449 510
                 return str_replace(array('@','.'),array('&#64;','&#46;'),$value);
450 511
             case 'strip':
451
-                if($opt==='') $opt = ' ';
512
+                if($opt==='') {
513
+                    $opt = ' ';
514
+                }
452 515
                 return preg_replace('/[\n\r\t\s]+/', $opt, $value);
453 516
             case 'strip_linefeeds':
454 517
                 return str_replace(array("\n","\r"), '', $value);
455 518
             case 'notags':
456 519
             case 'strip_tags':
457 520
             case 'remove_html':
458
-                if($opt!=='')
459
-                {
521
+                if($opt!=='') {
460 522
                     $param = array();
461
-                    foreach(explode(',',$opt) as $v)
462
-                    {
523
+                    foreach(explode(',',$opt) as $v) {
463 524
                         $v = trim($v,'</> ');
464 525
                         $param[] = "<{$v}>";
465 526
                     }
466 527
                     $params = implode(',',$param);
528
+                } else {
529
+                    $params = '';
467 530
                 }
468
-                else $params = '';
469 531
                 if(!strpos($params,'<br>')===false) {
470 532
                     $value = preg_replace('@(<br[ /]*>)\n@','$1',$value);
471 533
                     $value = preg_replace('@<br[ /]*>@',"\n",$value);
@@ -476,8 +538,11 @@  discard block
 block discarded – undo
476 538
             case 'encode_url':
477 539
                 return urlencode($value);
478 540
             case 'base64_decode':
479
-                if($opt!=='false') $opt = true;
480
-                else               $opt = false;
541
+                if($opt!=='false') {
542
+                    $opt = true;
543
+                } else {
544
+                    $opt = false;
545
+                }
481 546
                 return base64_decode($value,$opt);
482 547
             case 'encode_sha1': $cmd = 'sha1';
483 548
             case 'addslashes':
@@ -503,16 +568,19 @@  discard block
 block discarded – undo
503 568
                 return $this->strtoupper($value);
504 569
             case 'capitalize':
505 570
                 $_ = explode(' ',$value);
506
-                foreach($_ as $i=>$v)
507
-                {
571
+                foreach($_ as $i=>$v) {
508 572
                     $_[$i] = ucfirst($v);
509 573
                 }
510 574
                 return implode(' ',$_);
511 575
             case 'zenhan':
512
-                if(empty($opt)) $opt='VKas';
576
+                if(empty($opt)) {
577
+                    $opt='VKas';
578
+                }
513 579
                 return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
514 580
             case 'hanzen':
515
-                if(empty($opt)) $opt='VKAS';
581
+                if(empty($opt)) {
582
+                    $opt='VKAS';
583
+                }
516 584
                 return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
517 585
             case 'str_shuffle':
518 586
             case 'shuffle':
@@ -537,13 +605,18 @@  discard block
 block discarded – undo
537 605
                 $value = preg_replace('/\r/', '', $value);
538 606
                 return count(preg_split('/\n+/',$value));
539 607
             case 'strpos':
540
-                if($opt!=0&&empty($opt)) return $value;
608
+                if($opt!=0&&empty($opt)) {
609
+                    return $value;
610
+                }
541 611
                 return $this->strpos($value,$opt);
542 612
             case 'wordwrap':
543 613
                 // default: 70
544 614
                 $wrapat = (int)$opt > 0 ? (int)$opt : 70;
545
-                if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap');
546
-                else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
615
+                if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
616
+                    return $this->includeMdfFile('wordwrap');
617
+                } else {
618
+                    return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
619
+                }
547 620
             case 'wrap_text':
548 621
                 $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70;
549 622
                 if($modx->config['manager_language']==='japanese-utf8') {
@@ -559,30 +632,36 @@  discard block
 block discarded – undo
559 632
                         $value = $this->substr($value,$width);
560 633
                     }
561 634
                     return implode("\n",$chunk);
635
+                } else {
636
+                                    return wordwrap($value,$width,"\n",true);
562 637
                 }
563
-                else
564
-                    return wordwrap($value,$width,"\n",true);
565 638
             case 'substr':
566
-                if(empty($opt)) break;
639
+                if(empty($opt)) {
640
+                    break;
641
+                }
567 642
                 if(strpos($opt,',')!==false) {
568 643
                     list($b,$e) = explode(',',$opt,2);
569 644
                     return $this->substr($value,$b,(int)$e);
645
+                } else {
646
+                    return $this->substr($value,$opt);
570 647
                 }
571
-                else return $this->substr($value,$opt);
572 648
             case 'limit':
573 649
             case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html
574
-                if(strpos($opt,'+')!==false)
575
-                    list($len,$str) = explode('+',$opt,2);
576
-                else {
650
+                if(strpos($opt,'+')!==false) {
651
+                                    list($len,$str) = explode('+',$opt,2);
652
+                } else {
577 653
                     $len = $opt;
578 654
                     $str = '';
579 655
                 }
580
-                if($len==='') $len = 100;
581
-                if(abs($len) > $this->strlen($value)) $str ='';
656
+                if($len==='') {
657
+                    $len = 100;
658
+                }
659
+                if(abs($len) > $this->strlen($value)) {
660
+                    $str ='';
661
+                }
582 662
                 if(preg_match('/^[1-9][0-9]*$/',$len)) {
583 663
                     return $this->substr($value,0,$len) . $str;
584
-                }
585
-                elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
664
+                } elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
586 665
                     return $str . $this->substr($value,$len);
587 666
                 }
588 667
                 break;
@@ -592,18 +671,30 @@  discard block
 block discarded – undo
592 671
                 return $this->includeMdfFile('summary');
593 672
             case 'replace':
594 673
             case 'str_replace':
595
-                if(empty($opt) || strpos($opt,',')===false) break;
596
-                if    (substr_count($opt, ',') ==1) $delim = ',';
597
-                elseif(substr_count($opt, '|') ==1) $delim = '|';
598
-                elseif(substr_count($opt, '=>')==1) $delim = '=>';
599
-                elseif(substr_count($opt, '/') ==1) $delim = '/';
600
-                else break;
674
+                if(empty($opt) || strpos($opt,',')===false) {
675
+                    break;
676
+                }
677
+                if    (substr_count($opt, ',') ==1) {
678
+                    $delim = ',';
679
+                } elseif(substr_count($opt, '|') ==1) {
680
+                    $delim = '|';
681
+                } elseif(substr_count($opt, '=>')==1) {
682
+                    $delim = '=>';
683
+                } elseif(substr_count($opt, '/') ==1) {
684
+                    $delim = '/';
685
+                } else {
686
+                    break;
687
+                }
601 688
                 list($s,$r) = explode($delim,$opt);
602
-                if($value!=='') return str_replace($s,$r,$value);
689
+                if($value!=='') {
690
+                    return str_replace($s,$r,$value);
691
+                }
603 692
                 break;
604 693
             case 'replace_to':
605 694
             case 'tpl':
606
-                if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
695
+                if($value!=='') {
696
+                    return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
697
+                }
607 698
                 break;
608 699
             case 'eachtpl':
609 700
                 $value = explode('||',$value);
@@ -614,59 +705,83 @@  discard block
 block discarded – undo
614 705
                 return implode("\n", $_);
615 706
             case 'array_pop':
616 707
             case 'array_shift':
617
-                if(strpos($value,'||')!==false) $delim = '||';
618
-                else                            $delim = ',';
708
+                if(strpos($value,'||')!==false) {
709
+                    $delim = '||';
710
+                } else {
711
+                    $delim = ',';
712
+                }
619 713
                 return $cmd(explode($delim,$value));
620 714
             case 'preg_replace':
621 715
             case 'regex_replace':
622
-                if(empty($opt) || strpos($opt,',')===false) break;
716
+                if(empty($opt) || strpos($opt,',')===false) {
717
+                    break;
718
+                }
623 719
                 list($s,$r) = explode(',',$opt,2);
624
-                if($value!=='') return preg_replace($s,$r,$value);
720
+                if($value!=='') {
721
+                    return preg_replace($s,$r,$value);
722
+                }
625 723
                 break;
626 724
             case 'cat':
627 725
             case 'concatenate':
628 726
             case '.':
629
-                if($value!=='') return $value . $opt;
727
+                if($value!=='') {
728
+                    return $value . $opt;
729
+                }
630 730
                 break;
631 731
             case 'sprintf':
632 732
             case 'string_format':
633
-                if($value!=='') return sprintf($opt,$value);
733
+                if($value!=='') {
734
+                    return sprintf($opt,$value);
735
+                }
634 736
                 break;
635 737
             case 'number_format':
636
-                if($opt=='') $opt = 0;
738
+                if($opt=='') {
739
+                    $opt = 0;
740
+                }
637 741
                 return number_format($value,$opt);
638 742
             case 'money_format':
639 743
                 setlocale(LC_MONETARY,setlocale(LC_TIME,0));
640
-                if($value!=='') return money_format($opt,(double)$value);
744
+                if($value!=='') {
745
+                    return money_format($opt,(double)$value);
746
+                }
641 747
                 break;
642 748
             case 'tobool':
643 749
                 return boolval($value);
644 750
             case 'nl2lf':
645
-                if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value);
751
+                if($value!=='') {
752
+                    return str_replace(array("\r\n","\n", "\r"), '\n', $value);
753
+                }
646 754
                 break;
647 755
             case 'br2nl':
648 756
                 return preg_replace('@<br[\s/]*>@i', "\n", $value);
649 757
             case 'nl2br':
650
-                if (version_compare(PHP_VERSION, '5.3.0', '<'))
651
-                    return nl2br($value);
652
-                if($opt!=='')
653
-                {
758
+                if (version_compare(PHP_VERSION, '5.3.0', '<')) {
759
+                                    return nl2br($value);
760
+                }
761
+                if($opt!=='') {
654 762
                     $opt = trim($opt);
655 763
                     $opt = strtolower($opt);
656
-                    if($opt==='false') $opt = false;
657
-                    elseif($opt==='0') $opt = false;
658
-                    else               $opt = true;
764
+                    if($opt==='false') {
765
+                        $opt = false;
766
+                    } elseif($opt==='0') {
767
+                        $opt = false;
768
+                    } else {
769
+                        $opt = true;
770
+                    }
771
+                } elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') {
772
+                                    $opt = false;
773
+                } else {
774
+                    $opt = true;
659 775
                 }
660
-                elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html')
661
-                    $opt = false;
662
-                else                   $opt = true;
663 776
                 return nl2br($value,$opt);
664 777
             case 'ltrim':
665 778
             case 'rtrim':
666 779
             case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html
667
-                if($opt==='')
668
-                    return $cmd($value);
669
-                else return $cmd($value,$opt);
780
+                if($opt==='') {
781
+                                    return $cmd($value);
782
+                } else {
783
+                    return $cmd($value,$opt);
784
+                }
670 785
             // These are all straight wrappers for PHP functions
671 786
             case 'ucfirst':
672 787
             case 'lcfirst':
@@ -677,15 +792,24 @@  discard block
 block discarded – undo
677 792
             case 'strftime':
678 793
             case 'date':
679 794
             case 'dateformat':
680
-                if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
681
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
682
-                if(strpos($opt,'%')!==false)
683
-                    return strftime($opt,0+$value);
684
-                else
685
-                    return date($opt,0+$value);
795
+                if(empty($opt)) {
796
+                    $opt = $modx->toDateFormat(null, 'formatOnly');
797
+                }
798
+                if(!preg_match('@^[0-9]+$@',$value)) {
799
+                    $value = strtotime($value);
800
+                }
801
+                if(strpos($opt,'%')!==false) {
802
+                                    return strftime($opt,0+$value);
803
+                } else {
804
+                                    return date($opt,0+$value);
805
+                }
686 806
             case 'time':
687
-                if(empty($opt)) $opt = '%H:%M';
688
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
807
+                if(empty($opt)) {
808
+                    $opt = '%H:%M';
809
+                }
810
+                if(!preg_match('@^[0-9]+$@',$value)) {
811
+                    $value = strtotime($value);
812
+                }
689 813
                 return strftime($opt,0+$value);
690 814
             case 'strtotime':
691 815
                 return strtotime($value);
@@ -695,7 +819,9 @@  discard block
 block discarded – undo
695 819
             case 'tofloat':
696 820
                 return floatval($value);
697 821
             case 'round':
698
-                if(!$opt) $opt = 0;
822
+                if(!$opt) {
823
+                    $opt = 0;
824
+                }
699 825
                 return $cmd($value,$opt);
700 826
             case 'max':
701 827
             case 'min':
@@ -707,28 +833,42 @@  discard block
 block discarded – undo
707 833
             case 'math':
708 834
             case 'calc':
709 835
                 $value = (int)$value;
710
-                if(empty($value)) $value = '0';
836
+                if(empty($value)) {
837
+                    $value = '0';
838
+                }
711 839
                 $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt);
712 840
                 $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter);
713
-                if(strpos($filter,'?')===false) $filter = "?{$filter}";
841
+                if(strpos($filter,'?')===false) {
842
+                    $filter = "?{$filter}";
843
+                }
714 844
                 $filter = str_replace('?',$value,$filter);
715 845
                 return eval("return {$filter};");
716 846
             case 'count':
717
-                if($value=='') return 0;
847
+                if($value=='') {
848
+                    return 0;
849
+                }
718 850
                 $value = explode(',',$value);
719 851
                 return count($value);
720 852
             case 'sort':
721 853
             case 'rsort':
722
-                if(strpos($value,"\n")!==false) $delim="\n";
723
-                else $delim = ',';
854
+                if(strpos($value,"\n")!==false) {
855
+                    $delim="\n";
856
+                } else {
857
+                    $delim = ',';
858
+                }
724 859
                 $swap = explode($delim,$value);
725
-                if(!$opt) $opt = SORT_REGULAR;
726
-                else      $opt = constant($opt);
860
+                if(!$opt) {
861
+                    $opt = SORT_REGULAR;
862
+                } else {
863
+                    $opt = constant($opt);
864
+                }
727 865
                 $cmd($swap,$opt);
728 866
                 return implode($delim,$swap);
729 867
             #####  Resource fields
730 868
             case 'id':
731
-                if($opt) return $this->getDocumentObject($opt,$key);
869
+                if($opt) {
870
+                    return $this->getDocumentObject($opt,$key);
871
+                }
732 872
                 break;
733 873
             case 'type':
734 874
             case 'contenttype':
@@ -765,7 +905,9 @@  discard block
 block discarded – undo
765 905
             case 'privatemgr':
766 906
             case 'content_dispo':
767 907
             case 'hidemenu':
768
-                if($cmd==='contenttype') $cmd = 'contentType';
908
+                if($cmd==='contenttype') {
909
+                    $cmd = 'contentType';
910
+                }
769 911
                 return $this->getDocumentObject($value,$cmd);
770 912
             case 'title':
771 913
                 $pagetitle = $this->getDocumentObject($value,'pagetitle');
@@ -780,13 +922,20 @@  discard block
 block discarded – undo
780 922
                 $templateName = $modx->getDatabase()->getValue($rs);
781 923
                 return !$templateName ? '(blank)' : $templateName;
782 924
             case 'getfield':
783
-                if(!$opt) $opt = 'content';
925
+                if(!$opt) {
926
+                    $opt = 'content';
927
+                }
784 928
                 return $modx->getField($opt,$value);
785 929
             case 'children':
786 930
             case 'childids':
787
-                if($value=='') $value = 0; // 値がない場合はルートと見なす
931
+                if($value=='') {
932
+                    $value = 0;
933
+                }
934
+                // 値がない場合はルートと見なす
788 935
                 $published = 1;
789
-                if($opt=='') $opt = 'page';
936
+                if($opt=='') {
937
+                    $opt = 'page';
938
+                }
790 939
                 $_ = explode(',',$opt);
791 940
                 $where = array();
792 941
                 foreach($_ as $opt) {
@@ -802,29 +951,43 @@  discard block
 block discarded – undo
802 951
                 $where = implode(' AND ', $where);
803 952
                 $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where);
804 953
                 $result = array();
805
-                foreach((array)$children as $child){
954
+                foreach((array)$children as $child) {
806 955
                     $result[] = $child['id'];
807 956
                 }
808 957
                 return implode(',', $result);
809 958
             case 'fullurl':
810
-                if(!is_numeric($value)) return $value;
959
+                if(!is_numeric($value)) {
960
+                    return $value;
961
+                }
811 962
                 return $modx->makeUrl($value);
812 963
             case 'makeurl':
813
-                if(!is_numeric($value)) return $value;
814
-                if(!$opt) $opt = 'full';
964
+                if(!is_numeric($value)) {
965
+                    return $value;
966
+                }
967
+                if(!$opt) {
968
+                    $opt = 'full';
969
+                }
815 970
                 return $modx->makeUrl($value,'','',$opt);
816 971
 
817 972
             #####  File system
818 973
             case 'getimageinfo':
819 974
             case 'imageinfo':
820
-                if(!is_file($value)) return '';
975
+                if(!is_file($value)) {
976
+                    return '';
977
+                }
821 978
                 $_ = getimagesize($value);
822
-                if(!$_[0]) return '';
979
+                if(!$_[0]) {
980
+                    return '';
981
+                }
823 982
                 $info['width']  = $_[0];
824 983
                 $info['height'] = $_[1];
825
-                if    ($_[0] > $_[1]) $info['aspect'] = 'landscape';
826
-                elseif($_[0] < $_[1]) $info['aspect'] = 'portrait';
827
-                else                  $info['aspect'] = 'square';
984
+                if    ($_[0] > $_[1]) {
985
+                    $info['aspect'] = 'landscape';
986
+                } elseif($_[0] < $_[1]) {
987
+                    $info['aspect'] = 'portrait';
988
+                } else {
989
+                    $info['aspect'] = 'square';
990
+                }
828 991
                 switch($_[2]) {
829 992
                     case IMAGETYPE_GIF  : $info['type'] = 'gif'; break;
830 993
                     case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break;
@@ -843,33 +1006,47 @@  discard block
 block discarded – undo
843 1006
 
844 1007
             case 'file_get_contents':
845 1008
             case 'readfile':
846
-                if(!is_file($value)) return $value;
1009
+                if(!is_file($value)) {
1010
+                    return $value;
1011
+                }
847 1012
                 $value = realpath($value);
848
-                if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file');
1013
+                if(strpos($value,MODX_MANAGER_PATH)!==false) {
1014
+                    exit('Can not read core file');
1015
+                }
849 1016
                 $ext = strtolower(substr($value,-4));
850
-                if($ext==='.php') exit('Can not read php file');
851
-                if($ext==='.cgi') exit('Can not read cgi file');
1017
+                if($ext==='.php') {
1018
+                    exit('Can not read php file');
1019
+                }
1020
+                if($ext==='.cgi') {
1021
+                    exit('Can not read cgi file');
1022
+                }
852 1023
                 return file_get_contents($value);
853 1024
             case 'filesize':
854
-                if($value == '') return '';
1025
+                if($value == '') {
1026
+                    return '';
1027
+                }
855 1028
                 $filename = $value;
856 1029
 
857 1030
                 $site_url = $modx->config['site_url'];
858
-                if(strpos($filename,$site_url) === 0)
859
-                    $filename = substr($filename,0,strlen($site_url));
1031
+                if(strpos($filename,$site_url) === 0) {
1032
+                                    $filename = substr($filename,0,strlen($site_url));
1033
+                }
860 1034
                 $filename = trim($filename,'/');
861 1035
 
862 1036
                 $opt = trim($opt,'/');
863
-                if($opt!=='') $opt .= '/';
1037
+                if($opt!=='') {
1038
+                    $opt .= '/';
1039
+                }
864 1040
 
865 1041
                 $filename = MODX_BASE_PATH.$opt.$filename;
866 1042
 
867
-                if(is_file($filename)){
1043
+                if(is_file($filename)) {
868 1044
                     clearstatcache();
869 1045
                     $size = filesize($filename);
870 1046
                     return $size;
1047
+                } else {
1048
+                    return '';
871 1049
                 }
872
-                else return '';
873 1050
             #####  User info
874 1051
             case 'username':
875 1052
             case 'fullname':
@@ -897,32 +1074,47 @@  discard block
 block discarded – undo
897 1074
                 $this->opt = $cmd;
898 1075
                 return $this->includeMdfFile('moduser');
899 1076
             case 'userinfo':
900
-                if(empty($opt)) $this->opt = 'username';
1077
+                if(empty($opt)) {
1078
+                    $this->opt = 'username';
1079
+                }
901 1080
                 return $this->includeMdfFile('moduser');
902 1081
             case 'webuserinfo':
903
-                if(empty($opt)) $this->opt = 'username';
1082
+                if(empty($opt)) {
1083
+                    $this->opt = 'username';
1084
+                }
904 1085
                 $this->value = -$value;
905 1086
                 return $this->includeMdfFile('moduser');
906 1087
             #####  Special functions
907 1088
             case 'ifempty':
908 1089
             case '_default':
909 1090
             case 'default':
910
-                if (empty($value)) return $opt; break;
1091
+                if (empty($value)) {
1092
+                    return $opt;
1093
+                }
1094
+                break;
911 1095
             case 'ifnotempty':
912
-                if (!empty($value)) return $opt; break;
1096
+                if (!empty($value)) {
1097
+                    return $opt;
1098
+                }
1099
+                break;
913 1100
             case 'datagrid':
914 1101
                 include_once(MODX_CORE_PATH . 'controls/datagrid.class.php');
915 1102
                 $grd = new DataGrid(null, trim($value));
916 1103
                 $grd->itemStyle = '';
917 1104
                 $grd->altItemStyle = '';
918 1105
                 $pos = strpos($value,"\n");
919
-                if($pos) $_ = substr($value,0,$pos);
920
-                else $_ = $pos;
1106
+                if($pos) {
1107
+                    $_ = substr($value,0,$pos);
1108
+                } else {
1109
+                    $_ = $pos;
1110
+                }
921 1111
                 $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ',';
922 1112
                 return $grd->render();
923 1113
             case 'rotate':
924 1114
             case 'evenodd':
925
-                if(strpos($opt,',')===false) $opt = 'odd,even';
1115
+                if(strpos($opt,',')===false) {
1116
+                    $opt = 'odd,even';
1117
+                }
926 1118
                 $_ = explode(',', $opt);
927 1119
                 $c = count($_);
928 1120
                 $i = $value + $c;
@@ -931,7 +1123,9 @@  discard block
 block discarded – undo
931 1123
             case 'takeval':
932 1124
                 $arr = explode(",",$opt);
933 1125
                 $idx = $value;
934
-                if(!is_numeric($idx)) return $value;
1126
+                if(!is_numeric($idx)) {
1127
+                    return $value;
1128
+                }
935 1129
                 return $arr[$idx];
936 1130
             case 'getimage':
937 1131
                 return $this->includeMdfFile('getimage');
@@ -939,14 +1133,18 @@  discard block
 block discarded – undo
939 1133
                 return $modx->nicesize($value);
940 1134
             case 'googlemap':
941 1135
             case 'googlemaps':
942
-                if(empty($opt)) $opt = 'border:none;width:500px;height:350px;';
1136
+                if(empty($opt)) {
1137
+                    $opt = 'border:none;width:500px;height:350px;';
1138
+                }
943 1139
                 $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>';
944 1140
                 $ph['style'] = $opt;
945 1141
                 $ph['value'] = $value;
946 1142
                 return $modx->parseText($tpl,$ph);
947 1143
             case 'youtube':
948 1144
             case 'youtube16x9':
949
-                if(empty($opt)) $opt = 560;
1145
+                if(empty($opt)) {
1146
+                    $opt = 560;
1147
+                }
950 1148
                 $h = round($opt*0.5625);
951 1149
                 $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>';
952 1150
                 return sprintf($tpl,$opt,$h,$value);
@@ -979,7 +1177,8 @@  discard block
 block discarded – undo
979 1177
         return $value;
980 1178
     }
981 1179
 
982
-    public function includeMdfFile($cmd) {
1180
+    public function includeMdfFile($cmd)
1181
+    {
983 1182
         $modx = evolutionCMS();
984 1183
         $key = $this->key;
985 1184
         $value  = $this->value;
@@ -990,55 +1189,65 @@  discard block
 block discarded – undo
990 1189
     public function getValueFromElement($key, $value, $cmd, $opt)
991 1190
     {
992 1191
         $modx = evolutionCMS();
993
-        if( isset($modx->snippetCache[$this->elmName]) )
994
-        {
1192
+        if( isset($modx->snippetCache[$this->elmName]) ) {
995 1193
             $php = $modx->snippetCache[$this->elmName];
996
-        }
997
-        else
998
-        {
1194
+        } else {
999 1195
             $esc_elmName = $modx->getDatabase()->escape($this->elmName);
1000 1196
             $result = $modx->getDatabase()->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'");
1001 1197
             $total = $modx->getDatabase()->getRecordCount($result);
1002
-            if($total == 1)
1003
-            {
1198
+            if($total == 1) {
1004 1199
                 $row = $modx->getDatabase()->getRow($result);
1005 1200
                 $php = $row['snippet'];
1006
-            }
1007
-            elseif($total == 0)
1008
-            {
1201
+            } elseif($total == 0) {
1009 1202
                 $assets_path = MODX_BASE_PATH.'assets/';
1010
-                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
1011
-                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1012
-                elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
1013
-                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1014
-                elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
1015
-                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1016
-                else $modifiers_path = false;
1203
+                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) {
1204
+                                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1205
+                } elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) {
1206
+                                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1207
+                } elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) {
1208
+                                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1209
+                } else {
1210
+                    $modifiers_path = false;
1211
+                }
1017 1212
 
1018 1213
                 if($modifiers_path !== false) {
1019 1214
                     $php = @file_get_contents($modifiers_path);
1020 1215
                     $php = trim($php);
1021
-                    if(substr($php,0,5)==='<?php') $php = substr($php,6);
1022
-                    if(substr($php,0,2)==='<?')    $php = substr($php,3);
1023
-                    if(substr($php,-2)==='?>')     $php = substr($php,0,-2);
1024
-                    if($this->elmName!=='')
1025
-                        $modx->snippetCache[$this->elmName.'Props'] = '';
1026
-                }
1027
-                else
1028
-                    $php = false;
1216
+                    if(substr($php,0,5)==='<?php') {
1217
+                        $php = substr($php,6);
1218
+                    }
1219
+                    if(substr($php,0,2)==='<?') {
1220
+                        $php = substr($php,3);
1221
+                    }
1222
+                    if(substr($php,-2)==='?>') {
1223
+                        $php = substr($php,0,-2);
1224
+                    }
1225
+                    if($this->elmName!=='') {
1226
+                                            $modx->snippetCache[$this->elmName.'Props'] = '';
1227
+                    }
1228
+                } else {
1229
+                                    $php = false;
1230
+                }
1231
+            } else {
1232
+                $php = false;
1233
+            }
1234
+            if($this->elmName!=='') {
1235
+                $modx->snippetCache[$this->elmName]= $php;
1029 1236
             }
1030
-            else $php = false;
1031
-            if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php;
1032 1237
         }
1033
-        if($php==='') $php=false;
1238
+        if($php==='') {
1239
+            $php=false;
1240
+        }
1034 1241
 
1035
-        if($php===false) $html = $modx->getChunk($this->elmName);
1036
-        else             $html = false;
1242
+        if($php===false) {
1243
+            $html = $modx->getChunk($this->elmName);
1244
+        } else {
1245
+            $html = false;
1246
+        }
1037 1247
 
1038 1248
         $self = '[+output+]';
1039 1249
 
1040
-        if($php !== false)
1041
-        {
1250
+        if($php !== false) {
1042 1251
             ob_start();
1043 1252
             $options = $opt;
1044 1253
             $output = $value;
@@ -1050,19 +1259,19 @@  discard block
 block discarded – undo
1050 1259
             $this->vars['options'] = & $opt;
1051 1260
             $custom = eval($php);
1052 1261
             $msg = ob_get_contents();
1053
-            if($value===$this->bt) $value = $msg . $custom;
1262
+            if($value===$this->bt) {
1263
+                $value = $msg . $custom;
1264
+            }
1054 1265
             ob_end_clean();
1055
-        }
1056
-        elseif($html!==false && isset($value) && $value!=='')
1057
-        {
1266
+        } elseif($html!==false && isset($value) && $value!=='') {
1058 1267
             $html = str_replace(array($self,'[+value+]'), $value, $html);
1059 1268
             $value = str_replace(array('[+options+]','[+param+]'), $opt, $html);
1269
+        } else {
1270
+            return false;
1060 1271
         }
1061
-        else return false;
1062 1272
 
1063 1273
         if($php===false && $html===false && $value!==''
1064
-            && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false))
1065
-        {
1274
+            && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) {
1066 1275
             $value = str_replace(array('[+value+]',$self),$value,$cmd);
1067 1276
         }
1068 1277
         return $value;
@@ -1072,23 +1281,39 @@  discard block
 block discarded – undo
1072 1281
     {
1073 1282
         $modx = evolutionCMS();
1074 1283
 
1075
-        if(strpos($content,'[')===false && strpos($content,'{')===false) return $content;
1284
+        if(strpos($content,'[')===false && strpos($content,'{')===false) {
1285
+            return $content;
1286
+        }
1076 1287
 
1077
-        if(!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1288
+        if(!$modx->maxParserPasses) {
1289
+            $modx->maxParserPasses = 10;
1290
+        }
1078 1291
         $bt='';
1079 1292
         $i=0;
1080
-        while($bt!==$content)
1081
-        {
1293
+        while($bt!==$content) {
1082 1294
             $bt = $content;
1083
-            if(strpos($content,'[*')!==false && $modx->documentIdentifier)
1084
-                $content = $modx->mergeDocumentContent($content);
1085
-            if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content);
1086
-            if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content);
1087
-            if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1088
-            if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content);
1089
-
1090
-            if($content===$bt)              break;
1091
-            if($modx->maxParserPasses < $i) break;
1295
+            if(strpos($content,'[*')!==false && $modx->documentIdentifier) {
1296
+                            $content = $modx->mergeDocumentContent($content);
1297
+            }
1298
+            if(strpos($content,'[(')!==false) {
1299
+                $content = $modx->mergeSettingsContent($content);
1300
+            }
1301
+            if(strpos($content,'{{')!==false) {
1302
+                $content = $modx->mergeChunkContent($content);
1303
+            }
1304
+            if(strpos($content,'[!')!==false) {
1305
+                $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1306
+            }
1307
+            if(strpos($content,'[[')!==false) {
1308
+                $content = $modx->evalSnippets($content);
1309
+            }
1310
+
1311
+            if($content===$bt) {
1312
+                break;
1313
+            }
1314
+            if($modx->maxParserPasses < $i) {
1315
+                break;
1316
+            }
1092 1317
             $i++;
1093 1318
         }
1094 1319
         return $content;
@@ -1099,103 +1324,138 @@  discard block
 block discarded – undo
1099 1324
         $modx = evolutionCMS();
1100 1325
 
1101 1326
         $target = trim($target);
1102
-        if(empty($target)) $target = $modx->config['site_start'];
1103
-        if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id';
1104
-        else $method = 'alias';
1327
+        if(empty($target)) {
1328
+            $target = $modx->config['site_start'];
1329
+        }
1330
+        if(preg_match('@^[1-9][0-9]*$@',$target)) {
1331
+            $method='id';
1332
+        } else {
1333
+            $method = 'alias';
1334
+        }
1105 1335
 
1106
-        if(!isset($this->documentObject[$target]))
1107
-        {
1336
+        if(!isset($this->documentObject[$target])) {
1108 1337
             $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct');
1109 1338
         }
1110 1339
 
1111
-        if($this->documentObject[$target]['publishedon']==='0')
1112
-            return '';
1113
-        elseif(isset($this->documentObject[$target][$field]))
1114
-        {
1115
-            if(is_array($this->documentObject[$target][$field]))
1116
-            {
1340
+        if($this->documentObject[$target]['publishedon']==='0') {
1341
+                    return '';
1342
+        } elseif(isset($this->documentObject[$target][$field])) {
1343
+            if(is_array($this->documentObject[$target][$field])) {
1117 1344
                 $a = $modx->getTemplateVarOutput($field,$target);
1118 1345
                 $this->documentObject[$target][$field] = $a[$field];
1119 1346
             }
1347
+        } else {
1348
+            $this->documentObject[$target][$field] = false;
1120 1349
         }
1121
-        else $this->documentObject[$target][$field] = false;
1122 1350
 
1123 1351
         return $this->documentObject[$target][$field];
1124 1352
     }
1125 1353
 
1126
-    public function setPlaceholders($value = '', $key = '', $path = '') {
1127
-        if($path!=='') $key = "{$path}.{$key}";
1354
+    public function setPlaceholders($value = '', $key = '', $path = '')
1355
+    {
1356
+        if($path!=='') {
1357
+            $key = "{$path}.{$key}";
1358
+        }
1128 1359
         if (is_array($value)) {
1129 1360
             foreach ($value as $subkey => $subval) {
1130 1361
                 $this->setPlaceholders($subval, $subkey, $key);
1131 1362
             }
1363
+        } else {
1364
+            $this->setModifiersVariable($key, $value);
1132 1365
         }
1133
-        else $this->setModifiersVariable($key, $value);
1134 1366
     }
1135 1367
 
1136 1368
     // Sets a placeholder variable which can only be access by Modifiers
1137
-    public function setModifiersVariable($key, $value) {
1138
-        if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1369
+    public function setModifiersVariable($key, $value)
1370
+    {
1371
+        if ($key != 'phx' && $key != 'dummy') {
1372
+            $this->placeholders[$key] = $value;
1373
+        }
1139 1374
     }
1140 1375
 
1141 1376
     //mbstring
1142
-    public function substr($str, $s, $l = null) {
1377
+    public function substr($str, $s, $l = null)
1378
+    {
1143 1379
         $modx = evolutionCMS();
1144
-        if(is_null($l)) $l = $this->strlen($str);
1145
-        if (function_exists('mb_substr'))
1146
-        {
1147
-            if(strpos($str,"\r")!==false)
1148
-                $str = str_replace(array("\r\n","\r"), "\n", $str);
1380
+        if(is_null($l)) {
1381
+            $l = $this->strlen($str);
1382
+        }
1383
+        if (function_exists('mb_substr')) {
1384
+            if(strpos($str,"\r")!==false) {
1385
+                            $str = str_replace(array("\r\n","\r"), "\n", $str);
1386
+            }
1149 1387
             return mb_substr($str, $s, $l, $modx->config['modx_charset']);
1150 1388
         }
1151 1389
         return substr($str, $s, $l);
1152 1390
     }
1153
-    public function strpos($haystack,$needle,$offset=0) {
1391
+    public function strpos($haystack,$needle,$offset=0)
1392
+    {
1154 1393
         $modx = evolutionCMS();
1155
-        if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1394
+        if (function_exists('mb_strpos')) {
1395
+            return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1396
+        }
1156 1397
         return strpos($haystack,$needle,$offset);
1157 1398
     }
1158
-    public function strlen($str) {
1399
+    public function strlen($str)
1400
+    {
1159 1401
         $modx = evolutionCMS();
1160
-        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1402
+        if (function_exists('mb_strlen')) {
1403
+            return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1404
+        }
1161 1405
         return strlen($str);
1162 1406
     }
1163
-    public function strtolower($str) {
1164
-        if (function_exists('mb_strtolower')) return mb_strtolower($str);
1407
+    public function strtolower($str)
1408
+    {
1409
+        if (function_exists('mb_strtolower')) {
1410
+            return mb_strtolower($str);
1411
+        }
1165 1412
         return strtolower($str);
1166 1413
     }
1167
-    public function strtoupper($str) {
1168
-        if (function_exists('mb_strtoupper')) return mb_strtoupper($str);
1414
+    public function strtoupper($str)
1415
+    {
1416
+        if (function_exists('mb_strtoupper')) {
1417
+            return mb_strtoupper($str);
1418
+        }
1169 1419
         return strtoupper($str);
1170 1420
     }
1171
-    public function ucfirst($str) {
1172
-        if (function_exists('mb_strtoupper'))
1173
-            return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1421
+    public function ucfirst($str)
1422
+    {
1423
+        if (function_exists('mb_strtoupper')) {
1424
+                    return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1425
+        }
1174 1426
         return ucfirst($str);
1175 1427
     }
1176
-    public function lcfirst($str) {
1177
-        if (function_exists('mb_strtolower'))
1178
-            return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1428
+    public function lcfirst($str)
1429
+    {
1430
+        if (function_exists('mb_strtolower')) {
1431
+                    return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1432
+        }
1179 1433
         return lcfirst($str);
1180 1434
     }
1181
-    public function ucwords($str) {
1182
-        if (function_exists('mb_convert_case'))
1183
-            return mb_convert_case($str, MB_CASE_TITLE);
1435
+    public function ucwords($str)
1436
+    {
1437
+        if (function_exists('mb_convert_case')) {
1438
+                    return mb_convert_case($str, MB_CASE_TITLE);
1439
+        }
1184 1440
         return ucwords($str);
1185 1441
     }
1186
-    public function strrev($str) {
1442
+    public function strrev($str)
1443
+    {
1187 1444
         preg_match_all('/./us', $str, $ar);
1188 1445
         return implode(array_reverse($ar[0]));
1189 1446
     }
1190
-    public function str_shuffle($str) {
1447
+    public function str_shuffle($str)
1448
+    {
1191 1449
         preg_match_all('/./us', $str, $ar);
1192 1450
         shuffle($ar[0]);
1193 1451
         return implode($ar[0]);
1194 1452
     }
1195
-    public function str_word_count($str) {
1453
+    public function str_word_count($str)
1454
+    {
1196 1455
         return count(preg_split('~[^\p{L}\p{N}\']+~u',$str));
1197 1456
     }
1198
-    public function strip_tags($value,$params='') {
1457
+    public function strip_tags($value,$params='')
1458
+    {
1199 1459
         $modx = evolutionCMS();
1200 1460
 
1201 1461
         if(stripos($params,'style')===false && stripos($value,'</style>')!==false) {
Please login to merge, or discard this patch.
manager/includes/src/Exceptions/ServiceNotFoundException.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,4 +2,6 @@
 block discarded – undo
2 2
 
3 3
 use Exception;
4 4
 
5
-class ServiceNotFoundException extends Exception{}
5
+class ServiceNotFoundException extends Exception
6
+{
7
+}
Please login to merge, or discard this patch.
manager/includes/src/Exceptions/ContainerException.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,4 +2,6 @@
 block discarded – undo
2 2
 
3 3
 use Exception;
4 4
 
5
-class ContainerException extends Exception{}
5
+class ContainerException extends Exception
6
+{
7
+}
Please login to merge, or discard this patch.
manager/includes/src/Core.php 1 patch
Braces   +62 added lines, -31 removed lines patch added patch discarded remove patch
@@ -282,7 +282,8 @@  discard block
 block discarded – undo
282 282
         return $service;
283 283
     }
284 284
 
285
-    private function checkServiceAlias($name){
285
+    private function checkServiceAlias($name)
286
+    {
286 287
         foreach ($this->providerAliases as $alias => $interface) {
287 288
             if($name === $interface) {
288 289
                 return $alias;
@@ -962,13 +963,15 @@  discard block
 block discarded – undo
962 963
             $this->virtualDir = '';
963 964
         }
964 965
 
965
-        if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */
966
+        if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) {
967
+/* we got an ID returned, check to make sure it's not an alias */
966 968
             /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */
967 969
             if ($this->config['use_alias_path'] == 1) {
968 970
                 if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) {
969 971
                     $this->documentMethod = 'id';
970 972
                     return $q;
971
-                } else { /* not a valid id in terms of virtualDir, treat as alias */
973
+                } else {
974
+/* not a valid id in terms of virtualDir, treat as alias */
972 975
                     $this->documentMethod = 'alias';
973 976
                     return $q;
974 977
                 }
@@ -976,7 +979,8 @@  discard block
 block discarded – undo
976 979
                 $this->documentMethod = 'id';
977 980
                 return $q;
978 981
             }
979
-        } else { /* we didn't get an ID back, so instead we assume it's an alias */
982
+        } else {
983
+/* we didn't get an ID back, so instead we assume it's an alias */
980 984
             if ($this->config['friendly_alias_urls'] != 1) {
981 985
                 $q = $qOrig;
982 986
             }
@@ -1006,13 +1010,14 @@  discard block
 block discarded – undo
1006 1010
      * @param $id
1007 1011
      * @return array|mixed|null|string
1008 1012
      */
1009
-    public function makePageCacheKey($id){
1013
+    public function makePageCacheKey($id)
1014
+    {
1010 1015
         $hash = $id;
1011 1016
         $tmp = null;
1012 1017
         $params = array();
1013
-        if(!empty($this->systemCacheKey)){
1018
+        if(!empty($this->systemCacheKey)) {
1014 1019
             $hash = $this->systemCacheKey;
1015
-        }else {
1020
+        } else {
1016 1021
             if (!empty($_GET)) {
1017 1022
                 // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID.
1018 1023
                 $params = $_GET;
@@ -1021,7 +1026,7 @@  discard block
 block discarded – undo
1021 1026
             }
1022 1027
         }
1023 1028
         $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params));
1024
-        if (is_array($evtOut) && count($evtOut) > 0){
1029
+        if (is_array($evtOut) && count($evtOut) > 0) {
1025 1030
             $tmp = array_pop($evtOut);
1026 1031
         }
1027 1032
         return empty($tmp) ? $hash : $tmp;
@@ -1348,7 +1353,8 @@  discard block
 block discarded – undo
1348 1353
         $where = "pub_date <= {$timeNow} AND pub_date!=0 AND published=0";
1349 1354
         $result_pub = $this->getDatabase()->select( 'id', '[+prefix+]site_content',  $where);
1350 1355
         $this->getDatabase()->update($field, '[+prefix+]site_content', $where);
1351
-        if ($this->getDatabase()->getRecordCount($result_pub) >= 1) { //Event unPublished doc
1356
+        if ($this->getDatabase()->getRecordCount($result_pub) >= 1) {
1357
+//Event unPublished doc
1352 1358
             while ($row_pub = $this->getDatabase()->getRow($result_pub)) {
1353 1359
                 $this->invokeEvent("OnDocUnPublished", array(
1354 1360
                     "docid" => $row_pub['id']
@@ -1361,7 +1367,8 @@  discard block
 block discarded – undo
1361 1367
         $where = "unpub_date <= {$timeNow} AND unpub_date!=0 AND published=1";
1362 1368
         $result_unpub = $this->getDatabase()->select( 'id', '[+prefix+]site_content',  $where);
1363 1369
         $this->getDatabase()->update($field, '[+prefix+]site_content', $where);
1364
-        if ($this->getDatabase()->getRecordCount($result_unpub) >= 1) { //Event unPublished doc
1370
+        if ($this->getDatabase()->getRecordCount($result_unpub) >= 1) {
1371
+//Event unPublished doc
1365 1372
             while ($row_unpub = $this->getDatabase()->getRow($result_unpub)) {
1366 1373
                 $this->invokeEvent("OnDocUnPublished", array(
1367 1374
                     "docid" => $row_unpub['id']
@@ -1448,10 +1455,18 @@  discard block
 block discarded – undo
1448 1455
             return array();
1449 1456
         }
1450 1457
         $spacer = md5('<<<EVO>>>');
1451
-        if($left==='{{' && strpos($content,';}}')!==false)  $content = str_replace(';}}', sprintf(';}%s}',   $spacer),$content);
1452
-        if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content);
1453
-        if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]',  $spacer),$content);
1454
-        if($left==='[[' && strpos($content,']]]')!==false)  $content = str_replace(']]]', sprintf(']%s]]',   $spacer),$content);
1458
+        if($left==='{{' && strpos($content,';}}')!==false) {
1459
+            $content = str_replace(';}}', sprintf(';}%s}',   $spacer),$content);
1460
+        }
1461
+        if($left==='{{' && strpos($content,'{{}}')!==false) {
1462
+            $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content);
1463
+        }
1464
+        if($left==='[[' && strpos($content,']]]]')!==false) {
1465
+            $content = str_replace(']]]]',sprintf(']]%s]]',  $spacer),$content);
1466
+        }
1467
+        if($left==='[[' && strpos($content,']]]')!==false) {
1468
+            $content = str_replace(']]]', sprintf(']%s]]',   $spacer),$content);
1469
+        }
1455 1470
 
1456 1471
         $pos['<![CDATA['] = strpos($content, '<![CDATA[');
1457 1472
         $pos[']]>'] = strpos($content, ']]>');
@@ -1504,7 +1519,8 @@  discard block
 block discarded – undo
1504 1519
                         }
1505 1520
                     }
1506 1521
 
1507
-                    if (!in_array($fetch, $tags)) {  // Avoid double Matches
1522
+                    if (!in_array($fetch, $tags)) {
1523
+// Avoid double Matches
1508 1524
                         $tags[] = $fetch; // Fetch
1509 1525
                     };
1510 1526
                     $fetch = ''; // and reset
@@ -1522,7 +1538,9 @@  discard block
 block discarded – undo
1522 1538
             }
1523 1539
         }
1524 1540
         foreach($tags as $i=>$tag) {
1525
-            if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag);
1541
+            if(strpos($tag,$spacer)!==false) {
1542
+                $tags[$i] = str_replace($spacer, '', $tag);
1543
+            }
1526 1544
         }
1527 1545
         return $tags;
1528 1546
     }
@@ -1562,7 +1580,10 @@  discard block
 block discarded – undo
1562 1580
         }
1563 1581
 
1564 1582
         foreach ($matches[1] as $i => $key) {
1565
-            if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1583
+            if(strpos($key,'[+')!==false) {
1584
+                continue;
1585
+            }
1586
+            // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1566 1587
             if (substr($key, 0, 1) == '#') {
1567 1588
                 $key = substr($key, 1);
1568 1589
             } // remove # for QuickEdit format
@@ -2288,7 +2309,8 @@  discard block
 block discarded – undo
2288 2309
      * @return mixed|string
2289 2310
      */
2290 2311
     public function _getSGVar($value)
2291
-    { // Get super globals
2312
+    {
2313
+// Get super globals
2292 2314
         $key = $value;
2293 2315
         $_ = $this->config['enable_filter'];
2294 2316
         $this->config['enable_filter'] = 1;
@@ -2693,7 +2715,8 @@  discard block
 block discarded – undo
2693 2715
         if ($this->config['friendly_urls'] == 1) {
2694 2716
             $aliases = array();
2695 2717
             if (is_array($this->documentListing)) {
2696
-                foreach ($this->documentListing as $path => $docid) { // This is big Loop on large site!
2718
+                foreach ($this->documentListing as $path => $docid) {
2719
+// This is big Loop on large site!
2697 2720
                     $aliases[$docid] = $path;
2698 2721
                     $isfolder[$docid] = $this->aliasListing[$docid]['isfolder'];
2699 2722
                 }
@@ -2726,7 +2749,7 @@  discard block
 block discarded – undo
2726 2749
             $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0);
2727 2750
             $pref = $this->config['friendly_url_prefix'];
2728 2751
             $suff = $this->config['friendly_url_suffix'];
2729
-            $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) {
2752
+            $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff){
2730 2753
                 global $modx;
2731 2754
                 $thealias = $aliases[$m[1]];
2732 2755
                 $thefolder = $isfolder[$m[1]];
@@ -4509,7 +4532,8 @@  discard block
 block discarded – undo
4509 4532
         if (isset ($this->snippetCache[$snippetName])) {
4510 4533
             $snippet = $this->snippetCache[$snippetName];
4511 4534
             $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : '';
4512
-        } else { // not in cache so let's check the db
4535
+        } else {
4536
+// not in cache so let's check the db
4513 4537
             $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->getDatabase()->escape($snippetName) . "'  AND ss.disabled=0;";
4514 4538
             $result = $this->getDatabase()->query($sql);
4515 4539
             if ($this->getDatabase()->getRecordCount($result) == 1) {
@@ -5010,7 +5034,7 @@  discard block
 block discarded – undo
5010 5034
             $result = $this->getDatabase()->makeArray($rs);
5011 5035
 
5012 5036
             // get default/built-in template variables
5013
-            if(is_array($docRow)){
5037
+            if(is_array($docRow)) {
5014 5038
                 ksort($docRow);
5015 5039
 
5016 5040
                 foreach ($docRow as $key => $value) {
@@ -5485,12 +5509,16 @@  discard block
 block discarded – undo
5485 5509
             return '';
5486 5510
         } // nothing to register
5487 5511
         if (!is_array($options)) {
5488
-            if (is_bool($options))  // backward compatibility with old plaintext parameter
5512
+            if (is_bool($options)) {
5513
+                // backward compatibility with old plaintext parameter
5489 5514
             {
5490 5515
                 $options = array('plaintext' => $options);
5491
-            } elseif (is_string($options)) // Also allow script name as 2nd param
5516
+            }
5517
+            } elseif (is_string($options)) {
5518
+                // Also allow script name as 2nd param
5492 5519
             {
5493 5520
                 $options = array('name' => $options);
5521
+            }
5494 5522
             } else {
5495 5523
                 $options = array();
5496 5524
             }
@@ -5502,7 +5530,8 @@  discard block
 block discarded – undo
5502 5530
         unset($overwritepos); // probably unnecessary--just making sure
5503 5531
 
5504 5532
         $useThisVer = true;
5505
-        if (isset($this->loadedjscripts[$key])) { // a matching script was found
5533
+        if (isset($this->loadedjscripts[$key])) {
5534
+// a matching script was found
5506 5535
             // if existing script is a startup script, make sure the candidate is also a startup script
5507 5536
             if ($this->loadedjscripts[$key]['startup']) {
5508 5537
                 $startup = true;
@@ -5522,7 +5551,8 @@  discard block
 block discarded – undo
5522 5551
                     // overwrite the old script (the position may be important for dependent scripts)
5523 5552
                     $overwritepos = $this->loadedjscripts[$key]['pos'];
5524 5553
                 }
5525
-            } else { // Use the original version
5554
+            } else {
5555
+// Use the original version
5526 5556
                 if ($startup == true && $this->loadedjscripts[$key]['startup'] == false) {
5527 5557
                     // need to move the exisiting script to the head
5528 5558
                     $version = $this->loadedjscripts[$key][$version];
@@ -5647,7 +5677,8 @@  discard block
 block discarded – undo
5647 5677
         }
5648 5678
 
5649 5679
         $results = null;
5650
-        foreach ($this->pluginEvent[$evtName] as $pluginName) { // start for loop
5680
+        foreach ($this->pluginEvent[$evtName] as $pluginName) {
5681
+// start for loop
5651 5682
             if ($this->dumpPlugins) {
5652 5683
                 $eventtime = $this->getMicroTime();
5653 5684
             }
@@ -5793,8 +5824,7 @@  discard block
 block discarded – undo
5793 5824
                     }
5794 5825
                 }
5795 5826
             }
5796
-        }
5797
-        elseif(\is_array($propertyString)) {
5827
+        } elseif(\is_array($propertyString)) {
5798 5828
             $property = $propertyString;
5799 5829
         }
5800 5830
         if (!empty($elementName) && !empty($elementType)) {
@@ -6241,7 +6271,8 @@  discard block
 block discarded – undo
6241 6271
      * @return bool
6242 6272
      */
6243 6273
     public function isSafeCode($phpcode = '', $safe_functions = '')
6244
-    { // return true or false
6274
+    {
6275
+// return true or false
6245 6276
         if ($safe_functions == '') {
6246 6277
             return false;
6247 6278
         }
@@ -6650,7 +6681,7 @@  discard block
 block discarded – undo
6650 6681
             $args = array_pad(array(), $_, '$var');
6651 6682
             $args = implode(", ", $args);
6652 6683
             $modx = &$this;
6653
-            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) {
6684
+            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val){
6654 6685
                 $arg = $val['args'][$tmp - 1];
6655 6686
                 switch (true) {
6656 6687
                     case is_null($arg): {
Please login to merge, or discard this patch.
manager/includes/src/Interfaces/ManagerApiInterface.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,5 @@
 block discarded – undo
1 1
 <?php namespace EvolutionCMS\Interfaces;
2 2
 
3
-interface ManagerApiInterface{}
3
+interface ManagerApiInterface
4
+{
5
+}
Please login to merge, or discard this patch.
manager/includes/src/Interfaces/ServiceProviderInterface.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,5 @@
 block discarded – undo
1 1
 <?php namespace EvolutionCMS\Interfaces;
2 2
 
3
-interface ServiceProviderInterface{}
3
+interface ServiceProviderInterface
4
+{
5
+}
Please login to merge, or discard this patch.