Completed
Pull Request — develop (#725)
by Agel_Nash
08:07
created
manager/includes/src/Legacy/Permissions.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $role = $this->role;
40 40
 
41 41
         if ($role == 1) {
42
-            return true;  // administrator - grant all document permissions
42
+            return true; // administrator - grant all document permissions
43 43
         }
44 44
 
45 45
         if ($modx->config['use_udperms'] == 0 || $modx->config['use_udperms'] == "" || !isset($modx->config['use_udperms'])) {
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
             are private to the manager users will not be private to web users if the
67 67
             document group is not assigned to a web user group and visa versa.
68 68
          */
69
-        $permissionsok = false;  // set permissions to false
69
+        $permissionsok = false; // set permissions to false
70 70
 
71 71
         $rs = $modx->getDatabase()->select(
72 72
             'count(DISTINCT sc.id)',
73 73
             "{$tblsc} AS sc 
74 74
 				LEFT JOIN {$tbldg} AS dg on dg.document = sc.id 
75 75
 				LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group",
76
-            "sc.id='{$this->document}' AND (" . (empty($docgrp) ? '' : "dg.document_group = " . $docgrp . " ||") . " sc.privatemgr = 0)"
76
+            "sc.id='{$this->document}' AND (".(empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||")." sc.privatemgr = 0)"
77 77
         );
78 78
         $limit = $modx->getDatabase()->getValue($rs);
79 79
         if ($limit == 1) {
Please login to merge, or discard this patch.
manager/includes/src/Legacy/Categories.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         $this->db_tbl['categories'] = $modx->getFullTableName('categories');
21 21
 
22 22
         foreach ($this->elements as $element) {
23
-            $this->db_tbl[$element] = $modx->getFullTableName('site_' . $element);
23
+            $this->db_tbl[$element] = $modx->getFullTableName('site_'.$element);
24 24
         }
25 25
     }
26 26
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             $this->getDatabase()->select(
55 55
                 '*',
56 56
                 $this->db_tbl['categories'],
57
-                "`" . $where . "` = '" . $this->getDatabase()->escape($search) . "'"
57
+                "`".$where."` = '".$this->getDatabase()->escape($search)."'"
58 58
             )
59 59
         );
60 60
 
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $_value = $this->getDatabase()->getValue(
73 73
             $this->getDatabase()->select(
74
-                '`' . $value . '`',
74
+                '`'.$value.'`',
75 75
                 $this->db_tbl['categories'],
76
-                "`" . $where . "` = '" . $this->getDatabase()->escape($search) . "'"
76
+                "`".$where."` = '".$this->getDatabase()->escape($search)."'"
77 77
             )
78 78
         );
79 79
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                 $this->getDatabase()->select(
93 93
                     '*',
94 94
                     $this->db_tbl[$element],
95
-                    "`category` = '" . (int)$category_id . "'"
95
+                    "`category` = '".(int) $category_id."'"
96 96
                 )
97 97
             );
98 98
 
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
             $this->getDatabase()->update(
136 136
                 $_update,
137 137
                 $this->db_tbl[$element],
138
-                "`category` = '" . (int)$category_id . "'"
138
+                "`category` = '".(int) $category_id."'"
139 139
             );
140 140
         }
141 141
 
142 142
         $this->getDatabase()->delete(
143 143
             $this->db_tbl['categories'],
144
-            "`id` = '" . (int)$category_id . "'"
144
+            "`id` = '".(int) $category_id."'"
145 145
         );
146 146
 
147 147
         return $this->getDatabase()->getAffectedRows() === 1;
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
 
161 161
         $_update = array(
162 162
             'category' => $this->getDatabase()->escape($data['category']),
163
-            'rank'     => (int)$data['rank']
163
+            'rank'     => (int) $data['rank']
164 164
         );
165 165
 
166 166
         $this->getDatabase()->update(
167 167
             $_update,
168 168
             $this->db_tbl['categories'],
169
-            "`id` = '" . (int)$category_id . "'"
169
+            "`id` = '".(int) $category_id."'"
170 170
         );
171 171
 
172 172
         if ($this->getDatabase()->getAffectedRows() === 1) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
         $_insert = array(
191 191
             'category' => $this->getDatabase()->escape($category_name),
192
-            'rank'     => (int)$category_rank
192
+            'rank'     => (int) $category_rank
193 193
         );
194 194
 
195 195
         $this->getDatabase()->insert(
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             $this->getDatabase()->select(
217 217
                 '`id`',
218 218
                 $this->db_tbl['categories'],
219
-                "`category` = '" . $category . "'"
219
+                "`category` = '".$category."'"
220 220
             )
221 221
         );
222 222
 
Please login to merge, or discard this patch.
manager/includes/src/Legacy/LogHandler.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
         $action = "",
37 37
         $itemid = "",
38 38
         $itemname = ""
39
-    ) {
39
+    ){
40 40
         $modx = evolutionCMS();
41 41
         $this->entry['msg'] = $msg; // writes testmessage to the object
42
-        $this->entry['action'] = empty($action) ? $modx->getManagerApi()->action : $action;    // writes the action to the object
42
+        $this->entry['action'] = empty($action) ? $modx->getManagerApi()->action : $action; // writes the action to the object
43 43
 
44 44
         // User Credentials
45 45
         $this->entry['internalKey'] = $internalKey == "" ? $modx->getLoginUserID() : $internalKey;
46 46
         $this->entry['username'] = $username == "" ? $modx->getLoginUserName() : $username;
47 47
 
48
-        $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int)$_REQUEST['id'] : $itemid;  // writes the id to the object
48
+        $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int) $_REQUEST['id'] : $itemid; // writes the id to the object
49 49
         if ($this->entry['itemId'] == 0) {
50 50
             $this->entry['itemId'] = "-";
51 51
         } // to stop items having id 0
@@ -96,20 +96,20 @@  discard block
 block discarded – undo
96 96
 
97 97
         $insert_id = $modx->getDatabase()->insert($fields, $tbl_manager_log);
98 98
         if (!$insert_id) {
99
-            $modx->messageQuit("Logging error: couldn't save log to table! Error code: " . $modx->getDatabase()->getLastError());
99
+            $modx->messageQuit("Logging error: couldn't save log to table! Error code: ".$modx->getDatabase()->getLastError());
100 100
         } else {
101
-            $limit = (isset($modx->config['manager_log_limit'])) ? (int)$modx->config['manager_log_limit'] : 3000;
102
-            $trim = (isset($modx->config['manager_log_trim'])) ? (int)$modx->config['manager_log_trim'] : 100;
101
+            $limit = (isset($modx->config['manager_log_limit'])) ? (int) $modx->config['manager_log_limit'] : 3000;
102
+            $trim = (isset($modx->config['manager_log_trim'])) ? (int) $modx->config['manager_log_trim'] : 100;
103 103
             if (($insert_id % $trim) === 0) {
104 104
                 $modx->rotate_log('manager_log', $limit, $trim);
105 105
             }
106 106
         }
107 107
     }
108 108
 
109
-    private function getUserIP() {
110
-        if( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
111
-            if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')>0) {
112
-                $addr = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']);
109
+    private function getUserIP(){
110
+        if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
111
+            if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') > 0) {
112
+                $addr = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
113 113
                 return trim($addr[0]);
114 114
             } else {
115 115
                 return $_SERVER['HTTP_X_FORWARDED_FOR'];
Please login to merge, or discard this patch.
manager/includes/src/Legacy/mgrResources.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php namespace EvolutionCMS\Legacy;
2 2
 
3
-class mgrResources {
3
+class mgrResources{
4 4
     /**
5 5
      * @var array
6 6
      */
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * mgrResources constructor.
23 23
      */
24
-    public function __construct() {
24
+    public function __construct(){
25 25
         $this->setTypes();
26 26
         $this->queryItemsFromDB();
27 27
         $this->prepareCategoryArrays();
@@ -30,47 +30,47 @@  discard block
 block discarded – undo
30 30
     /**
31 31
      * @return void
32 32
      */
33
-    public function setTypes() {
33
+    public function setTypes(){
34 34
         global $_lang;
35
-        $this->types['site_templates']    = array(
35
+        $this->types['site_templates'] = array(
36 36
             'title'=>$_lang["manage_templates"],
37
-            'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ),
38
-            'permissions'=>array('new_template','edit_template'),
37
+            'actions'=>array('edit'=>array(16, 'edit_template'), 'duplicate'=>array(96, 'new_template'), 'remove'=>array(21, 'delete_template')),
38
+            'permissions'=>array('new_template', 'edit_template'),
39 39
             'name'=>'templatename'
40 40
         );
41
-        $this->types['site_tmplvars']     = array(
41
+        $this->types['site_tmplvars'] = array(
42 42
             'title'=>$_lang["tmplvars"],
43
-            'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')),
44
-            'permissions'=>array('new_template','edit_template'),
43
+            'actions'=>array('edit'=>array(301, 'edit_template'), 'duplicate'=>array(304, 'edit_template'), 'remove'=>array(303, 'edit_template')),
44
+            'permissions'=>array('new_template', 'edit_template'),
45 45
         );
46 46
         $this->types['site_htmlsnippets'] = array(
47 47
             'title'=>$_lang["manage_htmlsnippets"],
48
-            'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')),
49
-            'permissions'=>array('new_chunk','edit_chunk'),
48
+            'actions'=>array('edit'=>array(78, 'edit_chunk'), 'duplicate'=>array(97, 'new_chunk'), 'remove'=>array(80, 'delete_chunk')),
49
+            'permissions'=>array('new_chunk', 'edit_chunk'),
50 50
         );
51
-        $this->types['site_snippets']     = array(
51
+        $this->types['site_snippets'] = array(
52 52
             'title'=>$_lang["manage_snippets"],
53
-            'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')),
54
-            'permissions'=>array('new_snippet','edit_snippet'),
53
+            'actions'=>array('edit'=>array(22, 'edit_snippet'), 'duplicate'=>array(98, 'new_snippet'), 'remove'=>array(25, 'delete_snippet')),
54
+            'permissions'=>array('new_snippet', 'edit_snippet'),
55 55
         );
56
-        $this->types['site_plugins']      = array(
56
+        $this->types['site_plugins'] = array(
57 57
             'title'=>$_lang["manage_plugins"],
58
-            'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')),
59
-            'permissions'=>array('new_plugin','edit_plugin'),
58
+            'actions'=>array('edit'=>array(102, 'edit_plugin'), 'duplicate'=>array(105, 'new_plugin'), 'remove'=>array(104, 'delete_plugin')),
59
+            'permissions'=>array('new_plugin', 'edit_plugin'),
60 60
         );
61
-        $this->types['site_modules']      = array(
61
+        $this->types['site_modules'] = array(
62 62
             'title'=>$_lang["manage_modules"],
63
-            'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')),
64
-            'permissions'=>array('new_module','edit_module'),
63
+            'actions'=>array('edit'=>array(108, 'edit_module'), 'duplicate'=>array(111, 'new_module'), 'remove'=>array(110, 'delete_module')),
64
+            'permissions'=>array('new_module', 'edit_module'),
65 65
         );
66 66
     }
67 67
 
68 68
     /**
69 69
      * @return void
70 70
      */
71
-    public function queryItemsFromDB() {
72
-        foreach($this->types as $resourceTable=>$type) {
73
-            if($this->hasAnyPermissions($type['permissions'])) {
71
+    public function queryItemsFromDB(){
72
+        foreach ($this->types as $resourceTable=>$type) {
73
+            if ($this->hasAnyPermissions($type['permissions'])) {
74 74
                 $nameField = isset($type['name']) ? $type['name'] : 'name';
75 75
                 $this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField);
76 76
             }
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
      * @param array $permissions
82 82
      * @return bool
83 83
      */
84
-    public function hasAnyPermissions($permissions) {
84
+    public function hasAnyPermissions($permissions){
85 85
         $modx = evolutionCMS();
86 86
 
87
-        foreach($permissions as $p)
88
-            if($modx->hasPermission($p)) return true;
87
+        foreach ($permissions as $p)
88
+            if ($modx->hasPermission($p)) return true;
89 89
 
90 90
         return false;
91 91
     }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      * @param string $nameField
96 96
      * @return array|bool
97 97
      */
98
-    public function queryResources($resourceTable, $nameField = 'name') {
98
+    public function queryResources($resourceTable, $nameField = 'name'){
99 99
         $modx = evolutionCMS(); global $_lang;
100 100
 
101 101
         $allowed = array(
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             'site_plugins',
105 105
             'site_modules'
106 106
         );
107
-        $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : '';
107
+        $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable.'.disabled, ' : '';
108 108
 
109 109
         $tvsql  = '';
110 110
         $tvjoin = '';
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 
120 120
         $rs = $modx->getDatabase()->select(
121 121
             "{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid",
122
-            $modx->getFullTableName($resourceTable) . " AS {$resourceTable}
123
-	            LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}",
122
+            $modx->getFullTableName($resourceTable)." AS {$resourceTable}
123
+	            LEFT JOIN ".$modx->getFullTableName('categories')." AS categories ON {$resourceTable}.category = categories.id {$tvjoin}",
124 124
             "",
125 125
             "category,name"
126 126
         );
127 127
         $limit = $modx->getDatabase()->getRecordCount($rs);
128 128
 
129
-        if($limit < 1) return false;
129
+        if ($limit < 1) return false;
130 130
 
131 131
         $result = array();
132 132
         while ($row = $modx->getDatabase()->getRow($rs)) {
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
     /**
139 139
      * @return void
140 140
      */
141
-    public function prepareCategoryArrays() {
142
-        foreach($this->items as $type=>$items) {
143
-            foreach((array)$items as $item) {
141
+    public function prepareCategoryArrays(){
142
+        foreach ($this->items as $type=>$items) {
143
+            foreach ((array) $items as $item) {
144 144
                 $catid = $item['catid'] ? $item['catid'] : 0;
145 145
                 $this->categories[$catid] = $item['category'];
146 146
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
         natcasesort($this->categories);
154 154
 
155 155
         // Now sort by name
156
-        foreach($this->itemsPerCategory as $catid=>$items) {
157
-            usort($this->itemsPerCategory[$catid], function ($a, $b) {
156
+        foreach ($this->itemsPerCategory as $catid=>$items) {
157
+            usort($this->itemsPerCategory[$catid], function($a, $b){
158 158
                 return strcasecmp($a['name'], $b['name']);
159 159
             });
160 160
         }
Please login to merge, or discard this patch.
manager/includes/src/Legacy/DeprecatedCore.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
         for ($i = 0; $i < $tablevel; $i++) {
120 120
             $tabs .= "\t";
121 121
         }
122
-        $listhtml = $ordered == true ? $tabs . "<ol class='$ulroot'$typestr>\n" : $tabs . "<ul class='$ulroot'$typestr>\n";
122
+        $listhtml = $ordered == true ? $tabs."<ol class='$ulroot'$typestr>\n" : $tabs."<ul class='$ulroot'$typestr>\n";
123 123
         foreach ($array as $key => $value) {
124 124
             if (is_array($value)) {
125
-                $listhtml .= $tabs . "\t<li>" . $key . "\n" . $this->makeList($value, $ulprefix . $ulroot, $ulprefix,
126
-                        $type, $ordered, $tablevel + 2) . $tabs . "\t</li>\n";
125
+                $listhtml .= $tabs."\t<li>".$key."\n".$this->makeList($value, $ulprefix.$ulroot, $ulprefix,
126
+                        $type, $ordered, $tablevel + 2).$tabs."\t</li>\n";
127 127
             } else {
128
-                $listhtml .= $tabs . "\t<li>" . $value . "</li>\n";
128
+                $listhtml .= $tabs."\t<li>".$value."</li>\n";
129 129
             }
130 130
         }
131
-        $listhtml .= $ordered == true ? $tabs . "</ol>\n" : $tabs . "</ul>\n";
131
+        $listhtml .= $ordered == true ? $tabs."</ol>\n" : $tabs."</ul>\n";
132 132
 
133 133
         return $listhtml;
134 134
     }
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
         $msg = addslashes($modx->getDatabase()->escape($msg));
300 300
         if (substr(strtolower($url), 0, 11) == "javascript:") {
301 301
             $act = "__WebAlert();";
302
-            $fnc = "function __WebAlert(){" . substr($url, 11) . "};";
302
+            $fnc = "function __WebAlert(){".substr($url, 11)."};";
303 303
         } else {
304
-            $act = ($url ? "window.location.href='" . addslashes($url) . "';" : "");
304
+            $act = ($url ? "window.location.href='".addslashes($url)."';" : "");
305 305
         }
306 306
         $html = "<script>$fnc window.setTimeout(\"alert('$msg');$act\",100);</script>";
307 307
         if ($modx->isFrontend()) {
Please login to merge, or discard this patch.
manager/includes/src/Legacy/Modifiers.php 1 patch
Spacing   +348 added lines, -348 removed lines patch added patch discarded remove patch
@@ -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
         $modx = evolutionCMS();
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
         $modx = evolutionCMS();
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
         $modx = evolutionCMS();
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
         $modx = evolutionCMS();
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
         $modx = evolutionCMS();
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->getDatabase()->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->getDatabase()->select('templatename','[+prefix+]site_templates',"id='{$value}'");
779
+                $rs = $modx->getDatabase()->select('templatename', '[+prefix+]site_templates', "id='{$value}'");
780 780
                 $templateName = $modx->getDatabase()->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
         $modx = evolutionCMS();
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
         $modx = evolutionCMS();
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->getDatabase()->escape($this->elmName);
1000
-            $result = $modx->getDatabase()->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'");
1000
+            $result = $modx->getDatabase()->select('snippet', '[+prefix+]site_snippets', "name='{$esc_elmName}'");
1001 1001
             $total = $modx->getDatabase()->getRecordCount($result);
1002
-            if($total == 1)
1002
+            if ($total == 1)
1003 1003
             {
1004 1004
                 $row = $modx->getDatabase()->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
         $modx = evolutionCMS();
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
         $modx = evolutionCMS();
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
         $modx = evolutionCMS();
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
         $modx = evolutionCMS();
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
         $modx = evolutionCMS();
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
         $modx = evolutionCMS();
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.
manager/includes/src/Legacy/TemplateParser.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -8,46 +8,46 @@  discard block
 block discarded – undo
8 8
      * @param array $data
9 9
      * @return string
10 10
      */
11
-    public function output($config = array(), $data = array()) {
11
+    public function output($config = array(), $data = array()){
12 12
         $modx = evolutionCMS();
13 13
 
14 14
         $output = '';
15 15
         $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : '');
16
-        $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
16
+        $tab = isset($config['tab']) ? ' AND tab IN('.$config['tab'].')' : '';
17 17
 
18
-        if($action) {
18
+        if ($action) {
19 19
             $sql = $modx->getDatabase()->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
20
-			FROM ' . $modx->getFullTableName('system_templates') . ' AS t1
21
-			INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category
22
-			WHERE t1.action IN(' . $action . ') ' . $tab . '
20
+			FROM ' . $modx->getFullTableName('system_templates').' AS t1
21
+			INNER JOIN ' . $modx->getFullTableName('categories').' AS t2 ON t2.id=t1.category
22
+			WHERE t1.action IN(' . $action.') '.$tab.'
23 23
 			ORDER BY t1.tab ASC, t1.rank ASC');
24 24
 
25
-            if($modx->getDatabase()->getRecordCount($sql)) {
25
+            if ($modx->getDatabase()->getRecordCount($sql)) {
26 26
                 $tabs = array();
27
-                while($row = $modx->getDatabase()->getRow($sql)) {
28
-                    if(!$row['value'] && !empty($data[$row['name']])) {
27
+                while ($row = $modx->getDatabase()->getRow($sql)) {
28
+                    if (!$row['value'] && !empty($data[$row['name']])) {
29 29
                         $row['value'] = $data[$row['name']];
30 30
                     }
31 31
                     $tabs[$row['tab']]['category_name'] = $row['category_name'];
32 32
                     $tabs[$row['tab']][$row['name']] = $this->render($row);
33 33
                 }
34 34
 
35
-                if(!empty($config['toArray'])) {
35
+                if (!empty($config['toArray'])) {
36 36
                     $output = $tabs;
37 37
                 } else {
38
-                    $output .= '<div class="tab-pane" id="pane_' . $action . '">';
38
+                    $output .= '<div class="tab-pane" id="pane_'.$action.'">';
39 39
                     $output .= '
40 40
 					<script type="text/javascript">
41
-						var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
41
+						var pane_' . $action.' = new WebFXTabPane(document.getElementById("pane_'.$action.'"), '.($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').');
42 42
 					</script>';
43 43
 
44
-                    foreach($tabs as $idTab => $tab) {
45
-                        $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">';
44
+                    foreach ($tabs as $idTab => $tab) {
45
+                        $output .= '<div class="tab-page" id="tab_'.$action.'_'.$idTab.'">';
46 46
                         $output .= '
47
-						<h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2>
48
-						<script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>';
47
+						<h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']).'</h2>
48
+						<script type="text/javascript">pane_' . $action.'.addTabPage(document.getElementById("tab_'.$action.'_'.$idTab.'"));</script>';
49 49
                         unset($tab['category_name']);
50
-                        foreach($tab as $item) {
50
+                        foreach ($tab as $item) {
51 51
                             $output .= $item;
52 52
                         }
53 53
                         $output .= '</div>';
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      * @param array $data
65 65
      * @return string
66 66
      */
67
-    private function render($data) {
67
+    private function render($data){
68 68
         $modx = evolutionCMS(); global $_lang, $_country_lang;
69 69
 
70 70
         $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         $output = '';
75 75
         $output .= '<div class="form-group row">';
76 76
 
77
-        switch($data['type']) {
77
+        switch ($data['type']) {
78 78
 
79 79
             case 'text':
80 80
                 $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
                 $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
109 109
                 $output .= '<div class="col-sm-7">';
110 110
                 $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">';
111
-                if($data['name'] == 'country' && isset($_country_lang)) {
111
+                if ($data['name'] == 'country' && isset($_country_lang)) {
112 112
                     $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country'];
113
-                    $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '>&nbsp;</option>';
114
-                    foreach($_country_lang as $key => $value) {
115
-                        $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>';
113
+                    $output .= '<option value=""'.(!isset($chosenCountry) ? ' selected' : '').'>&nbsp;</option>';
114
+                    foreach ($_country_lang as $key => $value) {
115
+                        $output .= '<option value="'.$key.'"'.(isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '').'>'.$value.'</option>';
116 116
                     }
117 117
                 } else {
118
-                    if($data['elements']) {
118
+                    if ($data['elements']) {
119 119
                         $elements = explode('||', $data['elements']);
120
-                        foreach($elements as $key => $value) {
120
+                        foreach ($elements as $key => $value) {
121 121
                             $value = explode('==', $value);
122
-                            $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>';
122
+                            $output .= '<option value="'.$value[1].'">'.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]).'</option>';
123 123
                         }
124 124
                     }
125 125
                 }
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
                 $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
134 134
                 $output .= '<div class="col-sm-7">';
135 135
                 $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
136
-                if($data['elements']) {
136
+                if ($data['elements']) {
137 137
                     $elements = explode('||', $data['elements']);
138
-                    foreach($elements as $key => $value) {
138
+                    foreach ($elements as $key => $value) {
139 139
                         $value = explode('==', $value);
140
-                        $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
140
+                        $output .= '<br /><input type="checkbox" name="'.$value[0].'" class="form-control" id="'.$value[0].'" value="'.$value[1].'" onChange="documentDirty=true;"[+readonly+] /> '.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
141 141
                     }
142 142
                 }
143 143
                 $output .= $data['content'];
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
                 $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
150 150
                 $output .= '<div class="col-sm-7">';
151 151
                 $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
152
-                if($data['elements']) {
152
+                if ($data['elements']) {
153 153
                     $elements = explode('||', $data['elements']);
154
-                    foreach($elements as $key => $value) {
154
+                    foreach ($elements as $key => $value) {
155 155
                         $value = explode('==', $value);
156
-                        $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
156
+                        $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_'.$key.'" value="'.$value[1].'" onChange="documentDirty=true;"[+readonly+] /> '.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
157 157
                     }
158 158
                 }
159 159
                 $output .= $data['content'];
Please login to merge, or discard this patch.
manager/includes/src/Legacy/ModuleCategoriesManager.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
     {
86 86
         global $_lang, $_style;
87 87
 
88
-        $filename = trim($view_name) . '.tpl.phtml';
89
-        $file = self::get('views_dir') . $filename;
88
+        $filename = trim($view_name).'.tpl.phtml';
89
+        $file = self::get('views_dir').$filename;
90 90
         $view = &$this;
91 91
 
92 92
         if (is_file($file)
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
     {
112 112
 
113 113
         $_update = array(
114
-            'id'       => (int)$element_id,
115
-            'category' => (int)$category_id
114
+            'id'       => (int) $element_id,
115
+            'category' => (int) $category_id
116 116
         );
117 117
 
118 118
         $this->getDatabase()->update(
119 119
             $_update,
120 120
             $this->db_tbl[$element],
121
-            "`id` = '" . (int)$element_id . "'"
121
+            "`id` = '".(int) $element_id."'"
122 122
         );
123 123
 
124 124
         return $this->getDatabase()->getAffectedRows() === 1;
Please login to merge, or discard this patch.
manager/includes/src/Database.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $pre = null,
34 34
         $charset = '',
35 35
         $connection_method = 'SET CHARACTER SET'
36
-    ) {
36
+    ){
37 37
         $this->config['host'] = $host ? $host : $GLOBALS['database_server'];
38 38
         $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase'];
39 39
         $this->config['user'] = $uid ? $uid : $GLOBALS['database_user'];
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                         $ua = $modx->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_USER_AGENT']);
74 74
                         $referer = $modx->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_REFERER']);
75 75
                         $modx->sendmail(array(
76
-                            'subject' => 'Missing to create the database connection! from ' . $modx->config['site_name'],
76
+                            'subject' => 'Missing to create the database connection! from '.$modx->config['site_name'],
77 77
                             'body'    => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}",
78 78
                             'type'    => 'text'
79 79
                         ));
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             $tend = $modx->getMicroTime();
89 89
             $totaltime = $tend - $tstart;
90 90
             if ($modx->dumpSQL) {
91
-                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s",
92
-                        $totaltime) . "</fieldset><br />";
91
+                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s",
92
+                        $totaltime)."</fieldset><br />";
93 93
             }
94 94
             $this->conn->set_charset($this->config['charset']);
95 95
             $this->isConnected = true;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         if (1000 < $safeCount) {
123 123
             exit("Too many loops '{$safeCount}'");
124 124
         }
125
-        if ( ! ($this->conn instanceof mysqli)) {
125
+        if (!($this->conn instanceof mysqli)) {
126 126
             $this->connect();
127 127
         }
128 128
         if (is_array($s)) {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     public function query($sql, $watchError = true)
149 149
     {
150 150
         $modx = evolutionCMS();
151
-        if ( ! ($this->conn instanceof mysqli)) {
151
+        if (!($this->conn instanceof mysqli)) {
152 152
             $this->connect();
153 153
         }
154 154
         $tStart = $modx->getMicroTime();
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                 case 1091:
169 169
                     break;
170 170
                 default:
171
-                    $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql);
171
+                    $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql);
172 172
             }
173 173
         } else {
174 174
             $tend = $modx->getMicroTime();
@@ -182,24 +182,24 @@  discard block
 block discarded – undo
182 182
                     $debug_path[] = $line['function'];
183 183
                 }
184 184
                 $debug_path = implode(' > ', array_reverse($debug_path));
185
-                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms",
186
-                        $totalTime * 1000) . "</legend>";
187
-                $modx->queryCode .= $sql . '<br><br>';
185
+                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms",
186
+                        $totalTime * 1000)."</legend>";
187
+                $modx->queryCode .= $sql.'<br><br>';
188 188
                 if ($modx->event->name) {
189
-                    $modx->queryCode .= 'Current Event  => ' . $modx->event->name . '<br>';
189
+                    $modx->queryCode .= 'Current Event  => '.$modx->event->name.'<br>';
190 190
                 }
191 191
                 if ($modx->event->activePlugin) {
192
-                    $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>';
192
+                    $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>';
193 193
                 }
194 194
                 if ($modx->currentSnippet) {
195
-                    $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>';
195
+                    $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>';
196 196
                 }
197 197
                 if (stripos($sql, 'select') === 0) {
198
-                    $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>';
198
+                    $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>';
199 199
                 } else {
200
-                    $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>';
200
+                    $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>';
201 201
                 }
202
-                $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>';
202
+                $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>';
203 203
                 $modx->queryCode .= "</fieldset><br />";
204 204
             }
205 205
             $modx->executedQueries++;
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
                     if ($value === null || strtolower($value) === 'null') {
307 307
                         $f = 'NULL';
308 308
                     } else {
309
-                        $f = "'" . $value . "'";
309
+                        $f = "'".$value."'";
310 310
                     }
311
-                    $fields[$key] = "`{$key}` = " . $f;
311
+                    $fields[$key] = "`{$key}` = ".$f;
312 312
                 }
313 313
                 $fields = implode(',', $fields);
314 314
             }
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
                 $this->query("INSERT INTO {$intotable} {$fields}");
344 344
             } else {
345 345
                 if (empty($fromtable)) {
346
-                    $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '",
347
-                            array_values($fields)) . "')";
346
+                    $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '",
347
+                            array_values($fields))."')";
348 348
                     $this->query("INSERT INTO {$intotable} {$fields}");
349 349
                 } else {
350 350
                     $fromtable = $this->replaceFullTableName($fromtable);
351
-                    $fields = "(" . implode(",", array_keys($fields)) . ")";
351
+                    $fields = "(".implode(",", array_keys($fields)).")";
352 352
                     $where = trim($where);
353 353
                     $limit = trim($limit);
354 354
                     if ($where !== '' && stripos($where, 'WHERE') !== 0) {
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
      */
443 443
     public function getInsertId($conn = null)
444 444
     {
445
-        if (! ($conn instanceof mysqli)) {
446
-            $conn =& $this->conn;
445
+        if (!($conn instanceof mysqli)) {
446
+            $conn = & $this->conn;
447 447
         }
448 448
 
449 449
         return $conn->insert_id;
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
      */
456 456
     public function getAffectedRows($conn = null)
457 457
     {
458
-        if (! ($conn instanceof mysqli)) {
459
-            $conn =& $this->conn;
458
+        if (!($conn instanceof mysqli)) {
459
+            $conn = & $this->conn;
460 460
         }
461 461
 
462 462
         return $conn->affected_rows;
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
      */
469 469
     public function getLastError($conn = null)
470 470
     {
471
-        if (! ($conn instanceof mysqli)) {
472
-            $conn =& $this->conn;
471
+        if (!($conn instanceof mysqli)) {
472
+            $conn = & $this->conn;
473 473
         }
474 474
 
475 475
         return $conn->error;
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
     {
494 494
         $out = false;
495 495
         if ($ds instanceof mysqli_result) {
496
-            switch($mode){
496
+            switch ($mode) {
497 497
                 case 'assoc':
498 498
                     $out = $ds->fetch_assoc();
499 499
                     break;
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
     public function getColumn($name, $dsq)
524 524
     {
525 525
         $col = array();
526
-        if ( ! ($dsq instanceof mysqli_result)) {
526
+        if (!($dsq instanceof mysqli_result)) {
527 527
             $dsq = $this->query($dsq);
528 528
         }
529 529
         if ($dsq) {
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
     public function getColumnNames($dsq)
543 543
     {
544 544
         $names = array();
545
-        if ( ! ($dsq instanceof mysqli_result)) {
545
+        if (!($dsq instanceof mysqli_result)) {
546 546
             $dsq = $this->query($dsq);
547 547
         }
548 548
         if ($dsq) {
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
     public function getValue($dsq)
563 563
     {
564 564
         $out = false;
565
-        if ( ! ($dsq instanceof mysqli_result)) {
565
+        if (!($dsq instanceof mysqli_result)) {
566 566
             $dsq = $this->query($dsq);
567 567
         }
568 568
         if ($dsq) {
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
         $tableName = trim($tableName);
661 661
         $dbase = trim($this->config['dbase'], '`');
662 662
         $prefix = $this->config['table_prefix'];
663
-        if ((bool)$force === true) {
663
+        if ((bool) $force === true) {
664 664
             $result = "`{$dbase}`.`{$prefix}{$tableName}`";
665 665
         } elseif (strpos($tableName, '[+prefix+]') !== false) {
666 666
             $result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $tableName);
Please login to merge, or discard this patch.