Completed
Push — develop ( 923a1c...1e9876 )
by Maxim
47s queued 29s
created
manager/includes/extenders/manager.api.class.inc.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 global $_PAGE; // page view state object. Usage $_PAGE['vs']['propertyname'] = $value;
9 9
 
10 10
 // Content manager wrapper class
11
-class ManagerAPI {
11
+class ManagerAPI{
12 12
 	
13 13
 	var $action; // action directive
14 14
 
@@ -17,27 +17,27 @@  discard block
 block discarded – undo
17 17
 		$this->action = $action; // set action directive
18 18
 	}
19 19
 	
20
-	function initPageViewState($id=0){
20
+	function initPageViewState($id = 0){
21 21
 		global $_PAGE;
22 22
 		$vsid = isset($_SESSION["mgrPageViewSID"]) ? $_SESSION["mgrPageViewSID"] : '';
23
-		if($vsid!=$this->action) {
23
+		if ($vsid != $this->action) {
24 24
 			$_SESSION["mgrPageViewSDATA"] = array(); // new view state
25
-			$_SESSION["mgrPageViewSID"] = $id>0 ? $id:$this->action; // set id
25
+			$_SESSION["mgrPageViewSID"] = $id > 0 ? $id : $this->action; // set id
26 26
 		}
27 27
 		$_PAGE['vs'] = &$_SESSION["mgrPageViewSDATA"]; // restore viewstate
28 28
 	}
29 29
 
30 30
 	// save page view state - not really necessary,
31
-	function savePageViewState($id=0){
31
+	function savePageViewState($id = 0){
32 32
 		global $_PAGE;
33 33
 		$_SESSION["mgrPageViewSDATA"] = $_PAGE['vs'];
34
-		$_SESSION["mgrPageViewSID"] = $id>0 ? $id:$this->action;
34
+		$_SESSION["mgrPageViewSID"] = $id > 0 ? $id : $this->action;
35 35
 	}
36 36
 	
37 37
 	// check for saved form
38
-	function hasFormValues() {
39
-		if(isset($_SESSION["mgrFormValueId"])) {		
40
-			if($this->action==$_SESSION["mgrFormValueId"]) {
38
+	function hasFormValues(){
39
+		if (isset($_SESSION["mgrFormValueId"])) {		
40
+			if ($this->action == $_SESSION["mgrFormValueId"]) {
41 41
 				return true;
42 42
 			}
43 43
 			else {
@@ -47,19 +47,19 @@  discard block
 block discarded – undo
47 47
 		return false;
48 48
 	}	
49 49
 	// saved form post from $_POST
50
-	function saveFormValues($id=0){
50
+	function saveFormValues($id = 0){
51 51
 		$_SESSION["mgrFormValues"] = $_POST;
52
-		$_SESSION["mgrFormValueId"] = $id>0 ? $id:$this->action;
52
+		$_SESSION["mgrFormValueId"] = $id > 0 ? $id : $this->action;
53 53
 	}		
54 54
 	// load saved form values into $_POST
55 55
 	function loadFormValues(){
56 56
 		
57
-		if(!$this->hasFormValues()) return false;
57
+		if (!$this->hasFormValues()) return false;
58 58
 		
59 59
 		$p = $_SESSION["mgrFormValues"];
60 60
 		$this->clearSavedFormValues();
61
-		foreach($p as $k=>$v) {
62
-			$_POST[$k]=$v;
61
+		foreach ($p as $k=>$v) {
62
+			$_POST[$k] = $v;
63 63
 		}
64 64
 		return true;
65 65
 	}
@@ -69,50 +69,50 @@  discard block
 block discarded – undo
69 69
 		unset($_SESSION["mgrFormValueId"]);	
70 70
 	}
71 71
 	
72
-	function getHashType($db_value='') { // md5 | v1 | phpass
73
-		$c = substr($db_value,0,1);
74
-		if($c==='$')                                      return 'phpass';
75
-		elseif(strlen($db_value)===32)                    return 'md5';
76
-		elseif($c!=='$' && strpos($db_value,'>')!==false) return 'v1';
72
+	function getHashType($db_value = ''){ // md5 | v1 | phpass
73
+		$c = substr($db_value, 0, 1);
74
+		if ($c === '$')                                      return 'phpass';
75
+		elseif (strlen($db_value) === 32)                    return 'md5';
76
+		elseif ($c !== '$' && strpos($db_value, '>') !== false) return 'v1';
77 77
 		else                                              return 'unknown';
78 78
 	}
79 79
 	
80
-	function genV1Hash($password, $seed='1')
80
+	function genV1Hash($password, $seed = '1')
81 81
 	{ // $seed is user_id basically
82 82
 		global $modx;
83 83
 		
84
-		if(isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo']))
84
+		if (isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo']))
85 85
 			$algorithm = $modx->config['pwd_hash_algo'];
86 86
 		else $algorithm = 'UNCRYPT';
87 87
 		
88
-		$salt = md5($password . $seed);
88
+		$salt = md5($password.$seed);
89 89
 		
90
-		switch($algorithm)
90
+		switch ($algorithm)
91 91
 		{
92 92
 			case 'BLOWFISH_Y':
93
-				$salt = '$2y$07$' . substr($salt,0,22);
93
+				$salt = '$2y$07$'.substr($salt, 0, 22);
94 94
 				break;
95 95
 			case 'BLOWFISH_A':
96
-				$salt = '$2a$07$' . substr($salt,0,22);
96
+				$salt = '$2a$07$'.substr($salt, 0, 22);
97 97
 				break;
98 98
 			case 'SHA512':
99
-				$salt = '$6$' . substr($salt,0,16);
99
+				$salt = '$6$'.substr($salt, 0, 16);
100 100
 				break;
101 101
 			case 'SHA256':
102
-				$salt = '$5$' . substr($salt,0,16);
102
+				$salt = '$5$'.substr($salt, 0, 16);
103 103
 				break;
104 104
 			case 'MD5':
105
-				$salt = '$1$' . substr($salt,0,8);
105
+				$salt = '$1$'.substr($salt, 0, 8);
106 106
 				break;
107 107
 		}
108 108
 		
109
-		if($algorithm!=='UNCRYPT')
109
+		if ($algorithm !== 'UNCRYPT')
110 110
 		{
111
-			$password = sha1($password) . crypt($password,$salt);
111
+			$password = sha1($password).crypt($password, $salt);
112 112
 		}
113 113
 		else $password = sha1($salt.$password);
114 114
 		
115
-		$result = strtolower($algorithm) . '>' . md5($salt.$password) . substr(md5($salt),0,8);
115
+		$result = strtolower($algorithm).'>'.md5($salt.$password).substr(md5($salt), 0, 8);
116 116
 		
117 117
 		return $result;
118 118
 	}
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	{
122 122
 		global $modx;
123 123
 		$tbl_manager_users = $modx->getFullTableName('manager_users');
124
-		$rs = $modx->db->select('password',$tbl_manager_users,"id='{$uid}'");
124
+		$rs = $modx->db->select('password', $tbl_manager_users, "id='{$uid}'");
125 125
 		$password = $modx->db->getValue($rs);
126 126
 		
127
-		if(strpos($password,'>')===false) $algo = 'NOSALT';
127
+		if (strpos($password, '>') === false) $algo = 'NOSALT';
128 128
 		else
129 129
 		{
130
-			$algo = substr($password,0,strpos($password,'>'));
130
+			$algo = substr($password, 0, strpos($password, '>'));
131 131
 		}
132 132
 		return strtoupper($algo);
133 133
 	}
134 134
 	
135
-	function checkHashAlgorithm($algorithm='')
135
+	function checkHashAlgorithm($algorithm = '')
136 136
 	{
137 137
 		$result = false;
138 138
 		if (!empty($algorithm))
@@ -165,54 +165,54 @@  discard block
 block discarded – undo
165 165
 		return $result;
166 166
 	}
167 167
 
168
-	function getSystemChecksum($check_files) {
168
+	function getSystemChecksum($check_files){
169 169
 		$_ = array();
170 170
 		$check_files = trim($check_files);
171 171
 		$check_files = explode("\n", $check_files);
172
-		foreach($check_files as $file) {
172
+		foreach ($check_files as $file) {
173 173
 			$file = trim($file);
174
-			$file = MODX_BASE_PATH . $file;
175
-			if(!is_file($file)) continue;
176
-			$_[$file]= md5_file($file);
174
+			$file = MODX_BASE_PATH.$file;
175
+			if (!is_file($file)) continue;
176
+			$_[$file] = md5_file($file);
177 177
 		}
178 178
 		return serialize($_);
179 179
 	}
180 180
 
181
-	function getModifiedSystemFilesList($check_files, $checksum) {
181
+	function getModifiedSystemFilesList($check_files, $checksum){
182 182
 		$_ = array();
183 183
 		$check_files = trim($check_files);
184 184
 		$check_files = explode("\n", $check_files);
185 185
 		$checksum = unserialize($checksum);
186
-		foreach($check_files as $file) {
186
+		foreach ($check_files as $file) {
187 187
 			$file = trim($file);
188
-			$filePath = MODX_BASE_PATH . $file;
189
-			if(!is_file($filePath)) continue;
190
-			if(md5_file($filePath) != $checksum[$filePath]) $_[] = $file;
188
+			$filePath = MODX_BASE_PATH.$file;
189
+			if (!is_file($filePath)) continue;
190
+			if (md5_file($filePath) != $checksum[$filePath]) $_[] = $file;
191 191
 		}
192 192
 		return $_;
193 193
 	}
194 194
 
195
-	function setSystemChecksum($checksum) {
195
+	function setSystemChecksum($checksum){
196 196
 		global $modx;
197 197
 		$tbl_system_settings = $modx->getFullTableName('system_settings');
198
-		$sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','" . $modx->db->escape($checksum) . "')";
198
+		$sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','".$modx->db->escape($checksum)."')";
199 199
         $modx->db->query($sql);
200 200
 	}
201 201
 	
202
-	function checkSystemChecksum() {
202
+	function checkSystemChecksum(){
203 203
 		global $modx;
204 204
 
205
-		if(!isset($modx->config['check_files_onlogin']) || empty($modx->config['check_files_onlogin'])) return '0';
205
+		if (!isset($modx->config['check_files_onlogin']) || empty($modx->config['check_files_onlogin'])) return '0';
206 206
 		
207 207
 		$current = $this->getSystemChecksum($modx->config['check_files_onlogin']);
208
-		if(empty($current)) return '0';
208
+		if (empty($current)) return '0';
209 209
 		
210
-		if(!isset($modx->config['sys_files_checksum']) || empty($modx->config['sys_files_checksum']))
210
+		if (!isset($modx->config['sys_files_checksum']) || empty($modx->config['sys_files_checksum']))
211 211
 		{
212 212
 			$this->setSystemChecksum($current);
213 213
 			return '0';
214 214
 		}
215
-		if($current===$modx->config['sys_files_checksum']) $result = '0';
215
+		if ($current === $modx->config['sys_files_checksum']) $result = '0';
216 216
 		else {
217 217
 			$result = $this->getModifiedSystemFilesList($modx->config['check_files_onlogin'], $modx->config['sys_files_checksum']);
218 218
 		} 
@@ -220,28 +220,28 @@  discard block
 block discarded – undo
220 220
 		return $result;
221 221
 	}
222 222
 
223
-    function getLastUserSetting($key=false) {
223
+    function getLastUserSetting($key = false){
224 224
         global $modx;
225 225
         
226 226
         $rs = $modx->db->select('*', $modx->getFullTableName('user_settings'), "user = '{$_SESSION['mgrInternalKey']}'");
227 227
         
228
-        $usersettings = array ();
228
+        $usersettings = array();
229 229
         while ($row = $modx->db->getRow($rs)) {
230
-            if(substr($row['setting_name'], 0, 6) == '_LAST_') {
230
+            if (substr($row['setting_name'], 0, 6) == '_LAST_') {
231 231
                 $name = substr($row['setting_name'], 6);
232 232
                 $usersettings[$name] = $row['setting_value'];
233 233
             }
234 234
         }
235 235
         
236
-        if(!$key) return $usersettings;
236
+        if (!$key) return $usersettings;
237 237
         else return isset($usersettings[$key]) ? $usersettings[$key] : NULL;
238 238
     }
239 239
     
240
-    function saveLastUserSetting($settings, $val='') {
240
+    function saveLastUserSetting($settings, $val = ''){
241 241
         global $modx;
242 242
         
243
-        if(!empty($settings)) {
244
-            if(!is_array($settings)) $settings = array($settings=>$val);
243
+        if (!empty($settings)) {
244
+            if (!is_array($settings)) $settings = array($settings=>$val);
245 245
             
246 246
             foreach ($settings as $key => $val) {
247 247
                 $f = array();
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         }
257 257
     }
258 258
     
259
-    function loadDatePicker($path) {
259
+    function loadDatePicker($path){
260 260
         global $modx;
261 261
         include_once($path);
262 262
         $dp = new DATEPICKER();
Please login to merge, or discard this patch.
manager/includes/extenders/phpass.class.inc.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
 // Obviously, since this code is in the public domain, the above are not
25 25
 // requirements (there can be none), but merely suggestions.
26 26
 //
27
-class PasswordHash {
27
+class PasswordHash{
28 28
     var $itoa64;
29 29
     var $iteration_count_log2;
30 30
     var $portable_hashes;
31 31
     var $random_state;
32 32
 
33
-    function __construct($iteration_count_log2=8, $portable_hashes=true)
33
+    function __construct($iteration_count_log2 = 8, $portable_hashes = true)
34 34
     {
35 35
         $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
36 36
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
         $this->portable_hashes = $portable_hashes;
42 42
 
43
-        $this->random_state = microtime() . uniqid(mt_rand(), TRUE);
43
+        $this->random_state = microtime().uniqid(mt_rand(), TRUE);
44 44
     }
45 45
 
46 46
     function get_random_bytes($count)
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             $output = '';
57 57
             for ($i = 0; $i < $count; $i += 16) {
58 58
                 $this->random_state =
59
-                    md5(microtime() . $this->random_state);
59
+                    md5(microtime().$this->random_state);
60 60
                 $output .=
61 61
                     pack('H*', md5($this->random_state));
62 62
             }
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
         // consequently in lower iteration counts and hashes that are
127 127
         // quicker to crack (by non-PHP code).
128 128
         
129
-        $hash = md5($salt . $password, TRUE);
129
+        $hash = md5($salt.$password, TRUE);
130 130
         do {
131
-            $hash = md5($hash . $password, TRUE);
131
+            $hash = md5($hash.$password, TRUE);
132 132
         } while (--$count);
133 133
 
134 134
         $output = substr($setting, 0, 12);
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
     function HashPassword($password)
200 200
     {
201
-        if ( strlen( $password ) > 4096 ) {
201
+        if (strlen($password) > 4096) {
202 202
             return '*';
203 203
         }
204 204
 
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
 
238 238
     function CheckPassword($password, $stored_hash)
239 239
     {
240
-        if ( strlen( $password ) > 4096 ) {
240
+        if (strlen($password) > 4096) {
241 241
             return false;
242 242
         }
243 243
 
244 244
         $hash = $this->crypt_private($password, $stored_hash);
245
-        if (substr($hash,0,1) === '*')
245
+        if (substr($hash, 0, 1) === '*')
246 246
             $hash = crypt($password, $stored_hash);
247 247
 
248
-        return ($hash===$stored_hash) ? true : false;
248
+        return ($hash === $stored_hash) ? true : false;
249 249
     }
250 250
 }
Please login to merge, or discard this patch.
manager/includes/extenders/phpcompat.class.inc.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@
 block discarded – undo
6 6
 	{
7 7
 	}
8 8
 	
9
-	function htmlspecialchars($str='', $flags = ENT_COMPAT, $encode='')
9
+	function htmlspecialchars($str = '', $flags = ENT_COMPAT, $encode = '')
10 10
 	{
11 11
 		global $modx;
12 12
 		
13
-		if($str=='') return '';
13
+		if ($str == '') return '';
14 14
 		
15
-		if($encode=='') $encode = $modx->config['modx_charset'];
15
+		if ($encode == '') $encode = $modx->config['modx_charset'];
16 16
 		
17 17
 		$ent_str = htmlspecialchars($str, $flags, $encode);
18 18
 		
19
-		if(!empty($str) && empty($ent_str))
19
+		if (!empty($str) && empty($ent_str))
20 20
 		{
21 21
 			$detect_order = implode(',', mb_detect_order());
22 22
 			$ent_str = mb_convert_encoding($str, $encode, $detect_order); 
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers.class.inc.php 1 patch
Spacing   +342 added lines, -342 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
3
+if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
4 4
 
5
-class MODIFIERS {
5
+class MODIFIERS{
6 6
     
7 7
     var $placeholders = array();
8 8
     var $vars = array();
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
         $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';
25 25
     }
26 26
     
27
-    function phxFilter($key,$value,$modifiers)
27
+    function phxFilter($key, $value, $modifiers)
28 28
     {
29 29
         global $modx;
30
-        if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value);
30
+        if (substr($modifiers, 0, 3) !== 'id(') $value = $this->parseDocumentSource($value);
31 31
         $this->srcValue = $value;
32 32
         $modifiers = trim($modifiers);
33
-        $modifiers = ':'.trim($modifiers,':');
34
-        $modifiers = str_replace(array("\r\n","\r"), "\n", $modifiers);
33
+        $modifiers = ':'.trim($modifiers, ':');
34
+        $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers);
35 35
         $modifiers = $this->splitEachModifiers($modifiers);
36 36
         
37 37
         $this->placeholders = array();
@@ -39,117 +39,117 @@  discard block
 block discarded – undo
39 39
         $this->placeholders['dummy'] = '';
40 40
         $this->condition = array();
41 41
         $this->vars = array();
42
-        $this->vars['name']    = & $key;
43
-        $value = $this->parsePhx($key,$value,$modifiers);
42
+        $this->vars['name'] = & $key;
43
+        $value = $this->parsePhx($key, $value, $modifiers);
44 44
         $this->vars = array();
45 45
         return $value;
46 46
     }
47 47
     
48
-    function _getDelim($mode,$modifiers) {
49
-        $c = substr($modifiers,0,1);
50
-        if(!in_array($c, array('"', "'", '`')) ) return false;
48
+    function _getDelim($mode, $modifiers){
49
+        $c = substr($modifiers, 0, 1);
50
+        if (!in_array($c, array('"', "'", '`'))) return false;
51 51
         
52
-        $modifiers = substr($modifiers,1);
53
-        $closure = $mode=='(' ? "{$c})" : $c;
54
-        if(strpos($modifiers, $closure)===false) return false;
52
+        $modifiers = substr($modifiers, 1);
53
+        $closure = $mode == '(' ? "{$c})" : $c;
54
+        if (strpos($modifiers, $closure) === false) return false;
55 55
         
56 56
         return  $c;
57 57
     }
58 58
     
59
-    function _getOpt($mode,$delim,$modifiers) {
60
-        if($delim) {
61
-            if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
59
+    function _getOpt($mode, $delim, $modifiers){
60
+        if ($delim) {
61
+            if ($mode == '(') return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1);
62 62
             
63
-            return substr($modifiers,1,strpos($modifiers,$delim,1)-1);
63
+            return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1);
64 64
         }
65 65
         else {
66
-            if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') );
66
+            if ($mode == '(') return substr($modifiers, 0, strpos($modifiers, ')'));
67 67
             
68 68
             $chars = str_split($modifiers);
69
-            $opt='';
70
-            foreach($chars as $c) {
71
-                if($c==':' || $c==')') break;
72
-                $opt .=$c;
69
+            $opt = '';
70
+            foreach ($chars as $c) {
71
+                if ($c == ':' || $c == ')') break;
72
+                $opt .= $c;
73 73
             }
74 74
             return $opt;
75 75
         }
76 76
     }
77
-    function _getRemainModifiers($mode,$delim,$modifiers) {
78
-        if($delim) {
79
-            if($mode=='(')
80
-                return $this->_fetchContent($modifiers, $delim . ')');
77
+    function _getRemainModifiers($mode, $delim, $modifiers){
78
+        if ($delim) {
79
+            if ($mode == '(')
80
+                return $this->_fetchContent($modifiers, $delim.')');
81 81
             else {
82 82
                 $modifiers = trim($modifiers);
83
-                $modifiers = substr($modifiers,1);
83
+                $modifiers = substr($modifiers, 1);
84 84
                 return $this->_fetchContent($modifiers, $delim);
85 85
             }
86 86
         }
87 87
         else {
88
-            if($mode=='(') return $this->_fetchContent($modifiers, ')');
88
+            if ($mode == '(') return $this->_fetchContent($modifiers, ')');
89 89
             $chars = str_split($modifiers);
90
-            foreach($chars as $c) {
91
-                if($c==':') return $modifiers;
92
-                else $modifiers = substr($modifiers,1);
90
+            foreach ($chars as $c) {
91
+                if ($c == ':') return $modifiers;
92
+                else $modifiers = substr($modifiers, 1);
93 93
             }
94 94
             return $modifiers;
95 95
         }
96 96
     }
97 97
     
98
-    function _fetchContent($string,$delim) {
98
+    function _fetchContent($string, $delim){
99 99
         $len = strlen($delim);
100 100
         $string = $this->parseDocumentSource($string);
101
-        return substr($string,strpos($string, $delim)+$len);
101
+        return substr($string, strpos($string, $delim) + $len);
102 102
     }
103 103
     
104
-    function splitEachModifiers($modifiers) {
104
+    function splitEachModifiers($modifiers){
105 105
         global $modx;
106 106
         
107 107
         $cmd = '';
108 108
         $bt = '';
109
-        while($bt!==$modifiers) {
109
+        while ($bt !== $modifiers) {
110 110
             $bt = $modifiers;
111
-            $c = substr($modifiers,0,1);
112
-            $modifiers = substr($modifiers,1);
111
+            $c = substr($modifiers, 0, 1);
112
+            $modifiers = substr($modifiers, 1);
113 113
             
114
-            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
115
-                $c = substr($modifiers,strlen($match[1]),1);
114
+            if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
115
+                $c = substr($modifiers, strlen($match[1]), 1);
116 116
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
117
-                if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1);
118
-                else         $modifiers = substr($modifiers,strlen($match[1]));
117
+                if ($c === '(') $modifiers = substr($modifiers, strlen($match[1]) + 1);
118
+                else         $modifiers = substr($modifiers, strlen($match[1]));
119 119
                 
120
-                $delim     = $this->_getDelim($c,$modifiers);
121
-                $opt       = $this->_getOpt($c,$delim,$modifiers);
122
-                $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers));
120
+                $delim     = $this->_getDelim($c, $modifiers);
121
+                $opt       = $this->_getOpt($c, $delim, $modifiers);
122
+                $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers));
123 123
                 
124
-                $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
124
+                $result[] = array('cmd'=>trim($match[1]), 'opt'=>$opt, 'debuginfo'=>$debuginfo);
125 125
                 $cmd = '';
126 126
             }
127
-            elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
128
-                $modifiers = substr($modifiers,strlen($match[0]));
129
-                $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]);
127
+            elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
128
+                $modifiers = substr($modifiers, strlen($match[0]));
129
+                $result[] = array('cmd'=>'math', 'opt'=>'%s'.$c.$match[0]);
130 130
                 $cmd = '';
131 131
             }
132
-            elseif($c==='(' || $c==='=') {
132
+            elseif ($c === '(' || $c === '=') {
133 133
                 $modifiers = $m1 = trim($modifiers);
134
-                $delim     = $this->_getDelim($c,$modifiers);
135
-                $opt       = $this->_getOpt($c,$delim,$modifiers);
136
-                $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers));
134
+                $delim     = $this->_getDelim($c, $modifiers);
135
+                $opt       = $this->_getOpt($c, $delim, $modifiers);
136
+                $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers));
137 137
                 $debuginfo = "#i=1 #c=[{$c}] #delim=[{$delim}] #m1=[{$m1}] remainMdf=[{$modifiers}]";
138 138
                 
139
-                $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo);
139
+                $result[] = array('cmd'=>trim($cmd), 'opt'=>$opt, 'debuginfo'=>$debuginfo);
140 140
                 
141 141
                 $cmd = '';
142 142
             }
143
-            elseif($c==':') {
143
+            elseif ($c == ':') {
144 144
                 $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]";
145
-                if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
145
+                if ($cmd !== '') $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo);
146 146
                 
147 147
                 $cmd = '';
148 148
             }
149
-            elseif(trim($modifiers)=='' && trim($cmd)!=='') {
149
+            elseif (trim($modifiers) == '' && trim($cmd) !== '') {
150 150
                 $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]";
151 151
                 $cmd .= $c;
152
-                $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
152
+                $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo);
153 153
                 
154 154
                 break;
155 155
             }
@@ -158,64 +158,64 @@  discard block
 block discarded – undo
158 158
             }
159 159
         }
160 160
         
161
-        if(empty($result)) return array();
161
+        if (empty($result)) return array();
162 162
         
163
-        foreach($result as $i=>$a)
163
+        foreach ($result as $i=>$a)
164 164
         {
165 165
             $a['opt'] = $this->parseDocumentSource($a['opt']);
166
-            $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders);
166
+            $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'], $this->placeholders);
167 167
         }
168 168
         
169 169
         return $result;
170 170
     }
171 171
     
172
-    function parsePhx($key,$value,$modifiers)
172
+    function parsePhx($key, $value, $modifiers)
173 173
     {
174 174
         global $modx;
175
-        $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true)));
176
-        if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
177
-        if(empty($modifiers)) return '';
175
+        $cacheKey = md5(sprintf('parsePhx#%s#%s#%s', $key, $value, print_r($modifiers, true)));
176
+        if (isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
177
+        if (empty($modifiers)) return '';
178 178
         
179
-        foreach($modifiers as $m)
179
+        foreach ($modifiers as $m)
180 180
         {
181 181
             $lastKey = strtolower($m['cmd']);
182 182
         }
183
-        $_ = explode(',',$this->condModifiers);
184
-        if(in_array($lastKey,$_))
183
+        $_ = explode(',', $this->condModifiers);
184
+        if (in_array($lastKey, $_))
185 185
         {
186
-            $modifiers[] = array('cmd'=>'then','opt'=>'1');
187
-            $modifiers[] = array('cmd'=>'else','opt'=>'0');
186
+            $modifiers[] = array('cmd'=>'then', 'opt'=>'1');
187
+            $modifiers[] = array('cmd'=>'else', 'opt'=>'0');
188 188
         }
189 189
         
190
-        foreach($modifiers as $i=>$a)
190
+        foreach ($modifiers as $i=>$a)
191 191
         {
192
-            $value = $this->Filter($key,$value, $a['cmd'], $a['opt']);
192
+            $value = $this->Filter($key, $value, $a['cmd'], $a['opt']);
193 193
         }
194 194
         $this->tmpCache[$cacheKey] = $value;
195 195
         return $value;
196 196
     }
197 197
     
198 198
     // Parser: modifier detection and eXtended processing if needed
199
-    function Filter($key, $value, $cmd, $opt='')
199
+    function Filter($key, $value, $cmd, $opt = '')
200 200
     {
201 201
         global $modx;
202 202
         
203
-        if($key==='documentObject') $value = $modx->documentIdentifier;
203
+        if ($key === 'documentObject') $value = $modx->documentIdentifier;
204 204
         $cmd = $this->parseDocumentSource($cmd);
205
-        if(preg_match('@^[1-9][/0-9]*$@',$cmd))
205
+        if (preg_match('@^[1-9][/0-9]*$@', $cmd))
206 206
         {
207
-            if(strpos($cmd,'/')!==false)
208
-                $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
207
+            if (strpos($cmd, '/') !== false)
208
+                $cmd = $this->substr($cmd, strrpos($cmd, '/') + 1);
209 209
             $opt = $cmd;
210 210
             $cmd = 'id';
211 211
         }
212 212
         
213
-        if(isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
214
-        elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
213
+        if (isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
214
+        elseif (isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
215 215
         else                                           $this->elmName = '';
216 216
         
217 217
         $cmd = strtolower($cmd);
218
-        if($this->elmName!=='')
218
+        if ($this->elmName !== '')
219 219
             $value = $this->getValueFromElement($key, $value, $cmd, $opt);
220 220
         else
221 221
             $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
         return $value;
226 226
     }
227 227
     
228
-    function isEmpty($cmd,$value)
228
+    function isEmpty($cmd, $value)
229 229
     {
230
-        if($value!=='') return false;
230
+        if ($value !== '') return false;
231 231
         
232
-        $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
233
-        if(in_array($cmd,$_)) return false;
232
+        $_ = explode(',', $this->condModifiers.',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
233
+        if (in_array($cmd, $_)) return false;
234 234
         else                  return true;
235 235
     }
236 236
     
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     {
239 239
         global $modx;
240 240
         
241
-        if($this->isEmpty($cmd,$value)) return '';
241
+        if ($this->isEmpty($cmd, $value)) return '';
242 242
         
243 243
         $this->key = $key;
244 244
         $this->value  = $value;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
             #####  Conditional Modifiers 
250 250
             case 'input':
251 251
             case 'if':
252
-                if(!$opt) return $value;
252
+                if (!$opt) return $value;
253 253
                 return $opt;
254 254
             case '=':
255 255
             case 'eq':
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
             case 'isnot':
263 263
             case 'isnt':
264 264
             case 'not':
265
-                $this->condition[] = intval($value != $opt);break;
265
+                $this->condition[] = intval($value != $opt); break;
266 266
             case '%':
267
-                $this->condition[] = intval($value%$opt==0);break;
267
+                $this->condition[] = intval($value % $opt == 0); break;
268 268
             case 'isempty':
269 269
                 $this->condition[] = intval(empty($value)); break;
270 270
             case 'isntempty':
@@ -274,57 +274,57 @@  discard block
 block discarded – undo
274 274
             case 'gte':
275 275
             case 'eg':
276 276
             case 'isgte':
277
-                $this->condition[] = intval($value >= $opt);break;
277
+                $this->condition[] = intval($value >= $opt); break;
278 278
             case '<=':
279 279
             case 'lte':
280 280
             case 'el':
281 281
             case 'islte':
282
-                $this->condition[] = intval($value <= $opt);break;
282
+                $this->condition[] = intval($value <= $opt); break;
283 283
             case '>':
284 284
             case 'gt':
285 285
             case 'greaterthan':
286 286
             case 'isgreaterthan':
287 287
             case 'isgt':
288
-                $this->condition[] = intval($value > $opt);break;
288
+                $this->condition[] = intval($value > $opt); break;
289 289
             case '<':
290 290
             case 'lt':
291 291
             case 'lowerthan':
292 292
             case 'islowerthan':
293 293
             case 'islt':
294
-                $this->condition[] = intval($value < $opt);break;
294
+                $this->condition[] = intval($value < $opt); break;
295 295
             case 'find':
296
-                $this->condition[] = intval(strpos($value, $opt)!==false);break;
296
+                $this->condition[] = intval(strpos($value, $opt) !== false); break;
297 297
             case 'inarray':
298 298
             case 'in_array':
299 299
             case 'in':
300 300
                 $opt = explode(',', $opt);
301
-                $this->condition[] = intval(in_array($value, $opt)!==false);break;
301
+                $this->condition[] = intval(in_array($value, $opt) !== false); break;
302 302
             case 'wildcard_match':
303 303
             case 'wcard_match':
304 304
             case 'wildcard':
305 305
             case 'wcard':
306 306
             case 'fnmatch':
307
-                $this->condition[] = intval(fnmatch($opt, $value)!==false);break;
307
+                $this->condition[] = intval(fnmatch($opt, $value) !== false); break;
308 308
             case 'is_file':
309 309
             case 'is_dir':
310 310
             case 'file_exists':
311 311
             case 'is_readable':
312 312
             case 'is_writable':
313
-                if(!$opt) $path = $value;
313
+                if (!$opt) $path = $value;
314 314
                 else      $path = $opt;
315
-                if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path');
316
-                if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/');
317
-                $this->condition[] = intval($cmd($path)!==false);break;
315
+                if (strpos($path, MODX_MANAGER_PATH) !== false) exit('Can not read core path');
316
+                if (strpos($path, $modx->config['base_path']) === false) $path = ltrim($path, '/');
317
+                $this->condition[] = intval($cmd($path) !== false); break;
318 318
             case 'is_image':
319
-                if(!$opt) $path = $value;
319
+                if (!$opt) $path = $value;
320 320
                 else      $path = $opt;
321
-                if(!is_file($path)) {$this->condition[]='0';break;}
321
+                if (!is_file($path)) {$this->condition[] = '0'; break; }
322 322
                 $_ = getimagesize($path);
323
-                $this->condition[] = intval($_[0]);break;
323
+                $this->condition[] = intval($_[0]); break;
324 324
             case 'regex':
325 325
             case 'preg':
326 326
             case 'preg_match':
327
-                $this->condition[] = intval(preg_match($opt,$value));break;
327
+                $this->condition[] = intval(preg_match($opt, $value)); break;
328 328
             case 'isinrole':
329 329
             case 'ir':
330 330
             case 'memberof':
@@ -333,50 +333,50 @@  discard block
 block discarded – undo
333 333
                 $this->condition[] = $this->includeMdfFile('memberof');
334 334
                 break;
335 335
             case 'or':
336
-                $this->condition[] = '||';break;
336
+                $this->condition[] = '||'; break;
337 337
             case 'and':
338
-                $this->condition[] = '&&';break;
338
+                $this->condition[] = '&&'; break;
339 339
             case 'show':
340 340
             case 'this':
341
-                $conditional = join(' ',$this->condition);
341
+                $conditional = join(' ', $this->condition);
342 342
                 $isvalid = intval(eval("return ({$conditional});"));
343 343
                 if ($isvalid) return $this->srcValue;
344 344
                 return NULL;
345 345
             case 'then':
346
-                $conditional = join(' ',$this->condition);
346
+                $conditional = join(' ', $this->condition);
347 347
                 $isvalid = intval(eval("return ({$conditional});"));
348 348
                 if ($isvalid)  return $opt;
349 349
                 return null;
350 350
             case 'else':
351
-                $conditional = join(' ',$this->condition);
351
+                $conditional = join(' ', $this->condition);
352 352
                 $isvalid = intval(eval("return ({$conditional});"));
353 353
                 if (!$isvalid) return $opt;
354 354
                 break;
355 355
             case 'select':
356 356
             case 'switch':
357
-                $raw = explode('&',$opt);
357
+                $raw = explode('&', $opt);
358 358
                 $map = array();
359 359
                 $c = count($raw);
360
-                for($m=0; $m<$c; $m++) {
361
-                    $mi = explode('=',$raw[$m],2);
360
+                for ($m = 0; $m < $c; $m++) {
361
+                    $mi = explode('=', $raw[$m], 2);
362 362
                     $map[$mi[0]] = $mi[1];
363 363
                 }
364
-                if(isset($map[$value])) return $map[$value];
364
+                if (isset($map[$value])) return $map[$value];
365 365
                 else                    return '';
366 366
             ##### End of Conditional Modifiers
367 367
             
368 368
             #####  Encode / Decode / Hash / Escape
369 369
             case 'htmlent':
370 370
             case 'htmlentities':
371
-                return htmlentities($value,ENT_QUOTES,$modx->config['modx_charset']);
371
+                return htmlentities($value, ENT_QUOTES, $modx->config['modx_charset']);
372 372
             case 'html_entity_decode':
373 373
             case 'decode_html':
374 374
             case 'html_decode':
375
-                return html_entity_decode($value,ENT_QUOTES,$modx->config['modx_charset']);
375
+                return html_entity_decode($value, ENT_QUOTES, $modx->config['modx_charset']);
376 376
             case 'esc':
377 377
             case 'escape':
378 378
                 $value = preg_replace('/&amp;(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset']));
379
-                return str_replace(array('[', ']', '`'),array('&#91;', '&#93;', '&#96;'),$value);
379
+                return str_replace(array('[', ']', '`'), array('&#91;', '&#93;', '&#96;'), $value);
380 380
             case 'sql_escape':
381 381
             case 'encode_js':
382 382
                 return $modx->db->escape($value);
@@ -386,39 +386,39 @@  discard block
 block discarded – undo
386 386
             case 'html_encode':
387 387
                 return preg_replace('/&amp;(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset']));
388 388
             case 'spam_protect':
389
-                return str_replace(array('@','.'),array('&#64;','&#46;'),$value);
389
+                return str_replace(array('@', '.'), array('&#64;', '&#46;'), $value);
390 390
             case 'strip':
391
-                if($opt==='') $opt = ' ';
391
+                if ($opt === '') $opt = ' ';
392 392
                 return preg_replace('/[\n\r\t\s]+/', $opt, $value);
393 393
             case 'strip_linefeeds':
394
-                return str_replace(array("\n","\r"), '', $value);
394
+                return str_replace(array("\n", "\r"), '', $value);
395 395
             case 'notags':
396 396
             case 'strip_tags':
397 397
             case 'remove_html':
398
-                if($opt!=='')
398
+                if ($opt !== '')
399 399
                 {
400 400
                     $param = array();
401
-                    foreach(explode(',',$opt) as $v)
401
+                    foreach (explode(',', $opt) as $v)
402 402
                     {
403
-                        $v = trim($v,'</> ');
403
+                        $v = trim($v, '</> ');
404 404
                         $param[] = "<{$v}>";
405 405
                     }
406
-                    $params = join(',',$param);
406
+                    $params = join(',', $param);
407 407
                 }
408 408
                 else $params = '';
409
-                if(!strpos($params,'<br>')===false) {
410
-                    $value = preg_replace('@(<br[ /]*>)\n@','$1',$value);
411
-                    $value = preg_replace('@<br[ /]*>@',"\n",$value);
409
+                if (!strpos($params, '<br>') === false) {
410
+                    $value = preg_replace('@(<br[ /]*>)\n@', '$1', $value);
411
+                    $value = preg_replace('@<br[ /]*>@', "\n", $value);
412 412
                 }
413
-                return $this->strip_tags($value,$params);
413
+                return $this->strip_tags($value, $params);
414 414
             case 'urlencode':
415 415
             case 'url_encode':
416 416
             case 'encode_url':
417 417
                 return urlencode($value);
418 418
             case 'base64_decode':
419
-                if($opt!=='false') $opt = true;
419
+                if ($opt !== 'false') $opt = true;
420 420
                 else               $opt = false;
421
-                return base64_decode($value,$opt);
421
+                return base64_decode($value, $opt);
422 422
             case 'encode_sha1': $cmd = 'sha1';
423 423
             case 'addslashes':
424 424
             case 'urldecode':
@@ -442,18 +442,18 @@  discard block
 block discarded – undo
442 442
             case 'upper_case':
443 443
                 return $this->strtoupper($value);
444 444
             case 'capitalize':
445
-                $_ = explode(' ',$value);
446
-                foreach($_ as $i=>$v)
445
+                $_ = explode(' ', $value);
446
+                foreach ($_ as $i=>$v)
447 447
                 {
448 448
                     $_[$i] = ucfirst($v);
449 449
                 }
450
-                return join(' ',$_);
450
+                return join(' ', $_);
451 451
             case 'zenhan':
452
-                if(empty($opt)) $opt='VKas';
453
-                return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
452
+                if (empty($opt)) $opt = 'VKas';
453
+                return mb_convert_kana($value, $opt, $modx->config['modx_charset']);
454 454
             case 'hanzen':
455
-                if(empty($opt)) $opt='VKAS';
456
-                return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
455
+                if (empty($opt)) $opt = 'VKAS';
456
+                return mb_convert_kana($value, $opt, $modx->config['modx_charset']);
457 457
             case 'str_shuffle':
458 458
             case 'shuffle':
459 459
                 return $this->str_shuffle($value);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
                 return $this->strlen($value);
468 468
             case 'count_words':
469 469
                 $value = trim($value);
470
-                return count(preg_split('/\s+/',$value));
470
+                return count(preg_split('/\s+/', $value));
471 471
             case 'str_word_count':
472 472
             case 'word_count':
473 473
             case 'wordcount':
@@ -475,55 +475,55 @@  discard block
 block discarded – undo
475 475
             case 'count_paragraphs':
476 476
                 $value = trim($value);
477 477
                 $value = preg_replace('/\r/', '', $value);
478
-                return count(preg_split('/\n+/',$value));
478
+                return count(preg_split('/\n+/', $value));
479 479
             case 'strpos':
480
-                if($opt!=0&&empty($opt)) return $value;
481
-                return $this->strpos($value,$opt);
480
+                if ($opt != 0 && empty($opt)) return $value;
481
+                return $this->strpos($value, $opt);
482 482
             case 'wordwrap':
483 483
                 // default: 70
484 484
                   $wrapat = intval($opt) ? intval($opt) : 70;
485 485
                 if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap');
486
-                else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
486
+                else return preg_replace("@(\b\w+\b)@e", "wordwrap('\\1',\$wrapat,' ',1)", $value);
487 487
             case 'wrap_text':
488
-                $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70;
489
-                if($modx->config['manager_language']==='japanese-utf8') {
488
+                $width = preg_match('/^[1-9][0-9]*$/', $opt) ? $opt : 70;
489
+                if ($modx->config['manager_language'] === 'japanese-utf8') {
490 490
                     $chunk = array();
491
-                    $bt='';
492
-                    while($bt!=$value) {
491
+                    $bt = '';
492
+                    while ($bt != $value) {
493 493
                         $bt = $value;
494
-                        if($this->strlen($value)<$width) {
494
+                        if ($this->strlen($value) < $width) {
495 495
                             $chunk[] = $value;
496 496
                             break;
497 497
                         }
498
-                        $chunk[] = $this->substr($value,0,$width);
499
-                        $value = $this->substr($value,$width);
498
+                        $chunk[] = $this->substr($value, 0, $width);
499
+                        $value = $this->substr($value, $width);
500 500
                     }
501
-                    return join("\n",$chunk);
501
+                    return join("\n", $chunk);
502 502
                 }
503 503
                 else
504
-                    return wordwrap($value,$width,"\n",true);
504
+                    return wordwrap($value, $width, "\n", true);
505 505
             case 'substr':
506
-                if(empty($opt)) break;
507
-                if(strpos($opt,',')!==false) {
508
-                    list($b,$e) = explode(',',$opt,2);
509
-                    return $this->substr($value,$b,(int)$e);
506
+                if (empty($opt)) break;
507
+                if (strpos($opt, ',') !== false) {
508
+                    list($b, $e) = explode(',', $opt, 2);
509
+                    return $this->substr($value, $b, (int) $e);
510 510
                 }
511
-                else return $this->substr($value,$opt);
511
+                else return $this->substr($value, $opt);
512 512
             case 'limit':
513 513
             case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html
514
-                if(strpos($opt,'+')!==false)
515
-                    list($len,$str) = explode('+',$opt,2);
514
+                if (strpos($opt, '+') !== false)
515
+                    list($len, $str) = explode('+', $opt, 2);
516 516
                 else {
517 517
                     $len = $opt;
518 518
                     $str = '';
519 519
                 }
520
-                if($len==='') $len = 100;
521
-                if(abs($len) > $this->strlen($value)) $str ='';
522
-                if(preg_match('/^[1-9][0-9]*$/',$len)) {
523
-                    return $this->substr($value,0,$len) . $str;
520
+                if ($len === '') $len = 100;
521
+                if (abs($len) > $this->strlen($value)) $str = '';
522
+                if (preg_match('/^[1-9][0-9]*$/', $len)) {
523
+                    return $this->substr($value, 0, $len).$str;
524 524
                 }
525
-                elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
526
-                    return $str . $this->substr($value,$len);
525
+                elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) {
526
+                    return $str.$this->substr($value, $len);
527 527
                 }
528 528
                 break;
529 529
             case 'summary':
@@ -532,81 +532,81 @@  discard block
 block discarded – undo
532 532
                 return $this->includeMdfFile('summary');
533 533
             case 'replace':
534 534
             case 'str_replace':
535
-                if(empty($opt) || strpos($opt,',')===false) break;
536
-                if    (substr_count($opt, ',') ==1) $delim = ',';
537
-                elseif(substr_count($opt, '|') ==1) $delim = '|';
538
-                elseif(substr_count($opt, '=>')==1) $delim = '=>';
539
-                elseif(substr_count($opt, '/') ==1) $delim = '/';
535
+                if (empty($opt) || strpos($opt, ',') === false) break;
536
+                if (substr_count($opt, ',') == 1) $delim = ',';
537
+                elseif (substr_count($opt, '|') == 1) $delim = '|';
538
+                elseif (substr_count($opt, '=>') == 1) $delim = '=>';
539
+                elseif (substr_count($opt, '/') == 1) $delim = '/';
540 540
                 else break;
541
-                list($s,$r) = explode($delim,$opt);
542
-                if($value!=='') return str_replace($s,$r,$value);
541
+                list($s, $r) = explode($delim, $opt);
542
+                if ($value !== '') return str_replace($s, $r, $value);
543 543
                 break;
544 544
             case 'replace_to':
545 545
             case 'tpl':
546
-                if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
546
+                if ($value !== '') return str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $value, $opt);
547 547
                 break;
548 548
             case 'eachtpl':
549
-                $value = explode('||',$value);
549
+                $value = explode('||', $value);
550 550
                 $_ = array();
551
-                foreach($value as $v) {
552
-                    $_[] = str_replace(array('[+value+]','[+output+]','{value}','%s'),$v,$opt);
551
+                foreach ($value as $v) {
552
+                    $_[] = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $v, $opt);
553 553
                 }
554 554
                 return join("\n", $_);
555 555
             case 'array_pop':
556 556
             case 'array_shift':
557
-                if(strpos($value,'||')!==false) $delim = '||';
557
+                if (strpos($value, '||') !== false) $delim = '||';
558 558
                 else                            $delim = ',';
559
-                return $cmd(explode($delim,$value));
559
+                return $cmd(explode($delim, $value));
560 560
             case 'preg_replace':
561 561
             case 'regex_replace':
562
-                if(empty($opt) || strpos($opt,',')===false) break;
563
-                list($s,$r) = explode(',',$opt,2);
564
-                if($value!=='') return preg_replace($s,$r,$value);
562
+                if (empty($opt) || strpos($opt, ',') === false) break;
563
+                list($s, $r) = explode(',', $opt, 2);
564
+                if ($value !== '') return preg_replace($s, $r, $value);
565 565
                 break;
566 566
             case 'cat':
567 567
             case 'concatenate':
568 568
             case '.':
569
-                if($value!=='') return $value . $opt;
569
+                if ($value !== '') return $value.$opt;
570 570
                 break;
571 571
             case 'sprintf':
572 572
             case 'string_format':
573
-                if($value!=='') return sprintf($opt,$value);
573
+                if ($value !== '') return sprintf($opt, $value);
574 574
                 break;
575 575
             case 'number_format':
576
-                    if($opt=='') $opt = 0;
577
-                    return number_format($value,$opt);
576
+                    if ($opt == '') $opt = 0;
577
+                    return number_format($value, $opt);
578 578
             case 'money_format':
579
-                    setlocale(LC_MONETARY,setlocale(LC_TIME,0));
580
-                    if($value!=='') return money_format($opt,(double)$value);
579
+                    setlocale(LC_MONETARY, setlocale(LC_TIME, 0));
580
+                    if ($value !== '') return money_format($opt, (double) $value);
581 581
                     break;
582 582
             case 'tobool':
583 583
                 return boolval($value);
584 584
             case 'nl2lf':
585
-                if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value);
585
+                if ($value !== '') return str_replace(array("\r\n", "\n", "\r"), '\n', $value);
586 586
                 break;
587 587
             case 'br2nl':
588 588
                 return preg_replace('@<br[\s/]*>@i', "\n", $value);
589 589
             case 'nl2br':
590 590
                 if (version_compare(PHP_VERSION, '5.3.0', '<'))
591 591
                     return nl2br($value);
592
-                if($opt!=='')
592
+                if ($opt !== '')
593 593
                 {
594 594
                     $opt = trim($opt);
595 595
                     $opt = strtolower($opt);
596
-                    if($opt==='false') $opt = false;
597
-                    elseif($opt==='0') $opt = false;
596
+                    if ($opt === 'false') $opt = false;
597
+                    elseif ($opt === '0') $opt = false;
598 598
                     else               $opt = true;
599 599
                 }
600
-                elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html')
600
+                elseif (isset($modx->config['mce_element_format']) && $modx->config['mce_element_format'] === 'html')
601 601
                                        $opt = false;
602 602
                 else                   $opt = true;
603
-                return nl2br($value,$opt);
603
+                return nl2br($value, $opt);
604 604
             case 'ltrim':
605 605
             case 'rtrim':
606 606
             case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html
607
-                if($opt==='')
607
+                if ($opt === '')
608 608
                     return $cmd($value);
609
-                else return $cmd($value,$opt);
609
+                else return $cmd($value, $opt);
610 610
             // These are all straight wrappers for PHP functions
611 611
             case 'ucfirst':
612 612
             case 'lcfirst':
@@ -617,16 +617,16 @@  discard block
 block discarded – undo
617 617
             case 'strftime':
618 618
             case 'date':
619 619
             case 'dateformat':
620
-                if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
621
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
622
-                if(strpos($opt,'%')!==false)
623
-                    return strftime($opt,0+$value);
620
+                if (empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
621
+                if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value);
622
+                if (strpos($opt, '%') !== false)
623
+                    return strftime($opt, 0 + $value);
624 624
                 else
625
-                    return date($opt,0+$value);
625
+                    return date($opt, 0 + $value);
626 626
             case 'time':
627
-                if(empty($opt)) $opt = '%H:%M';
628
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
629
-                return strftime($opt,0+$value);
627
+                if (empty($opt)) $opt = '%H:%M';
628
+                if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value);
629
+                return strftime($opt, 0 + $value);
630 630
             case 'strtotime':
631 631
                 return strtotime($value);
632 632
             #####  mathematical function
@@ -635,40 +635,40 @@  discard block
 block discarded – undo
635 635
             case 'tofloat':
636 636
                 return floatval($value);
637 637
             case 'round':
638
-                if(!$opt) $opt = 0;
639
-                return $cmd($value,$opt);
638
+                if (!$opt) $opt = 0;
639
+                return $cmd($value, $opt);
640 640
             case 'max':
641 641
             case 'min':
642
-                return $cmd(explode(',',$value));
642
+                return $cmd(explode(',', $value));
643 643
             case 'floor':
644 644
             case 'ceil':
645 645
             case 'abs':
646 646
                 return $cmd($value);
647 647
             case 'math':
648 648
             case 'calc':
649
-                $value = (int)$value;
650
-                if(empty($value)) $value = '0';
651
-                $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt);
652
-                $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter);
653
-                if(strpos($filter,'?')===false) $filter = "?{$filter}";
654
-                $filter = str_replace('?',$value,$filter);
649
+                $value = (int) $value;
650
+                if (empty($value)) $value = '0';
651
+                $filter = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), '?', $opt);
652
+                $filter = preg_replace('@([a-zA-Z\n\r\t\s])@', '', $filter);
653
+                if (strpos($filter, '?') === false) $filter = "?{$filter}";
654
+                $filter = str_replace('?', $value, $filter);
655 655
                 return eval("return {$filter};");
656 656
             case 'count':
657
-                if($value=='') return 0;
658
-                $value = explode(',',$value);
657
+                if ($value == '') return 0;
658
+                $value = explode(',', $value);
659 659
                 return count($value);
660 660
             case 'sort':
661 661
             case 'rsort':
662
-                if(strpos($value,"\n")!==false) $delim="\n";
662
+                if (strpos($value, "\n") !== false) $delim = "\n";
663 663
                 else $delim = ',';
664
-                $swap = explode($delim,$value);
665
-                if(!$opt) $opt = SORT_REGULAR;
664
+                $swap = explode($delim, $value);
665
+                if (!$opt) $opt = SORT_REGULAR;
666 666
                 else      $opt = constant($opt);
667
-                $cmd($swap,$opt);
668
-                return join($delim,$swap);
667
+                $cmd($swap, $opt);
668
+                return join($delim, $swap);
669 669
             #####  Resource fields
670 670
             case 'id':
671
-                if($opt) return $this->getDocumentObject($opt,$key);
671
+                if ($opt) return $this->getDocumentObject($opt, $key);
672 672
                 break;
673 673
             case 'type':
674 674
             case 'contenttype':
@@ -705,36 +705,36 @@  discard block
 block discarded – undo
705 705
             case 'privatemgr':
706 706
             case 'content_dispo':
707 707
             case 'hidemenu':
708
-                if($cmd==='contenttype') $cmd = 'contentType';
709
-                return $this->getDocumentObject($value,$cmd);
708
+                if ($cmd === 'contenttype') $cmd = 'contentType';
709
+                return $this->getDocumentObject($value, $cmd);
710 710
             case 'title':
711
-                $pagetitle = $this->getDocumentObject($value,'pagetitle');
712
-                $longtitle = $this->getDocumentObject($value,'longtitle');
711
+                $pagetitle = $this->getDocumentObject($value, 'pagetitle');
712
+                $longtitle = $this->getDocumentObject($value, 'longtitle');
713 713
                 return $longtitle ? $longtitle : $pagetitle;
714 714
             case 'shorttitle':
715
-                $pagetitle = $this->getDocumentObject($value,'pagetitle');
716
-                $menutitle = $this->getDocumentObject($value,'menutitle');
715
+                $pagetitle = $this->getDocumentObject($value, 'pagetitle');
716
+                $menutitle = $this->getDocumentObject($value, 'menutitle');
717 717
                 return $menutitle ? $menutitle : $pagetitle;
718 718
             case 'templatename':
719
-                $rs = $modx->db->select('templatename','[+prefix+]site_templates',"id='{$value}'");
719
+                $rs = $modx->db->select('templatename', '[+prefix+]site_templates', "id='{$value}'");
720 720
                 $templateName = $modx->db->getValue($rs);
721 721
                 return !$templateName ? '(blank)' : $templateName;
722 722
             case 'getfield':
723
-                if(!$opt) $opt = 'content';
724
-                return $modx->getField($opt,$value);
723
+                if (!$opt) $opt = 'content';
724
+                return $modx->getField($opt, $value);
725 725
             case 'children':
726 726
             case 'childids':
727
-                if($value=='') $value = 0; // 値がない場合はルートと見なす
727
+                if ($value == '') $value = 0; // 値がない場合はルートと見なす
728 728
                 $published = 1;
729
-                if($opt=='') $opt = 'page';
730
-                $_ = explode(',',$opt);
729
+                if ($opt == '') $opt = 'page';
730
+                $_ = explode(',', $opt);
731 731
                 $where = array();
732
-                foreach($_ as $opt) {
733
-                    switch(trim($opt)) {
732
+                foreach ($_ as $opt) {
733
+                    switch (trim($opt)) {
734 734
                         case 'page'; case '!folder'; case '!isfolder': $where[] = 'sc.isfolder=0'; break;
735 735
                         case 'folder'; case 'isfolder':                $where[] = 'sc.isfolder=1'; break;
736
-                        case  'menu';  case  'show_menu':              $where[] = 'sc.hidemenu=0'; break;
737
-                        case '!menu';  case '!show_menu':              $where[] = 'sc.hidemenu=1'; break;
736
+                        case  'menu'; case  'show_menu':              $where[] = 'sc.hidemenu=0'; break;
737
+                        case '!menu'; case '!show_menu':              $where[] = 'sc.hidemenu=1'; break;
738 738
                         case  'published':                             $published = 1; break;
739 739
                         case '!published':                             $published = 0; break;
740 740
                     }
@@ -742,69 +742,69 @@  discard block
 block discarded – undo
742 742
                 $where = join(' AND ', $where);
743 743
                 $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where);
744 744
                 $result = array();
745
-                foreach((array)$children as $child){
745
+                foreach ((array) $children as $child) {
746 746
                     $result[] = $child['id'];
747 747
                 }
748 748
                 return join(',', $result);
749 749
             case 'fullurl':
750
-                if(!is_numeric($value)) return $value;
750
+                if (!is_numeric($value)) return $value;
751 751
                 return $modx->makeUrl($value);
752 752
             case 'makeurl':
753
-                if(!is_numeric($value)) return $value;
754
-                if(!$opt) $opt = 'full';
755
-                return $modx->makeUrl($value,'','',$opt);
753
+                if (!is_numeric($value)) return $value;
754
+                if (!$opt) $opt = 'full';
755
+                return $modx->makeUrl($value, '', '', $opt);
756 756
                 
757 757
             #####  File system
758 758
             case 'getimageinfo':
759 759
             case 'imageinfo':
760
-                if(!is_file($value)) return '';
760
+                if (!is_file($value)) return '';
761 761
                 $_ = getimagesize($value);
762
-                if(!$_[0]) return '';
762
+                if (!$_[0]) return '';
763 763
                 $info['width']  = $_[0];
764 764
                 $info['height'] = $_[1];
765
-                if    ($_[0] > $_[1]) $info['aspect'] = 'landscape';
766
-                elseif($_[0] < $_[1]) $info['aspect'] = 'portrait';
765
+                if ($_[0] > $_[1]) $info['aspect'] = 'landscape';
766
+                elseif ($_[0] < $_[1]) $info['aspect'] = 'portrait';
767 767
                 else                  $info['aspect'] = 'square';
768
-                switch($_[2]) {
768
+                switch ($_[2]) {
769 769
                     case IMAGETYPE_GIF  : $info['type'] = 'gif'; break;
770 770
                     case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break;
771 771
                     case IMAGETYPE_PNG  : $info['type'] = 'png'; break;
772 772
                     default             : $info['type'] = 'unknown';
773 773
                 }
774 774
                 $info['attrib'] = $_[3];
775
-                switch($opt) {
775
+                switch ($opt) {
776 776
                     case 'width' : return $info['width'];
777 777
                     case 'height': return $info['height'];
778 778
                     case 'aspect': return $info['aspect'];
779 779
                     case 'type'  : return $info['type'];
780 780
                     case 'attrib': return $info['attrib'];
781
-                    default      : return print_r($info,true);
781
+                    default      : return print_r($info, true);
782 782
                 }
783 783
             
784 784
             case 'file_get_contents':
785 785
             case 'readfile':
786
-                if(!is_file($value)) return $value;
786
+                if (!is_file($value)) return $value;
787 787
                 $value = realpath($value);
788
-                if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file');
789
-                $ext = strtolower(substr($value,-4));
790
-                if($ext==='.php') exit('Can not read php file');
791
-                if($ext==='.cgi') exit('Can not read cgi file');
788
+                if (strpos($value, MODX_MANAGER_PATH) !== false) exit('Can not read core file');
789
+                $ext = strtolower(substr($value, -4));
790
+                if ($ext === '.php') exit('Can not read php file');
791
+                if ($ext === '.cgi') exit('Can not read cgi file');
792 792
                 return file_get_contents($value);
793 793
             case 'filesize':
794
-                if($value == '') return '';
794
+                if ($value == '') return '';
795 795
                 $filename = $value;
796 796
                 
797 797
                 $site_url = $modx->config['site_url'];
798
-                if(strpos($filename,$site_url) === 0)
799
-                    $filename = substr($filename,0,strlen($site_url));
800
-                $filename = trim($filename,'/');
798
+                if (strpos($filename, $site_url) === 0)
799
+                    $filename = substr($filename, 0, strlen($site_url));
800
+                $filename = trim($filename, '/');
801 801
                 
802
-                $opt = trim($opt,'/');
803
-                if($opt!=='') $opt .= '/';
802
+                $opt = trim($opt, '/');
803
+                if ($opt !== '') $opt .= '/';
804 804
                 
805 805
                 $filename = MODX_BASE_PATH.$opt.$filename;
806 806
                 
807
-                if(is_file($filename)){
807
+                if (is_file($filename)) {
808 808
                     clearstatcache();
809 809
                     $size = filesize($filename);
810 810
                     return $size;
@@ -837,10 +837,10 @@  discard block
 block discarded – undo
837 837
                 $this->opt = $cmd;
838 838
                 return $this->includeMdfFile('moduser');
839 839
             case 'userinfo':
840
-                if(empty($opt)) $this->opt = 'username';
840
+                if (empty($opt)) $this->opt = 'username';
841 841
                 return $this->includeMdfFile('moduser');
842 842
             case 'webuserinfo':
843
-                if(empty($opt)) $this->opt = 'username';
843
+                if (empty($opt)) $this->opt = 'username';
844 844
                 $this->value = -$value;
845 845
                 return $this->includeMdfFile('moduser');
846 846
             #####  Special functions 
@@ -851,28 +851,28 @@  discard block
 block discarded – undo
851 851
             case 'ifnotempty':
852 852
                 if (!empty($value)) return $opt; break;
853 853
             case 'datagrid':
854
-                include_once(MODX_CORE_PATH . 'controls/datagrid.class.php');
854
+                include_once(MODX_CORE_PATH.'controls/datagrid.class.php');
855 855
                 $grd = new DataGrid();
856 856
                 $grd->ds = trim($value);
857 857
                 $grd->itemStyle = '';
858 858
                 $grd->altItemStyle = '';
859
-                $pos = strpos($value,"\n");
860
-                if($pos) $_ = substr($value,0,$pos);
859
+                $pos = strpos($value, "\n");
860
+                if ($pos) $_ = substr($value, 0, $pos);
861 861
                 else $_ = $pos;
862
-                $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ',';
862
+                $grd->cdelim = strpos($_, "\t") !== false ? 'tab' : ',';
863 863
                 return $grd->render();
864 864
             case 'rotate':
865 865
             case 'evenodd':
866
-                if(strpos($opt,',')===false) $opt = 'odd,even';
866
+                if (strpos($opt, ',') === false) $opt = 'odd,even';
867 867
                 $_ = explode(',', $opt);
868 868
                 $c = count($_);
869 869
                 $i = $value + $c;
870 870
                 $i = $i % $c;
871 871
                 return $_[$i];
872 872
             case 'takeval':
873
-                $arr = explode(",",$opt);
873
+                $arr = explode(",", $opt);
874 874
                 $idx = $value;
875
-                if(!is_numeric($idx)) return $value;
875
+                if (!is_numeric($idx)) return $value;
876 876
                 return $arr[$idx];
877 877
             case 'getimage':
878 878
                 return $this->includeMdfFile('getimage');
@@ -880,17 +880,17 @@  discard block
 block discarded – undo
880 880
                     return $modx->nicesize($value);
881 881
             case 'googlemap':
882 882
             case 'googlemaps':
883
-                if(empty($opt)) $opt = 'border:none;width:500px;height:350px;';
883
+                if (empty($opt)) $opt = 'border:none;width:500px;height:350px;';
884 884
                 $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>';
885 885
                 $ph['style'] = $opt;
886 886
                 $ph['value'] = $value;
887
-                return $modx->parseText($tpl,$ph);
887
+                return $modx->parseText($tpl, $ph);
888 888
             case 'youtube':
889 889
             case 'youtube16x9':
890
-                if(empty($opt)) $opt = 560;
891
-                $h = round($opt*0.5625);
890
+                if (empty($opt)) $opt = 560;
891
+                $h = round($opt * 0.5625);
892 892
                 $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>';
893
-                return sprintf($tpl,$opt,$h,$value);
893
+                return sprintf($tpl, $opt, $h, $value);
894 894
             //case 'youtube4x3':%s*0.75+25
895 895
             case 'setvar':
896 896
                 $modx->placeholders[$opt] = $value;
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
         return $value;
921 921
     }
922 922
 
923
-    function includeMdfFile($cmd) {
923
+    function includeMdfFile($cmd){
924 924
         global $modx;
925 925
         $key = $this->key;
926 926
         $value  = $this->value;
@@ -931,54 +931,54 @@  discard block
 block discarded – undo
931 931
     function getValueFromElement($key, $value, $cmd, $opt)
932 932
     {
933 933
         global $modx;
934
-        if( isset($modx->snippetCache[$this->elmName]) )
934
+        if (isset($modx->snippetCache[$this->elmName]))
935 935
         {
936 936
             $php = $modx->snippetCache[$this->elmName];
937 937
         }
938 938
         else
939 939
         {
940 940
             $esc_elmName = $modx->db->escape($this->elmName);
941
-            $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'");
941
+            $result = $modx->db->select('snippet', '[+prefix+]site_snippets', "name='{$esc_elmName}'");
942 942
             $total = $modx->db->getRecordCount($result);
943
-            if($total == 1)
943
+            if ($total == 1)
944 944
             {
945 945
                 $row = $modx->db->getRow($result);
946 946
                 $php = $row['snippet'];
947 947
             }
948
-            elseif($total == 0)
948
+            elseif ($total == 0)
949 949
             {
950 950
                 $assets_path = MODX_BASE_PATH.'assets/';
951
-                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
951
+                if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
952 952
                     $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
953
-                elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
953
+                elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
954 954
                     $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
955
-                elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
955
+                elseif (is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
956 956
                     $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
957 957
                 else $modifiers_path = false;
958 958
                 
959
-                if($modifiers_path) {
959
+                if ($modifiers_path) {
960 960
                     $php = @file_get_contents($modifiers_path);
961 961
                     $php = trim($php);
962
-                    if(substr($php,0,5)==='<?php') $php = substr($php,6);
963
-                    if(substr($php,0,2)==='<?')    $php = substr($php,3);
964
-                    if(substr($php,-2)==='?>')     $php = substr($php,0,-2);
965
-                    if($this->elmName!=='')
962
+                    if (substr($php, 0, 5) === '<?php') $php = substr($php, 6);
963
+                    if (substr($php, 0, 2) === '<?')    $php = substr($php, 3);
964
+                    if (substr($php, -2) === '?>')     $php = substr($php, 0, -2);
965
+                    if ($this->elmName !== '')
966 966
                         $modx->snippetCache[$this->elmName.'Props'] = '';
967 967
                 }
968 968
                 else
969 969
                     $php = false;
970 970
             }
971 971
             else $php = false;
972
-            if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php;
972
+            if ($this->elmName !== '') $modx->snippetCache[$this->elmName] = $php;
973 973
         }
974
-        if($php==='') $php=false;
974
+        if ($php === '') $php = false;
975 975
         
976
-        if($php===false) $html = $modx->getChunk($this->elmName);
976
+        if ($php === false) $html = $modx->getChunk($this->elmName);
977 977
         else             $html = false;
978 978
 
979 979
         $self = '[+output+]';
980 980
         
981
-        if($php !== false)
981
+        if ($php !== false)
982 982
         {
983 983
             ob_start();
984 984
             $options = $opt;
@@ -991,71 +991,71 @@  discard block
 block discarded – undo
991 991
             $this->vars['options'] = & $opt;
992 992
             $custom = eval($php);
993 993
             $msg = ob_get_contents();
994
-            if($value===$this->bt) $value = $msg . $custom;
994
+            if ($value === $this->bt) $value = $msg.$custom;
995 995
             ob_end_clean();
996 996
         }
997
-        elseif($html!==false && isset($value) && $value!=='')
997
+        elseif ($html !== false && isset($value) && $value !== '')
998 998
         {
999
-            $html = str_replace(array($self,'[+value+]'), $value, $html);
1000
-            $value = str_replace(array('[+options+]','[+param+]'), $opt, $html);
999
+            $html = str_replace(array($self, '[+value+]'), $value, $html);
1000
+            $value = str_replace(array('[+options+]', '[+param+]'), $opt, $html);
1001 1001
         }
1002 1002
         else return false;
1003 1003
         
1004
-        if($php===false && $html===false && $value!==''
1005
-           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false))
1004
+        if ($php === false && $html === false && $value !== ''
1005
+           && (strpos($cmd, '[+value+]') !== false || strpos($cmd, $self) !== false))
1006 1006
         {
1007
-            $value = str_replace(array('[+value+]',$self),$value,$cmd);
1007
+            $value = str_replace(array('[+value+]', $self), $value, $cmd);
1008 1008
         }
1009 1009
         return $value;
1010 1010
     }
1011 1011
     
1012
-    function parseDocumentSource($content='')
1012
+    function parseDocumentSource($content = '')
1013 1013
     {
1014 1014
         global $modx;
1015 1015
         
1016
-        if(strpos($content,'[')===false && strpos($content,'{')===false) return $content;
1016
+        if (strpos($content, '[') === false && strpos($content, '{') === false) return $content;
1017 1017
         
1018
-        if(!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1019
-        $bt='';
1020
-        $i=0;
1021
-        while($bt!==$content)
1018
+        if (!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1019
+        $bt = '';
1020
+        $i = 0;
1021
+        while ($bt !== $content)
1022 1022
         {
1023 1023
             $bt = $content;
1024
-            if(strpos($content,'[*')!==false && $modx->documentIdentifier)
1024
+            if (strpos($content, '[*') !== false && $modx->documentIdentifier)
1025 1025
                                               $content = $modx->mergeDocumentContent($content);
1026
-            if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content);
1027
-            if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content);
1028
-            if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1029
-            if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content);
1026
+            if (strpos($content, '[(') !== false) $content = $modx->mergeSettingsContent($content);
1027
+            if (strpos($content, '{{') !== false) $content = $modx->mergeChunkContent($content);
1028
+            if (strpos($content, '[!') !== false) $content = str_replace(array('[!', '!]'), array('[[', ']]'), $content);
1029
+            if (strpos($content, '[[') !== false) $content = $modx->evalSnippets($content);
1030 1030
             
1031
-            if($content===$bt)              break;
1032
-            if($modx->maxParserPasses < $i) break;
1031
+            if ($content === $bt)              break;
1032
+            if ($modx->maxParserPasses < $i) break;
1033 1033
             $i++;
1034 1034
         }
1035 1035
         return $content;
1036 1036
     }
1037 1037
     
1038
-    function getDocumentObject($target='',$field='pagetitle')
1038
+    function getDocumentObject($target = '', $field = 'pagetitle')
1039 1039
     {
1040 1040
         global $modx;
1041 1041
         
1042 1042
         $target = trim($target);
1043
-        if(empty($target)) $target = $modx->config['site_start'];
1044
-        if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id';
1043
+        if (empty($target)) $target = $modx->config['site_start'];
1044
+        if (preg_match('@^[1-9][0-9]*$@', $target)) $method = 'id';
1045 1045
         else $method = 'alias';
1046 1046
 
1047
-        if(!isset($this->documentObject[$target]))
1047
+        if (!isset($this->documentObject[$target]))
1048 1048
         {
1049
-            $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct');
1049
+            $this->documentObject[$target] = $modx->getDocumentObject($method, $target, 'direct');
1050 1050
         }
1051 1051
         
1052
-        if($this->documentObject[$target]['publishedon']==='0')
1052
+        if ($this->documentObject[$target]['publishedon'] === '0')
1053 1053
             return '';
1054
-        elseif(isset($this->documentObject[$target][$field]))
1054
+        elseif (isset($this->documentObject[$target][$field]))
1055 1055
         {
1056
-            if(is_array($this->documentObject[$target][$field]))
1056
+            if (is_array($this->documentObject[$target][$field]))
1057 1057
             {
1058
-                $a = $modx->getTemplateVarOutput($field,$target);
1058
+                $a = $modx->getTemplateVarOutput($field, $target);
1059 1059
                 $this->documentObject[$target][$field] = $a[$field];
1060 1060
             }
1061 1061
         }
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
         return $this->documentObject[$target][$field];
1065 1065
     }
1066 1066
     
1067
-    function setPlaceholders($value = '', $key = '', $path = '') {
1068
-        if($path!=='') $key = "{$path}.{$key}";
1067
+    function setPlaceholders($value = '', $key = '', $path = ''){
1068
+        if ($path !== '') $key = "{$path}.{$key}";
1069 1069
         if (is_array($value)) {
1070 1070
             foreach ($value as $subkey => $subval) {
1071 1071
                 $this->setPlaceholders($subval, $subkey, $key);
@@ -1075,77 +1075,77 @@  discard block
 block discarded – undo
1075 1075
     }
1076 1076
     
1077 1077
     // Sets a placeholder variable which can only be access by Modifiers
1078
-    function setModifiersVariable($key, $value) {
1078
+    function setModifiersVariable($key, $value){
1079 1079
         if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1080 1080
     }
1081 1081
     
1082 1082
     //mbstring
1083
-    function substr($str, $s, $l = null) {
1083
+    function substr($str, $s, $l = null){
1084 1084
         global $modx;
1085
-        if(is_null($l)) $l = $this->strlen($str);
1085
+        if (is_null($l)) $l = $this->strlen($str);
1086 1086
         if (function_exists('mb_substr'))
1087 1087
         {
1088
-            if(strpos($str,"\r")!==false)
1089
-                $str = str_replace(array("\r\n","\r"), "\n", $str);
1088
+            if (strpos($str, "\r") !== false)
1089
+                $str = str_replace(array("\r\n", "\r"), "\n", $str);
1090 1090
             return mb_substr($str, $s, $l, $modx->config['modx_charset']);
1091 1091
         }
1092 1092
         return substr($str, $s, $l);
1093 1093
     }
1094
-    function strpos($haystack,$needle,$offset=0) {
1094
+    function strpos($haystack, $needle, $offset = 0){
1095 1095
         global $modx;
1096
-        if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1097
-        return strpos($haystack,$needle,$offset);
1096
+        if (function_exists('mb_strpos')) return mb_strpos($haystack, $needle, $offset, $modx->config['modx_charset']);
1097
+        return strpos($haystack, $needle, $offset);
1098 1098
     }
1099
-    function strlen($str) {
1099
+    function strlen($str){
1100 1100
         global $modx;
1101
-        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1101
+        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str), $modx->config['modx_charset']);
1102 1102
         return strlen($str);
1103 1103
     }
1104
-    function strtolower($str) {
1104
+    function strtolower($str){
1105 1105
         if (function_exists('mb_strtolower')) return mb_strtolower($str);
1106 1106
         return strtolower($str);
1107 1107
     }
1108
-    function strtoupper($str) {
1108
+    function strtoupper($str){
1109 1109
         if (function_exists('mb_strtoupper')) return mb_strtoupper($str);
1110 1110
         return strtoupper($str);
1111 1111
     }
1112
-    function ucfirst($str) {
1112
+    function ucfirst($str){
1113 1113
         if (function_exists('mb_strtoupper')) 
1114 1114
             return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1115 1115
         return ucfirst($str);
1116 1116
     }
1117
-    function lcfirst($str) {
1117
+    function lcfirst($str){
1118 1118
         if (function_exists('mb_strtolower')) 
1119 1119
             return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1120 1120
         return lcfirst($str);
1121 1121
     }
1122
-    function ucwords($str) {
1122
+    function ucwords($str){
1123 1123
         if (function_exists('mb_convert_case'))
1124 1124
             return mb_convert_case($str, MB_CASE_TITLE);
1125 1125
         return ucwords($str);
1126 1126
     }
1127
-    function strrev($str) {
1127
+    function strrev($str){
1128 1128
         preg_match_all('/./us', $str, $ar);
1129 1129
         return join(array_reverse($ar[0]));
1130 1130
     }
1131
-    function str_shuffle($str) {
1131
+    function str_shuffle($str){
1132 1132
         preg_match_all('/./us', $str, $ar);
1133 1133
         shuffle($ar[0]);
1134 1134
         return join($ar[0]);
1135 1135
     }
1136
-    function str_word_count($str) {
1137
-        return count(preg_split('~[^\p{L}\p{N}\']+~u',$str));
1136
+    function str_word_count($str){
1137
+        return count(preg_split('~[^\p{L}\p{N}\']+~u', $str));
1138 1138
     }
1139
-    function strip_tags($value,$params='') {
1139
+    function strip_tags($value, $params = ''){
1140 1140
         global $modx;
1141 1141
 
1142
-        if(stripos($params,'style')===false && stripos($value,'</style>')!==false) {
1142
+        if (stripos($params, 'style') === false && stripos($value, '</style>') !== false) {
1143 1143
             $value = preg_replace('@<style.*?>.*?</style>@is', '', $value);
1144 1144
         }
1145
-        if(stripos($params,'script')===false && stripos($value,'</script>')!==false) {
1145
+        if (stripos($params, 'script') === false && stripos($value, '</script>') !== false) {
1146 1146
             $value = preg_replace('@<script.*?>.*?</script>@is', '', $value);        
1147 1147
         }
1148 1148
   
1149
-        return trim(strip_tags($value,$params));
1149
+        return trim(strip_tags($value, $params));
1150 1150
     }
1151 1151
 }
Please login to merge, or discard this patch.
manager/includes/extenders/ex_modxmailer.inc.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@
 block discarded – undo
6 6
  * Time: 14:17
7 7
  */
8 8
 
9
-if (!include_once(MODX_MANAGER_PATH . 'includes/extenders/modxmailer.class.inc.php')){
9
+if (!include_once(MODX_MANAGER_PATH.'includes/extenders/modxmailer.class.inc.php')) {
10 10
     return false;
11
-}else{
11
+} else {
12 12
     $this->mail = new MODxMailer;
13 13
     $this->mail->init($this);
14 14
     return true;
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
 	include_once($autoloader);
51 51
 }
52 52
 
53
-if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
54
-
55
-$base_path = str_replace('\\','/',dirname(__FILE__)) . '/';
56
-if(is_file($base_path . 'assets/cache/siteManager.php'))
57
-    include_once($base_path . 'assets/cache/siteManager.php');
58
-if(!defined('MGR_DIR') && is_dir("{$base_path}manager"))
59
-	define('MGR_DIR','manager');
60
-if(is_file($base_path . 'assets/cache/siteHostnames.php'))
61
-    include_once($base_path . 'assets/cache/siteHostnames.php');
62
-if(!defined('MODX_SITE_HOSTNAMES'))
63
-	define('MODX_SITE_HOSTNAMES','');
53
+if (!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
54
+
55
+$base_path = str_replace('\\', '/', dirname(__FILE__)).'/';
56
+if (is_file($base_path.'assets/cache/siteManager.php'))
57
+    include_once($base_path.'assets/cache/siteManager.php');
58
+if (!defined('MGR_DIR') && is_dir("{$base_path}manager"))
59
+	define('MGR_DIR', 'manager');
60
+if (is_file($base_path.'assets/cache/siteHostnames.php'))
61
+    include_once($base_path.'assets/cache/siteHostnames.php');
62
+if (!defined('MODX_SITE_HOSTNAMES'))
63
+	define('MODX_SITE_HOSTNAMES', '');
64 64
 
65 65
 // get start time
66 66
 $mstart = memory_get_usage();
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 // set some settings, and address some IE issues
72 72
 @ini_set('url_rewriter.tags', '');
73 73
 @ini_set('session.use_trans_sid', 0);
74
-@ini_set('session.use_only_cookies',1);
74
+@ini_set('session.use_only_cookies', 1);
75 75
 session_cache_limiter('');
76 76
 header('P3P: CP="NOI NID ADMa OUR IND UNI COM NAV"'); // header for weird cookie stuff. Blame IE.
77 77
 header('Cache-Control: private, must-revalidate');
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 }
92 92
 
93 93
 // get the required includes
94
-if(!isset($database_user) || $database_user=="") {
94
+if (!isset($database_user) || $database_user == "") {
95 95
 	$rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php');
96 96
 	// Be sure config.inc.php is there and that it contains some important values
97
-	if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) {
97
+	if (!$rt || !$database_type || !$database_server || !$database_user || !$dbase) {
98 98
 		readfile('install/not_installed.tpl');
99 99
 		exit;
100 100
 	}
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 $modx->stopOnNotice = false;
126 126
 
127 127
 // Don't show PHP errors to the public
128
-if(!isset($_SESSION['mgrValidated']) || !$_SESSION['mgrValidated']) {
129
-    @ini_set("display_errors","0");
128
+if (!isset($_SESSION['mgrValidated']) || !$_SESSION['mgrValidated']) {
129
+    @ini_set("display_errors", "0");
130 130
 }
131 131
 
132 132
 // execute the parser if index.php was not included
Please login to merge, or discard this patch.
install/actions/action_summary.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! function_exists('f_owc')){
2
+if (!function_exists('f_owc')) {
3 3
     /**
4 4
      * @param $path
5 5
      * @param $data
@@ -12,30 +12,30 @@  discard block
 block discarded – undo
12 12
             fwrite($hnd, $data);
13 13
             fclose($hnd);
14 14
 
15
-            if(null !== $mode) chmod($path, $mode);
16
-        }catch(Exception $e){
15
+            if (null !== $mode) chmod($path, $mode);
16
+        } catch (Exception $e) {
17 17
             // Nothing, this is NOT normal
18 18
             unset($e);
19 19
         }
20 20
     }
21 21
 }
22 22
 
23
-$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0;
24
-if( ! isset($_lang)) $_lang = array();
23
+$installMode = isset($_POST['installmode']) ? (int) $_POST['installmode'] : 0;
24
+if (!isset($_lang)) $_lang = array();
25 25
 
26 26
 echo '<div class="stepcontainer">
27 27
       <ul class="progressbar">
28
-          <li class="visited">' . $_lang['choose_language'] . '</li>
29
-          <li class="visited">' . $_lang['installation_mode'] . '</li>
30
-          <li class="visited">' . $_lang['optional_items'] . '</li>
31
-          <li class="active">' . $_lang['preinstall_validation'] . '</li>
32
-          <li>' . $_lang['install_results'] . '</li>
28
+          <li class="visited">' . $_lang['choose_language'].'</li>
29
+          <li class="visited">' . $_lang['installation_mode'].'</li>
30
+          <li class="visited">' . $_lang['optional_items'].'</li>
31
+          <li class="active">' . $_lang['preinstall_validation'].'</li>
32
+          <li>' . $_lang['install_results'].'</li>
33 33
   </ul>
34 34
   <div class="clearleft"></div>
35 35
 </div>';
36 36
 
37
-echo '<h2>' . $_lang['preinstall_validation'] . '</h2>';
38
-echo '<h3>' . $_lang['summary_setup_check'] . '</h3>';
37
+echo '<h2>'.$_lang['preinstall_validation'].'</h2>';
38
+echo '<h3>'.$_lang['summary_setup_check'].'</h3>';
39 39
 
40 40
 $errors = 0;
41 41
 
@@ -43,73 +43,73 @@  discard block
 block discarded – undo
43 43
 // check PHP version
44 44
 define('PHP_MIN_VERSION', '5.4.0');
45 45
 $phpMinVersion = PHP_MIN_VERSION; // Maybe not necessary. For backward compatibility
46
-echo '<p>' . $_lang['checking_php_version'];
46
+echo '<p>'.$_lang['checking_php_version'];
47 47
 // -1 if left is less, 0 if equal, +1 if left is higher
48 48
 if (version_compare(phpversion(), PHP_MIN_VERSION) < 0) {
49 49
     $errors++;
50
-    $tmp = $_lang['you_running_php'] . phpversion() . str_replace('[+min_version+]', PHP_MIN_VERSION, $_lang["modx_requires_php"]);
51
-    echo '<span class="notok">' . $_lang['failed'] . '</span>' . $tmp . '</p>';
50
+    $tmp = $_lang['you_running_php'].phpversion().str_replace('[+min_version+]', PHP_MIN_VERSION, $_lang["modx_requires_php"]);
51
+    echo '<span class="notok">'.$_lang['failed'].'</span>'.$tmp.'</p>';
52 52
 } else {
53
-    echo '<span class="ok">' . $_lang['ok'] . '</span></p>';
53
+    echo '<span class="ok">'.$_lang['ok'].'</span></p>';
54 54
 }
55 55
 
56 56
 
57 57
 // check if iconv is available
58
-echo '<p>' . $_lang['checking_iconv'];
58
+echo '<p>'.$_lang['checking_iconv'];
59 59
 $iconv = (int) function_exists('iconv');
60
-if ($iconv == '0'){
61
-    echo '<span class="notok">' . $_lang['failed'].'</span></p><p><strong>'.$_lang['checking_iconv_note'].'</strong></p>';
60
+if ($iconv == '0') {
61
+    echo '<span class="notok">'.$_lang['failed'].'</span></p><p><strong>'.$_lang['checking_iconv_note'].'</strong></p>';
62 62
     $errors++;
63 63
 } else {
64
-    echo '<span class="ok">' . $_lang['ok'] . '</span></p>';
64
+    echo '<span class="ok">'.$_lang['ok'].'</span></p>';
65 65
 }
66 66
 // check sessions
67
-echo '<p>' . $_lang['checking_sessions'];
67
+echo '<p>'.$_lang['checking_sessions'];
68 68
 if ($_SESSION['test'] != 1) {
69
-    echo '<span class="notok">' . $_lang['failed'].  '</span></p>';
69
+    echo '<span class="notok">'.$_lang['failed'].'</span></p>';
70 70
     $errors++;
71 71
 } else {
72
-    echo '<span class="ok">' . $_lang['ok'] . '</span></p>';
72
+    echo '<span class="ok">'.$_lang['ok'].'</span></p>';
73 73
 }
74 74
 
75 75
 
76 76
 // check directories
77 77
 // cache exists?
78
-echo '<p>' . $_lang['checking_if_cache_exist'];
78
+echo '<p>'.$_lang['checking_if_cache_exist'];
79 79
 if (!file_exists("../assets/cache") || !file_exists("../assets/cache/rss")) {
80
-    echo '<span class="notok">' . $_lang['failed'] . '</span></p>';
80
+    echo '<span class="notok">'.$_lang['failed'].'</span></p>';
81 81
     $errors++;
82 82
 } else {
83
-    echo '<span class="ok">' . $_lang['ok'] . '</span></p>';
83
+    echo '<span class="ok">'.$_lang['ok'].'</span></p>';
84 84
 }
85 85
 
86 86
 
87 87
 // cache writable?
88
-echo '<p>' . $_lang['checking_if_cache_writable'];
88
+echo '<p>'.$_lang['checking_if_cache_writable'];
89 89
 if (!is_writable("../assets/cache")) {
90 90
     $errors++;
91
-    echo '<span class="notok">' . $_lang['failed'] . '</span></p>';
91
+    echo '<span class="notok">'.$_lang['failed'].'</span></p>';
92 92
 } else {
93
-    echo '<span class="ok">' . $_lang['ok'] . '</span></p>';
93
+    echo '<span class="ok">'.$_lang['ok'].'</span></p>';
94 94
 }
95 95
 
96 96
 
97 97
 // cache files writable?
98
-echo '<p>' . $_lang['checking_if_cache_file_writable'];
98
+echo '<p>'.$_lang['checking_if_cache_file_writable'];
99 99
 $tmp = "../assets/cache/siteCache.idx.php";
100
-if ( ! file_exists($tmp)) {
100
+if (!file_exists($tmp)) {
101 101
     f_owc($tmp, "<?php //EVO site cache file ?>");
102 102
 }
103
-if ( ! is_writable($tmp)) {
103
+if (!is_writable($tmp)) {
104 104
     $errors++;
105
-    echo '<span class="notok">' . $_lang['failed'] . '</span></p>';
105
+    echo '<span class="notok">'.$_lang['failed'].'</span></p>';
106 106
 } else {
107 107
     echo '<span class="ok">'.$_lang['ok'].'</span></p>';
108 108
 }
109 109
 
110 110
 
111 111
 echo '<p>'.$_lang['checking_if_cache_file2_writable'];
112
-if ( ! is_writable("../assets/cache/sitePublishing.idx.php")) {
112
+if (!is_writable("../assets/cache/sitePublishing.idx.php")) {
113 113
     $errors++;
114 114
     echo '<span class="notok">'.$_lang['failed'].'</span></p>';
115 115
 } else {
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
 // File Browser directories exists?
121 121
 echo '<p>'.$_lang['checking_if_images_exist'];
122
-switch(true){
122
+switch (true) {
123 123
     case !file_exists("../assets/images"):
124 124
     case !file_exists("../assets/files"):
125 125
     case !file_exists("../assets/backup"):
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 // File Browser directories writable?
136 136
 echo '<p>'.$_lang['checking_if_images_writable'];
137
-switch(true){
137
+switch (true) {
138 138
     case !is_writable("../assets/images"):
139 139
     case !is_writable("../assets/files"):
140 140
     case !is_writable("../assets/backup"):
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     $database_charset = substr($database_collation, 0, strpos($database_collation, '_') - 1);
195 195
     $database_connection_charset = $_POST['database_connection_charset'];
196 196
     $database_connection_method = $_POST['database_connection_method'];
197
-    $dbase = '`' . $_POST['database_name'] . '`';
197
+    $dbase = '`'.$_POST['database_name'].'`';
198 198
     $table_prefix = $_POST['tableprefix'];
199 199
 }
200 200
 echo '<p>'.$_lang['creating_database_connection'];
@@ -234,54 +234,54 @@  discard block
 block discarded – undo
234 234
 
235 235
 // check table prefix
236 236
 if ($conn && $installMode == 0) {
237
-    echo '<p>' . $_lang['checking_table_prefix'] . $table_prefix . '`: ';
238
-    if ($rs= mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
239
-        echo '<span class="notok">' . $_lang['failed'] . '</span></b>' . $_lang['table_prefix_already_inuse'] . '</p>';
237
+    echo '<p>'.$_lang['checking_table_prefix'].$table_prefix.'`: ';
238
+    if ($rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
239
+        echo '<span class="notok">'.$_lang['failed'].'</span></b>'.$_lang['table_prefix_already_inuse'].'</p>';
240 240
         $errors++;
241
-        echo "<p>" . $_lang['table_prefix_already_inuse_note'] . '</p>';
241
+        echo "<p>".$_lang['table_prefix_already_inuse_note'].'</p>';
242 242
     } else {
243
-        echo '<span class="ok">' . $_lang['ok'] . '</span></p>';
243
+        echo '<span class="ok">'.$_lang['ok'].'</span></p>';
244 244
     }
245 245
 } elseif ($conn && $installMode == 2) {
246
-    echo '<p>' . $_lang['checking_table_prefix'] . $table_prefix . '`: ';
247
-    if (!$rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
248
-        echo '<span class="notok">' . $_lang['failed'] . '</span></b>' . $_lang['table_prefix_not_exist'] . '</p>';
246
+    echo '<p>'.$_lang['checking_table_prefix'].$table_prefix.'`: ';
247
+    if (!$rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
248
+        echo '<span class="notok">'.$_lang['failed'].'</span></b>'.$_lang['table_prefix_not_exist'].'</p>';
249 249
         $errors++;
250
-        echo '<p>' . $_lang['table_prefix_not_exist_note'] . '</p>';
250
+        echo '<p>'.$_lang['table_prefix_not_exist_note'].'</p>';
251 251
   } else {
252
-        echo '<span class="ok">' . $_lang['ok'] . '</span></p>';
252
+        echo '<span class="ok">'.$_lang['ok'].'</span></p>';
253 253
   }
254 254
 }
255 255
 
256 256
 // check mysql version
257 257
 if ($conn) {
258
-    echo '<p>' . $_lang['checking_mysql_version'];
259
-    if ( version_compare(mysqli_get_server_info($conn), '5.0.51', '=') ) {
260
-        echo '<span class="notok">'  . $_lang['warning'] . '</span></b>&nbsp;&nbsp;<strong>' . $_lang['mysql_5051'] . '</strong></p>';
261
-        echo '<p><span class="notok">' . $_lang['mysql_5051_warning'] . '</span></p>';
258
+    echo '<p>'.$_lang['checking_mysql_version'];
259
+    if (version_compare(mysqli_get_server_info($conn), '5.0.51', '=')) {
260
+        echo '<span class="notok">'.$_lang['warning'].'</span></b>&nbsp;&nbsp;<strong>'.$_lang['mysql_5051'].'</strong></p>';
261
+        echo '<p><span class="notok">'.$_lang['mysql_5051_warning'].'</span></p>';
262 262
     } else {
263
-        echo '<span class="ok">' . $_lang['ok'] . '</span>&nbsp;&nbsp;<strong>' . $_lang['mysql_version_is'] . mysqli_get_server_info($conn) . '</strong></p>';
263
+        echo '<span class="ok">'.$_lang['ok'].'</span>&nbsp;&nbsp;<strong>'.$_lang['mysql_version_is'].mysqli_get_server_info($conn).'</strong></p>';
264 264
     }
265 265
 }
266 266
 
267 267
 // check for strict mode
268 268
 if ($conn) {
269
-    echo '<p>'. $_lang['checking_mysql_strict_mode'];
269
+    echo '<p>'.$_lang['checking_mysql_strict_mode'];
270 270
     $mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode");
271
-    if (mysqli_num_rows($mysqlmode) > 0){
271
+    if (mysqli_num_rows($mysqlmode) > 0) {
272 272
         $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM);
273 273
         //$modes = array("STRICT_TRANS_TABLES"); // for testing
274 274
         // print_r($modes);
275 275
         foreach ($modes as $mode) {
276 276
             if (stristr($mode, "STRICT_TRANS_TABLES") !== false || stristr($mode, "STRICT_ALL_TABLES") !== false) {
277
-                echo '<span class="notok">' . $_lang['warning'] . '</span></b> <strong>&nbsp;&nbsp;' . $_lang['strict_mode'] . '</strong></p>';
278
-                echo '<p><span class="notok">' . $_lang['strict_mode_error'] . '</span></p>';
277
+                echo '<span class="notok">'.$_lang['warning'].'</span></b> <strong>&nbsp;&nbsp;'.$_lang['strict_mode'].'</strong></p>';
278
+                echo '<p><span class="notok">'.$_lang['strict_mode_error'].'</span></p>';
279 279
             } else {
280
-                echo '<span class="ok">' . $_lang['ok'] . '</span></p>';
280
+                echo '<span class="ok">'.$_lang['ok'].'</span></p>';
281 281
             }
282 282
         }
283 283
     } else {
284
-        echo '<span class="ok">' . $_lang['ok'] . '</span></p>';
284
+        echo '<span class="ok">'.$_lang['ok'].'</span></p>';
285 285
     }
286 286
 }
287 287
 // Version and strict mode check end
@@ -297,18 +297,18 @@  discard block
 block discarded – undo
297 297
     f_owc("../assets/cache/installProc.inc.php", '<?php $installStartTime = '.time().'; ?>');
298 298
 }
299 299
 
300
-if($installMode > 0 && $_POST['installdata'] == "1") {
301
-    echo '<p class="notes"><strong>' . $_lang['sample_web_site'] . ':</strong> ' . $_lang['sample_web_site_note'] . '</p>';
300
+if ($installMode > 0 && $_POST['installdata'] == "1") {
301
+    echo '<p class="notes"><strong>'.$_lang['sample_web_site'].':</strong> '.$_lang['sample_web_site_note'].'</p>';
302 302
 }
303 303
 
304 304
 if ($errors > 0) {
305 305
     echo '<p>';
306
-    echo $_lang['setup_cannot_continue'] . ' ';
306
+    echo $_lang['setup_cannot_continue'].' ';
307 307
 
308
-    if($errors > 1){
309
-        echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural'];
310
-    }else{
311
-        echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again'];
308
+    if ($errors > 1) {
309
+        echo $errors." ".$_lang['errors'].$_lang['please_correct_errors'].$_lang['and_try_again_plural'];
310
+    } else {
311
+        echo $_lang['error'].$_lang['please_correct_error'].$_lang['and_try_again'];
312 312
     }
313 313
 
314 314
     echo $_lang['visit_forum'];
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
 
318 318
 echo '<p>&nbsp;</p>';
319 319
 
320
-$nextAction= $errors > 0 ? 'summary' : 'install';
321
-$nextButton= $errors > 0 ? $_lang['retry'] : $_lang['install'];
322
-$nextVisibility= $errors > 0 || isset($_POST['chkagree']) ? 'visible' : 'hidden';
323
-$agreeToggle= $errors > 0 ? '' : ' onclick="if(document.getElementById(\'chkagree\').checked){document.getElementById(\'nextbutton\').style.visibility=\'visible\';}else{document.getElementById(\'nextbutton\').style.visibility=\'hidden\';}"';
320
+$nextAction = $errors > 0 ? 'summary' : 'install';
321
+$nextButton = $errors > 0 ? $_lang['retry'] : $_lang['install'];
322
+$nextVisibility = $errors > 0 || isset($_POST['chkagree']) ? 'visible' : 'hidden';
323
+$agreeToggle = $errors > 0 ? '' : ' onclick="if(document.getElementById(\'chkagree\').checked){document.getElementById(\'nextbutton\').style.visibility=\'visible\';}else{document.getElementById(\'nextbutton\').style.visibility=\'hidden\';}"';
324 324
 ?>
325 325
 <form name="install" id="install_form" action="index.php?action=<?php echo $nextAction ?>" method="post">
326 326
   <div>
@@ -342,32 +342,32 @@  discard block
 block discarded – undo
342 342
 
343 343
     <input type="hidden" value="<?php echo $_POST['installdata'] ?>" name="installdata" />
344 344
 <?php
345
-    $templates = isset ($_POST['template']) ? $_POST['template'] : array ();
345
+    $templates = isset ($_POST['template']) ? $_POST['template'] : array();
346 346
     foreach ($templates as $i => $template) echo '<input type="hidden" name="template[]" value="'.$template.'" />';
347 347
 
348
-    $tvs = isset ($_POST['tv']) ? $_POST['tv'] : array ();
348
+    $tvs = isset ($_POST['tv']) ? $_POST['tv'] : array();
349 349
     foreach ($tvs as $i => $tv) echo '<input type="hidden" name="tv[]" value="'.$tv.'" />';
350 350
 
351
-    $chunks = isset ($_POST['chunk']) ? $_POST['chunk'] : array ();
351
+    $chunks = isset ($_POST['chunk']) ? $_POST['chunk'] : array();
352 352
     foreach ($chunks as $i => $chunk) echo '<input type="hidden" name="chunk[]" value="'.$chunk.'" />';
353 353
 
354
-    $snippets = isset ($_POST['snippet']) ? $_POST['snippet'] : array ();
354
+    $snippets = isset ($_POST['snippet']) ? $_POST['snippet'] : array();
355 355
     foreach ($snippets as $i => $snippet) echo '<input type="hidden" name="snippet[]" value="'.$snippet.'" />';
356 356
 
357
-    $plugins = isset ($_POST['plugin']) ? $_POST['plugin'] : array ();
357
+    $plugins = isset ($_POST['plugin']) ? $_POST['plugin'] : array();
358 358
     foreach ($plugins as $i => $plugin) echo '<input type="hidden" name="plugin[]" value="'.$plugin.'" />';
359 359
 
360
-    $modules = isset ($_POST['module']) ? $_POST['module'] : array ();
360
+    $modules = isset ($_POST['module']) ? $_POST['module'] : array();
361 361
     foreach ($modules as $i => $module) echo '<input type="hidden" name="module[]" value="'.$module.'" />';
362 362
 ?>
363 363
 </div>
364 364
 
365
-<h2><?php echo $_lang['agree_to_terms'];?></h2>
365
+<h2><?php echo $_lang['agree_to_terms']; ?></h2>
366 366
 <p>
367
-<input type="checkbox" value="1" id="chkagree" name="chkagree" style="line-height:18px" <?php echo isset($_POST['chkagree']) ? 'checked="checked" ':""; ?><?php echo $agreeToggle;?>/><label for="chkagree" style="display:inline;float:none;line-height:18px;"> <?php echo $_lang['iagree_box']?> </label>
367
+<input type="checkbox" value="1" id="chkagree" name="chkagree" style="line-height:18px" <?php echo isset($_POST['chkagree']) ? 'checked="checked" ' : ""; ?><?php echo $agreeToggle; ?>/><label for="chkagree" style="display:inline;float:none;line-height:18px;"> <?php echo $_lang['iagree_box']?> </label>
368 368
 </p>
369 369
     <p class="buttonlinks">
370 370
         <a href="javascript:document.getElementById('install_form').action='index.php?action=options&language=<?php echo $install_language?>';document.getElementById('install_form').submit();" class="prev" title="<?php echo $_lang['btnback_value']?>"><span><?php echo $_lang['btnback_value']?></span></a>
371
-        <a id="nextbutton" href="javascript:document.getElementById('install_form').submit();" title="<?php echo $nextButton ?>" style="visibility:<?php echo $nextVisibility;?>"><span><?php echo $nextButton ?></span></a>
371
+        <a id="nextbutton" href="javascript:document.getElementById('install_form').submit();" title="<?php echo $nextButton ?>" style="visibility:<?php echo $nextVisibility; ?>"><span><?php echo $nextButton ?></span></a>
372 372
     </p>
373 373
 </form>
Please login to merge, or discard this patch.
install/actions/action_language.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 $content = parse($content, array(
4 4
     'langOptions' => getLangOptions($install_language))
5 5
 );
6
-$content = parse($content, $_lang,'[%','%]');
6
+$content = parse($content, $_lang, '[%', '%]');
7 7
 
8 8
 echo $content;
9 9
 
10
-if( ! function_exists('getLangOptions')) {
10
+if (!function_exists('getLangOptions')) {
11 11
     /**
12 12
      * @param string $install_language
13 13
      * @return string
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             $abrv_language = explode('-', $language);
30 30
             $selected = ($language === $install_language) ? 'selected' : '';
31 31
             $_[] = sprintf('<option value="%s" %s>%s</option>', $language, $selected,
32
-                    ucwords($abrv_language[0])) . "\n";
32
+                    ucwords($abrv_language[0]))."\n";
33 33
         }
34 34
 
35 35
         return implode("\n", $_);
Please login to merge, or discard this patch.
install/actions/action_mode.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Determine upgradeability
3 3
 $upgradeable = 0;
4
-if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) { // Include the file so we can test its validity
5
-    include $base_path . MGR_DIR . '/includes/config.inc.php';
4
+if (is_file($base_path.MGR_DIR.'/includes/config.inc.php')) { // Include the file so we can test its validity
5
+    include $base_path.MGR_DIR.'/includes/config.inc.php';
6 6
     // We need to have all connection settings - tho prefix may be empty so we have to ignore it
7 7
     if (isset($dbase)) {
8 8
         if (!$conn = @mysqli_connect($database_server, $database_user, $database_password))
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
 }
18 18
 
19 19
 $ph['moduleName']       = $moduleName;
20
-$ph['displayNew']       = ($upgradeable!=0) ? 'display:none;' : '';
21
-$ph['displayUpg']       = ($upgradeable==0) ? 'display:none;' : '';
20
+$ph['displayNew']       = ($upgradeable != 0) ? 'display:none;' : '';
21
+$ph['displayUpg']       = ($upgradeable == 0) ? 'display:none;' : '';
22 22
 $ph['displayAdvUpg']    = $ph['displayUpg'];
23
-$ph['checkedNew']       = !$upgradeable     ? 'checked' : '';
24
-$ph['checkedUpg']       = ($_POST['installmode']==1 || $upgradeable==1) ? 'checked' : '';
25
-$ph['checkedAdvUpg']    = ($_POST['installmode']==2 || $upgradeable==2) ? 'checked' : '';
23
+$ph['checkedNew']       = !$upgradeable ? 'checked' : '';
24
+$ph['checkedUpg']       = ($_POST['installmode'] == 1 || $upgradeable == 1) ? 'checked' : '';
25
+$ph['checkedAdvUpg']    = ($_POST['installmode'] == 2 || $upgradeable == 2) ? 'checked' : '';
26 26
 $ph['install_language'] = $install_language;
27
-$ph['disabledUpg']      = ($upgradeable!=1) ? 'disabled' : '';
28
-$ph['disabledAdvUpg']   = ($upgradeable==0) ? 'disabled' : '';
27
+$ph['disabledUpg']      = ($upgradeable != 1) ? 'disabled' : '';
28
+$ph['disabledAdvUpg']   = ($upgradeable == 0) ? 'disabled' : '';
29 29
 
30
-$tpl = file_get_contents($base_path . 'install/actions/tpl_mode.html');
30
+$tpl = file_get_contents($base_path.'install/actions/tpl_mode.html');
31 31
 $content = parse($tpl, $ph);
32
-echo parse($content, $_lang,'[%','%]');
32
+echo parse($content, $_lang, '[%', '%]');
Please login to merge, or discard this patch.