Completed
Push — develop ( 0132ab...e45b08 )
by Dmytro
13:40 queued 05:11
created
install/setup.info.php 1 patch
Spacing   +65 added lines, -66 removed lines patch added patch discarded remove patch
@@ -1,33 +1,32 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 //:: EVO Installer Setup file
3 3
 //:::::::::::::::::::::::::::::::::::::::::
4
-if (is_file($base_path . 'assets/cache/siteManager.php')) {
5
-    include_once($base_path . 'assets/cache/siteManager.php');
4
+if (is_file($base_path.'assets/cache/siteManager.php')) {
5
+    include_once($base_path.'assets/cache/siteManager.php');
6 6
 }
7
-if(!defined('MGR_DIR')) define('MGR_DIR', 'manager');
7
+if (!defined('MGR_DIR')) define('MGR_DIR', 'manager');
8 8
 
9 9
 require_once('../'.MGR_DIR.'/includes/version.inc.php');
10 10
 
11
-$chunkPath    = $base_path .'install/assets/chunks';
12
-$snippetPath  = $base_path .'install/assets/snippets';
13
-$pluginPath   = $base_path .'install/assets/plugins';
14
-$modulePath   = $base_path .'install/assets/modules';
15
-$templatePath = $base_path .'install/assets/templates';
16
-$tvPath = $base_path .'install/assets/tvs';
11
+$chunkPath    = $base_path.'install/assets/chunks';
12
+$snippetPath  = $base_path.'install/assets/snippets';
13
+$pluginPath   = $base_path.'install/assets/plugins';
14
+$modulePath   = $base_path.'install/assets/modules';
15
+$templatePath = $base_path.'install/assets/templates';
16
+$tvPath = $base_path.'install/assets/tvs';
17 17
 
18 18
 // setup Template template files - array : name, description, type - 0:file or 1:content, parameters, category
19 19
 $mt = &$moduleTemplates;
20
-if(is_dir($templatePath) && is_readable($templatePath)) {
20
+if (is_dir($templatePath) && is_readable($templatePath)) {
21 21
     $d = dir($templatePath);
22 22
     while (false !== ($tplfile = $d->read()))
23 23
     {
24
-        if(substr($tplfile, -4) != '.tpl') continue;
24
+        if (substr($tplfile, -4) != '.tpl') continue;
25 25
         $params = parse_docblock($templatePath, $tplfile);
26
-        if(is_array($params) && (count($params)>0))
26
+        if (is_array($params) && (count($params) > 0))
27 27
         {
28 28
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
29
-            $mt[] = array
30
-            (
29
+            $mt[] = array(
31 30
                 $params['name'],
32 31
                 $description,
33 32
                 // Don't think this is gonna be used ... but adding it just in case 'type'
@@ -45,12 +44,12 @@  discard block
 block discarded – undo
45 44
 
46 45
 // setup Template Variable template files
47 46
 $mtv = &$moduleTVs;
48
-if(is_dir($tvPath) && is_readable($tvPath)) {
47
+if (is_dir($tvPath) && is_readable($tvPath)) {
49 48
     $d = dir($tvPath);
50 49
     while (false !== ($tplfile = $d->read())) {
51
-        if(substr($tplfile, -4) != '.tpl') continue;
50
+        if (substr($tplfile, -4) != '.tpl') continue;
52 51
         $params = parse_docblock($tvPath, $tplfile);
53
-        if(is_array($params) && (count($params)>0)) {
52
+        if (is_array($params) && (count($params) > 0)) {
54 53
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
55 54
             $mtv[] = array(
56 55
                 $params['name'],
@@ -62,9 +61,9 @@  discard block
 block discarded – undo
62 61
                 $params['output_widget'],
63 62
                 $params['output_widget_params'],
64 63
                 "$templatePath/{$params['filename']}", /* not currently used */
65
-                $params['template_assignments']!="*"?$params['template_assignments']:implode(",",array_map(create_function('$v','return $v[0];'),$mt)), /* comma-separated list of template names */
64
+                $params['template_assignments'] != "*" ? $params['template_assignments'] : implode(",", array_map(create_function('$v', 'return $v[0];'), $mt)), /* comma-separated list of template names */
66 65
                 $params['modx_category'],
67
-                $params['lock_tv'],  /* value should be 1 or 0 */
66
+                $params['lock_tv'], /* value should be 1 or 0 */
68 67
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
69 68
             );
70 69
         }
@@ -74,14 +73,14 @@  discard block
 block discarded – undo
74 73
 
75 74
 // setup chunks template files - array : name, description, type - 0:file or 1:content, file or content
76 75
 $mc = &$moduleChunks;
77
-if(is_dir($chunkPath) && is_readable($chunkPath)) {
76
+if (is_dir($chunkPath) && is_readable($chunkPath)) {
78 77
     $d = dir($chunkPath);
79 78
     while (false !== ($tplfile = $d->read())) {
80
-        if(substr($tplfile, -4) != '.tpl') {
79
+        if (substr($tplfile, -4) != '.tpl') {
81 80
             continue;
82 81
         }
83 82
         $params = parse_docblock($chunkPath, $tplfile);
84
-        if(is_array($params) && count($params) > 0) {
83
+        if (is_array($params) && count($params) > 0) {
85 84
             $mc[] = array(
86 85
                 $params['name'],
87 86
                 $params['description'],
@@ -97,14 +96,14 @@  discard block
 block discarded – undo
97 96
 
98 97
 // setup snippets template files - array : name, description, type - 0:file or 1:content, file or content,properties
99 98
 $ms = &$moduleSnippets;
100
-if(is_dir($snippetPath) && is_readable($snippetPath)) {
99
+if (is_dir($snippetPath) && is_readable($snippetPath)) {
101 100
     $d = dir($snippetPath);
102 101
     while (false !== ($tplfile = $d->read())) {
103
-        if(substr($tplfile, -4) != '.tpl') {
102
+        if (substr($tplfile, -4) != '.tpl') {
104 103
             continue;
105 104
         }
106 105
         $params = parse_docblock($snippetPath, $tplfile);
107
-        if(is_array($params) && count($params) > 0) {
106
+        if (is_array($params) && count($params) > 0) {
108 107
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
109 108
             $ms[] = array(
110 109
                 $params['name'],
@@ -121,14 +120,14 @@  discard block
 block discarded – undo
121 120
 
122 121
 // setup plugins template files - array : name, description, type - 0:file or 1:content, file or content,properties
123 122
 $mp = &$modulePlugins;
124
-if(is_dir($pluginPath) && is_readable($pluginPath)) {
123
+if (is_dir($pluginPath) && is_readable($pluginPath)) {
125 124
     $d = dir($pluginPath);
126 125
     while (false !== ($tplfile = $d->read())) {
127
-        if(substr($tplfile, -4) != '.tpl') {
126
+        if (substr($tplfile, -4) != '.tpl') {
128 127
             continue;
129 128
         }
130 129
         $params = parse_docblock($pluginPath, $tplfile);
131
-        if(is_array($params) && count($params) > 0) {
130
+        if (is_array($params) && count($params) > 0) {
132 131
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
133 132
             $mp[] = array(
134 133
                 $params['name'],
@@ -140,7 +139,7 @@  discard block
 block discarded – undo
140 139
                 $params['modx_category'],
141 140
                 $params['legacy_names'],
142 141
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false,
143
-                (int)$params['disabled']
142
+                (int) $params['disabled']
144 143
             );
145 144
         }
146 145
     }
@@ -150,14 +149,14 @@  discard block
 block discarded – undo
150 149
 // setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
151 150
 $mm = &$moduleModules;
152 151
 $mdp = &$moduleDependencies;
153
-if(is_dir($modulePath) && is_readable($modulePath)) {
152
+if (is_dir($modulePath) && is_readable($modulePath)) {
154 153
     $d = dir($modulePath);
155 154
     while (false !== ($tplfile = $d->read())) {
156
-        if(substr($tplfile, -4) != '.tpl') {
155
+        if (substr($tplfile, -4) != '.tpl') {
157 156
             continue;
158 157
         }
159 158
         $params = parse_docblock($modulePath, $tplfile);
160
-        if(is_array($params) && count($params) > 0) {
159
+        if (is_array($params) && count($params) > 0) {
161 160
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
162 161
             $mm[] = array(
163 162
                 $params['name'],
@@ -165,12 +164,12 @@  discard block
 block discarded – undo
165 164
                 "$modulePath/{$params['filename']}",
166 165
                 $params['properties'],
167 166
                 $params['guid'],
168
-                (int)$params['shareparams'],
167
+                (int) $params['shareparams'],
169 168
                 $params['modx_category'],
170 169
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
171 170
             );
172 171
         }
173
-		if ((int)$params['shareparams'] || !empty($params['dependencies'])) {
172
+		if ((int) $params['shareparams'] || !empty($params['dependencies'])) {
174 173
 			$dependencies = explode(',', $params['dependencies']);
175 174
 			foreach ($dependencies as $dependency) {
176 175
 				$dependency = explode(':', $dependency);
@@ -241,103 +240,103 @@  discard block
 block discarded – undo
241 240
 // setup callback function
242 241
 $callBackFnc = "clean_up";
243 242
 
244
-function clean_up($sqlParser) {
243
+function clean_up($sqlParser){
245 244
     $ids = array();
246 245
 
247 246
     // secure web documents - privateweb
248
-    mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1");
249
-    $sql =  "SELECT DISTINCT sc.id
247
+    mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1");
248
+    $sql = "SELECT DISTINCT sc.id
250 249
              FROM `".$sqlParser->prefix."site_content` sc
251 250
              LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id
252 251
              LEFT JOIN `".$sqlParser->prefix."webgroup_access` wga ON wga.documentgroup = dg.document_group
253 252
              WHERE wga.id>0";
254
-    $ds = mysqli_query($sqlParser->conn,$sql);
255
-    if(!$ds) {
253
+    $ds = mysqli_query($sqlParser->conn, $sql);
254
+    if (!$ds) {
256 255
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
257 256
     }
258 257
     else {
259
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
260
-        if(count($ids)>0) {
261
-            mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")");
258
+        while ($r = mysqli_fetch_assoc($ds)) $ids[] = $r["id"];
259
+        if (count($ids) > 0) {
260
+            mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ", $ids).")");
262 261
             unset($ids);
263 262
         }
264 263
     }
265 264
 
266 265
     // secure manager documents privatemgr
267
-    mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1");
268
-    $sql =  "SELECT DISTINCT sc.id
266
+    mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1");
267
+    $sql = "SELECT DISTINCT sc.id
269 268
              FROM `".$sqlParser->prefix."site_content` sc
270 269
              LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id
271 270
              LEFT JOIN `".$sqlParser->prefix."membergroup_access` mga ON mga.documentgroup = dg.document_group
272 271
              WHERE mga.id>0";
273
-    $ds = mysqli_query($sqlParser->conn,$sql);
274
-    if(!$ds) {
272
+    $ds = mysqli_query($sqlParser->conn, $sql);
273
+    if (!$ds) {
275 274
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
276 275
     }
277 276
     else {
278
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
279
-        if(count($ids)>0) {
280
-            mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")");
277
+        while ($r = mysqli_fetch_assoc($ds)) $ids[] = $r["id"];
278
+        if (count($ids) > 0) {
279
+            mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ", $ids).")");
281 280
             unset($ids);
282 281
         }
283 282
     }
284 283
 }
285 284
 
286
-function parse_docblock($element_dir, $filename) {
285
+function parse_docblock($element_dir, $filename){
287 286
     $params = array();
288
-    $fullpath = $element_dir . '/' . $filename;
289
-    if(is_readable($fullpath)) {
287
+    $fullpath = $element_dir.'/'.$filename;
288
+    if (is_readable($fullpath)) {
290 289
         $tpl = @fopen($fullpath, "r");
291
-        if($tpl) {
290
+        if ($tpl) {
292 291
             $params['filename'] = $filename;
293 292
             $docblock_start_found = false;
294 293
             $name_found = false;
295 294
             $description_found = false;
296 295
 
297
-            while(!feof($tpl)) {
296
+            while (!feof($tpl)) {
298 297
                 $line = fgets($tpl);
299
-                if(!$docblock_start_found) {
298
+                if (!$docblock_start_found) {
300 299
                     // find docblock start
301
-                    if(strpos($line, '/**') !== false) {
300
+                    if (strpos($line, '/**') !== false) {
302 301
                         $docblock_start_found = true;
303 302
                     }
304 303
                     continue;
305
-                } elseif(!$name_found) {
304
+                } elseif (!$name_found) {
306 305
                     // find name
307 306
                     $ma = null;
308
-                    if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
307
+                    if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
309 308
                         $params['name'] = trim($ma[1]);
310 309
                         $name_found = !empty($params['name']);
311 310
                     }
312 311
                     continue;
313
-                } elseif(!$description_found) {
312
+                } elseif (!$description_found) {
314 313
                     // find description
315 314
                     $ma = null;
316
-                    if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
315
+                    if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
317 316
                         $params['description'] = trim($ma[1]);
318 317
                         $description_found = !empty($params['description']);
319 318
                     }
320 319
                     continue;
321 320
                 } else {
322 321
                     $ma = null;
323
-                    if(preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
322
+                    if (preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
324 323
                         $param = trim($ma[1]);
325 324
                         $val = trim($ma[2]);
326
-                        if(!empty($param) && !empty($val)) {
327
-                            if($param == 'internal') {
325
+                        if (!empty($param) && !empty($val)) {
326
+                            if ($param == 'internal') {
328 327
                                 $ma = null;
329
-                                if(preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
328
+                                if (preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
330 329
                                     $param = trim($ma[1]);
331 330
                                     $val = trim($ma[2]);
332 331
                                 }
333 332
                                 //if($val !== '0' && (empty($param) || empty($val))) {
334
-                                if(empty($param)) {
333
+                                if (empty($param)) {
335 334
                                     continue;
336 335
                                 }
337 336
                             }
338 337
                             $params[$param] = $val;
339 338
                         }
340
-                    } elseif(preg_match("/^\s*\*\/\s*$/", $line)) {
339
+                    } elseif (preg_match("/^\s*\*\/\s*$/", $line)) {
341 340
                         break;
342 341
                     }
343 342
                 }
Please login to merge, or discard this patch.
manager/actions/mutate_tmplvars.dynamic.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  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
-if(!$modx->hasPermission('edit_template') && $modx->manager->action == '301') {
5
+if (!$modx->hasPermission('edit_template') && $modx->manager->action == '301') {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8
-if(!$modx->hasPermission('new_template') && $modx->manager->action == '300') {
8
+if (!$modx->hasPermission('new_template') && $modx->manager->action == '300') {
9 9
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
10 10
 }
11 11
 
12
-$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
13
-$origin = isset($_REQUEST['or']) ? (int)$_REQUEST['or'] : 76;
14
-$originId = isset($_REQUEST['oid']) ? (int)$_REQUEST['oid'] : NULL;
12
+$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
13
+$origin = isset($_REQUEST['or']) ? (int) $_REQUEST['or'] : 76;
14
+$originId = isset($_REQUEST['oid']) ? (int) $_REQUEST['oid'] : NULL;
15 15
 
16 16
 $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars');
17 17
 $tbl_site_templates = $modx->getFullTableName('site_templates');
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 $tbl_documentgroup_names = $modx->getFullTableName('documentgroup_names');
20 20
 
21 21
 // check to see the snippet editor isn't locked
22
-if($lockedEl = $modx->elementIsLocked(2, $id)) {
22
+if ($lockedEl = $modx->elementIsLocked(2, $id)) {
23 23
 	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['tmplvar']));
24 24
 }
25 25
 // end check for lock
@@ -29,25 +29,25 @@  discard block
 block discarded – undo
29 29
 
30 30
 global $content;
31 31
 $content = array();
32
-if(isset($_GET['id'])) {
32
+if (isset($_GET['id'])) {
33 33
 	$rs = $modx->db->select('*', $tbl_site_tmplvars, "id='{$id}'");
34 34
 	$content = $modx->db->getRow($rs);
35
-	if(!$content) {
36
-		header("Location: " . MODX_SITE_URL . "index.php?id={$site_start}");
35
+	if (!$content) {
36
+		header("Location: ".MODX_SITE_URL."index.php?id={$site_start}");
37 37
 	}
38 38
 
39 39
 	$_SESSION['itemname'] = $content['caption'];
40
-	if($content['locked'] == 1 && $modx->hasPermission('save_role') != 1) {
40
+	if ($content['locked'] == 1 && $modx->hasPermission('save_role') != 1) {
41 41
 		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
42 42
 	}
43
-} else if(isset($_REQUEST['itemname'])) {
43
+} else if (isset($_REQUEST['itemname'])) {
44 44
 	$content['name'] = $_REQUEST['itemname'];
45 45
 } else {
46 46
 	$_SESSION['itemname'] = $_lang["new_tmplvars"];
47
-	$content['category'] = (int)$_REQUEST['catid'];
47
+	$content['category'] = (int) $_REQUEST['catid'];
48 48
 }
49 49
 
50
-if($modx->manager->hasFormValues()) {
50
+if ($modx->manager->hasFormValues()) {
51 51
 	$modx->manager->loadFormValues();
52 52
 }
53 53
 
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
 // Add lock-element JS-Script
57 57
 $lockElementId = $id;
58 58
 $lockElementType = 2;
59
-require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php');
59
+require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php');
60 60
 
61 61
 // get available RichText Editors
62 62
 $RTEditors = '';
63 63
 $evtOut = $modx->invokeEvent('OnRichTextEditorRegister', array('forfrontend' => 1));
64
-if(is_array($evtOut)) {
64
+if (is_array($evtOut)) {
65 65
 	$RTEditors = implode(',', $evtOut);
66 66
 }
67 67
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		},
108 108
 		cancel: function() {
109 109
 			documentDirty = false;
110
-			document.location.href = 'index.php?a=<?= $origin ?><?=(empty($originId) ? '' : '&id=' . $originId) ?>';
110
+			document.location.href = 'index.php?a=<?= $origin ?><?=(empty($originId) ? '' : '&id='.$originId) ?>';
111 111
 		}
112 112
 	};
113 113
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	<?php
280 280
 	// invoke OnTVFormPrerender event
281 281
 	$evtOut = $modx->invokeEvent('OnTVFormPrerender', array('id' => $id));
282
-	if(is_array($evtOut)) {
282
+	if (is_array($evtOut)) {
283 283
 		echo implode("", $evtOut);
284 284
 	}
285 285
 	?>
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	<input type="hidden" name="params" value="<?= $modx->htmlspecialchars($content['display_params']) ?>">
292 292
 
293 293
 	<h1>
294
-		<i class="fa fa-list-alt"></i><?= ($content['name'] ? $content['name'] . '<small>(' . $content['id'] . ')</small>' : $_lang['new_tmplvars']) ?><i class="fa fa-question-circle help"></i>
294
+		<i class="fa fa-list-alt"></i><?= ($content['name'] ? $content['name'].'<small>('.$content['id'].')</small>' : $_lang['new_tmplvars']) ?><i class="fa fa-question-circle help"></i>
295 295
 	</h1>
296 296
 
297 297
 	<?= $_style['actionbuttons']['dynamic']['element'] ?>
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 					<div class="col-md-9 col-lg-10">
315 315
 						<div class="form-control-name clearfix">
316 316
 							<input name="name" type="text" maxlength="50" value="<?= $modx->htmlspecialchars($content['name']) ?>" class="form-control form-control-lg" onchange="documentDirty=true;" />
317
-							<?php if($modx->hasPermission('save_role')): ?>
318
-								<label class="custom-control" title="<?= $_lang['lock_tmplvars'] . "\n" . $_lang['lock_tmplvars_msg'] ?>" tooltip>
317
+							<?php if ($modx->hasPermission('save_role')): ?>
318
+								<label class="custom-control" title="<?= $_lang['lock_tmplvars']."\n".$_lang['lock_tmplvars_msg'] ?>" tooltip>
319 319
 									<input name="locked" type="checkbox"<?= ($content['locked'] == 1 ? ' checked="checked"' : '') ?> />
320 320
 									<i class="fa fa-lock"></i>
321 321
 								</label>
@@ -343,9 +343,9 @@  discard block
 block discarded – undo
343 343
 						<select name="categoryid" class="form-control" onChange="documentDirty=true;">
344 344
 							<option>&nbsp;</option>
345 345
 							<?php
346
-							include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
347
-							foreach(getCategories() as $n => $v) {
348
-								echo "<option value='" . $v['id'] . "'" . ($content["category"] == $v["id"] ? " selected='selected'" : "") . ">" . $modx->htmlspecialchars($v["category"]) . "</option>";
346
+							include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
347
+							foreach (getCategories() as $n => $v) {
348
+								echo "<option value='".$v['id']."'".($content["category"] == $v["id"] ? " selected='selected'" : "").">".$modx->htmlspecialchars($v["category"])."</option>";
349 349
 							}
350 350
 							?>
351 351
 						</select>
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
 							<optgroup label="Custom Type">
384 384
 								<option value="custom_tv" <?= ($content['type'] == 'custom_tv' ? "selected='selected'" : "") ?>>Custom Input</option>
385 385
 								<?php
386
-								$custom_tvs = scandir(MODX_BASE_PATH . 'assets/tvs');
387
-								foreach($custom_tvs as $ctv) {
388
-									if(strpos($ctv, '.') !== 0 && $ctv != 'index.html') {
389
-										$selected = ($content['type'] == 'custom_tv:' . $ctv ? "selected='selected'" : "");
390
-										echo '<option value="custom_tv:' . $ctv . '"  ' . $selected . '>' . $ctv . '</option>';
386
+								$custom_tvs = scandir(MODX_BASE_PATH.'assets/tvs');
387
+								foreach ($custom_tvs as $ctv) {
388
+									if (strpos($ctv, '.') !== 0 && $ctv != 'index.html') {
389
+										$selected = ($content['type'] == 'custom_tv:'.$ctv ? "selected='selected'" : "");
390
+										echo '<option value="custom_tv:'.$ctv.'"  '.$selected.'>'.$ctv.'</option>';
391 391
 									}
392 392
 								}
393 393
 								?>
@@ -462,36 +462,36 @@  discard block
 block discarded – undo
462 462
 				$tplList = '<ul>';
463 463
 				$preCat = '';
464 464
 				$insideUl = 0;
465
-				while($row = $modx->db->getRow($rs)) {
465
+				while ($row = $modx->db->getRow($rs)) {
466 466
 					$row['category'] = stripslashes($row['category']); //pixelchutes
467
-					if($preCat !== $row['category']) {
467
+					if ($preCat !== $row['category']) {
468 468
 						$tplList .= $insideUl ? '</ul>' : '';
469
-						$tplList .= '<li><strong>' . $row['category'] . ($row['catid'] != '' ? ' <small>(' . $row['catid'] . ')</small>' : '') . '</strong><ul>';
469
+						$tplList .= '<li><strong>'.$row['category'].($row['catid'] != '' ? ' <small>('.$row['catid'].')</small>' : '').'</strong><ul>';
470 470
 						$insideUl = 1;
471 471
 					}
472 472
 
473
-					if($modx->manager->action == '300' && $modx->config['default_template'] == $row['id']) {
473
+					if ($modx->manager->action == '300' && $modx->config['default_template'] == $row['id']) {
474 474
 						$checked = true;
475
-					} elseif(isset($_GET['tpl']) && $_GET['tpl'] == $row['id']) {
475
+					} elseif (isset($_GET['tpl']) && $_GET['tpl'] == $row['id']) {
476 476
 						$checked = true;
477
-					} elseif($id == 0 && is_array($_POST['template'])) {
477
+					} elseif ($id == 0 && is_array($_POST['template'])) {
478 478
 						$checked = in_array($row['id'], $_POST['template']);
479 479
 					} else {
480 480
 						$checked = $row['tmplvarid'];
481 481
 					}
482 482
 					$selectable = !$row['selectable'] ? ' class="disabled"' : '';
483 483
 					$checked = $checked ? ' checked="checked"' : '';
484
-					$tplId = '&nbsp;<small>(' . $row['id'] . ')</small>';
485
-					$desc = !empty($row['tpldescription']) ? ' - ' . $row['tpldescription'] : '';
484
+					$tplId = '&nbsp;<small>('.$row['id'].')</small>';
485
+					$desc = !empty($row['tpldescription']) ? ' - '.$row['tpldescription'] : '';
486 486
 
487 487
 					$tplInfo = array();
488
-					if($row['tpllocked']) {
488
+					if ($row['tpllocked']) {
489 489
 						$tplInfo[] = $_lang['locked'];
490 490
 					}
491
-					if($row['id'] == $modx->config['default_template']) {
491
+					if ($row['id'] == $modx->config['default_template']) {
492 492
 						$tplInfo[] = $_lang['defaulttemplate_title'];
493 493
 					}
494
-					$tplInfo = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
494
+					$tplInfo = !empty($tplInfo) ? ' <em>('.implode(', ', $tplInfo).')</em>' : '';
495 495
 
496 496
 					$tplList .= sprintf('<li><label%s><input name="template[]" value="%s" type="checkbox" %s onchange="documentDirty=true;"> %s%s%s%s</label></li>', $selectable, $row['id'], $checked, $row['templatename'], $tplId, $desc, $tplInfo);
497 497
 					$tplList .= '</li>';
@@ -506,13 +506,13 @@  discard block
 block discarded – undo
506 506
 
507 507
 				<!-- Access Permissions -->
508 508
 				<?php
509
-				if($use_udperms == 1) {
509
+				if ($use_udperms == 1) {
510 510
 					// fetch permissions for the variable
511 511
 					$rs = $modx->db->select('documentgroup', $modx->getFullTableName('site_tmplvar_access'), "tmplvarid='{$id}'");
512 512
 					$groupsarray = $modx->db->getColumn('documentgroup', $rs);
513 513
 
514 514
 					?>
515
-					<?php if($modx->hasPermission('access_permissions')) { ?>
515
+					<?php if ($modx->hasPermission('access_permissions')) { ?>
516 516
 						<script type="text/javascript">
517 517
 							function makePublic(b) {
518 518
 								var notPublic = false;
@@ -541,26 +541,26 @@  discard block
 block discarded – undo
541 541
 						<?php
542 542
 						$chk = '';
543 543
 						$rs = $modx->db->select('name, id', $tbl_documentgroup_names);
544
-						if(empty($groupsarray) && is_array($_POST['docgroups']) && empty($_POST['id'])) {
544
+						if (empty($groupsarray) && is_array($_POST['docgroups']) && empty($_POST['id'])) {
545 545
 							$groupsarray = $_POST['docgroups'];
546 546
 						}
547
-						while($row = $modx->db->getRow($rs)) {
547
+						while ($row = $modx->db->getRow($rs)) {
548 548
 							$checked = in_array($row['id'], $groupsarray);
549
-							if($modx->hasPermission('access_permissions')) {
550
-								if($checked) {
549
+							if ($modx->hasPermission('access_permissions')) {
550
+								if ($checked) {
551 551
 									$notPublic = true;
552 552
 								}
553
-								$chks .= "<li><label><input type='checkbox' name='docgroups[]' value='" . $row['id'] . "' " . ($checked ? "checked='checked'" : '') . " onclick=\"makePublic(false)\" /> " . $row['name'] . "</label></li>";
553
+								$chks .= "<li><label><input type='checkbox' name='docgroups[]' value='".$row['id']."' ".($checked ? "checked='checked'" : '')." onclick=\"makePublic(false)\" /> ".$row['name']."</label></li>";
554 554
 							} else {
555
-								if($checked) {
556
-									echo "<input type='hidden' name='docgroups[]'  value='" . $row['id'] . "' />";
555
+								if ($checked) {
556
+									echo "<input type='hidden' name='docgroups[]'  value='".$row['id']."' />";
557 557
 								}
558 558
 							}
559 559
 						}
560
-						if($modx->hasPermission('access_permissions')) {
561
-							$chks = "<li><label><input type='checkbox' name='chkalldocs' " . (!$notPublic ? "checked='checked'" : '') . " onclick=\"makePublic(true)\" /> <span class='warning'>" . $_lang['all_doc_groups'] . "</span></label></li>" . $chks;
560
+						if ($modx->hasPermission('access_permissions')) {
561
+							$chks = "<li><label><input type='checkbox' name='chkalldocs' ".(!$notPublic ? "checked='checked'" : '')." onclick=\"makePublic(true)\" /> <span class='warning'>".$_lang['all_doc_groups']."</span></label></li>".$chks;
562 562
 						}
563
-						echo '<ul>' . $chks . '</ul>';
563
+						echo '<ul>'.$chks.'</ul>';
564 564
 						?>
565 565
 					<?php } ?>
566 566
 				<?php } ?>
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 		<?php
574 574
 		// invoke OnTVFormRender event
575 575
 		$evtOut = $modx->invokeEvent('OnTVFormRender', array('id' => $id));
576
-		if(is_array($evtOut)) {
576
+		if (is_array($evtOut)) {
577 577
 			echo implode('', $evtOut);
578 578
 		}
579 579
 		?>
Please login to merge, or discard this patch.
manager/processors/delete_snippet.processor.php 1 patch
Spacing   +5 added lines, -5 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
-if(!$modx->hasPermission('delete_snippet')) {
5
+if (!$modx->hasPermission('delete_snippet')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
@@ -34,5 +34,5 @@  discard block
 block discarded – undo
34 34
 $modx->clearCache('full');
35 35
 
36 36
 // finished emptying cache - redirect
37
-$header="Location: index.php?a=76&r=2";
37
+$header = "Location: index.php?a=76&r=2";
38 38
 header($header);
Please login to merge, or discard this patch.
manager/includes/charsets.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -65,26 +65,26 @@
 block discarded – undo
65 65
 $_['macintosh']         = 'Western European (Mac) - macintosh';
66 66
 $_['Windows-1252']      = 'Western European (Windows) - Windows-1252';
67 67
 
68
-if($modx_charset     == 'euc-jp')      $_['euc-jp']      = 'Japanese (EUC) - euc-jp';
69
-elseif($modx_charset == 'shift_jis')   $_['shift_jis']   = 'Japanese (Shift-JIS) - shift_jis';
70
-elseif($modx_charset == 'iso-2022-jp') $_['iso-2022-jp'] = 'Japanese (JIS-Allow 1 byte Kana - SO/SI) - iso-2022-jp';
71
-elseif($modx_charset == 'csISO2022JP') $_['csISO2022JP'] = 'Japanese (JIS-Allow 1 byte Kana) - csISO2022JP';
72
-elseif($modx_charset == 'EUC-CN')            $_['EUC-CN']            = 'Chinese Simplified (EUC) - EUC-CN';
73
-elseif($modx_charset == 'hz-gb-2312')        $_['hz-gb-2312']        = 'Chinese Simplified (HZ) - hz-gb-2312';
74
-elseif($modx_charset == 'x-mac-chinesesimp') $_['x-mac-chinesesimp'] = 'Chinese Simplified (Mac) - x-mac-chinesesimp';
75
-elseif($modx_charset == 'x-Chinese-CNS')     $_['x-Chinese-CNS']     = 'Chinese Traditional (CNS) - x-Chinese-CNS';
76
-elseif($modx_charset == 'x-Chinese-Eten')    $_['x-Chinese-Eten']    = 'Chinese Traditional (Eten) - x-Chinese-Eten';
77
-elseif($modx_charset == 'x-mac-chinesetrad') $_['x-mac-chinesetrad'] = 'Chinese Traditional (Mac) - x-mac-chinesetrad';
78
-elseif($modx_charset == 'ks_c_5601-1987') $_['ks_c_5601-1987'] = 'Korean - ks_c_5601-1987';
79
-elseif($modx_charset == 'euc-kr')         $_['euc-kr']         = 'Korean (EUC) - euc-kr';
80
-elseif($modx_charset == 'iso-2022-kr')    $_['iso-2022-kr']    = 'Korean (ISO) - iso-2022-kr';
81
-elseif($modx_charset == 'Johab')          $_['Johab']          = 'Korean (Johab) - Johab';
82
-elseif($modx_charset == 'x-mac-korean')   $_['x-mac-korean']   = 'Korean (Mac) - x-mac-korean';
68
+if ($modx_charset == 'euc-jp')      $_['euc-jp']      = 'Japanese (EUC) - euc-jp';
69
+elseif ($modx_charset == 'shift_jis')   $_['shift_jis']   = 'Japanese (Shift-JIS) - shift_jis';
70
+elseif ($modx_charset == 'iso-2022-jp') $_['iso-2022-jp'] = 'Japanese (JIS-Allow 1 byte Kana - SO/SI) - iso-2022-jp';
71
+elseif ($modx_charset == 'csISO2022JP') $_['csISO2022JP'] = 'Japanese (JIS-Allow 1 byte Kana) - csISO2022JP';
72
+elseif ($modx_charset == 'EUC-CN')            $_['EUC-CN']            = 'Chinese Simplified (EUC) - EUC-CN';
73
+elseif ($modx_charset == 'hz-gb-2312')        $_['hz-gb-2312']        = 'Chinese Simplified (HZ) - hz-gb-2312';
74
+elseif ($modx_charset == 'x-mac-chinesesimp') $_['x-mac-chinesesimp'] = 'Chinese Simplified (Mac) - x-mac-chinesesimp';
75
+elseif ($modx_charset == 'x-Chinese-CNS')     $_['x-Chinese-CNS']     = 'Chinese Traditional (CNS) - x-Chinese-CNS';
76
+elseif ($modx_charset == 'x-Chinese-Eten')    $_['x-Chinese-Eten']    = 'Chinese Traditional (Eten) - x-Chinese-Eten';
77
+elseif ($modx_charset == 'x-mac-chinesetrad') $_['x-mac-chinesetrad'] = 'Chinese Traditional (Mac) - x-mac-chinesetrad';
78
+elseif ($modx_charset == 'ks_c_5601-1987') $_['ks_c_5601-1987'] = 'Korean - ks_c_5601-1987';
79
+elseif ($modx_charset == 'euc-kr')         $_['euc-kr']         = 'Korean (EUC) - euc-kr';
80
+elseif ($modx_charset == 'iso-2022-kr')    $_['iso-2022-kr']    = 'Korean (ISO) - iso-2022-kr';
81
+elseif ($modx_charset == 'Johab')          $_['Johab']          = 'Korean (Johab) - Johab';
82
+elseif ($modx_charset == 'x-mac-korean')   $_['x-mac-korean']   = 'Korean (Mac) - x-mac-korean';
83 83
 
84 84
 $tpl = '<option value="%s" %s>%s</option>';
85 85
 $options = array();
86
-foreach($_ as $value=>$label) {
87
-    $selected = $value===$modx_charset ? 'selected' : '';
86
+foreach ($_ as $value=>$label) {
87
+    $selected = $value === $modx_charset ? 'selected' : '';
88 88
     $options[] = sprintf($tpl, $value, $selected, $label);
89 89
 }
90 90
 echo implode("\n", $options);
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.
install/functions.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! function_exists('install_sessionCheck')) {
2
+if (!function_exists('install_sessionCheck')) {
3 3
     function install_sessionCheck()
4 4
     {
5 5
         global $_lang;
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 </head>
22 22
 <body>
23 23
 	<div class="install">
24
-		<p>' . $_lang["session_problem"] . '</p>
25
-		<p><a href="./">' . $_lang["session_problem_try_again"] . '</a></p>
24
+		<p>' . $_lang["session_problem"].'</p>
25
+		<p><a href="./">' . $_lang["session_problem_try_again"].'</a></p>
26 26
 	</div>
27 27
 </body>
28 28
 </html>';
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     }
33 33
 }
34 34
 
35
-if( ! function_exists('parse')) {
35
+if (!function_exists('parse')) {
36 36
     /**
37 37
      * @param string $src
38 38
      * @param array $ph
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     function parse($src, $ph, $left = '[+', $right = '+]')
44 44
     {
45 45
         foreach ($ph as $k => $v) {
46
-            $k = $left . $k . $right;
46
+            $k = $left.$k.$right;
47 47
             $src = str_replace($k, $v, $src);
48 48
         }
49 49
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     }
52 52
 }
53 53
 
54
-if( ! function_exists('ph')) {
54
+if (!function_exists('ph')) {
55 55
     /**
56 56
      * @return array
57 57
      */
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $ph['textdir'] = $modx_textdir ? ' id="rtl"' : '';
71 71
         $ph['help_link'] = $installmode == 0 ? $_lang['help_link_new'] : $_lang['help_link_upd'];
72 72
         $ph['version'] = $moduleVersion;
73
-        $ph['release_date'] = ($modx_textdir ? '&rlm;' : '') . $modx_release_date;
73
+        $ph['release_date'] = ($modx_textdir ? '&rlm;' : '').$modx_release_date;
74 74
         $ph['footer1'] = $_lang['modx_footer1'];
75 75
         $ph['footer2'] = $_lang['modx_footer2'];
76 76
         $ph['current_year'] = date('Y');
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     }
80 80
 }
81 81
 
82
-if( ! function_exists('get_installmode')) {
82
+if (!function_exists('get_installmode')) {
83 83
     /**
84 84
      * @return int
85 85
      */
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     }
142 142
 }
143 143
 
144
-if( ! function_exists('getLangs')) {
144
+if (!function_exists('getLangs')) {
145 145
     /**
146 146
      * @param string $install_language
147 147
      * @return string
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         }
156 156
 
157 157
         $langs = array();
158
-        if ($handle = opendir("../" . MGR_DIR . "/includes/lang")) {
158
+        if ($handle = opendir("../".MGR_DIR."/includes/lang")) {
159 159
             while (false !== ($file = readdir($handle))) {
160 160
                 if (strpos($file, '.inc.') !== false) {
161 161
                     $langs[] = $file;
Please login to merge, or discard this patch.
install/actions/action_options.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0;
2
+$installMode = isset($_POST['installmode']) ? (int) $_POST['installmode'] : 0;
3 3
 
4
-if( ! function_exists('getTemplates')) {
4
+if (!function_exists('getTemplates')) {
5 5
     /**
6 6
      * @param array $presets
7 7
      * @return string
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
             $_[] = parse($tpl, $ph);
26 26
             $i++;
27 27
         }
28
-        return (0 < count($_)) ? '<h3>[%templates%]</h3>' . implode("\n", $_) : '';
28
+        return (0 < count($_)) ? '<h3>[%templates%]</h3>'.implode("\n", $_) : '';
29 29
     }
30 30
 }
31 31
 
32
-if( ! function_exists('getTVs')) {
32
+if (!function_exists('getTVs')) {
33 33
     /**
34 34
      * @param array $presets
35 35
      * @return string
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
             $_[] = parse($tpl, $ph);
55 55
             $i++;
56 56
         }
57
-        return (0 < count($_)) ? '<h3>[%tvs%]</h3>' . implode("\n", $_) : '';
57
+        return (0 < count($_)) ? '<h3>[%tvs%]</h3>'.implode("\n", $_) : '';
58 58
     }
59 59
 }
60 60
 
61
-if( ! function_exists('getChunks')) {
61
+if (!function_exists('getChunks')) {
62 62
     /**
63 63
      * display chunks
64 64
      *
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
             $_[] = parse($tpl, $ph);
85 85
             $i++;
86 86
         }
87
-        return (0 < count($_)) ? '<h3>[%chunks%]</h3>' . implode("\n", $_) : '';
87
+        return (0 < count($_)) ? '<h3>[%chunks%]</h3>'.implode("\n", $_) : '';
88 88
     }
89 89
 }
90 90
 
91
-if( ! function_exists('getModules')) {
91
+if (!function_exists('getModules')) {
92 92
     /**
93 93
      * display modules
94 94
      *
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
             $_[] = parse($tpl, $ph);
115 115
             $i++;
116 116
         }
117
-        return (0 < count($_)) ? '<h3>[%modules%]</h3>' . implode("\n", $_) : '';
117
+        return (0 < count($_)) ? '<h3>[%modules%]</h3>'.implode("\n", $_) : '';
118 118
     }
119 119
 }
120 120
 
121
-if( ! function_exists('getPlugins')) {
121
+if (!function_exists('getPlugins')) {
122 122
     /**
123 123
      * display plugins
124 124
      *
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
             $_[] = parse($tpl, $ph);
149 149
             $i++;
150 150
         }
151
-        return (0 < count($_)) ? '<h3>[%plugins%]</h3>' . implode("\n", $_) : '';
151
+        return (0 < count($_)) ? '<h3>[%plugins%]</h3>'.implode("\n", $_) : '';
152 152
     }
153 153
 }
154 154
 
155
-if( ! function_exists('getSnippets')) {
155
+if (!function_exists('getSnippets')) {
156 156
     /**
157 157
      * display snippets
158 158
      *
@@ -178,23 +178,23 @@  discard block
 block discarded – undo
178 178
             $_[] = parse($tpl, $ph);
179 179
             $i++;
180 180
         }
181
-        return (0 < count($_)) ? '<h3>[%snippets%]</h3>' . implode("\n", $_) : '';
181
+        return (0 < count($_)) ? '<h3>[%snippets%]</h3>'.implode("\n", $_) : '';
182 182
     }
183 183
 }
184 184
 
185
-switch($installMode){
185
+switch ($installMode) {
186 186
     case 0:
187 187
     case 2:
188 188
         $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci';
189 189
         $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
190 190
         $_POST['database_connection_charset'] = $database_charset;
191
-        if(empty($_SESSION['databaseloginpassword']))
191
+        if (empty($_SESSION['databaseloginpassword']))
192 192
             $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword'];
193
-        if(empty($_SESSION['databaseloginname']))
193
+        if (empty($_SESSION['databaseloginname']))
194 194
             $_SESSION['databaseloginname'] = $_POST['databaseloginname'];
195 195
         break;
196 196
     case 1:
197
-        include $base_path . MGR_DIR . '/includes/config.inc.php';
197
+        include $base_path.MGR_DIR.'/includes/config.inc.php';
198 198
         if (@ $conn = mysqli_connect($database_server, $database_user, $database_password)) {
199 199
             if (@ mysqli_query($conn, "USE {$dbase}")) {
200 200
                 if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 $ph['checked'] = isset ($_POST['installdata']) && $_POST['installdata'] == "1" ? 'checked' : '';
250 250
 
251 251
 # load setup information file
252
-include($base_path . 'install/setup.info.php');
252
+include($base_path.'install/setup.info.php');
253 253
 $ph['templates'] = getTemplates($moduleTemplates);
254 254
 $ph['tvs']       = getTVs($moduleTVs);
255 255
 $ph['chunks']    = getChunks($moduleChunks);
@@ -259,6 +259,6 @@  discard block
 block discarded – undo
259 259
 
260 260
 $ph['action'] = ($installMode == 1) ? 'mode' : 'connection';
261 261
 
262
-$tpl = file_get_contents($base_path . 'install/actions/tpl_options.html');
263
-$content = parse($tpl,$ph);
264
-echo parse($content,$_lang,'[%','%]');
262
+$tpl = file_get_contents($base_path.'install/actions/tpl_options.html');
263
+$content = parse($tpl, $ph);
264
+echo parse($content, $_lang, '[%', '%]');
Please login to merge, or discard this patch.
install/instprocessor.php 1 patch
Spacing   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) {
3 3
     include_once(dirname(__FILE__)."/../assets/cache/siteManager.php");
4
-}else{
4
+} else {
5 5
     define('MGR_DIR', 'manager');
6 6
 }
7 7
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 echo "<p>{$_lang['setup_database']}</p>\n";
30 30
 
31
-$installMode= (int)$_POST['installmode'];
31
+$installMode = (int) $_POST['installmode'];
32 32
 $installData = $_POST['installdata'] == "1" ? 1 : 0;
33 33
 
34 34
 //if ($installMode == 1) {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
43 43
 $database_connection_charset = $_POST['database_connection_charset'];
44 44
 $database_connection_method = $_POST['database_connection_method'];
45
-$dbase = "`" . $_POST['database_name'] . "`";
45
+$dbase = "`".$_POST['database_name']."`";
46 46
 $table_prefix = $_POST['tableprefix'];
47 47
 $adminname = $_POST['cmsadmin'];
48 48
 $adminemail = $_POST['cmsadminemail'];
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 // set session name variable
55 55
 if (!isset ($site_sessionname)) {
56
-    $site_sessionname = 'SN' . uniqid('');
56
+    $site_sessionname = 'SN'.uniqid('');
57 57
 }
58 58
 
59 59
 // get base path and url
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
     array_pop($a);
68 68
 $pth = implode("install", $a);
69 69
 unset ($a);
70
-$base_url = $url . (substr($url, -1) != "/" ? "/" : "");
71
-$base_path = $pth . (substr($pth, -1) != "/" ? "/" : "");
70
+$base_url = $url.(substr($url, -1) != "/" ? "/" : "");
71
+$base_path = $pth.(substr($pth, -1) != "/" ? "/" : "");
72 72
 
73 73
 // connect to the database
74
-echo "<p>". $_lang['setup_database_create_connection'];
74
+echo "<p>".$_lang['setup_database_create_connection'];
75 75
 if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) {
76 76
     echo '<span class="notok">'.$_lang["setup_database_create_connection_failed"]."</span></p><p>".$_lang['setup_database_create_connection_failed_note']."</p>";
77 77
     return;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 }
81 81
 
82 82
 // select database
83
-echo "<p>".$_lang['setup_database_selection']. str_replace("`", "", $dbase) . "`: ";
83
+echo "<p>".$_lang['setup_database_selection'].str_replace("`", "", $dbase)."`: ";
84 84
 if (!mysqli_select_db($conn, str_replace("`", "", $dbase))) {
85 85
     echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>";
86 86
     $create = true;
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 
93 93
 // try to create the database
94 94
 if ($create) {
95
-    echo "<p>".$_lang['setup_database_creation']. str_replace("`", "", $dbase) . "`: ";
95
+    echo "<p>".$_lang['setup_database_creation'].str_replace("`", "", $dbase)."`: ";
96 96
     //	if(!@mysqli_create_db(str_replace("`","",$dbase), $conn)) {
97
-    if (! mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) {
97
+    if (!mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) {
98 98
         echo '<span class="notok">'.$_lang['setup_database_creation_failed']."</span>".$_lang['setup_database_creation_failed_note']."</p>";
99 99
         $errors += 1;
100 100
 ?>
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 
114 114
 // check table prefix
115 115
 if ($installMode == 0) {
116
-    echo "<p>" . $_lang['checking_table_prefix'] . $table_prefix . "`: ";
117
-    if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
118
-        echo '<span class="notok">' . $_lang['failed'] . "</span>" . $_lang['table_prefix_already_inuse'] . "</p>";
116
+    echo "<p>".$_lang['checking_table_prefix'].$table_prefix."`: ";
117
+    if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
118
+        echo '<span class="notok">'.$_lang['failed']."</span>".$_lang['table_prefix_already_inuse']."</p>";
119 119
         $errors += 1;
120
-        echo "<p>" . $_lang['table_prefix_already_inuse_note'] . "</p>";
120
+        echo "<p>".$_lang['table_prefix_already_inuse_note']."</p>";
121 121
         return;
122 122
     } else {
123 123
         echo '<span class="ok">'.$_lang['ok']."</span></p>";
124 124
     }
125 125
 }
126 126
 
127
-if(!function_exists('parseProperties')) {
127
+if (!function_exists('parseProperties')) {
128 128
     /**
129 129
      * parses a resource property string and returns the result as an array
130 130
      * duplicate of method in documentParser class
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
      * @param string $propertyString
133 133
      * @return array
134 134
      */
135
-    function parseProperties($propertyString) {
136
-        $parameter= array ();
135
+    function parseProperties($propertyString){
136
+        $parameter = array();
137 137
         if (!empty ($propertyString)) {
138
-            $tmpParams= explode("&", $propertyString);
138
+            $tmpParams = explode("&", $propertyString);
139 139
             $countParams = count($tmpParams);
140
-            for ($x= 0; $x < $countParams; $x++) {
140
+            for ($x = 0; $x < $countParams; $x++) {
141 141
                 if (strpos($tmpParams[$x], '=', 0)) {
142
-                    $pTmp= explode("=", $tmpParams[$x]);
143
-                    $pvTmp= explode(";", trim($pTmp[1]));
142
+                    $pTmp = explode("=", $tmpParams[$x]);
143
+                    $pvTmp = explode(";", trim($pTmp[1]));
144 144
                     if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
145
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
145
+                        $parameter[trim($pTmp[0])] = $pvTmp[3]; //list default
146 146
                     else
147 147
                         if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
148
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
148
+                            $parameter[trim($pTmp[0])] = $pvTmp[2];
149 149
                 }
150 150
             }
151 151
         }
@@ -156,20 +156,20 @@  discard block
 block discarded – undo
156 156
 // check status of Inherit Parent Template plugin
157 157
 $auto_template_logic = 'parent';
158 158
 if ($installMode != 0) {
159
-    $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'");
159
+    $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`".$table_prefix."site_plugins` WHERE name='Inherit Parent Template'");
160 160
     $row = mysqli_fetch_row($rs);
161
-    if(!$row) {
161
+    if (!$row) {
162 162
         // not installed
163 163
         $auto_template_logic = 'system';
164 164
     } else {
165
-        if($row[1] == 1) {
165
+        if ($row[1] == 1) {
166 166
             // installed but disabled
167 167
             $auto_template_logic = 'system';
168 168
         } else {
169 169
             // installed, enabled .. see how it's configured
170 170
             $properties = parseProperties($row[0]);
171
-            if(isset($properties['inheritTemplate'])) {
172
-                if($properties['inheritTemplate'] == 'From First Sibling') {
171
+            if (isset($properties['inheritTemplate'])) {
172
+                if ($properties['inheritTemplate'] == 'From First Sibling') {
173 173
                     $auto_template_logic = 'sibling';
174 174
                 }
175 175
             }
@@ -193,20 +193,20 @@  discard block
 block discarded – undo
193 193
 $sqlParser->connect();
194 194
 
195 195
 // install/update database
196
-echo "<p>" . $_lang['setup_database_creating_tables'];
196
+echo "<p>".$_lang['setup_database_creating_tables'];
197 197
 if ($moduleSQLBaseFile) {
198 198
     $sqlParser->process($moduleSQLBaseFile);
199 199
     // display database results
200 200
     if ($sqlParser->installFailed == true) {
201 201
         $errors += 1;
202
-        echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>";
203
-        echo "<p>" . $_lang['setup_couldnt_install'] . "</p>";
204
-        echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />";
202
+        echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>";
203
+        echo "<p>".$_lang['setup_couldnt_install']."</p>";
204
+        echo "<p>".$_lang['installation_error_occured']."<br /><br />";
205 205
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
206
-            echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />";
206
+            echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />";
207 207
         }
208 208
         echo "</p>";
209
-        echo "<p>" . $_lang['some_tables_not_updated'] . "</p>";
209
+        echo "<p>".$_lang['some_tables_not_updated']."</p>";
210 210
         return;
211 211
     } else {
212 212
         echo '<span class="ok">'.$_lang['ok']."</span></p>";
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
 // custom or not
217 217
 if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) {
218 218
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
219
-}else{
219
+} else {
220 220
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
221 221
 }
222 222
 
223 223
 // write the config.inc.php file if new installation
224
-echo "<p>" . $_lang['writing_config_file'];
224
+echo "<p>".$_lang['writing_config_file'];
225 225
 
226 226
 $confph = array();
227 227
 $confph['database_server']    = $database_server;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 $chmodSuccess = @chmod($filename, 0404);
254 254
 
255 255
 if ($configFileFailed == true) {
256
-    echo '<span class="notok">' . $_lang['failed'] . "</span></p>";
256
+    echo '<span class="notok">'.$_lang['failed']."</span></p>";
257 257
     $errors += 1;
258 258
 ?>
259 259
     <p><?php echo $_lang['cant_write_config_file']?><span class="mono"><?php echo MGR_DIR; ?>/includes/config.inc.php</span></p>
@@ -270,35 +270,35 @@  discard block
 block discarded – undo
270 270
 // generate new site_id and set manager theme to default
271 271
 if ($installMode == 0) {
272 272
     $siteid = uniqid('');
273
-    mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
273
+    mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
274 274
 } else {
275 275
     // update site_id if missing
276
-    $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'");
276
+    $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`".$table_prefix."system_settings` WHERE setting_name='site_id'");
277 277
     if ($ds) {
278 278
         $r = mysqli_fetch_assoc($ds);
279 279
         $siteid = $r['setting_value'];
280 280
         if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') {
281 281
             $siteid = uniqid('');
282
-            mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
282
+            mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
283 283
         }
284 284
     }
285 285
 }
286 286
 
287 287
 // Reset database for installation of demo-site
288 288
 if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) {
289
-	echo "<p>" . $_lang['resetting_database'];
289
+	echo "<p>".$_lang['resetting_database'];
290 290
 	$sqlParser->process($moduleSQLResetFile);
291 291
 	// display database results
292 292
 	if ($sqlParser->installFailed == true) {
293 293
 		$errors += 1;
294
-		echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>";
295
-		echo "<p>" . $_lang['setup_couldnt_install'] . "</p>";
296
-		echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />";
294
+		echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>";
295
+		echo "<p>".$_lang['setup_couldnt_install']."</p>";
296
+		echo "<p>".$_lang['installation_error_occured']."<br /><br />";
297 297
 		for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
298
-			echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />";
298
+			echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />";
299 299
 		}
300 300
 		echo "</p>";
301
-		echo "<p>" . $_lang['some_tables_not_updated'] . "</p>";
301
+		echo "<p>".$_lang['some_tables_not_updated']."</p>";
302 302
 		return;
303 303
 	} else {
304 304
 		echo '<span class="ok">'.$_lang['ok']."</span></p>";
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
 
308 308
 // Install Templates
309 309
 if (isset ($_POST['template']) || $installData) {
310
-    echo "<h3>" . $_lang['templates'] . ":</h3> ";
310
+    echo "<h3>".$_lang['templates'].":</h3> ";
311 311
     $selTemplates = $_POST['template'];
312 312
     foreach ($moduleTemplates as $k=>$moduleTemplate) {
313 313
         $installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1;
314
-        if($installSample || in_array($k, $selTemplates)) {
314
+        if ($installSample || in_array($k, $selTemplates)) {
315 315
             $name = mysqli_real_escape_string($conn, $moduleTemplate[0]);
316 316
             $desc = mysqli_real_escape_string($conn, $moduleTemplate[1]);
317 317
             $category = mysqli_real_escape_string($conn, $moduleTemplate[4]);
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             $filecontent = $moduleTemplate[3];
320 320
             $save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site
321 321
             if (!file_exists($filecontent)) {
322
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_template'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
322
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">".$_lang['unable_install_template']." '$filecontent' ".$_lang['not_found'].".</span></p>";
323 323
             } else {
324 324
                 // Create the category if it does not already exist
325 325
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -329,31 +329,31 @@  discard block
 block discarded – undo
329 329
                 $template = mysqli_real_escape_string($conn, $template);
330 330
 
331 331
                 // See if the template already exists
332
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'");
332
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name'");
333 333
 
334 334
                 if (mysqli_num_rows($rs)) {
335
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked'  WHERE templatename='$name' LIMIT 1;")) {
335
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked'  WHERE templatename='$name' LIMIT 1;")) {
336 336
                         $errors += 1;
337
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
337
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
338 338
                         return;
339 339
                     }
340
-                    if(!is_null($save_sql_id_as)) {
340
+                    if (!is_null($save_sql_id_as)) {
341 341
                         $sql_id = @mysqli_insert_id($sqlParser->conn);
342
-                        if(!$sql_id) {
343
-                            $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;"));
342
+                        if (!$sql_id) {
343
+                            $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name' LIMIT 1;"));
344 344
                             $sql_id = $idQuery['id'];
345 345
                         }
346 346
                         $custom_placeholders[$save_sql_id_as] = $sql_id;
347 347
                     }
348
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
348
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
349 349
                 } else {
350
-                    if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) {
350
+                    if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) {
351 351
                         $errors += 1;
352
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
352
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
353 353
                         return;
354 354
                     }
355
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
356
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
355
+                    if (!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
356
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
357 357
                 }
358 358
             }
359 359
         }
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
 
363 363
 // Install Template Variables
364 364
 if (isset ($_POST['tv']) || $installData) {
365
-    echo "<h3>" . $_lang['tvs'] . ":</h3> ";
365
+    echo "<h3>".$_lang['tvs'].":</h3> ";
366 366
     $selTVs = $_POST['tv'];
367 367
     foreach ($moduleTVs as $k=>$moduleTV) {
368 368
         $installSample = in_array('sample', $moduleTV[12]) && $installData == 1;
369
-        if($installSample || in_array($k, $selTVs)) {
369
+        if ($installSample || in_array($k, $selTVs)) {
370 370
             $name = mysqli_real_escape_string($conn, $moduleTV[0]);
371 371
             $caption = mysqli_real_escape_string($conn, $moduleTV[1]);
372 372
             $desc = mysqli_real_escape_string($conn, $moduleTV[2]);
@@ -384,25 +384,25 @@  discard block
 block discarded – undo
384 384
             // Create the category if it does not already exist
385 385
             $category = getCreateDbCategory($category, $sqlParser);
386 386
 
387
-            $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'");
387
+            $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name'");
388 388
             if (mysqli_num_rows($rs)) {
389 389
                 $insert = true;
390
-                while($row = mysqli_fetch_assoc($rs)) {
391
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) {
392
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
390
+                while ($row = mysqli_fetch_assoc($rs)) {
391
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) {
392
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
393 393
                         return;
394 394
                     }
395 395
                     $insert = false;
396 396
                 }
397
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
397
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
398 398
             } else {
399 399
                 //$q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',(SELECT (CASE COUNT(*) WHEN 0 THEN 0 ELSE `id` END) `id` FROM $dbase.`" . $table_prefix . "categories` WHERE `category` = '$category'),$locked,'$input_options','$output_widget','$output_widget_params','$input_default');";
400
-                $q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');";
400
+                $q = "INSERT INTO $dbase.`".$table_prefix."site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');";
401 401
                 if (!mysqli_query($sqlParser->conn, $q)) {
402
-                    echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
402
+                    echo "<p>".mysqli_error($sqlParser->conn)."</p>";
403 403
                     return;
404 404
                 }
405
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
405
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
406 406
             }
407 407
 
408 408
             // add template assignments
@@ -411,10 +411,10 @@  discard block
 block discarded – undo
411 411
             if (count($assignments) > 0) {
412 412
 
413 413
                 // remove existing tv -> template assignments
414
-                $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
414
+                $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
415 415
                 $row = mysqli_fetch_assoc($ds);
416 416
                 $id = $row["id"];
417
-                mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\'');
417
+                mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_tmplvar_templates` WHERE tmplvarid = \''.$id.'\'');
418 418
 
419 419
                 // add tv -> template assignments
420 420
                 foreach ($assignments as $assignment) {
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
                     if ($ds && $ts) {
424 424
                         $tRow = mysqli_fetch_assoc($ts);
425 425
                         $templateId = $tRow['id'];
426
-                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
426
+                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
427 427
                    }
428 428
                 }
429 429
             }
@@ -433,12 +433,12 @@  discard block
 block discarded – undo
433 433
 
434 434
 // Install Chunks
435 435
 if (isset ($_POST['chunk']) || $installData) {
436
-    echo "<h3>" . $_lang['chunks'] . ":</h3> ";
436
+    echo "<h3>".$_lang['chunks'].":</h3> ";
437 437
     $selChunks = $_POST['chunk'];
438 438
     foreach ($moduleChunks as $k=>$moduleChunk) {
439 439
         $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1;
440 440
         $count_new_name = 0;
441
-        if($installSample || in_array($k, $selChunks)) {
441
+        if ($installSample || in_array($k, $selChunks)) {
442 442
 
443 443
             $name = mysqli_real_escape_string($conn, $moduleChunk[0]);
444 444
             $desc = mysqli_real_escape_string($conn, $moduleChunk[1]);
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             $filecontent = $moduleChunk[2];
448 448
 
449 449
             if (!file_exists($filecontent))
450
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
450
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">".$_lang['unable_install_chunk']." '$filecontent' ".$_lang['not_found'].".</span></p>";
451 451
             else {
452 452
 
453 453
                 // Create the category if it does not already exist
@@ -455,31 +455,31 @@  discard block
 block discarded – undo
455 455
 
456 456
                 $chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1);
457 457
                 $chunk = mysqli_real_escape_string($conn, $chunk);
458
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'");
458
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$name'");
459 459
                 $count_original_name = mysqli_num_rows($rs);
460
-                if($overwrite == 'false') {
461
-                    $newname = $name . '-' . str_replace('.', '_', $modx_version);
462
-                    $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'");
460
+                if ($overwrite == 'false') {
461
+                    $newname = $name.'-'.str_replace('.', '_', $modx_version);
462
+                    $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$newname'");
463 463
                     $count_new_name = mysqli_num_rows($rs);
464 464
                 }
465 465
                 $update = $count_original_name > 0 && $overwrite == 'true';
466 466
                 if ($update) {
467
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
467
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
468 468
                         $errors += 1;
469
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
469
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
470 470
                         return;
471 471
                     }
472
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
473
-                } elseif($count_new_name == 0) {
474
-                    if($count_original_name > 0 && $overwrite == 'false') {
472
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
473
+                } elseif ($count_new_name == 0) {
474
+                    if ($count_original_name > 0 && $overwrite == 'false') {
475 475
                         $name = $newname;
476 476
                     }
477
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) {
477
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) {
478 478
                         $errors += 1;
479
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
479
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
480 480
                         return;
481 481
                     }
482
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
482
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
483 483
                 }
484 484
             }
485 485
         }
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
 
489 489
 // Install Modules
490 490
 if (isset ($_POST['module']) || $installData) {
491
-    echo "<h3>" . $_lang['modules'] . ":</h3> ";
491
+    echo "<h3>".$_lang['modules'].":</h3> ";
492 492
     $selModules = $_POST['module'];
493 493
     foreach ($moduleModules as $k=>$moduleModule) {
494 494
         $installSample = in_array('sample', $moduleModule[7]) && $installData == 1;
495
-        if($installSample || in_array($k, $selModules)) {
495
+        if ($installSample || in_array($k, $selModules)) {
496 496
             $name = mysqli_real_escape_string($conn, $moduleModule[0]);
497 497
             $desc = mysqli_real_escape_string($conn, $moduleModule[1]);
498 498
             $filecontent = $moduleModule[2];
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
502 502
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
503 503
             if (!file_exists($filecontent))
504
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
504
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">".$_lang['unable_install_module']." '$filecontent' ".$_lang['not_found'].".</span></p>";
505 505
             else {
506 506
 
507 507
                 // Create the category if it does not already exist
@@ -510,22 +510,22 @@  discard block
 block discarded – undo
510 510
                 $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
511 511
                 // $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab
512 512
                 $module = mysqli_real_escape_string($conn, $module);
513
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'");
513
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_modules` WHERE name='$name'");
514 514
                 if (mysqli_num_rows($rs)) {
515 515
                     $row = mysqli_fetch_assoc($rs);
516
-                    $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
517
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
518
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
516
+                    $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
517
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
518
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
519 519
                         return;
520 520
                     }
521
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
521
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
522 522
                 } else {
523 523
                     $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
524
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) {
525
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
524
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) {
525
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
526 526
                         return;
527 527
                     }
528
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
528
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
529 529
                 }
530 530
             }
531 531
         }
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
 
535 535
 // Install Plugins
536 536
 if (isset ($_POST['plugin']) || $installData) {
537
-    echo "<h3>" . $_lang['plugins'] . ":</h3> ";
537
+    echo "<h3>".$_lang['plugins'].":</h3> ";
538 538
     $selPlugs = $_POST['plugin'];
539 539
     foreach ($modulePlugins as $k=>$modulePlugin) {
540 540
         $installSample = in_array('sample', $modulePlugin[8]) && $installData == 1;
541
-        if($installSample || in_array($k, $selPlugs)) {
541
+        if ($installSample || in_array($k, $selPlugs)) {
542 542
             $name = mysqli_real_escape_string($conn, $modulePlugin[0]);
543 543
             $desc = mysqli_real_escape_string($conn, $modulePlugin[1]);
544 544
             $filecontent = $modulePlugin[2];
@@ -548,17 +548,17 @@  discard block
 block discarded – undo
548 548
             $category = mysqli_real_escape_string($conn, $modulePlugin[6]);
549 549
             $leg_names = '';
550 550
             $disabled = $modulePlugin[9];
551
-            if(array_key_exists(7, $modulePlugin)) {
551
+            if (array_key_exists(7, $modulePlugin)) {
552 552
                 // parse comma-separated legacy names and prepare them for sql IN clause
553
-                $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
553
+                $leg_names = "'".implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7])))."'";
554 554
             }
555 555
             if (!file_exists($filecontent))
556
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
556
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">".$_lang['unable_install_plugin']." '$filecontent' ".$_lang['not_found'].".</span></p>";
557 557
             else {
558 558
 
559 559
                 // disable legacy versions based on legacy_names provided
560
-                if(!empty($leg_names)) {
561
-                    $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
560
+                if (!empty($leg_names)) {
561
+                    $update_query = "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
562 562
                     $rs = mysqli_query($sqlParser->conn, $update_query);
563 563
                 }
564 564
 
@@ -568,50 +568,50 @@  discard block
 block discarded – undo
568 568
                 $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
569 569
                 $plugin = removeDocblock($plugin, 'plugin');
570 570
                 $plugin = mysqli_real_escape_string($conn, $plugin);
571
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'");
571
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name'");
572 572
                 if (mysqli_num_rows($rs)) {
573 573
                     $insert = true;
574
-                    while($row = mysqli_fetch_assoc($rs)) {
575
-                        $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
576
-                        if($row['description'] == $desc){
577
-                            if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
578
-                                echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
574
+                    while ($row = mysqli_fetch_assoc($rs)) {
575
+                        $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
576
+                        if ($row['description'] == $desc) {
577
+                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
578
+                                echo "<p>".mysqli_error($sqlParser->conn)."</p>";
579 579
                                 return;
580 580
                             }
581 581
                             $insert = false;
582 582
                         } else {
583
-                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
583
+                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
584 584
                                 echo "<p>".mysqli_error($sqlParser->conn)."</p>";
585 585
                                 return;
586 586
                             }
587 587
                         }
588 588
                     }
589
-                    if($insert === true) {
590
-                        $properties = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
591
-                        if(!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) {
589
+                    if ($insert === true) {
590
+                        $properties = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
591
+                        if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) {
592 592
                             echo "<p>".mysqli_error($sqlParser->conn)."</p>";
593 593
                             return;
594 594
                         }
595 595
                     }
596
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
596
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
597 597
                 } else {
598 598
                     $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
599
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) {
600
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
599
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) {
600
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
601 601
                         return;
602 602
                     }
603
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
603
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
604 604
                 }
605 605
                 // add system events
606 606
                 if (count($events) > 0) {
607
-                    $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';");
607
+                    $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';");
608 608
                     if ($ds) {
609 609
                         $row = mysqli_fetch_assoc($ds);
610 610
                         $id = $row["id"];
611 611
                         // remove existing events
612
-                        mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_plugin_events` WHERE pluginid = \'' . $id . '\'');
612
+                        mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_plugin_events` WHERE pluginid = \''.$id.'\'');
613 613
                         // add new events
614
-                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`" . $table_prefix . "system_eventnames` se WHERE name IN ('" . implode("','", $events) . "')");
614
+                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`".$table_prefix."system_eventnames` se WHERE name IN ('".implode("','", $events)."')");
615 615
                     }
616 616
                 }
617 617
             }
@@ -621,18 +621,18 @@  discard block
 block discarded – undo
621 621
 
622 622
 // Install Snippets
623 623
 if (isset ($_POST['snippet']) || $installData) {
624
-    echo "<h3>" . $_lang['snippets'] . ":</h3> ";
624
+    echo "<h3>".$_lang['snippets'].":</h3> ";
625 625
     $selSnips = $_POST['snippet'];
626 626
     foreach ($moduleSnippets as $k=>$moduleSnippet) {
627 627
         $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1;
628
-        if($installSample || in_array($k, $selSnips)) {
628
+        if ($installSample || in_array($k, $selSnips)) {
629 629
             $name = mysqli_real_escape_string($conn, $moduleSnippet[0]);
630 630
             $desc = mysqli_real_escape_string($conn, $moduleSnippet[1]);
631 631
             $filecontent = $moduleSnippet[2];
632 632
             $properties = $moduleSnippet[3];
633 633
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
634 634
             if (!file_exists($filecontent))
635
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
635
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">".$_lang['unable_install_snippet']." '$filecontent' ".$_lang['not_found'].".</span></p>";
636 636
             else {
637 637
 
638 638
                 // Create the category if it does not already exist
@@ -641,22 +641,22 @@  discard block
 block discarded – undo
641 641
                 $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent)));
642 642
                 $snippet = removeDocblock($snippet, 'snippet');
643 643
                 $snippet = mysqli_real_escape_string($conn, $snippet);
644
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'");
644
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_snippets` WHERE name='$name'");
645 645
                 if (mysqli_num_rows($rs)) {
646 646
                     $row = mysqli_fetch_assoc($rs);
647
-                    $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
648
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
649
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
647
+                    $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
648
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
649
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
650 650
                         return;
651 651
                     }
652
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
652
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
653 653
                 } else {
654 654
                     $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
655
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
656
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
655
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
656
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
657 657
                         return;
658 658
                     }
659
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
659
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
660 660
                 }
661 661
             }
662 662
         }
@@ -665,24 +665,24 @@  discard block
 block discarded – undo
665 665
 
666 666
 // Install demo-site
667 667
 if ($installData && $moduleSQLDataFile) {
668
-    echo "<p>" . $_lang['installing_demo_site'];
668
+    echo "<p>".$_lang['installing_demo_site'];
669 669
     $sqlParser->process($moduleSQLDataFile);
670 670
     // display database results
671 671
     if ($sqlParser->installFailed == true) {
672 672
         $errors += 1;
673
-        echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>";
674
-        echo "<p>" . $_lang['setup_couldnt_install'] . "</p>";
675
-        echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />";
673
+        echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>";
674
+        echo "<p>".$_lang['setup_couldnt_install']."</p>";
675
+        echo "<p>".$_lang['installation_error_occured']."<br /><br />";
676 676
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
677
-            echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />";
677
+            echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />";
678 678
         }
679 679
         echo "</p>";
680
-        echo "<p>" . $_lang['some_tables_not_updated'] . "</p>";
680
+        echo "<p>".$_lang['some_tables_not_updated']."</p>";
681 681
         return;
682 682
     } else {
683 683
         $sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", $sqlParser->prefix);
684 684
         $rs = mysqli_query($sqlParser->conn, $sql);
685
-        if(mysqli_num_rows($rs)) {
685
+        if (mysqli_num_rows($rs)) {
686 686
             $row = mysqli_fetch_assoc($rs);
687 687
             $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']);
688 688
             mysqli_query($sqlParser->conn, $sql);
@@ -693,9 +693,9 @@  discard block
 block discarded – undo
693 693
 
694 694
 // Install Dependencies
695 695
 foreach ($moduleDependencies as $dependency) {
696
-	$ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"');
696
+	$ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM '.$dbase.'`'.$sqlParser->prefix.'site_modules` WHERE name="'.$dependency['module'].'"');
697 697
 	if (!$ds) {
698
-		echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
698
+		echo "<p>".mysqli_error($sqlParser->conn)."</p>";
699 699
 		return;
700 700
 	} else {
701 701
 		$row = mysqli_fetch_assoc($ds);
@@ -703,37 +703,37 @@  discard block
 block discarded – undo
703 703
 		$moduleGuid = $row["guid"];
704 704
 	}
705 705
 	// get extra id
706
-	$ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"');
706
+	$ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE '.$dependency['column'].'="'.$dependency['name'].'"');
707 707
 	if (!$ds) {
708
-		echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
708
+		echo "<p>".mysqli_error($sqlParser->conn)."</p>";
709 709
 		return;
710 710
 	} else {
711 711
 		$row = mysqli_fetch_assoc($ds);
712 712
 		$extraId = $row["id"];
713 713
 	}
714 714
 	// setup extra as module dependency
715
-	$ds = mysqli_query($sqlParser->conn, 'SELECT module FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type'] . ' LIMIT 1');
715
+	$ds = mysqli_query($sqlParser->conn, 'SELECT module FROM '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` WHERE module='.$moduleId.' AND resource='.$extraId.' AND type='.$dependency['type'].' LIMIT 1');
716 716
 	if (!$ds) {
717
-		echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
717
+		echo "<p>".mysqli_error($sqlParser->conn)."</p>";
718 718
 		return;
719 719
 	} else {
720 720
 		if (mysqli_num_rows($ds) === 0) {
721
-			mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')');
722
-			echo '<p>&nbsp;&nbsp;' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_create'] . '</span></p>';
721
+			mysqli_query($sqlParser->conn, 'INSERT INTO '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` (module, resource, type) VALUES('.$moduleId.','.$extraId.','.$dependency['type'].')');
722
+			echo '<p>&nbsp;&nbsp;'.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_create'].'</span></p>';
723 723
 		} else {
724
-			mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` SET module = ' . $moduleId . ', resource = ' . $extraId . ', type = ' . $dependency['type'] . ' WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type']);
725
-			echo '<p>&nbsp;&nbsp;' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_update'] . '</span></p>';
724
+			mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` SET module = '.$moduleId.', resource = '.$extraId.', type = '.$dependency['type'].' WHERE module='.$moduleId.' AND resource='.$extraId.' AND type='.$dependency['type']);
725
+			echo '<p>&nbsp;&nbsp;'.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_update'].'</span></p>';
726 726
 		}
727 727
 		if ($dependency['type'] == 30 || $dependency['type'] == 40) {
728 728
 			// set extra guid for plugins and snippets
729
-			$ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1');
729
+			$ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE id='.$extraId.' LIMIT 1');
730 730
 			if (!$ds) {
731
-				echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
731
+				echo "<p>".mysqli_error($sqlParser->conn)."</p>";
732 732
 				return;
733 733
 			} else {
734 734
 				if (mysqli_num_rows($ds) != 0) {
735
-					mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId);
736
-					echo '<p>&nbsp;&nbsp;' . $dependency['name'] . ': <span class="ok">' . $_lang['guid_set'] . '</span></p>';
735
+					mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` SET moduleguid = '.$moduleGuid.' WHERE id='.$extraId);
736
+					echo '<p>&nbsp;&nbsp;'.$dependency['name'].': <span class="ok">'.$_lang['guid_set'].'</span></p>';
737 737
 				}
738 738
 			}
739 739
 		}
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 
743 743
 // call back function
744 744
 if ($callBackFnc != "")
745
-    $callBackFnc ($sqlParser);
745
+    $callBackFnc($sqlParser);
746 746
 
747 747
 // Setup the MODX API -- needed for the cache processor
748 748
 define('MODX_API_MODE', true);
@@ -777,12 +777,12 @@  discard block
 block discarded – undo
777 777
 }
778 778
 
779 779
 // setup completed!
780
-echo "<p><b>" . $_lang['installation_successful'] . "</b></p>";
781
-echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>";
780
+echo "<p><b>".$_lang['installation_successful']."</b></p>";
781
+echo "<p>".$_lang['to_log_into_content_manager']."</p>";
782 782
 if ($installMode == 0) {
783
-    echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['installation_note'] . "</p>";
783
+    echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['installation_note']."</p>";
784 784
 } else {
785
-    echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['upgrade_note'] . "</p>";
785
+    echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['upgrade_note']."</p>";
786 786
 }
787 787
 
788 788
 /**
@@ -792,11 +792,11 @@  discard block
 block discarded – undo
792 792
  * @param string $old
793 793
  * @return string
794 794
  */
795
-function propUpdate($new,$old){
795
+function propUpdate($new, $old){
796 796
     $newArr = parseProperties($new);
797 797
     $oldArr = parseProperties($old);
798
-    foreach ($oldArr as $k => $v){
799
-        if (isset($v['0']['options'])){
798
+    foreach ($oldArr as $k => $v) {
799
+        if (isset($v['0']['options'])) {
800 800
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
801 801
         }
802 802
     }
@@ -811,30 +811,30 @@  discard block
 block discarded – undo
811 811
  * @param bool|mixed $json
812 812
  * @return string
813 813
  */
814
-function parseProperties($propertyString, $json=false) {
815
-    $propertyString = str_replace('{}', '', $propertyString );
816
-    $propertyString = str_replace('} {', ',', $propertyString );
814
+function parseProperties($propertyString, $json = false){
815
+    $propertyString = str_replace('{}', '', $propertyString);
816
+    $propertyString = str_replace('} {', ',', $propertyString);
817 817
 
818
-    if(empty($propertyString)) return array();
819
-    if($propertyString=='{}' || $propertyString=='[]') return array();
818
+    if (empty($propertyString)) return array();
819
+    if ($propertyString == '{}' || $propertyString == '[]') return array();
820 820
 
821 821
     $jsonFormat = isJson($propertyString, true);
822 822
     $property = array();
823 823
     // old format
824
-    if ( $jsonFormat === false) {
825
-        $props= explode('&', $propertyString);
824
+    if ($jsonFormat === false) {
825
+        $props = explode('&', $propertyString);
826 826
         foreach ($props as $prop) {
827 827
             $prop = trim($prop);
828
-            if($prop === '') {
828
+            if ($prop === '') {
829 829
                 continue;
830 830
             }
831 831
 
832 832
             $arr = explode(';', $prop);
833
-            if( ! is_array($arr)) {
833
+            if (!is_array($arr)) {
834 834
                 $arr = array();
835 835
             }
836 836
             $key = explode('=', isset($arr[0]) ? $arr[0] : '');
837
-            if( ! is_array($key) || empty($key[0])) {
837
+            if (!is_array($key) || empty($key[0])) {
838 838
                 continue;
839 839
             }
840 840
 
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 
859 859
         }
860 860
     // new json-format
861
-    } else if(!empty($jsonFormat)){
861
+    } else if (!empty($jsonFormat)) {
862 862
         $property = $jsonFormat;
863 863
     }
864 864
     if ($json) {
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
  * @param bool $returnData
874 874
  * @return bool|mixed
875 875
  */
876
-function isJson($string, $returnData=false) {
876
+function isJson($string, $returnData = false){
877 877
     $data = json_decode($string, true);
878 878
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
879 879
 }
@@ -883,20 +883,20 @@  discard block
 block discarded – undo
883 883
  * @param SqlParser $sqlParser
884 884
  * @return int
885 885
  */
886
-function getCreateDbCategory($category, $sqlParser) {
886
+function getCreateDbCategory($category, $sqlParser){
887 887
     $dbase = $sqlParser->dbname;
888
-    $dbase = '`' . trim($dbase,'`') . '`';
888
+    $dbase = '`'.trim($dbase, '`').'`';
889 889
     $table_prefix = $sqlParser->prefix;
890 890
     $category_id = 0;
891
-    if(!empty($category)) {
891
+    if (!empty($category)) {
892 892
         $category = mysqli_real_escape_string($sqlParser->conn, $category);
893 893
         $rs = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."categories` WHERE category = '".$category."'");
894
-        if(mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) {
894
+        if (mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) {
895 895
             $category_id = $row['id'];
896 896
         } else {
897 897
             $q = "INSERT INTO $dbase.`".$table_prefix."categories` (`category`) VALUES ('{$category}');";
898 898
             $rs = mysqli_query($sqlParser->conn, $q);
899
-            if($rs) {
899
+            if ($rs) {
900 900
                 $category_id = mysqli_insert_id($sqlParser->conn);
901 901
             }
902 902
         }
@@ -911,12 +911,12 @@  discard block
 block discarded – undo
911 911
  * @param string $type
912 912
  * @return string
913 913
  */
914
-function removeDocblock($code, $type) {
914
+function removeDocblock($code, $type){
915 915
 
916 916
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
917 917
 
918 918
     // Procedure taken from plugin.filesource.php
919
-    switch($type) {
919
+    switch ($type) {
920 920
         case 'snippet':
921 921
             $elm_name = 'snippets';
922 922
             $include = 'return require';
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
         default:
933 933
             return $cleaned;
934 934
     };
935
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
935
+    if (substr(trim($cleaned), 0, $count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
936 936
         return $cleaned;
937 937
 
938 938
     // fileBinding not found - return code incl docblock
Please login to merge, or discard this patch.