Completed
Pull Request — develop (#534)
by Agel_Nash
05:08
created
manager/includes/config_check.inc.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 
6 6
 // PROCESSOR FIRST
7
-if($_SESSION['mgrRole'] == 1) {
8
-	if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) {
7
+if ($_SESSION['mgrRole'] == 1) {
8
+	if ($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) {
9 9
 		$current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']);
10
-		if(!empty($current)) {
10
+		if (!empty($current)) {
11 11
 			$modx->manager->setSystemChecksum($current);
12 12
 			$modx->clearCache('full');
13 13
 			$modx->config['sys_files_checksum'] = $current;
@@ -19,14 +19,14 @@  discard block
 block discarded – undo
19 19
 $warningspresent = 0;
20 20
 
21 21
 $sysfiles_check = $modx->manager->checkSystemChecksum();
22
-if ($sysfiles_check!=='0'){
22
+if ($sysfiles_check !== '0') {
23 23
       $warningspresent = 1;
24 24
       $warnings[] = array($_lang['configcheck_sysfiles_mod']);
25 25
 }
26 26
 
27
-if (is_writable("includes/config.inc.php")){
27
+if (is_writable("includes/config.inc.php")) {
28 28
     // Warn if world writable
29
-    if(@fileperms('includes/config.inc.php') & 0x0002) {
29
+    if (@fileperms('includes/config.inc.php') & 0x0002) {
30 30
       $warningspresent = 1;
31 31
       $warnings[] = array($_lang['configcheck_configinc']);
32 32
     }
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
     $warnings[] = array($_lang['configcheck_php_gdzip']);
43 43
 }
44 44
 
45
-if(!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') {
46
-    if(isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') {
45
+if (!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') {
46
+    if (isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') {
47 47
         if ($modx->db->getValue($modx->db->select('COUNT(setting_value)', $modx->getFullTableName('system_settings'), "setting_name='validate_referer' AND setting_value='0'"))) {
48 48
             $warningspresent = 1;
49 49
             $warnings[] = array($_lang['configcheck_validate_referer']);
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 }
53 53
 
54 54
 // check for Template Switcher plugin
55
-if(!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') {
56
-    if(isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') {
55
+if (!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') {
56
+    if (isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') {
57 57
         $rs = $modx->db->select('name, disabled', $modx->getFullTableName('site_plugins'), "name IN ('TemplateSwitcher', 'Template Switcher', 'templateswitcher', 'template_switcher', 'template switcher') OR plugincode LIKE '%TemplateSwitcher%'");
58 58
         $row = $modx->db->getRow($rs);
59
-        if($row && $row['disabled'] == 0) {
59
+        if ($row && $row['disabled'] == 0) {
60 60
             $warningspresent = 1;
61 61
             $warnings[] = array($_lang['configcheck_templateswitcher_present']);
62 62
             $tplName = $row['name'];
@@ -117,36 +117,36 @@  discard block
 block discarded – undo
117 117
 }
118 118
 
119 119
 if (!function_exists('checkSiteCache')) {
120
-    function checkSiteCache() {
120
+    function checkSiteCache(){
121 121
         global $modx;
122
-        $checked= true;
123
-        if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) {
124
-            $checked= @include_once ($modx->config['base_path'] . 'assets/cache/siteCache.idx.php');
122
+        $checked = true;
123
+        if (file_exists($modx->config['base_path'].'assets/cache/siteCache.idx.php')) {
124
+            $checked = @include_once ($modx->config['base_path'].'assets/cache/siteCache.idx.php');
125 125
         }
126 126
         return $checked;
127 127
     }
128 128
 }
129 129
 
130
-if (!is_writable(MODX_BASE_PATH . "assets/cache/")) {
130
+if (!is_writable(MODX_BASE_PATH."assets/cache/")) {
131 131
     $warningspresent = 1;
132 132
     $warnings[] = array($_lang['configcheck_cache']);
133 133
 }
134 134
 
135 135
 if (!checkSiteCache()) {
136 136
     $warningspresent = 1;
137
-    $warnings[]= array($lang['configcheck_sitecache_integrity']);
137
+    $warnings[] = array($lang['configcheck_sitecache_integrity']);
138 138
 }
139 139
 
140
-if (!is_writable(MODX_BASE_PATH . "assets/images/")) {
140
+if (!is_writable(MODX_BASE_PATH."assets/images/")) {
141 141
     $warningspresent = 1;
142 142
     $warnings[] = array($_lang['configcheck_images']);
143 143
 }
144 144
 
145
-if(strpos($modx->config['rb_base_dir'],MODX_BASE_PATH)!==0) {
145
+if (strpos($modx->config['rb_base_dir'], MODX_BASE_PATH) !== 0) {
146 146
     $warningspresent = 1;
147 147
     $warnings[] = array($_lang['configcheck_rb_base_dir']);
148 148
 }
149
-if(strpos($modx->config['filemanager_path'],MODX_BASE_PATH)!==0) {
149
+if (strpos($modx->config['filemanager_path'], MODX_BASE_PATH) !== 0) {
150 150
     $warningspresent = 1;
151 151
     $warnings[] = array($_lang['configcheck_filemanager_path']);
152 152
 }
@@ -154,36 +154,36 @@  discard block
 block discarded – undo
154 154
 // clear file info cache
155 155
 clearstatcache();
156 156
 
157
-if ($warningspresent==1) {
157
+if ($warningspresent == 1) {
158 158
 
159
-if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3';
159
+if (!isset($modx->config['send_errormail'])) $modx->config['send_errormail'] = '3';
160 160
 $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>";
161 161
 
162
-for ($i=0;$i<count($warnings);$i++) {
162
+for ($i = 0; $i < count($warnings); $i++) {
163 163
     switch ($warnings[$i][0]) {
164 164
         case $_lang['configcheck_configinc'];
165 165
             $warnings[$i][1] = $_lang['configcheck_configinc_msg'];
166
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
166
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_configinc']);
167 167
             break;
168 168
         case $_lang['configcheck_installer'] :
169 169
             $warnings[$i][1] = $_lang['configcheck_installer_msg'];
170
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
170
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_installer']);
171 171
             break;
172 172
         case $_lang['configcheck_cache'] :
173 173
             $warnings[$i][1] = $_lang['configcheck_cache_msg'];
174
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
174
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_cache']);
175 175
             break;
176 176
         case $_lang['configcheck_images'] :
177 177
             $warnings[$i][1] = $_lang['configcheck_images_msg'];
178
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
178
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_images']);
179 179
             break;
180 180
         case $_lang['configcheck_sysfiles_mod']:
181 181
             $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"];
182
-			$warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>';
183
-			if($modx->hasPermission('settings')) {
184
-				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>';
182
+			$warnings[$i][2] = '<ul><li>'.implode('</li><li>', $sysfiles_check).'</li></ul>';
183
+			if ($modx->hasPermission('settings')) {
184
+				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\''.$_lang["reset_sysfiles_checksum_alert"].'\')">'.$_lang["reset_sysfiles_checksum_button"].'</a></li></ul>';
185 185
 			}
186
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
186
+            if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1]." ".implode(', ', $sysfiles_check), $_lang['configcheck_sysfiles_mod']);
187 187
             break;
188 188
         case $_lang['configcheck_lang_difference'] :
189 189
             $warnings[$i][1] = $_lang['configcheck_lang_difference_msg'];
@@ -205,18 +205,18 @@  discard block
 block discarded – undo
205 205
             break;
206 206
         case $_lang['configcheck_validate_referer'] :
207 207
             $msg = $_lang['configcheck_validate_referer_msg'];
208
-            $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'validate_referer');
208
+            $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'validate_referer');
209 209
             $warnings[$i][1] = "<span id=\"validate_referer_warning_wrapper\">{$msg}</span>\n";
210 210
             break;
211 211
         case $_lang['configcheck_templateswitcher_present'] :
212 212
             $msg = $_lang["configcheck_templateswitcher_present_msg"];
213
-            if(isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') {
214
-                $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_disable"];
213
+            if (isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') {
214
+                $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_disable"];
215 215
             }
216
-            if(isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') {
217
-                $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_delete"];
216
+            if (isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') {
217
+                $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_delete"];
218 218
             }
219
-            $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present');
219
+            $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present');
220 220
             $warnings[$i][1] = "<span id=\"templateswitcher_present_warning_wrapper\">{$msg}</span>\n";
221 221
             break;
222 222
         case $_lang['configcheck_rb_base_dir'] :
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
             $warnings[$i][1] = $_lang['configcheck_default_msg'];
230 230
     }
231 231
 
232
-    $admin_warning = $_SESSION['mgrRole']!=1 ? $_lang['configcheck_admin'] : "" ;
232
+    $admin_warning = $_SESSION['mgrRole'] != 1 ? $_lang['configcheck_admin'] : "";
233 233
     $config_check_results .= "
234 234
             <fieldset>
235 235
             <p><strong>".$_lang['configcheck_warning']."</strong> '".$warnings[$i][0]."'</p>
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
             ".(isset($warnings[$i][2]) ? '<div style="padding-left:1em">'.$warnings[$i][2].'</div>' : '')."
239 239
             </fieldset>
240 240
 ";
241
-        if ($i!=count($warnings)-1) {
241
+        if ($i != count($warnings) - 1) {
242 242
             $config_check_results .= "<br />";
243 243
         }
244 244
     }
245
-    $_SESSION["mgrConfigCheck"]=true;
245
+    $_SESSION["mgrConfigCheck"] = true;
246 246
 } else {
247 247
     $config_check_results = $_lang['configcheck_ok'];
248 248
 }
Please login to merge, or discard this patch.
manager/includes/document.parser.class.inc.php 1 patch
Spacing   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     function __call($method_name, $arguments)
207 207
     {
208
-        include_once(MODX_MANAGER_PATH . 'includes/extenders/deprecated.functions.inc.php');
208
+        include_once(MODX_MANAGER_PATH.'includes/extenders/deprecated.functions.inc.php');
209 209
         if (method_exists($this->old, $method_name)) {
210 210
             $error_type = 1;
211 211
         } else {
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
             $info = debug_backtrace();
224 224
             $m[] = $msg;
225 225
             if (!empty($this->currentSnippet)) {
226
-                $m[] = 'Snippet - ' . $this->currentSnippet;
226
+                $m[] = 'Snippet - '.$this->currentSnippet;
227 227
             } elseif (!empty($this->event->activePlugin)) {
228
-                $m[] = 'Plugin - ' . $this->event->activePlugin;
228
+                $m[] = 'Plugin - '.$this->event->activePlugin;
229 229
             }
230 230
             $m[] = $this->decoded_request_uri;
231
-            $m[] = str_replace('\\', '/', $info[0]['file']) . '(line:' . $info[0]['line'] . ')';
231
+            $m[] = str_replace('\\', '/', $info[0]['file']).'(line:'.$info[0]['line'].')';
232 232
             $msg = implode('<br />', $m);
233 233
             $this->logEvent(0, $error_type, $msg, $title);
234 234
         }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     {
246 246
         $flag = false;
247 247
         if (is_scalar($connector) && !empty($connector) && isset($this->{$connector}) && $this->{$connector} instanceof DBAPI) {
248
-            $flag = (bool)$this->{$connector}->conn;
248
+            $flag = (bool) $this->{$connector}->conn;
249 249
         }
250 250
         return $flag;
251 251
     }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         }
273 273
         if (!$out && $flag) {
274 274
             $extname = trim(str_replace(array('..', '/', '\\'), '', strtolower($extname)));
275
-            $filename = MODX_MANAGER_PATH . "includes/extenders/ex_{$extname}.inc.php";
275
+            $filename = MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php";
276 276
             $out = is_file($filename) ? include $filename : false;
277 277
         }
278 278
         if ($out && !in_array($extname, $this->extensions)) {
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     public function getMicroTime()
290 290
     {
291 291
         list ($usec, $sec) = explode(' ', microtime());
292
-        return ((float)$usec + (float)$sec);
292
+        return ((float) $usec + (float) $sec);
293 293
     }
294 294
 
295 295
     /**
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             // append the redirect count string to the url
314 314
             $currentNumberOfRedirects = isset ($_REQUEST['err']) ? $_REQUEST['err'] : 0;
315 315
             if ($currentNumberOfRedirects > 3) {
316
-                $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>' . $url . '</i></p>');
316
+                $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>'.$url.'</i></p>');
317 317
             } else {
318 318
                 $currentNumberOfRedirects += 1;
319 319
                 if (strpos($url, "?") > 0) {
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
             }
325 325
         }
326 326
         if ($type == 'REDIRECT_REFRESH') {
327
-            $header = 'Refresh: 0;URL=' . $url;
327
+            $header = 'Refresh: 0;URL='.$url;
328 328
         } elseif ($type == 'REDIRECT_META') {
329
-            $header = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=' . $url . '" />';
329
+            $header = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL='.$url.'" />';
330 330
             echo $header;
331 331
             exit;
332 332
         } elseif ($type == 'REDIRECT_HEADER' || empty ($type)) {
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
             global $base_url, $site_url;
335 335
             if (substr($url, 0, strlen($base_url)) == $base_url) {
336 336
                 // append $site_url to make it work with Location:
337
-                $url = $site_url . substr($url, strlen($base_url));
337
+                $url = $site_url.substr($url, strlen($base_url));
338 338
             }
339 339
             if (strpos($url, "\n") === false) {
340
-                $header = 'Location: ' . $url;
340
+                $header = 'Location: '.$url;
341 341
             } else {
342 342
                 $this->messageQuit('No newline allowed in redirect url.');
343 343
             }
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
             header($responseCode);
347 347
         }
348 348
 
349
-        if(!empty($header)) {
349
+        if (!empty($header)) {
350 350
             header($header);
351 351
         }
352 352
 
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
 
451 451
     private function recoverySiteCache()
452 452
     {
453
-        $site_cache_dir = MODX_BASE_PATH . $this->getCacheFolder();
454
-        $site_cache_path = $site_cache_dir . 'siteCache.idx.php';
453
+        $site_cache_dir = MODX_BASE_PATH.$this->getCacheFolder();
454
+        $site_cache_path = $site_cache_dir.'siteCache.idx.php';
455 455
 
456 456
         if (is_file($site_cache_path)) {
457 457
             include($site_cache_path);
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
             return;
461 461
         }
462 462
 
463
-        include_once(MODX_MANAGER_PATH . 'processors/cache_sync.class.processor.php');
463
+        include_once(MODX_MANAGER_PATH.'processors/cache_sync.class.processor.php');
464 464
         $cache = new synccache();
465 465
         $cache->setCachepath($site_cache_dir);
466 466
         $cache->setReport(false);
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
                 $this->invokeEvent("OnBeforeManagerPageInit");
512 512
             }
513 513
 
514
-            if (isset ($_SESSION[$usrType . 'UsrConfigSet'])) {
515
-                $usrSettings = &$_SESSION[$usrType . 'UsrConfigSet'];
514
+            if (isset ($_SESSION[$usrType.'UsrConfigSet'])) {
515
+                $usrSettings = &$_SESSION[$usrType.'UsrConfigSet'];
516 516
             } else {
517 517
                 if ($usrType == 'web') {
518 518
                     $from = $tbl_web_user_settings;
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
                     $usrSettings[$row['setting_name']] = $row['setting_value'];
533 533
                 }
534 534
                 if (isset ($usrType)) {
535
-                    $_SESSION[$usrType . 'UsrConfigSet'] = $usrSettings;
535
+                    $_SESSION[$usrType.'UsrConfigSet'] = $usrSettings;
536 536
                 } // store user settings in session
537 537
             }
538 538
         }
@@ -677,10 +677,10 @@  discard block
 block discarded – undo
677 677
         $suf = $this->config['friendly_url_suffix'];
678 678
         $pre = preg_quote($pre, '/');
679 679
         $suf = preg_quote($suf, '/');
680
-        if ($pre && preg_match('@^' . $pre . '(.*)$@', $q, $_)) {
680
+        if ($pre && preg_match('@^'.$pre.'(.*)$@', $q, $_)) {
681 681
             $q = $_[1];
682 682
         }
683
-        if ($suf && preg_match('@(.*)' . $suf . '$@', $q, $_)) {
683
+        if ($suf && preg_match('@(.*)'.$suf.'$@', $q, $_)) {
684 684
             $q = $_[1];
685 685
         }
686 686
 
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
         if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */
703 703
             /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */
704 704
             if ($this->config['use_alias_path'] == 1) {
705
-                if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) {
705
+                if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir.'/'.$q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) {
706 706
                     $this->documentMethod = 'id';
707 707
                     return $q;
708 708
                 } else { /* not a valid id in terms of virtualDir, treat as alias */
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
      */
737 737
     public function getHashFile($key)
738 738
     {
739
-        return $this->getCacheFolder() . "docid_" . $key . ".pageCache.php";
739
+        return $this->getCacheFolder()."docid_".$key.".pageCache.php";
740 740
     }
741 741
 
742 742
     /**
@@ -747,9 +747,9 @@  discard block
 block discarded – undo
747 747
         $hash = $id;
748 748
         $tmp = null;
749 749
         $params = array();
750
-        if(!empty($this->systemCacheKey)){
750
+        if (!empty($this->systemCacheKey)) {
751 751
             $hash = $this->systemCacheKey;
752
-        }else {
752
+        } else {
753 753
             if (!empty($_GET)) {
754 754
                 // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID.
755 755
                 $params = $_GET;
@@ -757,8 +757,8 @@  discard block
 block discarded – undo
757 757
                 $hash .= '_'.md5(http_build_query($params));
758 758
             }
759 759
         }
760
-        $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params));
761
-        if (is_array($evtOut) && count($evtOut) > 0){
760
+        $evtOut = $this->invokeEvent("OnMakePageCacheKey", array("hash" => $hash, "id" => $id, 'params' => $params));
761
+        if (is_array($evtOut) && count($evtOut) > 0) {
762 762
             $tmp = array_pop($evtOut);
763 763
         }
764 764
         return empty($tmp) ? $hash : $tmp;
@@ -900,12 +900,12 @@  discard block
 block discarded – undo
900 900
         if ($js = $this->getRegisteredClientStartupScripts()) {
901 901
             // change to just before closing </head>
902 902
             // $this->documentContent = preg_replace("/(<head[^>]*>)/i", "\\1\n".$js, $this->documentContent);
903
-            $this->documentOutput = preg_replace("/(<\/head>)/i", $js . "\n\\1", $this->documentOutput);
903
+            $this->documentOutput = preg_replace("/(<\/head>)/i", $js."\n\\1", $this->documentOutput);
904 904
         }
905 905
 
906 906
         // Insert jscripts & html block into template - template must have a </body> tag
907 907
         if ($js = $this->getRegisteredClientScripts()) {
908
-            $this->documentOutput = preg_replace("/(<\/body>)/i", $js . "\n\\1", $this->documentOutput);
908
+            $this->documentOutput = preg_replace("/(<\/body>)/i", $js."\n\\1", $this->documentOutput);
909 909
         }
910 910
         // End fix by sirlancelot
911 911
 
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
         // send out content-type and content-disposition headers
917 917
         if (IN_PARSER_MODE == "true") {
918 918
             $type = !empty ($this->contentTypes[$this->documentIdentifier]) ? $this->contentTypes[$this->documentIdentifier] : "text/html";
919
-            header('Content-Type: ' . $type . '; charset=' . $this->config['modx_charset']);
919
+            header('Content-Type: '.$type.'; charset='.$this->config['modx_charset']);
920 920
             //            if (($this->documentIdentifier == $this->config['error_page']) || $redirect_error)
921 921
             //                header('HTTP/1.0 404 Not Found');
922 922
             if (!$this->checkPreview() && $this->documentObject['content_dispo'] == 1) {
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
                     $name = preg_replace('|-+|', '-', $name);
935 935
                     $name = trim($name, '-');
936 936
                 }
937
-                $header = 'Content-Disposition: attachment; filename=' . $name;
937
+                $header = 'Content-Disposition: attachment; filename='.$name;
938 938
                 header($header);
939 939
             }
940 940
         }
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 
943 943
         $stats = $this->getTimerStats($this->tstart);
944 944
 
945
-        $out =& $this->documentOutput;
945
+        $out = & $this->documentOutput;
946 946
         $out = str_replace("[^q^]", $stats['queries'], $out);
947 947
         $out = str_replace("[^qt^]", $stats['queryTime'], $out);
948 948
         $out = str_replace("[^p^]", $stats['phpTime'], $out);
@@ -981,17 +981,17 @@  discard block
 block discarded – undo
981 981
                 $sc .= sprintf("%s. %s (%s)<br>", $s, $sname, sprintf("%2.2f ms", $t)); // currentSnippet
982 982
                 $tt += $t;
983 983
             }
984
-            echo "<fieldset><legend><b>Snippets</b> (" . count($this->snippetsTime) . " / " . sprintf("%2.2f ms", $tt) . ")</legend>{$sc}</fieldset><br />";
984
+            echo "<fieldset><legend><b>Snippets</b> (".count($this->snippetsTime)." / ".sprintf("%2.2f ms", $tt).")</legend>{$sc}</fieldset><br />";
985 985
             echo $this->snippetsCode;
986 986
         }
987 987
         if ($this->dumpPlugins) {
988 988
             $ps = "";
989 989
             $tt = 0;
990 990
             foreach ($this->pluginsTime as $s => $t) {
991
-                $ps .= "$s (" . sprintf("%2.2f ms", $t * 1000) . ")<br>";
991
+                $ps .= "$s (".sprintf("%2.2f ms", $t * 1000).")<br>";
992 992
                 $tt += $t;
993 993
             }
994
-            echo "<fieldset><legend><b>Plugins</b> (" . count($this->pluginsTime) . " / " . sprintf("%2.2f ms", $tt * 1000) . ")</legend>{$ps}</fieldset><br />";
994
+            echo "<fieldset><legend><b>Plugins</b> (".count($this->pluginsTime)." / ".sprintf("%2.2f ms", $tt * 1000).")</legend>{$ps}</fieldset><br />";
995 995
             echo $this->pluginsCode;
996 996
         }
997 997
 
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
         $srcTags = explode(',', $tags);
1018 1018
         $repTags = array();
1019 1019
         foreach ($srcTags as $tag) {
1020
-            $repTags[] = '\\' . $tag[0] . '\\' . $tag[1];
1020
+            $repTags[] = '\\'.$tag[0].'\\'.$tag[1];
1021 1021
         }
1022 1022
         return array($srcTags, $repTags);
1023 1023
     }
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
         $stats['phpTime'] = sprintf("%2.4f s", $stats['phpTime']);
1040 1040
         $stats['source'] = $this->documentGenerated == 1 ? "database" : "cache";
1041 1041
         $stats['queries'] = isset ($this->executedQueries) ? $this->executedQueries : 0;
1042
-        $stats['phpMemory'] = (memory_get_peak_usage(true) / 1024 / 1024) . " mb";
1042
+        $stats['phpMemory'] = (memory_get_peak_usage(true) / 1024 / 1024)." mb";
1043 1043
 
1044 1044
         return $stats;
1045 1045
     }
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
     {
1073 1073
         $cacheRefreshTime = 0;
1074 1074
         $recent_update = 0;
1075
-        @include(MODX_BASE_PATH . $this->getCacheFolder() . 'sitePublishing.idx.php');
1075
+        @include(MODX_BASE_PATH.$this->getCacheFolder().'sitePublishing.idx.php');
1076 1076
         $this->recentUpdate = $recent_update;
1077 1077
 
1078 1078
         $timeNow = $_SERVER['REQUEST_TIME'] + $this->config['server_offset_time'];
@@ -1126,8 +1126,8 @@  discard block
 block discarded – undo
1126 1126
                 }
1127 1127
 
1128 1128
                 $docObjSerial = serialize($this->documentObject);
1129
-                $cacheContent = $docObjSerial . "<!--__MODxCacheSpliter__-->" . $this->documentContent;
1130
-                $page_cache_path = MODX_BASE_PATH . $this->getHashFile($this->cacheKey);
1129
+                $cacheContent = $docObjSerial."<!--__MODxCacheSpliter__-->".$this->documentContent;
1130
+                $page_cache_path = MODX_BASE_PATH.$this->getHashFile($this->cacheKey);
1131 1131
                 file_put_contents($page_cache_path, "<?php die('Unauthorized access.'); ?>$cacheContent");
1132 1132
             }
1133 1133
         }
@@ -1169,16 +1169,16 @@  discard block
 block discarded – undo
1169 1169
             return array();
1170 1170
         }
1171 1171
         $spacer = md5('<<<EVO>>>');
1172
-        if($left==='{{' && strpos($content,';}}')!==false)  $content = str_replace(';}}', sprintf(';}%s}',   $spacer),$content);
1173
-        if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content);
1174
-        if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]',  $spacer),$content);
1175
-        if($left==='[[' && strpos($content,']]]')!==false)  $content = str_replace(']]]', sprintf(']%s]]',   $spacer),$content);
1172
+        if ($left === '{{' && strpos($content, ';}}') !== false)  $content = str_replace(';}}', sprintf(';}%s}', $spacer), $content);
1173
+        if ($left === '{{' && strpos($content, '{{}}') !== false) $content = str_replace('{{}}', sprintf('{%$1s{}%$1s}', $spacer), $content);
1174
+        if ($left === '[[' && strpos($content, ']]]]') !== false) $content = str_replace(']]]]', sprintf(']]%s]]', $spacer), $content);
1175
+        if ($left === '[[' && strpos($content, ']]]') !== false)  $content = str_replace(']]]', sprintf(']%s]]', $spacer), $content);
1176 1176
 
1177 1177
         $pos['<![CDATA['] = strpos($content, '<![CDATA[');
1178 1178
         $pos[']]>'] = strpos($content, ']]>');
1179 1179
 
1180 1180
         if ($pos['<![CDATA['] !== false && $pos[']]>'] !== false) {
1181
-            $content = substr($content, 0, $pos['<![CDATA[']) . substr($content, $pos[']]>'] + 3);
1181
+            $content = substr($content, 0, $pos['<![CDATA[']).substr($content, $pos[']]>'] + 3);
1182 1182
         }
1183 1183
 
1184 1184
         $lp = explode($left, $content);
@@ -1242,8 +1242,8 @@  discard block
 block discarded – undo
1242 1242
                 }
1243 1243
             }
1244 1244
         }
1245
-        foreach($tags as $i=>$tag) {
1246
-            if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag);
1245
+        foreach ($tags as $i=>$tag) {
1246
+            if (strpos($tag, $spacer) !== false) $tags[$i] = str_replace($spacer, '', $tag);
1247 1247
         }
1248 1248
         return $tags;
1249 1249
     }
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
         }
1284 1284
 
1285 1285
         foreach ($matches[1] as $i => $key) {
1286
-            if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1286
+            if (strpos($key, '[+') !== false) continue; // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1287 1287
             if (substr($key, 0, 1) == '#') {
1288 1288
                 $key = substr($key, 1);
1289 1289
             } // remove # for QuickEdit format
@@ -1303,8 +1303,8 @@  discard block
 block discarded – undo
1303 1303
             }
1304 1304
 
1305 1305
             if (is_array($value)) {
1306
-                include_once(MODX_MANAGER_PATH . 'includes/tmplvars.format.inc.php');
1307
-                include_once(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php');
1306
+                include_once(MODX_MANAGER_PATH.'includes/tmplvars.format.inc.php');
1307
+                include_once(MODX_MANAGER_PATH.'includes/tmplvars.commands.inc.php');
1308 1308
                 $value = getTVDisplayFormat($value[0], $value[1], $value[2], $value[3], $value[4]);
1309 1309
             }
1310 1310
 
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
 
1316 1316
             if (strpos($content, $s) !== false) {
1317 1317
                 $content = str_replace($s, $value, $content);
1318
-            } elseif($this->debug) {
1319
-                $this->addLog('mergeDocumentContent parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1318
+            } elseif ($this->debug) {
1319
+                $this->addLog('mergeDocumentContent parse error', $_SERVER['REQUEST_URI'].$s, 2);
1320 1320
             }
1321 1321
         }
1322 1322
 
@@ -1483,8 +1483,8 @@  discard block
 block discarded – undo
1483 1483
             $s = &$matches[0][$i];
1484 1484
             if (strpos($content, $s) !== false) {
1485 1485
                 $content = str_replace($s, $value, $content);
1486
-            } elseif($this->debug) {
1487
-                $this->addLog('mergeSettingsContent parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1486
+            } elseif ($this->debug) {
1487
+                $this->addLog('mergeSettingsContent parse error', $_SERVER['REQUEST_URI'].$s, 2);
1488 1488
             }
1489 1489
         }
1490 1490
         return $content;
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
             }
1538 1538
 
1539 1539
             $value = $this->parseText($value, $params); // parse local scope placeholers for ConditionalTags
1540
-            $value = $this->mergePlaceholderContent($value, $params);  // parse page global placeholers
1540
+            $value = $this->mergePlaceholderContent($value, $params); // parse page global placeholers
1541 1541
             if ($this->config['enable_at_syntax']) {
1542 1542
                 $value = $this->mergeConditionalTagsContent($value);
1543 1543
             }
@@ -1552,8 +1552,8 @@  discard block
 block discarded – undo
1552 1552
             $s = &$matches[0][$i];
1553 1553
             if (strpos($content, $s) !== false) {
1554 1554
                 $content = str_replace($s, $value, $content);
1555
-            } elseif($this->debug) {
1556
-                $this->addLog('mergeChunkContent parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1555
+            } elseif ($this->debug) {
1556
+                $this->addLog('mergeChunkContent parse error', $_SERVER['REQUEST_URI'].$s, 2);
1557 1557
             }
1558 1558
         }
1559 1559
         return $content;
@@ -1611,8 +1611,8 @@  discard block
 block discarded – undo
1611 1611
             $s = &$matches[0][$i];
1612 1612
             if (strpos($content, $s) !== false) {
1613 1613
                 $content = str_replace($s, $value, $content);
1614
-            } elseif($this->debug) {
1615
-                $this->addLog('mergePlaceholderContent parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1614
+            } elseif ($this->debug) {
1615
+                $this->addLog('mergePlaceholderContent parse error', $_SERVER['REQUEST_URI'].$s, 2);
1616 1616
             }
1617 1617
         }
1618 1618
         return $content;
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
             return $content;
1637 1637
         }
1638 1638
 
1639
-        $sp = '#' . md5('ConditionalTags' . $_SERVER['REQUEST_TIME']) . '#';
1639
+        $sp = '#'.md5('ConditionalTags'.$_SERVER['REQUEST_TIME']).'#';
1640 1640
         $content = str_replace(array('<?php', '<?=', '<?', '?>'), array("{$sp}b", "{$sp}p", "{$sp}s", "{$sp}e"), $content);
1641 1641
 
1642 1642
         $pieces = explode('<@IF:', $content);
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
             }
1648 1648
             list($cmd, $text) = explode('>', $split, 2);
1649 1649
             $cmd = str_replace("'", "\'", $cmd);
1650
-            $content .= "<?php if(\$this->_parseCTagCMD('" . $cmd . "')): ?>";
1650
+            $content .= "<?php if(\$this->_parseCTagCMD('".$cmd."')): ?>";
1651 1651
             $content .= $text;
1652 1652
         }
1653 1653
         $pieces = explode('<@ELSEIF:', $content);
@@ -1658,13 +1658,13 @@  discard block
 block discarded – undo
1658 1658
             }
1659 1659
             list($cmd, $text) = explode('>', $split, 2);
1660 1660
             $cmd = str_replace("'", "\'", $cmd);
1661
-            $content .= "<?php elseif(\$this->_parseCTagCMD('" . $cmd . "')): ?>";
1661
+            $content .= "<?php elseif(\$this->_parseCTagCMD('".$cmd."')): ?>";
1662 1662
             $content .= $text;
1663 1663
         }
1664 1664
 
1665 1665
         $content = str_replace(array('<@ELSE>', '<@ENDIF>'), array('<?php else:?>', '<?php endif;?>'), $content);
1666 1666
         ob_start();
1667
-        $content = eval('?>' . $content);
1667
+        $content = eval('?>'.$content);
1668 1668
         $content = ob_get_clean();
1669 1669
         $content = str_replace(array("{$sp}b", "{$sp}p", "{$sp}s", "{$sp}e"), array('<?php', '<?=', '<?', '?>'), $content);
1670 1670
 
@@ -1789,7 +1789,7 @@  discard block
 block discarded – undo
1789 1789
         $matches = $this->getTagsFromContent($content, $left, $right);
1790 1790
         if (!empty($matches)) {
1791 1791
             foreach ($matches[0] as $i => $v) {
1792
-                $addBreakMatches[$i] = $v . "\n";
1792
+                $addBreakMatches[$i] = $v."\n";
1793 1793
             }
1794 1794
             $content = str_replace($addBreakMatches, '', $content);
1795 1795
             if (strpos($content, $left) !== false) {
@@ -1822,8 +1822,8 @@  discard block
 block discarded – undo
1822 1822
             $s = &$matches[0][$i];
1823 1823
             if (strpos($content, $s) !== false) {
1824 1824
                 $content = str_replace($s, $v, $content);
1825
-            } elseif($this->debug) {
1826
-                $this->addLog('ignoreCommentedTagsContent parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1825
+            } elseif ($this->debug) {
1826
+                $this->addLog('ignoreCommentedTagsContent parse error', $_SERVER['REQUEST_URI'].$s, 2);
1827 1827
             }
1828 1828
         }
1829 1829
         return $content;
@@ -1887,7 +1887,7 @@  discard block
 block discarded – undo
1887 1887
                 $msg = ($msg === false) ? 'ob_get_contents() error' : $msg;
1888 1888
                 $this->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], 'Plugin', $error_info['message'], $error_info['line'], $msg);
1889 1889
                 if ($this->isBackend()) {
1890
-                    $this->event->alert('An error occurred while loading. Please see the event log for more information.<p>' . $msg . '</p>');
1890
+                    $this->event->alert('An error occurred while loading. Please see the event log for more information.<p>'.$msg.'</p>');
1891 1891
                 }
1892 1892
             }
1893 1893
         } else {
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
                 $echo = ($echo === false) ? 'ob_get_contents() error' : $echo;
1934 1934
                 $this->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], 'Snippet', $error_info['message'], $error_info['line'], $echo);
1935 1935
                 if ($this->isBackend()) {
1936
-                    $this->event->alert('An error occurred while loading. Please see the event log for more information<p>' . $echo . $return . '</p>');
1936
+                    $this->event->alert('An error occurred while loading. Please see the event log for more information<p>'.$echo.$return.'</p>');
1937 1937
                 }
1938 1938
             }
1939 1939
         }
@@ -1941,7 +1941,7 @@  discard block
 block discarded – undo
1941 1941
         if (is_array($return) || is_object($return)) {
1942 1942
             return $return;
1943 1943
         } else {
1944
-            return $echo . $return;
1944
+            return $echo.$return;
1945 1945
         }
1946 1946
     }
1947 1947
 
@@ -1979,8 +1979,8 @@  discard block
 block discarded – undo
1979 1979
                 }
1980 1980
                 if (strpos($content, $s) !== false) {
1981 1981
                     $content = str_replace($s, $value, $content);
1982
-                } elseif($this->debug) {
1983
-                    $this->addLog('evalSnippetsSGVar parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1982
+                } elseif ($this->debug) {
1983
+                    $this->addLog('evalSnippetsSGVar parse error', $_SERVER['REQUEST_URI'].$s, 2);
1984 1984
                 }
1985 1985
                 continue;
1986 1986
             }
@@ -1991,8 +1991,8 @@  discard block
 block discarded – undo
1991 1991
 
1992 1992
             if (strpos($content, $s) !== false) {
1993 1993
                 $content = str_replace($s, $value, $content);
1994
-            } elseif($this->debug) {
1995
-                $this->addLog('evalSnippets parse error', $_SERVER['REQUEST_URI'] . $s, 2);
1994
+            } elseif ($this->debug) {
1995
+                $this->addLog('evalSnippets parse error', $_SERVER['REQUEST_URI'].$s, 2);
1996 1996
             }
1997 1997
         }
1998 1998
 
@@ -2083,7 +2083,7 @@  discard block
 block discarded – undo
2083 2083
             $eventtime = sprintf('%2.2f ms', $eventtime * 1000);
2084 2084
             $code = str_replace("\t", '  ', $this->htmlspecialchars($value));
2085 2085
             $piece = str_replace("\t", '  ', $this->htmlspecialchars($piece));
2086
-            $print_r_params = str_replace("\t", '  ', $this->htmlspecialchars('$modx->event->params = ' . print_r($params, true)));
2086
+            $print_r_params = str_replace("\t", '  ', $this->htmlspecialchars('$modx->event->params = '.print_r($params, true)));
2087 2087
             $this->snippetsCode .= sprintf('<fieldset style="margin:1em;"><legend><b>%s</b>(%s)</legend><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">[[%s]]</pre><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">%s</pre><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">%s</pre></fieldset>', $snippetObject['name'], $eventtime, $piece, $print_r_params, $code);
2088 2088
             $this->snippetsTime[] = array('sname' => $key, 'time' => $eventtime);
2089 2089
         }
@@ -2327,7 +2327,7 @@  discard block
 block discarded – undo
2327 2327
             $rs = $this->db->select('name,snippet,properties', '[+prefix+]site_snippets', $where);
2328 2328
             $count = $this->db->getRecordCount($rs);
2329 2329
             if (1 < $count) {
2330
-                exit('Error $modx->_getSnippetObject()' . $snip_name);
2330
+                exit('Error $modx->_getSnippetObject()'.$snip_name);
2331 2331
             }
2332 2332
             if ($count) {
2333 2333
                 $row = $this->db->getRow($rs);
@@ -2353,7 +2353,7 @@  discard block
 block discarded – undo
2353 2353
     public function toAlias($text)
2354 2354
     {
2355 2355
         $suff = $this->config['friendly_url_suffix'];
2356
-        return str_replace(array('.xml' . $suff, '.rss' . $suff, '.js' . $suff, '.css' . $suff, '.txt' . $suff, '.json' . $suff, '.pdf' . $suff), array('.xml', '.rss', '.js', '.css', '.txt', '.json', '.pdf'), $text);
2356
+        return str_replace(array('.xml'.$suff, '.rss'.$suff, '.js'.$suff, '.css'.$suff, '.txt'.$suff, '.json'.$suff, '.pdf'.$suff), array('.xml', '.rss', '.js', '.css', '.txt', '.json', '.pdf'), $text);
2357 2357
     }
2358 2358
 
2359 2359
     /**
@@ -2385,7 +2385,7 @@  discard block
 block discarded – undo
2385 2385
                 $suff = '/';
2386 2386
             }
2387 2387
 
2388
-            $url = ($dir != '' ? $dir . '/' : '') . $pre . $alias . $suff;
2388
+            $url = ($dir != '' ? $dir.'/' : '').$pre.$alias.$suff;
2389 2389
         }
2390 2390
 
2391 2391
         $evtOut = $this->invokeEvent('OnMakeDocUrl', array(
@@ -2422,7 +2422,7 @@  discard block
 block discarded – undo
2422 2422
                 preg_match_all('!\[\~([0-9]+)\~\]!ise', $documentSource, $match);
2423 2423
                 $ids = implode(',', array_unique($match['1']));
2424 2424
                 if ($ids) {
2425
-                    $res = $this->db->select("id,alias,isfolder,parent,alias_visible", $this->getFullTableName('site_content'), "id IN (" . $ids . ") AND isfolder = '0'");
2425
+                    $res = $this->db->select("id,alias,isfolder,parent,alias_visible", $this->getFullTableName('site_content'), "id IN (".$ids.") AND isfolder = '0'");
2426 2426
                     while ($row = $this->db->getRow($res)) {
2427 2427
                         if ($this->config['use_alias_path'] == '1' && $row['parent'] != 0) {
2428 2428
                             $parent = $row['parent'];
@@ -2433,7 +2433,7 @@  discard block
 block discarded – undo
2433 2433
                                 $parent = $this->aliasListing[$parent]['parent'];
2434 2434
                             }
2435 2435
 
2436
-                            $aliases[$row['id']] = $path . '/' . $row['alias'];
2436
+                            $aliases[$row['id']] = $path.'/'.$row['alias'];
2437 2437
                         } else {
2438 2438
                             $aliases[$row['id']] = $row['alias'];
2439 2439
                         }
@@ -2445,7 +2445,7 @@  discard block
 block discarded – undo
2445 2445
             $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0);
2446 2446
             $pref = $this->config['friendly_url_prefix'];
2447 2447
             $suff = $this->config['friendly_url_suffix'];
2448
-            $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) {
2448
+            $documentSource = preg_replace_callback($in, function($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) {
2449 2449
                 global $modx;
2450 2450
                 $thealias = $aliases[$m[1]];
2451 2451
                 $thefolder = $isfolder[$m[1]];
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
 
2462 2462
         } else {
2463 2463
             $in = '!\[\~([0-9]+)\~\]!is';
2464
-            $out = "index.php?id=" . '\1';
2464
+            $out = "index.php?id=".'\1';
2465 2465
             $documentSource = preg_replace($in, $out, $documentSource);
2466 2466
         }
2467 2467
 
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
         $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
2483 2483
         $len_base_url = strlen($this->config['base_url']);
2484 2484
 
2485
-        $url_path = $q;//LANG
2485
+        $url_path = $q; //LANG
2486 2486
 
2487 2487
         if (substr($url_path, 0, $len_base_url) === $this->config['base_url']) {
2488 2488
             $url_path = substr($url_path, $len_base_url);
@@ -2494,7 +2494,7 @@  discard block
 block discarded – undo
2494 2494
             $strictURL = substr($strictURL, $len_base_url);
2495 2495
         }
2496 2496
         $http_host = $_SERVER['HTTP_HOST'];
2497
-        $requestedURL = "{$scheme}://{$http_host}" . '/' . $q; //LANG
2497
+        $requestedURL = "{$scheme}://{$http_host}".'/'.$q; //LANG
2498 2498
 
2499 2499
         $site_url = $this->config['site_url'];
2500 2500
 
@@ -2510,7 +2510,7 @@  discard block
 block discarded – undo
2510 2510
                 }
2511 2511
                 if ($this->config['base_url'] != $_SERVER['REQUEST_URI']) {
2512 2512
                     if (empty($_POST)) {
2513
-                        if (($this->config['base_url'] . '?' . $qstring) != $_SERVER['REQUEST_URI']) {
2513
+                        if (($this->config['base_url'].'?'.$qstring) != $_SERVER['REQUEST_URI']) {
2514 2514
                             $this->sendRedirect($url, 0, 'REDIRECT_HEADER', 'HTTP/1.0 301 Moved Permanently');
2515 2515
                             exit(0);
2516 2516
                         }
@@ -2573,7 +2573,7 @@  discard block
 block discarded – undo
2573 2573
                 $docgrp = implode(",", $docgrp);
2574 2574
             }
2575 2575
             // get document
2576
-            $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
2576
+            $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
2577 2577
             $rs = $this->db->select('sc.*', "{$tblsc} sc
2578 2578
                 LEFT JOIN {$tbldg} dg ON dg.document = sc.id", "sc.{$method} = '{$identifier}' AND ({$access})", "", 1);
2579 2579
             if ($this->db->getRecordCount($rs) < 1) {
@@ -2609,9 +2609,9 @@  discard block
 block discarded – undo
2609 2609
             }
2610 2610
             if ($documentObject['template']) {
2611 2611
                 // load TVs and merge with document - Orig by Apodigm - Docvars
2612
-                $rs = $this->db->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars") . " tv
2613
-                INNER JOIN " . $this->getFullTableName("site_tmplvar_templates") . " tvtpl ON tvtpl.tmplvarid = tv.id
2614
-                LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues") . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'");
2612
+                $rs = $this->db->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars")." tv
2613
+                INNER JOIN " . $this->getFullTableName("site_tmplvar_templates")." tvtpl ON tvtpl.tmplvarid = tv.id
2614
+                LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues")." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'");
2615 2615
                 $tmplvars = array();
2616 2616
                 while ($row = $this->db->getRow($rs)) {
2617 2617
                     $tmplvars[$row['name']] = array(
@@ -2657,7 +2657,7 @@  discard block
 block discarded – undo
2657 2657
                 $st = md5($source);
2658 2658
             }
2659 2659
             if ($this->dumpSnippets == 1) {
2660
-                $this->snippetsCode .= "<fieldset><legend><b style='color: #821517;'>PARSE PASS " . ($i + 1) . "</b></legend><p>The following snippets (if any) were parsed during this pass.</p>";
2660
+                $this->snippetsCode .= "<fieldset><legend><b style='color: #821517;'>PARSE PASS ".($i + 1)."</b></legend><p>The following snippets (if any) were parsed during this pass.</p>";
2661 2661
             }
2662 2662
 
2663 2663
             // invoke OnParseDocument event
@@ -2743,7 +2743,7 @@  discard block
 block discarded – undo
2743 2743
 
2744 2744
             // Check use_alias_path and check if $this->virtualDir is set to anything, then parse the path
2745 2745
             if ($this->config['use_alias_path'] == 1) {
2746
-                $alias = (strlen($this->virtualDir) > 0 ? $this->virtualDir . '/' : '') . $this->documentIdentifier;
2746
+                $alias = (strlen($this->virtualDir) > 0 ? $this->virtualDir.'/' : '').$this->documentIdentifier;
2747 2747
                 if (isset($this->documentListing[$alias])) {
2748 2748
                     $this->documentIdentifier = $this->documentListing[$alias];
2749 2749
                 } else {
@@ -2804,7 +2804,7 @@  discard block
 block discarded – undo
2804 2804
                 } else {
2805 2805
                     $docAlias = $this->db->escape($this->documentIdentifier);
2806 2806
                     $rs = $this->db->select('id', $this->getFullTableName('site_content'), "deleted=0 and alias='{$docAlias}'");
2807
-                    $this->documentIdentifier = (int)$this->db->getValue($rs);
2807
+                    $this->documentIdentifier = (int) $this->db->getValue($rs);
2808 2808
                 }
2809 2809
             }
2810 2810
             $this->documentMethod = 'id';
@@ -2857,7 +2857,7 @@  discard block
 block discarded – undo
2857 2857
                 $_REQUEST[$n] = $_GET[$n] = $v;
2858 2858
             }
2859 2859
         }
2860
-        $_SERVER['PHP_SELF'] = $this->config['base_url'] . $qp['path'];
2860
+        $_SERVER['PHP_SELF'] = $this->config['base_url'].$qp['path'];
2861 2861
         $this->q = $qp['path'];
2862 2862
         return $qp['path'];
2863 2863
     }
@@ -2951,7 +2951,7 @@  discard block
 block discarded – undo
2951 2951
             $this->sendErrorPage();
2952 2952
         } else {
2953 2953
             // Inculde the necessary files to check document permissions
2954
-            include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php');
2954
+            include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php');
2955 2955
             $udperms = new udperms();
2956 2956
             $udperms->user = $this->getLoginUserID();
2957 2957
             $udperms->document = $this->documentIdentifier;
@@ -3005,7 +3005,7 @@  discard block
 block discarded – undo
3005 3005
         while ($id && $height--) {
3006 3006
             $thisid = $id;
3007 3007
             if ($this->config['aliaslistingfolder'] == 1) {
3008
-                $id = isset($this->aliasListing[$id]['parent']) ? $this->aliasListing[$id]['parent'] : $this->db->getValue("SELECT `parent` FROM " . $this->getFullTableName("site_content") . " WHERE `id` = '{$id}' LIMIT 0,1");
3008
+                $id = isset($this->aliasListing[$id]['parent']) ? $this->aliasListing[$id]['parent'] : $this->db->getValue("SELECT `parent` FROM ".$this->getFullTableName("site_content")." WHERE `id` = '{$id}' LIMIT 0,1");
3009 3009
                 if (!$id || $id == '0') {
3010 3010
                     break;
3011 3011
                 }
@@ -3056,15 +3056,15 @@  discard block
 block discarded – undo
3056 3056
 
3057 3057
         if ($this->config['aliaslistingfolder'] == 1) {
3058 3058
 
3059
-            $res = $this->db->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (" . $id . ") AND deleted = '0'");
3059
+            $res = $this->db->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (".$id.") AND deleted = '0'");
3060 3060
             $idx = array();
3061 3061
             while ($row = $this->db->getRow($res)) {
3062 3062
                 $pAlias = '';
3063 3063
                 if (isset($this->aliasListing[$row['parent']])) {
3064
-                    $pAlias .= !empty($this->aliasListing[$row['parent']]['path']) ? $this->aliasListing[$row['parent']]['path'] . '/' : '';
3065
-                    $pAlias .= !empty($this->aliasListing[$row['parent']]['alias']) ? $this->aliasListing[$row['parent']]['alias'] . '/' : '';
3064
+                    $pAlias .= !empty($this->aliasListing[$row['parent']]['path']) ? $this->aliasListing[$row['parent']]['path'].'/' : '';
3065
+                    $pAlias .= !empty($this->aliasListing[$row['parent']]['alias']) ? $this->aliasListing[$row['parent']]['alias'].'/' : '';
3066 3066
                 };
3067
-                $children[$pAlias . $row['alias']] = $row['id'];
3067
+                $children[$pAlias.$row['alias']] = $row['id'];
3068 3068
                 if ($row['isfolder'] == 1) {
3069 3069
                     $idx[] = $row['id'];
3070 3070
                 }
@@ -3096,7 +3096,7 @@  discard block
 block discarded – undo
3096 3096
                 $depth--;
3097 3097
 
3098 3098
                 foreach ($documentMap_cache[$id] as $childId) {
3099
-                    $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '') . $this->aliasListing[$childId]['alias'];
3099
+                    $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '').$this->aliasListing[$childId]['alias'];
3100 3100
                     if (!strlen($pkey)) {
3101 3101
                         $pkey = "{$childId}";
3102 3102
                     }
@@ -3125,7 +3125,7 @@  discard block
 block discarded – undo
3125 3125
         if (substr(strtolower($url), 0, 11) == "javascript:") {
3126 3126
             $fnc = substr($url, 11);
3127 3127
         } elseif ($url) {
3128
-            $fnc = "window.location.href='" . addslashes($url) . "';";
3128
+            $fnc = "window.location.href='".addslashes($url)."';";
3129 3129
         } else {
3130 3130
             $fnc = "history.back(-1);";
3131 3131
         }
@@ -3134,7 +3134,7 @@  discard block
 block discarded – undo
3134 3134
             <meta http-equiv=\"Content-Type\" content=\"text/html; charset={$modx_manager_charset};\">
3135 3135
             <script>
3136 3136
                 function __alertQuit() {
3137
-                    alert('" . addslashes($msg) . "');
3137
+                    alert('".addslashes($msg)."');
3138 3138
                     {$fnc}
3139 3139
                 }
3140 3140
                 window.setTimeout('__alertQuit();',100);
@@ -3158,7 +3158,7 @@  discard block
 block discarded – undo
3158 3158
         if ($pms) {
3159 3159
             $state = ($pms[$pm] == 1);
3160 3160
         }
3161
-        return (int)$state;
3161
+        return (int) $state;
3162 3162
     }
3163 3163
 
3164 3164
     /**
@@ -3171,8 +3171,8 @@  discard block
 block discarded – undo
3171 3171
      */
3172 3172
     public function elementIsLocked($type, $id, $includeThisUser = false)
3173 3173
     {
3174
-        $id = (int)$id;
3175
-        $type = (int)$type;
3174
+        $id = (int) $id;
3175
+        $type = (int) $type;
3176 3176
         if (!$type || !$id) {
3177 3177
             return null;
3178 3178
         }
@@ -3222,7 +3222,7 @@  discard block
 block discarded – undo
3222 3222
             return $lockedElements;
3223 3223
         }
3224 3224
 
3225
-        $type = (int)$type;
3225
+        $type = (int) $type;
3226 3226
         if (isset($lockedElements[$type])) {
3227 3227
             return $lockedElements[$type];
3228 3228
         } else {
@@ -3239,7 +3239,7 @@  discard block
 block discarded – undo
3239 3239
             $this->lockedElements = array();
3240 3240
             $this->cleanupExpiredLocks();
3241 3241
 
3242
-            $rs = $this->db->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks') . " ul
3242
+            $rs = $this->db->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks')." ul
3243 3243
                 LEFT JOIN {$this->getFullTableName('manager_users')} mu on ul.internalKey = mu.id");
3244 3244
             while ($row = $this->db->getRow($rs)) {
3245 3245
                 $this->lockedElements[$row['elementType']][$row['elementId']] = array(
@@ -3262,7 +3262,7 @@  discard block
 block discarded – undo
3262 3262
     public function cleanupExpiredLocks()
3263 3263
     {
3264 3264
         // Clean-up active_user_sessions first
3265
-        $timeout = (int)$this->config['session_timeout'] < 2 ? 120 : $this->config['session_timeout'] * 60; // session.js pings every 10min, updateMail() in mainMenu pings every minute, so 2min is minimum
3265
+        $timeout = (int) $this->config['session_timeout'] < 2 ? 120 : $this->config['session_timeout'] * 60; // session.js pings every 10min, updateMail() in mainMenu pings every minute, so 2min is minimum
3266 3266
         $validSessionTimeLimit = $this->time - $timeout;
3267 3267
         $this->db->delete($this->getFullTableName('active_user_sessions'), "lasthit < {$validSessionTimeLimit}");
3268 3268
 
@@ -3275,7 +3275,7 @@  discard block
 block discarded – undo
3275 3275
             foreach ($rs as $row) {
3276 3276
                 $userSids[] = $row['sid'];
3277 3277
             }
3278
-            $userSids = "'" . implode("','", $userSids) . "'";
3278
+            $userSids = "'".implode("','", $userSids)."'";
3279 3279
             $this->db->delete($this->getFullTableName('active_user_locks'), "sid NOT IN({$userSids})");
3280 3280
         } else {
3281 3281
             $this->db->delete($this->getFullTableName('active_user_locks'));
@@ -3359,8 +3359,8 @@  discard block
 block discarded – undo
3359 3359
     public function lockElement($type, $id)
3360 3360
     {
3361 3361
         $userId = $this->isBackend() && $_SESSION['mgrInternalKey'] ? $_SESSION['mgrInternalKey'] : 0;
3362
-        $type = (int)$type;
3363
-        $id = (int)$id;
3362
+        $type = (int) $type;
3363
+        $id = (int) $id;
3364 3364
         if (!$type || !$id || !$userId) {
3365 3365
             return false;
3366 3366
         }
@@ -3381,8 +3381,8 @@  discard block
 block discarded – undo
3381 3381
     public function unlockElement($type, $id, $includeAllUsers = false)
3382 3382
     {
3383 3383
         $userId = $this->isBackend() && $_SESSION['mgrInternalKey'] ? $_SESSION['mgrInternalKey'] : 0;
3384
-        $type = (int)$type;
3385
-        $id = (int)$id;
3384
+        $type = (int) $type;
3385
+        $id = (int) $id;
3386 3386
         if (!$type || !$id) {
3387 3387
             return false;
3388 3388
         }
@@ -3449,8 +3449,8 @@  discard block
 block discarded – undo
3449 3449
         }
3450 3450
 
3451 3451
         $usertype = $this->isFrontend() ? 1 : 0;
3452
-        $evtid = (int)$evtid;
3453
-        $type = (int)$type;
3452
+        $evtid = (int) $evtid;
3453
+        $type = (int) $type;
3454 3454
 
3455 3455
         // Types: 1 = information, 2 = warning, 3 = error
3456 3456
         if ($type < 1) {
@@ -3472,8 +3472,8 @@  discard block
 block discarded – undo
3472 3472
         if (isset($this->config['send_errormail']) && $this->config['send_errormail'] !== '0') {
3473 3473
             if ($this->config['send_errormail'] <= $type) {
3474 3474
                 $this->sendmail(array(
3475
-                    'subject' => 'MODX System Error on ' . $this->config['site_name'],
3476
-                    'body' => 'Source: ' . $source . ' - The details of the error could be seen in the MODX system events log.',
3475
+                    'subject' => 'MODX System Error on '.$this->config['site_name'],
3476
+                    'body' => 'Source: '.$source.' - The details of the error could be seen in the MODX system events log.',
3477 3477
                     'type' => 'text'
3478 3478
                 ));
3479 3479
             }
@@ -3521,7 +3521,7 @@  discard block
 block discarded – undo
3521 3521
             $p['fromname'] = $userinfo['username'];
3522 3522
         }
3523 3523
         if ($msg === '' && !isset($p['body'])) {
3524
-            $p['body'] = $_SERVER['REQUEST_URI'] . "\n" . $_SERVER['HTTP_USER_AGENT'] . "\n" . $_SERVER['HTTP_REFERER'];
3524
+            $p['body'] = $_SERVER['REQUEST_URI']."\n".$_SERVER['HTTP_USER_AGENT']."\n".$_SERVER['HTTP_REFERER'];
3525 3525
         } elseif (is_string($msg) && 0 < strlen($msg)) {
3526 3526
             $p['body'] = $msg;
3527 3527
         }
@@ -3561,8 +3561,8 @@  discard block
 block discarded – undo
3561 3561
             $files = array();
3562 3562
         }
3563 3563
         foreach ($files as $f) {
3564
-            if (file_exists(MODX_BASE_PATH . $f) && is_file(MODX_BASE_PATH . $f) && is_readable(MODX_BASE_PATH . $f)) {
3565
-                $this->mail->AddAttachment(MODX_BASE_PATH . $f);
3564
+            if (file_exists(MODX_BASE_PATH.$f) && is_file(MODX_BASE_PATH.$f) && is_readable(MODX_BASE_PATH.$f)) {
3565
+                $this->mail->AddAttachment(MODX_BASE_PATH.$f);
3566 3566
             }
3567 3567
         }
3568 3568
         $rs = $this->mail->send();
@@ -3607,7 +3607,7 @@  discard block
 block discarded – undo
3607 3607
      */
3608 3608
     public function isFrontend()
3609 3609
     {
3610
-        return ! $this->isBackend();
3610
+        return !$this->isBackend();
3611 3611
     }
3612 3612
 
3613 3613
     /**
@@ -3632,14 +3632,14 @@  discard block
 block discarded – undo
3632 3632
         $tblsc = $this->getFullTableName("site_content");
3633 3633
         $tbldg = $this->getFullTableName("document_groups");
3634 3634
         // modify field names to use sc. table reference
3635
-        $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3636
-        $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3635
+        $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3636
+        $sort = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3637 3637
         // get document groups for current user
3638 3638
         if ($docgrp = $this->getUserDocGroups()) {
3639 3639
             $docgrp = implode(",", $docgrp);
3640 3640
         }
3641 3641
         // build query
3642
-        $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3642
+        $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3643 3643
         $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc
3644 3644
                 LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}");
3645 3645
         $resourceArray = $this->db->makeArray($result);
@@ -3669,14 +3669,14 @@  discard block
 block discarded – undo
3669 3669
         $tbldg = $this->getFullTableName("document_groups");
3670 3670
 
3671 3671
         // modify field names to use sc. table reference
3672
-        $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3673
-        $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3672
+        $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3673
+        $sort = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3674 3674
         // get document groups for current user
3675 3675
         if ($docgrp = $this->getUserDocGroups()) {
3676 3676
             $docgrp = implode(",", $docgrp);
3677 3677
         }
3678 3678
         // build query
3679
-        $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3679
+        $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3680 3680
         $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc
3681 3681
                 LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND sc.published=1 AND sc.deleted=0 AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}");
3682 3682
         $resourceArray = $this->db->makeArray($result);
@@ -3711,16 +3711,16 @@  discard block
 block discarded – undo
3711 3711
             return $this->tmpCache[__FUNCTION__][$cacheKey];
3712 3712
         }
3713 3713
 
3714
-        $published = ($published !== 'all') ? 'AND sc.published = ' . $published : '';
3715
-        $deleted = ($deleted !== 'all') ? 'AND sc.deleted = ' . $deleted : '';
3714
+        $published = ($published !== 'all') ? 'AND sc.published = '.$published : '';
3715
+        $deleted = ($deleted !== 'all') ? 'AND sc.deleted = '.$deleted : '';
3716 3716
 
3717 3717
         if ($where != '') {
3718
-            $where = 'AND ' . $where;
3718
+            $where = 'AND '.$where;
3719 3719
         }
3720 3720
 
3721 3721
         // modify field names to use sc. table reference
3722
-        $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3723
-        $sort = ($sort == '') ? '' : 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3722
+        $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3723
+        $sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3724 3724
 
3725 3725
         // get document groups for current user
3726 3726
         if ($docgrp = $this->getUserDocGroups()) {
@@ -3728,7 +3728,7 @@  discard block
 block discarded – undo
3728 3728
         }
3729 3729
 
3730 3730
         // build query
3731
-        $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="' . $_SESSION['mgrRole'] . '" OR sc.privatemgr=0') . (!$docgrp ? '' : ' OR dg.document_group IN (' . $docgrp . ')');
3731
+        $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')');
3732 3732
 
3733 3733
         $tblsc = $this->getFullTableName('site_content');
3734 3734
         $tbldg = $this->getFullTableName('document_groups');
@@ -3780,10 +3780,10 @@  discard block
 block discarded – undo
3780 3780
             return false;
3781 3781
         } else {
3782 3782
             // modify field names to use sc. table reference
3783
-            $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3784
-            $sort = ($sort == '') ? '' : 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3783
+            $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3784
+            $sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3785 3785
             if ($where != '') {
3786
-                $where = 'AND ' . $where;
3786
+                $where = 'AND '.$where;
3787 3787
             }
3788 3788
 
3789 3789
             $published = ($published !== 'all') ? "AND sc.published = '{$published}'" : '';
@@ -3794,13 +3794,13 @@  discard block
 block discarded – undo
3794 3794
                 $docgrp = implode(',', $docgrp);
3795 3795
             }
3796 3796
 
3797
-            $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="' . $_SESSION['mgrRole'] . '" OR sc.privatemgr=0') . (!$docgrp ? '' : ' OR dg.document_group IN (' . $docgrp . ')');
3797
+            $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')');
3798 3798
 
3799 3799
             $tblsc = $this->getFullTableName('site_content');
3800 3800
             $tbldg = $this->getFullTableName('document_groups');
3801 3801
 
3802 3802
             $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc
3803
-                    LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (" . implode(',', $ids) . ") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit);
3803
+                    LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (".implode(',', $ids).") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit);
3804 3804
 
3805 3805
             $resourceArray = $this->db->makeArray($result);
3806 3806
 
@@ -3905,12 +3905,12 @@  discard block
 block discarded – undo
3905 3905
             $tbldg = $this->getFullTableName("document_groups");
3906 3906
             $activeSql = $active == 1 ? "AND sc.published=1 AND sc.deleted=0" : "";
3907 3907
             // modify field names to use sc. table reference
3908
-            $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3908
+            $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3909 3909
             // get document groups for current user
3910 3910
             if ($docgrp = $this->getUserDocGroups()) {
3911 3911
                 $docgrp = implode(",", $docgrp);
3912 3912
             }
3913
-            $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3913
+            $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3914 3914
             $result = $this->db->select($fields, "{$tblsc} sc LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id='{$pageid}' {$activeSql}) AND ({$access})", "", 1);
3915 3915
             $pageInfo = $this->db->getRow($result);
3916 3916
 
@@ -3957,7 +3957,7 @@  discard block
 block discarded – undo
3957 3957
     {
3958 3958
         if ($this->currentSnippet) {
3959 3959
             $tbl = $this->getFullTableName("site_snippets");
3960
-            $rs = $this->db->select('id', $tbl, "name='" . $this->db->escape($this->currentSnippet) . "'", '', 1);
3960
+            $rs = $this->db->select('id', $tbl, "name='".$this->db->escape($this->currentSnippet)."'", '', 1);
3961 3961
             if ($snippetId = $this->db->getValue($rs)) {
3962 3962
                 return $snippetId;
3963 3963
             }
@@ -3984,23 +3984,23 @@  discard block
 block discarded – undo
3984 3984
      */
3985 3985
     public function clearCache($type = '', $report = false)
3986 3986
     {
3987
-        $cache_dir = MODX_BASE_PATH . $this->getCacheFolder();
3987
+        $cache_dir = MODX_BASE_PATH.$this->getCacheFolder();
3988 3988
         if (is_array($type)) {
3989 3989
             foreach ($type as $_) {
3990 3990
                 $this->clearCache($_, $report);
3991 3991
             }
3992 3992
         } elseif ($type == 'full') {
3993
-            include_once(MODX_MANAGER_PATH . 'processors/cache_sync.class.processor.php');
3993
+            include_once(MODX_MANAGER_PATH.'processors/cache_sync.class.processor.php');
3994 3994
             $sync = new synccache();
3995 3995
             $sync->setCachepath($cache_dir);
3996 3996
             $sync->setReport($report);
3997 3997
             $sync->emptyCache();
3998 3998
         } elseif (preg_match('@^[1-9][0-9]*$@', $type)) {
3999 3999
             $key = ($this->config['cache_type'] == 2) ? $this->makePageCacheKey($type) : $type;
4000
-            $file_name = "docid_" . $key . "_*.pageCache.php";
4001
-            $cache_path = $cache_dir . $file_name;
4000
+            $file_name = "docid_".$key."_*.pageCache.php";
4001
+            $cache_path = $cache_dir.$file_name;
4002 4002
             $files = glob($cache_path);
4003
-            $files[] = $cache_dir . "docid_" . $key . ".pageCache.php";
4003
+            $files[] = $cache_dir."docid_".$key.".pageCache.php";
4004 4004
             foreach ($files as $file) {
4005 4005
                 if (!is_file($file)) {
4006 4006
                     continue;
@@ -4008,7 +4008,7 @@  discard block
 block discarded – undo
4008 4008
                 unlink($file);
4009 4009
             }
4010 4010
         } else {
4011
-            $files = glob($cache_dir . '*');
4011
+            $files = glob($cache_dir.'*');
4012 4012
             foreach ($files as $file) {
4013 4013
                 $name = basename($file);
4014 4014
                 if (strpos($name, '.pageCache.php') === false) {
@@ -4077,7 +4077,7 @@  discard block
 block discarded – undo
4077 4077
                         $f_url_suffix = '/';
4078 4078
                     }
4079 4079
 
4080
-                    $alPath = !empty ($al['path']) ? $al['path'] . '/' : '';
4080
+                    $alPath = !empty ($al['path']) ? $al['path'].'/' : '';
4081 4081
 
4082 4082
                     if ($al && $al['alias']) {
4083 4083
                         $alias = $al['alias'];
@@ -4085,7 +4085,7 @@  discard block
 block discarded – undo
4085 4085
 
4086 4086
                 }
4087 4087
 
4088
-                $alias = $alPath . $f_url_prefix . $alias . $f_url_suffix;
4088
+                $alias = $alPath.$f_url_prefix.$alias.$f_url_suffix;
4089 4089
                 $url = "{$alias}{$args}";
4090 4090
             } else {
4091 4091
                 $url = "index.php?id={$id}{$args}";
@@ -4104,7 +4104,7 @@  discard block
 block discarded – undo
4104 4104
             }
4105 4105
 
4106 4106
             //TODO: check to make sure that $site_url incudes the url :port (e.g. :8080)
4107
-            $host = $scheme == 'full' ? $this->config['site_url'] : $scheme . '://' . $_SERVER['HTTP_HOST'] . $host;
4107
+            $host = $scheme == 'full' ? $this->config['site_url'] : $scheme.'://'.$_SERVER['HTTP_HOST'].$host;
4108 4108
         }
4109 4109
 
4110 4110
         //fix strictUrl by Bumkaka
@@ -4113,9 +4113,9 @@  discard block
 block discarded – undo
4113 4113
         }
4114 4114
 
4115 4115
         if ($this->config['xhtml_urls']) {
4116
-            $url = preg_replace("/&(?!amp;)/", "&amp;", $host . $virtualDir . $url);
4116
+            $url = preg_replace("/&(?!amp;)/", "&amp;", $host.$virtualDir.$url);
4117 4117
         } else {
4118
-            $url = $host . $virtualDir . $url;
4118
+            $url = $host.$virtualDir.$url;
4119 4119
         }
4120 4120
 
4121 4121
         $evtOut = $this->invokeEvent('OnMakeDocUrl', array(
@@ -4139,21 +4139,21 @@  discard block
 block discarded – undo
4139 4139
         if (isset($this->aliasListing[$id])) {
4140 4140
             $out = $this->aliasListing[$id];
4141 4141
         } else {
4142
-            $q = $this->db->query("SELECT id,alias,isfolder,parent FROM " . $this->getFullTableName("site_content") . " WHERE id=" . (int)$id);
4142
+            $q = $this->db->query("SELECT id,alias,isfolder,parent FROM ".$this->getFullTableName("site_content")." WHERE id=".(int) $id);
4143 4143
             if ($this->db->getRecordCount($q) == '1') {
4144 4144
                 $q = $this->db->getRow($q);
4145 4145
                 $this->aliasListing[$id] = array(
4146
-                    'id' => (int)$q['id'],
4146
+                    'id' => (int) $q['id'],
4147 4147
                     'alias' => $q['alias'] == '' ? $q['id'] : $q['alias'],
4148
-                    'parent' => (int)$q['parent'],
4149
-                    'isfolder' => (int)$q['isfolder'],
4148
+                    'parent' => (int) $q['parent'],
4149
+                    'isfolder' => (int) $q['isfolder'],
4150 4150
                 );
4151 4151
                 if ($this->aliasListing[$id]['parent'] > 0) {
4152 4152
                     //fix alias_path_usage
4153 4153
                     if ($this->config['use_alias_path'] == '1') {
4154 4154
                         //&& $tmp['path'] != '' - fix error slash with epty path
4155 4155
                         $tmp = $this->getAliasListing($this->aliasListing[$id]['parent']);
4156
-                        $this->aliasListing[$id]['path'] = $tmp['path'] . ($tmp['alias_visible'] ? (($tmp['parent'] > 0 && $tmp['path'] != '') ? '/' : '') . $tmp['alias'] : '');
4156
+                        $this->aliasListing[$id]['path'] = $tmp['path'].($tmp['alias_visible'] ? (($tmp['parent'] > 0 && $tmp['path'] != '') ? '/' : '').$tmp['alias'] : '');
4157 4157
                     } else {
4158 4158
                         $this->aliasListing[$id]['path'] = '';
4159 4159
                     }
@@ -4194,7 +4194,7 @@  discard block
 block discarded – undo
4194 4194
         $out = array();
4195 4195
         if (empty($this->version) || !is_array($this->version)) {
4196 4196
             //include for compatibility modx version < 1.0.10
4197
-            include MODX_MANAGER_PATH . "includes/version.inc.php";
4197
+            include MODX_MANAGER_PATH."includes/version.inc.php";
4198 4198
             $this->version = array();
4199 4199
             $this->version['version'] = isset($modx_version) ? $modx_version : '';
4200 4200
             $this->version['branch'] = isset($modx_branch) ? $modx_branch : '';
@@ -4216,18 +4216,18 @@  discard block
 block discarded – undo
4216 4216
     {
4217 4217
         if (isset ($this->snippetCache[$snippetName])) {
4218 4218
             $snippet = $this->snippetCache[$snippetName];
4219
-            $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : '';
4219
+            $properties = !empty($this->snippetCache[$snippetName."Props"]) ? $this->snippetCache[$snippetName."Props"] : '';
4220 4220
         } else { // not in cache so let's check the db
4221
-            $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->db->escape($snippetName) . "'  AND ss.disabled=0;";
4221
+            $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM ".$this->getFullTableName("site_snippets")." as ss LEFT JOIN ".$this->getFullTableName('site_modules')." as sm on sm.guid=ss.moduleguid WHERE ss.`name`='".$this->db->escape($snippetName)."'  AND ss.disabled=0;";
4222 4222
             $result = $this->db->query($sql);
4223 4223
             if ($this->db->getRecordCount($result) == 1) {
4224 4224
                 $row = $this->db->getRow($result);
4225 4225
                 $snippet = $this->snippetCache[$snippetName] = $row['snippet'];
4226 4226
                 $mergedProperties = array_merge($this->parseProperties($row['properties']), $this->parseProperties($row['sharedproperties']));
4227
-                $properties = $this->snippetCache[$snippetName . "Props"] = json_encode($mergedProperties);
4227
+                $properties = $this->snippetCache[$snippetName."Props"] = json_encode($mergedProperties);
4228 4228
             } else {
4229 4229
                 $snippet = $this->snippetCache[$snippetName] = "return false;";
4230
-                $properties = $this->snippetCache[$snippetName . "Props"] = '';
4230
+                $properties = $this->snippetCache[$snippetName."Props"] = '';
4231 4231
             }
4232 4232
         }
4233 4233
         // load default params/properties
@@ -4327,8 +4327,8 @@  discard block
 block discarded – undo
4327 4327
             }
4328 4328
             if (strpos($tpl, $s) !== false) {
4329 4329
                 $tpl = str_replace($s, $value, $tpl);
4330
-            } elseif($this->debug) {
4331
-                $this->addLog('parseText parse error', $_SERVER['REQUEST_URI'] . $s, 2);
4330
+            } elseif ($this->debug) {
4331
+                $this->addLog('parseText parse error', $_SERVER['REQUEST_URI'].$s, 2);
4332 4332
             }
4333 4333
         }
4334 4334
 
@@ -4377,7 +4377,7 @@  discard block
 block discarded – undo
4377 4377
             case 'CODE':
4378 4378
                 break;
4379 4379
             case 'FILE':
4380
-                $template = file_get_contents(MODX_BASE_PATH . $template);
4380
+                $template = file_get_contents(MODX_BASE_PATH.$template);
4381 4381
                 break;
4382 4382
             case 'CHUNK':
4383 4383
                 $template = $this->getChunk($template);
@@ -4410,7 +4410,7 @@  discard block
 block discarded – undo
4410 4410
         if ($mode !== 'formatOnly' && empty($timestamp)) {
4411 4411
             return '-';
4412 4412
         }
4413
-        $timestamp = (int)$timestamp;
4413
+        $timestamp = (int) $timestamp;
4414 4414
 
4415 4415
         switch ($this->config['datetime_format']) {
4416 4416
             case 'YYYY/mm/dd':
@@ -4430,7 +4430,7 @@  discard block
 block discarded – undo
4430 4430
         }
4431 4431
 
4432 4432
         if (empty($mode)) {
4433
-            $strTime = strftime($dateFormat . " %H:%M:%S", $timestamp);
4433
+            $strTime = strftime($dateFormat." %H:%M:%S", $timestamp);
4434 4434
         } elseif ($mode == 'dateOnly') {
4435 4435
             $strTime = strftime($dateFormat, $timestamp);
4436 4436
         } elseif ($mode == 'formatOnly') {
@@ -4484,7 +4484,7 @@  discard block
 block discarded – undo
4484 4484
             $S = 0;
4485 4485
         }
4486 4486
         $timeStamp = mktime($H, $M, $S, $m, $d, $Y);
4487
-        $timeStamp = (int)$timeStamp;
4487
+        $timeStamp = (int) $timeStamp;
4488 4488
         return $timeStamp;
4489 4489
     }
4490 4490
 
@@ -4526,7 +4526,7 @@  discard block
 block discarded – undo
4526 4526
                     if ($v === 'value') {
4527 4527
                         unset($_[$i]);
4528 4528
                     } else {
4529
-                        $_[$i] = 'tv.' . $v;
4529
+                        $_[$i] = 'tv.'.$v;
4530 4530
                     }
4531 4531
                 }
4532 4532
                 $fields = implode(',', $_);
@@ -4535,12 +4535,12 @@  discard block
 block discarded – undo
4535 4535
             }
4536 4536
 
4537 4537
             if ($tvsort != '') {
4538
-                $tvsort = 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $tvsort))));
4538
+                $tvsort = 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $tvsort))));
4539 4539
             }
4540 4540
             if ($tvidnames == "*") {
4541 4541
                 $query = "tv.id<>0";
4542 4542
             } else {
4543
-                $query = (is_numeric($tvidnames[0]) ? "tv.id" : "tv.name") . " IN ('" . implode("','", $tvidnames) . "')";
4543
+                $query = (is_numeric($tvidnames[0]) ? "tv.id" : "tv.name")." IN ('".implode("','", $tvidnames)."')";
4544 4544
             }
4545 4545
 
4546 4546
             $this->getUserDocGroups();
@@ -4684,7 +4684,7 @@  discard block
 block discarded – undo
4684 4684
             return $this->tmpCache[__FUNCTION__][$cacheKey];
4685 4685
         }
4686 4686
 
4687
-        if (($idnames != '*' && !is_array($idnames)) || empty($idnames) ) {
4687
+        if (($idnames != '*' && !is_array($idnames)) || empty($idnames)) {
4688 4688
             return false;
4689 4689
         } else {
4690 4690
 
@@ -4702,23 +4702,23 @@  discard block
 block discarded – undo
4702 4702
             }
4703 4703
 
4704 4704
             // get user defined template variables
4705
-            $fields = ($fields == '') ? 'tv.*' : 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $fields))));
4706
-            $sort = ($sort == '') ? '' : 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $sort))));
4705
+            $fields = ($fields == '') ? 'tv.*' : 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $fields))));
4706
+            $sort = ($sort == '') ? '' : 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $sort))));
4707 4707
 
4708 4708
             if ($idnames == '*') {
4709 4709
                 $query = 'tv.id<>0';
4710 4710
             } else {
4711
-                $query = (is_numeric($idnames[0]) ? 'tv.id' : 'tv.name') . " IN ('" . implode("','", $idnames) . "')";
4711
+                $query = (is_numeric($idnames[0]) ? 'tv.id' : 'tv.name')." IN ('".implode("','", $idnames)."')";
4712 4712
             }
4713 4713
 
4714
-            $rs = $this->db->select("{$fields}, IF(tvc.value != '', tvc.value, tv.default_text) as value", $this->getFullTableName('site_tmplvars') . " tv
4715
-                    INNER JOIN " . $this->getFullTableName('site_tmplvar_templates') . " tvtpl ON tvtpl.tmplvarid = tv.id
4716
-                    LEFT JOIN " . $this->getFullTableName('site_tmplvar_contentvalues') . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$docid}'", "{$query} AND tvtpl.templateid = '{$docRow['template']}'", ($sort ? "{$sort} {$dir}" : ""));
4714
+            $rs = $this->db->select("{$fields}, IF(tvc.value != '', tvc.value, tv.default_text) as value", $this->getFullTableName('site_tmplvars')." tv
4715
+                    INNER JOIN " . $this->getFullTableName('site_tmplvar_templates')." tvtpl ON tvtpl.tmplvarid = tv.id
4716
+                    LEFT JOIN " . $this->getFullTableName('site_tmplvar_contentvalues')." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$docid}'", "{$query} AND tvtpl.templateid = '{$docRow['template']}'", ($sort ? "{$sort} {$dir}" : ""));
4717 4717
 
4718 4718
             $result = $this->db->makeArray($rs);
4719 4719
 
4720 4720
             // get default/built-in template variables
4721
-            if(is_array($docRow)){
4721
+            if (is_array($docRow)) {
4722 4722
                 ksort($docRow);
4723 4723
 
4724 4724
                 foreach ($docRow as $key => $value) {
@@ -4756,22 +4756,22 @@  discard block
 block discarded – undo
4756 4756
      */
4757 4757
     public function getTemplateVarOutput($idnames = array(), $docid = '', $published = 1, $sep = '')
4758 4758
     {
4759
-        if (is_array($idnames) && empty($idnames) ) {
4759
+        if (is_array($idnames) && empty($idnames)) {
4760 4760
             return false;
4761 4761
         } else {
4762 4762
             $output = array();
4763 4763
             $vars = ($idnames == '*' || is_array($idnames)) ? $idnames : array($idnames);
4764 4764
 
4765
-            $docid = (int)$docid > 0 ? (int)$docid : $this->documentIdentifier;
4765
+            $docid = (int) $docid > 0 ? (int) $docid : $this->documentIdentifier;
4766 4766
             // remove sort for speed
4767 4767
             $result = $this->getTemplateVars($vars, '*', $docid, $published, '', '');
4768 4768
 
4769 4769
             if ($result == false) {
4770 4770
                 return false;
4771 4771
             } else {
4772
-                $baspath = MODX_MANAGER_PATH . 'includes';
4773
-                include_once $baspath . '/tmplvars.format.inc.php';
4774
-                include_once $baspath . '/tmplvars.commands.inc.php';
4772
+                $baspath = MODX_MANAGER_PATH.'includes';
4773
+                include_once $baspath.'/tmplvars.format.inc.php';
4774
+                include_once $baspath.'/tmplvars.commands.inc.php';
4775 4775
 
4776 4776
                 for ($i = 0; $i < count($result); $i++) {
4777 4777
                     $row = $result[$i];
@@ -4796,7 +4796,7 @@  discard block
 block discarded – undo
4796 4796
      */
4797 4797
     public function getFullTableName($tbl)
4798 4798
     {
4799
-        return $this->db->config['dbase'] . ".`" . $this->db->config['table_prefix'] . $tbl . "`";
4799
+        return $this->db->config['dbase'].".`".$this->db->config['table_prefix'].$tbl."`";
4800 4800
     }
4801 4801
 
4802 4802
     /**
@@ -4875,7 +4875,7 @@  discard block
 block discarded – undo
4875 4875
     public function getCachePath()
4876 4876
     {
4877 4877
         global $base_url;
4878
-        $pth = $base_url . $this->getCacheFolder();
4878
+        $pth = $base_url.$this->getCacheFolder();
4879 4879
         return $pth;
4880 4880
     }
4881 4881
 
@@ -4927,8 +4927,8 @@  discard block
 block discarded – undo
4927 4927
         $out = false;
4928 4928
 
4929 4929
         if (!empty($context)) {
4930
-            if (is_scalar($context) && isset($_SESSION[$context . 'Validated'])) {
4931
-                $out = $_SESSION[$context . 'InternalKey'];
4930
+            if (is_scalar($context) && isset($_SESSION[$context.'Validated'])) {
4931
+                $out = $_SESSION[$context.'InternalKey'];
4932 4932
             }
4933 4933
         } else {
4934 4934
             switch (true) {
@@ -4956,8 +4956,8 @@  discard block
 block discarded – undo
4956 4956
         $out = false;
4957 4957
 
4958 4958
         if (!empty($context)) {
4959
-            if (is_scalar($context) && isset($_SESSION[$context . 'Validated'])) {
4960
-                $out = $_SESSION[$context . 'Shortname'];
4959
+            if (is_scalar($context) && isset($_SESSION[$context.'Validated'])) {
4960
+                $out = $_SESSION[$context.'Shortname'];
4961 4961
             }
4962 4962
         } else {
4963 4963
             switch (true) {
@@ -5028,8 +5028,8 @@  discard block
 block discarded – undo
5028 5028
      */
5029 5029
     public function getWebUserInfo($uid)
5030 5030
     {
5031
-        $rs = $this->db->select('wu.username, wu.password, wua.*', $this->getFullTableName("web_users") . " wu
5032
-                INNER JOIN " . $this->getFullTableName("web_user_attributes") . " wua ON wua.internalkey=wu.id", "wu.id='{$uid}'");
5031
+        $rs = $this->db->select('wu.username, wu.password, wua.*', $this->getFullTableName("web_users")." wu
5032
+                INNER JOIN " . $this->getFullTableName("web_user_attributes")." wua ON wua.internalkey=wu.id", "wu.id='{$uid}'");
5033 5033
         if ($row = $this->db->getRow($rs)) {
5034 5034
             if (!isset($row['usertype']) or !$row["usertype"]) {
5035 5035
                 $row["usertype"] = "web";
@@ -5065,7 +5065,7 @@  discard block
 block discarded – undo
5065 5065
         } else if (is_array($dg)) {
5066 5066
             // resolve ids to names
5067 5067
             $dgn = array();
5068
-            $ds = $this->db->select('name', $this->getFullTableName("documentgroup_names"), "id IN (" . implode(",", $dg) . ")");
5068
+            $ds = $this->db->select('name', $this->getFullTableName("documentgroup_names"), "id IN (".implode(",", $dg).")");
5069 5069
             while ($row = $this->db->getRow($ds)) {
5070 5070
                 $dgn[] = $row['name'];
5071 5071
             }
@@ -5093,7 +5093,7 @@  discard block
 block discarded – undo
5093 5093
         $rt = false;
5094 5094
         if ($_SESSION["webValidated"] == 1) {
5095 5095
             $tbl = $this->getFullTableName("web_users");
5096
-            $ds = $this->db->select('id, username, password', $tbl, "id='" . $this->getLoginUserID() . "'");
5096
+            $ds = $this->db->select('id, username, password', $tbl, "id='".$this->getLoginUserID()."'");
5097 5097
             if ($row = $this->db->getRow($ds)) {
5098 5098
                 if ($row["password"] == md5($oldPwd)) {
5099 5099
                     if (strlen($newPwd) < 6) {
@@ -5103,7 +5103,7 @@  discard block
 block discarded – undo
5103 5103
                     } else {
5104 5104
                         $this->db->update(array(
5105 5105
                             'password' => $this->db->escape($newPwd),
5106
-                        ), $tbl, "id='" . $this->getLoginUserID() . "'");
5106
+                        ), $tbl, "id='".$this->getLoginUserID()."'");
5107 5107
                         // invoke OnWebChangePassword event
5108 5108
                         $this->invokeEvent("OnWebChangePassword", array(
5109 5109
                             "userid" => $row["id"],
@@ -5134,8 +5134,8 @@  discard block
 block discarded – undo
5134 5134
         // check cache
5135 5135
         $grpNames = isset ($_SESSION['webUserGroupNames']) ? $_SESSION['webUserGroupNames'] : false;
5136 5136
         if (!is_array($grpNames)) {
5137
-            $rs = $this->db->select('wgn.name', $this->getFullTableName("webgroup_names") . " wgn
5138
-                    INNER JOIN " . $this->getFullTableName("web_groups") . " wg ON wg.webgroup=wgn.id AND wg.webuser='" . $this->getLoginUserID() . "'");
5137
+            $rs = $this->db->select('wgn.name', $this->getFullTableName("webgroup_names")." wgn
5138
+                    INNER JOIN " . $this->getFullTableName("web_groups")." wg ON wg.webgroup=wgn.id AND wg.webuser='".$this->getLoginUserID()."'");
5139 5139
             $grpNames = $this->db->getColumn("name", $rs);
5140 5140
             // save to cache
5141 5141
             $_SESSION['webUserGroupNames'] = $grpNames;
@@ -5168,7 +5168,7 @@  discard block
 block discarded – undo
5168 5168
         if (strpos(strtolower($src), "<style") !== false || strpos(strtolower($src), "<link") !== false) {
5169 5169
             $this->sjscripts[$nextpos] = $src;
5170 5170
         } else {
5171
-            $this->sjscripts[$nextpos] = "\t" . '<link rel="stylesheet" type="text/css" href="' . $src . '" ' . ($media ? 'media="' . $media . '" ' : '') . '/>';
5171
+            $this->sjscripts[$nextpos] = "\t".'<link rel="stylesheet" type="text/css" href="'.$src.'" '.($media ? 'media="'.$media.'" ' : '').'/>';
5172 5172
         }
5173 5173
     }
5174 5174
 
@@ -5247,7 +5247,7 @@  discard block
 block discarded – undo
5247 5247
         }
5248 5248
 
5249 5249
         if ($useThisVer && $plaintext != true && (strpos(strtolower($src), "<script") === false)) {
5250
-            $src = "\t" . '<script type="text/javascript" src="' . $src . '"></script>';
5250
+            $src = "\t".'<script type="text/javascript" src="'.$src.'"></script>';
5251 5251
         }
5252 5252
         if ($startup) {
5253 5253
             $pos = isset($overwritepos) ? $overwritepos : max(array_merge(array(0), array_keys($this->sjscripts))) + 1;
@@ -5393,7 +5393,7 @@  discard block
 block discarded – undo
5393 5393
                 $eventtime = $this->getMicroTime() - $eventtime;
5394 5394
                 $this->pluginsCode .= sprintf('<fieldset><legend><b>%s / %s</b> (%2.2f ms)</legend>', $evtName, $pluginName, $eventtime * 1000);
5395 5395
                 foreach ($parameter as $k => $v) {
5396
-                    $this->pluginsCode .= "{$k} => " . print_r($v, true) . '<br>';
5396
+                    $this->pluginsCode .= "{$k} => ".print_r($v, true).'<br>';
5397 5397
                 }
5398 5398
                 $this->pluginsCode .= '</fieldset><br />';
5399 5399
                 $this->pluginsTime["{$evtName} / {$pluginName}"] += $eventtime;
@@ -5421,13 +5421,13 @@  discard block
 block discarded – undo
5421 5421
         $plugin = array();
5422 5422
         if (isset ($this->pluginCache[$pluginName])) {
5423 5423
             $pluginCode = $this->pluginCache[$pluginName];
5424
-            $pluginProperties = isset($this->pluginCache[$pluginName . "Props"]) ? $this->pluginCache[$pluginName . "Props"] : '';
5424
+            $pluginProperties = isset($this->pluginCache[$pluginName."Props"]) ? $this->pluginCache[$pluginName."Props"] : '';
5425 5425
         } else {
5426 5426
             $pluginName = $this->db->escape($pluginName);
5427 5427
             $result = $this->db->select('name, plugincode, properties', $this->getFullTableName("site_plugins"), "name='{$pluginName}' AND disabled=0");
5428 5428
             if ($row = $this->db->getRow($result)) {
5429 5429
                 $pluginCode = $this->pluginCache[$row['name']] = $row['plugincode'];
5430
-                $pluginProperties = $this->pluginCache[$row['name'] . "Props"] = $row['properties'];
5430
+                $pluginProperties = $this->pluginCache[$row['name']."Props"] = $row['properties'];
5431 5431
             } else {
5432 5432
                 $pluginCode = $this->pluginCache[$pluginName] = "return false;";
5433 5433
                 $pluginProperties = '';
@@ -5534,7 +5534,7 @@  discard block
 block discarded – undo
5534 5534
     public function parseDocBlockFromFile($element_dir, $filename, $escapeValues = false)
5535 5535
     {
5536 5536
         $params = array();
5537
-        $fullpath = $element_dir . '/' . $filename;
5537
+        $fullpath = $element_dir.'/'.$filename;
5538 5538
         if (is_readable($fullpath)) {
5539 5539
             $tpl = @fopen($fullpath, "r");
5540 5540
             if ($tpl) {
@@ -5701,8 +5701,8 @@  discard block
 block discarded – undo
5701 5701
         $ph = array('site_url' => MODX_SITE_URL);
5702 5702
         $regexUrl = "/((http|https|ftp|ftps)\:\/\/[^\/]+(\/[^\s]+[^,.?!:;\s])?)/";
5703 5703
         $regexEmail = '#([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)#i';
5704
-        $emailSubject = isset($parsed['name']) ? '?subject=' . $parsed['name'] : '';
5705
-        $emailSubject .= isset($parsed['version']) ? ' v' . $parsed['version'] : '';
5704
+        $emailSubject = isset($parsed['name']) ? '?subject='.$parsed['name'] : '';
5705
+        $emailSubject .= isset($parsed['version']) ? ' v'.$parsed['version'] : '';
5706 5706
         foreach ($parsed as $key => $val) {
5707 5707
             if (is_array($val)) {
5708 5708
                 foreach ($val as $key2 => $val2) {
@@ -5711,7 +5711,7 @@  discard block
 block discarded – undo
5711 5711
                         $val2 = preg_replace($regexUrl, "<a href=\"{$url[0]}\" target=\"_blank\">{$url[0]}</a> ", $val2);
5712 5712
                     }
5713 5713
                     if (preg_match($regexEmail, $val2, $url)) {
5714
-                        $val2 = preg_replace($regexEmail, '<a href="mailto:\\1' . $emailSubject . '">\\1</a>', $val2);
5714
+                        $val2 = preg_replace($regexEmail, '<a href="mailto:\\1'.$emailSubject.'">\\1</a>', $val2);
5715 5715
                     }
5716 5716
                     $parsed[$key][$key2] = $val2;
5717 5717
                 }
@@ -5721,7 +5721,7 @@  discard block
 block discarded – undo
5721 5721
                     $val = preg_replace($regexUrl, "<a href=\"{$url[0]}\" target=\"_blank\">{$url[0]}</a> ", $val);
5722 5722
                 }
5723 5723
                 if (preg_match($regexEmail, $val, $url)) {
5724
-                    $val = preg_replace($regexEmail, '<a href="mailto:\\1' . $emailSubject . '">\\1</a>', $val);
5724
+                    $val = preg_replace($regexEmail, '<a href="mailto:\\1'.$emailSubject.'">\\1</a>', $val);
5725 5725
                 }
5726 5726
                 $parsed[$key] = $val;
5727 5727
             }
@@ -5735,32 +5735,32 @@  discard block
 block discarded – undo
5735 5735
         );
5736 5736
 
5737 5737
         $nl = "\n";
5738
-        $list = isset($parsed['logo']) ? '<img src="' . $this->config['base_url'] . ltrim($parsed['logo'], "/") . '" style="float:right;max-width:100px;height:auto;" />' . $nl : '';
5739
-        $list .= '<p>' . $nl;
5740
-        $list .= isset($parsed['name']) ? '<strong>' . $parsed['name'] . '</strong><br/>' . $nl : '';
5741
-        $list .= isset($parsed['description']) ? $parsed['description'] . $nl : '';
5742
-        $list .= '</p><br/>' . $nl;
5743
-        $list .= isset($parsed['version']) ? '<p><strong>' . $_lang['version'] . ':</strong> ' . $parsed['version'] . '</p>' . $nl : '';
5744
-        $list .= isset($parsed['license']) ? '<p><strong>' . $_lang['license'] . ':</strong> ' . $parsed['license'] . '</p>' . $nl : '';
5745
-        $list .= isset($parsed['lastupdate']) ? '<p><strong>' . $_lang['last_update'] . ':</strong> ' . $parsed['lastupdate'] . '</p>' . $nl : '';
5746
-        $list .= '<br/>' . $nl;
5738
+        $list = isset($parsed['logo']) ? '<img src="'.$this->config['base_url'].ltrim($parsed['logo'], "/").'" style="float:right;max-width:100px;height:auto;" />'.$nl : '';
5739
+        $list .= '<p>'.$nl;
5740
+        $list .= isset($parsed['name']) ? '<strong>'.$parsed['name'].'</strong><br/>'.$nl : '';
5741
+        $list .= isset($parsed['description']) ? $parsed['description'].$nl : '';
5742
+        $list .= '</p><br/>'.$nl;
5743
+        $list .= isset($parsed['version']) ? '<p><strong>'.$_lang['version'].':</strong> '.$parsed['version'].'</p>'.$nl : '';
5744
+        $list .= isset($parsed['license']) ? '<p><strong>'.$_lang['license'].':</strong> '.$parsed['license'].'</p>'.$nl : '';
5745
+        $list .= isset($parsed['lastupdate']) ? '<p><strong>'.$_lang['last_update'].':</strong> '.$parsed['lastupdate'].'</p>'.$nl : '';
5746
+        $list .= '<br/>'.$nl;
5747 5747
         $first = true;
5748 5748
         foreach ($arrayParams as $param => $label) {
5749 5749
             if (isset($parsed[$param])) {
5750 5750
                 if ($first) {
5751
-                    $list .= '<p><strong>' . $_lang['references'] . '</strong></p>' . $nl;
5752
-                    $list .= '<ul class="docBlockList">' . $nl;
5751
+                    $list .= '<p><strong>'.$_lang['references'].'</strong></p>'.$nl;
5752
+                    $list .= '<ul class="docBlockList">'.$nl;
5753 5753
                     $first = false;
5754 5754
                 }
5755
-                $list .= '    <li><strong>' . $label . '</strong>' . $nl;
5756
-                $list .= '        <ul>' . $nl;
5755
+                $list .= '    <li><strong>'.$label.'</strong>'.$nl;
5756
+                $list .= '        <ul>'.$nl;
5757 5757
                 foreach ($parsed[$param] as $val) {
5758
-                    $list .= '            <li>' . $val . '</li>' . $nl;
5758
+                    $list .= '            <li>'.$val.'</li>'.$nl;
5759 5759
                 }
5760
-                $list .= '        </ul></li>' . $nl;
5760
+                $list .= '        </ul></li>'.$nl;
5761 5761
             }
5762 5762
         }
5763
-        $list .= !$first ? '</ul>' . $nl : '';
5763
+        $list .= !$first ? '</ul>'.$nl : '';
5764 5764
 
5765 5765
         return $list;
5766 5766
     }
@@ -5836,7 +5836,7 @@  discard block
 block discarded – undo
5836 5836
      */
5837 5837
     public function addSnippet($name, $phpCode)
5838 5838
     {
5839
-        $this->snippetCache['#' . $name] = $phpCode;
5839
+        $this->snippetCache['#'.$name] = $phpCode;
5840 5840
     }
5841 5841
 
5842 5842
     /**
@@ -5845,7 +5845,7 @@  discard block
 block discarded – undo
5845 5845
      */
5846 5846
     public function addChunk($name, $text)
5847 5847
     {
5848
-        $this->chunkCache['#' . $name] = $text;
5848
+        $this->chunkCache['#'.$name] = $text;
5849 5849
     }
5850 5850
 
5851 5851
     /**
@@ -5881,7 +5881,7 @@  discard block
 block discarded – undo
5881 5881
         }
5882 5882
 
5883 5883
         if (!$isSafe) {
5884
-            $msg = $phpcode . "\n" . $this->currentSnippet . "\n" . print_r($_SERVER, true);
5884
+            $msg = $phpcode."\n".$this->currentSnippet."\n".print_r($_SERVER, true);
5885 5885
             $title = sprintf('Unknown eval was executed (%s)', $this->htmlspecialchars(substr(trim($phpcode), 0, 50)));
5886 5886
             $this->messageQuit($title, '', true, '', '', 'Parser', $msg);
5887 5887
             return;
@@ -5895,7 +5895,7 @@  discard block
 block discarded – undo
5895 5895
             return 'array()';
5896 5896
         }
5897 5897
 
5898
-        $output = $echo . $return;
5898
+        $output = $echo.$return;
5899 5899
         modx_sanitize_gpc($output);
5900 5900
         return $this->htmlspecialchars($output); // Maybe, all html tags are dangerous
5901 5901
     }
@@ -5913,8 +5913,8 @@  discard block
 block discarded – undo
5913 5913
 
5914 5914
         $safe = explode(',', $safe_functions);
5915 5915
 
5916
-        $phpcode = rtrim($phpcode, ';') . ';';
5917
-        $tokens = token_get_all('<?php ' . $phpcode);
5916
+        $phpcode = rtrim($phpcode, ';').';';
5917
+        $tokens = token_get_all('<?php '.$phpcode);
5918 5918
         foreach ($tokens as $i => $token) {
5919 5919
             if (!is_array($token)) {
5920 5920
                 continue;
@@ -5950,7 +5950,7 @@  discard block
 block discarded – undo
5950 5950
     public function atBindFileContent($str = '')
5951 5951
     {
5952 5952
 
5953
-        $search_path = array('assets/tvs/', 'assets/chunks/', 'assets/templates/', $this->config['rb_base_url'] . 'files/', '');
5953
+        $search_path = array('assets/tvs/', 'assets/chunks/', 'assets/templates/', $this->config['rb_base_url'].'files/', '');
5954 5954
 
5955 5955
         if (stripos($str, '@FILE') !== 0) {
5956 5956
             return $str;
@@ -5973,7 +5973,7 @@  discard block
 block discarded – undo
5973 5973
         $errorMsg = sprintf("Could not retrieve string '%s'.", $str);
5974 5974
 
5975 5975
         foreach ($search_path as $path) {
5976
-            $file_path = MODX_BASE_PATH . $path . $str;
5976
+            $file_path = MODX_BASE_PATH.$path.$str;
5977 5977
             if (strpos($file_path, MODX_MANAGER_PATH) === 0) {
5978 5978
                 return $errorMsg;
5979 5979
             } elseif (is_file($file_path)) {
@@ -5987,7 +5987,7 @@  discard block
 block discarded – undo
5987 5987
             return $errorMsg;
5988 5988
         }
5989 5989
 
5990
-        $content = (string)file_get_contents($file_path);
5990
+        $content = (string) file_get_contents($file_path);
5991 5991
         if ($content === false) {
5992 5992
             return $errorMsg;
5993 5993
         }
@@ -6100,22 +6100,22 @@  discard block
 block discarded – undo
6100 6100
 
6101 6101
         $version = isset ($GLOBALS['modx_version']) ? $GLOBALS['modx_version'] : '';
6102 6102
         $release_date = isset ($GLOBALS['release_date']) ? $GLOBALS['release_date'] : '';
6103
-        $request_uri = "http://" . $_SERVER['HTTP_HOST'] . ($_SERVER["SERVER_PORT"] == 80 ? "" : (":" . $_SERVER["SERVER_PORT"])) . $_SERVER['REQUEST_URI'];
6103
+        $request_uri = "http://".$_SERVER['HTTP_HOST'].($_SERVER["SERVER_PORT"] == 80 ? "" : (":".$_SERVER["SERVER_PORT"])).$_SERVER['REQUEST_URI'];
6104 6104
         $request_uri = $this->htmlspecialchars($request_uri, ENT_QUOTES, $this->config['modx_charset']);
6105 6105
         $ua = $this->htmlspecialchars($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, $this->config['modx_charset']);
6106 6106
         $referer = $this->htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES, $this->config['modx_charset']);
6107 6107
         if ($is_error) {
6108 6108
             $str = '<h2 style="color:red">&laquo; Evo Parse Error &raquo;</h2>';
6109 6109
             if ($msg != 'PHP Parse Error') {
6110
-                $str .= '<h3 style="color:red">' . $msg . '</h3>';
6110
+                $str .= '<h3 style="color:red">'.$msg.'</h3>';
6111 6111
             }
6112 6112
         } else {
6113 6113
             $str = '<h2 style="color:#003399">&laquo; Evo Debug/ stop message &raquo;</h2>';
6114
-            $str .= '<h3 style="color:#003399">' . $msg . '</h3>';
6114
+            $str .= '<h3 style="color:#003399">'.$msg.'</h3>';
6115 6115
         }
6116 6116
 
6117 6117
         if (!empty ($query)) {
6118
-            $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">SQL &gt; <span id="sqlHolder">' . $query . '</span></div>';
6118
+            $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">SQL &gt; <span id="sqlHolder">'.$query.'</span></div>';
6119 6119
         }
6120 6120
 
6121 6121
         $errortype = array(
@@ -6138,13 +6138,13 @@  discard block
 block discarded – undo
6138 6138
 
6139 6139
         if (!empty($nr) || !empty($file)) {
6140 6140
             if ($text != '') {
6141
-                $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">Error : ' . $text . '</div>';
6141
+                $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">Error : '.$text.'</div>';
6142 6142
             }
6143 6143
             if ($output != '') {
6144
-                $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">' . $output . '</div>';
6144
+                $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">'.$output.'</div>';
6145 6145
             }
6146 6146
             if ($nr !== '') {
6147
-                $table[] = array('ErrorType[num]', $errortype [$nr] . "[" . $nr . "]");
6147
+                $table[] = array('ErrorType[num]', $errortype [$nr]."[".$nr."]");
6148 6148
             }
6149 6149
             if ($file) {
6150 6150
                 $table[] = array('File', $file);
@@ -6164,7 +6164,7 @@  discard block
 block discarded – undo
6164 6164
         }
6165 6165
 
6166 6166
         if (!empty($this->event->activePlugin)) {
6167
-            $table[] = array('Current Plugin', $this->event->activePlugin . '(' . $this->event->name . ')');
6167
+            $table[] = array('Current Plugin', $this->event->activePlugin.'('.$this->event->name.')');
6168 6168
         }
6169 6169
 
6170 6170
         $str .= $MakeTable->create($table, array('Error information', ''));
@@ -6174,17 +6174,17 @@  discard block
 block discarded – undo
6174 6174
         $table[] = array('REQUEST_URI', $request_uri);
6175 6175
 
6176 6176
         if ($this->manager->action) {
6177
-            include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
6177
+            include_once(MODX_MANAGER_PATH.'includes/actionlist.inc.php');
6178 6178
             global $action_list;
6179 6179
             $actionName = (isset($action_list[$this->manager->action])) ? " - {$action_list[$this->manager->action]}" : '';
6180 6180
 
6181
-            $table[] = array('Manager action', $this->manager->action . $actionName);
6181
+            $table[] = array('Manager action', $this->manager->action.$actionName);
6182 6182
         }
6183 6183
 
6184 6184
         if (preg_match('@^[0-9]+@', $this->documentIdentifier)) {
6185 6185
             $resource = $this->getDocumentObject('id', $this->documentIdentifier);
6186 6186
             $url = $this->makeUrl($this->documentIdentifier, '', '', 'full');
6187
-            $table[] = array('Resource', '[' . $this->documentIdentifier . '] <a href="' . $url . '" target="_blank">' . $resource['pagetitle'] . '</a>');
6187
+            $table[] = array('Resource', '['.$this->documentIdentifier.'] <a href="'.$url.'" target="_blank">'.$resource['pagetitle'].'</a>');
6188 6188
         }
6189 6189
         $table[] = array('Referer', $referer);
6190 6190
         $table[] = array('User Agent', $ua);
@@ -6205,7 +6205,7 @@  discard block
 block discarded – undo
6205 6205
 
6206 6206
         $mem = memory_get_peak_usage(true);
6207 6207
         $total_mem = $mem - $this->mstart;
6208
-        $total_mem = ($total_mem / 1024 / 1024) . ' mb';
6208
+        $total_mem = ($total_mem / 1024 / 1024).' mb';
6209 6209
 
6210 6210
         $queryTime = $this->queryTime;
6211 6211
         $phpTime = $totalTime - $queryTime;
@@ -6226,18 +6226,18 @@  discard block
 block discarded – undo
6226 6226
         $str .= $this->get_backtrace(debug_backtrace());
6227 6227
         // Log error
6228 6228
         if (!empty($this->currentSnippet)) {
6229
-            $source = 'Snippet - ' . $this->currentSnippet;
6229
+            $source = 'Snippet - '.$this->currentSnippet;
6230 6230
         } elseif (!empty($this->event->activePlugin)) {
6231
-            $source = 'Plugin - ' . $this->event->activePlugin;
6231
+            $source = 'Plugin - '.$this->event->activePlugin;
6232 6232
         } elseif ($source !== '') {
6233
-            $source = 'Parser - ' . $source;
6233
+            $source = 'Parser - '.$source;
6234 6234
         } elseif ($query !== '') {
6235 6235
             $source = 'SQL Query';
6236 6236
         } else {
6237 6237
             $source = 'Parser';
6238 6238
         }
6239 6239
         if ($msg) {
6240
-            $source .= ' / ' . $msg;
6240
+            $source .= ' / '.$msg;
6241 6241
         }
6242 6242
         if (isset($actionName) && !empty($actionName)) {
6243 6243
             $source .= $actionName;
@@ -6269,12 +6269,12 @@  discard block
 block discarded – undo
6269 6269
 
6270 6270
         // Display error
6271 6271
         if (isset($_SESSION['mgrValidated'])) {
6272
-            echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>EVO Content Manager ' . $version . ' &raquo; ' . $release_date . '</title>
6272
+            echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>EVO Content Manager '.$version.' &raquo; '.$release_date.'</title>
6273 6273
                  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6274
-                 <link rel="stylesheet" type="text/css" href="' . $this->config['site_manager_url'] . 'media/style/' . $this->config['manager_theme'] . '/style.css" />
6274
+                 <link rel="stylesheet" type="text/css" href="' . $this->config['site_manager_url'].'media/style/'.$this->config['manager_theme'].'/style.css" />
6275 6275
                  <style type="text/css">body { padding:10px; } td {font:inherit;}</style>
6276 6276
                  </head><body>
6277
-                 ' . $str . '</body></html>';
6277
+                 ' . $str.'</body></html>';
6278 6278
 
6279 6279
         } else {
6280 6280
             echo 'Error';
@@ -6312,7 +6312,7 @@  discard block
 block discarded – undo
6312 6312
             switch ($val['type']) {
6313 6313
                 case '->':
6314 6314
                 case '::':
6315
-                    $functionName = $val['function'] = $val['class'] . $val['type'] . $val['function'];
6315
+                    $functionName = $val['function'] = $val['class'].$val['type'].$val['function'];
6316 6316
                     break;
6317 6317
                 default:
6318 6318
                     $functionName = $val['function'];
@@ -6322,7 +6322,7 @@  discard block
 block discarded – undo
6322 6322
             $args = array_pad(array(), $_, '$var');
6323 6323
             $args = implode(", ", $args);
6324 6324
             $modx = &$this;
6325
-            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) {
6325
+            $args = preg_replace_callback('/\$var/', function() use ($modx, &$tmp, $val) {
6326 6326
                 $arg = $val['args'][$tmp - 1];
6327 6327
                 switch (true) {
6328 6328
                     case is_null($arg): {
@@ -6334,7 +6334,7 @@  discard block
 block discarded – undo
6334 6334
                         break;
6335 6335
                     }
6336 6336
                     case is_scalar($arg): {
6337
-                        $out = strlen($arg) > 20 ? 'string $var' . $tmp : ("'" . $this->htmlspecialchars(str_replace("'", "\\'", $arg)) . "'");
6337
+                        $out = strlen($arg) > 20 ? 'string $var'.$tmp : ("'".$this->htmlspecialchars(str_replace("'", "\\'", $arg))."'");
6338 6338
                         break;
6339 6339
                     }
6340 6340
                     case is_bool($arg): {
@@ -6342,23 +6342,23 @@  discard block
 block discarded – undo
6342 6342
                         break;
6343 6343
                     }
6344 6344
                     case is_array($arg): {
6345
-                        $out = 'array $var' . $tmp;
6345
+                        $out = 'array $var'.$tmp;
6346 6346
                         break;
6347 6347
                     }
6348 6348
                     case is_object($arg): {
6349
-                        $out = get_class($arg) . ' $var' . $tmp;
6349
+                        $out = get_class($arg).' $var'.$tmp;
6350 6350
                         break;
6351 6351
                     }
6352 6352
                     default: {
6353
-                        $out = '$var' . $tmp;
6353
+                        $out = '$var'.$tmp;
6354 6354
                     }
6355 6355
                 }
6356 6356
                 $tmp++;
6357 6357
                 return $out;
6358 6358
             }, $args);
6359 6359
             $line = array(
6360
-                "<strong>" . $functionName . "</strong>(" . $args . ")",
6361
-                $path . " on line " . $val['line']
6360
+                "<strong>".$functionName."</strong>(".$args.")",
6361
+                $path." on line ".$val['line']
6362 6362
             );
6363 6363
             $table[] = array(implode("<br />", $line));
6364 6364
         }
@@ -6399,7 +6399,7 @@  discard block
 block discarded – undo
6399 6399
             $alias = strip_tags($alias); // strip HTML
6400 6400
             $alias = preg_replace('/[^\.A-Za-z0-9 _-]/', '', $alias); // strip non-alphanumeric characters
6401 6401
             $alias = preg_replace('/\s+/', '-', $alias); // convert white-space to dash
6402
-            $alias = preg_replace('/-+/', '-', $alias);  // convert multiple dashes to one
6402
+            $alias = preg_replace('/-+/', '-', $alias); // convert multiple dashes to one
6403 6403
             $alias = trim($alias, '-'); // trim excess
6404 6404
             return $alias;
6405 6405
         }
@@ -6415,7 +6415,7 @@  discard block
 block discarded – undo
6415 6415
         $precisions = count($sizes) - 1;
6416 6416
         foreach ($sizes as $unit => $bytes) {
6417 6417
             if ($size >= $bytes) {
6418
-                return number_format($size / $bytes, $precisions) . ' ' . $unit;
6418
+                return number_format($size / $bytes, $precisions).' '.$unit;
6419 6419
             }
6420 6420
             $precisions--;
6421 6421
         }
@@ -6519,10 +6519,10 @@  discard block
 block discarded – undo
6519 6519
 
6520 6520
         if (strpos($str, MODX_MANAGER_PATH) === 0) {
6521 6521
             return false;
6522
-        } elseif (is_file(MODX_BASE_PATH . $str)) {
6523
-            $file_path = MODX_BASE_PATH . $str;
6524
-        } elseif (is_file(MODX_BASE_PATH . "{$tpl_dir}{$str}")) {
6525
-            $file_path = MODX_BASE_PATH . $tpl_dir . $str;
6522
+        } elseif (is_file(MODX_BASE_PATH.$str)) {
6523
+            $file_path = MODX_BASE_PATH.$str;
6524
+        } elseif (is_file(MODX_BASE_PATH."{$tpl_dir}{$str}")) {
6525
+            $file_path = MODX_BASE_PATH.$tpl_dir.$str;
6526 6526
         } else {
6527 6527
             return false;
6528 6528
         }
@@ -6648,7 +6648,7 @@  discard block
 block discarded – undo
6648 6648
             $title = 'no title';
6649 6649
         }
6650 6650
         if (is_array($msg)) {
6651
-            $msg = '<pre>' . print_r($msg, true) . '</pre>';
6651
+            $msg = '<pre>'.print_r($msg, true).'</pre>';
6652 6652
         } elseif ($msg === '') {
6653 6653
             $msg = $_SERVER['REQUEST_URI'];
6654 6654
         }
@@ -6693,7 +6693,7 @@  discard block
 block discarded – undo
6693 6693
         if (is_array($SystemAlertMsgQueque)) {
6694 6694
             $title = '';
6695 6695
             if ($this->name && $this->activePlugin) {
6696
-                $title = "<div><b>" . $this->activePlugin . "</b> - <span style='color:maroon;'>" . $this->name . "</span></div>";
6696
+                $title = "<div><b>".$this->activePlugin."</b> - <span style='color:maroon;'>".$this->name."</span></div>";
6697 6697
             }
6698 6698
             $SystemAlertMsgQueque[] = "$title<div style='margin-left:10px;margin-top:3px;'>$msg</div>";
6699 6699
         }
Please login to merge, or discard this patch.
manager/media/rss/rss_parse.inc 1 patch
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 define('RSS', 'RSS');
24 24
 define('ATOM', 'Atom');
25 25
 
26
-require_once (MAGPIE_DIR . 'rss_utils.inc');
26
+require_once (MAGPIE_DIR.'rss_utils.inc');
27 27
 
28 28
 /**
29 29
 * Hybrid parser, and object, takes RSS as a string and returns a simple object.
@@ -31,19 +31,19 @@  discard block
 block discarded – undo
31 31
 * see: rss_fetch.inc for a simpler interface with integrated caching support
32 32
 *
33 33
 */
34
-class MagpieRSS {
34
+class MagpieRSS{
35 35
     var $parser;
36 36
 
37
-    var $current_item   = array();  // item currently being parsed
38
-    var $items          = array();  // collection of parsed items
39
-    var $channel        = array();  // hash of channel fields
37
+    var $current_item   = array(); // item currently being parsed
38
+    var $items          = array(); // collection of parsed items
39
+    var $channel        = array(); // hash of channel fields
40 40
     var $textinput      = array();
41 41
     var $image          = array();
42 42
     var $feed_type;
43 43
     var $feed_version;
44
-    var $encoding       = '';       // output encoding of parsed rss
44
+    var $encoding       = ''; // output encoding of parsed rss
45 45
 
46
-    var $_source_encoding = '';     // only set if we have to parse xml prolog
46
+    var $_source_encoding = ''; // only set if we have to parse xml prolog
47 47
 
48 48
     var $ERROR = "";
49 49
     var $WARNING = "";
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
      *                                  source encoding. (caveat emptor)
92 92
      *
93 93
      */
94
-    function __construct($source, $output_encoding='ISO-8859-1',
95
-                        $input_encoding=null, $detect_encoding=true)
94
+    function __construct($source, $output_encoding = 'ISO-8859-1',
95
+                        $input_encoding = null, $detect_encoding = true)
96 96
     {
97 97
         # if PHP xml isn't compiled in, die
98 98
         #
99 99
         if (!function_exists('xml_parser_create')) {
100
-            $this->error( "Failed to load PHP's XML Extension. " .
100
+            $this->error("Failed to load PHP's XML Extension. ".
101 101
                           "http://www.php.net/manual/en/ref.xml.php",
102
-                           E_USER_ERROR );
102
+                           E_USER_ERROR);
103 103
         }
104 104
 
105 105
         list($parser, $source) = $this->create_parser($source,
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 
108 108
 
109 109
         if (!is_resource($parser)) {
110
-            $this->error( "Failed to create an instance of PHP's XML parser. " .
110
+            $this->error("Failed to create an instance of PHP's XML parser. ".
111 111
                           "http://www.php.net/manual/en/ref.xml.php",
112
-                          E_USER_ERROR );
112
+                          E_USER_ERROR);
113 113
         }
114 114
 
115 115
 
@@ -118,57 +118,57 @@  discard block
 block discarded – undo
118 118
         # pass in parser, and a reference to this object
119 119
         # setup handlers
120 120
         #
121
-        xml_set_object( $this->parser, $this );
121
+        xml_set_object($this->parser, $this);
122 122
         xml_set_element_handler($this->parser,
123
-                'feed_start_element', 'feed_end_element' );
123
+                'feed_start_element', 'feed_end_element');
124 124
 
125
-        xml_set_character_data_handler( $this->parser, 'feed_cdata' );
125
+        xml_set_character_data_handler($this->parser, 'feed_cdata');
126 126
 
127
-        $status = xml_parse( $this->parser, $source );
127
+        $status = xml_parse($this->parser, $source);
128 128
 
129
-        if (! $status ) {
130
-            $errorcode = xml_get_error_code( $this->parser );
131
-            if ( $errorcode != XML_ERROR_NONE ) {
132
-                $xml_error = xml_error_string( $errorcode );
129
+        if (!$status) {
130
+            $errorcode = xml_get_error_code($this->parser);
131
+            if ($errorcode != XML_ERROR_NONE) {
132
+                $xml_error = xml_error_string($errorcode);
133 133
                 $error_line = xml_get_current_line_number($this->parser);
134 134
                 $error_col = xml_get_current_column_number($this->parser);
135 135
                 $errormsg = "$xml_error at line $error_line, column $error_col";
136 136
 
137
-                $this->error( $errormsg );
137
+                $this->error($errormsg);
138 138
             }
139 139
         }
140 140
 
141
-        xml_parser_free( $this->parser );
141
+        xml_parser_free($this->parser);
142 142
 
143 143
         $this->normalize();
144 144
     }
145 145
 
146
-    function feed_start_element($p, $element, &$attrs) {
146
+    function feed_start_element($p, $element, &$attrs){
147 147
         $el = $element = strtolower($element);
148 148
         $attrs = array_change_key_case($attrs, CASE_LOWER);
149 149
 
150 150
         // check for a namespace, and split if found
151 151
         $ns = false;
152
-        if ( strpos( $element, ':' ) ) {
153
-            list($ns, $el) = explode( ':', $element, 2);
152
+        if (strpos($element, ':')) {
153
+            list($ns, $el) = explode(':', $element, 2);
154 154
         }
155
-        if ( $ns and $ns != 'rdf' ) {
155
+        if ($ns and $ns != 'rdf') {
156 156
             $this->current_namespace = $ns;
157 157
         }
158 158
 
159 159
         # if feed type isn't set, then this is first element of feed
160 160
         # identify feed from root element
161 161
         #
162
-        if (!isset($this->feed_type) ) {
163
-            if ( $el == 'rdf' ) {
162
+        if (!isset($this->feed_type)) {
163
+            if ($el == 'rdf') {
164 164
                 $this->feed_type = RSS;
165 165
                 $this->feed_version = '1.0';
166 166
             }
167
-            elseif ( $el == 'rss' ) {
167
+            elseif ($el == 'rss') {
168 168
                 $this->feed_type = RSS;
169 169
                 $this->feed_version = $attrs['version'];
170 170
             }
171
-            elseif ( $el == 'feed' ) {
171
+            elseif ($el == 'feed') {
172 172
                 $this->feed_type = ATOM;
173 173
                 $this->feed_version = $attrs['version'];
174 174
                 $this->inchannel = true;
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
             return;
177 177
         }
178 178
 
179
-        if ( $el == 'channel' )
179
+        if ($el == 'channel')
180 180
         {
181 181
             $this->inchannel = true;
182 182
         }
183
-        elseif ($el == 'item' or $el == 'entry' )
183
+        elseif ($el == 'item' or $el == 'entry')
184 184
         {
185 185
             $this->initem = true;
186
-            if ( isset($attrs['rdf:about']) ) {
186
+            if (isset($attrs['rdf:about'])) {
187 187
                 $this->current_item['about'] = $attrs['rdf:about'];
188 188
             }
189 189
         }
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
         }
208 208
 
209 209
         # handle atom content constructs
210
-        elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
210
+        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS))
211 211
         {
212 212
             // avoid clashing w/ RSS mod_content
213
-            if ($el == 'content' ) {
213
+            if ($el == 'content') {
214 214
                 $el = 'atom_content';
215 215
             }
216 216
 
@@ -220,31 +220,31 @@  discard block
 block discarded – undo
220 220
         }
221 221
 
222 222
         // if inside an Atom content construct (e.g. content or summary) field treat tags as text
223
-        elseif ($this->feed_type == ATOM and $this->incontent )
223
+        elseif ($this->feed_type == ATOM and $this->incontent)
224 224
         {
225 225
             // if tags are inlined, then flatten
226 226
             $attrs_str = implode(' ',
227 227
                     array_map('map_attrs',
228 228
                     array_keys($attrs),
229
-                    array_values($attrs) ) );
229
+                    array_values($attrs)));
230 230
 
231
-            $this->append_content( "<$element $attrs_str>"  );
231
+            $this->append_content("<$element $attrs_str>");
232 232
 
233
-            array_unshift( $this->stack, $el );
233
+            array_unshift($this->stack, $el);
234 234
         }
235 235
 
236 236
         // Atom support many links per containging element.
237 237
         // Magpie treats link elements of type rel='alternate'
238 238
         // as being equivalent to RSS's simple link element.
239 239
         //
240
-        elseif ($this->feed_type == ATOM and $el == 'link' )
240
+        elseif ($this->feed_type == ATOM and $el == 'link')
241 241
         {
242
-            if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
242
+            if (isset($attrs['rel']) and $attrs['rel'] == 'alternate')
243 243
             {
244 244
                 $link_el = 'link';
245 245
             }
246 246
             else {
247
-                $link_el = 'link_' . $attrs['rel'];
247
+                $link_el = 'link_'.$attrs['rel'];
248 248
             }
249 249
 
250 250
             $this->append($link_el, $attrs['href']);
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 
258 258
 
259 259
 
260
-    function feed_cdata ($p, $text) {
260
+    function feed_cdata($p, $text){
261 261
         if ($this->feed_type == ATOM and $this->incontent)
262 262
         {
263
-            $this->append_content( $text );
263
+            $this->append_content($text);
264 264
         }
265 265
         else {
266 266
             $current_el = implode('_', array_reverse($this->stack));
@@ -268,35 +268,35 @@  discard block
 block discarded – undo
268 268
         }
269 269
     }
270 270
 
271
-    function feed_end_element ($p, $el) {
271
+    function feed_end_element($p, $el){
272 272
         $el = strtolower($el);
273 273
 
274
-        if ( $el == 'item' or $el == 'entry' )
274
+        if ($el == 'item' or $el == 'entry')
275 275
         {
276 276
             $this->items[] = $this->current_item;
277 277
             $this->current_item = array();
278 278
             $this->initem = false;
279 279
         }
280
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
280
+        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput')
281 281
         {
282 282
             $this->intextinput = false;
283 283
         }
284
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
284
+        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image')
285 285
         {
286 286
             $this->inimage = false;
287 287
         }
288
-        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
288
+        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS))
289 289
         {
290 290
             $this->incontent = false;
291 291
         }
292
-        elseif ($el == 'channel' or $el == 'feed' )
292
+        elseif ($el == 'channel' or $el == 'feed')
293 293
         {
294 294
             $this->inchannel = false;
295 295
         }
296
-        elseif ($this->feed_type == ATOM and $this->incontent  ) {
296
+        elseif ($this->feed_type == ATOM and $this->incontent) {
297 297
             // balance tags properly
298 298
             // note:  i don't think this is actually neccessary
299
-            if ( $this->stack[0] == $el )
299
+            if ($this->stack[0] == $el)
300 300
             {
301 301
                 $this->append_content("</$el>");
302 302
             }
@@ -304,91 +304,91 @@  discard block
 block discarded – undo
304 304
                 $this->append_content("<$el />");
305 305
             }
306 306
 
307
-            array_shift( $this->stack );
307
+            array_shift($this->stack);
308 308
         }
309 309
         else {
310
-            array_shift( $this->stack );
310
+            array_shift($this->stack);
311 311
         }
312 312
 
313 313
         $this->current_namespace = false;
314 314
     }
315 315
 
316
-    function concat (&$str1, $str2="") {
317
-        if (!isset($str1) ) {
318
-            $str1="";
316
+    function concat(&$str1, $str2 = ""){
317
+        if (!isset($str1)) {
318
+            $str1 = "";
319 319
         }
320 320
         $str1 .= $str2;
321 321
     }
322 322
 
323 323
 
324 324
 
325
-    function append_content($text) {
326
-        if ( $this->initem ) {
327
-            $this->concat( $this->current_item[ $this->incontent ], $text );
325
+    function append_content($text){
326
+        if ($this->initem) {
327
+            $this->concat($this->current_item[$this->incontent], $text);
328 328
         }
329
-        elseif ( $this->inchannel ) {
330
-            $this->concat( $this->channel[ $this->incontent ], $text );
329
+        elseif ($this->inchannel) {
330
+            $this->concat($this->channel[$this->incontent], $text);
331 331
         }
332 332
     }
333 333
 
334 334
     // smart append - field and namespace aware
335
-    function append($el, $text) {
335
+    function append($el, $text){
336 336
         if (!$el) {
337 337
             return;
338 338
         }
339
-        if ( $this->current_namespace )
339
+        if ($this->current_namespace)
340 340
         {
341
-            if ( $this->initem ) {
341
+            if ($this->initem) {
342 342
                 $this->concat(
343
-                    $this->current_item[ $this->current_namespace ][ $el ], $text);
343
+                    $this->current_item[$this->current_namespace][$el], $text);
344 344
             }
345 345
             elseif ($this->inchannel) {
346 346
                 $this->concat(
347
-                    $this->channel[ $this->current_namespace][ $el ], $text );
347
+                    $this->channel[$this->current_namespace][$el], $text );
348 348
             }
349 349
             elseif ($this->intextinput) {
350 350
                 $this->concat(
351
-                    $this->textinput[ $this->current_namespace][ $el ], $text );
351
+                    $this->textinput[$this->current_namespace][$el], $text );
352 352
             }
353 353
             elseif ($this->inimage) {
354 354
                 $this->concat(
355
-                    $this->image[ $this->current_namespace ][ $el ], $text );
355
+                    $this->image[$this->current_namespace][$el], $text );
356 356
             }
357 357
         }
358 358
         else {
359
-            if ( $this->initem ) {
359
+            if ($this->initem) {
360 360
                 $this->concat(
361
-                    $this->current_item[ $el ], $text);
361
+                    $this->current_item[$el], $text);
362 362
             }
363 363
             elseif ($this->intextinput) {
364 364
                 $this->concat(
365
-                    $this->textinput[ $el ], $text );
365
+                    $this->textinput[$el], $text );
366 366
             }
367 367
             elseif ($this->inimage) {
368 368
                 $this->concat(
369
-                    $this->image[ $el ], $text );
369
+                    $this->image[$el], $text );
370 370
             }
371 371
             elseif ($this->inchannel) {
372 372
                 $this->concat(
373
-                    $this->channel[ $el ], $text );
373
+                    $this->channel[$el], $text );
374 374
             }
375 375
 
376 376
         }
377 377
     }
378 378
 
379
-    function normalize () {
379
+    function normalize(){
380 380
         // if atom populate rss fields
381
-        if ( $this->is_atom() ) {
381
+        if ($this->is_atom()) {
382 382
             $this->channel['description'] = $this->channel['tagline'];
383
-            for ( $i = 0; $i < count($this->items); $i++) {
383
+            for ($i = 0; $i < count($this->items); $i++) {
384 384
                 $item = $this->items[$i];
385
-                if ( isset($item['summary']) )
385
+                if (isset($item['summary']))
386 386
                     $item['description'] = $item['summary'];
387
-                if ( isset($item['atom_content']))
387
+                if (isset($item['atom_content']))
388 388
                     $item['content']['encoded'] = $item['atom_content'];
389 389
 
390
-                $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified'];
391
-                if ( $atom_date ) {
390
+                $atom_date = (isset($item['issued'])) ? $item['issued'] : $item['modified'];
391
+                if ($atom_date) {
392 392
                     $epoch = @parse_w3cdtf($atom_date);
393 393
                     if ($epoch and $epoch > 0) {
394 394
                         $item['date_timestamp'] = $epoch;
@@ -398,22 +398,22 @@  discard block
 block discarded – undo
398 398
                 $this->items[$i] = $item;
399 399
             }
400 400
         }
401
-        elseif ( $this->is_rss() ) {
401
+        elseif ($this->is_rss()) {
402 402
             $this->channel['tagline'] = $this->channel['description'];
403
-            for ( $i = 0; $i < count($this->items); $i++) {
403
+            for ($i = 0; $i < count($this->items); $i++) {
404 404
                 $item = $this->items[$i];
405
-                if ( isset($item['description']))
405
+                if (isset($item['description']))
406 406
                     $item['summary'] = $item['description'];
407
-                if ( isset($item['content']['encoded'] ) )
407
+                if (isset($item['content']['encoded']))
408 408
                     $item['atom_content'] = $item['content']['encoded'];
409 409
 
410
-                if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) {
410
+                if ($this->is_rss() == '1.0' and isset($item['dc']['date'])) {
411 411
                     $epoch = @parse_w3cdtf($item['dc']['date']);
412 412
                     if ($epoch and $epoch > 0) {
413 413
                         $item['date_timestamp'] = $epoch;
414 414
                     }
415 415
                 }
416
-                elseif ( isset($item['pubdate']) ) {
416
+                elseif (isset($item['pubdate'])) {
417 417
                     $epoch = @strtotime($item['pubdate']);
418 418
                     if ($epoch > 0) {
419 419
                         $item['date_timestamp'] = $epoch;
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
     }
427 427
 
428 428
 
429
-    function is_rss () {
430
-        if ( $this->feed_type == RSS ) {
429
+    function is_rss(){
430
+        if ($this->feed_type == RSS) {
431 431
             return $this->feed_version;
432 432
         }
433 433
         else {
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
         }
436 436
     }
437 437
 
438
-    function is_atom() {
439
-        if ( $this->feed_type == ATOM ) {
438
+    function is_atom(){
439
+        if ($this->feed_type == ATOM) {
440 440
             return $this->feed_version;
441 441
         }
442 442
         else {
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
     * return XML parser, and possibly re-encoded source
449 449
     *
450 450
     */
451
-    function create_parser($source, $out_enc, $in_enc, $detect) {
452
-        if ( substr(phpversion(),0,1) == 5) {
451
+    function create_parser($source, $out_enc, $in_enc, $detect){
452
+        if (substr(phpversion(), 0, 1) == 5) {
453 453
             $parser = $this->php5_create_parser($in_enc, $detect);
454 454
         }
455 455
         else {
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
     * All hail libxml2!
473 473
     *
474 474
     */
475
-    function php5_create_parser($in_enc, $detect) {
475
+    function php5_create_parser($in_enc, $detect){
476 476
         // by default php5 does a fine job of detecting input encodings
477
-        if(!$detect && $in_enc) {
477
+        if (!$detect && $in_enc) {
478 478
             return xml_parser_create($in_enc);
479 479
         }
480 480
         else {
@@ -497,8 +497,8 @@  discard block
 block discarded – undo
497 497
     * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
498 498
     *
499 499
     */
500
-    function php4_create_parser($source, $in_enc, $detect) {
501
-        if ( !$detect ) {
500
+    function php4_create_parser($source, $in_enc, $detect){
501
+        if (!$detect) {
502 502
             return array(xml_parser_create($in_enc), $source);
503 503
         }
504 504
 
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
         // cast the XML to a known encoding
523 523
         // @see http://php.net/iconv
524 524
 
525
-        if (function_exists('iconv'))  {
526
-            $encoded_source = iconv($in_enc,'UTF-8', $source);
525
+        if (function_exists('iconv')) {
526
+            $encoded_source = iconv($in_enc, 'UTF-8', $source);
527 527
             if ($encoded_source) {
528 528
                 return array(xml_parser_create('UTF-8'), $encoded_source);
529 529
             }
@@ -531,24 +531,24 @@  discard block
 block discarded – undo
531 531
 
532 532
         // iconv didn't work, try mb_convert_encoding
533 533
         // @see http://php.net/mbstring
534
-        if(function_exists('mb_convert_encoding')) {
535
-            $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc );
534
+        if (function_exists('mb_convert_encoding')) {
535
+            $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc);
536 536
             if ($encoded_source) {
537 537
                 return array(xml_parser_create('UTF-8'), $encoded_source);
538 538
             }
539 539
         }
540 540
 
541 541
         // else
542
-        $this->error("Feed is in an unsupported character encoding. ($in_enc) " .
542
+        $this->error("Feed is in an unsupported character encoding. ($in_enc) ".
543 543
                      "You may see strange artifacts, and mangled characters.",
544 544
                      E_USER_NOTICE);
545 545
 
546 546
         return array(xml_parser_create(), $source);
547 547
     }
548 548
 
549
-    function known_encoding($enc) {
549
+    function known_encoding($enc){
550 550
         $enc = strtoupper($enc);
551
-        if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) {
551
+        if (in_array($enc, $this->_KNOWN_ENCODINGS)) {
552 552
             return $enc;
553 553
         }
554 554
         else {
@@ -556,20 +556,20 @@  discard block
 block discarded – undo
556 556
         }
557 557
     }
558 558
 
559
-    function error ($errormsg, $lvl=E_USER_WARNING) {
559
+    function error($errormsg, $lvl = E_USER_WARNING){
560 560
         // append PHP's error message if track_errors enabled
561
-        if ( isset($php_errormsg) ) {
561
+        if (isset($php_errormsg)) {
562 562
             $errormsg .= " ($php_errormsg)";
563 563
         }
564
-        if ( MAGPIE_DEBUG ) {
565
-            trigger_error( $errormsg, $lvl);
564
+        if (MAGPIE_DEBUG) {
565
+            trigger_error($errormsg, $lvl);
566 566
         }
567 567
         else {
568
-            error_log( $errormsg, 0);
568
+            error_log($errormsg, 0);
569 569
         }
570 570
 
571
-        $notices = E_USER_NOTICE|E_NOTICE;
572
-        if ( $lvl&$notices ) {
571
+        $notices = E_USER_NOTICE | E_NOTICE;
572
+        if ($lvl & $notices) {
573 573
             $this->WARNING = $errormsg;
574 574
         } else {
575 575
             $this->ERROR = $errormsg;
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 
580 580
 } // end class RSS
581 581
 
582
-function map_attrs($k, $v) {
582
+function map_attrs($k, $v){
583 583
     return "$k=\"$v\"";
584 584
 }
585 585
 
@@ -591,19 +591,19 @@  discard block
 block discarded – undo
591 591
 	define('CASE_LOWER', 0);
592 592
 
593 593
 
594
-	function array_change_key_case($array, $case=CASE_LOWER) {
594
+	function array_change_key_case($array, $case = CASE_LOWER){
595 595
         $output = array();
596
-        switch($case){
596
+        switch ($case) {
597 597
            case CASE_LOWER:
598
-               $cmd='strtolower';
598
+               $cmd = 'strtolower';
599 599
                break;
600 600
            case CASE_UPPER:
601
-               $cmd='strtoupper';
601
+               $cmd = 'strtoupper';
602 602
                break;
603 603
            default:
604 604
                $cmd = '';
605 605
         }
606
-        foreach($array as $key=>$value) {
606
+        foreach ($array as $key=>$value) {
607 607
             $output[empty($cmd) ? $key : $cmd($key)] = $value;
608 608
         }
609 609
         return $output;
Please login to merge, or discard this patch.
manager/media/rss/rss_cache.inc 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -16,27 +16,27 @@  discard block
 block discarded – undo
16 16
  *
17 17
  */
18 18
 
19
-class RSSCache {
20
-    var $BASE_CACHE = './cache';    // where the cache files are stored
21
-    var $MAX_AGE    = 3600;         // when are files stale, default one hour
22
-    var $ERROR      = "";           // accumulate error messages
19
+class RSSCache{
20
+    var $BASE_CACHE = './cache'; // where the cache files are stored
21
+    var $MAX_AGE    = 3600; // when are files stale, default one hour
22
+    var $ERROR      = ""; // accumulate error messages
23 23
 
24
-    function __construct($base='', $age='') {
25
-        if ( $base ) {
24
+    function __construct($base = '', $age = ''){
25
+        if ($base) {
26 26
             $this->BASE_CACHE = $base;
27 27
         }
28
-        if ( $age ) {
28
+        if ($age) {
29 29
             $this->MAX_AGE = $age;
30 30
         }
31 31
 
32 32
         // attempt to make the cache directory
33
-        if ( ! file_exists( $this->BASE_CACHE ) ) {
34
-            $status = @mkdir( $this->BASE_CACHE, 0755 );
33
+        if (!file_exists($this->BASE_CACHE)) {
34
+            $status = @mkdir($this->BASE_CACHE, 0755);
35 35
 
36 36
             // if make failed
37
-            if ( ! $status ) {
37
+            if (!$status) {
38 38
                 $this->error(
39
-                    "Cache couldn't make dir '" . $this->BASE_CACHE . "'."
39
+                    "Cache couldn't make dir '".$this->BASE_CACHE."'."
40 40
                 );
41 41
             }
42 42
         }
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
     Input:      url from wich the rss file was fetched
49 49
     Output:     true on sucess
50 50
 \*=======================================================================*/
51
-    function set ($url, $rss) {
51
+    function set($url, $rss){
52 52
         $this->ERROR = "";
53
-        $cache_file = $this->file_name( $url );
54
-        $fp = @fopen( $cache_file, 'w' );
53
+        $cache_file = $this->file_name($url);
54
+        $fp = @fopen($cache_file, 'w');
55 55
 
56
-        if ( ! $fp ) {
56
+        if (!$fp) {
57 57
             $this->error(
58 58
                 "Cache unable to open file for writing: $cache_file"
59 59
             );
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
         }
62 62
 
63 63
 
64
-        $data = $this->serialize( $rss );
65
-        fwrite( $fp, $data );
66
-        fclose( $fp );
64
+        $data = $this->serialize($rss);
65
+        fwrite($fp, $data);
66
+        fclose($fp);
67 67
 
68 68
         return $cache_file;
69 69
     }
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
     Input:      url from wich the rss file was fetched
75 75
     Output:     cached object on HIT, false on MISS
76 76
 \*=======================================================================*/
77
-    function get ($url) {
77
+    function get($url){
78 78
         $this->ERROR = "";
79
-        $cache_file = $this->file_name( $url );
79
+        $cache_file = $this->file_name($url);
80 80
 
81
-        if ( ! file_exists( $cache_file ) ) {
81
+        if (!file_exists($cache_file)) {
82 82
             $this->debug(
83 83
                 "Cache doesn't contain: $url (cache file: $cache_file)"
84 84
             );
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
         }
87 87
 
88 88
         $fp = @fopen($cache_file, 'r');
89
-        if ( ! $fp ) {
89
+        if (!$fp) {
90 90
             $this->error(
91 91
                 "Failed to open cache file for reading: $cache_file"
92 92
             );
93 93
             return 0;
94 94
         }
95 95
 
96
-        if ($filesize = filesize($cache_file) ) {
97
-        	$data = fread( $fp, filesize($cache_file) );
98
-        	$rss = $this->unserialize( $data );
96
+        if ($filesize = filesize($cache_file)) {
97
+        	$data = fread($fp, filesize($cache_file));
98
+        	$rss = $this->unserialize($data);
99 99
 
100 100
         	return $rss;
101 101
     	}
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
     Input:      url from wich the rss file was fetched
111 111
     Output:     cached object on HIT, false on MISS
112 112
 \*=======================================================================*/
113
-    function check_cache ( $url ) {
113
+    function check_cache($url){
114 114
         $this->ERROR = "";
115
-        $filename = $this->file_name( $url );
115
+        $filename = $this->file_name($url);
116 116
 
117
-        if ( file_exists( $filename ) ) {
117
+        if (file_exists($filename)) {
118 118
             // find how long ago the file was added to the cache
119 119
             // and whether that is longer then MAX_AGE
120
-            $mtime = filemtime( $filename );
120
+            $mtime = filemtime($filename);
121 121
             $age = time() - $mtime;
122
-            if ( $this->MAX_AGE > $age ) {
122
+            if ($this->MAX_AGE > $age) {
123 123
                 // object exists and is current
124 124
                 return 'HIT';
125 125
             }
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
         }
135 135
     }
136 136
 
137
-	function cache_age( $cache_key ) {
138
-		$filename = $this->file_name( $url );
139
-		if ( file_exists( $filename ) ) {
140
-			$mtime = filemtime( $filename );
137
+	function cache_age($cache_key){
138
+		$filename = $this->file_name($url);
139
+		if (file_exists($filename)) {
140
+			$mtime = filemtime($filename);
141 141
             $age = time() - $mtime;
142 142
 			return $age;
143 143
 		}
@@ -149,15 +149,15 @@  discard block
 block discarded – undo
149 149
 /*=======================================================================*\
150 150
     Function:   serialize
151 151
 \*=======================================================================*/
152
-    function serialize ( $rss ) {
153
-        return serialize( $rss );
152
+    function serialize($rss){
153
+        return serialize($rss);
154 154
     }
155 155
 
156 156
 /*=======================================================================*\
157 157
     Function:   unserialize
158 158
 \*=======================================================================*/
159
-    function unserialize ( $data ) {
160
-        return unserialize( $data );
159
+    function unserialize($data){
160
+        return unserialize($data);
161 161
     }
162 162
 
163 163
 /*=======================================================================*\
@@ -166,31 +166,31 @@  discard block
 block discarded – undo
166 166
     Input:      url from wich the rss file was fetched
167 167
     Output:     a file name
168 168
 \*=======================================================================*/
169
-    function file_name ($url) {
170
-        $filename = md5( $url );
171
-        return implode( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) );
169
+    function file_name($url){
170
+        $filename = md5($url);
171
+        return implode(DIRECTORY_SEPARATOR, array($this->BASE_CACHE, $filename));
172 172
     }
173 173
 
174 174
 /*=======================================================================*\
175 175
     Function:   error
176 176
     Purpose:    register error
177 177
 \*=======================================================================*/
178
-    function error ($errormsg, $lvl=E_USER_WARNING) {
178
+    function error($errormsg, $lvl = E_USER_WARNING){
179 179
         // append PHP's error message if track_errors enabled
180
-        if ( isset($php_errormsg) ) {
180
+        if (isset($php_errormsg)) {
181 181
             $errormsg .= " ($php_errormsg)";
182 182
         }
183 183
         $this->ERROR = $errormsg;
184
-        if ( MAGPIE_DEBUG ) {
185
-            trigger_error( $errormsg, $lvl);
184
+        if (MAGPIE_DEBUG) {
185
+            trigger_error($errormsg, $lvl);
186 186
         }
187 187
         else {
188
-            error_log( $errormsg, 0);
188
+            error_log($errormsg, 0);
189 189
         }
190 190
     }
191 191
 
192
-    function debug ($debugmsg, $lvl=E_USER_NOTICE) {
193
-        if ( MAGPIE_DEBUG ) {
192
+    function debug($debugmsg, $lvl = E_USER_NOTICE){
193
+        if (MAGPIE_DEBUG) {
194 194
             $this->error("MagpieRSS [debug] $debugmsg", $lvl);
195 195
         }
196 196
     }
Please login to merge, or discard this patch.