Completed
Push — develop ( e6bcf2...351294 )
by Dmytro
06:18
created
install/actions/action_mode.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Determine upgradeability
3 3
 $upgradeable = 0;
4
-if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) { // Include the file so we can test its validity
5
-    include_once $base_path . MGR_DIR . '/includes/config.inc.php';
4
+if (is_file($base_path.MGR_DIR.'/includes/config.inc.php')) { // Include the file so we can test its validity
5
+    include_once $base_path.MGR_DIR.'/includes/config.inc.php';
6 6
     // We need to have all connection settings - tho prefix may be empty so we have to ignore it
7 7
     if (isset($dbase)) {
8 8
         if (!$conn = @mysqli_connect($database_server, $database_user, $database_password))
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
 }
18 18
 
19 19
 $ph['moduleName']       = $moduleName;
20
-$ph['displayNew']       = ($upgradeable!=0) ? 'display:none;' : '';
21
-$ph['displayUpg']       = ($upgradeable==0) ? 'display:none;' : '';
20
+$ph['displayNew']       = ($upgradeable != 0) ? 'display:none;' : '';
21
+$ph['displayUpg']       = ($upgradeable == 0) ? 'display:none;' : '';
22 22
 $ph['displayAdvUpg']    = $ph['displayUpg'];
23
-$ph['checkedNew']       = !$upgradeable     ? 'checked' : '';
24
-$ph['checkedUpg']       = ($_POST['installmode']==1 || $upgradeable==1) ? 'checked' : '';
25
-$ph['checkedAdvUpg']    = ($_POST['installmode']==2 || $upgradeable==2) ? 'checked' : '';
23
+$ph['checkedNew']       = !$upgradeable ? 'checked' : '';
24
+$ph['checkedUpg']       = ($_POST['installmode'] == 1 || $upgradeable == 1) ? 'checked' : '';
25
+$ph['checkedAdvUpg']    = ($_POST['installmode'] == 2 || $upgradeable == 2) ? 'checked' : '';
26 26
 $ph['install_language'] = $install_language;
27
-$ph['disabledUpg']      = ($upgradeable!=1) ? 'disabled' : '';
28
-$ph['disabledAdvUpg']   = ($upgradeable==0) ? 'disabled' : '';
27
+$ph['disabledUpg']      = ($upgradeable != 1) ? 'disabled' : '';
28
+$ph['disabledAdvUpg']   = ($upgradeable == 0) ? 'disabled' : '';
29 29
 
30
-$tpl = file_get_contents($base_path . 'install/actions/tpl_mode.html');
30
+$tpl = file_get_contents($base_path.'install/actions/tpl_mode.html');
31 31
 $content = parse($tpl, $ph);
32
-echo parse($content, $_lang,'[%','%]');
32
+echo parse($content, $_lang, '[%', '%]');
Please login to merge, or discard this patch.
Braces   +12 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,20 +1,22 @@
 block discarded – undo
1 1
 <?php
2 2
 // Determine upgradeability
3 3
 $upgradeable = 0;
4
-if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) { // Include the file so we can test its validity
4
+if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) {
5
+// Include the file so we can test its validity
5 6
     include_once $base_path . MGR_DIR . '/includes/config.inc.php';
6 7
     // We need to have all connection settings - tho prefix may be empty so we have to ignore it
7 8
     if (isset($dbase)) {
8
-        if (!$conn = @mysqli_connect($database_server, $database_user, $database_password))
9
-            $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2;
10
-        elseif (!@mysqli_select_db($conn, trim($dbase, '`')))
11
-            $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2;
12
-        else
13
-            $upgradeable = 1;
9
+        if (!$conn = @mysqli_connect($database_server, $database_user, $database_password)) {
10
+                    $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2;
11
+        } elseif (!@mysqli_select_db($conn, trim($dbase, '`'))) {
12
+                    $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2;
13
+        } else {
14
+                    $upgradeable = 1;
15
+        }
16
+    } else {
17
+            $upgradeable = 2;
18
+    }
14 19
     }
15
-    else
16
-        $upgradeable = 2;
17
-}
18 20
 
19 21
 $ph['moduleName']       = $moduleName;
20 22
 $ph['displayNew']       = ($upgradeable!=0) ? 'display:none;' : '';
Please login to merge, or discard this patch.
manager/actions/help/version_notices/1.3.6.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 ?>
Please login to merge, or discard this patch.
manager/actions/help/version_notices/1.4.1.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 ?>
Please login to merge, or discard this patch.
manager/actions/help/version_notices/1.4.0.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 ?>
Please login to merge, or discard this patch.
install/cli-install.php 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@
 block discarded – undo
130 130
      * duplicate of method in documentParser class
131 131
      *
132 132
      * @param string $propertyString
133
-     * @return array
133
+     * @return string
134 134
      */
135 135
     function parseProperties($propertyString) {
136 136
         $parameter= array ();
Please login to merge, or discard this patch.
Upper-Lower-Casing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 
270 270
 
271 271
 // make sure we can use the database
272
-if ($installMode > 0 && !mysqli_query($conn, "USE {$dbase}")) {
272
+if ($installMode > 0 && !mysqli_query($conn, "use {$dbase}")) {
273 273
     $errors++;
274 274
     echo $_lang['database_use_failed'].PHP_EOL;
275 275
 }
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
                 $params['modx_category'],
574 574
                 $params['lock_template'],
575 575
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false,
576
-                isset($params['save_sql_id_as']) ? $params['save_sql_id_as'] : NULL // Nessecary to fix template-ID for demo-site
576
+                isset($params['save_sql_id_as']) ? $params['save_sql_id_as'] : null // Nessecary to fix template-ID for demo-site
577 577
             );
578 578
         }
579 579
     }
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 }
950 950
 
951 951
 // write $somecontent to our opened file.
952
-if (@ fwrite($handle, $configString) === FALSE) {
952
+if (@ fwrite($handle, $configString) === false) {
953 953
     $configFileFailed = true;
954 954
 }
955 955
 @ fclose($handle);
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
                 $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'");
1042 1042
 
1043 1043
                 if (mysqli_num_rows($rs)) {
1044
-                    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;")) {
1044
+                    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;")) {
1045 1045
                         $errors += 1;
1046 1046
                         echo mysqli_error($sqlParser->conn) . PHP_EOL;
1047 1047
                         return;
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
             if (mysqli_num_rows($rs)) {
1099 1099
                 $insert = true;
1100 1100
                 while($row = mysqli_fetch_assoc($rs)) {
1101
-                    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']};")) {
1101
+                    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']};")) {
1102 1102
                         echo mysqli_error($sqlParser->conn) . PHP_EOL;
1103 1103
                         return;
1104 1104
                     }
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
                 }
1175 1175
                 $update = $count_original_name > 0 && $overwrite == 'true';
1176 1176
                 if ($update) {
1177
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
1177
+                    if (!mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
1178 1178
                         $errors += 1;
1179 1179
                         echo mysqli_error($sqlParser->conn) . PHP_EOL;
1180 1180
                         return;
@@ -1225,13 +1225,13 @@  discard block
 block discarded – undo
1225 1225
                 if (mysqli_num_rows($rs)) {
1226 1226
                     $row = mysqli_fetch_assoc($rs);
1227 1227
                     $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1228
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
1228
+                    if (!mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
1229 1229
                         echo mysqli_error($sqlParser->conn) . PHP_EOL;
1230 1230
                         return;
1231 1231
                     }
1232 1232
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1233 1233
                 } else {
1234
-                    if ($properties != NULL ){
1234
+                    if ($properties != null ){
1235 1235
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1236 1236
                     }
1237 1237
                     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);")) {
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 
1273 1273
                 // disable legacy versions based on legacy_names provided
1274 1274
                 if(!empty($leg_names)) {
1275
-                    $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
1275
+                    $update_query = "update $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
1276 1276
                     $rs = mysqli_query($sqlParser->conn, $update_query);
1277 1277
                 }
1278 1278
 
@@ -1288,13 +1288,13 @@  discard block
 block discarded – undo
1288 1288
                     while($row = mysqli_fetch_assoc($rs)) {
1289 1289
                         $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1290 1290
                         if($row['description'] == $desc){
1291
-                            if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1291
+                            if (! mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1292 1292
                                 echo mysqli_error($sqlParser->conn) . PHP_EOL;
1293 1293
                                 return;
1294 1294
                             }
1295 1295
                             $insert = false;
1296 1296
                         } else {
1297
-                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
1297
+                            if (!mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
1298 1298
                                 echo mysqli_error($sqlParser->conn).PHP_EOL;
1299 1299
                                 return;
1300 1300
                             }
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
                     }
1310 1310
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1311 1311
                 } else {
1312
-                    if ($properties != NULL ){
1312
+                    if ($properties != null ){
1313 1313
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1314 1314
                     }
1315 1315
                     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);")) {
@@ -1362,13 +1362,13 @@  discard block
 block discarded – undo
1362 1362
                 if (mysqli_num_rows($rs)) {
1363 1363
                     $row = mysqli_fetch_assoc($rs);
1364 1364
                     $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1365
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
1365
+                    if (!mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
1366 1366
                         echo mysqli_error($sqlParser->conn) . PHP_EOL;
1367 1367
                         return;
1368 1368
                     }
1369 1369
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1370 1370
                 } else {
1371
-                    if ($properties != NULL ){
1371
+                    if ($properties != null ){
1372 1372
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1373 1373
                     }
1374 1374
                     if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
         echo $_lang['failed'] . ' ' . $_lang['table_prefix_not_exist'] . PHP_EOL;
340 340
         $errors++;
341 341
 
342
-  } else {
342
+    } else {
343 343
         echo $_lang['ok'] . PHP_EOL;
344
-  }
344
+    }
345 345
 }
346 346
 
347 347
 // check mysql version
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
                         $tRow = mysqli_fetch_assoc($ts);
1163 1163
                         $templateId = $tRow['id'];
1164 1164
                         mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
1165
-                   }
1165
+                    }
1166 1166
                 }
1167 1167
             }
1168 1168
         }
@@ -1527,9 +1527,9 @@  discard block
 block discarded – undo
1527 1527
 echo PHP_EOL . $_lang['installation_successful'] . PHP_EOL . PHP_EOL;
1528 1528
 //echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>";
1529 1529
 if ($installMode == 0) {
1530
-   echo strip_tags($_lang['installation_note']) . PHP_EOL;
1530
+    echo strip_tags($_lang['installation_note']) . PHP_EOL;
1531 1531
 } else {
1532
-   echo strip_tags($_lang['upgrade_note']) . PHP_EOL;
1532
+    echo strip_tags($_lang['upgrade_note']) . PHP_EOL;
1533 1533
 }
1534 1534
 
1535 1535
 
Please login to merge, or discard this patch.
Braces   +98 added lines, -66 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 $args = array_slice($argv, 1);
59 59
 
60
-if ( empty($args) ){
60
+if ( empty($args) ) {
61 61
     echo 'Install Evolution CMS'.PHP_EOL;
62 62
     //$installYes = readline("Type 'y' to continue: ");
63 63
     //if ($installYes != 'y') return;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     $managerlanguage = readline('Мanager language:' . ' [en] ');
77 77
     $installData = readline('Instal demo-site (y/n):' . ' [n] ');
78 78
     
79
-}else{
79
+} else {
80 80
     
81 81
     $cli_variables = [];
82 82
     foreach ($args as $arg) {
@@ -130,21 +130,24 @@  discard block
 block discarded – undo
130 130
 }
131 131
 
132 132
 //////////////////////////////////////////////////////////////////////////////////////
133
-if( ! function_exists('f_owc')){
133
+if( ! function_exists('f_owc')) {
134 134
     /**
135 135
      * @param $path
136 136
      * @param $data
137 137
      * @param null|int $mode
138 138
      */
139
-    function f_owc($path, $data, $mode = null){
139
+    function f_owc($path, $data, $mode = null)
140
+    {
140 141
         try {
141 142
             // make an attempt to create the file
142 143
             $hnd = fopen($path, 'w');
143 144
             fwrite($hnd, $data);
144 145
             fclose($hnd);
145 146
 
146
-            if(null !== $mode) chmod($path, $mode);
147
-        }catch(Exception $e){
147
+            if(null !== $mode) {
148
+                chmod($path, $mode);
149
+            }
150
+        } catch(Exception $e) {
148 151
             // Nothing, this is NOT normal
149 152
             unset($e);
150 153
         }
@@ -210,7 +213,7 @@  discard block
 block discarded – undo
210 213
 
211 214
 // File Browser directories exists?
212 215
 echo strip_tags($_lang['checking_if_images_exist']);
213
-switch(true){
216
+switch(true) {
214 217
     case !file_exists($path."../assets/images"):
215 218
     case !file_exists($path."../assets/files"):
216 219
     case !file_exists($path."../assets/backup"):
@@ -225,7 +228,7 @@  discard block
 block discarded – undo
225 228
 
226 229
 // File Browser directories writable?
227 230
 echo strip_tags($_lang['checking_if_images_writable']);
228
-switch(true){
231
+switch(true) {
229 232
     case !is_writable($path."../assets/images"):
230 233
     case !is_writable($path."../assets/files"):
231 234
     case !is_writable($path."../assets/backup"):
@@ -361,7 +364,7 @@  discard block
 block discarded – undo
361 364
 if ($conn) {
362 365
     echo $_lang['checking_mysql_strict_mode'];
363 366
     $mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode");
364
-    if (mysqli_num_rows($mysqlmode) > 0){
367
+    if (mysqli_num_rows($mysqlmode) > 0) {
365 368
         $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM);
366 369
         //$modes = array("STRICT_TRANS_TABLES"); // for testing
367 370
         // print_r($modes);
@@ -397,9 +400,9 @@  discard block
 block discarded – undo
397 400
 if ($errors > 0) {
398 401
     echo $_lang['setup_cannot_continue'] . ' ';
399 402
 
400
-    if($errors > 1){
403
+    if($errors > 1) {
401 404
         echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural'];
402
-    }else{
405
+    } else {
403 406
         echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again']. PHP_EOL;
404 407
     }
405 408
 
@@ -445,13 +448,15 @@  discard block
 block discarded – undo
445 448
 
446 449
 // get base path and url
447 450
 $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"])));
448
-if (count($a) > 1)
451
+if (count($a) > 1) {
449 452
     array_pop($a);
453
+}
450 454
 $url = implode("install", $a);
451 455
 reset($a);
452 456
 $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__))));
453
-if (count($a) > 1)
457
+if (count($a) > 1) {
454 458
     array_pop($a);
459
+}
455 460
 $pth = implode("install", $a);
456 461
 unset ($a);
457 462
 $base_url = $url . (substr($url, -1) != "/" ? "/" : "");
@@ -472,7 +477,9 @@  discard block
 block discarded – undo
472 477
     echo $_lang['setup_database_selection_failed']." ".$_lang['setup_database_selection_failed_note'].PHP_EOL;
473 478
     $create = true;
474 479
 } else {
475
-    if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset);
480
+    if (function_exists('mysqli_set_charset')) {
481
+        mysqli_set_charset($conn, $database_charset);
482
+    }
476 483
     mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}");
477 484
     echo $_lang['ok'].PHP_EOL;
478 485
 }
@@ -518,7 +525,8 @@  discard block
 block discarded – undo
518 525
      * @param string $propertyString
519 526
      * @return array
520 527
      */
521
-    function parseProperties($propertyString) {
528
+    function parseProperties($propertyString)
529
+    {
522 530
         $parameter= array ();
523 531
         if (!empty ($propertyString)) {
524 532
             $tmpParams= explode("&", $propertyString);
@@ -527,11 +535,14 @@  discard block
 block discarded – undo
527 535
                 if (strpos($tmpParams[$x], '=', 0)) {
528 536
                     $pTmp= explode("=", $tmpParams[$x]);
529 537
                     $pvTmp= explode(";", trim($pTmp[1]));
530
-                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
531
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
538
+                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "") {
539
+                                            $parameter[trim($pTmp[0])]= $pvTmp[3];
540
+                    }
541
+                    //list default
532 542
                     else
533
-                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
534
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
543
+                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "") {
544
+                                                    $parameter[trim($pTmp[0])]= $pvTmp[2];
545
+                        }
535 546
                 }
536 547
             }
537 548
         }
@@ -579,12 +590,12 @@  discard block
 block discarded – undo
579 590
 $mt = &$moduleTemplates;
580 591
 if(is_dir($templatePath) && is_readable($templatePath)) {
581 592
     $d = dir($templatePath);
582
-    while (false !== ($tplfile = $d->read()))
583
-    {
584
-        if(substr($tplfile, -4) != '.tpl') continue;
593
+    while (false !== ($tplfile = $d->read())) {
594
+        if(substr($tplfile, -4) != '.tpl') {
595
+            continue;
596
+        }
585 597
         $params = parse_docblock($templatePath, $tplfile);
586
-        if(is_array($params) && (count($params)>0))
587
-        {
598
+        if(is_array($params) && (count($params)>0)) {
588 599
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
589 600
             $mt[] = array
590 601
             (
@@ -608,7 +619,9 @@  discard block
 block discarded – undo
608 619
 if(is_dir($tvPath) && is_readable($tvPath)) {
609 620
     $d = dir($tvPath);
610 621
     while (false !== ($tplfile = $d->read())) {
611
-        if(substr($tplfile, -4) != '.tpl') continue;
622
+        if(substr($tplfile, -4) != '.tpl') {
623
+            continue;
624
+        }
612 625
         $params = parse_docblock($tvPath, $tplfile);
613 626
         if(is_array($params) && (count($params)>0)) {
614 627
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
@@ -801,7 +814,8 @@  discard block
 block discarded – undo
801 814
 // setup callback function
802 815
 $callBackFnc = "clean_up";
803 816
 
804
-function clean_up($sqlParser) {
817
+function clean_up($sqlParser)
818
+{
805 819
     $ids = array();
806 820
 
807 821
     // secure web documents - privateweb
@@ -814,9 +828,10 @@  discard block
 block discarded – undo
814 828
     $ds = mysqli_query($sqlParser->conn,$sql);
815 829
     if(!$ds) {
816 830
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
817
-    }
818
-    else {
819
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
831
+    } else {
832
+        while($r = mysqli_fetch_assoc($ds)) {
833
+            $ids[]=$r["id"];
834
+        }
820 835
         if(count($ids)>0) {
821 836
             mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")");
822 837
             unset($ids);
@@ -833,9 +848,10 @@  discard block
 block discarded – undo
833 848
     $ds = mysqli_query($sqlParser->conn,$sql);
834 849
     if(!$ds) {
835 850
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
836
-    }
837
-    else {
838
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
851
+    } else {
852
+        while($r = mysqli_fetch_assoc($ds)) {
853
+            $ids[]=$r["id"];
854
+        }
839 855
         if(count($ids)>0) {
840 856
             mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")");
841 857
             unset($ids);
@@ -843,7 +859,8 @@  discard block
 block discarded – undo
843 859
     }
844 860
 }
845 861
 
846
-function parse_docblock($element_dir, $filename) {
862
+function parse_docblock($element_dir, $filename)
863
+{
847 864
     $params = array();
848 865
     $fullpath = $element_dir . '/' . $filename;
849 866
     if(is_readable($fullpath)) {
@@ -944,7 +961,7 @@  discard block
 block discarded – undo
944 961
 // custom or not
945 962
 if (file_exists($path."../assets/cache/siteManager.php")) {
946 963
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
947
-}else{
964
+} else {
948 965
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
949 966
 }
950 967
 
@@ -1084,7 +1101,9 @@  discard block
 block discarded – undo
1084 1101
                         echo mysqli_error($sqlParser->conn) . PHP_EOL;
1085 1102
                         die();
1086 1103
                     }
1087
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1104
+                    if(!is_null($save_sql_id_as)) {
1105
+                        $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1106
+                    }
1088 1107
                     echo "  $name: " . $_lang['installed'] . PHP_EOL;
1089 1108
                 }
1090 1109
             }
@@ -1179,9 +1198,9 @@  discard block
 block discarded – undo
1179 1198
             $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]);
1180 1199
             $filecontent = $moduleChunk[2];
1181 1200
 
1182
-            if (!file_exists($filecontent))
1183
-                echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1184
-            else {
1201
+            if (!file_exists($filecontent)) {
1202
+                            echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1203
+            } else {
1185 1204
 
1186 1205
                 // Create the category if it does not already exist
1187 1206
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -1234,9 +1253,9 @@  discard block
 block discarded – undo
1234 1253
             $guid = mysqli_real_escape_string($conn, $moduleModule[4]);
1235 1254
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
1236 1255
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
1237
-            if (!file_exists($filecontent))
1238
-                echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1239
-            else {
1256
+            if (!file_exists($filecontent)) {
1257
+                            echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1258
+            } else {
1240 1259
 
1241 1260
                 // Create the category if it does not already exist
1242 1261
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -1254,7 +1273,7 @@  discard block
 block discarded – undo
1254 1273
                     }
1255 1274
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1256 1275
                 } else {
1257
-                    if ($properties != NULL ){
1276
+                    if ($properties != NULL ) {
1258 1277
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1259 1278
                     }
1260 1279
                     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);")) {
@@ -1289,9 +1308,9 @@  discard block
 block discarded – undo
1289 1308
                 // parse comma-separated legacy names and prepare them for sql IN clause
1290 1309
                 $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
1291 1310
             }
1292
-            if (!file_exists($filecontent))
1293
-                echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1294
-            else {
1311
+            if (!file_exists($filecontent)) {
1312
+                            echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1313
+            } else {
1295 1314
 
1296 1315
                 // disable legacy versions based on legacy_names provided
1297 1316
                 if(!empty($leg_names)) {
@@ -1310,7 +1329,7 @@  discard block
 block discarded – undo
1310 1329
                     $insert = true;
1311 1330
                     while($row = mysqli_fetch_assoc($rs)) {
1312 1331
                         $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1313
-                        if($row['description'] == $desc){
1332
+                        if($row['description'] == $desc) {
1314 1333
                             if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1315 1334
                                 echo mysqli_error($sqlParser->conn) . PHP_EOL;
1316 1335
                                 return;
@@ -1332,7 +1351,7 @@  discard block
 block discarded – undo
1332 1351
                     }
1333 1352
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1334 1353
                 } else {
1335
-                    if ($properties != NULL ){
1354
+                    if ($properties != NULL ) {
1336 1355
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1337 1356
                     }
1338 1357
                     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);")) {
@@ -1371,9 +1390,9 @@  discard block
 block discarded – undo
1371 1390
             $filecontent = $moduleSnippet[2];
1372 1391
             $properties = $moduleSnippet[3];
1373 1392
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
1374
-            if (!file_exists($filecontent))
1375
-                echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1376
-            else {
1393
+            if (!file_exists($filecontent)) {
1394
+                            echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1395
+            } else {
1377 1396
 
1378 1397
                 // Create the category if it does not already exist
1379 1398
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -1391,7 +1410,7 @@  discard block
 block discarded – undo
1391 1410
                     }
1392 1411
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1393 1412
                 } else {
1394
-                    if ($properties != NULL ){
1413
+                    if ($properties != NULL ) {
1395 1414
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1396 1415
                     }
1397 1416
                     if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
@@ -1484,11 +1503,14 @@  discard block
 block discarded – undo
1484 1503
 }
1485 1504
 
1486 1505
 // call back function
1487
-if ($callBackFnc != "")
1506
+if ($callBackFnc != "") {
1488 1507
     $callBackFnc ($sqlParser);
1508
+}
1489 1509
 
1490 1510
 // Setup the MODX API -- needed for the cache processor
1491
-if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
1511
+if (!defined('MODX_MANAGER_PATH')) {
1512
+    define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
1513
+}
1492 1514
 $database_type = 'mysqli';
1493 1515
 // initiate a new document parser
1494 1516
 include_once($path.'../'.MGR_DIR.'/includes/document.parser.class.inc.php');
@@ -1527,7 +1549,7 @@  discard block
 block discarded – undo
1527 1549
 }
1528 1550
 
1529 1551
 
1530
-if ( empty($args) ){
1552
+if ( empty($args) ) {
1531 1553
     echo PHP_EOL . 'Remove install folder?'.PHP_EOL;
1532 1554
     $removeInstall = readline("Type 'y' or 'n' to continue: ");
1533 1555
 }
@@ -1543,11 +1565,12 @@  discard block
 block discarded – undo
1543 1565
  * @param string $old
1544 1566
  * @return string
1545 1567
  */
1546
-function propUpdate($new,$old){
1568
+function propUpdate($new,$old)
1569
+{
1547 1570
     $newArr = parseProperties($new);
1548 1571
     $oldArr = parseProperties($old);
1549
-    foreach ($oldArr as $k => $v){
1550
-        if (isset($v['0']['options'])){
1572
+    foreach ($oldArr as $k => $v) {
1573
+        if (isset($v['0']['options'])) {
1551 1574
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
1552 1575
         }
1553 1576
     }
@@ -1562,12 +1585,17 @@  discard block
 block discarded – undo
1562 1585
  * @param bool|mixed $json
1563 1586
  * @return string
1564 1587
  */
1565
-function parseProperties($propertyString, $json=false) {
1588
+function parseProperties($propertyString, $json=false)
1589
+{
1566 1590
     $propertyString = str_replace('{}', '', $propertyString );
1567 1591
     $propertyString = str_replace('} {', ',', $propertyString );
1568 1592
 
1569
-    if(empty($propertyString)) return array();
1570
-    if($propertyString=='{}' || $propertyString=='[]') return array();
1593
+    if(empty($propertyString)) {
1594
+        return array();
1595
+    }
1596
+    if($propertyString=='{}' || $propertyString=='[]') {
1597
+        return array();
1598
+    }
1571 1599
 
1572 1600
     $jsonFormat = isJson($propertyString, true);
1573 1601
     $property = array();
@@ -1609,7 +1637,7 @@  discard block
 block discarded – undo
1609 1637
 
1610 1638
         }
1611 1639
     // new json-format
1612
-    } else if(!empty($jsonFormat)){
1640
+    } else if(!empty($jsonFormat)) {
1613 1641
         $property = $jsonFormat;
1614 1642
     }
1615 1643
     if ($json) {
@@ -1624,7 +1652,8 @@  discard block
 block discarded – undo
1624 1652
  * @param bool $returnData
1625 1653
  * @return bool|mixed
1626 1654
  */
1627
-function isJson($string, $returnData=false) {
1655
+function isJson($string, $returnData=false)
1656
+{
1628 1657
     $data = json_decode($string, true);
1629 1658
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
1630 1659
 }
@@ -1634,7 +1663,8 @@  discard block
 block discarded – undo
1634 1663
  * @param SqlParser $sqlParser
1635 1664
  * @return int
1636 1665
  */
1637
-function getCreateDbCategory($category, $sqlParser) {
1666
+function getCreateDbCategory($category, $sqlParser)
1667
+{
1638 1668
     $dbase = $sqlParser->dbname;
1639 1669
     $dbase = '`' . trim($dbase,'`') . '`';
1640 1670
     $table_prefix = $sqlParser->prefix;
@@ -1662,7 +1692,8 @@  discard block
 block discarded – undo
1662 1692
  * @param string $type
1663 1693
  * @return string
1664 1694
  */
1665
-function removeDocblock($code, $type) {
1695
+function removeDocblock($code, $type)
1696
+{
1666 1697
 
1667 1698
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
1668 1699
 
@@ -1683,8 +1714,9 @@  discard block
 block discarded – undo
1683 1714
         default:
1684 1715
             return $cleaned;
1685 1716
     };
1686
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
1687
-        return $cleaned;
1717
+    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') {
1718
+            return $cleaned;
1719
+    }
1688 1720
 
1689 1721
     // fileBinding not found - return code incl docblock
1690 1722
     return $code;
Please login to merge, or discard this patch.
Spacing   +330 added lines, -331 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 $self = 'install/cli-install.php';
8
-$path = dirname(__FILE__) . '/';
9
-$base_path = str_replace($self,'',str_replace('\\','/', __FILE__));
8
+$path = dirname(__FILE__).'/';
9
+$base_path = str_replace($self, '', str_replace('\\', '/', __FILE__));
10 10
 define('MODX_API_MODE', true);
11 11
 define('MODX_BASE_PATH', $base_path);
12 12
 define('MODX_SITE_URL', '/');
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 if (is_file($base_path."assets/cache/siteManager.php")) {
20 20
     include_once($base_path."assets/cache/siteManager.php");
21 21
 }
22
-if(!defined('MGR_DIR') && is_dir($base_path."manager")) {
22
+if (!defined('MGR_DIR') && is_dir($base_path."manager")) {
23 23
     define('MGR_DIR', 'manager');
24 24
 }
25 25
 
@@ -33,43 +33,43 @@  discard block
 block discarded – undo
33 33
 $moduleSQLDataFile = $path."setup.data.sql";
34 34
 $moduleSQLResetFile = $path."setup.data.reset.sql";
35 35
 
36
-$moduleChunks = array (); // chunks - array : name, description, type - 0:file or 1:content, file or content
37
-$moduleTemplates = array (); // templates - array : name, description, type - 0:file or 1:content, file or content
38
-$moduleSnippets = array (); // snippets - array : name, description, type - 0:file or 1:content, file or content,properties
39
-$modulePlugins = array (); // plugins - array : name, description, type - 0:file or 1:content, file or content,properties, events,guid
40
-$moduleModules = array (); // modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid
41
-$moduleTemplates = array (); // templates - array : name, description, type - 0:file or 1:content, file or content,properties
42
-$moduleTVs = array (); // template variables - array : name, description, type - 0:file or 1:content, file or content,properties
36
+$moduleChunks = array(); // chunks - array : name, description, type - 0:file or 1:content, file or content
37
+$moduleTemplates = array(); // templates - array : name, description, type - 0:file or 1:content, file or content
38
+$moduleSnippets = array(); // snippets - array : name, description, type - 0:file or 1:content, file or content,properties
39
+$modulePlugins = array(); // plugins - array : name, description, type - 0:file or 1:content, file or content,properties, events,guid
40
+$moduleModules = array(); // modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid
41
+$moduleTemplates = array(); // templates - array : name, description, type - 0:file or 1:content, file or content,properties
42
+$moduleTVs = array(); // template variables - array : name, description, type - 0:file or 1:content, file or content,properties
43 43
 $moduleDependencies = array(); // module depedencies - array : module, table, column, type, name
44
-$errors= 0;
44
+$errors = 0;
45 45
 
46 46
 
47
-$installMode= 0;
47
+$installMode = 0;
48 48
 $installData = 0;
49 49
 $tableprefixauto = base_convert(rand(10, 20), 10, 36).substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), rand(0, 33), 3).'_';
50 50
 
51 51
 $args = array_slice($argv, 1);
52 52
 
53
-if ( empty($args) ){
53
+if (empty($args)) {
54 54
     echo 'Install Evolution CMS'.PHP_EOL;
55 55
     //$installYes = readline("Type 'y' to continue: ");
56 56
     //if ($installYes != 'y') return;
57 57
 
58 58
     //set param manual
59
-    $databasehost = readline($_lang['connection_screen_database_host']. ' [localhost] ');
60
-    $databaseloginname = readline($_lang['connection_screen_database_login']. ' ');
61
-    $databaseloginpassword = readline($_lang['connection_screen_database_pass']. ' ');
62
-    $database_name = readline($_lang['connection_screen_database_name']. ' ');
63
-    $tableprefix = readline($_lang['connection_screen_table_prefix']. ' ['.$tableprefixauto.'] ');
64
-    $database_connection_method = readline($_lang['connection_screen_connection_method']. ' [SET CHARACTER SET] ');
65
-    $database_collation = readline($_lang['connection_screen_collation']. ' [utf8_general_ci] ');
66
-    $cmsadmin = readline($_lang['connection_screen_default_admin_login']. ' [admin] ');
67
-    $cmsadminemail = readline($_lang['connection_screen_default_admin_email']. ' ');
68
-    $cmspassword = readline($_lang['connection_screen_default_admin_password']. ' ');
69
-    $managerlanguage = readline('Мanager language:' . ' [en] ');
70
-    $installData = readline('Instal demo-site (y/n):' . ' [n] ');
59
+    $databasehost = readline($_lang['connection_screen_database_host'].' [localhost] ');
60
+    $databaseloginname = readline($_lang['connection_screen_database_login'].' ');
61
+    $databaseloginpassword = readline($_lang['connection_screen_database_pass'].' ');
62
+    $database_name = readline($_lang['connection_screen_database_name'].' ');
63
+    $tableprefix = readline($_lang['connection_screen_table_prefix'].' ['.$tableprefixauto.'] ');
64
+    $database_connection_method = readline($_lang['connection_screen_connection_method'].' [SET CHARACTER SET] ');
65
+    $database_collation = readline($_lang['connection_screen_collation'].' [utf8_general_ci] ');
66
+    $cmsadmin = readline($_lang['connection_screen_default_admin_login'].' [admin] ');
67
+    $cmsadminemail = readline($_lang['connection_screen_default_admin_email'].' ');
68
+    $cmspassword = readline($_lang['connection_screen_default_admin_password'].' ');
69
+    $managerlanguage = readline('Мanager language:'.' [en] ');
70
+    $installData = readline('Instal demo-site (y/n):'.' [n] ');
71 71
     
72
-}else{
72
+} else {
73 73
     
74 74
     $cli_variables = [];
75 75
     foreach ($args as $arg) {
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 }
101 101
 
102 102
 
103
-if ($databasehost == '') { $databasehost= 'localhost'; } 
104
-if ($tableprefix == ''){ $tableprefix = $tableprefixauto; }
103
+if ($databasehost == '') { $databasehost = 'localhost'; } 
104
+if ($tableprefix == '') { $tableprefix = $tableprefixauto; }
105 105
 if ($database_connection_method == '') { $database_connection_method = 'SET CHARACTER SET'; } 
106 106
 if ($database_collation == '') { $database_collation = 'utf8_general_ci'; } 
107
-if ($cmsadmin == ''){ $cmsadmin = 'admin'; }
107
+if ($cmsadmin == '') { $cmsadmin = 'admin'; }
108 108
 if ($managerlanguage == '') { $managerlanguage = 'en'; } 
109
-if ($installData == 'y') { $installData = 1;}
110
-if ($mode == 'upgrade') { $installMode = 1;}
109
+if ($installData == 'y') { $installData = 1; }
110
+if ($mode == 'upgrade') { $installMode = 1; }
111 111
 
112 112
 //добавить обработку языка
113 113
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 }
124 124
 
125 125
 //////////////////////////////////////////////////////////////////////////////////////
126
-if( ! function_exists('f_owc')){
126
+if (!function_exists('f_owc')) {
127 127
     /**
128 128
      * @param $path
129 129
      * @param $data
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
             fwrite($hnd, $data);
137 137
             fclose($hnd);
138 138
 
139
-            if(null !== $mode) chmod($path, $mode);
140
-        }catch(Exception $e){
139
+            if (null !== $mode) chmod($path, $mode);
140
+        } catch (Exception $e) {
141 141
             // Nothing, this is NOT normal
142 142
             unset($e);
143 143
         }
@@ -147,24 +147,24 @@  discard block
 block discarded – undo
147 147
 // check PHP version
148 148
 define('PHP_MIN_VERSION', '5.4.0');
149 149
 $phpMinVersion = PHP_MIN_VERSION; // Maybe not necessary. For backward compatibility
150
-echo PHP_EOL . $_lang['checking_php_version'];
150
+echo PHP_EOL.$_lang['checking_php_version'];
151 151
 // -1 if left is less, 0 if equal, +1 if left is higher
152 152
 if (version_compare(phpversion(), PHP_MIN_VERSION) < 0) {
153 153
     $errors++;
154
-    $tmp = $_lang['you_running_php'] . phpversion() . str_replace('[+min_version+]', PHP_MIN_VERSION, $_lang["modx_requires_php"]);
155
-    echo $_lang['failed'] . ' ' . $tmp . PHP_EOL;
154
+    $tmp = $_lang['you_running_php'].phpversion().str_replace('[+min_version+]', PHP_MIN_VERSION, $_lang["modx_requires_php"]);
155
+    echo $_lang['failed'].' '.$tmp.PHP_EOL;
156 156
 } else {
157
-    echo $_lang['ok'] . PHP_EOL;
157
+    echo $_lang['ok'].PHP_EOL;
158 158
 }
159 159
 
160 160
 // check directories
161 161
 // cache exists?
162 162
 echo strip_tags($_lang['checking_if_cache_exist']);
163 163
 if (!file_exists($path."../assets/cache") || !file_exists($path."../assets/cache/rss")) {
164
-    echo $_lang['failed'] . PHP_EOL;
164
+    echo $_lang['failed'].PHP_EOL;
165 165
     $errors++;
166 166
 } else {
167
-    echo $_lang['ok'] . PHP_EOL;
167
+    echo $_lang['ok'].PHP_EOL;
168 168
 }
169 169
 
170 170
 
@@ -172,82 +172,82 @@  discard block
 block discarded – undo
172 172
 echo strip_tags($_lang['checking_if_cache_writable']);
173 173
 if (!is_writable($path."../assets/cache")) {
174 174
     $errors++;
175
-    echo $_lang['failed'] . PHP_EOL;
175
+    echo $_lang['failed'].PHP_EOL;
176 176
 } else {
177
-    echo $_lang['ok'] . PHP_EOL;
177
+    echo $_lang['ok'].PHP_EOL;
178 178
 }
179 179
 
180 180
 
181 181
 // cache files writable?
182 182
 echo strip_tags($_lang['checking_if_cache_file_writable']);
183 183
 $tmp = $path."../assets/cache/siteCache.idx.php";
184
-if ( ! file_exists($tmp)) {
184
+if (!file_exists($tmp)) {
185 185
     f_owc($tmp, "<?php //EVO site cache file ?>");
186 186
 }
187
-if ( ! is_writable($tmp)) {
187
+if (!is_writable($tmp)) {
188 188
     $errors++;
189
-    echo $_lang['failed'] . PHP_EOL;
189
+    echo $_lang['failed'].PHP_EOL;
190 190
 } else {
191
-    echo $_lang['ok'] . PHP_EOL;
191
+    echo $_lang['ok'].PHP_EOL;
192 192
 }
193 193
 
194 194
 
195 195
 echo strip_tags($_lang['checking_if_cache_file2_writable']);
196
-if ( ! is_writable($path."../assets/cache/sitePublishing.idx.php")) {
196
+if (!is_writable($path."../assets/cache/sitePublishing.idx.php")) {
197 197
     $errors++;
198
-    echo $_lang['failed'] . PHP_EOL;
198
+    echo $_lang['failed'].PHP_EOL;
199 199
 } else {
200
-    echo $_lang['ok'] . PHP_EOL;
200
+    echo $_lang['ok'].PHP_EOL;
201 201
 }
202 202
 
203 203
 
204 204
 // File Browser directories exists?
205 205
 echo strip_tags($_lang['checking_if_images_exist']);
206
-switch(true){
206
+switch (true) {
207 207
     case !file_exists($path."../assets/images"):
208 208
     case !file_exists($path."../assets/files"):
209 209
     case !file_exists($path."../assets/backup"):
210 210
     //case !file_exists("../assets/.thumbs"):
211 211
         $errors++;
212
-        echo $_lang['failed'] . PHP_EOL;
212
+        echo $_lang['failed'].PHP_EOL;
213 213
         break;
214 214
     default:
215
-        echo $_lang['ok'] . PHP_EOL;
215
+        echo $_lang['ok'].PHP_EOL;
216 216
 }
217 217
 
218 218
 
219 219
 // File Browser directories writable?
220 220
 echo strip_tags($_lang['checking_if_images_writable']);
221
-switch(true){
221
+switch (true) {
222 222
     case !is_writable($path."../assets/images"):
223 223
     case !is_writable($path."../assets/files"):
224 224
     case !is_writable($path."../assets/backup"):
225 225
     //case !is_writable("../assets/.thumbs"):
226 226
         $errors++;
227
-        echo $_lang['failed'] . PHP_EOL;
227
+        echo $_lang['failed'].PHP_EOL;
228 228
         break;
229 229
     default:
230
-        echo $_lang['ok'] . PHP_EOL;
230
+        echo $_lang['ok'].PHP_EOL;
231 231
 }
232 232
 
233 233
 
234 234
 // export exists?
235 235
 echo strip_tags($_lang['checking_if_export_exists']);
236 236
 if (!file_exists($path."../assets/export")) {
237
-    echo $_lang['failed'] . PHP_EOL;
237
+    echo $_lang['failed'].PHP_EOL;
238 238
     $errors++;
239 239
 } else {
240
-    echo $_lang['ok'] . PHP_EOL;
240
+    echo $_lang['ok'].PHP_EOL;
241 241
 }
242 242
 
243 243
 
244 244
 // export writable?
245 245
 echo strip_tags($_lang['checking_if_export_writable']);
246 246
 if (!is_writable($path."../assets/export")) {
247
-    echo $_lang['failed'] . PHP_EOL;
247
+    echo $_lang['failed'].PHP_EOL;
248 248
     $errors++;
249 249
 } else {
250
-    echo $_lang['ok'] . PHP_EOL;
250
+    echo $_lang['ok'].PHP_EOL;
251 251
 }
252 252
 
253 253
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 $isWriteable = is_writable($tmp);
263 263
 if (!$isWriteable) {
264 264
     $errors++;
265
-    echo $_lang['failed'] . PHP_EOL;
265
+    echo $_lang['failed'].PHP_EOL;
266 266
 } else {
267
-    echo $_lang['ok'] . PHP_EOL;
267
+    echo $_lang['ok'].PHP_EOL;
268 268
 }
269 269
 
270 270
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     $database_charset = substr($database_collation, 0, strpos($database_collation, '_') - 1);
281 281
     $database_connection_charset = $database_collation;
282 282
     $database_connection_method = $database_connection_method;
283
-    $dbase = '`' . $database_name . '`';
283
+    $dbase = '`'.$database_name.'`';
284 284
     $table_prefix = $tableprefix;
285 285
 }
286 286
 echo $_lang['creating_database_connection'];
@@ -320,33 +320,33 @@  discard block
 block discarded – undo
320 320
 
321 321
 // check table prefix
322 322
 if ($conn && $installMode == 0) {
323
-    echo $_lang['checking_table_prefix'] . $table_prefix . '`: ';
324
-    if ($rs= mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
325
-        echo $_lang['failed'] . ' ' . $_lang['table_prefix_already_inuse_note'] . PHP_EOL;
323
+    echo $_lang['checking_table_prefix'].$table_prefix.'`: ';
324
+    if ($rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
325
+        echo $_lang['failed'].' '.$_lang['table_prefix_already_inuse_note'].PHP_EOL;
326 326
         $errors++;
327 327
 
328 328
     } else {
329
-        echo $_lang['ok'] . PHP_EOL;
329
+        echo $_lang['ok'].PHP_EOL;
330 330
     }
331 331
 } elseif ($conn && $installMode == 2) {
332
-    echo $_lang['checking_table_prefix'] . $table_prefix . '`: ';
333
-    if (!$rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
334
-        echo $_lang['failed'] . ' ' . $_lang['table_prefix_not_exist'] . PHP_EOL;
332
+    echo $_lang['checking_table_prefix'].$table_prefix.'`: ';
333
+    if (!$rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
334
+        echo $_lang['failed'].' '.$_lang['table_prefix_not_exist'].PHP_EOL;
335 335
         $errors++;
336 336
 
337 337
   } else {
338
-        echo $_lang['ok'] . PHP_EOL;
338
+        echo $_lang['ok'].PHP_EOL;
339 339
   }
340 340
 }
341 341
 
342 342
 // check mysql version
343 343
 if ($conn) {
344 344
     echo $_lang['checking_mysql_version'];
345
-    if ( version_compare(mysqli_get_server_info($conn), '5.0.51', '=') ) {
346
-        echo $_lang['warning'] . ' ' . $_lang['mysql_5051'] . PHP_EOL;
347
-        echo $_lang['mysql_5051_warning'] . PHP_EOL;
345
+    if (version_compare(mysqli_get_server_info($conn), '5.0.51', '=')) {
346
+        echo $_lang['warning'].' '.$_lang['mysql_5051'].PHP_EOL;
347
+        echo $_lang['mysql_5051_warning'].PHP_EOL;
348 348
     } else {
349
-        echo $_lang['ok'] . ' ' . $_lang['mysql_version_is'] . mysqli_get_server_info($conn) . PHP_EOL;
349
+        echo $_lang['ok'].' '.$_lang['mysql_version_is'].mysqli_get_server_info($conn).PHP_EOL;
350 350
     }
351 351
 }
352 352
 
@@ -354,20 +354,20 @@  discard block
 block discarded – undo
354 354
 if ($conn) {
355 355
     echo $_lang['checking_mysql_strict_mode'];
356 356
     $mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode");
357
-    if (mysqli_num_rows($mysqlmode) > 0){
357
+    if (mysqli_num_rows($mysqlmode) > 0) {
358 358
         $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM);
359 359
         //$modes = array("STRICT_TRANS_TABLES"); // for testing
360 360
         // print_r($modes);
361 361
         foreach ($modes as $mode) {
362 362
             if (stristr($mode, "STRICT_TRANS_TABLES") !== false || stristr($mode, "STRICT_ALL_TABLES") !== false) {
363
-                echo $_lang['warning'] . ' ' . $_lang['strict_mode'] . PHP_EOL;
364
-                echo $_lang['strict_mode_error'] . PHP_EOL;
363
+                echo $_lang['warning'].' '.$_lang['strict_mode'].PHP_EOL;
364
+                echo $_lang['strict_mode_error'].PHP_EOL;
365 365
             } else {
366
-                echo $_lang['ok'] . PHP_EOL;
366
+                echo $_lang['ok'].PHP_EOL;
367 367
             }
368 368
         }
369 369
     } else {
370
-        echo $_lang['ok'] . PHP_EOL;
370
+        echo $_lang['ok'].PHP_EOL;
371 371
     }
372 372
 }
373 373
 // Version and strict mode check end
@@ -383,17 +383,17 @@  discard block
 block discarded – undo
383 383
     f_owc($path."../assets/cache/installProc.inc.php", '<?php $installStartTime = '.time().'; ?>');
384 384
 }
385 385
 
386
-if($installMode > 0 && $_POST['installdata'] == "1") {
387
-    echo $_lang['sample_web_site'] . ': ' . $_lang['sample_web_site_note'] . PHP_EOL;
386
+if ($installMode > 0 && $_POST['installdata'] == "1") {
387
+    echo $_lang['sample_web_site'].': '.$_lang['sample_web_site_note'].PHP_EOL;
388 388
 }
389 389
 
390 390
 if ($errors > 0) {
391
-    echo $_lang['setup_cannot_continue'] . ' ';
391
+    echo $_lang['setup_cannot_continue'].' ';
392 392
 
393
-    if($errors > 1){
394
-        echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural'];
395
-    }else{
396
-        echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again']. PHP_EOL;
393
+    if ($errors > 1) {
394
+        echo $errors." ".$_lang['errors'].$_lang['please_correct_errors'].$_lang['and_try_again_plural'];
395
+    } else {
396
+        echo $_lang['error'].$_lang['please_correct_error'].$_lang['and_try_again'].PHP_EOL;
397 397
     }
398 398
 
399 399
     die();
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
     $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
423 423
     $database_connection_charset = $database_charset;
424 424
     $database_connection_method = $database_connection_method;
425
-    $dbase = "`" .$database_name. "`";
425
+    $dbase = "`".$database_name."`";
426 426
     $table_prefix = $tableprefix;
427 427
     $adminname = $cmsadmin;
428 428
     $adminemail = $cmsadminemail;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 
434 434
 // set session name variable
435 435
 if (!isset ($site_sessionname)) {
436
-    $site_sessionname = 'SN' . uniqid('');
436
+    $site_sessionname = 'SN'.uniqid('');
437 437
 }
438 438
 
439 439
 // get base path and url
@@ -447,8 +447,8 @@  discard block
 block discarded – undo
447 447
     array_pop($a);
448 448
 $pth = implode("install", $a);
449 449
 unset ($a);
450
-$base_url = $url . (substr($url, -1) != "/" ? "/" : "");
451
-$base_path = $pth . (substr($pth, -1) != "/" ? "/" : "");
450
+$base_url = $url.(substr($url, -1) != "/" ? "/" : "");
451
+$base_path = $pth.(substr($pth, -1) != "/" ? "/" : "");
452 452
 
453 453
 // connect to the database
454 454
 echo $_lang['setup_database_create_connection'].': ';
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 }
461 461
 
462 462
 // select database
463
-echo $_lang['setup_database_selection']. str_replace("`", "", $dbase) . "`: ";
463
+echo $_lang['setup_database_selection'].str_replace("`", "", $dbase)."`: ";
464 464
 if (!mysqli_select_db($conn, str_replace("`", "", $dbase))) {
465 465
     echo $_lang['setup_database_selection_failed']." ".$_lang['setup_database_selection_failed_note'].PHP_EOL;
466 466
     $create = true;
@@ -472,16 +472,16 @@  discard block
 block discarded – undo
472 472
 
473 473
 // try to create the database
474 474
 if ($create) {
475
-    echo $_lang['setup_database_creation']. str_replace("`", "", $dbase) . "`: ";
475
+    echo $_lang['setup_database_creation'].str_replace("`", "", $dbase)."`: ";
476 476
     //  if(!@mysqli_create_db(str_replace("`","",$dbase), $conn)) {
477
-    if (! mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) {
477
+    if (!mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) {
478 478
         echo $_lang['setup_database_creation_failed']." ".$_lang['setup_database_creation_failed_note'].PHP_EOL;
479 479
         $errors += 1;
480 480
         
481
-        echo 'database charset: ' . $database_charset . PHP_EOL;
482
-        echo 'database collation: ' . $database_collation . PHP_EOL;
481
+        echo 'database charset: '.$database_charset.PHP_EOL;
482
+        echo 'database collation: '.$database_collation.PHP_EOL;
483 483
 
484
-        echo $_lang['setup_database_creation_failed_note2'] . PHP_EOL;
484
+        echo $_lang['setup_database_creation_failed_note2'].PHP_EOL;
485 485
 
486 486
         die();
487 487
 
@@ -492,18 +492,18 @@  discard block
 block discarded – undo
492 492
 
493 493
 // check table prefix
494 494
 if ($installMode == 0) {
495
-    echo $_lang['checking_table_prefix'] . $table_prefix . "`: ";
496
-    if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
497
-        echo $_lang['failed'] . " " . $_lang['table_prefix_already_inuse'] . PHP_EOL;
495
+    echo $_lang['checking_table_prefix'].$table_prefix."`: ";
496
+    if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
497
+        echo $_lang['failed']." ".$_lang['table_prefix_already_inuse'].PHP_EOL;
498 498
         $errors += 1;
499
-        echo $_lang['table_prefix_already_inuse_note'] . PHP_EOL;
499
+        echo $_lang['table_prefix_already_inuse_note'].PHP_EOL;
500 500
         return;
501 501
     } else {
502 502
         echo $_lang['ok'].PHP_EOL;
503 503
     }
504 504
 }
505 505
 
506
-if(!function_exists('parseProperties')) {
506
+if (!function_exists('parseProperties')) {
507 507
     /**
508 508
      * parses a resource property string and returns the result as an array
509 509
      * duplicate of method in documentParser class
@@ -511,20 +511,20 @@  discard block
 block discarded – undo
511 511
      * @param string $propertyString
512 512
      * @return array
513 513
      */
514
-    function parseProperties($propertyString) {
515
-        $parameter= array ();
514
+    function parseProperties($propertyString){
515
+        $parameter = array();
516 516
         if (!empty ($propertyString)) {
517
-            $tmpParams= explode("&", $propertyString);
517
+            $tmpParams = explode("&", $propertyString);
518 518
             $countParams = count($tmpParams);
519
-            for ($x= 0; $x < $countParams; $x++) {
519
+            for ($x = 0; $x < $countParams; $x++) {
520 520
                 if (strpos($tmpParams[$x], '=', 0)) {
521
-                    $pTmp= explode("=", $tmpParams[$x]);
522
-                    $pvTmp= explode(";", trim($pTmp[1]));
521
+                    $pTmp = explode("=", $tmpParams[$x]);
522
+                    $pvTmp = explode(";", trim($pTmp[1]));
523 523
                     if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
524
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
524
+                        $parameter[trim($pTmp[0])] = $pvTmp[3]; //list default
525 525
                     else
526 526
                         if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
527
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
527
+                            $parameter[trim($pTmp[0])] = $pvTmp[2];
528 528
                 }
529 529
             }
530 530
         }
@@ -535,20 +535,20 @@  discard block
 block discarded – undo
535 535
 // check status of Inherit Parent Template plugin
536 536
 $auto_template_logic = 'parent';
537 537
 if ($installMode != 0) {
538
-    $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'");
538
+    $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`".$table_prefix."site_plugins` WHERE name='Inherit Parent Template'");
539 539
     $row = mysqli_fetch_row($rs);
540
-    if(!$row) {
540
+    if (!$row) {
541 541
         // not installed
542 542
         $auto_template_logic = 'system';
543 543
     } else {
544
-        if($row[1] == 1) {
544
+        if ($row[1] == 1) {
545 545
             // installed but disabled
546 546
             $auto_template_logic = 'system';
547 547
         } else {
548 548
             // installed, enabled .. see how it's configured
549 549
             $properties = parseProperties($row[0]);
550
-            if(isset($properties['inheritTemplate'])) {
551
-                if($properties['inheritTemplate'] == 'From First Sibling') {
550
+            if (isset($properties['inheritTemplate'])) {
551
+                if ($properties['inheritTemplate'] == 'From First Sibling') {
552 552
                     $auto_template_logic = 'sibling';
553 553
                 }
554 554
             }
@@ -570,17 +570,16 @@  discard block
 block discarded – undo
570 570
 
571 571
 // setup Template template files - array : name, description, type - 0:file or 1:content, parameters, category
572 572
 $mt = &$moduleTemplates;
573
-if(is_dir($templatePath) && is_readable($templatePath)) {
573
+if (is_dir($templatePath) && is_readable($templatePath)) {
574 574
     $d = dir($templatePath);
575 575
     while (false !== ($tplfile = $d->read()))
576 576
     {
577
-        if(substr($tplfile, -4) != '.tpl') continue;
577
+        if (substr($tplfile, -4) != '.tpl') continue;
578 578
         $params = parse_docblock($templatePath, $tplfile);
579
-        if(is_array($params) && (count($params)>0))
579
+        if (is_array($params) && (count($params) > 0))
580 580
         {
581 581
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
582
-            $mt[] = array
583
-            (
582
+            $mt[] = array(
584 583
                 $params['name'],
585 584
                 $description,
586 585
                 // Don't think this is gonna be used ... but adding it just in case 'type'
@@ -598,12 +597,12 @@  discard block
 block discarded – undo
598 597
 
599 598
 // setup Template Variable template files
600 599
 $mtv = &$moduleTVs;
601
-if(is_dir($tvPath) && is_readable($tvPath)) {
600
+if (is_dir($tvPath) && is_readable($tvPath)) {
602 601
     $d = dir($tvPath);
603 602
     while (false !== ($tplfile = $d->read())) {
604
-        if(substr($tplfile, -4) != '.tpl') continue;
603
+        if (substr($tplfile, -4) != '.tpl') continue;
605 604
         $params = parse_docblock($tvPath, $tplfile);
606
-        if(is_array($params) && (count($params)>0)) {
605
+        if (is_array($params) && (count($params) > 0)) {
607 606
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
608 607
             $mtv[] = array(
609 608
                 $params['name'],
@@ -615,9 +614,9 @@  discard block
 block discarded – undo
615 614
                 $params['output_widget'],
616 615
                 $params['output_widget_params'],
617 616
                 "$templatePath/{$params['filename']}", /* not currently used */
618
-                $params['template_assignments']!="*"?$params['template_assignments']:implode(",",array_map(create_function('$v','return $v[0];'),$mt)), /* comma-separated list of template names */
617
+                $params['template_assignments'] != "*" ? $params['template_assignments'] : implode(",", array_map(create_function('$v', 'return $v[0];'), $mt)), /* comma-separated list of template names */
619 618
                 $params['modx_category'],
620
-                $params['lock_tv'],  /* value should be 1 or 0 */
619
+                $params['lock_tv'], /* value should be 1 or 0 */
621 620
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
622 621
             );
623 622
         }
@@ -627,14 +626,14 @@  discard block
 block discarded – undo
627 626
 
628 627
 // setup chunks template files - array : name, description, type - 0:file or 1:content, file or content
629 628
 $mc = &$moduleChunks;
630
-if(is_dir($chunkPath) && is_readable($chunkPath)) {
629
+if (is_dir($chunkPath) && is_readable($chunkPath)) {
631 630
     $d = dir($chunkPath);
632 631
     while (false !== ($tplfile = $d->read())) {
633
-        if(substr($tplfile, -4) != '.tpl') {
632
+        if (substr($tplfile, -4) != '.tpl') {
634 633
             continue;
635 634
         }
636 635
         $params = parse_docblock($chunkPath, $tplfile);
637
-        if(is_array($params) && count($params) > 0) {
636
+        if (is_array($params) && count($params) > 0) {
638 637
             $mc[] = array(
639 638
                 $params['name'],
640 639
                 $params['description'],
@@ -650,14 +649,14 @@  discard block
 block discarded – undo
650 649
 
651 650
 // setup snippets template files - array : name, description, type - 0:file or 1:content, file or content,properties
652 651
 $ms = &$moduleSnippets;
653
-if(is_dir($snippetPath) && is_readable($snippetPath)) {
652
+if (is_dir($snippetPath) && is_readable($snippetPath)) {
654 653
     $d = dir($snippetPath);
655 654
     while (false !== ($tplfile = $d->read())) {
656
-        if(substr($tplfile, -4) != '.tpl') {
655
+        if (substr($tplfile, -4) != '.tpl') {
657 656
             continue;
658 657
         }
659 658
         $params = parse_docblock($snippetPath, $tplfile);
660
-        if(is_array($params) && count($params) > 0) {
659
+        if (is_array($params) && count($params) > 0) {
661 660
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
662 661
             $ms[] = array(
663 662
                 $params['name'],
@@ -674,14 +673,14 @@  discard block
 block discarded – undo
674 673
 
675 674
 // setup plugins template files - array : name, description, type - 0:file or 1:content, file or content,properties
676 675
 $mp = &$modulePlugins;
677
-if(is_dir($pluginPath) && is_readable($pluginPath)) {
676
+if (is_dir($pluginPath) && is_readable($pluginPath)) {
678 677
     $d = dir($pluginPath);
679 678
     while (false !== ($tplfile = $d->read())) {
680
-        if(substr($tplfile, -4) != '.tpl') {
679
+        if (substr($tplfile, -4) != '.tpl') {
681 680
             continue;
682 681
         }
683 682
         $params = parse_docblock($pluginPath, $tplfile);
684
-        if(is_array($params) && count($params) > 0) {
683
+        if (is_array($params) && count($params) > 0) {
685 684
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
686 685
             $mp[] = array(
687 686
                 $params['name'],
@@ -693,7 +692,7 @@  discard block
 block discarded – undo
693 692
                 $params['modx_category'],
694 693
                 $params['legacy_names'],
695 694
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false,
696
-                (int)$params['disabled']
695
+                (int) $params['disabled']
697 696
             );
698 697
         }
699 698
     }
@@ -703,14 +702,14 @@  discard block
 block discarded – undo
703 702
 // setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
704 703
 $mm = &$moduleModules;
705 704
 $mdp = &$moduleDependencies;
706
-if(is_dir($modulePath) && is_readable($modulePath)) {
705
+if (is_dir($modulePath) && is_readable($modulePath)) {
707 706
     $d = dir($modulePath);
708 707
     while (false !== ($tplfile = $d->read())) {
709
-        if(substr($tplfile, -4) != '.tpl') {
708
+        if (substr($tplfile, -4) != '.tpl') {
710 709
             continue;
711 710
         }
712 711
         $params = parse_docblock($modulePath, $tplfile);
713
-        if(is_array($params) && count($params) > 0) {
712
+        if (is_array($params) && count($params) > 0) {
714 713
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
715 714
             $mm[] = array(
716 715
                 $params['name'],
@@ -718,12 +717,12 @@  discard block
 block discarded – undo
718 717
                 "$modulePath/{$params['filename']}",
719 718
                 $params['properties'],
720 719
                 $params['guid'],
721
-                (int)$params['shareparams'],
720
+                (int) $params['shareparams'],
722 721
                 $params['modx_category'],
723 722
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
724 723
             );
725 724
         }
726
-        if ((int)$params['shareparams'] || !empty($params['dependencies'])) {
725
+        if ((int) $params['shareparams'] || !empty($params['dependencies'])) {
727 726
             $dependencies = explode(',', $params['dependencies']);
728 727
             foreach ($dependencies as $dependency) {
729 728
                 $dependency = explode(':', $dependency);
@@ -794,103 +793,103 @@  discard block
 block discarded – undo
794 793
 // setup callback function
795 794
 $callBackFnc = "clean_up";
796 795
 
797
-function clean_up($sqlParser) {
796
+function clean_up($sqlParser){
798 797
     $ids = array();
799 798
 
800 799
     // secure web documents - privateweb
801
-    mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1");
802
-    $sql =  "SELECT DISTINCT sc.id
800
+    mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1");
801
+    $sql = "SELECT DISTINCT sc.id
803 802
              FROM `".$sqlParser->prefix."site_content` sc
804 803
              LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id
805 804
              LEFT JOIN `".$sqlParser->prefix."webgroup_access` wga ON wga.documentgroup = dg.document_group
806 805
              WHERE wga.id>0";
807
-    $ds = mysqli_query($sqlParser->conn,$sql);
808
-    if(!$ds) {
806
+    $ds = mysqli_query($sqlParser->conn, $sql);
807
+    if (!$ds) {
809 808
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
810 809
     }
811 810
     else {
812
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
813
-        if(count($ids)>0) {
814
-            mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")");
811
+        while ($r = mysqli_fetch_assoc($ds)) $ids[] = $r["id"];
812
+        if (count($ids) > 0) {
813
+            mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ", $ids).")");
815 814
             unset($ids);
816 815
         }
817 816
     }
818 817
 
819 818
     // secure manager documents privatemgr
820
-    mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1");
821
-    $sql =  "SELECT DISTINCT sc.id
819
+    mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1");
820
+    $sql = "SELECT DISTINCT sc.id
822 821
              FROM `".$sqlParser->prefix."site_content` sc
823 822
              LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id
824 823
              LEFT JOIN `".$sqlParser->prefix."membergroup_access` mga ON mga.documentgroup = dg.document_group
825 824
              WHERE mga.id>0";
826
-    $ds = mysqli_query($sqlParser->conn,$sql);
827
-    if(!$ds) {
825
+    $ds = mysqli_query($sqlParser->conn, $sql);
826
+    if (!$ds) {
828 827
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
829 828
     }
830 829
     else {
831
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
832
-        if(count($ids)>0) {
833
-            mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")");
830
+        while ($r = mysqli_fetch_assoc($ds)) $ids[] = $r["id"];
831
+        if (count($ids) > 0) {
832
+            mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ", $ids).")");
834 833
             unset($ids);
835 834
         }
836 835
     }
837 836
 }
838 837
 
839
-function parse_docblock($element_dir, $filename) {
838
+function parse_docblock($element_dir, $filename){
840 839
     $params = array();
841
-    $fullpath = $element_dir . '/' . $filename;
842
-    if(is_readable($fullpath)) {
840
+    $fullpath = $element_dir.'/'.$filename;
841
+    if (is_readable($fullpath)) {
843 842
         $tpl = @fopen($fullpath, "r");
844
-        if($tpl) {
843
+        if ($tpl) {
845 844
             $params['filename'] = $filename;
846 845
             $docblock_start_found = false;
847 846
             $name_found = false;
848 847
             $description_found = false;
849 848
 
850
-            while(!feof($tpl)) {
849
+            while (!feof($tpl)) {
851 850
                 $line = fgets($tpl);
852
-                if(!$docblock_start_found) {
851
+                if (!$docblock_start_found) {
853 852
                     // find docblock start
854
-                    if(strpos($line, '/**') !== false) {
853
+                    if (strpos($line, '/**') !== false) {
855 854
                         $docblock_start_found = true;
856 855
                     }
857 856
                     continue;
858
-                } elseif(!$name_found) {
857
+                } elseif (!$name_found) {
859 858
                     // find name
860 859
                     $ma = null;
861
-                    if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
860
+                    if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
862 861
                         $params['name'] = trim($ma[1]);
863 862
                         $name_found = !empty($params['name']);
864 863
                     }
865 864
                     continue;
866
-                } elseif(!$description_found) {
865
+                } elseif (!$description_found) {
867 866
                     // find description
868 867
                     $ma = null;
869
-                    if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
868
+                    if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
870 869
                         $params['description'] = trim($ma[1]);
871 870
                         $description_found = !empty($params['description']);
872 871
                     }
873 872
                     continue;
874 873
                 } else {
875 874
                     $ma = null;
876
-                    if(preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
875
+                    if (preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
877 876
                         $param = trim($ma[1]);
878 877
                         $val = trim($ma[2]);
879
-                        if(!empty($param) && !empty($val)) {
880
-                            if($param == 'internal') {
878
+                        if (!empty($param) && !empty($val)) {
879
+                            if ($param == 'internal') {
881 880
                                 $ma = null;
882
-                                if(preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
881
+                                if (preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
883 882
                                     $param = trim($ma[1]);
884 883
                                     $val = trim($ma[2]);
885 884
                                 }
886 885
                                 //if($val !== '0' && (empty($param) || empty($val))) {
887
-                                if(empty($param)) {
886
+                                if (empty($param)) {
888 887
                                     continue;
889 888
                                 }
890 889
                             }
891 890
                             $params[$param] = $val;
892 891
                         }
893
-                    } elseif(preg_match("/^\s*\*\/\s*$/", $line)) {
892
+                    } elseif (preg_match("/^\s*\*\/\s*$/", $line)) {
894 893
                         break;
895 894
                     }
896 895
                 }
@@ -921,13 +920,13 @@  discard block
 block discarded – undo
921 920
     // display database results
922 921
     if ($sqlParser->installFailed == true) {
923 922
         $errors += 1;
924
-        echo $_lang['database_alerts'] . PHP_EOL;
925
-        echo $_lang['setup_couldnt_install'] . PHP_EOL;
926
-        echo $_lang['installation_error_occured'] . PHP_EOL;
923
+        echo $_lang['database_alerts'].PHP_EOL;
924
+        echo $_lang['setup_couldnt_install'].PHP_EOL;
925
+        echo $_lang['installation_error_occured'].PHP_EOL;
927 926
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
928
-            echo $sqlParser->mysqlErrors[$i]["error"] . " " . $_lang['during_execution_of_sql'] . " " . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . PHP_EOL;
927
+            echo $sqlParser->mysqlErrors[$i]["error"]." ".$_lang['during_execution_of_sql']." ".strip_tags($sqlParser->mysqlErrors[$i]["sql"]).PHP_EOL;
929 928
         }
930
-        echo $_lang['some_tables_not_updated'] . PHP_EOL;
929
+        echo $_lang['some_tables_not_updated'].PHP_EOL;
931 930
         die();
932 931
     } else {
933 932
         echo $_lang['ok'].PHP_EOL;
@@ -937,7 +936,7 @@  discard block
 block discarded – undo
937 936
 // custom or not
938 937
 if (file_exists($path."../assets/cache/siteManager.php")) {
939 938
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
940
-}else{
939
+} else {
941 940
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
942 941
 }
943 942
 
@@ -974,16 +973,16 @@  discard block
 block discarded – undo
974 973
 $chmodSuccess = @chmod($filename, 0404);
975 974
 
976 975
 if ($configFileFailed == true) {
977
-    echo $_lang['failed'] . PHP_EOL;
976
+    echo $_lang['failed'].PHP_EOL;
978 977
     $errors += 1;
979 978
 
980
-    echo $_lang['cant_write_config_file'] . ' ' . MGR_DIR .'/includes/config.inc.php' .PHP_EOL;
979
+    echo $_lang['cant_write_config_file'].' '.MGR_DIR.'/includes/config.inc.php'.PHP_EOL;
981 980
     echo ' '.PHP_EOL;
982 981
     echo ' '.PHP_EOL;
983 982
     echo $configString;
984 983
     echo ' '.PHP_EOL;
985 984
     echo ' '.PHP_EOL;
986
-    echo $_lang['cant_write_config_file_note'] . PHP_EOL;
985
+    echo $_lang['cant_write_config_file_note'].PHP_EOL;
987 986
     die();
988 987
 
989 988
 } else {
@@ -993,16 +992,16 @@  discard block
 block discarded – undo
993 992
 // generate new site_id and set manager theme to default
994 993
 if ($installMode == 0) {
995 994
     $siteid = uniqid('');
996
-    mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
995
+    mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
997 996
 } else {
998 997
     // update site_id if missing
999
-    $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'");
998
+    $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`".$table_prefix."system_settings` WHERE setting_name='site_id'");
1000 999
     if ($ds) {
1001 1000
         $r = mysqli_fetch_assoc($ds);
1002 1001
         $siteid = $r['setting_value'];
1003 1002
         if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') {
1004 1003
             $siteid = uniqid('');
1005
-            mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
1004
+            mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
1006 1005
         }
1007 1006
     }
1008 1007
 }
@@ -1014,29 +1013,29 @@  discard block
 block discarded – undo
1014 1013
     // display database results
1015 1014
     if ($sqlParser->installFailed == true) {
1016 1015
         $errors += 1;
1017
-        echo $_lang['database_alerts'] . PHP_EOL;
1018
-        echo $_lang['setup_couldnt_install'] . PHP_EOL;
1019
-        echo $_lang['installation_error_occured'] . PHP_EOL . PHP_EOL;
1016
+        echo $_lang['database_alerts'].PHP_EOL;
1017
+        echo $_lang['setup_couldnt_install'].PHP_EOL;
1018
+        echo $_lang['installation_error_occured'].PHP_EOL.PHP_EOL;
1020 1019
         /*
1021 1020
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
1022 1021
             echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />";
1023 1022
         }
1024 1023
         echo "</p>";*/
1025
-        echo $_lang['some_tables_not_updated'] . PHP_EOL;
1024
+        echo $_lang['some_tables_not_updated'].PHP_EOL;
1026 1025
         die();
1027 1026
     } else {
1028
-        echo $_lang['ok'] . PHP_EOL;
1027
+        echo $_lang['ok'].PHP_EOL;
1029 1028
     }
1030 1029
 }
1031 1030
 
1032 1031
 // Install Templates
1033 1032
 $moduleTemplate = $mt; 
1034 1033
 if (!empty($moduleTemplate) || $installData) {
1035
-    echo PHP_EOL . $_lang['templates'] . ":" . PHP_EOL;
1034
+    echo PHP_EOL.$_lang['templates'].":".PHP_EOL;
1036 1035
     //$selTemplates = $_POST['template'];
1037 1036
     foreach ($moduleTemplates as $k=>$moduleTemplate) {
1038 1037
         $installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1;
1039
-        if($installSample || is_array($moduleTemplate)) {
1038
+        if ($installSample || is_array($moduleTemplate)) {
1040 1039
             $name = mysqli_real_escape_string($conn, $moduleTemplate[0]);
1041 1040
             $desc = mysqli_real_escape_string($conn, $moduleTemplate[1]);
1042 1041
             $category = mysqli_real_escape_string($conn, $moduleTemplate[4]);
@@ -1044,7 +1043,7 @@  discard block
 block discarded – undo
1044 1043
             $filecontent = $moduleTemplate[3];
1045 1044
             $save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site
1046 1045
             if (!file_exists($filecontent)) {
1047
-                echo "  $name: " . $_lang['unable_install_template'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1046
+                echo "  $name: ".$_lang['unable_install_template']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1048 1047
             } else {
1049 1048
                 // Create the category if it does not already exist
1050 1049
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -1054,31 +1053,31 @@  discard block
 block discarded – undo
1054 1053
                 $template = mysqli_real_escape_string($conn, $template);
1055 1054
 
1056 1055
                 // See if the template already exists
1057
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'");
1056
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name'");
1058 1057
 
1059 1058
                 if (mysqli_num_rows($rs)) {
1060
-                    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;")) {
1059
+                    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;")) {
1061 1060
                         $errors += 1;
1062
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1061
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1063 1062
                         return;
1064 1063
                     }
1065
-                    if(!is_null($save_sql_id_as)) {
1064
+                    if (!is_null($save_sql_id_as)) {
1066 1065
                         $sql_id = @mysqli_insert_id($sqlParser->conn);
1067
-                        if(!$sql_id) {
1068
-                            $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;"));
1066
+                        if (!$sql_id) {
1067
+                            $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name' LIMIT 1;"));
1069 1068
                             $sql_id = $idQuery['id'];
1070 1069
                         }
1071 1070
                         $custom_placeholders[$save_sql_id_as] = $sql_id;
1072 1071
                     }
1073
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1072
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1074 1073
                 } else {
1075
-                    if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) {
1074
+                    if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) {
1076 1075
                         $errors += 1;
1077
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1076
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1078 1077
                         die();
1079 1078
                     }
1080
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1081
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1079
+                    if (!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1080
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1082 1081
                 }
1083 1082
             }
1084 1083
         }
@@ -1088,11 +1087,11 @@  discard block
 block discarded – undo
1088 1087
 // Install Template Variables
1089 1088
 $moduleTVs = $mtv;
1090 1089
 if (is_array($moduleTVs) || $installData) {
1091
-    echo PHP_EOL . $_lang['tvs'].': '.PHP_EOL;
1090
+    echo PHP_EOL.$_lang['tvs'].': '.PHP_EOL;
1092 1091
     //$selTVs = $_POST['tv'];
1093 1092
     foreach ($moduleTVs as $k=>$moduleTV) {
1094 1093
         $installSample = in_array('sample', $moduleTV[12]) && $installData == 1;
1095
-        if($installSample || is_array($moduleTVs)) {
1094
+        if ($installSample || is_array($moduleTVs)) {
1096 1095
             $name = mysqli_real_escape_string($conn, $moduleTV[0]);
1097 1096
             $caption = mysqli_real_escape_string($conn, $moduleTV[1]);
1098 1097
             $desc = mysqli_real_escape_string($conn, $moduleTV[2]);
@@ -1110,24 +1109,24 @@  discard block
 block discarded – undo
1110 1109
             // Create the category if it does not already exist
1111 1110
             $category = getCreateDbCategory($category, $sqlParser);
1112 1111
 
1113
-            $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'");
1112
+            $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name'");
1114 1113
             if (mysqli_num_rows($rs)) {
1115 1114
                 $insert = true;
1116
-                while($row = mysqli_fetch_assoc($rs)) {
1117
-                    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']};")) {
1118
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1115
+                while ($row = mysqli_fetch_assoc($rs)) {
1116
+                    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']};")) {
1117
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1119 1118
                         return;
1120 1119
                     }
1121 1120
                     $insert = false;
1122 1121
                 }
1123
-                echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1122
+                echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1124 1123
             } else {
1125
-                $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');";
1124
+                $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');";
1126 1125
                 if (!mysqli_query($sqlParser->conn, $q)) {
1127
-                    echo mysqli_error($sqlParser->conn) . PHP_EOL;
1126
+                    echo mysqli_error($sqlParser->conn).PHP_EOL;
1128 1127
                     return;
1129 1128
                 }
1130
-                echo "  $name: " . $_lang['installed'] . PHP_EOL;
1129
+                echo "  $name: ".$_lang['installed'].PHP_EOL;
1131 1130
             }
1132 1131
 
1133 1132
             // add template assignments
@@ -1136,10 +1135,10 @@  discard block
 block discarded – undo
1136 1135
             if (count($assignments) > 0) {
1137 1136
 
1138 1137
                 // remove existing tv -> template assignments
1139
-                $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
1138
+                $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
1140 1139
                 $row = mysqli_fetch_assoc($ds);
1141 1140
                 $id = $row["id"];
1142
-                mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\'');
1141
+                mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_tmplvar_templates` WHERE tmplvarid = \''.$id.'\'');
1143 1142
 
1144 1143
                 // add tv -> template assignments
1145 1144
                 foreach ($assignments as $assignment) {
@@ -1148,7 +1147,7 @@  discard block
 block discarded – undo
1148 1147
                     if ($ds && $ts) {
1149 1148
                         $tRow = mysqli_fetch_assoc($ts);
1150 1149
                         $templateId = $tRow['id'];
1151
-                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
1150
+                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
1152 1151
                    }
1153 1152
                 }
1154 1153
             }
@@ -1159,12 +1158,12 @@  discard block
 block discarded – undo
1159 1158
 
1160 1159
 $moduleChunks = $mc;
1161 1160
 // Install Chunks
1162
-if (is_array ($moduleChunks) || $installData) {
1163
-    echo PHP_EOL . $_lang['chunks'] . ": " . PHP_EOL;
1161
+if (is_array($moduleChunks) || $installData) {
1162
+    echo PHP_EOL.$_lang['chunks'].": ".PHP_EOL;
1164 1163
     foreach ($moduleChunks as $k=>$moduleChunk) {
1165 1164
         $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1;
1166 1165
         $count_new_name = 0;
1167
-        if($installSample || is_array ($moduleChunks)) {
1166
+        if ($installSample || is_array($moduleChunks)) {
1168 1167
 
1169 1168
             $name = mysqli_real_escape_string($conn, $moduleChunk[0]);
1170 1169
             $desc = mysqli_real_escape_string($conn, $moduleChunk[1]);
@@ -1173,7 +1172,7 @@  discard block
 block discarded – undo
1173 1172
             $filecontent = $moduleChunk[2];
1174 1173
 
1175 1174
             if (!file_exists($filecontent))
1176
-                echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1175
+                echo "  $name: ".$_lang['unable_install_chunk']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1177 1176
             else {
1178 1177
 
1179 1178
                 // Create the category if it does not already exist
@@ -1181,31 +1180,31 @@  discard block
 block discarded – undo
1181 1180
 
1182 1181
                 $chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1);
1183 1182
                 $chunk = mysqli_real_escape_string($conn, $chunk);
1184
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'");
1183
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$name'");
1185 1184
                 $count_original_name = mysqli_num_rows($rs);
1186
-                if($overwrite == 'false') {
1187
-                    $newname = $name . '-' . str_replace('.', '_', $modx_version);
1188
-                    $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'");
1185
+                if ($overwrite == 'false') {
1186
+                    $newname = $name.'-'.str_replace('.', '_', $modx_version);
1187
+                    $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$newname'");
1189 1188
                     $count_new_name = mysqli_num_rows($rs);
1190 1189
                 }
1191 1190
                 $update = $count_original_name > 0 && $overwrite == 'true';
1192 1191
                 if ($update) {
1193
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
1192
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
1194 1193
                         $errors += 1;
1195
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1194
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1196 1195
                         return;
1197 1196
                     }
1198
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1199
-                } elseif($count_new_name == 0) {
1200
-                    if($count_original_name > 0 && $overwrite == 'false') {
1197
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1198
+                } elseif ($count_new_name == 0) {
1199
+                    if ($count_original_name > 0 && $overwrite == 'false') {
1201 1200
                         $name = $newname;
1202 1201
                     }
1203
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) {
1202
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) {
1204 1203
                         $errors += 1;
1205
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1204
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1206 1205
                         return;
1207 1206
                     }
1208
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1207
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1209 1208
                 }
1210 1209
             }
1211 1210
         }
@@ -1215,11 +1214,11 @@  discard block
 block discarded – undo
1215 1214
 // Install Modules
1216 1215
 $moduleModules = $mm;
1217 1216
 if (is_array($moduleModules) || $installData) {
1218
-    echo PHP_EOL . $_lang['modules'] . ":" . PHP_EOL;
1217
+    echo PHP_EOL.$_lang['modules'].":".PHP_EOL;
1219 1218
     //$selModules = $_POST['module'];
1220 1219
     foreach ($moduleModules as $k=>$moduleModule) {
1221 1220
         $installSample = in_array('sample', $moduleModule[7]) && $installData == 1;
1222
-        if($installSample || is_array($moduleModules)) {
1221
+        if ($installSample || is_array($moduleModules)) {
1223 1222
             $name = mysqli_real_escape_string($conn, $moduleModule[0]);
1224 1223
             $desc = mysqli_real_escape_string($conn, $moduleModule[1]);
1225 1224
             $filecontent = $moduleModule[2];
@@ -1228,7 +1227,7 @@  discard block
 block discarded – undo
1228 1227
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
1229 1228
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
1230 1229
             if (!file_exists($filecontent))
1231
-                echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1230
+                echo "  $name: ".$_lang['unable_install_module']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1232 1231
             else {
1233 1232
 
1234 1233
                 // Create the category if it does not already exist
@@ -1237,24 +1236,24 @@  discard block
 block discarded – undo
1237 1236
                 $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
1238 1237
                 // $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab
1239 1238
                 $module = mysqli_real_escape_string($conn, $module);
1240
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'");
1239
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_modules` WHERE name='$name'");
1241 1240
                 if (mysqli_num_rows($rs)) {
1242 1241
                     $row = mysqli_fetch_assoc($rs);
1243
-                    $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1244
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
1245
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1242
+                    $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1243
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
1244
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1246 1245
                         return;
1247 1246
                     }
1248
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1247
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1249 1248
                 } else {
1250
-                    if ($properties != NULL ){
1249
+                    if ($properties != NULL) {
1251 1250
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1252 1251
                     }
1253
-                    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);")) {
1254
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
1252
+                    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);")) {
1253
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
1255 1254
                         return;
1256 1255
                     }
1257
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1256
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1258 1257
                 }
1259 1258
             }
1260 1259
         }
@@ -1264,11 +1263,11 @@  discard block
 block discarded – undo
1264 1263
 // Install Plugins
1265 1264
 $modulePlugins = $mp;
1266 1265
 if (is_array($modulePlugins) || $installData) {
1267
-    echo PHP_EOL . $_lang['plugins'] . ":" . PHP_EOL;
1266
+    echo PHP_EOL.$_lang['plugins'].":".PHP_EOL;
1268 1267
     $selPlugs = $_POST['plugin'];
1269 1268
     foreach ($modulePlugins as $k=>$modulePlugin) {
1270 1269
         //$installSample = in_array('sample', $modulePlugin[8]) && $installData == 1;
1271
-        if($installSample || is_array($modulePlugins)) {
1270
+        if ($installSample || is_array($modulePlugins)) {
1272 1271
             $name = mysqli_real_escape_string($conn, $modulePlugin[0]);
1273 1272
             $desc = mysqli_real_escape_string($conn, $modulePlugin[1]);
1274 1273
             $filecontent = $modulePlugin[2];
@@ -1278,17 +1277,17 @@  discard block
 block discarded – undo
1278 1277
             $category = mysqli_real_escape_string($conn, $modulePlugin[6]);
1279 1278
             $leg_names = '';
1280 1279
             $disabled = $modulePlugin[9];
1281
-            if(array_key_exists(7, $modulePlugin)) {
1280
+            if (array_key_exists(7, $modulePlugin)) {
1282 1281
                 // parse comma-separated legacy names and prepare them for sql IN clause
1283
-                $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
1282
+                $leg_names = "'".implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7])))."'";
1284 1283
             }
1285 1284
             if (!file_exists($filecontent))
1286
-                echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1285
+                echo "  $name: ".$_lang['unable_install_plugin']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1287 1286
             else {
1288 1287
 
1289 1288
                 // disable legacy versions based on legacy_names provided
1290
-                if(!empty($leg_names)) {
1291
-                    $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
1289
+                if (!empty($leg_names)) {
1290
+                    $update_query = "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
1292 1291
                     $rs = mysqli_query($sqlParser->conn, $update_query);
1293 1292
                 }
1294 1293
 
@@ -1298,52 +1297,52 @@  discard block
 block discarded – undo
1298 1297
                 $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
1299 1298
                 $plugin = removeDocblock($plugin, 'plugin');
1300 1299
                 $plugin = mysqli_real_escape_string($conn, $plugin);
1301
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'");
1300
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name'");
1302 1301
                 if (mysqli_num_rows($rs)) {
1303 1302
                     $insert = true;
1304
-                    while($row = mysqli_fetch_assoc($rs)) {
1305
-                        $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1306
-                        if($row['description'] == $desc){
1307
-                            if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1308
-                                echo mysqli_error($sqlParser->conn) . PHP_EOL;
1303
+                    while ($row = mysqli_fetch_assoc($rs)) {
1304
+                        $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1305
+                        if ($row['description'] == $desc) {
1306
+                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1307
+                                echo mysqli_error($sqlParser->conn).PHP_EOL;
1309 1308
                                 return;
1310 1309
                             }
1311 1310
                             $insert = false;
1312 1311
                         } else {
1313
-                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
1312
+                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
1314 1313
                                 echo mysqli_error($sqlParser->conn).PHP_EOL;
1315 1314
                                 return;
1316 1315
                             }
1317 1316
                         }
1318 1317
                     }
1319
-                    if($insert === true) {
1320
-                        $properties = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1321
-                        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);")) {
1318
+                    if ($insert === true) {
1319
+                        $properties = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1320
+                        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);")) {
1322 1321
                             echo mysqli_error($sqlParser->conn).PHP_EOL;
1323 1322
                             return;
1324 1323
                         }
1325 1324
                     }
1326
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1325
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1327 1326
                 } else {
1328
-                    if ($properties != NULL ){
1327
+                    if ($properties != NULL) {
1329 1328
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1330 1329
                     }
1331
-                    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);")) {
1332
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1330
+                    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);")) {
1331
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1333 1332
                         return;
1334 1333
                     }
1335
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1334
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1336 1335
                 }
1337 1336
                 // add system events
1338 1337
                 if (count($events) > 0) {
1339
-                    $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';");
1338
+                    $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';");
1340 1339
                     if ($ds) {
1341 1340
                         $row = mysqli_fetch_assoc($ds);
1342 1341
                         $id = $row["id"];
1343 1342
                         // remove existing events
1344
-                        mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_plugin_events` WHERE pluginid = \'' . $id . '\'');
1343
+                        mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_plugin_events` WHERE pluginid = \''.$id.'\'');
1345 1344
                         // add new events
1346
-                        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) . "')");
1345
+                        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)."')");
1347 1346
                     }
1348 1347
                 }
1349 1348
             }
@@ -1354,18 +1353,18 @@  discard block
 block discarded – undo
1354 1353
 // Install Snippets
1355 1354
 $moduleSnippet = $ms;
1356 1355
 if (is_array($moduleSnippet) || $installData) {
1357
-    echo PHP_EOL . $_lang['snippets'] . ":" . PHP_EOL;
1356
+    echo PHP_EOL.$_lang['snippets'].":".PHP_EOL;
1358 1357
     //$selSnips = $_POST['snippet'];
1359 1358
     foreach ($moduleSnippets as $k=>$moduleSnippet) {
1360 1359
         $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1;
1361
-        if($installSample || is_array($moduleSnippet)) {
1360
+        if ($installSample || is_array($moduleSnippet)) {
1362 1361
             $name = mysqli_real_escape_string($conn, $moduleSnippet[0]);
1363 1362
             $desc = mysqli_real_escape_string($conn, $moduleSnippet[1]);
1364 1363
             $filecontent = $moduleSnippet[2];
1365 1364
             $properties = $moduleSnippet[3];
1366 1365
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
1367 1366
             if (!file_exists($filecontent))
1368
-                echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1367
+                echo "  $name: ".$_lang['unable_install_snippet']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1369 1368
             else {
1370 1369
 
1371 1370
                 // Create the category if it does not already exist
@@ -1374,24 +1373,24 @@  discard block
 block discarded – undo
1374 1373
                 $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent)));
1375 1374
                 $snippet = removeDocblock($snippet, 'snippet');
1376 1375
                 $snippet = mysqli_real_escape_string($conn, $snippet);
1377
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'");
1376
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_snippets` WHERE name='$name'");
1378 1377
                 if (mysqli_num_rows($rs)) {
1379 1378
                     $row = mysqli_fetch_assoc($rs);
1380
-                    $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1381
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
1382
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1379
+                    $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1380
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
1381
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1383 1382
                         return;
1384 1383
                     }
1385
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1384
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1386 1385
                 } else {
1387
-                    if ($properties != NULL ){
1386
+                    if ($properties != NULL) {
1388 1387
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1389 1388
                     }
1390
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
1391
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1389
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
1390
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1392 1391
                         return;
1393 1392
                     }
1394
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1393
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1395 1394
                 }
1396 1395
             }
1397 1396
         }
@@ -1400,24 +1399,24 @@  discard block
 block discarded – undo
1400 1399
 
1401 1400
 // Install demo-site
1402 1401
 if ($installData && $moduleSQLDataFile) {
1403
-    echo PHP_EOL . $_lang['installing_demo_site'];
1402
+    echo PHP_EOL.$_lang['installing_demo_site'];
1404 1403
     $sqlParser->process($moduleSQLDataFile);
1405 1404
     // display database results
1406 1405
     if ($sqlParser->installFailed == true) {
1407 1406
         $errors += 1;
1408
-        echo $_lang['database_alerts'] . PHP_EOL;
1409
-        echo $_lang['setup_couldnt_install'] . PHP_EOL;
1410
-        echo $_lang['installation_error_occured'] . PHP_EOL . PHP_EOL;
1407
+        echo $_lang['database_alerts'].PHP_EOL;
1408
+        echo $_lang['setup_couldnt_install'].PHP_EOL;
1409
+        echo $_lang['installation_error_occured'].PHP_EOL.PHP_EOL;
1411 1410
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
1412
-            echo $sqlParser->mysqlErrors[$i]["error"] . " " . $_lang['during_execution_of_sql'] . " " . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . PHP_EOL;
1411
+            echo $sqlParser->mysqlErrors[$i]["error"]." ".$_lang['during_execution_of_sql']." ".strip_tags($sqlParser->mysqlErrors[$i]["sql"]).PHP_EOL;
1413 1412
         }
1414 1413
 
1415
-        echo $_lang['some_tables_not_updated'] . PHP_EOL;
1414
+        echo $_lang['some_tables_not_updated'].PHP_EOL;
1416 1415
         return;
1417 1416
     } else {
1418 1417
         $sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", $sqlParser->prefix);
1419 1418
         $rs = mysqli_query($sqlParser->conn, $sql);
1420
-        if(mysqli_num_rows($rs)) {
1419
+        if (mysqli_num_rows($rs)) {
1421 1420
             $row = mysqli_fetch_assoc($rs);
1422 1421
             $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']);
1423 1422
             mysqli_query($sqlParser->conn, $sql);
@@ -1429,9 +1428,9 @@  discard block
 block discarded – undo
1429 1428
 // Install Dependencies
1430 1429
 $moduleDependencies = $mdp;
1431 1430
 foreach ($moduleDependencies as $dependency) {
1432
-    $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"');
1431
+    $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM '.$dbase.'`'.$sqlParser->prefix.'site_modules` WHERE name="'.$dependency['module'].'"');
1433 1432
     if (!$ds) {
1434
-        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1433
+        echo mysqli_error($sqlParser->conn).PHP_EOL;
1435 1434
         return;
1436 1435
     } else {
1437 1436
         $row = mysqli_fetch_assoc($ds);
@@ -1439,37 +1438,37 @@  discard block
 block discarded – undo
1439 1438
         $moduleGuid = $row["guid"];
1440 1439
     }
1441 1440
     // get extra id
1442
-    $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"');
1441
+    $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE '.$dependency['column'].'="'.$dependency['name'].'"');
1443 1442
     if (!$ds) {
1444
-        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1443
+        echo mysqli_error($sqlParser->conn).PHP_EOL;
1445 1444
         return;
1446 1445
     } else {
1447 1446
         $row = mysqli_fetch_assoc($ds);
1448 1447
         $extraId = $row["id"];
1449 1448
     }
1450 1449
     // setup extra as module dependency
1451
-    $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');
1450
+    $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');
1452 1451
     if (!$ds) {
1453
-        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1452
+        echo mysqli_error($sqlParser->conn).PHP_EOL;
1454 1453
         return;
1455 1454
     } else {
1456 1455
         if (mysqli_num_rows($ds) === 0) {
1457
-            mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')');
1458
-            echo $dependency['module'] . ' Module: ' . $_lang['depedency_create'] . PHP_EOL;
1456
+            mysqli_query($sqlParser->conn, 'INSERT INTO '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` (module, resource, type) VALUES('.$moduleId.','.$extraId.','.$dependency['type'].')');
1457
+            echo $dependency['module'].' Module: '.$_lang['depedency_create'].PHP_EOL;
1459 1458
         } else {
1460
-            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']);
1461
-            echo $dependency['module'] . ' Module: ' . $_lang['depedency_update'] . PHP_EOL;
1459
+            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']);
1460
+            echo $dependency['module'].' Module: '.$_lang['depedency_update'].PHP_EOL;
1462 1461
         }
1463 1462
         if ($dependency['type'] == 30 || $dependency['type'] == 40) {
1464 1463
             // set extra guid for plugins and snippets
1465
-            $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1');
1464
+            $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE id='.$extraId.' LIMIT 1');
1466 1465
             if (!$ds) {
1467
-                echo mysqli_error($sqlParser->conn) . PHP_EOL;
1466
+                echo mysqli_error($sqlParser->conn).PHP_EOL;
1468 1467
                 return;
1469 1468
             } else {
1470 1469
                 if (mysqli_num_rows($ds) != 0) {
1471
-                    mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId);
1472
-                    echo $dependency['name'] . ': ' . $_lang['guid_set'] . PHP_EOL;
1470
+                    mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` SET moduleguid = '.$moduleGuid.' WHERE id='.$extraId);
1471
+                    echo $dependency['name'].': '.$_lang['guid_set'].PHP_EOL;
1473 1472
                 }
1474 1473
             }
1475 1474
         }
@@ -1478,7 +1477,7 @@  discard block
 block discarded – undo
1478 1477
 
1479 1478
 // call back function
1480 1479
 if ($callBackFnc != "")
1481
-    $callBackFnc ($sqlParser);
1480
+    $callBackFnc($sqlParser);
1482 1481
 
1483 1482
 // Setup the MODX API -- needed for the cache processor
1484 1483
 if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
@@ -1511,17 +1510,17 @@  discard block
 block discarded – undo
1511 1510
 }
1512 1511
 
1513 1512
 // setup completed!
1514
-echo PHP_EOL . $_lang['installation_successful'] . PHP_EOL . PHP_EOL;
1513
+echo PHP_EOL.$_lang['installation_successful'].PHP_EOL.PHP_EOL;
1515 1514
 //echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>";
1516 1515
 if ($installMode == 0) {
1517
-   echo strip_tags($_lang['installation_note']) . PHP_EOL;
1516
+   echo strip_tags($_lang['installation_note']).PHP_EOL;
1518 1517
 } else {
1519
-   echo strip_tags($_lang['upgrade_note']) . PHP_EOL;
1518
+   echo strip_tags($_lang['upgrade_note']).PHP_EOL;
1520 1519
 }
1521 1520
 
1522 1521
 
1523
-if ( empty($args) ){
1524
-    echo PHP_EOL . 'Remove install folder?'.PHP_EOL;
1522
+if (empty($args)) {
1523
+    echo PHP_EOL.'Remove install folder?'.PHP_EOL;
1525 1524
     $removeInstall = readline("Type 'y' or 'n' to continue: ");
1526 1525
 }
1527 1526
 //remove installFolder
@@ -1529,7 +1528,7 @@  discard block
 block discarded – undo
1529 1528
     removeFolder($path);
1530 1529
     removeFolder($base_path.'.tx');
1531 1530
     unlink($base_path.'README.md');
1532
-    echo 'Install folder deleted!'. PHP_EOL . PHP_EOL;
1531
+    echo 'Install folder deleted!'.PHP_EOL.PHP_EOL;
1533 1532
 }
1534 1533
 
1535 1534
 /**
@@ -1568,11 +1567,11 @@  discard block
 block discarded – undo
1568 1567
  * @param string $old
1569 1568
  * @return string
1570 1569
  */
1571
-function propUpdate($new,$old){
1570
+function propUpdate($new, $old){
1572 1571
     $newArr = parseProperties($new);
1573 1572
     $oldArr = parseProperties($old);
1574
-    foreach ($oldArr as $k => $v){
1575
-        if (isset($v['0']['options'])){
1573
+    foreach ($oldArr as $k => $v) {
1574
+        if (isset($v['0']['options'])) {
1576 1575
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
1577 1576
         }
1578 1577
     }
@@ -1587,30 +1586,30 @@  discard block
 block discarded – undo
1587 1586
  * @param bool|mixed $json
1588 1587
  * @return string
1589 1588
  */
1590
-function parseProperties($propertyString, $json=false) {
1591
-    $propertyString = str_replace('{}', '', $propertyString );
1592
-    $propertyString = str_replace('} {', ',', $propertyString );
1589
+function parseProperties($propertyString, $json = false){
1590
+    $propertyString = str_replace('{}', '', $propertyString);
1591
+    $propertyString = str_replace('} {', ',', $propertyString);
1593 1592
 
1594
-    if(empty($propertyString)) return array();
1595
-    if($propertyString=='{}' || $propertyString=='[]') return array();
1593
+    if (empty($propertyString)) return array();
1594
+    if ($propertyString == '{}' || $propertyString == '[]') return array();
1596 1595
 
1597 1596
     $jsonFormat = isJson($propertyString, true);
1598 1597
     $property = array();
1599 1598
     // old format
1600
-    if ( $jsonFormat === false) {
1601
-        $props= explode('&', $propertyString);
1599
+    if ($jsonFormat === false) {
1600
+        $props = explode('&', $propertyString);
1602 1601
         foreach ($props as $prop) {
1603 1602
             $prop = trim($prop);
1604
-            if($prop === '') {
1603
+            if ($prop === '') {
1605 1604
                 continue;
1606 1605
             }
1607 1606
 
1608 1607
             $arr = explode(';', $prop);
1609
-            if( ! is_array($arr)) {
1608
+            if (!is_array($arr)) {
1610 1609
                 $arr = array();
1611 1610
             }
1612 1611
             $key = explode('=', isset($arr[0]) ? $arr[0] : '');
1613
-            if( ! is_array($key) || empty($key[0])) {
1612
+            if (!is_array($key) || empty($key[0])) {
1614 1613
                 continue;
1615 1614
             }
1616 1615
 
@@ -1634,7 +1633,7 @@  discard block
 block discarded – undo
1634 1633
 
1635 1634
         }
1636 1635
     // new json-format
1637
-    } else if(!empty($jsonFormat)){
1636
+    } else if (!empty($jsonFormat)) {
1638 1637
         $property = $jsonFormat;
1639 1638
     }
1640 1639
     if ($json) {
@@ -1649,7 +1648,7 @@  discard block
 block discarded – undo
1649 1648
  * @param bool $returnData
1650 1649
  * @return bool|mixed
1651 1650
  */
1652
-function isJson($string, $returnData=false) {
1651
+function isJson($string, $returnData = false){
1653 1652
     $data = json_decode($string, true);
1654 1653
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
1655 1654
 }
@@ -1659,20 +1658,20 @@  discard block
 block discarded – undo
1659 1658
  * @param SqlParser $sqlParser
1660 1659
  * @return int
1661 1660
  */
1662
-function getCreateDbCategory($category, $sqlParser) {
1661
+function getCreateDbCategory($category, $sqlParser){
1663 1662
     $dbase = $sqlParser->dbname;
1664
-    $dbase = '`' . trim($dbase,'`') . '`';
1663
+    $dbase = '`'.trim($dbase, '`').'`';
1665 1664
     $table_prefix = $sqlParser->prefix;
1666 1665
     $category_id = 0;
1667
-    if(!empty($category)) {
1666
+    if (!empty($category)) {
1668 1667
         $category = mysqli_real_escape_string($sqlParser->conn, $category);
1669 1668
         $rs = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."categories` WHERE category = '".$category."'");
1670
-        if(mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) {
1669
+        if (mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) {
1671 1670
             $category_id = $row['id'];
1672 1671
         } else {
1673 1672
             $q = "INSERT INTO $dbase.`".$table_prefix."categories` (`category`) VALUES ('{$category}');";
1674 1673
             $rs = mysqli_query($sqlParser->conn, $q);
1675
-            if($rs) {
1674
+            if ($rs) {
1676 1675
                 $category_id = mysqli_insert_id($sqlParser->conn);
1677 1676
             }
1678 1677
         }
@@ -1687,12 +1686,12 @@  discard block
 block discarded – undo
1687 1686
  * @param string $type
1688 1687
  * @return string
1689 1688
  */
1690
-function removeDocblock($code, $type) {
1689
+function removeDocblock($code, $type){
1691 1690
 
1692 1691
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
1693 1692
 
1694 1693
     // Procedure taken from plugin.filesource.php
1695
-    switch($type) {
1694
+    switch ($type) {
1696 1695
         case 'snippet':
1697 1696
             $elm_name = 'snippets';
1698 1697
             $include = 'return require';
@@ -1708,7 +1707,7 @@  discard block
 block discarded – undo
1708 1707
         default:
1709 1708
             return $cleaned;
1710 1709
     };
1711
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
1710
+    if (substr(trim($cleaned), 0, $count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
1712 1711
         return $cleaned;
1713 1712
 
1714 1713
     // fileBinding not found - return code incl docblock
Please login to merge, or discard this patch.
manager/actions/import_site.static.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -346,7 +346,7 @@
 block discarded – undo
346 346
 
347 347
 /**
348 348
  * @param string $filepath
349
- * @return bool|string
349
+ * @return null|string
350 350
  */
351 351
 function getFileContent($filepath)
352 352
 {
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if (!$modx->hasPermission('import_static')) {
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		<div class="container container-body">
45 45
 			<?php
46 46
             if (!isset($_POST['import'])) {
47
-                echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; ?>
47
+                echo "<div class=\"element-edit-message\">".$_lang['import_site_message']."</div>"; ?>
48 48
 				<form action="index.php" method="post" name="importFrm">
49 49
 					<input type="hidden" name="import" value="import" />
50 50
 					<input type="hidden" name="a" value="95" />
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
         $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
128 128
     }
129 129
 
130
-    $parent = (int)$_POST['parent'];
130
+    $parent = (int) $_POST['parent'];
131 131
 
132
-    if (is_dir(MODX_BASE_PATH . 'temp/import')) {
133
-        $filedir = MODX_BASE_PATH . 'temp/import/';
134
-    } elseif (is_dir(MODX_BASE_PATH . 'assets/import')) {
135
-        $filedir = MODX_BASE_PATH . 'assets/import/';
132
+    if (is_dir(MODX_BASE_PATH.'temp/import')) {
133
+        $filedir = MODX_BASE_PATH.'temp/import/';
134
+    } elseif (is_dir(MODX_BASE_PATH.'assets/import')) {
135
+        $filedir = MODX_BASE_PATH.'assets/import/';
136 136
     } else {
137 137
         $filedir = '';
138 138
     }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     $files = pop_index($files);
144 144
 
145 145
     // no. of files to import
146
-    $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
146
+    $output .= sprintf('<p>'.$_lang['import_files_found'].'</p>', $filesfound);
147 147
 
148 148
     // import files
149 149
     if (0 < count($files)) {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     $mtime = $mtime[1] + $mtime[0];
157 157
     $importend = $mtime;
158 158
     $totaltime = ($importend - $importstart);
159
-    $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
159
+    $output .= sprintf('<p>'.$_lang['import_site_time'].'</p>', round($totaltime, 3));
160 160
 
161 161
     if ($_POST['convert_link'] == 'on') {
162 162
         convertLink();
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         if (is_array($value)) {
196 196
             // create folder
197 197
             $alias = $id;
198
-            printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
198
+            printf('<span>'.$_lang['import_site_importing_document'].'</span>', $alias);
199 199
             $field = array();
200 200
             $field['type'] = 'document';
201 201
             $field['contentType'] = 'text/html';
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
                         'index.html',
215 215
                         'index.htm'
216 216
                     ) as $filename) {
217
-                $filepath = $filedir . $alias . '/' . $filename;
217
+                $filepath = $filedir.$alias.'/'.$filename;
218 218
                 if ($find === false && file_exists($filepath)) {
219 219
                     $file = getFileContent($filepath);
220 220
                     list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
                     $newid = $modx->db->insert($field, $tbl_site_content);
230 230
                     if ($newid) {
231 231
                         $find = true;
232
-                        echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
233
-                        importFiles($newid, $filedir . $alias . '/', $value, 'sub');
232
+                        echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
233
+                        importFiles($newid, $filedir.$alias.'/', $value, 'sub');
234 234
                     } else {
235
-                        echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
235
+                        echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
236 236
                         exit;
237 237
                     }
238 238
                 }
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
                 $newid = $modx->db->insert($field, $tbl_site_content);
248 248
                 if ($newid) {
249 249
                     $find = true;
250
-                    echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
251
-                    importFiles($newid, $filedir . $alias . '/', $value, 'sub');
250
+                    echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
251
+                    importFiles($newid, $filedir.$alias.'/', $value, 'sub');
252 252
                 } else {
253
-                    echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
253
+                    echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
254 254
                     exit;
255 255
                 }
256 256
             }
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
             $fparts = explode('.', $value);
264 264
             $alias = $fparts[0];
265 265
             $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
266
-            printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
266
+            printf("<span>".$_lang['import_site_importing_document']."</span>", $filename);
267 267
 
268 268
             if (!in_array($ext, $allowedfiles)) {
269
-                echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
269
+                echo ' - <span class="fail">'.$_lang["import_site_skip"].'</span><br />'."\n";
270 270
             } else {
271
-                $filepath = $filedir . $filename;
271
+                $filepath = $filedir.$filename;
272 272
                 $file = getFileContent($filepath);
273 273
                 list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
274 274
 
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
                 $field['menuindex'] = ($alias == 'index') ? 0 : 2;
295 295
                 $newid = $modx->db->insert($field, $tbl_site_content);
296 296
                 if ($newid) {
297
-                    echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
297
+                    echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
298 298
                 } else {
299
-                    echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
299
+                    echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
300 300
                     exit;
301 301
                 }
302 302
 
@@ -324,14 +324,14 @@  discard block
 block discarded – undo
324 324
     global $_lang;
325 325
     global $filesfound;
326 326
     $dummy = $count;
327
-    if (! empty($directory) && $files = scandir($directory)) {
327
+    if (!empty($directory) && $files = scandir($directory)) {
328 328
         foreach ($files as $file) {
329 329
             if ($file == '.' || $file == '..') {
330 330
                 continue;
331
-            } elseif ($h = @opendir($directory . $file . "/")) {
331
+            } elseif ($h = @opendir($directory.$file."/")) {
332 332
                 closedir($h);
333 333
                 $count = -1;
334
-                $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
334
+                $listing[$file] = getFiles($directory.$file."/", array(), $count + 1);
335 335
             } elseif (strpos($file, '.htm') !== false) {
336 336
                 $listing[$dummy] = $file;
337 337
                 $dummy = $dummy + 1;
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
             }
340 340
         }
341 341
     } else {
342
-        echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
342
+        echo '<p><span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_no_open_dir"].$directory.".</p>";
343 343
     }
344 344
     return ($listing);
345 345
 }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     global $_lang;
354 354
     // get the file
355 355
     if (!$buffer = file_get_contents($filepath)) {
356
-        echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
356
+        echo '<p><span class="fail">'.$_lang['import_site_failed']."</span> ".$_lang["import_site_failed_no_retrieve_file"].$filepath.".</p>";
357 357
     } else {
358 358
         return $buffer;
359 359
     }
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     } else {
416 416
         $content = $src;
417 417
         $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
418
-        $r = '$1' . $modx->config['modx_charset'] . '$2';
418
+        $r = '$1'.$modx->config['modx_charset'].'$2';
419 419
         $content = preg_replace($s, $r, $content);
420 420
         $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
421 421
     }
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
                 list($href, $v) = explode('"', $v, 2);
452 452
                 $_ = $href;
453 453
                 if (strpos($_, $modx->config['site_url']) !== false) {
454
-                    $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
454
+                    $_ = $modx->config['base_url'].str_replace($modx->config['site_url'], '', $_);
455 455
                 }
456 456
                 if ($_[0] === '/') {
457 457
                     $_ = substr($_, 1);
@@ -478,15 +478,15 @@  discard block
 block discarded – undo
478 478
                 if (strpos($_, '/') !== false) {
479 479
                     $_ = substr($_, strrpos($_, '/'));
480 480
                 }
481
-                $_ = $dir . str_replace('.html', '', $_);
481
+                $_ = $dir.str_replace('.html', '', $_);
482 482
                 if (!isset($target[$_])) {
483 483
                     $target[$_] = $modx->getIdFromAlias($_);
484 484
                 }
485 485
                 $target[$_] = trim($target[$_]);
486 486
                 if (!empty($target[$_])) {
487
-                    $href = '[~' . $target[$_] . '~]';
487
+                    $href = '[~'.$target[$_].'~]';
488 488
                 }
489
-                $array[$c] = '<a href="' . $href . '"' . $v;
489
+                $array[$c] = '<a href="'.$href.'"'.$v;
490 490
             }
491 491
             $c++;
492 492
         }
Please login to merge, or discard this patch.
manager/includes/controls/datagrid.class.php 2 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -72,6 +72,10 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public $cdelim;
74 74
 
75
+    /**
76
+     * @param null|string $id
77
+     * @param string $ds
78
+     */
75 79
     public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1)
76 80
     {
77 81
         global $__DataGridCnt;
@@ -212,6 +216,9 @@  discard block
 block discarded – undo
212 216
 
213 217
     // format column values
214 218
 
219
+    /**
220
+     * @param integer $n
221
+     */
215 222
     public function RenderRowFnc($n, $row)
216 223
     {
217 224
         if ($this->_alt == 0) {
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
 {
15 15
     public $ds; // datasource
16 16
     public $id;
17
-    public $pageSize;            // pager settings
17
+    public $pageSize; // pager settings
18 18
     public $pageNumber;
19 19
     public $pager;
20
-    public $pagerLocation;        // top-right, top-left, bottom-left, bottom-right, both-left, both-right
20
+    public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right
21 21
 
22 22
     public $cssStyle;
23 23
     public $cssClass;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public $colAligns;
36 36
     public $colWraps;
37 37
     public $colColors;
38
-    public $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
38
+    public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
39 39
     // data type: integer,float,currency,date
40 40
 
41 41
     public $header;
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public $cellPadding;
44 44
     public $cellSpacing;
45 45
 
46
-    public $rowAlign;            // vertical alignment: top, middle, bottom
46
+    public $rowAlign; // vertical alignment: top, middle, bottom
47 47
     public $rowIdField;
48 48
 
49 49
     public $pagerStyle;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
         // set id
80 80
         $__DataGridCnt++;
81
-        $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt;
81
+        $this->id = $this->id ? empty($id) : "dg".$__DataGridCnt;
82 82
 
83 83
         // set datasource
84 84
         $this->ds = $ds;
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
     public function render()
98 98
     {
99 99
         $modx = evolutionCMS();
100
-        $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
101
-        $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
102
-        $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
103
-        $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
100
+        $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='".$this->columnHeaderStyle."'" : '';
101
+        $columnHeaderClass = ($this->columnHeaderClass) ? "class='".$this->columnHeaderClass."'" : "";
102
+        $cssStyle = ($this->cssStyle) ? "style='".$this->cssStyle."'" : '';
103
+        $cssClass = ($this->cssClass) ? "class='".$this->cssClass."'" : '';
104 104
 
105
-        $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
106
-        $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
105
+        $pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : '';
106
+        $pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'";
107 107
 
108
-        $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
109
-        $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
110
-        $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
111
-        $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
108
+        $this->_itemStyle = ($this->itemStyle) ? "style='".$this->itemStyle."'" : '';
109
+        $this->_itemClass = ($this->itemClass) ? "class='".$this->itemClass."'" : '';
110
+        $this->_altItemStyle = ($this->altItemStyle) ? "style='".$this->altItemStyle."'" : '';
111
+        $this->_altItemClass = ($this->altItemClass) ? "class='".$this->altItemClass."'" : '';
112 112
 
113 113
         $this->_alt = 0;
114 114
         $this->_total = 0;
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
         if ($this->_isDataset && !$this->columns) {
132 132
             $cols = $modx->db->numFields($this->ds);
133 133
             for ($i = 0; $i < $cols; $i++) {
134
-                $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
134
+                $this->columns .= ($i ? "," : "").$modx->db->fieldName($this->ds, $i);
135 135
             }
136 136
         }
137 137
 
138 138
         // start grid
139
-        $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
139
+        $tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>";
140 140
         $tblEnd = "</table>";
141 141
 
142 142
         // build column header
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         for ($c = 0; $c < $this->_colcount; $c++) {
156 156
             $name = $this->_colnames[$c];
157 157
             $width = $this->_colwidths[$c];
158
-            $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
158
+            $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>";
159 159
         }
160 160
         $tblColHdr .= "</tr></thead>\n";
161 161
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
164 164
         $this->_fieldnames = explode(",", $this->fields);
165 165
         if ($rowcount == 0) {
166
-            $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
166
+            $tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n";
167 167
         } else {
168 168
             // render grid items
169 169
             if ($this->pageSize <= 0) {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                 }
174 174
             } else {
175 175
                 if (!$this->pager) {
176
-                    include_once dirname(__FILE__) . "/datasetpager.class.php";
176
+                    include_once dirname(__FILE__)."/datasetpager.class.php";
177 177
                     $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
178 178
                     $this->pager->setRenderRowFnc($this); // pass this object
179 179
                     $this->pager->cssStyle = $pagerStyle;
@@ -194,17 +194,17 @@  discard block
 block discarded – undo
194 194
         $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
195 195
         $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
196 196
         if ($this->header) {
197
-            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
197
+            $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>";
198 198
         }
199 199
         if ($tblPager && $ptop) {
200
-            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
200
+            $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager."&nbsp;</td></tr>";
201 201
         }
202
-        $o .= $tblColHdr . $tblRows;
202
+        $o .= $tblColHdr.$tblRows;
203 203
         if ($tblPager && $pbot) {
204
-            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
204
+            $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager."&nbsp;</td></tr>";
205 205
         }
206 206
         if ($this->footer) {
207
-            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
207
+            $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>";
208 208
         }
209 209
         $o .= $tblEnd;
210 210
         return $o;
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
             $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
235 235
             $value = $row[($this->_isDataset && $fld ? $fld : $c)];
236 236
             if ($color && $Style) {
237
-                $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
237
+                $colStyle = substr($colStyle, 0, -1).";background-color:$color;'";
238 238
             }
239 239
             $value = $this->formatColumnValue($row, $value, $type, $align);
240
-            $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
240
+            $o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>";
241 241
         }
242 242
         $o .= "</tr>\n";
243 243
         return $o;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
                 if (!$type_format) {
274 274
                     $type_format = 2;
275 275
                 }
276
-                $value = "$" . number_format($value, $type_format);
276
+                $value = "$".number_format($value, $type_format);
277 277
                 break;
278 278
 
279 279
             case "date":
Please login to merge, or discard this patch.
manager/includes/controls/datasetpager.class.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -31,6 +31,9 @@  discard block
 block discarded – undo
31 31
     public $renderPagerFnc;
32 32
     public $renderPagerFncArgs;
33 33
 
34
+    /**
35
+     * @param boolean|string $id
36
+     */
34 37
     public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1)
35 38
     {
36 39
         global $_PAGE; // use view state object
@@ -82,6 +85,9 @@  discard block
 block discarded – undo
82 85
         $this->pageSize = $ps;
83 86
     }
84 87
 
88
+    /**
89
+     * @param DataGrid $fncName
90
+     */
85 91
     public function setRenderRowFnc($fncName, $args = "")
86 92
     {
87 93
         $this->renderRowFnc = &$fncName;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
 
40 40
         // set id
41 41
         $__DataSetPagerCnt++;
42
-        $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
42
+        $this->id = !empty($id) ? $id : "dsp".$__DataSetPagerCnt;
43 43
 
44 44
         // get pagenumber
45 45
         // by setting pager to -1 cause pager to load it's last page number
46 46
         if ($pageNumber == -1) {
47 47
             $pageNumber = 1;
48
-            if (isset($_GET["dpgn" . $this->id])) {
49
-                $pageNumber = $_GET["dpgn" . $this->id];
50
-            } elseif (isset($_PAGE['vs'][$id . '_dpgn'])) {
51
-                $pageNumber = $_PAGE['vs'][$id . '_dpgn'];
48
+            if (isset($_GET["dpgn".$this->id])) {
49
+                $pageNumber = $_GET["dpgn".$this->id];
50
+            } elseif (isset($_PAGE['vs'][$id.'_dpgn'])) {
51
+                $pageNumber = $_PAGE['vs'][$id.'_dpgn'];
52 52
             }
53 53
         }
54 54
         if (!is_numeric($pageNumber)) {
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
     public function setRenderRowFnc($fncName, $args = "")
86 86
     {
87 87
         $this->renderRowFnc = &$fncName;
88
-        $this->renderRowFncArgs = $args;    // extra agruments
88
+        $this->renderRowFncArgs = $args; // extra agruments
89 89
     }
90 90
 
91 91
     public function setRenderPagerFnc($fncName, $args = "")
92 92
     {
93 93
         $this->renderPagerFnc = $fncName;
94
-        $this->renderPagerFncArgs = $args;    // extra agruments
94
+        $this->renderPagerFncArgs = $args; // extra agruments
95 95
     }
96 96
 
97 97
     public function render()
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
         // save page number to view state if available
136 136
         if (isset($_PAGE['vs'])) {
137
-            $_PAGE['vs'][$this->id . '_dpgn'] = $p;
137
+            $_PAGE['vs'][$this->id.'_dpgn'] = $p;
138 138
         }
139 139
 
140 140
         // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
             $args = $this->renderPagerFncArgs;
145 145
             if (!isset($fnc)) {
146 146
                 if ($modx->isFrontend()) {
147
-                    $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
147
+                    $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?';
148 148
                 } else {
149
-                    $url = $_SERVER['PHP_SELF'] . '?';
149
+                    $url = $_SERVER['PHP_SELF'].'?';
150 150
                 }
151 151
                 $i = 0;
152 152
                 foreach ($_GET as $n => $v) {
153
-                    if ($n != 'dpgn' . $this->id) {
153
+                    if ($n != 'dpgn'.$this->id) {
154 154
                         $i++;
155
-                        $url .= (($i > 1) ? "&" : "") . "$n=$v";
155
+                        $url .= (($i > 1) ? "&" : "")."$n=$v";
156 156
                     }
157 157
                 }
158 158
                 if ($i >= 1) {
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                         $this->pager .= $fnc($p, $i);
168 168
                     }
169 169
                 } else {
170
-                    $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> ";
170
+                    $this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> ";
171 171
                 }
172 172
             }
173 173
         }
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers.class.inc.php 3 patches
Doc Comments   +27 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     /**
102 102
      * @param string $mode
103 103
      * @param string $modifiers
104
-     * @return bool|string
104
+     * @return false|string
105 105
      */
106 106
     public function _getDelim($mode, $modifiers)
107 107
     {
@@ -149,6 +149,14 @@  discard block
 block discarded – undo
149 149
             return $opt;
150 150
         }
151 151
     }
152
+
153
+    /**
154
+     * @param string $mode
155
+     * @param false|string $delim
156
+     * @param string $modifiers
157
+     *
158
+     * @return string
159
+     */
152 160
     public function _getRemainModifiers($mode, $delim, $modifiers)
153 161
     {
154 162
         if ($delim) {
@@ -182,6 +190,9 @@  discard block
 block discarded – undo
182 190
         return substr($string, strpos($string, $delim)+$len);
183 191
     }
184 192
 
193
+    /**
194
+     * @param string $modifiers
195
+     */
185 196
     public function splitEachModifiers($modifiers)
186 197
     {
187 198
         $modx = evolutionCMS();
@@ -253,6 +264,10 @@  discard block
 block discarded – undo
253 264
         return $result;
254 265
     }
255 266
 
267
+    /**
268
+     * @param string $key
269
+     * @param string $value
270
+     */
256 271
     public function parsePhx($key, $value, $modifiers)
257 272
     {
258 273
         $modx = evolutionCMS();
@@ -332,6 +347,10 @@  discard block
 block discarded – undo
332 347
         }
333 348
     }
334 349
 
350
+    /**
351
+     * @param string $cmd
352
+     * @param string $opt
353
+     */
335 354
     public function getValueFromPreset($key, $value, $cmd, $opt)
336 355
     {
337 356
         $modx = evolutionCMS();
@@ -1185,6 +1204,9 @@  discard block
 block discarded – undo
1185 1204
         return $value;
1186 1205
     }
1187 1206
 
1207
+    /**
1208
+     * @param string $cmd
1209
+     */
1188 1210
     public function includeMdfFile($cmd)
1189 1211
     {
1190 1212
         $modx = evolutionCMS();
@@ -1374,6 +1396,10 @@  discard block
 block discarded – undo
1374 1396
     }
1375 1397
 
1376 1398
     // Sets a placeholder variable which can only be access by Modifiers
1399
+
1400
+    /**
1401
+     * @param string $value
1402
+     */
1377 1403
     public function setModifiersVariable($key, $value)
1378 1404
     {
1379 1405
         if ($key != 'phx' && $key != 'dummy') {
Please login to merge, or discard this patch.
Spacing   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (!defined('MODX_CORE_PATH')) {
4
-    define('MODX_CORE_PATH', MODX_MANAGER_PATH . 'includes/');
4
+    define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
5 5
 }
6 6
 
7 7
 class MODIFIERS
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
     public function phxFilter($key, $value, $modifiers)
79 79
     {
80 80
         $modx = evolutionCMS();
81
-        if (substr($modifiers, 0, 3)!=='id(') {
81
+        if (substr($modifiers, 0, 3) !== 'id(') {
82 82
             $value = $this->parseDocumentSource($value);
83 83
         }
84 84
         $this->srcValue = $value;
85 85
         $modifiers = trim($modifiers);
86
-        $modifiers = ':' . trim($modifiers, ':');
87
-        $modifiers = str_replace(array("\r\n","\r"), "\n", $modifiers);
86
+        $modifiers = ':'.trim($modifiers, ':');
87
+        $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers);
88 88
         $modifiers = $this->splitEachModifiers($modifiers);
89 89
 
90 90
         $this->placeholders = array();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         $this->placeholders['dummy'] = '';
93 93
         $this->condition = array();
94 94
         $this->vars = array();
95
-        $this->vars['name']    = & $key;
95
+        $this->vars['name'] = & $key;
96 96
         $value = $this->parsePhx($key, $value, $modifiers);
97 97
         $this->vars = array();
98 98
         return $value;
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
         }
112 112
 
113 113
         $modifiers = substr($modifiers, 1);
114
-        $closure = $mode=='(' ? "{$c})" : $c;
115
-        if (strpos($modifiers, $closure)===false) {
114
+        $closure = $mode == '(' ? "{$c})" : $c;
115
+        if (strpos($modifiers, $closure) === false) {
116 116
             return false;
117 117
         }
118 118
 
@@ -128,23 +128,23 @@  discard block
 block discarded – undo
128 128
     public function _getOpt($mode, $delim, $modifiers)
129 129
     {
130 130
         if ($delim) {
131
-            if ($mode=='(') {
132
-                return substr($modifiers, 1, strpos($modifiers, $delim . ')')-1);
131
+            if ($mode == '(') {
132
+                return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1);
133 133
             }
134 134
 
135
-            return substr($modifiers, 1, strpos($modifiers, $delim, 1)-1);
135
+            return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1);
136 136
         } else {
137
-            if ($mode=='(') {
137
+            if ($mode == '(') {
138 138
                 return substr($modifiers, 0, strpos($modifiers, ')'));
139 139
             }
140 140
 
141 141
             $chars = str_split($modifiers);
142
-            $opt='';
142
+            $opt = '';
143 143
             foreach ($chars as $c) {
144
-                if ($c==':' || $c==')') {
144
+                if ($c == ':' || $c == ')') {
145 145
                     break;
146 146
                 }
147
-                $opt .=$c;
147
+                $opt .= $c;
148 148
             }
149 149
             return $opt;
150 150
         }
@@ -152,20 +152,20 @@  discard block
 block discarded – undo
152 152
     public function _getRemainModifiers($mode, $delim, $modifiers)
153 153
     {
154 154
         if ($delim) {
155
-            if ($mode=='(') {
156
-                return $this->_fetchContent($modifiers, $delim . ')');
155
+            if ($mode == '(') {
156
+                return $this->_fetchContent($modifiers, $delim.')');
157 157
             } else {
158 158
                 $modifiers = trim($modifiers);
159 159
                 $modifiers = substr($modifiers, 1);
160 160
                 return $this->_fetchContent($modifiers, $delim);
161 161
             }
162 162
         } else {
163
-            if ($mode=='(') {
163
+            if ($mode == '(') {
164 164
                 return $this->_fetchContent($modifiers, ')');
165 165
             }
166 166
             $chars = str_split($modifiers);
167 167
             foreach ($chars as $c) {
168
-                if ($c==':') {
168
+                if ($c == ':') {
169 169
                     return $modifiers;
170 170
                 } else {
171 171
                     $modifiers = substr($modifiers, 1);
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     {
180 180
         $len = strlen($delim);
181 181
         $string = $this->parseDocumentSource($string);
182
-        return substr($string, strpos($string, $delim)+$len);
182
+        return substr($string, strpos($string, $delim) + $len);
183 183
     }
184 184
 
185 185
     public function splitEachModifiers($modifiers)
@@ -189,16 +189,16 @@  discard block
 block discarded – undo
189 189
         $cmd = '';
190 190
         $bt = '';
191 191
         $result = array();
192
-        while ($bt!==$modifiers) {
192
+        while ($bt !== $modifiers) {
193 193
             $bt = $modifiers;
194 194
             $c = substr($modifiers, 0, 1);
195 195
             $modifiers = substr($modifiers, 1);
196 196
 
197
-            if ($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
197
+            if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
198 198
                 $c = substr($modifiers, strlen($match[1]), 1);
199 199
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
200
-                if ($c==='(') {
201
-                    $modifiers = substr($modifiers, strlen($match[1])+1);
200
+                if ($c === '(') {
201
+                    $modifiers = substr($modifiers, strlen($match[1]) + 1);
202 202
                 } else {
203 203
                     $modifiers = substr($modifiers, strlen($match[1]));
204 204
                 }
@@ -207,33 +207,33 @@  discard block
 block discarded – undo
207 207
                 $opt       = $this->_getOpt($c, $delim, $modifiers);
208 208
                 $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers));
209 209
 
210
-                $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
210
+                $result[] = array('cmd'=>trim($match[1]), 'opt'=>$opt, 'debuginfo'=>$debuginfo);
211 211
                 $cmd = '';
212
-            } elseif (in_array($c, array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
212
+            } elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
213 213
                 $modifiers = substr($modifiers, strlen($match[0]));
214
-                $result[]=array('cmd'=>'math','opt'=>'%s' . $c . $match[0]);
214
+                $result[] = array('cmd'=>'math', 'opt'=>'%s'.$c.$match[0]);
215 215
                 $cmd = '';
216
-            } elseif ($c==='(' || $c==='=') {
216
+            } elseif ($c === '(' || $c === '=') {
217 217
                 $modifiers = $m1 = trim($modifiers);
218 218
                 $delim     = $this->_getDelim($c, $modifiers);
219 219
                 $opt       = $this->_getOpt($c, $delim, $modifiers);
220 220
                 $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers));
221 221
                 $debuginfo = "#i=1 #c=[{$c}] #delim=[{$delim}] #m1=[{$m1}] remainMdf=[{$modifiers}]";
222 222
 
223
-                $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo);
223
+                $result[] = array('cmd'=>trim($cmd), 'opt'=>$opt, 'debuginfo'=>$debuginfo);
224 224
 
225 225
                 $cmd = '';
226
-            } elseif ($c==':') {
226
+            } elseif ($c == ':') {
227 227
                 $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]";
228
-                if ($cmd!=='') {
229
-                    $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
228
+                if ($cmd !== '') {
229
+                    $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo);
230 230
                 }
231 231
 
232 232
                 $cmd = '';
233
-            } elseif (trim($modifiers)=='' && trim($cmd)!=='') {
233
+            } elseif (trim($modifiers) == '' && trim($cmd) !== '') {
234 234
                 $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]";
235 235
                 $cmd .= $c;
236
-                $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
236
+                $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo);
237 237
 
238 238
                 break;
239 239
             } else {
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
         }
271 271
         $_ = explode(',', $this->condModifiers);
272 272
         if (in_array($lastKey, $_)) {
273
-            $modifiers[] = array('cmd'=>'then','opt'=>'1');
274
-            $modifiers[] = array('cmd'=>'else','opt'=>'0');
273
+            $modifiers[] = array('cmd'=>'then', 'opt'=>'1');
274
+            $modifiers[] = array('cmd'=>'else', 'opt'=>'0');
275 275
         }
276 276
 
277 277
         foreach ($modifiers as $i=>$a) {
@@ -282,17 +282,17 @@  discard block
 block discarded – undo
282 282
     }
283 283
 
284 284
     // Parser: modifier detection and eXtended processing if needed
285
-    public function Filter($key, $value, $cmd, $opt='')
285
+    public function Filter($key, $value, $cmd, $opt = '')
286 286
     {
287 287
         $modx = evolutionCMS();
288 288
 
289
-        if ($key==='documentObject') {
289
+        if ($key === 'documentObject') {
290 290
             $value = $modx->documentIdentifier;
291 291
         }
292 292
         $cmd = $this->parseDocumentSource($cmd);
293 293
         if (preg_match('@^[1-9][/0-9]*$@', $cmd)) {
294
-            if (strpos($cmd, '/')!==false) {
295
-                $cmd = $this->substr($cmd, strrpos($cmd, '/')+1);
294
+            if (strpos($cmd, '/') !== false) {
295
+                $cmd = $this->substr($cmd, strrpos($cmd, '/') + 1);
296 296
             }
297 297
             $opt = $cmd;
298 298
             $cmd = 'id';
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         }
308 308
 
309 309
         $cmd = strtolower($cmd);
310
-        if ($this->elmName!=='') {
310
+        if ($this->elmName !== '') {
311 311
             $value = $this->getValueFromElement($key, $value, $cmd, $opt);
312 312
         } else {
313 313
             $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
@@ -320,11 +320,11 @@  discard block
 block discarded – undo
320 320
 
321 321
     public function isEmpty($cmd, $value)
322 322
     {
323
-        if ($value!=='') {
323
+        if ($value !== '') {
324 324
             return false;
325 325
         }
326 326
 
327
-        $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
327
+        $_ = explode(',', $this->condModifiers.',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
328 328
         if (in_array($cmd, $_)) {
329 329
             return false;
330 330
         } else {
@@ -356,56 +356,56 @@  discard block
 block discarded – undo
356 356
             case 'eq':
357 357
             case 'is':
358 358
             case 'equals':
359
-                $this->condition[] = (int)($value == $opt); break;
359
+                $this->condition[] = (int) ($value == $opt); break;
360 360
             case 'neq':
361 361
             case 'ne':
362 362
             case 'notequals':
363 363
             case 'isnot':
364 364
             case 'isnt':
365 365
             case 'not':
366
-                $this->condition[] = (int)($value != $opt);break;
366
+                $this->condition[] = (int) ($value != $opt); break;
367 367
             case '%':
368
-                $this->condition[] = (int)($value%$opt==0);break;
368
+                $this->condition[] = (int) ($value % $opt == 0); break;
369 369
             case 'isempty':
370
-                $this->condition[] = (int)(empty($value)); break;
370
+                $this->condition[] = (int) (empty($value)); break;
371 371
             case 'isntempty':
372 372
             case 'isnotempty':
373
-                $this->condition[] = (int)(!empty($value)); break;
373
+                $this->condition[] = (int) (!empty($value)); break;
374 374
             case '>=':
375 375
             case 'gte':
376 376
             case 'eg':
377 377
             case 'isgte':
378
-                $this->condition[] = (int)($value >= $opt);break;
378
+                $this->condition[] = (int) ($value >= $opt); break;
379 379
             case '<=':
380 380
             case 'lte':
381 381
             case 'el':
382 382
             case 'islte':
383
-                $this->condition[] = (int)($value <= $opt);break;
383
+                $this->condition[] = (int) ($value <= $opt); break;
384 384
             case '>':
385 385
             case 'gt':
386 386
             case 'greaterthan':
387 387
             case 'isgreaterthan':
388 388
             case 'isgt':
389
-                $this->condition[] = (int)($value > $opt);break;
389
+                $this->condition[] = (int) ($value > $opt); break;
390 390
             case '<':
391 391
             case 'lt':
392 392
             case 'lowerthan':
393 393
             case 'islowerthan':
394 394
             case 'islt':
395
-                $this->condition[] = (int)($value < $opt);break;
395
+                $this->condition[] = (int) ($value < $opt); break;
396 396
             case 'find':
397
-                $this->condition[] = (int)(strpos($value, $opt)!==false);break;
397
+                $this->condition[] = (int) (strpos($value, $opt) !== false); break;
398 398
             case 'inarray':
399 399
             case 'in_array':
400 400
             case 'in':
401 401
                 $opt = explode(',', $opt);
402
-                $this->condition[] = (int)(in_array($value, $opt)!==false);break;
402
+                $this->condition[] = (int) (in_array($value, $opt) !== false); break;
403 403
             case 'wildcard_match':
404 404
             case 'wcard_match':
405 405
             case 'wildcard':
406 406
             case 'wcard':
407 407
             case 'fnmatch':
408
-                $this->condition[] = (int)(fnmatch($opt, $value)!==false);break;
408
+                $this->condition[] = (int) (fnmatch($opt, $value) !== false); break;
409 409
             case 'is_file':
410 410
             case 'is_dir':
411 411
             case 'file_exists':
@@ -416,13 +416,13 @@  discard block
 block discarded – undo
416 416
                 } else {
417 417
                     $path = $opt;
418 418
                 }
419
-                if (strpos($path, MODX_MANAGER_PATH)!==false) {
419
+                if (strpos($path, MODX_MANAGER_PATH) !== false) {
420 420
                     exit('Can not read core path');
421 421
                 }
422
-                if (strpos($path, $modx->config['base_path'])===false) {
422
+                if (strpos($path, $modx->config['base_path']) === false) {
423 423
                     $path = ltrim($path, '/');
424 424
                 }
425
-                $this->condition[] = (int)($cmd($path)!==false);break;
425
+                $this->condition[] = (int) ($cmd($path) !== false); break;
426 426
             case 'is_image':
427 427
                 if (!$opt) {
428 428
                     $path = $value;
@@ -430,16 +430,16 @@  discard block
 block discarded – undo
430 430
                     $path = $opt;
431 431
                 }
432 432
                 if (!is_file($path)) {
433
-                    $this->condition[]='0';
433
+                    $this->condition[] = '0';
434 434
                     break;
435 435
                 }
436 436
                 $_ = getimagesize($path);
437
-                $this->condition[] = (int)($_[0]);break;
437
+                $this->condition[] = (int) ($_[0]); break;
438 438
             case 'regex':
439 439
             case 'preg':
440 440
             case 'preg_match':
441 441
             case 'isinrole':
442
-            $this->condition[] = (int)(preg_match($opt, $value));break;
442
+            $this->condition[] = (int) (preg_match($opt, $value)); break;
443 443
             case 'ir':
444 444
             case 'memberof':
445 445
             case 'mo':
@@ -447,27 +447,27 @@  discard block
 block discarded – undo
447 447
                 $this->condition[] = $this->includeMdfFile('memberof');
448 448
                 break;
449 449
             case 'or':
450
-                $this->condition[] = '||';break;
450
+                $this->condition[] = '||'; break;
451 451
             case 'and':
452
-                $this->condition[] = '&&';break;
452
+                $this->condition[] = '&&'; break;
453 453
             case 'show':
454 454
             case 'this':
455 455
                 $conditional = implode(' ', $this->condition);
456
-                $isvalid = (int)(eval("return ({$conditional});"));
456
+                $isvalid = (int) (eval("return ({$conditional});"));
457 457
                 if ($isvalid) {
458 458
                     return $this->srcValue;
459 459
                 }
460 460
                 return null;
461 461
             case 'then':
462 462
                 $conditional = implode(' ', $this->condition);
463
-                $isvalid = (int)eval("return ({$conditional});");
463
+                $isvalid = (int) eval("return ({$conditional});");
464 464
                 if ($isvalid) {
465 465
                     return $opt;
466 466
                 }
467 467
                 return null;
468 468
             case 'else':
469 469
                 $conditional = implode(' ', $this->condition);
470
-                $isvalid = (int)eval("return ({$conditional});");
470
+                $isvalid = (int) eval("return ({$conditional});");
471 471
                 if (!$isvalid) {
472 472
                     return $opt;
473 473
                 }
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 $raw = explode('&', $opt);
478 478
                 $map = array();
479 479
                 $c = count($raw);
480
-                for ($m=0; $m<$c; $m++) {
480
+                for ($m = 0; $m < $c; $m++) {
481 481
                     $mi = explode('=', $raw[$m], 2);
482 482
                     $map[$mi[0]] = $mi[1];
483 483
                 }
@@ -510,18 +510,18 @@  discard block
 block discarded – undo
510 510
             case 'html_encode':
511 511
                 return preg_replace('/&amp;(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset']));
512 512
             case 'spam_protect':
513
-                return str_replace(array('@','.'), array('&#64;','&#46;'), $value);
513
+                return str_replace(array('@', '.'), array('&#64;', '&#46;'), $value);
514 514
             case 'strip':
515
-                if ($opt==='') {
515
+                if ($opt === '') {
516 516
                     $opt = ' ';
517 517
                 }
518 518
                 return preg_replace('/[\n\r\t\s]+/', $opt, $value);
519 519
             case 'strip_linefeeds':
520
-                return str_replace(array("\n","\r"), '', $value);
520
+                return str_replace(array("\n", "\r"), '', $value);
521 521
             case 'notags':
522 522
             case 'strip_tags':
523 523
             case 'remove_html':
524
-                if ($opt!=='') {
524
+                if ($opt !== '') {
525 525
                     $param = array();
526 526
                     foreach (explode(',', $opt) as $v) {
527 527
                         $v = trim($v, '</> ');
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
                 } else {
532 532
                     $params = '';
533 533
                 }
534
-                if (!strpos($params, '<br>')===false) {
534
+                if (!strpos($params, '<br>') === false) {
535 535
                     $value = preg_replace('@(<br[ /]*>)\n@', '$1', $value);
536 536
                     $value = preg_replace('@<br[ /]*>@', "\n", $value);
537 537
                 }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
             case 'encode_url':
542 542
                 return urlencode($value);
543 543
             case 'base64_decode':
544
-                if ($opt!=='false') {
544
+                if ($opt !== 'false') {
545 545
                     $opt = true;
546 546
                 } else {
547 547
                     $opt = false;
@@ -578,12 +578,12 @@  discard block
 block discarded – undo
578 578
                 return implode(' ', $_);
579 579
             case 'zenhan':
580 580
                 if (empty($opt)) {
581
-                    $opt='VKas';
581
+                    $opt = 'VKas';
582 582
                 }
583 583
                 return mb_convert_kana($value, $opt, $modx->config['modx_charset']);
584 584
             case 'hanzen':
585 585
                 if (empty($opt)) {
586
-                    $opt='VKAS';
586
+                    $opt = 'VKAS';
587 587
                 }
588 588
                 return mb_convert_kana($value, $opt, $modx->config['modx_charset']);
589 589
             case 'str_shuffle':
@@ -609,13 +609,13 @@  discard block
 block discarded – undo
609 609
                 $value = preg_replace('/\r/', '', $value);
610 610
                 return count(preg_split('/\n+/', $value));
611 611
             case 'strpos':
612
-                if ($opt!=0&&empty($opt)) {
612
+                if ($opt != 0 && empty($opt)) {
613 613
                     return $value;
614 614
                 }
615 615
                 return $this->strpos($value, $opt);
616 616
             case 'wordwrap':
617 617
                 // default: 70
618
-                  $wrapat = (int)$opt > 0 ? (int)$opt : 70;
618
+                  $wrapat = (int) $opt > 0 ? (int) $opt : 70;
619 619
                 if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
620 620
                     return $this->includeMdfFile('wordwrap');
621 621
                 } else {
@@ -624,12 +624,12 @@  discard block
 block discarded – undo
624 624
                 // no break
625 625
             case 'wrap_text':
626 626
                 $width = preg_match('/^[1-9][0-9]*$/', $opt) ? $opt : 70;
627
-                if ($modx->config['manager_language']==='japanese-utf8') {
627
+                if ($modx->config['manager_language'] === 'japanese-utf8') {
628 628
                     $chunk = array();
629
-                    $bt='';
630
-                    while ($bt!=$value) {
629
+                    $bt = '';
630
+                    while ($bt != $value) {
631 631
                         $bt = $value;
632
-                        if ($this->strlen($value)<$width) {
632
+                        if ($this->strlen($value) < $width) {
633 633
                             $chunk[] = $value;
634 634
                             break;
635 635
                         }
@@ -645,31 +645,31 @@  discard block
 block discarded – undo
645 645
                 if (empty($opt)) {
646 646
                     break;
647 647
                 }
648
-                if (strpos($opt, ',')!==false) {
648
+                if (strpos($opt, ',') !== false) {
649 649
                     list($b, $e) = explode(',', $opt, 2);
650
-                    return $this->substr($value, $b, (int)$e);
650
+                    return $this->substr($value, $b, (int) $e);
651 651
                 } else {
652 652
                     return $this->substr($value, $opt);
653 653
                 }
654 654
                 // no break
655 655
             case 'limit':
656 656
             case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html
657
-                if (strpos($opt, '+')!==false) {
657
+                if (strpos($opt, '+') !== false) {
658 658
                     list($len, $str) = explode('+', $opt, 2);
659 659
                 } else {
660 660
                     $len = $opt;
661 661
                     $str = '';
662 662
                 }
663
-                if ($len==='') {
663
+                if ($len === '') {
664 664
                     $len = 100;
665 665
                 }
666 666
                 if (abs($len) > $this->strlen($value)) {
667
-                    $str ='';
667
+                    $str = '';
668 668
                 }
669 669
                 if (preg_match('/^[1-9][0-9]*$/', $len)) {
670
-                    return $this->substr($value, 0, $len) . $str;
670
+                    return $this->substr($value, 0, $len).$str;
671 671
                 } elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) {
672
-                    return $str . $this->substr($value, $len);
672
+                    return $str.$this->substr($value, $len);
673 673
                 }
674 674
                 break;
675 675
             case 'summary':
@@ -678,41 +678,41 @@  discard block
 block discarded – undo
678 678
                 return $this->includeMdfFile('summary');
679 679
             case 'replace':
680 680
             case 'str_replace':
681
-                if (empty($opt) || strpos($opt, ',')===false) {
681
+                if (empty($opt) || strpos($opt, ',') === false) {
682 682
                     break;
683 683
                 }
684
-                if (substr_count($opt, ',') ==1) {
684
+                if (substr_count($opt, ',') == 1) {
685 685
                     $delim = ',';
686
-                } elseif (substr_count($opt, '|') ==1) {
686
+                } elseif (substr_count($opt, '|') == 1) {
687 687
                     $delim = '|';
688
-                } elseif (substr_count($opt, '=>')==1) {
688
+                } elseif (substr_count($opt, '=>') == 1) {
689 689
                     $delim = '=>';
690
-                } elseif (substr_count($opt, '/') ==1) {
690
+                } elseif (substr_count($opt, '/') == 1) {
691 691
                     $delim = '/';
692 692
                 } else {
693 693
                     break;
694 694
                 }
695 695
                 list($s, $r) = explode($delim, $opt);
696
-                if ($value!=='') {
696
+                if ($value !== '') {
697 697
                     return str_replace($s, $r, $value);
698 698
                 }
699 699
                 break;
700 700
             case 'replace_to':
701 701
             case 'tpl':
702
-                if ($value!=='') {
703
-                    return str_replace(array('[+value+]','[+output+]','{value}','%s'), $value, $opt);
702
+                if ($value !== '') {
703
+                    return str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $value, $opt);
704 704
                 }
705 705
                 break;
706 706
             case 'eachtpl':
707 707
                 $value = explode('||', $value);
708 708
                 $_ = array();
709 709
                 foreach ($value as $v) {
710
-                    $_[] = str_replace(array('[+value+]','[+output+]','{value}','%s'), $v, $opt);
710
+                    $_[] = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $v, $opt);
711 711
                 }
712 712
                 return implode("\n", $_);
713 713
             case 'array_pop':
714 714
             case 'array_shift':
715
-                if (strpos($value, '||')!==false) {
715
+                if (strpos($value, '||') !== false) {
716 716
                     $delim = '||';
717 717
                 } else {
718 718
                     $delim = ',';
@@ -720,43 +720,43 @@  discard block
 block discarded – undo
720 720
                 return $cmd(explode($delim, $value));
721 721
             case 'preg_replace':
722 722
             case 'regex_replace':
723
-                if (empty($opt) || strpos($opt, ',')===false) {
723
+                if (empty($opt) || strpos($opt, ',') === false) {
724 724
                     break;
725 725
                 }
726 726
                 list($s, $r) = explode(',', $opt, 2);
727
-                if ($value!=='') {
727
+                if ($value !== '') {
728 728
                     return preg_replace($s, $r, $value);
729 729
                 }
730 730
                 break;
731 731
             case 'cat':
732 732
             case 'concatenate':
733 733
             case '.':
734
-                if ($value!=='') {
735
-                    return $value . $opt;
734
+                if ($value !== '') {
735
+                    return $value.$opt;
736 736
                 }
737 737
                 break;
738 738
             case 'sprintf':
739 739
             case 'string_format':
740
-                if ($value!=='') {
740
+                if ($value !== '') {
741 741
                     return sprintf($opt, $value);
742 742
                 }
743 743
                 break;
744 744
             case 'number_format':
745
-                    if ($opt=='') {
745
+                    if ($opt == '') {
746 746
                         $opt = 0;
747 747
                     }
748 748
                     return number_format($value, $opt);
749 749
             case 'money_format':
750 750
                     setlocale(LC_MONETARY, setlocale(LC_TIME, 0));
751
-                    if ($value!=='') {
752
-                        return money_format($opt, (double)$value);
751
+                    if ($value !== '') {
752
+                        return money_format($opt, (double) $value);
753 753
                     }
754 754
                     break;
755 755
             case 'tobool':
756 756
                 return boolval($value);
757 757
             case 'nl2lf':
758
-                if ($value!=='') {
759
-                    return str_replace(array("\r\n","\n", "\r"), '\n', $value);
758
+                if ($value !== '') {
759
+                    return str_replace(array("\r\n", "\n", "\r"), '\n', $value);
760 760
                 }
761 761
                 break;
762 762
             case 'br2nl':
@@ -765,17 +765,17 @@  discard block
 block discarded – undo
765 765
                 if (version_compare(PHP_VERSION, '5.3.0', '<')) {
766 766
                     return nl2br($value);
767 767
                 }
768
-                if ($opt!=='') {
768
+                if ($opt !== '') {
769 769
                     $opt = trim($opt);
770 770
                     $opt = strtolower($opt);
771
-                    if ($opt==='false') {
771
+                    if ($opt === 'false') {
772 772
                         $opt = false;
773
-                    } elseif ($opt==='0') {
773
+                    } elseif ($opt === '0') {
774 774
                         $opt = false;
775 775
                     } else {
776 776
                         $opt = true;
777 777
                     }
778
-                } elseif (isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') {
778
+                } elseif (isset($modx->config['mce_element_format']) && $modx->config['mce_element_format'] === 'html') {
779 779
                     $opt = false;
780 780
                 } else {
781 781
                     $opt = true;
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
             case 'ltrim':
785 785
             case 'rtrim':
786 786
             case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html
787
-                if ($opt==='') {
787
+                if ($opt === '') {
788 788
                     return $cmd($value);
789 789
                 } else {
790 790
                     return $cmd($value, $opt);
@@ -806,10 +806,10 @@  discard block
 block discarded – undo
806 806
                 if (!preg_match('@^[0-9]+$@', $value)) {
807 807
                     $value = strtotime($value);
808 808
                 }
809
-                if (strpos($opt, '%')!==false) {
810
-                    return strftime($opt, 0+$value);
809
+                if (strpos($opt, '%') !== false) {
810
+                    return strftime($opt, 0 + $value);
811 811
                 } else {
812
-                    return date($opt, 0+$value);
812
+                    return date($opt, 0 + $value);
813 813
                 }
814 814
                     // no break
815 815
             case 'time':
@@ -819,12 +819,12 @@  discard block
 block discarded – undo
819 819
                 if (!preg_match('@^[0-9]+$@', $value)) {
820 820
                     $value = strtotime($value);
821 821
                 }
822
-                return strftime($opt, 0+$value);
822
+                return strftime($opt, 0 + $value);
823 823
             case 'strtotime':
824 824
                 return strtotime($value);
825 825
             #####  mathematical function
826 826
             case 'toint':
827
-                return (int)$value;
827
+                return (int) $value;
828 828
             case 'tofloat':
829 829
                 return floatval($value);
830 830
             case 'round':
@@ -841,27 +841,27 @@  discard block
 block discarded – undo
841 841
                 return $cmd($value);
842 842
             case 'math':
843 843
             case 'calc':
844
-                $value = (int)$value;
844
+                $value = (int) $value;
845 845
                 if (empty($value)) {
846 846
                     $value = '0';
847 847
                 }
848
-                $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'), '?', $opt);
848
+                $filter = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), '?', $opt);
849 849
                 $filter = preg_replace('@([a-zA-Z\n\r\t\s])@', '', $filter);
850
-                if (strpos($filter, '?')===false) {
850
+                if (strpos($filter, '?') === false) {
851 851
                     $filter = "?{$filter}";
852 852
                 }
853 853
                 $filter = str_replace('?', $value, $filter);
854 854
                 return eval("return {$filter};");
855 855
             case 'count':
856
-                if ($value=='') {
856
+                if ($value == '') {
857 857
                     return 0;
858 858
                 }
859 859
                 $value = explode(',', $value);
860 860
                 return count($value);
861 861
             case 'sort':
862 862
             case 'rsort':
863
-                if (strpos($value, "\n")!==false) {
864
-                    $delim="\n";
863
+                if (strpos($value, "\n") !== false) {
864
+                    $delim = "\n";
865 865
                 } else {
866 866
                     $delim = ',';
867 867
                 }
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
             case 'privatemgr':
915 915
             case 'content_dispo':
916 916
             case 'hidemenu':
917
-                if ($cmd==='contenttype') {
917
+                if ($cmd === 'contenttype') {
918 918
                     $cmd = 'contentType';
919 919
                 }
920 920
                 return $this->getDocumentObject($value, $cmd);
@@ -937,11 +937,11 @@  discard block
 block discarded – undo
937 937
                 return $modx->getField($opt, $value);
938 938
             case 'children':
939 939
             case 'childids':
940
-                if ($value=='') {
940
+                if ($value == '') {
941 941
                     $value = 0;
942 942
                 } // 値がない場合はルートと見なす
943 943
                 $published = 1;
944
-                if ($opt=='') {
944
+                if ($opt == '') {
945 945
                     $opt = 'page';
946 946
                 }
947 947
                 $_ = explode(',', $opt);
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
                 $where = implode(' AND ', $where);
960 960
                 $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where);
961 961
                 $result = array();
962
-                foreach ((array)$children as $child) {
962
+                foreach ((array) $children as $child) {
963 963
                     $result[] = $child['id'];
964 964
                 }
965 965
                 return implode(',', $result);
@@ -1019,14 +1019,14 @@  discard block
 block discarded – undo
1019 1019
                     return $value;
1020 1020
                 }
1021 1021
                 $value = realpath($value);
1022
-                if (strpos($value, MODX_MANAGER_PATH)!==false) {
1022
+                if (strpos($value, MODX_MANAGER_PATH) !== false) {
1023 1023
                     exit('Can not read core file');
1024 1024
                 }
1025 1025
                 $ext = strtolower(substr($value, -4));
1026
-                if ($ext==='.php') {
1026
+                if ($ext === '.php') {
1027 1027
                     exit('Can not read php file');
1028 1028
                 }
1029
-                if ($ext==='.cgi') {
1029
+                if ($ext === '.cgi') {
1030 1030
                     exit('Can not read cgi file');
1031 1031
                 }
1032 1032
                 return file_get_contents($value);
@@ -1043,11 +1043,11 @@  discard block
 block discarded – undo
1043 1043
                 $filename = trim($filename, '/');
1044 1044
 
1045 1045
                 $opt = trim($opt, '/');
1046
-                if ($opt!=='') {
1046
+                if ($opt !== '') {
1047 1047
                     $opt .= '/';
1048 1048
                 }
1049 1049
 
1050
-                $filename = MODX_BASE_PATH . $opt . $filename;
1050
+                $filename = MODX_BASE_PATH.$opt.$filename;
1051 1051
 
1052 1052
                 if (is_file($filename)) {
1053 1053
                     clearstatcache();
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
                     return $opt;
1107 1107
                 } break;
1108 1108
             case 'datagrid':
1109
-                include_once(MODX_CORE_PATH . 'controls/datagrid.class.php');
1109
+                include_once(MODX_CORE_PATH.'controls/datagrid.class.php');
1110 1110
                 $grd = new DataGrid(null, trim($value));
1111 1111
                 $grd->itemStyle = '';
1112 1112
                 $grd->altItemStyle = '';
@@ -1116,11 +1116,11 @@  discard block
 block discarded – undo
1116 1116
                 } else {
1117 1117
                     $_ = $pos;
1118 1118
                 }
1119
-                $grd->cdelim = strpos($_, "\t")!==false ? 'tab' : ',';
1119
+                $grd->cdelim = strpos($_, "\t") !== false ? 'tab' : ',';
1120 1120
                 return $grd->render();
1121 1121
             case 'rotate':
1122 1122
             case 'evenodd':
1123
-                if (strpos($opt, ',')===false) {
1123
+                if (strpos($opt, ',') === false) {
1124 1124
                     $opt = 'odd,even';
1125 1125
                 }
1126 1126
                 $_ = explode(',', $opt);
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
                 if (empty($opt)) {
1154 1154
                     $opt = 560;
1155 1155
                 }
1156
-                $h = round($opt*0.5625);
1156
+                $h = round($opt * 0.5625);
1157 1157
                 $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>';
1158 1158
                 return sprintf($tpl, $opt, $h, $value);
1159 1159
             //case 'youtube4x3':%s*0.75+25
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
         $key = $this->key;
1192 1192
         $value  = $this->value;
1193 1193
         $opt    = $this->opt;
1194
-        return include(MODX_CORE_PATH . "extenders/modifiers/mdf_{$cmd}.inc.php");
1194
+        return include(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php");
1195 1195
     }
1196 1196
 
1197 1197
     public function getValueFromElement($key, $value, $cmd, $opt)
@@ -1207,13 +1207,13 @@  discard block
 block discarded – undo
1207 1207
                 $row = $modx->db->getRow($result);
1208 1208
                 $php = $row['snippet'];
1209 1209
             } elseif ($total == 0) {
1210
-                $assets_path = MODX_BASE_PATH . 'assets/';
1211
-                if (is_file($assets_path . "modifiers/mdf_{$cmd}.inc.php")) {
1212
-                    $modifiers_path = $assets_path . "modifiers/mdf_{$cmd}.inc.php";
1213
-                } elseif (is_file($assets_path . "plugins/phx/modifiers/{$cmd}.phx.php")) {
1214
-                    $modifiers_path = $assets_path . "plugins/phx/modifiers/{$cmd}.phx.php";
1215
-                } elseif (is_file(MODX_CORE_PATH . "extenders/modifiers/mdf_{$cmd}.inc.php")) {
1216
-                    $modifiers_path = MODX_CORE_PATH . "extenders/modifiers/mdf_{$cmd}.inc.php";
1210
+                $assets_path = MODX_BASE_PATH.'assets/';
1211
+                if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) {
1212
+                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1213
+                } elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) {
1214
+                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1215
+                } elseif (is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) {
1216
+                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1217 1217
                 } else {
1218 1218
                     $modifiers_path = false;
1219 1219
                 }
@@ -1221,17 +1221,17 @@  discard block
 block discarded – undo
1221 1221
                 if ($modifiers_path !== false) {
1222 1222
                     $php = @file_get_contents($modifiers_path);
1223 1223
                     $php = trim($php);
1224
-                    if (substr($php, 0, 5)==='<?php') {
1224
+                    if (substr($php, 0, 5) === '<?php') {
1225 1225
                         $php = substr($php, 6);
1226 1226
                     }
1227
-                    if (substr($php, 0, 2)==='<?') {
1227
+                    if (substr($php, 0, 2) === '<?') {
1228 1228
                         $php = substr($php, 3);
1229 1229
                     }
1230
-                    if (substr($php, -2)==='?>') {
1230
+                    if (substr($php, -2) === '?>') {
1231 1231
                         $php = substr($php, 0, -2);
1232 1232
                     }
1233
-                    if ($this->elmName!=='') {
1234
-                        $modx->snippetCache[$this->elmName . 'Props'] = '';
1233
+                    if ($this->elmName !== '') {
1234
+                        $modx->snippetCache[$this->elmName.'Props'] = '';
1235 1235
                     }
1236 1236
                 } else {
1237 1237
                     $php = false;
@@ -1239,15 +1239,15 @@  discard block
 block discarded – undo
1239 1239
             } else {
1240 1240
                 $php = false;
1241 1241
             }
1242
-            if ($this->elmName!=='') {
1243
-                $modx->snippetCache[$this->elmName]= $php;
1242
+            if ($this->elmName !== '') {
1243
+                $modx->snippetCache[$this->elmName] = $php;
1244 1244
             }
1245 1245
         }
1246
-        if ($php==='') {
1247
-            $php=false;
1246
+        if ($php === '') {
1247
+            $php = false;
1248 1248
         }
1249 1249
 
1250
-        if ($php===false) {
1250
+        if ($php === false) {
1251 1251
             $html = $modx->getChunk($this->elmName);
1252 1252
         } else {
1253 1253
             $html = false;
@@ -1267,56 +1267,56 @@  discard block
 block discarded – undo
1267 1267
             $this->vars['options'] = & $opt;
1268 1268
             $custom = eval($php);
1269 1269
             $msg = ob_get_contents();
1270
-            if ($value===$this->bt) {
1271
-                $value = $msg . $custom;
1270
+            if ($value === $this->bt) {
1271
+                $value = $msg.$custom;
1272 1272
             }
1273 1273
             ob_end_clean();
1274
-        } elseif ($html!==false && isset($value) && $value!=='') {
1275
-            $html = str_replace(array($self,'[+value+]'), $value, $html);
1276
-            $value = str_replace(array('[+options+]','[+param+]'), $opt, $html);
1274
+        } elseif ($html !== false && isset($value) && $value !== '') {
1275
+            $html = str_replace(array($self, '[+value+]'), $value, $html);
1276
+            $value = str_replace(array('[+options+]', '[+param+]'), $opt, $html);
1277 1277
         } else {
1278 1278
             return false;
1279 1279
         }
1280 1280
 
1281
-        if ($php===false && $html===false && $value!==''
1282
-           && (strpos($cmd, '[+value+]')!==false || strpos($cmd, $self)!==false)) {
1283
-            $value = str_replace(array('[+value+]',$self), $value, $cmd);
1281
+        if ($php === false && $html === false && $value !== ''
1282
+           && (strpos($cmd, '[+value+]') !== false || strpos($cmd, $self) !== false)) {
1283
+            $value = str_replace(array('[+value+]', $self), $value, $cmd);
1284 1284
         }
1285 1285
         return $value;
1286 1286
     }
1287 1287
 
1288
-    public function parseDocumentSource($content='')
1288
+    public function parseDocumentSource($content = '')
1289 1289
     {
1290 1290
         $modx = evolutionCMS();
1291 1291
 
1292
-        if (strpos($content, '[')===false && strpos($content, '{')===false) {
1292
+        if (strpos($content, '[') === false && strpos($content, '{') === false) {
1293 1293
             return $content;
1294 1294
         }
1295 1295
 
1296 1296
         if (!$modx->maxParserPasses) {
1297 1297
             $modx->maxParserPasses = 10;
1298 1298
         }
1299
-        $bt='';
1300
-        $i=0;
1301
-        while ($bt!==$content) {
1299
+        $bt = '';
1300
+        $i = 0;
1301
+        while ($bt !== $content) {
1302 1302
             $bt = $content;
1303
-            if (strpos($content, '[*')!==false && $modx->documentIdentifier) {
1303
+            if (strpos($content, '[*') !== false && $modx->documentIdentifier) {
1304 1304
                 $content = $modx->mergeDocumentContent($content);
1305 1305
             }
1306
-            if (strpos($content, '[(')!==false) {
1306
+            if (strpos($content, '[(') !== false) {
1307 1307
                 $content = $modx->mergeSettingsContent($content);
1308 1308
             }
1309
-            if (strpos($content, '{{')!==false) {
1309
+            if (strpos($content, '{{') !== false) {
1310 1310
                 $content = $modx->mergeChunkContent($content);
1311 1311
             }
1312
-            if (strpos($content, '[!')!==false) {
1313
-                $content = str_replace(array('[!','!]'), array('[[',']]'), $content);
1312
+            if (strpos($content, '[!') !== false) {
1313
+                $content = str_replace(array('[!', '!]'), array('[[', ']]'), $content);
1314 1314
             }
1315
-            if (strpos($content, '[[')!==false) {
1315
+            if (strpos($content, '[[') !== false) {
1316 1316
                 $content = $modx->evalSnippets($content);
1317 1317
             }
1318 1318
 
1319
-            if ($content===$bt) {
1319
+            if ($content === $bt) {
1320 1320
                 break;
1321 1321
             }
1322 1322
             if ($modx->maxParserPasses < $i) {
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
         return $content;
1328 1328
     }
1329 1329
 
1330
-    public function getDocumentObject($target='', $field='pagetitle')
1330
+    public function getDocumentObject($target = '', $field = 'pagetitle')
1331 1331
     {
1332 1332
         $modx = evolutionCMS();
1333 1333
 
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
             $target = $modx->config['site_start'];
1337 1337
         }
1338 1338
         if (preg_match('@^[1-9][0-9]*$@', $target)) {
1339
-            $method='id';
1339
+            $method = 'id';
1340 1340
         } else {
1341 1341
             $method = 'alias';
1342 1342
         }
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
             $this->documentObject[$target] = $modx->getDocumentObject($method, $target, 'direct');
1346 1346
         }
1347 1347
 
1348
-        if ($this->documentObject[$target]['publishedon']==='0') {
1348
+        if ($this->documentObject[$target]['publishedon'] === '0') {
1349 1349
             return '';
1350 1350
         } elseif (isset($this->documentObject[$target][$field])) {
1351 1351
             if (is_array($this->documentObject[$target][$field])) {
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
 
1362 1362
     public function setPlaceholders($value = '', $key = '', $path = '')
1363 1363
     {
1364
-        if ($path!=='') {
1364
+        if ($path !== '') {
1365 1365
             $key = "{$path}.{$key}";
1366 1366
         }
1367 1367
         if (is_array($value)) {
@@ -1389,14 +1389,14 @@  discard block
 block discarded – undo
1389 1389
             $l = $this->strlen($str);
1390 1390
         }
1391 1391
         if (function_exists('mb_substr')) {
1392
-            if (strpos($str, "\r")!==false) {
1393
-                $str = str_replace(array("\r\n","\r"), "\n", $str);
1392
+            if (strpos($str, "\r") !== false) {
1393
+                $str = str_replace(array("\r\n", "\r"), "\n", $str);
1394 1394
             }
1395 1395
             return mb_substr($str, $s, $l, $modx->config['modx_charset']);
1396 1396
         }
1397 1397
         return substr($str, $s, $l);
1398 1398
     }
1399
-    public function strpos($haystack, $needle, $offset=0)
1399
+    public function strpos($haystack, $needle, $offset = 0)
1400 1400
     {
1401 1401
         $modx = evolutionCMS();
1402 1402
         if (function_exists('mb_strpos')) {
@@ -1429,14 +1429,14 @@  discard block
 block discarded – undo
1429 1429
     public function ucfirst($str)
1430 1430
     {
1431 1431
         if (function_exists('mb_strtoupper')) {
1432
-            return mb_strtoupper($this->substr($str, 0, 1)) . $this->substr($str, 1, $this->strlen($str));
1432
+            return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1433 1433
         }
1434 1434
         return ucfirst($str);
1435 1435
     }
1436 1436
     public function lcfirst($str)
1437 1437
     {
1438 1438
         if (function_exists('mb_strtolower')) {
1439
-            return mb_strtolower($this->substr($str, 0, 1)) . $this->substr($str, 1, $this->strlen($str));
1439
+            return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1440 1440
         }
1441 1441
         return lcfirst($str);
1442 1442
     }
@@ -1462,14 +1462,14 @@  discard block
 block discarded – undo
1462 1462
     {
1463 1463
         return count(preg_split('~[^\p{L}\p{N}\']+~u', $str));
1464 1464
     }
1465
-    public function strip_tags($value, $params='')
1465
+    public function strip_tags($value, $params = '')
1466 1466
     {
1467 1467
         $modx = evolutionCMS();
1468 1468
 
1469
-        if (stripos($params, 'style')===false && stripos($value, '</style>')!==false) {
1469
+        if (stripos($params, 'style') === false && stripos($value, '</style>') !== false) {
1470 1470
             $value = preg_replace('@<style.*?>.*?</style>@is', '', $value);
1471 1471
         }
1472
-        if (stripos($params, 'script')===false && stripos($value, '</script>')!==false) {
1472
+        if (stripos($params, 'script') === false && stripos($value, '</script>') !== false) {
1473 1473
             $value = preg_replace('@<script.*?>.*?</script>@is', '', $value);
1474 1474
         }
1475 1475
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -194,7 +194,8 @@  discard block
 block discarded – undo
194 194
             $c = substr($modifiers, 0, 1);
195 195
             $modifiers = substr($modifiers, 1);
196 196
 
197
-            if ($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
197
+            if ($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) {
198
+// :=, :!=, :<=, :>=, :!<=, :!>=
198 199
                 $c = substr($modifiers, strlen($match[1]), 1);
199 200
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
200 201
                 if ($c==='(') {
@@ -209,7 +210,8 @@  discard block
 block discarded – undo
209 210
 
210 211
                 $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
211 212
                 $cmd = '';
212
-            } elseif (in_array($c, array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
213
+            } elseif (in_array($c, array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) {
214
+// :+3, :-3, :*3 ...
213 215
                 $modifiers = substr($modifiers, strlen($match[0]));
214 216
                 $result[]=array('cmd'=>'math','opt'=>'%s' . $c . $match[0]);
215 217
                 $cmd = '';
Please login to merge, or discard this patch.