Completed
Pull Request — develop (#689)
by Alexander
05:50
created
manager/includes/controls/phpmailer/OAuth.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -128,10 +128,10 @@
 block discarded – undo
128 128
         }
129 129
 
130 130
         return base64_encode(
131
-            'user=' .
132
-            $this->oauthUserEmail .
133
-            "\001auth=Bearer " .
134
-            $this->oauthToken .
131
+            'user='.
132
+            $this->oauthUserEmail.
133
+            "\001auth=Bearer ".
134
+            $this->oauthToken.
135 135
             "\001\001"
136 136
         );
137 137
     }
Please login to merge, or discard this patch.
manager/includes/controls/phpmailer/Exception.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,6 +34,6 @@
 block discarded – undo
34 34
      */
35 35
     public function errorMessage()
36 36
     {
37
-        return '<strong>' . htmlspecialchars($this->getMessage()) . "</strong><br />\n";
37
+        return '<strong>'.htmlspecialchars($this->getMessage())."</strong><br />\n";
38 38
     }
39 39
 }
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers/mdf_getimage.inc.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 $pattern = '/<img[\s\n]+.*src=[\s\n]*"([^"]+\.(jpg|jpeg|png|gif))"[^>]+>/i';
3
-preg_match_all($pattern , $value , $images);
4
-if($opt==='')
3
+preg_match_all($pattern, $value, $images);
4
+if ($opt === '')
5 5
 {
6
-    if($images[1][0])  return $images[1][0];
6
+    if ($images[1][0])  return $images[1][0];
7 7
     else               return '';
8 8
 }
9 9
 else
10 10
 {
11
-    foreach($images[0] as $i=>$image)
11
+    foreach ($images[0] as $i=>$image)
12 12
     {
13
-        if(strpos($image,$opt)!==false) return $images[1][$i];
13
+        if (strpos($image, $opt) !== false) return $images[1][$i];
14 14
     }
15 15
 }
16 16
 
Please login to merge, or discard this patch.
Braces   +11 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,16 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 $pattern = '/<img[\s\n]+.*src=[\s\n]*"([^"]+\.(jpg|jpeg|png|gif))"[^>]+>/i';
3 3
 preg_match_all($pattern , $value , $images);
4
-if($opt==='')
5
-{
6
-    if($images[1][0])  return $images[1][0];
7
-    else               return '';
8
-}
9
-else
10
-{
11
-    foreach($images[0] as $i=>$image)
12
-    {
13
-        if(strpos($image,$opt)!==false) return $images[1][$i];
4
+if($opt==='') {
5
+    if($images[1][0]) {
6
+        return $images[1][0];
7
+    } else {
8
+        return '';
9
+    }
10
+    } else {
11
+    foreach($images[0] as $i=>$image) {
12
+        if(strpos($image,$opt)!==false) {
13
+            return $images[1][$i];
14
+        }
14 15
     }
15 16
 }
16 17
 
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers/mdf_wordwrap.inc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,2 +1,2 @@
 block discarded – undo
1 1
 <?php
2
-return preg_replace_callback("~(\b\w+\b)~",function($m) use($wrapat) {return wordwrap($m[1],$wrapat,' ',1);},$value);
2
+return preg_replace_callback("~(\b\w+\b)~", function($m) use($wrapat) {return wordwrap($m[1], $wrapat, ' ', 1); },$value);
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers/mdf_addbreak.inc.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
 $text = $modx->filter->parseDocumentSource($value);
3
-$text = str_replace(array("\r\n","\r"),"\n",$text);
3
+$text = str_replace(array("\r\n", "\r"), "\n", $text);
4 4
 
5 5
 $blockElms  = 'br,table,tbody,tr,td,th,thead,tfoot,caption,colgroup,div';
6 6
 $blockElms .= ',dl,dd,dt,ul,ol,li,pre,select,option,form,map,area,blockquote';
7 7
 $blockElms .= ',address,math,style,input,p,h1,h2,h3,h4,h5,h6,hr,object,param,embed';
8 8
 $blockElms .= ',noframes,noscript,section,article,aside,hgroup,footer,address,code';
9 9
 $blockElms = explode(',', $blockElms);
10
-$lines = explode("\n",$text);
10
+$lines = explode("\n", $text);
11 11
 $c = count($lines);
12
-foreach($lines as $i=>$line)
12
+foreach ($lines as $i=>$line)
13 13
 {
14 14
     $line = rtrim($line);
15
-    if($i===$c-1) break;
16
-    foreach($blockElms as $block)
15
+    if ($i === $c - 1) break;
16
+    foreach ($blockElms as $block)
17 17
     {
18
-        if(preg_match("@</?{$block}" . '[^>]*>$@',$line))
18
+        if (preg_match("@</?{$block}".'[^>]*>$@', $line))
19 19
             continue 2;
20 20
     }
21 21
     $lines[$i] = "{$line}<br />";
Please login to merge, or discard this patch.
Braces   +8 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,14 +9,15 @@
 block discarded – undo
9 9
 $blockElms = explode(',', $blockElms);
10 10
 $lines = explode("\n",$text);
11 11
 $c = count($lines);
12
-foreach($lines as $i=>$line)
13
-{
12
+foreach($lines as $i=>$line) {
14 13
     $line = rtrim($line);
15
-    if($i===$c-1) break;
16
-    foreach($blockElms as $block)
17
-    {
18
-        if(preg_match("@</?{$block}" . '[^>]*>$@',$line))
19
-            continue 2;
14
+    if($i===$c-1) {
15
+        break;
16
+    }
17
+    foreach($blockElms as $block) {
18
+        if(preg_match("@</?{$block}" . '[^>]*>$@',$line)) {
19
+                    continue 2;
20
+        }
20 21
     }
21 22
     $lines[$i] = "{$line}<br />";
22 23
 }
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers/mdf_memberof.inc.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,22 +2,22 @@
 block discarded – undo
2 2
 $userID = abs($modx->getLoginUserID('web'));
3 3
 $modx->qs_hash = md5($modx->qs_hash."^{$userID}^");
4 4
 
5
-$groupNames = ($this->strlen($opt) > 0 ) ? explode(',',$opt) : array();
5
+$groupNames = ($this->strlen($opt) > 0) ? explode(',', $opt) : array();
6 6
 
7 7
 // if $groupNames is not an array return false
8
-if(!is_array($groupNames)) return 0;
8
+if (!is_array($groupNames)) return 0;
9 9
 
10 10
 // Creates an array with all webgroups the user id is in
11 11
 if (isset($modx->filter->cache['mo'][$userID])) $grpNames = $modx->filter->cache['mo'][$userID];
12 12
 else {
13
-    $from = sprintf("[+prefix+]webgroup_names wgn INNER JOIN [+prefix+]web_groups wg ON wg.webgroup=wgn.id AND wg.webuser='%s'",$userID);
14
-    $rs = $modx->db->select('wgn.name',$from);
15
-    $modx->filter->cache['mo'][$userID] = $grpNames = $modx->db->getColumn('name',$rs);
13
+    $from = sprintf("[+prefix+]webgroup_names wgn INNER JOIN [+prefix+]web_groups wg ON wg.webgroup=wgn.id AND wg.webuser='%s'", $userID);
14
+    $rs = $modx->db->select('wgn.name', $from);
15
+    $modx->filter->cache['mo'][$userID] = $grpNames = $modx->db->getColumn('name', $rs);
16 16
 }
17 17
 
18 18
 // Check if a supplied group matches a webgroup from the array we just created
19
-foreach($groupNames as $k=>$v) {
20
-    if(in_array(trim($v),$grpNames)) return 1;
19
+foreach ($groupNames as $k=>$v) {
20
+    if (in_array(trim($v), $grpNames)) return 1;
21 21
 }
22 22
 
23 23
 // If we get here the above logic did not find a match, so return false
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -5,11 +5,14 @@  discard block
 block discarded – undo
5 5
 $groupNames = ($this->strlen($opt) > 0 ) ? explode(',',$opt) : array();
6 6
 
7 7
 // if $groupNames is not an array return false
8
-if(!is_array($groupNames)) return 0;
8
+if(!is_array($groupNames)) {
9
+    return 0;
10
+}
9 11
 
10 12
 // Creates an array with all webgroups the user id is in
11
-if (isset($modx->filter->cache['mo'][$userID])) $grpNames = $modx->filter->cache['mo'][$userID];
12
-else {
13
+if (isset($modx->filter->cache['mo'][$userID])) {
14
+    $grpNames = $modx->filter->cache['mo'][$userID];
15
+} else {
13 16
     $from = sprintf("[+prefix+]webgroup_names wgn INNER JOIN [+prefix+]web_groups wg ON wg.webgroup=wgn.id AND wg.webuser='%s'",$userID);
14 17
     $rs = $modx->db->select('wgn.name',$from);
15 18
     $modx->filter->cache['mo'][$userID] = $grpNames = $modx->db->getColumn('name',$rs);
@@ -17,8 +20,10 @@  discard block
 block discarded – undo
17 20
 
18 21
 // Check if a supplied group matches a webgroup from the array we just created
19 22
 foreach($groupNames as $k=>$v) {
20
-    if(in_array(trim($v),$grpNames)) return 1;
21
-}
23
+    if(in_array(trim($v),$grpNames)) {
24
+        return 1;
25
+    }
26
+    }
22 27
 
23 28
 // If we get here the above logic did not find a match, so return false
24 29
 return 0;
Please login to merge, or discard this patch.
manager/includes/extenders/message.quit.inc.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -19,60 +19,60 @@
 block discarded – undo
19 19
 </head><body>
20 20
 ";
21 21
 if($is_error) {
22
-	$parsedMessageString .= "<h3 style='color:red;background:#e0e0e0;padding:2px;'>&nbsp;MODX Parse Error </h3>
22
+    $parsedMessageString .= "<h3 style='color:red;background:#e0e0e0;padding:2px;'>&nbsp;MODX Parse Error </h3>
23 23
 	<table border='0' cellpadding='1' cellspacing='0'>
24 24
 	<tr><td colspan='3'>MODX encountered the following error while attempting to parse the requested resource:</td></tr>
25 25
 	<tr><td colspan='3'><b style='color:red;'>&laquo; $msg &raquo;</b></td></tr>";
26 26
 } else {
27
-	$parsedMessageString .= "<h3 style='color:#003399; background:#eeeeee;padding:2px;'>&nbsp;MODX Debug/ stop message </h3>
27
+    $parsedMessageString .= "<h3 style='color:#003399; background:#eeeeee;padding:2px;'>&nbsp;MODX Debug/ stop message </h3>
28 28
 	<table border='0' cellpadding='1' cellspacing='0'>
29 29
 	<tr><td colspan='3'>The MODX parser recieved the following debug/ stop message:</td></tr>
30 30
 	<tr><td colspan='3'><b style='color:#003399;'>&laquo; $msg &raquo;</b></td></tr>";
31 31
 }
32 32
 
33 33
 if(!empty($query)) {
34
-	$parsedMessageString .= "<tr><td colspan='3'><hr size='1' width='98%' style='color:#e0e0e0'/><b style='color:#999;font-size: 9px;border-left:1px solid #c0c0c0; margin-left:10px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SQL:&nbsp;<span id='sqlHolder'>$query</span></b><hr size='1' width='98%' style='color:#e0e0e0'/>
34
+    $parsedMessageString .= "<tr><td colspan='3'><hr size='1' width='98%' style='color:#e0e0e0'/><b style='color:#999;font-size: 9px;border-left:1px solid #c0c0c0; margin-left:10px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SQL:&nbsp;<span id='sqlHolder'>$query</span></b><hr size='1' width='98%' style='color:#e0e0e0'/>
35 35
 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:copyToClip();' style='color:#821517;font-size: 9px; text-decoration: none'>[Copy SQL to ClipBoard]</a><textarea id='holdtext' style='display:none;'></textarea></td></tr>";
36 36
 }
37 37
 
38 38
 if($text!='') {
39 39
 
40
-	$errortype = array (
41
-		E_ERROR          => "Error",
42
-		E_WARNING        => "Warning",
43
-		E_PARSE          => "Parsing Error",
44
-		E_NOTICE          => "Notice",
45
-		E_CORE_ERROR      => "Core Error",
46
-		E_CORE_WARNING    => "Core Warning",
47
-		E_COMPILE_ERROR  => "Compile Error",
48
-		E_COMPILE_WARNING => "Compile Warning",
49
-		E_USER_ERROR      => "User Error",
50
-		E_USER_WARNING    => "User Warning",
51
-		E_USER_NOTICE    => "User Notice",
52
-	);
40
+    $errortype = array (
41
+        E_ERROR          => "Error",
42
+        E_WARNING        => "Warning",
43
+        E_PARSE          => "Parsing Error",
44
+        E_NOTICE          => "Notice",
45
+        E_CORE_ERROR      => "Core Error",
46
+        E_CORE_WARNING    => "Core Warning",
47
+        E_COMPILE_ERROR  => "Compile Error",
48
+        E_COMPILE_WARNING => "Compile Warning",
49
+        E_USER_ERROR      => "User Error",
50
+        E_USER_WARNING    => "User Warning",
51
+        E_USER_NOTICE    => "User Notice",
52
+    );
53 53
 
54
-	$parsedMessageString .= "<tr><td>&nbsp;</td></tr><tr><td colspan='3'><b>PHP error debug</b></td></tr>";
54
+    $parsedMessageString .= "<tr><td>&nbsp;</td></tr><tr><td colspan='3'><b>PHP error debug</b></td></tr>";
55 55
 
56
-	$parsedMessageString .= "<tr><td valign='top'>&nbsp;&nbsp;Error: </td>";
57
-	$parsedMessageString .= "<td colspan='2'>$text</td><td>&nbsp;</td>";
58
-	$parsedMessageString .= "</tr>";
56
+    $parsedMessageString .= "<tr><td valign='top'>&nbsp;&nbsp;Error: </td>";
57
+    $parsedMessageString .= "<td colspan='2'>$text</td><td>&nbsp;</td>";
58
+    $parsedMessageString .= "</tr>";
59 59
 
60
-	$parsedMessageString .= "<tr><td valign='top'>&nbsp;&nbsp;Error type/ Nr.: </td>";
61
-	$parsedMessageString .= "<td colspan='2'>".$errortype[$nr]." - $nr</b></td><td>&nbsp;</td>";
62
-	$parsedMessageString .= "</tr>";
60
+    $parsedMessageString .= "<tr><td valign='top'>&nbsp;&nbsp;Error type/ Nr.: </td>";
61
+    $parsedMessageString .= "<td colspan='2'>".$errortype[$nr]." - $nr</b></td><td>&nbsp;</td>";
62
+    $parsedMessageString .= "</tr>";
63 63
 
64
-	$parsedMessageString .= "<tr><td>&nbsp;&nbsp;File: </td>";
65
-	$parsedMessageString .= "<td colspan='2'>$file</td><td>&nbsp;</td>";
66
-	$parsedMessageString .= "</tr>";
64
+    $parsedMessageString .= "<tr><td>&nbsp;&nbsp;File: </td>";
65
+    $parsedMessageString .= "<td colspan='2'>$file</td><td>&nbsp;</td>";
66
+    $parsedMessageString .= "</tr>";
67 67
 
68
-	$parsedMessageString .= "<tr><td>&nbsp;&nbsp;Line: </td>";
69
-	$parsedMessageString .= "<td colspan='2'>$line</td><td>&nbsp;</td>";
70
-	$parsedMessageString .= "</tr>";
71
-	if($source!='') {
72
-		$parsedMessageString .= "<tr><td valign='top'>&nbsp;&nbsp;Line $line source: </td>";
73
-		$parsedMessageString .= "<td colspan='2'>$source</td><td>&nbsp;</td>";
74
-		$parsedMessageString .= "</tr>";
75
-	}
68
+    $parsedMessageString .= "<tr><td>&nbsp;&nbsp;Line: </td>";
69
+    $parsedMessageString .= "<td colspan='2'>$line</td><td>&nbsp;</td>";
70
+    $parsedMessageString .= "</tr>";
71
+    if($source!='') {
72
+        $parsedMessageString .= "<tr><td valign='top'>&nbsp;&nbsp;Line $line source: </td>";
73
+        $parsedMessageString .= "<td colspan='2'>$source</td><td>&nbsp;</td>";
74
+        $parsedMessageString .= "</tr>";
75
+    }
76 76
 }
77 77
 
78 78
 $parsedMessageString .= "<tr><td>&nbsp;</td></tr><tr><td colspan='3'><b>Parser timing</b></td></tr>";
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Message Quit Template
4 4
  *
5 5
  */
6
-if(( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) && IN_PARSER_MODE!="true") {
6
+if ((!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) && IN_PARSER_MODE != "true") {
7 7
     die("<b>INCLUDE ACCESS ERROR</b><br /><br />Direct access to this file prohibited.");
8 8
 }
9 9
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 </script>
21 21
 </head><body>
22 22
 ";
23
-if($is_error) {
23
+if ($is_error) {
24 24
 	$parsedMessageString .= "<h3 style='color:red;background:#e0e0e0;padding:2px;'>&nbsp;MODX Parse Error </h3>
25 25
 	<table border='0' cellpadding='1' cellspacing='0'>
26 26
 	<tr><td colspan='3'>MODX encountered the following error while attempting to parse the requested resource:</td></tr>
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 	<tr><td colspan='3'><b style='color:#003399;'>&laquo; $msg &raquo;</b></td></tr>";
33 33
 }
34 34
 
35
-if(!empty($query)) {
35
+if (!empty($query)) {
36 36
 	$parsedMessageString .= "<tr><td colspan='3'><hr size='1' width='98%' style='color:#e0e0e0'/><b style='color:#999;font-size: 9px;border-left:1px solid #c0c0c0; margin-left:10px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SQL:&nbsp;<span id='sqlHolder'>$query</span></b><hr size='1' width='98%' style='color:#e0e0e0'/>
37 37
 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:copyToClip();' style='color:#821517;font-size: 9px; text-decoration: none'>[Copy SQL to ClipBoard]</a><textarea id='holdtext' style='display:none;'></textarea></td></tr>";
38 38
 }
39 39
 
40
-if($text!='') {
40
+if ($text != '') {
41 41
 
42
-	$errortype = array (
42
+	$errortype = array(
43 43
 		E_ERROR          => "Error",
44 44
 		E_WARNING        => "Warning",
45 45
 		E_PARSE          => "Parsing Error",
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	$parsedMessageString .= "<tr><td>&nbsp;&nbsp;Line: </td>";
71 71
 	$parsedMessageString .= "<td colspan='2'>$line</td><td>&nbsp;</td>";
72 72
 	$parsedMessageString .= "</tr>";
73
-	if($source!='') {
73
+	if ($source != '') {
74 74
 		$parsedMessageString .= "<tr><td valign='top'>&nbsp;&nbsp;Line $line source: </td>";
75 75
 		$parsedMessageString .= "<td colspan='2'>$source</td><td>&nbsp;</td>";
76 76
 		$parsedMessageString .= "</tr>";
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers.class.inc.php 5 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
                     else               $opt = true;
599 599
                 }
600 600
                 elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html')
601
-                                       $opt = false;
601
+                                        $opt = false;
602 602
                 else                   $opt = true;
603 603
                 return nl2br($value,$opt);
604 604
             case 'ltrim':
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
         {
1023 1023
             $bt = $content;
1024 1024
             if(strpos($content,'[*')!==false && $modx->documentIdentifier)
1025
-                                              $content = $modx->mergeDocumentContent($content);
1025
+                                                $content = $modx->mergeDocumentContent($content);
1026 1026
             if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content);
1027 1027
             if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content);
1028 1028
             if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -349,7 +349,7 @@
 block discarded – undo
349 349
                 $conditional = implode(' ',$this->condition);
350 350
                 $isvalid = (int)(eval("return ({$conditional});"));
351 351
                 if ($isvalid) return $this->srcValue;
352
-                return NULL;
352
+                return null;
353 353
             case 'then':
354 354
                 $conditional = implode(' ',$this->condition);
355 355
                 $isvalid = (int)eval("return ({$conditional});");
Please login to merge, or discard this patch.
Doc Comments   +25 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     /**
96 96
      * @param string $mode
97 97
      * @param string $modifiers
98
-     * @return bool|string
98
+     * @return false|string
99 99
      */
100 100
     public function _getDelim($mode,$modifiers) {
101 101
         $c = substr($modifiers,0,1);
@@ -132,6 +132,14 @@  discard block
 block discarded – undo
132 132
             return $opt;
133 133
         }
134 134
     }
135
+
136
+    /**
137
+     * @param string $mode
138
+     * @param false|string $delim
139
+     * @param string $modifiers
140
+     *
141
+     * @return string
142
+     */
135 143
     public function _getRemainModifiers($mode,$delim,$modifiers) {
136 144
         if($delim) {
137 145
             if($mode=='(')
@@ -159,6 +167,9 @@  discard block
 block discarded – undo
159 167
         return substr($string,strpos($string, $delim)+$len);
160 168
     }
161 169
 
170
+    /**
171
+     * @param string $modifiers
172
+     */
162 173
     public function splitEachModifiers($modifiers) {
163 174
         global $modx;
164 175
 
@@ -228,6 +239,9 @@  discard block
 block discarded – undo
228 239
         return $result;
229 240
     }
230 241
 
242
+    /**
243
+     * @param string $key
244
+     */
231 245
     public function parsePhx($key,$value,$modifiers)
232 246
     {
233 247
         global $modx;
@@ -294,6 +308,9 @@  discard block
 block discarded – undo
294 308
         else                  return true;
295 309
     }
296 310
 
311
+    /**
312
+     * @param string $cmd
313
+     */
297 314
     public function getValueFromPreset($key, $value, $cmd, $opt)
298 315
     {
299 316
         global $modx;
@@ -979,6 +996,9 @@  discard block
 block discarded – undo
979 996
         return $value;
980 997
     }
981 998
 
999
+    /**
1000
+     * @param string $cmd
1001
+     */
982 1002
     public function includeMdfFile($cmd) {
983 1003
         global $modx;
984 1004
         $key = $this->key;
@@ -1134,6 +1154,10 @@  discard block
 block discarded – undo
1134 1154
     }
1135 1155
 
1136 1156
     // Sets a placeholder variable which can only be access by Modifiers
1157
+
1158
+    /**
1159
+     * @param string $value
1160
+     */
1137 1161
     public function setModifiersVariable($key, $value) {
1138 1162
         if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1139 1163
     }
Please login to merge, or discard this patch.
Spacing   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
3
+if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
4 4
 
5
-class MODIFIERS {
5
+class MODIFIERS{
6 6
     /**
7 7
      * @var array
8 8
      */
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
      * @param string $modifiers
72 72
      * @return bool|mixed|string
73 73
      */
74
-    public function phxFilter($key,$value,$modifiers)
74
+    public function phxFilter($key, $value, $modifiers)
75 75
     {
76 76
         global $modx;
77
-        if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value);
77
+        if (substr($modifiers, 0, 3) !== 'id(') $value = $this->parseDocumentSource($value);
78 78
         $this->srcValue = $value;
79 79
         $modifiers = trim($modifiers);
80
-        $modifiers = ':'.trim($modifiers,':');
81
-        $modifiers = str_replace(array("\r\n","\r"), "\n", $modifiers);
80
+        $modifiers = ':'.trim($modifiers, ':');
81
+        $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers);
82 82
         $modifiers = $this->splitEachModifiers($modifiers);
83 83
 
84 84
         $this->placeholders = array();
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
         $this->placeholders['dummy'] = '';
87 87
         $this->condition = array();
88 88
         $this->vars = array();
89
-        $this->vars['name']    = & $key;
90
-        $value = $this->parsePhx($key,$value,$modifiers);
89
+        $this->vars['name'] = & $key;
90
+        $value = $this->parsePhx($key, $value, $modifiers);
91 91
         $this->vars = array();
92 92
         return $value;
93 93
     }
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
      * @param string $modifiers
98 98
      * @return bool|string
99 99
      */
100
-    public function _getDelim($mode,$modifiers) {
101
-        $c = substr($modifiers,0,1);
102
-        if(!in_array($c, array('"', "'", '`')) ) return false;
100
+    public function _getDelim($mode, $modifiers){
101
+        $c = substr($modifiers, 0, 1);
102
+        if (!in_array($c, array('"', "'", '`'))) return false;
103 103
 
104
-        $modifiers = substr($modifiers,1);
105
-        $closure = $mode=='(' ? "{$c})" : $c;
106
-        if(strpos($modifiers, $closure)===false) return false;
104
+        $modifiers = substr($modifiers, 1);
105
+        $closure = $mode == '(' ? "{$c})" : $c;
106
+        if (strpos($modifiers, $closure) === false) return false;
107 107
 
108 108
         return  $c;
109 109
     }
@@ -114,101 +114,101 @@  discard block
 block discarded – undo
114 114
      * @param string $modifiers
115 115
      * @return bool|string
116 116
      */
117
-    public function _getOpt($mode,$delim,$modifiers) {
118
-        if($delim) {
119
-            if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
117
+    public function _getOpt($mode, $delim, $modifiers){
118
+        if ($delim) {
119
+            if ($mode == '(') return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1);
120 120
 
121
-            return substr($modifiers,1,strpos($modifiers,$delim,1)-1);
121
+            return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1);
122 122
         }
123 123
         else {
124
-            if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') );
124
+            if ($mode == '(') return substr($modifiers, 0, strpos($modifiers, ')'));
125 125
 
126 126
             $chars = str_split($modifiers);
127
-            $opt='';
128
-            foreach($chars as $c) {
129
-                if($c==':' || $c==')') break;
130
-                $opt .=$c;
127
+            $opt = '';
128
+            foreach ($chars as $c) {
129
+                if ($c == ':' || $c == ')') break;
130
+                $opt .= $c;
131 131
             }
132 132
             return $opt;
133 133
         }
134 134
     }
135
-    public function _getRemainModifiers($mode,$delim,$modifiers) {
136
-        if($delim) {
137
-            if($mode=='(')
138
-                return $this->_fetchContent($modifiers, $delim . ')');
135
+    public function _getRemainModifiers($mode, $delim, $modifiers){
136
+        if ($delim) {
137
+            if ($mode == '(')
138
+                return $this->_fetchContent($modifiers, $delim.')');
139 139
             else {
140 140
                 $modifiers = trim($modifiers);
141
-                $modifiers = substr($modifiers,1);
141
+                $modifiers = substr($modifiers, 1);
142 142
                 return $this->_fetchContent($modifiers, $delim);
143 143
             }
144 144
         }
145 145
         else {
146
-            if($mode=='(') return $this->_fetchContent($modifiers, ')');
146
+            if ($mode == '(') return $this->_fetchContent($modifiers, ')');
147 147
             $chars = str_split($modifiers);
148
-            foreach($chars as $c) {
149
-                if($c==':') return $modifiers;
150
-                else $modifiers = substr($modifiers,1);
148
+            foreach ($chars as $c) {
149
+                if ($c == ':') return $modifiers;
150
+                else $modifiers = substr($modifiers, 1);
151 151
             }
152 152
             return $modifiers;
153 153
         }
154 154
     }
155 155
 
156
-    public function _fetchContent($string,$delim) {
156
+    public function _fetchContent($string, $delim){
157 157
         $len = strlen($delim);
158 158
         $string = $this->parseDocumentSource($string);
159
-        return substr($string,strpos($string, $delim)+$len);
159
+        return substr($string, strpos($string, $delim) + $len);
160 160
     }
161 161
 
162
-    public function splitEachModifiers($modifiers) {
162
+    public function splitEachModifiers($modifiers){
163 163
         global $modx;
164 164
 
165 165
         $cmd = '';
166 166
         $bt = '';
167 167
         $result = array();
168
-        while($bt!==$modifiers) {
168
+        while ($bt !== $modifiers) {
169 169
             $bt = $modifiers;
170
-            $c = substr($modifiers,0,1);
171
-            $modifiers = substr($modifiers,1);
170
+            $c = substr($modifiers, 0, 1);
171
+            $modifiers = substr($modifiers, 1);
172 172
 
173
-            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
174
-                $c = substr($modifiers,strlen($match[1]),1);
173
+            if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
174
+                $c = substr($modifiers, strlen($match[1]), 1);
175 175
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
176
-                if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1);
177
-                else         $modifiers = substr($modifiers,strlen($match[1]));
176
+                if ($c === '(') $modifiers = substr($modifiers, strlen($match[1]) + 1);
177
+                else         $modifiers = substr($modifiers, strlen($match[1]));
178 178
 
179
-                $delim     = $this->_getDelim($c,$modifiers);
180
-                $opt       = $this->_getOpt($c,$delim,$modifiers);
181
-                $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers));
179
+                $delim     = $this->_getDelim($c, $modifiers);
180
+                $opt       = $this->_getOpt($c, $delim, $modifiers);
181
+                $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers));
182 182
 
183
-                $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
183
+                $result[] = array('cmd'=>trim($match[1]), 'opt'=>$opt, 'debuginfo'=>$debuginfo);
184 184
                 $cmd = '';
185 185
             }
186
-            elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
187
-                $modifiers = substr($modifiers,strlen($match[0]));
188
-                $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]);
186
+            elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
187
+                $modifiers = substr($modifiers, strlen($match[0]));
188
+                $result[] = array('cmd'=>'math', 'opt'=>'%s'.$c.$match[0]);
189 189
                 $cmd = '';
190 190
             }
191
-            elseif($c==='(' || $c==='=') {
191
+            elseif ($c === '(' || $c === '=') {
192 192
                 $modifiers = $m1 = trim($modifiers);
193
-                $delim     = $this->_getDelim($c,$modifiers);
194
-                $opt       = $this->_getOpt($c,$delim,$modifiers);
195
-                $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers));
193
+                $delim     = $this->_getDelim($c, $modifiers);
194
+                $opt       = $this->_getOpt($c, $delim, $modifiers);
195
+                $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers));
196 196
                 $debuginfo = "#i=1 #c=[{$c}] #delim=[{$delim}] #m1=[{$m1}] remainMdf=[{$modifiers}]";
197 197
 
198
-                $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo);
198
+                $result[] = array('cmd'=>trim($cmd), 'opt'=>$opt, 'debuginfo'=>$debuginfo);
199 199
 
200 200
                 $cmd = '';
201 201
             }
202
-            elseif($c==':') {
202
+            elseif ($c == ':') {
203 203
                 $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]";
204
-                if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
204
+                if ($cmd !== '') $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo);
205 205
 
206 206
                 $cmd = '';
207 207
             }
208
-            elseif(trim($modifiers)=='' && trim($cmd)!=='') {
208
+            elseif (trim($modifiers) == '' && trim($cmd) !== '') {
209 209
                 $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]";
210 210
                 $cmd .= $c;
211
-                $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
211
+                $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo);
212 212
 
213 213
                 break;
214 214
             }
@@ -217,65 +217,65 @@  discard block
 block discarded – undo
217 217
             }
218 218
         }
219 219
 
220
-        if(empty($result)) return array();
220
+        if (empty($result)) return array();
221 221
 
222
-        foreach($result as $i=>$a)
222
+        foreach ($result as $i=>$a)
223 223
         {
224 224
             $a['opt'] = $this->parseDocumentSource($a['opt']);
225
-            $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders);
225
+            $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'], $this->placeholders);
226 226
         }
227 227
 
228 228
         return $result;
229 229
     }
230 230
 
231
-    public function parsePhx($key,$value,$modifiers)
231
+    public function parsePhx($key, $value, $modifiers)
232 232
     {
233 233
         global $modx;
234 234
         $lastKey = '';
235
-        $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true)));
236
-        if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
237
-        if(empty($modifiers)) return '';
235
+        $cacheKey = md5(sprintf('parsePhx#%s#%s#%s', $key, $value, print_r($modifiers, true)));
236
+        if (isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
237
+        if (empty($modifiers)) return '';
238 238
 
239
-        foreach($modifiers as $m)
239
+        foreach ($modifiers as $m)
240 240
         {
241 241
             $lastKey = strtolower($m['cmd']);
242 242
         }
243
-        $_ = explode(',',$this->condModifiers);
244
-        if(in_array($lastKey,$_))
243
+        $_ = explode(',', $this->condModifiers);
244
+        if (in_array($lastKey, $_))
245 245
         {
246
-            $modifiers[] = array('cmd'=>'then','opt'=>'1');
247
-            $modifiers[] = array('cmd'=>'else','opt'=>'0');
246
+            $modifiers[] = array('cmd'=>'then', 'opt'=>'1');
247
+            $modifiers[] = array('cmd'=>'else', 'opt'=>'0');
248 248
         }
249 249
 
250
-        foreach($modifiers as $i=>$a)
250
+        foreach ($modifiers as $i=>$a)
251 251
         {
252
-            $value = $this->Filter($key,$value, $a['cmd'], $a['opt']);
252
+            $value = $this->Filter($key, $value, $a['cmd'], $a['opt']);
253 253
         }
254 254
         $this->tmpCache[$cacheKey] = $value;
255 255
         return $value;
256 256
     }
257 257
 
258 258
     // Parser: modifier detection and eXtended processing if needed
259
-    public function Filter($key, $value, $cmd, $opt='')
259
+    public function Filter($key, $value, $cmd, $opt = '')
260 260
     {
261 261
         global $modx;
262 262
 
263
-        if($key==='documentObject') $value = $modx->documentIdentifier;
263
+        if ($key === 'documentObject') $value = $modx->documentIdentifier;
264 264
         $cmd = $this->parseDocumentSource($cmd);
265
-        if(preg_match('@^[1-9][/0-9]*$@',$cmd))
265
+        if (preg_match('@^[1-9][/0-9]*$@', $cmd))
266 266
         {
267
-            if(strpos($cmd,'/')!==false)
268
-                $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
267
+            if (strpos($cmd, '/') !== false)
268
+                $cmd = $this->substr($cmd, strrpos($cmd, '/') + 1);
269 269
             $opt = $cmd;
270 270
             $cmd = 'id';
271 271
         }
272 272
 
273
-        if(isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
274
-        elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
273
+        if (isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
274
+        elseif (isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
275 275
         else                                           $this->elmName = '';
276 276
 
277 277
         $cmd = strtolower($cmd);
278
-        if($this->elmName!=='')
278
+        if ($this->elmName !== '')
279 279
             $value = $this->getValueFromElement($key, $value, $cmd, $opt);
280 280
         else
281 281
             $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
@@ -285,12 +285,12 @@  discard block
 block discarded – undo
285 285
         return $value;
286 286
     }
287 287
 
288
-    public function isEmpty($cmd,$value)
288
+    public function isEmpty($cmd, $value)
289 289
     {
290
-        if($value!=='') return false;
290
+        if ($value !== '') return false;
291 291
 
292
-        $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
293
-        if(in_array($cmd,$_)) return false;
292
+        $_ = explode(',', $this->condModifiers.',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
293
+        if (in_array($cmd, $_)) return false;
294 294
         else                  return true;
295 295
     }
296 296
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
     {
299 299
         global $modx;
300 300
 
301
-        if($this->isEmpty($cmd,$value)) return '';
301
+        if ($this->isEmpty($cmd, $value)) return '';
302 302
 
303 303
         $this->key = $key;
304 304
         $this->value  = $value;
@@ -309,83 +309,83 @@  discard block
 block discarded – undo
309 309
             #####  Conditional Modifiers
310 310
             case 'input':
311 311
             case 'if':
312
-                if(!$opt) return $value;
312
+                if (!$opt) return $value;
313 313
                 return $opt;
314 314
             case '=':
315 315
             case 'eq':
316 316
             case 'is':
317 317
             case 'equals':
318
-                $this->condition[] = (int)($value == $opt); break;
318
+                $this->condition[] = (int) ($value == $opt); break;
319 319
             case 'neq':
320 320
             case 'ne':
321 321
             case 'notequals':
322 322
             case 'isnot':
323 323
             case 'isnt':
324 324
             case 'not':
325
-                $this->condition[] = (int)($value != $opt);break;
325
+                $this->condition[] = (int) ($value != $opt); break;
326 326
             case '%':
327
-                $this->condition[] = (int)($value%$opt==0);break;
327
+                $this->condition[] = (int) ($value % $opt == 0); break;
328 328
             case 'isempty':
329
-                $this->condition[] = (int)(empty($value)); break;
329
+                $this->condition[] = (int) (empty($value)); break;
330 330
             case 'isntempty':
331 331
             case 'isnotempty':
332
-                $this->condition[] = (int)(!empty($value)); break;
332
+                $this->condition[] = (int) (!empty($value)); break;
333 333
             case '>=':
334 334
             case 'gte':
335 335
             case 'eg':
336 336
             case 'isgte':
337
-                $this->condition[] = (int)($value >= $opt);break;
337
+                $this->condition[] = (int) ($value >= $opt); break;
338 338
             case '<=':
339 339
             case 'lte':
340 340
             case 'el':
341 341
             case 'islte':
342
-                $this->condition[] = (int)($value <= $opt);break;
342
+                $this->condition[] = (int) ($value <= $opt); break;
343 343
             case '>':
344 344
             case 'gt':
345 345
             case 'greaterthan':
346 346
             case 'isgreaterthan':
347 347
             case 'isgt':
348
-                $this->condition[] = (int)($value > $opt);break;
348
+                $this->condition[] = (int) ($value > $opt); break;
349 349
             case '<':
350 350
             case 'lt':
351 351
             case 'lowerthan':
352 352
             case 'islowerthan':
353 353
             case 'islt':
354
-                $this->condition[] = (int)($value < $opt);break;
354
+                $this->condition[] = (int) ($value < $opt); break;
355 355
             case 'find':
356
-                $this->condition[] = (int)(strpos($value, $opt)!==false);break;
356
+                $this->condition[] = (int) (strpos($value, $opt) !== false); break;
357 357
             case 'inarray':
358 358
             case 'in_array':
359 359
             case 'in':
360 360
                 $opt = explode(',', $opt);
361
-                $this->condition[] = (int)(in_array($value, $opt)!==false);break;
361
+                $this->condition[] = (int) (in_array($value, $opt) !== false); break;
362 362
             case 'wildcard_match':
363 363
             case 'wcard_match':
364 364
             case 'wildcard':
365 365
             case 'wcard':
366 366
             case 'fnmatch':
367
-                $this->condition[] = (int)(fnmatch($opt, $value)!==false);break;
367
+                $this->condition[] = (int) (fnmatch($opt, $value) !== false); break;
368 368
             case 'is_file':
369 369
             case 'is_dir':
370 370
             case 'file_exists':
371 371
             case 'is_readable':
372 372
             case 'is_writable':
373
-                if(!$opt) $path = $value;
373
+                if (!$opt) $path = $value;
374 374
                 else      $path = $opt;
375
-                if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path');
376
-                if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/');
377
-                $this->condition[] = (int)($cmd($path)!==false);break;
375
+                if (strpos($path, MODX_MANAGER_PATH) !== false) exit('Can not read core path');
376
+                if (strpos($path, $modx->config['base_path']) === false) $path = ltrim($path, '/');
377
+                $this->condition[] = (int) ($cmd($path) !== false); break;
378 378
             case 'is_image':
379
-                if(!$opt) $path = $value;
379
+                if (!$opt) $path = $value;
380 380
                 else      $path = $opt;
381
-                if(!is_file($path)) {$this->condition[]='0';break;}
381
+                if (!is_file($path)) {$this->condition[] = '0'; break; }
382 382
                 $_ = getimagesize($path);
383
-                $this->condition[] = (int)($_[0]);break;
383
+                $this->condition[] = (int) ($_[0]); break;
384 384
             case 'regex':
385 385
             case 'preg':
386 386
             case 'preg_match':
387 387
             case 'isinrole':
388
-            $this->condition[] = (int)(preg_match($opt,$value));break;
388
+            $this->condition[] = (int) (preg_match($opt, $value)); break;
389 389
             case 'ir':
390 390
             case 'memberof':
391 391
             case 'mo':
@@ -393,50 +393,50 @@  discard block
 block discarded – undo
393 393
                 $this->condition[] = $this->includeMdfFile('memberof');
394 394
                 break;
395 395
             case 'or':
396
-                $this->condition[] = '||';break;
396
+                $this->condition[] = '||'; break;
397 397
             case 'and':
398
-                $this->condition[] = '&&';break;
398
+                $this->condition[] = '&&'; break;
399 399
             case 'show':
400 400
             case 'this':
401
-                $conditional = implode(' ',$this->condition);
402
-                $isvalid = (int)(eval("return ({$conditional});"));
401
+                $conditional = implode(' ', $this->condition);
402
+                $isvalid = (int) (eval("return ({$conditional});"));
403 403
                 if ($isvalid) return $this->srcValue;
404 404
                 return NULL;
405 405
             case 'then':
406
-                $conditional = implode(' ',$this->condition);
407
-                $isvalid = (int)eval("return ({$conditional});");
406
+                $conditional = implode(' ', $this->condition);
407
+                $isvalid = (int) eval("return ({$conditional});");
408 408
                 if ($isvalid)  return $opt;
409 409
                 return null;
410 410
             case 'else':
411
-                $conditional = implode(' ',$this->condition);
412
-                $isvalid = (int)eval("return ({$conditional});");
411
+                $conditional = implode(' ', $this->condition);
412
+                $isvalid = (int) eval("return ({$conditional});");
413 413
                 if (!$isvalid) return $opt;
414 414
                 break;
415 415
             case 'select':
416 416
             case 'switch':
417
-                $raw = explode('&',$opt);
417
+                $raw = explode('&', $opt);
418 418
                 $map = array();
419 419
                 $c = count($raw);
420
-                for($m=0; $m<$c; $m++) {
421
-                    $mi = explode('=',$raw[$m],2);
420
+                for ($m = 0; $m < $c; $m++) {
421
+                    $mi = explode('=', $raw[$m], 2);
422 422
                     $map[$mi[0]] = $mi[1];
423 423
                 }
424
-                if(isset($map[$value])) return $map[$value];
424
+                if (isset($map[$value])) return $map[$value];
425 425
                 else                    return '';
426 426
             ##### End of Conditional Modifiers
427 427
 
428 428
             #####  Encode / Decode / Hash / Escape
429 429
             case 'htmlent':
430 430
             case 'htmlentities':
431
-                return htmlentities($value,ENT_QUOTES,$modx->config['modx_charset']);
431
+                return htmlentities($value, ENT_QUOTES, $modx->config['modx_charset']);
432 432
             case 'html_entity_decode':
433 433
             case 'decode_html':
434 434
             case 'html_decode':
435
-                return html_entity_decode($value,ENT_QUOTES,$modx->config['modx_charset']);
435
+                return html_entity_decode($value, ENT_QUOTES, $modx->config['modx_charset']);
436 436
             case 'esc':
437 437
             case 'escape':
438 438
                 $value = preg_replace('/&amp;(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset']));
439
-                return str_replace(array('[', ']', '`'),array('&#91;', '&#93;', '&#96;'),$value);
439
+                return str_replace(array('[', ']', '`'), array('&#91;', '&#93;', '&#96;'), $value);
440 440
             case 'sql_escape':
441 441
             case 'encode_js':
442 442
                 return $modx->db->escape($value);
@@ -446,39 +446,39 @@  discard block
 block discarded – undo
446 446
             case 'html_encode':
447 447
                 return preg_replace('/&amp;(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset']));
448 448
             case 'spam_protect':
449
-                return str_replace(array('@','.'),array('&#64;','&#46;'),$value);
449
+                return str_replace(array('@', '.'), array('&#64;', '&#46;'), $value);
450 450
             case 'strip':
451
-                if($opt==='') $opt = ' ';
451
+                if ($opt === '') $opt = ' ';
452 452
                 return preg_replace('/[\n\r\t\s]+/', $opt, $value);
453 453
             case 'strip_linefeeds':
454
-                return str_replace(array("\n","\r"), '', $value);
454
+                return str_replace(array("\n", "\r"), '', $value);
455 455
             case 'notags':
456 456
             case 'strip_tags':
457 457
             case 'remove_html':
458
-                if($opt!=='')
458
+                if ($opt !== '')
459 459
                 {
460 460
                     $param = array();
461
-                    foreach(explode(',',$opt) as $v)
461
+                    foreach (explode(',', $opt) as $v)
462 462
                     {
463
-                        $v = trim($v,'</> ');
463
+                        $v = trim($v, '</> ');
464 464
                         $param[] = "<{$v}>";
465 465
                     }
466
-                    $params = implode(',',$param);
466
+                    $params = implode(',', $param);
467 467
                 }
468 468
                 else $params = '';
469
-                if(!strpos($params,'<br>')===false) {
470
-                    $value = preg_replace('@(<br[ /]*>)\n@','$1',$value);
471
-                    $value = preg_replace('@<br[ /]*>@',"\n",$value);
469
+                if (!strpos($params, '<br>') === false) {
470
+                    $value = preg_replace('@(<br[ /]*>)\n@', '$1', $value);
471
+                    $value = preg_replace('@<br[ /]*>@', "\n", $value);
472 472
                 }
473
-                return $this->strip_tags($value,$params);
473
+                return $this->strip_tags($value, $params);
474 474
             case 'urlencode':
475 475
             case 'url_encode':
476 476
             case 'encode_url':
477 477
                 return urlencode($value);
478 478
             case 'base64_decode':
479
-                if($opt!=='false') $opt = true;
479
+                if ($opt !== 'false') $opt = true;
480 480
                 else               $opt = false;
481
-                return base64_decode($value,$opt);
481
+                return base64_decode($value, $opt);
482 482
             case 'encode_sha1': $cmd = 'sha1';
483 483
             case 'addslashes':
484 484
             case 'urldecode':
@@ -502,18 +502,18 @@  discard block
 block discarded – undo
502 502
             case 'upper_case':
503 503
                 return $this->strtoupper($value);
504 504
             case 'capitalize':
505
-                $_ = explode(' ',$value);
506
-                foreach($_ as $i=>$v)
505
+                $_ = explode(' ', $value);
506
+                foreach ($_ as $i=>$v)
507 507
                 {
508 508
                     $_[$i] = ucfirst($v);
509 509
                 }
510
-                return implode(' ',$_);
510
+                return implode(' ', $_);
511 511
             case 'zenhan':
512
-                if(empty($opt)) $opt='VKas';
513
-                return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
512
+                if (empty($opt)) $opt = 'VKas';
513
+                return mb_convert_kana($value, $opt, $modx->config['modx_charset']);
514 514
             case 'hanzen':
515
-                if(empty($opt)) $opt='VKAS';
516
-                return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
515
+                if (empty($opt)) $opt = 'VKAS';
516
+                return mb_convert_kana($value, $opt, $modx->config['modx_charset']);
517 517
             case 'str_shuffle':
518 518
             case 'shuffle':
519 519
                 return $this->str_shuffle($value);
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
                 return $this->strlen($value);
528 528
             case 'count_words':
529 529
                 $value = trim($value);
530
-                return count(preg_split('/\s+/',$value));
530
+                return count(preg_split('/\s+/', $value));
531 531
             case 'str_word_count':
532 532
             case 'word_count':
533 533
             case 'wordcount':
@@ -535,55 +535,55 @@  discard block
 block discarded – undo
535 535
             case 'count_paragraphs':
536 536
                 $value = trim($value);
537 537
                 $value = preg_replace('/\r/', '', $value);
538
-                return count(preg_split('/\n+/',$value));
538
+                return count(preg_split('/\n+/', $value));
539 539
             case 'strpos':
540
-                if($opt!=0&&empty($opt)) return $value;
541
-                return $this->strpos($value,$opt);
540
+                if ($opt != 0 && empty($opt)) return $value;
541
+                return $this->strpos($value, $opt);
542 542
             case 'wordwrap':
543 543
                 // default: 70
544
-                  $wrapat = (int)$opt > 0 ? (int)$opt : 70;
544
+                  $wrapat = (int) $opt > 0 ? (int) $opt : 70;
545 545
                 if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap');
546
-                else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
546
+                else return preg_replace("@(\b\w+\b)@e", "wordwrap('\\1',\$wrapat,' ',1)", $value);
547 547
             case 'wrap_text':
548
-                $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70;
549
-                if($modx->config['manager_language']==='japanese-utf8') {
548
+                $width = preg_match('/^[1-9][0-9]*$/', $opt) ? $opt : 70;
549
+                if ($modx->config['manager_language'] === 'japanese-utf8') {
550 550
                     $chunk = array();
551
-                    $bt='';
552
-                    while($bt!=$value) {
551
+                    $bt = '';
552
+                    while ($bt != $value) {
553 553
                         $bt = $value;
554
-                        if($this->strlen($value)<$width) {
554
+                        if ($this->strlen($value) < $width) {
555 555
                             $chunk[] = $value;
556 556
                             break;
557 557
                         }
558
-                        $chunk[] = $this->substr($value,0,$width);
559
-                        $value = $this->substr($value,$width);
558
+                        $chunk[] = $this->substr($value, 0, $width);
559
+                        $value = $this->substr($value, $width);
560 560
                     }
561
-                    return implode("\n",$chunk);
561
+                    return implode("\n", $chunk);
562 562
                 }
563 563
                 else
564
-                    return wordwrap($value,$width,"\n",true);
564
+                    return wordwrap($value, $width, "\n", true);
565 565
             case 'substr':
566
-                if(empty($opt)) break;
567
-                if(strpos($opt,',')!==false) {
568
-                    list($b,$e) = explode(',',$opt,2);
569
-                    return $this->substr($value,$b,(int)$e);
566
+                if (empty($opt)) break;
567
+                if (strpos($opt, ',') !== false) {
568
+                    list($b, $e) = explode(',', $opt, 2);
569
+                    return $this->substr($value, $b, (int) $e);
570 570
                 }
571
-                else return $this->substr($value,$opt);
571
+                else return $this->substr($value, $opt);
572 572
             case 'limit':
573 573
             case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html
574
-                if(strpos($opt,'+')!==false)
575
-                    list($len,$str) = explode('+',$opt,2);
574
+                if (strpos($opt, '+') !== false)
575
+                    list($len, $str) = explode('+', $opt, 2);
576 576
                 else {
577 577
                     $len = $opt;
578 578
                     $str = '';
579 579
                 }
580
-                if($len==='') $len = 100;
581
-                if(abs($len) > $this->strlen($value)) $str ='';
582
-                if(preg_match('/^[1-9][0-9]*$/',$len)) {
583
-                    return $this->substr($value,0,$len) . $str;
580
+                if ($len === '') $len = 100;
581
+                if (abs($len) > $this->strlen($value)) $str = '';
582
+                if (preg_match('/^[1-9][0-9]*$/', $len)) {
583
+                    return $this->substr($value, 0, $len).$str;
584 584
                 }
585
-                elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
586
-                    return $str . $this->substr($value,$len);
585
+                elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) {
586
+                    return $str.$this->substr($value, $len);
587 587
                 }
588 588
                 break;
589 589
             case 'summary':
@@ -592,81 +592,81 @@  discard block
 block discarded – undo
592 592
                 return $this->includeMdfFile('summary');
593 593
             case 'replace':
594 594
             case 'str_replace':
595
-                if(empty($opt) || strpos($opt,',')===false) break;
596
-                if    (substr_count($opt, ',') ==1) $delim = ',';
597
-                elseif(substr_count($opt, '|') ==1) $delim = '|';
598
-                elseif(substr_count($opt, '=>')==1) $delim = '=>';
599
-                elseif(substr_count($opt, '/') ==1) $delim = '/';
595
+                if (empty($opt) || strpos($opt, ',') === false) break;
596
+                if (substr_count($opt, ',') == 1) $delim = ',';
597
+                elseif (substr_count($opt, '|') == 1) $delim = '|';
598
+                elseif (substr_count($opt, '=>') == 1) $delim = '=>';
599
+                elseif (substr_count($opt, '/') == 1) $delim = '/';
600 600
                 else break;
601
-                list($s,$r) = explode($delim,$opt);
602
-                if($value!=='') return str_replace($s,$r,$value);
601
+                list($s, $r) = explode($delim, $opt);
602
+                if ($value !== '') return str_replace($s, $r, $value);
603 603
                 break;
604 604
             case 'replace_to':
605 605
             case 'tpl':
606
-                if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
606
+                if ($value !== '') return str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $value, $opt);
607 607
                 break;
608 608
             case 'eachtpl':
609
-                $value = explode('||',$value);
609
+                $value = explode('||', $value);
610 610
                 $_ = array();
611
-                foreach($value as $v) {
612
-                    $_[] = str_replace(array('[+value+]','[+output+]','{value}','%s'),$v,$opt);
611
+                foreach ($value as $v) {
612
+                    $_[] = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $v, $opt);
613 613
                 }
614 614
                 return implode("\n", $_);
615 615
             case 'array_pop':
616 616
             case 'array_shift':
617
-                if(strpos($value,'||')!==false) $delim = '||';
617
+                if (strpos($value, '||') !== false) $delim = '||';
618 618
                 else                            $delim = ',';
619
-                return $cmd(explode($delim,$value));
619
+                return $cmd(explode($delim, $value));
620 620
             case 'preg_replace':
621 621
             case 'regex_replace':
622
-                if(empty($opt) || strpos($opt,',')===false) break;
623
-                list($s,$r) = explode(',',$opt,2);
624
-                if($value!=='') return preg_replace($s,$r,$value);
622
+                if (empty($opt) || strpos($opt, ',') === false) break;
623
+                list($s, $r) = explode(',', $opt, 2);
624
+                if ($value !== '') return preg_replace($s, $r, $value);
625 625
                 break;
626 626
             case 'cat':
627 627
             case 'concatenate':
628 628
             case '.':
629
-                if($value!=='') return $value . $opt;
629
+                if ($value !== '') return $value.$opt;
630 630
                 break;
631 631
             case 'sprintf':
632 632
             case 'string_format':
633
-                if($value!=='') return sprintf($opt,$value);
633
+                if ($value !== '') return sprintf($opt, $value);
634 634
                 break;
635 635
             case 'number_format':
636
-                    if($opt=='') $opt = 0;
637
-                    return number_format($value,$opt);
636
+                    if ($opt == '') $opt = 0;
637
+                    return number_format($value, $opt);
638 638
             case 'money_format':
639
-                    setlocale(LC_MONETARY,setlocale(LC_TIME,0));
640
-                    if($value!=='') return money_format($opt,(double)$value);
639
+                    setlocale(LC_MONETARY, setlocale(LC_TIME, 0));
640
+                    if ($value !== '') return money_format($opt, (double) $value);
641 641
                     break;
642 642
             case 'tobool':
643 643
                 return boolval($value);
644 644
             case 'nl2lf':
645
-                if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value);
645
+                if ($value !== '') return str_replace(array("\r\n", "\n", "\r"), '\n', $value);
646 646
                 break;
647 647
             case 'br2nl':
648 648
                 return preg_replace('@<br[\s/]*>@i', "\n", $value);
649 649
             case 'nl2br':
650 650
                 if (version_compare(PHP_VERSION, '5.3.0', '<'))
651 651
                     return nl2br($value);
652
-                if($opt!=='')
652
+                if ($opt !== '')
653 653
                 {
654 654
                     $opt = trim($opt);
655 655
                     $opt = strtolower($opt);
656
-                    if($opt==='false') $opt = false;
657
-                    elseif($opt==='0') $opt = false;
656
+                    if ($opt === 'false') $opt = false;
657
+                    elseif ($opt === '0') $opt = false;
658 658
                     else               $opt = true;
659 659
                 }
660
-                elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html')
660
+                elseif (isset($modx->config['mce_element_format']) && $modx->config['mce_element_format'] === 'html')
661 661
                                        $opt = false;
662 662
                 else                   $opt = true;
663
-                return nl2br($value,$opt);
663
+                return nl2br($value, $opt);
664 664
             case 'ltrim':
665 665
             case 'rtrim':
666 666
             case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html
667
-                if($opt==='')
667
+                if ($opt === '')
668 668
                     return $cmd($value);
669
-                else return $cmd($value,$opt);
669
+                else return $cmd($value, $opt);
670 670
             // These are all straight wrappers for PHP functions
671 671
             case 'ucfirst':
672 672
             case 'lcfirst':
@@ -677,58 +677,58 @@  discard block
 block discarded – undo
677 677
             case 'strftime':
678 678
             case 'date':
679 679
             case 'dateformat':
680
-                if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
681
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
682
-                if(strpos($opt,'%')!==false)
683
-                    return strftime($opt,0+$value);
680
+                if (empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
681
+                if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value);
682
+                if (strpos($opt, '%') !== false)
683
+                    return strftime($opt, 0 + $value);
684 684
                 else
685
-                    return date($opt,0+$value);
685
+                    return date($opt, 0 + $value);
686 686
             case 'time':
687
-                if(empty($opt)) $opt = '%H:%M';
688
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
689
-                return strftime($opt,0+$value);
687
+                if (empty($opt)) $opt = '%H:%M';
688
+                if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value);
689
+                return strftime($opt, 0 + $value);
690 690
             case 'strtotime':
691 691
                 return strtotime($value);
692 692
             #####  mathematical function
693 693
             case 'toint':
694
-                return (int)$value;
694
+                return (int) $value;
695 695
             case 'tofloat':
696 696
                 return floatval($value);
697 697
             case 'round':
698
-                if(!$opt) $opt = 0;
699
-                return $cmd($value,$opt);
698
+                if (!$opt) $opt = 0;
699
+                return $cmd($value, $opt);
700 700
             case 'max':
701 701
             case 'min':
702
-                return $cmd(explode(',',$value));
702
+                return $cmd(explode(',', $value));
703 703
             case 'floor':
704 704
             case 'ceil':
705 705
             case 'abs':
706 706
                 return $cmd($value);
707 707
             case 'math':
708 708
             case 'calc':
709
-                $value = (int)$value;
710
-                if(empty($value)) $value = '0';
711
-                $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt);
712
-                $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter);
713
-                if(strpos($filter,'?')===false) $filter = "?{$filter}";
714
-                $filter = str_replace('?',$value,$filter);
709
+                $value = (int) $value;
710
+                if (empty($value)) $value = '0';
711
+                $filter = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), '?', $opt);
712
+                $filter = preg_replace('@([a-zA-Z\n\r\t\s])@', '', $filter);
713
+                if (strpos($filter, '?') === false) $filter = "?{$filter}";
714
+                $filter = str_replace('?', $value, $filter);
715 715
                 return eval("return {$filter};");
716 716
             case 'count':
717
-                if($value=='') return 0;
718
-                $value = explode(',',$value);
717
+                if ($value == '') return 0;
718
+                $value = explode(',', $value);
719 719
                 return count($value);
720 720
             case 'sort':
721 721
             case 'rsort':
722
-                if(strpos($value,"\n")!==false) $delim="\n";
722
+                if (strpos($value, "\n") !== false) $delim = "\n";
723 723
                 else $delim = ',';
724
-                $swap = explode($delim,$value);
725
-                if(!$opt) $opt = SORT_REGULAR;
724
+                $swap = explode($delim, $value);
725
+                if (!$opt) $opt = SORT_REGULAR;
726 726
                 else      $opt = constant($opt);
727
-                $cmd($swap,$opt);
728
-                return implode($delim,$swap);
727
+                $cmd($swap, $opt);
728
+                return implode($delim, $swap);
729 729
             #####  Resource fields
730 730
             case 'id':
731
-                if($opt) return $this->getDocumentObject($opt,$key);
731
+                if ($opt) return $this->getDocumentObject($opt, $key);
732 732
                 break;
733 733
             case 'type':
734 734
             case 'contenttype':
@@ -765,36 +765,36 @@  discard block
 block discarded – undo
765 765
             case 'privatemgr':
766 766
             case 'content_dispo':
767 767
             case 'hidemenu':
768
-                if($cmd==='contenttype') $cmd = 'contentType';
769
-                return $this->getDocumentObject($value,$cmd);
768
+                if ($cmd === 'contenttype') $cmd = 'contentType';
769
+                return $this->getDocumentObject($value, $cmd);
770 770
             case 'title':
771
-                $pagetitle = $this->getDocumentObject($value,'pagetitle');
772
-                $longtitle = $this->getDocumentObject($value,'longtitle');
771
+                $pagetitle = $this->getDocumentObject($value, 'pagetitle');
772
+                $longtitle = $this->getDocumentObject($value, 'longtitle');
773 773
                 return $longtitle ? $longtitle : $pagetitle;
774 774
             case 'shorttitle':
775
-                $pagetitle = $this->getDocumentObject($value,'pagetitle');
776
-                $menutitle = $this->getDocumentObject($value,'menutitle');
775
+                $pagetitle = $this->getDocumentObject($value, 'pagetitle');
776
+                $menutitle = $this->getDocumentObject($value, 'menutitle');
777 777
                 return $menutitle ? $menutitle : $pagetitle;
778 778
             case 'templatename':
779
-                $rs = $modx->db->select('templatename','[+prefix+]site_templates',"id='{$value}'");
779
+                $rs = $modx->db->select('templatename', '[+prefix+]site_templates', "id='{$value}'");
780 780
                 $templateName = $modx->db->getValue($rs);
781 781
                 return !$templateName ? '(blank)' : $templateName;
782 782
             case 'getfield':
783
-                if(!$opt) $opt = 'content';
784
-                return $modx->getField($opt,$value);
783
+                if (!$opt) $opt = 'content';
784
+                return $modx->getField($opt, $value);
785 785
             case 'children':
786 786
             case 'childids':
787
-                if($value=='') $value = 0; // 値がない場合はルートと見なす
787
+                if ($value == '') $value = 0; // 値がない場合はルートと見なす
788 788
                 $published = 1;
789
-                if($opt=='') $opt = 'page';
790
-                $_ = explode(',',$opt);
789
+                if ($opt == '') $opt = 'page';
790
+                $_ = explode(',', $opt);
791 791
                 $where = array();
792
-                foreach($_ as $opt) {
793
-                    switch(trim($opt)) {
792
+                foreach ($_ as $opt) {
793
+                    switch (trim($opt)) {
794 794
                         case 'page'; case '!folder'; case '!isfolder': $where[] = 'sc.isfolder=0'; break;
795 795
                         case 'folder'; case 'isfolder':                $where[] = 'sc.isfolder=1'; break;
796
-                        case  'menu';  case  'show_menu':              $where[] = 'sc.hidemenu=0'; break;
797
-                        case '!menu';  case '!show_menu':              $where[] = 'sc.hidemenu=1'; break;
796
+                        case  'menu'; case  'show_menu':              $where[] = 'sc.hidemenu=0'; break;
797
+                        case '!menu'; case '!show_menu':              $where[] = 'sc.hidemenu=1'; break;
798 798
                         case  'published':                             $published = 1; break;
799 799
                         case '!published':                             $published = 0; break;
800 800
                     }
@@ -802,69 +802,69 @@  discard block
 block discarded – undo
802 802
                 $where = implode(' AND ', $where);
803 803
                 $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where);
804 804
                 $result = array();
805
-                foreach((array)$children as $child){
805
+                foreach ((array) $children as $child) {
806 806
                     $result[] = $child['id'];
807 807
                 }
808 808
                 return implode(',', $result);
809 809
             case 'fullurl':
810
-                if(!is_numeric($value)) return $value;
810
+                if (!is_numeric($value)) return $value;
811 811
                 return $modx->makeUrl($value);
812 812
             case 'makeurl':
813
-                if(!is_numeric($value)) return $value;
814
-                if(!$opt) $opt = 'full';
815
-                return $modx->makeUrl($value,'','',$opt);
813
+                if (!is_numeric($value)) return $value;
814
+                if (!$opt) $opt = 'full';
815
+                return $modx->makeUrl($value, '', '', $opt);
816 816
 
817 817
             #####  File system
818 818
             case 'getimageinfo':
819 819
             case 'imageinfo':
820
-                if(!is_file($value)) return '';
820
+                if (!is_file($value)) return '';
821 821
                 $_ = getimagesize($value);
822
-                if(!$_[0]) return '';
822
+                if (!$_[0]) return '';
823 823
                 $info['width']  = $_[0];
824 824
                 $info['height'] = $_[1];
825
-                if    ($_[0] > $_[1]) $info['aspect'] = 'landscape';
826
-                elseif($_[0] < $_[1]) $info['aspect'] = 'portrait';
825
+                if ($_[0] > $_[1]) $info['aspect'] = 'landscape';
826
+                elseif ($_[0] < $_[1]) $info['aspect'] = 'portrait';
827 827
                 else                  $info['aspect'] = 'square';
828
-                switch($_[2]) {
828
+                switch ($_[2]) {
829 829
                     case IMAGETYPE_GIF  : $info['type'] = 'gif'; break;
830 830
                     case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break;
831 831
                     case IMAGETYPE_PNG  : $info['type'] = 'png'; break;
832 832
                     default             : $info['type'] = 'unknown';
833 833
                 }
834 834
                 $info['attrib'] = $_[3];
835
-                switch($opt) {
835
+                switch ($opt) {
836 836
                     case 'width' : return $info['width'];
837 837
                     case 'height': return $info['height'];
838 838
                     case 'aspect': return $info['aspect'];
839 839
                     case 'type'  : return $info['type'];
840 840
                     case 'attrib': return $info['attrib'];
841
-                    default      : return print_r($info,true);
841
+                    default      : return print_r($info, true);
842 842
                 }
843 843
 
844 844
             case 'file_get_contents':
845 845
             case 'readfile':
846
-                if(!is_file($value)) return $value;
846
+                if (!is_file($value)) return $value;
847 847
                 $value = realpath($value);
848
-                if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file');
849
-                $ext = strtolower(substr($value,-4));
850
-                if($ext==='.php') exit('Can not read php file');
851
-                if($ext==='.cgi') exit('Can not read cgi file');
848
+                if (strpos($value, MODX_MANAGER_PATH) !== false) exit('Can not read core file');
849
+                $ext = strtolower(substr($value, -4));
850
+                if ($ext === '.php') exit('Can not read php file');
851
+                if ($ext === '.cgi') exit('Can not read cgi file');
852 852
                 return file_get_contents($value);
853 853
             case 'filesize':
854
-                if($value == '') return '';
854
+                if ($value == '') return '';
855 855
                 $filename = $value;
856 856
 
857 857
                 $site_url = $modx->config['site_url'];
858
-                if(strpos($filename,$site_url) === 0)
859
-                    $filename = substr($filename,0,strlen($site_url));
860
-                $filename = trim($filename,'/');
858
+                if (strpos($filename, $site_url) === 0)
859
+                    $filename = substr($filename, 0, strlen($site_url));
860
+                $filename = trim($filename, '/');
861 861
 
862
-                $opt = trim($opt,'/');
863
-                if($opt!=='') $opt .= '/';
862
+                $opt = trim($opt, '/');
863
+                if ($opt !== '') $opt .= '/';
864 864
 
865 865
                 $filename = MODX_BASE_PATH.$opt.$filename;
866 866
 
867
-                if(is_file($filename)){
867
+                if (is_file($filename)) {
868 868
                     clearstatcache();
869 869
                     $size = filesize($filename);
870 870
                     return $size;
@@ -897,10 +897,10 @@  discard block
 block discarded – undo
897 897
                 $this->opt = $cmd;
898 898
                 return $this->includeMdfFile('moduser');
899 899
             case 'userinfo':
900
-                if(empty($opt)) $this->opt = 'username';
900
+                if (empty($opt)) $this->opt = 'username';
901 901
                 return $this->includeMdfFile('moduser');
902 902
             case 'webuserinfo':
903
-                if(empty($opt)) $this->opt = 'username';
903
+                if (empty($opt)) $this->opt = 'username';
904 904
                 $this->value = -$value;
905 905
                 return $this->includeMdfFile('moduser');
906 906
             #####  Special functions
@@ -911,27 +911,27 @@  discard block
 block discarded – undo
911 911
             case 'ifnotempty':
912 912
                 if (!empty($value)) return $opt; break;
913 913
             case 'datagrid':
914
-                include_once(MODX_CORE_PATH . 'controls/datagrid.class.php');
914
+                include_once(MODX_CORE_PATH.'controls/datagrid.class.php');
915 915
                 $grd = new DataGrid(null, trim($value));
916 916
                 $grd->itemStyle = '';
917 917
                 $grd->altItemStyle = '';
918
-                $pos = strpos($value,"\n");
919
-                if($pos) $_ = substr($value,0,$pos);
918
+                $pos = strpos($value, "\n");
919
+                if ($pos) $_ = substr($value, 0, $pos);
920 920
                 else $_ = $pos;
921
-                $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ',';
921
+                $grd->cdelim = strpos($_, "\t") !== false ? 'tab' : ',';
922 922
                 return $grd->render();
923 923
             case 'rotate':
924 924
             case 'evenodd':
925
-                if(strpos($opt,',')===false) $opt = 'odd,even';
925
+                if (strpos($opt, ',') === false) $opt = 'odd,even';
926 926
                 $_ = explode(',', $opt);
927 927
                 $c = count($_);
928 928
                 $i = $value + $c;
929 929
                 $i = $i % $c;
930 930
                 return $_[$i];
931 931
             case 'takeval':
932
-                $arr = explode(",",$opt);
932
+                $arr = explode(",", $opt);
933 933
                 $idx = $value;
934
-                if(!is_numeric($idx)) return $value;
934
+                if (!is_numeric($idx)) return $value;
935 935
                 return $arr[$idx];
936 936
             case 'getimage':
937 937
                 return $this->includeMdfFile('getimage');
@@ -939,17 +939,17 @@  discard block
 block discarded – undo
939 939
                     return $modx->nicesize($value);
940 940
             case 'googlemap':
941 941
             case 'googlemaps':
942
-                if(empty($opt)) $opt = 'border:none;width:500px;height:350px;';
942
+                if (empty($opt)) $opt = 'border:none;width:500px;height:350px;';
943 943
                 $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>';
944 944
                 $ph['style'] = $opt;
945 945
                 $ph['value'] = $value;
946
-                return $modx->parseText($tpl,$ph);
946
+                return $modx->parseText($tpl, $ph);
947 947
             case 'youtube':
948 948
             case 'youtube16x9':
949
-                if(empty($opt)) $opt = 560;
950
-                $h = round($opt*0.5625);
949
+                if (empty($opt)) $opt = 560;
950
+                $h = round($opt * 0.5625);
951 951
                 $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>';
952
-                return sprintf($tpl,$opt,$h,$value);
952
+                return sprintf($tpl, $opt, $h, $value);
953 953
             //case 'youtube4x3':%s*0.75+25
954 954
             case 'setvar':
955 955
                 $modx->placeholders[$opt] = $value;
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
         return $value;
980 980
     }
981 981
 
982
-    public function includeMdfFile($cmd) {
982
+    public function includeMdfFile($cmd){
983 983
         global $modx;
984 984
         $key = $this->key;
985 985
         $value  = $this->value;
@@ -990,54 +990,54 @@  discard block
 block discarded – undo
990 990
     public function getValueFromElement($key, $value, $cmd, $opt)
991 991
     {
992 992
         global $modx;
993
-        if( isset($modx->snippetCache[$this->elmName]) )
993
+        if (isset($modx->snippetCache[$this->elmName]))
994 994
         {
995 995
             $php = $modx->snippetCache[$this->elmName];
996 996
         }
997 997
         else
998 998
         {
999 999
             $esc_elmName = $modx->db->escape($this->elmName);
1000
-            $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'");
1000
+            $result = $modx->db->select('snippet', '[+prefix+]site_snippets', "name='{$esc_elmName}'");
1001 1001
             $total = $modx->db->getRecordCount($result);
1002
-            if($total == 1)
1002
+            if ($total == 1)
1003 1003
             {
1004 1004
                 $row = $modx->db->getRow($result);
1005 1005
                 $php = $row['snippet'];
1006 1006
             }
1007
-            elseif($total == 0)
1007
+            elseif ($total == 0)
1008 1008
             {
1009 1009
                 $assets_path = MODX_BASE_PATH.'assets/';
1010
-                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
1010
+                if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
1011 1011
                     $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1012
-                elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
1012
+                elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
1013 1013
                     $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1014
-                elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
1014
+                elseif (is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
1015 1015
                     $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1016 1016
                 else $modifiers_path = false;
1017 1017
 
1018
-                if($modifiers_path !== false) {
1018
+                if ($modifiers_path !== false) {
1019 1019
                     $php = @file_get_contents($modifiers_path);
1020 1020
                     $php = trim($php);
1021
-                    if(substr($php,0,5)==='<?php') $php = substr($php,6);
1022
-                    if(substr($php,0,2)==='<?')    $php = substr($php,3);
1023
-                    if(substr($php,-2)==='?>')     $php = substr($php,0,-2);
1024
-                    if($this->elmName!=='')
1021
+                    if (substr($php, 0, 5) === '<?php') $php = substr($php, 6);
1022
+                    if (substr($php, 0, 2) === '<?')    $php = substr($php, 3);
1023
+                    if (substr($php, -2) === '?>')     $php = substr($php, 0, -2);
1024
+                    if ($this->elmName !== '')
1025 1025
                         $modx->snippetCache[$this->elmName.'Props'] = '';
1026 1026
                 }
1027 1027
                 else
1028 1028
                     $php = false;
1029 1029
             }
1030 1030
             else $php = false;
1031
-            if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php;
1031
+            if ($this->elmName !== '') $modx->snippetCache[$this->elmName] = $php;
1032 1032
         }
1033
-        if($php==='') $php=false;
1033
+        if ($php === '') $php = false;
1034 1034
 
1035
-        if($php===false) $html = $modx->getChunk($this->elmName);
1035
+        if ($php === false) $html = $modx->getChunk($this->elmName);
1036 1036
         else             $html = false;
1037 1037
 
1038 1038
         $self = '[+output+]';
1039 1039
 
1040
-        if($php !== false)
1040
+        if ($php !== false)
1041 1041
         {
1042 1042
             ob_start();
1043 1043
             $options = $opt;
@@ -1050,71 +1050,71 @@  discard block
 block discarded – undo
1050 1050
             $this->vars['options'] = & $opt;
1051 1051
             $custom = eval($php);
1052 1052
             $msg = ob_get_contents();
1053
-            if($value===$this->bt) $value = $msg . $custom;
1053
+            if ($value === $this->bt) $value = $msg.$custom;
1054 1054
             ob_end_clean();
1055 1055
         }
1056
-        elseif($html!==false && isset($value) && $value!=='')
1056
+        elseif ($html !== false && isset($value) && $value !== '')
1057 1057
         {
1058
-            $html = str_replace(array($self,'[+value+]'), $value, $html);
1059
-            $value = str_replace(array('[+options+]','[+param+]'), $opt, $html);
1058
+            $html = str_replace(array($self, '[+value+]'), $value, $html);
1059
+            $value = str_replace(array('[+options+]', '[+param+]'), $opt, $html);
1060 1060
         }
1061 1061
         else return false;
1062 1062
 
1063
-        if($php===false && $html===false && $value!==''
1064
-           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false))
1063
+        if ($php === false && $html === false && $value !== ''
1064
+           && (strpos($cmd, '[+value+]') !== false || strpos($cmd, $self) !== false))
1065 1065
         {
1066
-            $value = str_replace(array('[+value+]',$self),$value,$cmd);
1066
+            $value = str_replace(array('[+value+]', $self), $value, $cmd);
1067 1067
         }
1068 1068
         return $value;
1069 1069
     }
1070 1070
 
1071
-    public function parseDocumentSource($content='')
1071
+    public function parseDocumentSource($content = '')
1072 1072
     {
1073 1073
         global $modx;
1074 1074
 
1075
-        if(strpos($content,'[')===false && strpos($content,'{')===false) return $content;
1075
+        if (strpos($content, '[') === false && strpos($content, '{') === false) return $content;
1076 1076
 
1077
-        if(!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1078
-        $bt='';
1079
-        $i=0;
1080
-        while($bt!==$content)
1077
+        if (!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1078
+        $bt = '';
1079
+        $i = 0;
1080
+        while ($bt !== $content)
1081 1081
         {
1082 1082
             $bt = $content;
1083
-            if(strpos($content,'[*')!==false && $modx->documentIdentifier)
1083
+            if (strpos($content, '[*') !== false && $modx->documentIdentifier)
1084 1084
                                               $content = $modx->mergeDocumentContent($content);
1085
-            if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content);
1086
-            if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content);
1087
-            if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1088
-            if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content);
1085
+            if (strpos($content, '[(') !== false) $content = $modx->mergeSettingsContent($content);
1086
+            if (strpos($content, '{{') !== false) $content = $modx->mergeChunkContent($content);
1087
+            if (strpos($content, '[!') !== false) $content = str_replace(array('[!', '!]'), array('[[', ']]'), $content);
1088
+            if (strpos($content, '[[') !== false) $content = $modx->evalSnippets($content);
1089 1089
 
1090
-            if($content===$bt)              break;
1091
-            if($modx->maxParserPasses < $i) break;
1090
+            if ($content === $bt)              break;
1091
+            if ($modx->maxParserPasses < $i) break;
1092 1092
             $i++;
1093 1093
         }
1094 1094
         return $content;
1095 1095
     }
1096 1096
 
1097
-    public function getDocumentObject($target='',$field='pagetitle')
1097
+    public function getDocumentObject($target = '', $field = 'pagetitle')
1098 1098
     {
1099 1099
         global $modx;
1100 1100
 
1101 1101
         $target = trim($target);
1102
-        if(empty($target)) $target = $modx->config['site_start'];
1103
-        if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id';
1102
+        if (empty($target)) $target = $modx->config['site_start'];
1103
+        if (preg_match('@^[1-9][0-9]*$@', $target)) $method = 'id';
1104 1104
         else $method = 'alias';
1105 1105
 
1106
-        if(!isset($this->documentObject[$target]))
1106
+        if (!isset($this->documentObject[$target]))
1107 1107
         {
1108
-            $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct');
1108
+            $this->documentObject[$target] = $modx->getDocumentObject($method, $target, 'direct');
1109 1109
         }
1110 1110
 
1111
-        if($this->documentObject[$target]['publishedon']==='0')
1111
+        if ($this->documentObject[$target]['publishedon'] === '0')
1112 1112
             return '';
1113
-        elseif(isset($this->documentObject[$target][$field]))
1113
+        elseif (isset($this->documentObject[$target][$field]))
1114 1114
         {
1115
-            if(is_array($this->documentObject[$target][$field]))
1115
+            if (is_array($this->documentObject[$target][$field]))
1116 1116
             {
1117
-                $a = $modx->getTemplateVarOutput($field,$target);
1117
+                $a = $modx->getTemplateVarOutput($field, $target);
1118 1118
                 $this->documentObject[$target][$field] = $a[$field];
1119 1119
             }
1120 1120
         }
@@ -1123,8 +1123,8 @@  discard block
 block discarded – undo
1123 1123
         return $this->documentObject[$target][$field];
1124 1124
     }
1125 1125
 
1126
-    public function setPlaceholders($value = '', $key = '', $path = '') {
1127
-        if($path!=='') $key = "{$path}.{$key}";
1126
+    public function setPlaceholders($value = '', $key = '', $path = ''){
1127
+        if ($path !== '') $key = "{$path}.{$key}";
1128 1128
         if (is_array($value)) {
1129 1129
             foreach ($value as $subkey => $subval) {
1130 1130
                 $this->setPlaceholders($subval, $subkey, $key);
@@ -1134,77 +1134,77 @@  discard block
 block discarded – undo
1134 1134
     }
1135 1135
 
1136 1136
     // Sets a placeholder variable which can only be access by Modifiers
1137
-    public function setModifiersVariable($key, $value) {
1137
+    public function setModifiersVariable($key, $value){
1138 1138
         if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1139 1139
     }
1140 1140
 
1141 1141
     //mbstring
1142
-    public function substr($str, $s, $l = null) {
1142
+    public function substr($str, $s, $l = null){
1143 1143
         global $modx;
1144
-        if(is_null($l)) $l = $this->strlen($str);
1144
+        if (is_null($l)) $l = $this->strlen($str);
1145 1145
         if (function_exists('mb_substr'))
1146 1146
         {
1147
-            if(strpos($str,"\r")!==false)
1148
-                $str = str_replace(array("\r\n","\r"), "\n", $str);
1147
+            if (strpos($str, "\r") !== false)
1148
+                $str = str_replace(array("\r\n", "\r"), "\n", $str);
1149 1149
             return mb_substr($str, $s, $l, $modx->config['modx_charset']);
1150 1150
         }
1151 1151
         return substr($str, $s, $l);
1152 1152
     }
1153
-    public function strpos($haystack,$needle,$offset=0) {
1153
+    public function strpos($haystack, $needle, $offset = 0){
1154 1154
         global $modx;
1155
-        if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1156
-        return strpos($haystack,$needle,$offset);
1155
+        if (function_exists('mb_strpos')) return mb_strpos($haystack, $needle, $offset, $modx->config['modx_charset']);
1156
+        return strpos($haystack, $needle, $offset);
1157 1157
     }
1158
-    public function strlen($str) {
1158
+    public function strlen($str){
1159 1159
         global $modx;
1160
-        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1160
+        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str), $modx->config['modx_charset']);
1161 1161
         return strlen($str);
1162 1162
     }
1163
-    public function strtolower($str) {
1163
+    public function strtolower($str){
1164 1164
         if (function_exists('mb_strtolower')) return mb_strtolower($str);
1165 1165
         return strtolower($str);
1166 1166
     }
1167
-    public function strtoupper($str) {
1167
+    public function strtoupper($str){
1168 1168
         if (function_exists('mb_strtoupper')) return mb_strtoupper($str);
1169 1169
         return strtoupper($str);
1170 1170
     }
1171
-    public function ucfirst($str) {
1171
+    public function ucfirst($str){
1172 1172
         if (function_exists('mb_strtoupper'))
1173 1173
             return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1174 1174
         return ucfirst($str);
1175 1175
     }
1176
-    public function lcfirst($str) {
1176
+    public function lcfirst($str){
1177 1177
         if (function_exists('mb_strtolower'))
1178 1178
             return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1179 1179
         return lcfirst($str);
1180 1180
     }
1181
-    public function ucwords($str) {
1181
+    public function ucwords($str){
1182 1182
         if (function_exists('mb_convert_case'))
1183 1183
             return mb_convert_case($str, MB_CASE_TITLE);
1184 1184
         return ucwords($str);
1185 1185
     }
1186
-    public function strrev($str) {
1186
+    public function strrev($str){
1187 1187
         preg_match_all('/./us', $str, $ar);
1188 1188
         return implode(array_reverse($ar[0]));
1189 1189
     }
1190
-    public function str_shuffle($str) {
1190
+    public function str_shuffle($str){
1191 1191
         preg_match_all('/./us', $str, $ar);
1192 1192
         shuffle($ar[0]);
1193 1193
         return implode($ar[0]);
1194 1194
     }
1195
-    public function str_word_count($str) {
1196
-        return count(preg_split('~[^\p{L}\p{N}\']+~u',$str));
1195
+    public function str_word_count($str){
1196
+        return count(preg_split('~[^\p{L}\p{N}\']+~u', $str));
1197 1197
     }
1198
-    public function strip_tags($value,$params='') {
1198
+    public function strip_tags($value, $params = ''){
1199 1199
         global $modx;
1200 1200
 
1201
-        if(stripos($params,'style')===false && stripos($value,'</style>')!==false) {
1201
+        if (stripos($params, 'style') === false && stripos($value, '</style>') !== false) {
1202 1202
             $value = preg_replace('@<style.*?>.*?</style>@is', '', $value);
1203 1203
         }
1204
-        if(stripos($params,'script')===false && stripos($value,'</script>')!==false) {
1204
+        if (stripos($params, 'script') === false && stripos($value, '</script>') !== false) {
1205 1205
             $value = preg_replace('@<script.*?>.*?</script>@is', '', $value);
1206 1206
         }
1207 1207
 
1208
-        return trim(strip_tags($value,$params));
1208
+        return trim(strip_tags($value, $params));
1209 1209
     }
1210 1210
 }
Please login to merge, or discard this patch.
Braces   +544 added lines, -282 removed lines patch added patch discarded remove patch
@@ -1,8 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
3
+if(!defined('MODX_CORE_PATH')) {
4
+    define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
5
+}
4 6
 
5
-class MODIFIERS {
7
+class MODIFIERS
8
+{
6 9
     /**
7 10
      * @var array
8 11
      */
@@ -61,7 +64,9 @@  discard block
 block discarded – undo
61 64
     {
62 65
         global $modx;
63 66
 
64
-        if (function_exists('mb_internal_encoding')) mb_internal_encoding($modx->config['modx_charset']);
67
+        if (function_exists('mb_internal_encoding')) {
68
+            mb_internal_encoding($modx->config['modx_charset']);
69
+        }
65 70
         $this->condModifiers = '=,is,eq,equals,ne,neq,notequals,isnot,isnt,not,%,isempty,isnotempty,isntempty,>=,gte,eg,gte,greaterthan,>,gt,isgreaterthan,isgt,lowerthan,<,lt,<=,lte,islte,islowerthan,islt,el,find,in,inarray,in_array,fnmatch,wcard,wcard_match,wildcard,wildcard_match,is_file,is_dir,file_exists,is_readable,is_writable,is_image,regex,preg,preg_match,memberof,mo,isinrole,ir';
66 71
     }
67 72
 
@@ -74,7 +79,9 @@  discard block
 block discarded – undo
74 79
     public function phxFilter($key,$value,$modifiers)
75 80
     {
76 81
         global $modx;
77
-        if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value);
82
+        if(substr($modifiers,0,3)!=='id(') {
83
+            $value = $this->parseDocumentSource($value);
84
+        }
78 85
         $this->srcValue = $value;
79 86
         $modifiers = trim($modifiers);
80 87
         $modifiers = ':'.trim($modifiers,':');
@@ -97,13 +104,18 @@  discard block
 block discarded – undo
97 104
      * @param string $modifiers
98 105
      * @return bool|string
99 106
      */
100
-    public function _getDelim($mode,$modifiers) {
107
+    public function _getDelim($mode,$modifiers)
108
+    {
101 109
         $c = substr($modifiers,0,1);
102
-        if(!in_array($c, array('"', "'", '`')) ) return false;
110
+        if(!in_array($c, array('"', "'", '`')) ) {
111
+            return false;
112
+        }
103 113
 
104 114
         $modifiers = substr($modifiers,1);
105 115
         $closure = $mode=='(' ? "{$c})" : $c;
106
-        if(strpos($modifiers, $closure)===false) return false;
116
+        if(strpos($modifiers, $closure)===false) {
117
+            return false;
118
+        }
107 119
 
108 120
         return  $c;
109 121
     }
@@ -114,52 +126,65 @@  discard block
 block discarded – undo
114 126
      * @param string $modifiers
115 127
      * @return bool|string
116 128
      */
117
-    public function _getOpt($mode,$delim,$modifiers) {
129
+    public function _getOpt($mode,$delim,$modifiers)
130
+    {
118 131
         if($delim) {
119
-            if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
132
+            if($mode=='(') {
133
+                return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1);
134
+            }
120 135
 
121 136
             return substr($modifiers,1,strpos($modifiers,$delim,1)-1);
122
-        }
123
-        else {
124
-            if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') );
137
+        } else {
138
+            if($mode=='(') {
139
+                return substr($modifiers,0,strpos($modifiers, ')') );
140
+            }
125 141
 
126 142
             $chars = str_split($modifiers);
127 143
             $opt='';
128 144
             foreach($chars as $c) {
129
-                if($c==':' || $c==')') break;
145
+                if($c==':' || $c==')') {
146
+                    break;
147
+                }
130 148
                 $opt .=$c;
131 149
             }
132 150
             return $opt;
133 151
         }
134 152
     }
135
-    public function _getRemainModifiers($mode,$delim,$modifiers) {
153
+    public function _getRemainModifiers($mode,$delim,$modifiers)
154
+    {
136 155
         if($delim) {
137
-            if($mode=='(')
138
-                return $this->_fetchContent($modifiers, $delim . ')');
139
-            else {
156
+            if($mode=='(') {
157
+                            return $this->_fetchContent($modifiers, $delim . ')');
158
+            } else {
140 159
                 $modifiers = trim($modifiers);
141 160
                 $modifiers = substr($modifiers,1);
142 161
                 return $this->_fetchContent($modifiers, $delim);
143 162
             }
144
-        }
145
-        else {
146
-            if($mode=='(') return $this->_fetchContent($modifiers, ')');
163
+        } else {
164
+            if($mode=='(') {
165
+                return $this->_fetchContent($modifiers, ')');
166
+            }
147 167
             $chars = str_split($modifiers);
148 168
             foreach($chars as $c) {
149
-                if($c==':') return $modifiers;
150
-                else $modifiers = substr($modifiers,1);
169
+                if($c==':') {
170
+                    return $modifiers;
171
+                } else {
172
+                    $modifiers = substr($modifiers,1);
173
+                }
151 174
             }
152 175
             return $modifiers;
153 176
         }
154 177
     }
155 178
 
156
-    public function _fetchContent($string,$delim) {
179
+    public function _fetchContent($string,$delim)
180
+    {
157 181
         $len = strlen($delim);
158 182
         $string = $this->parseDocumentSource($string);
159 183
         return substr($string,strpos($string, $delim)+$len);
160 184
     }
161 185
 
162
-    public function splitEachModifiers($modifiers) {
186
+    public function splitEachModifiers($modifiers)
187
+    {
163 188
         global $modx;
164 189
 
165 190
         $cmd = '';
@@ -170,11 +195,15 @@  discard block
 block discarded – undo
170 195
             $c = substr($modifiers,0,1);
171 196
             $modifiers = substr($modifiers,1);
172 197
 
173
-            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
198
+            if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) {
199
+// :=, :!=, :<=, :>=, :!<=, :!>=
174 200
                 $c = substr($modifiers,strlen($match[1]),1);
175 201
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
176
-                if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1);
177
-                else         $modifiers = substr($modifiers,strlen($match[1]));
202
+                if($c==='(') {
203
+                    $modifiers = substr($modifiers,strlen($match[1])+1);
204
+                } else {
205
+                    $modifiers = substr($modifiers,strlen($match[1]));
206
+                }
178 207
 
179 208
                 $delim     = $this->_getDelim($c,$modifiers);
180 209
                 $opt       = $this->_getOpt($c,$delim,$modifiers);
@@ -182,13 +211,12 @@  discard block
 block discarded – undo
182 211
 
183 212
                 $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
184 213
                 $cmd = '';
185
-            }
186
-            elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
214
+            } elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) {
215
+// :+3, :-3, :*3 ...
187 216
                 $modifiers = substr($modifiers,strlen($match[0]));
188 217
                 $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]);
189 218
                 $cmd = '';
190
-            }
191
-            elseif($c==='(' || $c==='=') {
219
+            } elseif($c==='(' || $c==='=') {
192 220
                 $modifiers = $m1 = trim($modifiers);
193 221
                 $delim     = $this->_getDelim($c,$modifiers);
194 222
                 $opt       = $this->_getOpt($c,$delim,$modifiers);
@@ -198,29 +226,29 @@  discard block
 block discarded – undo
198 226
                 $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo);
199 227
 
200 228
                 $cmd = '';
201
-            }
202
-            elseif($c==':') {
229
+            } elseif($c==':') {
203 230
                 $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]";
204
-                if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
231
+                if($cmd!=='') {
232
+                    $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
233
+                }
205 234
 
206 235
                 $cmd = '';
207
-            }
208
-            elseif(trim($modifiers)=='' && trim($cmd)!=='') {
236
+            } elseif(trim($modifiers)=='' && trim($cmd)!=='') {
209 237
                 $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]";
210 238
                 $cmd .= $c;
211 239
                 $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
212 240
 
213 241
                 break;
214
-            }
215
-            else {
242
+            } else {
216 243
                 $cmd .= $c;
217 244
             }
218 245
         }
219 246
 
220
-        if(empty($result)) return array();
247
+        if(empty($result)) {
248
+            return array();
249
+        }
221 250
 
222
-        foreach($result as $i=>$a)
223
-        {
251
+        foreach($result as $i=>$a) {
224 252
             $a['opt'] = $this->parseDocumentSource($a['opt']);
225 253
             $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders);
226 254
         }
@@ -233,22 +261,23 @@  discard block
 block discarded – undo
233 261
         global $modx;
234 262
         $lastKey = '';
235 263
         $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true)));
236
-        if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey];
237
-        if(empty($modifiers)) return '';
264
+        if(isset($this->tmpCache[$cacheKey])) {
265
+            return $this->tmpCache[$cacheKey];
266
+        }
267
+        if(empty($modifiers)) {
268
+            return '';
269
+        }
238 270
 
239
-        foreach($modifiers as $m)
240
-        {
271
+        foreach($modifiers as $m) {
241 272
             $lastKey = strtolower($m['cmd']);
242 273
         }
243 274
         $_ = explode(',',$this->condModifiers);
244
-        if(in_array($lastKey,$_))
245
-        {
275
+        if(in_array($lastKey,$_)) {
246 276
             $modifiers[] = array('cmd'=>'then','opt'=>'1');
247 277
             $modifiers[] = array('cmd'=>'else','opt'=>'0');
248 278
         }
249 279
 
250
-        foreach($modifiers as $i=>$a)
251
-        {
280
+        foreach($modifiers as $i=>$a) {
252 281
             $value = $this->Filter($key,$value, $a['cmd'], $a['opt']);
253 282
         }
254 283
         $this->tmpCache[$cacheKey] = $value;
@@ -260,25 +289,32 @@  discard block
 block discarded – undo
260 289
     {
261 290
         global $modx;
262 291
 
263
-        if($key==='documentObject') $value = $modx->documentIdentifier;
292
+        if($key==='documentObject') {
293
+            $value = $modx->documentIdentifier;
294
+        }
264 295
         $cmd = $this->parseDocumentSource($cmd);
265
-        if(preg_match('@^[1-9][/0-9]*$@',$cmd))
266
-        {
267
-            if(strpos($cmd,'/')!==false)
268
-                $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
296
+        if(preg_match('@^[1-9][/0-9]*$@',$cmd)) {
297
+            if(strpos($cmd,'/')!==false) {
298
+                            $cmd = $this->substr($cmd,strrpos($cmd,'/')+1);
299
+            }
269 300
             $opt = $cmd;
270 301
             $cmd = 'id';
271 302
         }
272 303
 
273
-        if(isset($modx->snippetCache["phx:{$cmd}"]))   $this->elmName = "phx:{$cmd}";
274
-        elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}";
275
-        else                                           $this->elmName = '';
304
+        if(isset($modx->snippetCache["phx:{$cmd}"])) {
305
+            $this->elmName = "phx:{$cmd}";
306
+        } elseif(isset($modx->chunkCache["phx:{$cmd}"])) {
307
+            $this->elmName = "phx:{$cmd}";
308
+        } else {
309
+            $this->elmName = '';
310
+        }
276 311
 
277 312
         $cmd = strtolower($cmd);
278
-        if($this->elmName!=='')
279
-            $value = $this->getValueFromElement($key, $value, $cmd, $opt);
280
-        else
281
-            $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
313
+        if($this->elmName!=='') {
314
+                    $value = $this->getValueFromElement($key, $value, $cmd, $opt);
315
+        } else {
316
+                    $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
317
+        }
282 318
 
283 319
         $value = str_replace('[+key+]', $key, $value);
284 320
 
@@ -287,29 +323,37 @@  discard block
 block discarded – undo
287 323
 
288 324
     public function isEmpty($cmd,$value)
289 325
     {
290
-        if($value!=='') return false;
326
+        if($value!=='') {
327
+            return false;
328
+        }
291 329
 
292 330
         $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
293
-        if(in_array($cmd,$_)) return false;
294
-        else                  return true;
331
+        if(in_array($cmd,$_)) {
332
+            return false;
333
+        } else {
334
+            return true;
335
+        }
295 336
     }
296 337
 
297 338
     public function getValueFromPreset($key, $value, $cmd, $opt)
298 339
     {
299 340
         global $modx;
300 341
 
301
-        if($this->isEmpty($cmd,$value)) return '';
342
+        if($this->isEmpty($cmd,$value)) {
343
+            return '';
344
+        }
302 345
 
303 346
         $this->key = $key;
304 347
         $this->value  = $value;
305 348
         $this->opt    = $opt;
306 349
 
307
-        switch ($cmd)
308
-        {
350
+        switch ($cmd) {
309 351
             #####  Conditional Modifiers
310 352
             case 'input':
311 353
             case 'if':
312
-                if(!$opt) return $value;
354
+                if(!$opt) {
355
+                    return $value;
356
+                }
313 357
                 return $opt;
314 358
             case '=':
315 359
             case 'eq':
@@ -370,14 +414,24 @@  discard block
 block discarded – undo
370 414
             case 'file_exists':
371 415
             case 'is_readable':
372 416
             case 'is_writable':
373
-                if(!$opt) $path = $value;
374
-                else      $path = $opt;
375
-                if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path');
376
-                if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/');
417
+                if(!$opt) {
418
+                    $path = $value;
419
+                } else {
420
+                    $path = $opt;
421
+                }
422
+                if(strpos($path,MODX_MANAGER_PATH)!==false) {
423
+                    exit('Can not read core path');
424
+                }
425
+                if(strpos($path,$modx->config['base_path'])===false) {
426
+                    $path = ltrim($path,'/');
427
+                }
377 428
                 $this->condition[] = (int)($cmd($path)!==false);break;
378 429
             case 'is_image':
379
-                if(!$opt) $path = $value;
380
-                else      $path = $opt;
430
+                if(!$opt) {
431
+                    $path = $value;
432
+                } else {
433
+                    $path = $opt;
434
+                }
381 435
                 if(!is_file($path)) {$this->condition[]='0';break;}
382 436
                 $_ = getimagesize($path);
383 437
                 $this->condition[] = (int)($_[0]);break;
@@ -400,17 +454,23 @@  discard block
 block discarded – undo
400 454
             case 'this':
401 455
                 $conditional = implode(' ',$this->condition);
402 456
                 $isvalid = (int)(eval("return ({$conditional});"));
403
-                if ($isvalid) return $this->srcValue;
457
+                if ($isvalid) {
458
+                    return $this->srcValue;
459
+                }
404 460
                 return NULL;
405 461
             case 'then':
406 462
                 $conditional = implode(' ',$this->condition);
407 463
                 $isvalid = (int)eval("return ({$conditional});");
408
-                if ($isvalid)  return $opt;
464
+                if ($isvalid) {
465
+                    return $opt;
466
+                }
409 467
                 return null;
410 468
             case 'else':
411 469
                 $conditional = implode(' ',$this->condition);
412 470
                 $isvalid = (int)eval("return ({$conditional});");
413
-                if (!$isvalid) return $opt;
471
+                if (!$isvalid) {
472
+                    return $opt;
473
+                }
414 474
                 break;
415 475
             case 'select':
416 476
             case 'switch':
@@ -421,8 +481,11 @@  discard block
 block discarded – undo
421 481
                     $mi = explode('=',$raw[$m],2);
422 482
                     $map[$mi[0]] = $mi[1];
423 483
                 }
424
-                if(isset($map[$value])) return $map[$value];
425
-                else                    return '';
484
+                if(isset($map[$value])) {
485
+                    return $map[$value];
486
+                } else {
487
+                    return '';
488
+                }
426 489
             ##### End of Conditional Modifiers
427 490
 
428 491
             #####  Encode / Decode / Hash / Escape
@@ -448,24 +511,25 @@  discard block
 block discarded – undo
448 511
             case 'spam_protect':
449 512
                 return str_replace(array('@','.'),array('&#64;','&#46;'),$value);
450 513
             case 'strip':
451
-                if($opt==='') $opt = ' ';
514
+                if($opt==='') {
515
+                    $opt = ' ';
516
+                }
452 517
                 return preg_replace('/[\n\r\t\s]+/', $opt, $value);
453 518
             case 'strip_linefeeds':
454 519
                 return str_replace(array("\n","\r"), '', $value);
455 520
             case 'notags':
456 521
             case 'strip_tags':
457 522
             case 'remove_html':
458
-                if($opt!=='')
459
-                {
523
+                if($opt!=='') {
460 524
                     $param = array();
461
-                    foreach(explode(',',$opt) as $v)
462
-                    {
525
+                    foreach(explode(',',$opt) as $v) {
463 526
                         $v = trim($v,'</> ');
464 527
                         $param[] = "<{$v}>";
465 528
                     }
466 529
                     $params = implode(',',$param);
530
+                } else {
531
+                    $params = '';
467 532
                 }
468
-                else $params = '';
469 533
                 if(!strpos($params,'<br>')===false) {
470 534
                     $value = preg_replace('@(<br[ /]*>)\n@','$1',$value);
471 535
                     $value = preg_replace('@<br[ /]*>@',"\n",$value);
@@ -476,8 +540,11 @@  discard block
 block discarded – undo
476 540
             case 'encode_url':
477 541
                 return urlencode($value);
478 542
             case 'base64_decode':
479
-                if($opt!=='false') $opt = true;
480
-                else               $opt = false;
543
+                if($opt!=='false') {
544
+                    $opt = true;
545
+                } else {
546
+                    $opt = false;
547
+                }
481 548
                 return base64_decode($value,$opt);
482 549
             case 'encode_sha1': $cmd = 'sha1';
483 550
             case 'addslashes':
@@ -503,16 +570,19 @@  discard block
 block discarded – undo
503 570
                 return $this->strtoupper($value);
504 571
             case 'capitalize':
505 572
                 $_ = explode(' ',$value);
506
-                foreach($_ as $i=>$v)
507
-                {
573
+                foreach($_ as $i=>$v) {
508 574
                     $_[$i] = ucfirst($v);
509 575
                 }
510 576
                 return implode(' ',$_);
511 577
             case 'zenhan':
512
-                if(empty($opt)) $opt='VKas';
578
+                if(empty($opt)) {
579
+                    $opt='VKas';
580
+                }
513 581
                 return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
514 582
             case 'hanzen':
515
-                if(empty($opt)) $opt='VKAS';
583
+                if(empty($opt)) {
584
+                    $opt='VKAS';
585
+                }
516 586
                 return mb_convert_kana($value,$opt,$modx->config['modx_charset']);
517 587
             case 'str_shuffle':
518 588
             case 'shuffle':
@@ -537,13 +607,18 @@  discard block
 block discarded – undo
537 607
                 $value = preg_replace('/\r/', '', $value);
538 608
                 return count(preg_split('/\n+/',$value));
539 609
             case 'strpos':
540
-                if($opt!=0&&empty($opt)) return $value;
610
+                if($opt!=0&&empty($opt)) {
611
+                    return $value;
612
+                }
541 613
                 return $this->strpos($value,$opt);
542 614
             case 'wordwrap':
543 615
                 // default: 70
544 616
                   $wrapat = (int)$opt > 0 ? (int)$opt : 70;
545
-                if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap');
546
-                else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
617
+                if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
618
+                    return $this->includeMdfFile('wordwrap');
619
+                } else {
620
+                    return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value);
621
+                }
547 622
             case 'wrap_text':
548 623
                 $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70;
549 624
                 if($modx->config['manager_language']==='japanese-utf8') {
@@ -559,30 +634,36 @@  discard block
 block discarded – undo
559 634
                         $value = $this->substr($value,$width);
560 635
                     }
561 636
                     return implode("\n",$chunk);
637
+                } else {
638
+                                    return wordwrap($value,$width,"\n",true);
562 639
                 }
563
-                else
564
-                    return wordwrap($value,$width,"\n",true);
565 640
             case 'substr':
566
-                if(empty($opt)) break;
641
+                if(empty($opt)) {
642
+                    break;
643
+                }
567 644
                 if(strpos($opt,',')!==false) {
568 645
                     list($b,$e) = explode(',',$opt,2);
569 646
                     return $this->substr($value,$b,(int)$e);
647
+                } else {
648
+                    return $this->substr($value,$opt);
570 649
                 }
571
-                else return $this->substr($value,$opt);
572 650
             case 'limit':
573 651
             case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html
574
-                if(strpos($opt,'+')!==false)
575
-                    list($len,$str) = explode('+',$opt,2);
576
-                else {
652
+                if(strpos($opt,'+')!==false) {
653
+                                    list($len,$str) = explode('+',$opt,2);
654
+                } else {
577 655
                     $len = $opt;
578 656
                     $str = '';
579 657
                 }
580
-                if($len==='') $len = 100;
581
-                if(abs($len) > $this->strlen($value)) $str ='';
658
+                if($len==='') {
659
+                    $len = 100;
660
+                }
661
+                if(abs($len) > $this->strlen($value)) {
662
+                    $str ='';
663
+                }
582 664
                 if(preg_match('/^[1-9][0-9]*$/',$len)) {
583 665
                     return $this->substr($value,0,$len) . $str;
584
-                }
585
-                elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
666
+                } elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) {
586 667
                     return $str . $this->substr($value,$len);
587 668
                 }
588 669
                 break;
@@ -592,18 +673,30 @@  discard block
 block discarded – undo
592 673
                 return $this->includeMdfFile('summary');
593 674
             case 'replace':
594 675
             case 'str_replace':
595
-                if(empty($opt) || strpos($opt,',')===false) break;
596
-                if    (substr_count($opt, ',') ==1) $delim = ',';
597
-                elseif(substr_count($opt, '|') ==1) $delim = '|';
598
-                elseif(substr_count($opt, '=>')==1) $delim = '=>';
599
-                elseif(substr_count($opt, '/') ==1) $delim = '/';
600
-                else break;
676
+                if(empty($opt) || strpos($opt,',')===false) {
677
+                    break;
678
+                }
679
+                if    (substr_count($opt, ',') ==1) {
680
+                    $delim = ',';
681
+                } elseif(substr_count($opt, '|') ==1) {
682
+                    $delim = '|';
683
+                } elseif(substr_count($opt, '=>')==1) {
684
+                    $delim = '=>';
685
+                } elseif(substr_count($opt, '/') ==1) {
686
+                    $delim = '/';
687
+                } else {
688
+                    break;
689
+                }
601 690
                 list($s,$r) = explode($delim,$opt);
602
-                if($value!=='') return str_replace($s,$r,$value);
691
+                if($value!=='') {
692
+                    return str_replace($s,$r,$value);
693
+                }
603 694
                 break;
604 695
             case 'replace_to':
605 696
             case 'tpl':
606
-                if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
697
+                if($value!=='') {
698
+                    return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt);
699
+                }
607 700
                 break;
608 701
             case 'eachtpl':
609 702
                 $value = explode('||',$value);
@@ -614,59 +707,83 @@  discard block
 block discarded – undo
614 707
                 return implode("\n", $_);
615 708
             case 'array_pop':
616 709
             case 'array_shift':
617
-                if(strpos($value,'||')!==false) $delim = '||';
618
-                else                            $delim = ',';
710
+                if(strpos($value,'||')!==false) {
711
+                    $delim = '||';
712
+                } else {
713
+                    $delim = ',';
714
+                }
619 715
                 return $cmd(explode($delim,$value));
620 716
             case 'preg_replace':
621 717
             case 'regex_replace':
622
-                if(empty($opt) || strpos($opt,',')===false) break;
718
+                if(empty($opt) || strpos($opt,',')===false) {
719
+                    break;
720
+                }
623 721
                 list($s,$r) = explode(',',$opt,2);
624
-                if($value!=='') return preg_replace($s,$r,$value);
722
+                if($value!=='') {
723
+                    return preg_replace($s,$r,$value);
724
+                }
625 725
                 break;
626 726
             case 'cat':
627 727
             case 'concatenate':
628 728
             case '.':
629
-                if($value!=='') return $value . $opt;
729
+                if($value!=='') {
730
+                    return $value . $opt;
731
+                }
630 732
                 break;
631 733
             case 'sprintf':
632 734
             case 'string_format':
633
-                if($value!=='') return sprintf($opt,$value);
735
+                if($value!=='') {
736
+                    return sprintf($opt,$value);
737
+                }
634 738
                 break;
635 739
             case 'number_format':
636
-                    if($opt=='') $opt = 0;
740
+                    if($opt=='') {
741
+                        $opt = 0;
742
+                    }
637 743
                     return number_format($value,$opt);
638 744
             case 'money_format':
639 745
                     setlocale(LC_MONETARY,setlocale(LC_TIME,0));
640
-                    if($value!=='') return money_format($opt,(double)$value);
746
+                    if($value!=='') {
747
+                        return money_format($opt,(double)$value);
748
+                    }
641 749
                     break;
642 750
             case 'tobool':
643 751
                 return boolval($value);
644 752
             case 'nl2lf':
645
-                if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value);
753
+                if($value!=='') {
754
+                    return str_replace(array("\r\n","\n", "\r"), '\n', $value);
755
+                }
646 756
                 break;
647 757
             case 'br2nl':
648 758
                 return preg_replace('@<br[\s/]*>@i', "\n", $value);
649 759
             case 'nl2br':
650
-                if (version_compare(PHP_VERSION, '5.3.0', '<'))
651
-                    return nl2br($value);
652
-                if($opt!=='')
653
-                {
760
+                if (version_compare(PHP_VERSION, '5.3.0', '<')) {
761
+                                    return nl2br($value);
762
+                }
763
+                if($opt!=='') {
654 764
                     $opt = trim($opt);
655 765
                     $opt = strtolower($opt);
656
-                    if($opt==='false') $opt = false;
657
-                    elseif($opt==='0') $opt = false;
658
-                    else               $opt = true;
766
+                    if($opt==='false') {
767
+                        $opt = false;
768
+                    } elseif($opt==='0') {
769
+                        $opt = false;
770
+                    } else {
771
+                        $opt = true;
772
+                    }
773
+                } elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') {
774
+                                                       $opt = false;
775
+                } else {
776
+                    $opt = true;
659 777
                 }
660
-                elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html')
661
-                                       $opt = false;
662
-                else                   $opt = true;
663 778
                 return nl2br($value,$opt);
664 779
             case 'ltrim':
665 780
             case 'rtrim':
666 781
             case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html
667
-                if($opt==='')
668
-                    return $cmd($value);
669
-                else return $cmd($value,$opt);
782
+                if($opt==='') {
783
+                                    return $cmd($value);
784
+                } else {
785
+                    return $cmd($value,$opt);
786
+                }
670 787
             // These are all straight wrappers for PHP functions
671 788
             case 'ucfirst':
672 789
             case 'lcfirst':
@@ -677,15 +794,24 @@  discard block
 block discarded – undo
677 794
             case 'strftime':
678 795
             case 'date':
679 796
             case 'dateformat':
680
-                if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly');
681
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
682
-                if(strpos($opt,'%')!==false)
683
-                    return strftime($opt,0+$value);
684
-                else
685
-                    return date($opt,0+$value);
797
+                if(empty($opt)) {
798
+                    $opt = $modx->toDateFormat(null, 'formatOnly');
799
+                }
800
+                if(!preg_match('@^[0-9]+$@',$value)) {
801
+                    $value = strtotime($value);
802
+                }
803
+                if(strpos($opt,'%')!==false) {
804
+                                    return strftime($opt,0+$value);
805
+                } else {
806
+                                    return date($opt,0+$value);
807
+                }
686 808
             case 'time':
687
-                if(empty($opt)) $opt = '%H:%M';
688
-                if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value);
809
+                if(empty($opt)) {
810
+                    $opt = '%H:%M';
811
+                }
812
+                if(!preg_match('@^[0-9]+$@',$value)) {
813
+                    $value = strtotime($value);
814
+                }
689 815
                 return strftime($opt,0+$value);
690 816
             case 'strtotime':
691 817
                 return strtotime($value);
@@ -695,7 +821,9 @@  discard block
 block discarded – undo
695 821
             case 'tofloat':
696 822
                 return floatval($value);
697 823
             case 'round':
698
-                if(!$opt) $opt = 0;
824
+                if(!$opt) {
825
+                    $opt = 0;
826
+                }
699 827
                 return $cmd($value,$opt);
700 828
             case 'max':
701 829
             case 'min':
@@ -707,28 +835,42 @@  discard block
 block discarded – undo
707 835
             case 'math':
708 836
             case 'calc':
709 837
                 $value = (int)$value;
710
-                if(empty($value)) $value = '0';
838
+                if(empty($value)) {
839
+                    $value = '0';
840
+                }
711 841
                 $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt);
712 842
                 $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter);
713
-                if(strpos($filter,'?')===false) $filter = "?{$filter}";
843
+                if(strpos($filter,'?')===false) {
844
+                    $filter = "?{$filter}";
845
+                }
714 846
                 $filter = str_replace('?',$value,$filter);
715 847
                 return eval("return {$filter};");
716 848
             case 'count':
717
-                if($value=='') return 0;
849
+                if($value=='') {
850
+                    return 0;
851
+                }
718 852
                 $value = explode(',',$value);
719 853
                 return count($value);
720 854
             case 'sort':
721 855
             case 'rsort':
722
-                if(strpos($value,"\n")!==false) $delim="\n";
723
-                else $delim = ',';
856
+                if(strpos($value,"\n")!==false) {
857
+                    $delim="\n";
858
+                } else {
859
+                    $delim = ',';
860
+                }
724 861
                 $swap = explode($delim,$value);
725
-                if(!$opt) $opt = SORT_REGULAR;
726
-                else      $opt = constant($opt);
862
+                if(!$opt) {
863
+                    $opt = SORT_REGULAR;
864
+                } else {
865
+                    $opt = constant($opt);
866
+                }
727 867
                 $cmd($swap,$opt);
728 868
                 return implode($delim,$swap);
729 869
             #####  Resource fields
730 870
             case 'id':
731
-                if($opt) return $this->getDocumentObject($opt,$key);
871
+                if($opt) {
872
+                    return $this->getDocumentObject($opt,$key);
873
+                }
732 874
                 break;
733 875
             case 'type':
734 876
             case 'contenttype':
@@ -765,7 +907,9 @@  discard block
 block discarded – undo
765 907
             case 'privatemgr':
766 908
             case 'content_dispo':
767 909
             case 'hidemenu':
768
-                if($cmd==='contenttype') $cmd = 'contentType';
910
+                if($cmd==='contenttype') {
911
+                    $cmd = 'contentType';
912
+                }
769 913
                 return $this->getDocumentObject($value,$cmd);
770 914
             case 'title':
771 915
                 $pagetitle = $this->getDocumentObject($value,'pagetitle');
@@ -780,13 +924,20 @@  discard block
 block discarded – undo
780 924
                 $templateName = $modx->db->getValue($rs);
781 925
                 return !$templateName ? '(blank)' : $templateName;
782 926
             case 'getfield':
783
-                if(!$opt) $opt = 'content';
927
+                if(!$opt) {
928
+                    $opt = 'content';
929
+                }
784 930
                 return $modx->getField($opt,$value);
785 931
             case 'children':
786 932
             case 'childids':
787
-                if($value=='') $value = 0; // 値がない場合はルートと見なす
933
+                if($value=='') {
934
+                    $value = 0;
935
+                }
936
+                // 値がない場合はルートと見なす
788 937
                 $published = 1;
789
-                if($opt=='') $opt = 'page';
938
+                if($opt=='') {
939
+                    $opt = 'page';
940
+                }
790 941
                 $_ = explode(',',$opt);
791 942
                 $where = array();
792 943
                 foreach($_ as $opt) {
@@ -802,29 +953,43 @@  discard block
 block discarded – undo
802 953
                 $where = implode(' AND ', $where);
803 954
                 $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where);
804 955
                 $result = array();
805
-                foreach((array)$children as $child){
956
+                foreach((array)$children as $child) {
806 957
                     $result[] = $child['id'];
807 958
                 }
808 959
                 return implode(',', $result);
809 960
             case 'fullurl':
810
-                if(!is_numeric($value)) return $value;
961
+                if(!is_numeric($value)) {
962
+                    return $value;
963
+                }
811 964
                 return $modx->makeUrl($value);
812 965
             case 'makeurl':
813
-                if(!is_numeric($value)) return $value;
814
-                if(!$opt) $opt = 'full';
966
+                if(!is_numeric($value)) {
967
+                    return $value;
968
+                }
969
+                if(!$opt) {
970
+                    $opt = 'full';
971
+                }
815 972
                 return $modx->makeUrl($value,'','',$opt);
816 973
 
817 974
             #####  File system
818 975
             case 'getimageinfo':
819 976
             case 'imageinfo':
820
-                if(!is_file($value)) return '';
977
+                if(!is_file($value)) {
978
+                    return '';
979
+                }
821 980
                 $_ = getimagesize($value);
822
-                if(!$_[0]) return '';
981
+                if(!$_[0]) {
982
+                    return '';
983
+                }
823 984
                 $info['width']  = $_[0];
824 985
                 $info['height'] = $_[1];
825
-                if    ($_[0] > $_[1]) $info['aspect'] = 'landscape';
826
-                elseif($_[0] < $_[1]) $info['aspect'] = 'portrait';
827
-                else                  $info['aspect'] = 'square';
986
+                if    ($_[0] > $_[1]) {
987
+                    $info['aspect'] = 'landscape';
988
+                } elseif($_[0] < $_[1]) {
989
+                    $info['aspect'] = 'portrait';
990
+                } else {
991
+                    $info['aspect'] = 'square';
992
+                }
828 993
                 switch($_[2]) {
829 994
                     case IMAGETYPE_GIF  : $info['type'] = 'gif'; break;
830 995
                     case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break;
@@ -843,33 +1008,47 @@  discard block
 block discarded – undo
843 1008
 
844 1009
             case 'file_get_contents':
845 1010
             case 'readfile':
846
-                if(!is_file($value)) return $value;
1011
+                if(!is_file($value)) {
1012
+                    return $value;
1013
+                }
847 1014
                 $value = realpath($value);
848
-                if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file');
1015
+                if(strpos($value,MODX_MANAGER_PATH)!==false) {
1016
+                    exit('Can not read core file');
1017
+                }
849 1018
                 $ext = strtolower(substr($value,-4));
850
-                if($ext==='.php') exit('Can not read php file');
851
-                if($ext==='.cgi') exit('Can not read cgi file');
1019
+                if($ext==='.php') {
1020
+                    exit('Can not read php file');
1021
+                }
1022
+                if($ext==='.cgi') {
1023
+                    exit('Can not read cgi file');
1024
+                }
852 1025
                 return file_get_contents($value);
853 1026
             case 'filesize':
854
-                if($value == '') return '';
1027
+                if($value == '') {
1028
+                    return '';
1029
+                }
855 1030
                 $filename = $value;
856 1031
 
857 1032
                 $site_url = $modx->config['site_url'];
858
-                if(strpos($filename,$site_url) === 0)
859
-                    $filename = substr($filename,0,strlen($site_url));
1033
+                if(strpos($filename,$site_url) === 0) {
1034
+                                    $filename = substr($filename,0,strlen($site_url));
1035
+                }
860 1036
                 $filename = trim($filename,'/');
861 1037
 
862 1038
                 $opt = trim($opt,'/');
863
-                if($opt!=='') $opt .= '/';
1039
+                if($opt!=='') {
1040
+                    $opt .= '/';
1041
+                }
864 1042
 
865 1043
                 $filename = MODX_BASE_PATH.$opt.$filename;
866 1044
 
867
-                if(is_file($filename)){
1045
+                if(is_file($filename)) {
868 1046
                     clearstatcache();
869 1047
                     $size = filesize($filename);
870 1048
                     return $size;
1049
+                } else {
1050
+                    return '';
871 1051
                 }
872
-                else return '';
873 1052
             #####  User info
874 1053
             case 'username':
875 1054
             case 'fullname':
@@ -897,32 +1076,47 @@  discard block
 block discarded – undo
897 1076
                 $this->opt = $cmd;
898 1077
                 return $this->includeMdfFile('moduser');
899 1078
             case 'userinfo':
900
-                if(empty($opt)) $this->opt = 'username';
1079
+                if(empty($opt)) {
1080
+                    $this->opt = 'username';
1081
+                }
901 1082
                 return $this->includeMdfFile('moduser');
902 1083
             case 'webuserinfo':
903
-                if(empty($opt)) $this->opt = 'username';
1084
+                if(empty($opt)) {
1085
+                    $this->opt = 'username';
1086
+                }
904 1087
                 $this->value = -$value;
905 1088
                 return $this->includeMdfFile('moduser');
906 1089
             #####  Special functions
907 1090
             case 'ifempty':
908 1091
             case '_default':
909 1092
             case 'default':
910
-                if (empty($value)) return $opt; break;
1093
+                if (empty($value)) {
1094
+                    return $opt;
1095
+                }
1096
+                break;
911 1097
             case 'ifnotempty':
912
-                if (!empty($value)) return $opt; break;
1098
+                if (!empty($value)) {
1099
+                    return $opt;
1100
+                }
1101
+                break;
913 1102
             case 'datagrid':
914 1103
                 include_once(MODX_CORE_PATH . 'controls/datagrid.class.php');
915 1104
                 $grd = new DataGrid(null, trim($value));
916 1105
                 $grd->itemStyle = '';
917 1106
                 $grd->altItemStyle = '';
918 1107
                 $pos = strpos($value,"\n");
919
-                if($pos) $_ = substr($value,0,$pos);
920
-                else $_ = $pos;
1108
+                if($pos) {
1109
+                    $_ = substr($value,0,$pos);
1110
+                } else {
1111
+                    $_ = $pos;
1112
+                }
921 1113
                 $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ',';
922 1114
                 return $grd->render();
923 1115
             case 'rotate':
924 1116
             case 'evenodd':
925
-                if(strpos($opt,',')===false) $opt = 'odd,even';
1117
+                if(strpos($opt,',')===false) {
1118
+                    $opt = 'odd,even';
1119
+                }
926 1120
                 $_ = explode(',', $opt);
927 1121
                 $c = count($_);
928 1122
                 $i = $value + $c;
@@ -931,7 +1125,9 @@  discard block
 block discarded – undo
931 1125
             case 'takeval':
932 1126
                 $arr = explode(",",$opt);
933 1127
                 $idx = $value;
934
-                if(!is_numeric($idx)) return $value;
1128
+                if(!is_numeric($idx)) {
1129
+                    return $value;
1130
+                }
935 1131
                 return $arr[$idx];
936 1132
             case 'getimage':
937 1133
                 return $this->includeMdfFile('getimage');
@@ -939,14 +1135,18 @@  discard block
 block discarded – undo
939 1135
                     return $modx->nicesize($value);
940 1136
             case 'googlemap':
941 1137
             case 'googlemaps':
942
-                if(empty($opt)) $opt = 'border:none;width:500px;height:350px;';
1138
+                if(empty($opt)) {
1139
+                    $opt = 'border:none;width:500px;height:350px;';
1140
+                }
943 1141
                 $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>';
944 1142
                 $ph['style'] = $opt;
945 1143
                 $ph['value'] = $value;
946 1144
                 return $modx->parseText($tpl,$ph);
947 1145
             case 'youtube':
948 1146
             case 'youtube16x9':
949
-                if(empty($opt)) $opt = 560;
1147
+                if(empty($opt)) {
1148
+                    $opt = 560;
1149
+                }
950 1150
                 $h = round($opt*0.5625);
951 1151
                 $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>';
952 1152
                 return sprintf($tpl,$opt,$h,$value);
@@ -979,7 +1179,8 @@  discard block
 block discarded – undo
979 1179
         return $value;
980 1180
     }
981 1181
 
982
-    public function includeMdfFile($cmd) {
1182
+    public function includeMdfFile($cmd)
1183
+    {
983 1184
         global $modx;
984 1185
         $key = $this->key;
985 1186
         $value  = $this->value;
@@ -990,55 +1191,65 @@  discard block
 block discarded – undo
990 1191
     public function getValueFromElement($key, $value, $cmd, $opt)
991 1192
     {
992 1193
         global $modx;
993
-        if( isset($modx->snippetCache[$this->elmName]) )
994
-        {
1194
+        if( isset($modx->snippetCache[$this->elmName]) ) {
995 1195
             $php = $modx->snippetCache[$this->elmName];
996
-        }
997
-        else
998
-        {
1196
+        } else {
999 1197
             $esc_elmName = $modx->db->escape($this->elmName);
1000 1198
             $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'");
1001 1199
             $total = $modx->db->getRecordCount($result);
1002
-            if($total == 1)
1003
-            {
1200
+            if($total == 1) {
1004 1201
                 $row = $modx->db->getRow($result);
1005 1202
                 $php = $row['snippet'];
1006
-            }
1007
-            elseif($total == 0)
1008
-            {
1203
+            } elseif($total == 0) {
1009 1204
                 $assets_path = MODX_BASE_PATH.'assets/';
1010
-                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php"))
1011
-                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1012
-                elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php"))
1013
-                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1014
-                elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"))
1015
-                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1016
-                else $modifiers_path = false;
1205
+                if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) {
1206
+                                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1207
+                } elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) {
1208
+                                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1209
+                } elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) {
1210
+                                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1211
+                } else {
1212
+                    $modifiers_path = false;
1213
+                }
1017 1214
 
1018 1215
                 if($modifiers_path !== false) {
1019 1216
                     $php = @file_get_contents($modifiers_path);
1020 1217
                     $php = trim($php);
1021
-                    if(substr($php,0,5)==='<?php') $php = substr($php,6);
1022
-                    if(substr($php,0,2)==='<?')    $php = substr($php,3);
1023
-                    if(substr($php,-2)==='?>')     $php = substr($php,0,-2);
1024
-                    if($this->elmName!=='')
1025
-                        $modx->snippetCache[$this->elmName.'Props'] = '';
1026
-                }
1027
-                else
1028
-                    $php = false;
1218
+                    if(substr($php,0,5)==='<?php') {
1219
+                        $php = substr($php,6);
1220
+                    }
1221
+                    if(substr($php,0,2)==='<?') {
1222
+                        $php = substr($php,3);
1223
+                    }
1224
+                    if(substr($php,-2)==='?>') {
1225
+                        $php = substr($php,0,-2);
1226
+                    }
1227
+                    if($this->elmName!=='') {
1228
+                                            $modx->snippetCache[$this->elmName.'Props'] = '';
1229
+                    }
1230
+                } else {
1231
+                                    $php = false;
1232
+                }
1233
+            } else {
1234
+                $php = false;
1235
+            }
1236
+            if($this->elmName!=='') {
1237
+                $modx->snippetCache[$this->elmName]= $php;
1029 1238
             }
1030
-            else $php = false;
1031
-            if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php;
1032 1239
         }
1033
-        if($php==='') $php=false;
1240
+        if($php==='') {
1241
+            $php=false;
1242
+        }
1034 1243
 
1035
-        if($php===false) $html = $modx->getChunk($this->elmName);
1036
-        else             $html = false;
1244
+        if($php===false) {
1245
+            $html = $modx->getChunk($this->elmName);
1246
+        } else {
1247
+            $html = false;
1248
+        }
1037 1249
 
1038 1250
         $self = '[+output+]';
1039 1251
 
1040
-        if($php !== false)
1041
-        {
1252
+        if($php !== false) {
1042 1253
             ob_start();
1043 1254
             $options = $opt;
1044 1255
             $output = $value;
@@ -1050,19 +1261,19 @@  discard block
 block discarded – undo
1050 1261
             $this->vars['options'] = & $opt;
1051 1262
             $custom = eval($php);
1052 1263
             $msg = ob_get_contents();
1053
-            if($value===$this->bt) $value = $msg . $custom;
1264
+            if($value===$this->bt) {
1265
+                $value = $msg . $custom;
1266
+            }
1054 1267
             ob_end_clean();
1055
-        }
1056
-        elseif($html!==false && isset($value) && $value!=='')
1057
-        {
1268
+        } elseif($html!==false && isset($value) && $value!=='') {
1058 1269
             $html = str_replace(array($self,'[+value+]'), $value, $html);
1059 1270
             $value = str_replace(array('[+options+]','[+param+]'), $opt, $html);
1271
+        } else {
1272
+            return false;
1060 1273
         }
1061
-        else return false;
1062 1274
 
1063 1275
         if($php===false && $html===false && $value!==''
1064
-           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false))
1065
-        {
1276
+           && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) {
1066 1277
             $value = str_replace(array('[+value+]',$self),$value,$cmd);
1067 1278
         }
1068 1279
         return $value;
@@ -1072,23 +1283,39 @@  discard block
 block discarded – undo
1072 1283
     {
1073 1284
         global $modx;
1074 1285
 
1075
-        if(strpos($content,'[')===false && strpos($content,'{')===false) return $content;
1286
+        if(strpos($content,'[')===false && strpos($content,'{')===false) {
1287
+            return $content;
1288
+        }
1076 1289
 
1077
-        if(!$modx->maxParserPasses) $modx->maxParserPasses = 10;
1290
+        if(!$modx->maxParserPasses) {
1291
+            $modx->maxParserPasses = 10;
1292
+        }
1078 1293
         $bt='';
1079 1294
         $i=0;
1080
-        while($bt!==$content)
1081
-        {
1295
+        while($bt!==$content) {
1082 1296
             $bt = $content;
1083
-            if(strpos($content,'[*')!==false && $modx->documentIdentifier)
1084
-                                              $content = $modx->mergeDocumentContent($content);
1085
-            if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content);
1086
-            if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content);
1087
-            if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1088
-            if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content);
1089
-
1090
-            if($content===$bt)              break;
1091
-            if($modx->maxParserPasses < $i) break;
1297
+            if(strpos($content,'[*')!==false && $modx->documentIdentifier) {
1298
+                                                          $content = $modx->mergeDocumentContent($content);
1299
+            }
1300
+            if(strpos($content,'[(')!==false) {
1301
+                $content = $modx->mergeSettingsContent($content);
1302
+            }
1303
+            if(strpos($content,'{{')!==false) {
1304
+                $content = $modx->mergeChunkContent($content);
1305
+            }
1306
+            if(strpos($content,'[!')!==false) {
1307
+                $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
1308
+            }
1309
+            if(strpos($content,'[[')!==false) {
1310
+                $content = $modx->evalSnippets($content);
1311
+            }
1312
+
1313
+            if($content===$bt) {
1314
+                break;
1315
+            }
1316
+            if($modx->maxParserPasses < $i) {
1317
+                break;
1318
+            }
1092 1319
             $i++;
1093 1320
         }
1094 1321
         return $content;
@@ -1099,103 +1326,138 @@  discard block
 block discarded – undo
1099 1326
         global $modx;
1100 1327
 
1101 1328
         $target = trim($target);
1102
-        if(empty($target)) $target = $modx->config['site_start'];
1103
-        if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id';
1104
-        else $method = 'alias';
1329
+        if(empty($target)) {
1330
+            $target = $modx->config['site_start'];
1331
+        }
1332
+        if(preg_match('@^[1-9][0-9]*$@',$target)) {
1333
+            $method='id';
1334
+        } else {
1335
+            $method = 'alias';
1336
+        }
1105 1337
 
1106
-        if(!isset($this->documentObject[$target]))
1107
-        {
1338
+        if(!isset($this->documentObject[$target])) {
1108 1339
             $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct');
1109 1340
         }
1110 1341
 
1111
-        if($this->documentObject[$target]['publishedon']==='0')
1112
-            return '';
1113
-        elseif(isset($this->documentObject[$target][$field]))
1114
-        {
1115
-            if(is_array($this->documentObject[$target][$field]))
1116
-            {
1342
+        if($this->documentObject[$target]['publishedon']==='0') {
1343
+                    return '';
1344
+        } elseif(isset($this->documentObject[$target][$field])) {
1345
+            if(is_array($this->documentObject[$target][$field])) {
1117 1346
                 $a = $modx->getTemplateVarOutput($field,$target);
1118 1347
                 $this->documentObject[$target][$field] = $a[$field];
1119 1348
             }
1349
+        } else {
1350
+            $this->documentObject[$target][$field] = false;
1120 1351
         }
1121
-        else $this->documentObject[$target][$field] = false;
1122 1352
 
1123 1353
         return $this->documentObject[$target][$field];
1124 1354
     }
1125 1355
 
1126
-    public function setPlaceholders($value = '', $key = '', $path = '') {
1127
-        if($path!=='') $key = "{$path}.{$key}";
1356
+    public function setPlaceholders($value = '', $key = '', $path = '')
1357
+    {
1358
+        if($path!=='') {
1359
+            $key = "{$path}.{$key}";
1360
+        }
1128 1361
         if (is_array($value)) {
1129 1362
             foreach ($value as $subkey => $subval) {
1130 1363
                 $this->setPlaceholders($subval, $subkey, $key);
1131 1364
             }
1365
+        } else {
1366
+            $this->setModifiersVariable($key, $value);
1132 1367
         }
1133
-        else $this->setModifiersVariable($key, $value);
1134 1368
     }
1135 1369
 
1136 1370
     // Sets a placeholder variable which can only be access by Modifiers
1137
-    public function setModifiersVariable($key, $value) {
1138
-        if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1371
+    public function setModifiersVariable($key, $value)
1372
+    {
1373
+        if ($key != 'phx' && $key != 'dummy') {
1374
+            $this->placeholders[$key] = $value;
1375
+        }
1139 1376
     }
1140 1377
 
1141 1378
     //mbstring
1142
-    public function substr($str, $s, $l = null) {
1379
+    public function substr($str, $s, $l = null)
1380
+    {
1143 1381
         global $modx;
1144
-        if(is_null($l)) $l = $this->strlen($str);
1145
-        if (function_exists('mb_substr'))
1146
-        {
1147
-            if(strpos($str,"\r")!==false)
1148
-                $str = str_replace(array("\r\n","\r"), "\n", $str);
1382
+        if(is_null($l)) {
1383
+            $l = $this->strlen($str);
1384
+        }
1385
+        if (function_exists('mb_substr')) {
1386
+            if(strpos($str,"\r")!==false) {
1387
+                            $str = str_replace(array("\r\n","\r"), "\n", $str);
1388
+            }
1149 1389
             return mb_substr($str, $s, $l, $modx->config['modx_charset']);
1150 1390
         }
1151 1391
         return substr($str, $s, $l);
1152 1392
     }
1153
-    public function strpos($haystack,$needle,$offset=0) {
1393
+    public function strpos($haystack,$needle,$offset=0)
1394
+    {
1154 1395
         global $modx;
1155
-        if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1396
+        if (function_exists('mb_strpos')) {
1397
+            return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']);
1398
+        }
1156 1399
         return strpos($haystack,$needle,$offset);
1157 1400
     }
1158
-    public function strlen($str) {
1401
+    public function strlen($str)
1402
+    {
1159 1403
         global $modx;
1160
-        if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1404
+        if (function_exists('mb_strlen')) {
1405
+            return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']);
1406
+        }
1161 1407
         return strlen($str);
1162 1408
     }
1163
-    public function strtolower($str) {
1164
-        if (function_exists('mb_strtolower')) return mb_strtolower($str);
1409
+    public function strtolower($str)
1410
+    {
1411
+        if (function_exists('mb_strtolower')) {
1412
+            return mb_strtolower($str);
1413
+        }
1165 1414
         return strtolower($str);
1166 1415
     }
1167
-    public function strtoupper($str) {
1168
-        if (function_exists('mb_strtoupper')) return mb_strtoupper($str);
1416
+    public function strtoupper($str)
1417
+    {
1418
+        if (function_exists('mb_strtoupper')) {
1419
+            return mb_strtoupper($str);
1420
+        }
1169 1421
         return strtoupper($str);
1170 1422
     }
1171
-    public function ucfirst($str) {
1172
-        if (function_exists('mb_strtoupper'))
1173
-            return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1423
+    public function ucfirst($str)
1424
+    {
1425
+        if (function_exists('mb_strtoupper')) {
1426
+                    return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1427
+        }
1174 1428
         return ucfirst($str);
1175 1429
     }
1176
-    public function lcfirst($str) {
1177
-        if (function_exists('mb_strtolower'))
1178
-            return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1430
+    public function lcfirst($str)
1431
+    {
1432
+        if (function_exists('mb_strtolower')) {
1433
+                    return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1434
+        }
1179 1435
         return lcfirst($str);
1180 1436
     }
1181
-    public function ucwords($str) {
1182
-        if (function_exists('mb_convert_case'))
1183
-            return mb_convert_case($str, MB_CASE_TITLE);
1437
+    public function ucwords($str)
1438
+    {
1439
+        if (function_exists('mb_convert_case')) {
1440
+                    return mb_convert_case($str, MB_CASE_TITLE);
1441
+        }
1184 1442
         return ucwords($str);
1185 1443
     }
1186
-    public function strrev($str) {
1444
+    public function strrev($str)
1445
+    {
1187 1446
         preg_match_all('/./us', $str, $ar);
1188 1447
         return implode(array_reverse($ar[0]));
1189 1448
     }
1190
-    public function str_shuffle($str) {
1449
+    public function str_shuffle($str)
1450
+    {
1191 1451
         preg_match_all('/./us', $str, $ar);
1192 1452
         shuffle($ar[0]);
1193 1453
         return implode($ar[0]);
1194 1454
     }
1195
-    public function str_word_count($str) {
1455
+    public function str_word_count($str)
1456
+    {
1196 1457
         return count(preg_split('~[^\p{L}\p{N}\']+~u',$str));
1197 1458
     }
1198
-    public function strip_tags($value,$params='') {
1459
+    public function strip_tags($value,$params='')
1460
+    {
1199 1461
         global $modx;
1200 1462
 
1201 1463
         if(stripos($params,'style')===false && stripos($value,'</style>')!==false) {
Please login to merge, or discard this patch.
install/actions/action_summary.php 4 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -248,9 +248,9 @@
 block discarded – undo
248 248
         echo '<span class="notok">' . $_lang['failed'] . '</span></b>' . $_lang['table_prefix_not_exist'] . '</p>';
249 249
         $errors++;
250 250
         echo '<p>' . $_lang['table_prefix_not_exist_note'] . '</p>';
251
-  } else {
251
+    } else {
252 252
         echo '<span class="ok">' . $_lang['ok'] . '</span></p>';
253
-  }
253
+    }
254 254
 }
255 255
 
256 256
 // check mysql version
Please login to merge, or discard this 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.
Braces   +35 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,19 +1,22 @@  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
6 6
      * @param null|int $mode
7 7
      */
8
-    function f_owc($path, $data, $mode = null){
8
+    function f_owc($path, $data, $mode = null)
9
+    {
9 10
         try {
10 11
             // make an attempt to create the file
11 12
             $hnd = fopen($path, 'w');
12 13
             fwrite($hnd, $data);
13 14
             fclose($hnd);
14 15
 
15
-            if(null !== $mode) chmod($path, $mode);
16
-        }catch(Exception $e){
16
+            if(null !== $mode) {
17
+                chmod($path, $mode);
18
+            }
19
+        } catch(Exception $e) {
17 20
             // Nothing, this is NOT normal
18 21
             unset($e);
19 22
         }
@@ -21,7 +24,9 @@  discard block
 block discarded – undo
21 24
 }
22 25
 
23 26
 $installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0;
24
-if( ! isset($_lang)) $_lang = array();
27
+if( ! isset($_lang)) {
28
+    $_lang = array();
29
+}
25 30
 
26 31
 echo '<div class="stepcontainer">
27 32
       <ul class="progressbar">
@@ -57,7 +62,7 @@  discard block
 block discarded – undo
57 62
 // check if iconv is available
58 63
 echo '<p>' . $_lang['checking_iconv'];
59 64
 $iconv = (int) function_exists('iconv');
60
-if ($iconv == '0'){
65
+if ($iconv == '0') {
61 66
     echo '<span class="notok">' . $_lang['failed'].'</span></p><p><strong>'.$_lang['checking_iconv_note'].'</strong></p>';
62 67
     $errors++;
63 68
 } else {
@@ -119,7 +124,7 @@  discard block
 block discarded – undo
119 124
 
120 125
 // File Browser directories exists?
121 126
 echo '<p>'.$_lang['checking_if_images_exist'];
122
-switch(true){
127
+switch(true) {
123 128
     case !file_exists("../assets/images"):
124 129
     case !file_exists("../assets/files"):
125 130
     case !file_exists("../assets/backup"):
@@ -134,7 +139,7 @@  discard block
 block discarded – undo
134 139
 
135 140
 // File Browser directories writable?
136 141
 echo '<p>'.$_lang['checking_if_images_writable'];
137
-switch(true){
142
+switch(true) {
138 143
     case !is_writable("../assets/images"):
139 144
     case !is_writable("../assets/files"):
140 145
     case !is_writable("../assets/backup"):
@@ -268,7 +273,7 @@  discard block
 block discarded – undo
268 273
 if ($conn) {
269 274
     echo '<p>'. $_lang['checking_mysql_strict_mode'];
270 275
     $mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode");
271
-    if (mysqli_num_rows($mysqlmode) > 0){
276
+    if (mysqli_num_rows($mysqlmode) > 0) {
272 277
         $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM);
273 278
         //$modes = array("STRICT_TRANS_TABLES"); // for testing
274 279
         // print_r($modes);
@@ -305,9 +310,9 @@  discard block
 block discarded – undo
305 310
     echo '<p>';
306 311
     echo $_lang['setup_cannot_continue'] . ' ';
307 312
 
308
-    if($errors > 1){
313
+    if($errors > 1) {
309 314
         echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural'];
310
-    }else{
315
+    } else {
311 316
         echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again'];
312 317
     }
313 318
 
@@ -343,23 +348,35 @@  discard block
 block discarded – undo
343 348
     <input type="hidden" value="<?php echo $_POST['installdata'] ?>" name="installdata" />
344 349
 <?php
345 350
     $templates = isset ($_POST['template']) ? $_POST['template'] : array ();
346
-    foreach ($templates as $i => $template) echo '<input type="hidden" name="template[]" value="'.$template.'" />';
351
+    foreach ($templates as $i => $template) {
352
+        echo '<input type="hidden" name="template[]" value="'.$template.'" />';
353
+    }
347 354
 
348 355
     $tvs = isset ($_POST['tv']) ? $_POST['tv'] : array ();
349
-    foreach ($tvs as $i => $tv) echo '<input type="hidden" name="tv[]" value="'.$tv.'" />';
356
+    foreach ($tvs as $i => $tv) {
357
+        echo '<input type="hidden" name="tv[]" value="'.$tv.'" />';
358
+    }
350 359
 
351 360
     $chunks = isset ($_POST['chunk']) ? $_POST['chunk'] : array ();
352
-    foreach ($chunks as $i => $chunk) echo '<input type="hidden" name="chunk[]" value="'.$chunk.'" />';
361
+    foreach ($chunks as $i => $chunk) {
362
+        echo '<input type="hidden" name="chunk[]" value="'.$chunk.'" />';
363
+    }
353 364
 
354 365
     $snippets = isset ($_POST['snippet']) ? $_POST['snippet'] : array ();
355
-    foreach ($snippets as $i => $snippet) echo '<input type="hidden" name="snippet[]" value="'.$snippet.'" />';
366
+    foreach ($snippets as $i => $snippet) {
367
+        echo '<input type="hidden" name="snippet[]" value="'.$snippet.'" />';
368
+    }
356 369
 
357 370
     $plugins = isset ($_POST['plugin']) ? $_POST['plugin'] : array ();
358
-    foreach ($plugins as $i => $plugin) echo '<input type="hidden" name="plugin[]" value="'.$plugin.'" />';
371
+    foreach ($plugins as $i => $plugin) {
372
+        echo '<input type="hidden" name="plugin[]" value="'.$plugin.'" />';
373
+    }
359 374
 
360 375
     $modules = isset ($_POST['module']) ? $_POST['module'] : array ();
361
-    foreach ($modules as $i => $module) echo '<input type="hidden" name="module[]" value="'.$module.'" />';
362
-?>
376
+    foreach ($modules as $i => $module) {
377
+        echo '<input type="hidden" name="module[]" value="'.$module.'" />';
378
+    }
379
+    ?>
363 380
 </div>
364 381
 
365 382
 <h2><?php echo $_lang['agree_to_terms'];?></h2>
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@
 block discarded – undo
207 207
 
208 208
 
209 209
 // make sure we can use the database
210
-if ($installMode > 0 && !mysqli_query($conn, "USE {$dbase}")) {
210
+if ($installMode > 0 && !mysqli_query($conn, "use {$dbase}")) {
211 211
     $errors++;
212 212
     echo '<span class="notok">'.$_lang['database_use_failed'].'</span><p />'.$_lang["database_use_failed_note"].'</p>';
213 213
 }
Please login to merge, or discard this patch.