@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) { |
3 | 3 | include_once(dirname(__FILE__)."/../assets/cache/siteManager.php"); |
4 | -}else{ |
|
4 | +} else { |
|
5 | 5 | define('MGR_DIR', 'manager'); |
6 | 6 | } |
7 | 7 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | echo "<p>{$_lang['setup_database']}</p>\n"; |
30 | 30 | |
31 | -$installMode= (int)$_POST['installmode']; |
|
31 | +$installMode = (int) $_POST['installmode']; |
|
32 | 32 | $installData = $_POST['installdata'] == "1" ? 1 : 0; |
33 | 33 | |
34 | 34 | //if ($installMode == 1) { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
43 | 43 | $database_connection_charset = $_POST['database_connection_charset']; |
44 | 44 | $database_connection_method = $_POST['database_connection_method']; |
45 | -$dbase = "`" . $_POST['database_name'] . "`"; |
|
45 | +$dbase = "`".$_POST['database_name']."`"; |
|
46 | 46 | $table_prefix = $_POST['tableprefix']; |
47 | 47 | $adminname = $_POST['cmsadmin']; |
48 | 48 | $adminemail = $_POST['cmsadminemail']; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | // set session name variable |
55 | 55 | if (!isset ($site_sessionname)) { |
56 | - $site_sessionname = 'SN' . uniqid(''); |
|
56 | + $site_sessionname = 'SN'.uniqid(''); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // get base path and url |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | array_pop($a); |
68 | 68 | $pth = implode("install", $a); |
69 | 69 | unset ($a); |
70 | -$base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
|
71 | -$base_path = $pth . (substr($pth, -1) != "/" ? "/" : ""); |
|
70 | +$base_url = $url.(substr($url, -1) != "/" ? "/" : ""); |
|
71 | +$base_path = $pth.(substr($pth, -1) != "/" ? "/" : ""); |
|
72 | 72 | |
73 | 73 | // connect to the database |
74 | -echo "<p>". $_lang['setup_database_create_connection']; |
|
74 | +echo "<p>".$_lang['setup_database_create_connection']; |
|
75 | 75 | if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { |
76 | 76 | echo '<span class="notok">'.$_lang["setup_database_create_connection_failed"]."</span></p><p>".$_lang['setup_database_create_connection_failed_note']."</p>"; |
77 | 77 | return; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | // select database |
83 | -echo "<p>".$_lang['setup_database_selection']. str_replace("`", "", $dbase) . "`: "; |
|
83 | +echo "<p>".$_lang['setup_database_selection'].str_replace("`", "", $dbase)."`: "; |
|
84 | 84 | if (!mysqli_select_db($conn, str_replace("`", "", $dbase))) { |
85 | 85 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
86 | 86 | $create = true; |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | |
93 | 93 | // try to create the database |
94 | 94 | if ($create) { |
95 | - echo "<p>".$_lang['setup_database_creation']. str_replace("`", "", $dbase) . "`: "; |
|
95 | + echo "<p>".$_lang['setup_database_creation'].str_replace("`", "", $dbase)."`: "; |
|
96 | 96 | // if(!@mysqli_create_db(str_replace("`","",$dbase), $conn)) { |
97 | - if (! mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) { |
|
97 | + if (!mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) { |
|
98 | 98 | echo '<span class="notok">'.$_lang['setup_database_creation_failed']."</span>".$_lang['setup_database_creation_failed_note']."</p>"; |
99 | 99 | $errors += 1; |
100 | 100 | ?> |
@@ -113,33 +113,33 @@ discard block |
||
113 | 113 | |
114 | 114 | // check table prefix |
115 | 115 | if ($installMode == 0) { |
116 | - echo "<p>" . $_lang['checking_table_prefix'] . $table_prefix . "`: "; |
|
117 | - if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) { |
|
118 | - echo '<span class="notok">' . $_lang['failed'] . "</span>" . $_lang['table_prefix_already_inuse'] . "</p>"; |
|
116 | + echo "<p>".$_lang['checking_table_prefix'].$table_prefix."`: "; |
|
117 | + if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) { |
|
118 | + echo '<span class="notok">'.$_lang['failed']."</span>".$_lang['table_prefix_already_inuse']."</p>"; |
|
119 | 119 | $errors += 1; |
120 | - echo "<p>" . $_lang['table_prefix_already_inuse_note'] . "</p>"; |
|
120 | + echo "<p>".$_lang['table_prefix_already_inuse_note']."</p>"; |
|
121 | 121 | return; |
122 | 122 | } else { |
123 | 123 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | -if(!function_exists('parseProperties')) { |
|
127 | +if (!function_exists('parseProperties')) { |
|
128 | 128 | // parses a resource property string and returns the result as an array |
129 | 129 | // duplicate of method in documentParser class |
130 | - function parseProperties($propertyString) { |
|
131 | - $parameter= array (); |
|
130 | + function parseProperties($propertyString){ |
|
131 | + $parameter = array(); |
|
132 | 132 | if (!empty ($propertyString)) { |
133 | - $tmpParams= explode("&", $propertyString); |
|
134 | - for ($x= 0; $x < count($tmpParams); $x++) { |
|
133 | + $tmpParams = explode("&", $propertyString); |
|
134 | + for ($x = 0; $x < count($tmpParams); $x++) { |
|
135 | 135 | if (strpos($tmpParams[$x], '=', 0)) { |
136 | - $pTmp= explode("=", $tmpParams[$x]); |
|
137 | - $pvTmp= explode(";", trim($pTmp[1])); |
|
136 | + $pTmp = explode("=", $tmpParams[$x]); |
|
137 | + $pvTmp = explode(";", trim($pTmp[1])); |
|
138 | 138 | if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
139 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
139 | + $parameter[trim($pTmp[0])] = $pvTmp[3]; //list default |
|
140 | 140 | else |
141 | 141 | if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
142 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
142 | + $parameter[trim($pTmp[0])] = $pvTmp[2]; |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | // check status of Inherit Parent Template plugin |
151 | 151 | $auto_template_logic = 'parent'; |
152 | 152 | if ($installMode != 0) { |
153 | - $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'"); |
|
153 | + $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`".$table_prefix."site_plugins` WHERE name='Inherit Parent Template'"); |
|
154 | 154 | $row = mysqli_fetch_row($rs); |
155 | - if(!$row) { |
|
155 | + if (!$row) { |
|
156 | 156 | // not installed |
157 | 157 | $auto_template_logic = 'system'; |
158 | 158 | } else { |
159 | - if($row[1] == 1) { |
|
159 | + if ($row[1] == 1) { |
|
160 | 160 | // installed but disabled |
161 | 161 | $auto_template_logic = 'system'; |
162 | 162 | } else { |
163 | 163 | // installed, enabled .. see how it's configured |
164 | 164 | $properties = parseProperties($row[0]); |
165 | - if(isset($properties['inheritTemplate'])) { |
|
166 | - if($properties['inheritTemplate'] == 'From First Sibling') { |
|
165 | + if (isset($properties['inheritTemplate'])) { |
|
166 | + if ($properties['inheritTemplate'] == 'From First Sibling') { |
|
167 | 167 | $auto_template_logic = 'sibling'; |
168 | 168 | } |
169 | 169 | } |
@@ -187,20 +187,20 @@ discard block |
||
187 | 187 | $sqlParser->connect(); |
188 | 188 | |
189 | 189 | // install/update database |
190 | -echo "<p>" . $_lang['setup_database_creating_tables']; |
|
190 | +echo "<p>".$_lang['setup_database_creating_tables']; |
|
191 | 191 | if ($moduleSQLBaseFile) { |
192 | 192 | $sqlParser->process($moduleSQLBaseFile); |
193 | 193 | // display database results |
194 | 194 | if ($sqlParser->installFailed == true) { |
195 | 195 | $errors += 1; |
196 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
197 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
198 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
196 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
197 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
198 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
199 | 199 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
200 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
200 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
201 | 201 | } |
202 | 202 | echo "</p>"; |
203 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
203 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
204 | 204 | return; |
205 | 205 | } else { |
206 | 206 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | // custom or not |
211 | 211 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
212 | 212 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
213 | -}else{ |
|
213 | +} else { |
|
214 | 214 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
215 | 215 | } |
216 | 216 | |
217 | 217 | // write the config.inc.php file if new installation |
218 | -echo "<p>" . $_lang['writing_config_file']; |
|
218 | +echo "<p>".$_lang['writing_config_file']; |
|
219 | 219 | |
220 | 220 | $confph = array(); |
221 | 221 | $confph['database_server'] = $database_server; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $chmodSuccess = @chmod($filename, 0404); |
248 | 248 | |
249 | 249 | if ($configFileFailed == true) { |
250 | - echo '<span class="notok">' . $_lang['failed'] . "</span></p>"; |
|
250 | + echo '<span class="notok">'.$_lang['failed']."</span></p>"; |
|
251 | 251 | $errors += 1; |
252 | 252 | ?> |
253 | 253 | <p><?php echo $_lang['cant_write_config_file']?><span class="mono"><?php echo MGR_DIR; ?>/includes/config.inc.php</span></p> |
@@ -264,35 +264,35 @@ discard block |
||
264 | 264 | // generate new site_id and set manager theme to default |
265 | 265 | if ($installMode == 0) { |
266 | 266 | $siteid = uniqid(''); |
267 | - mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')"); |
|
267 | + mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')"); |
|
268 | 268 | } else { |
269 | 269 | // update site_id if missing |
270 | - $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'"); |
|
270 | + $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`".$table_prefix."system_settings` WHERE setting_name='site_id'"); |
|
271 | 271 | if ($ds) { |
272 | 272 | $r = mysqli_fetch_assoc($ds); |
273 | 273 | $siteid = $r['setting_value']; |
274 | 274 | if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') { |
275 | 275 | $siteid = uniqid(''); |
276 | - mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')"); |
|
276 | + mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')"); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | 281 | // Reset database for installation of demo-site |
282 | 282 | if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) { |
283 | - echo "<p>" . $_lang['resetting_database']; |
|
283 | + echo "<p>".$_lang['resetting_database']; |
|
284 | 284 | $sqlParser->process($moduleSQLResetFile); |
285 | 285 | // display database results |
286 | 286 | if ($sqlParser->installFailed == true) { |
287 | 287 | $errors += 1; |
288 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
289 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
290 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
288 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
289 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
290 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
291 | 291 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
292 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
292 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
293 | 293 | } |
294 | 294 | echo "</p>"; |
295 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
295 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
296 | 296 | return; |
297 | 297 | } else { |
298 | 298 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | |
302 | 302 | // Install Templates |
303 | 303 | if (isset ($_POST['template']) || $installData) { |
304 | - echo "<h3>" . $_lang['templates'] . ":</h3> "; |
|
304 | + echo "<h3>".$_lang['templates'].":</h3> "; |
|
305 | 305 | $selTemplates = $_POST['template']; |
306 | 306 | foreach ($moduleTemplates as $k=>$moduleTemplate) { |
307 | 307 | $installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1; |
308 | - if($installSample || in_array($k, $selTemplates)) { |
|
308 | + if ($installSample || in_array($k, $selTemplates)) { |
|
309 | 309 | $name = mysqli_real_escape_string($conn, $moduleTemplate[0]); |
310 | 310 | $desc = mysqli_real_escape_string($conn, $moduleTemplate[1]); |
311 | 311 | $category = mysqli_real_escape_string($conn, $moduleTemplate[4]); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $filecontent = $moduleTemplate[3]; |
314 | 314 | $save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site |
315 | 315 | if (!file_exists($filecontent)) { |
316 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_template'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
316 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_template']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
317 | 317 | } else { |
318 | 318 | // Create the category if it does not already exist |
319 | 319 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -323,31 +323,31 @@ discard block |
||
323 | 323 | $template = mysqli_real_escape_string($conn, $template); |
324 | 324 | |
325 | 325 | // See if the template already exists |
326 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'"); |
|
326 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name'"); |
|
327 | 327 | |
328 | 328 | if (mysqli_num_rows($rs)) { |
329 | - 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;")) { |
|
329 | + 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;")) { |
|
330 | 330 | $errors += 1; |
331 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
331 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
332 | 332 | return; |
333 | 333 | } |
334 | - if(!is_null($save_sql_id_as)) { |
|
334 | + if (!is_null($save_sql_id_as)) { |
|
335 | 335 | $sql_id = @mysqli_insert_id($sqlParser->conn); |
336 | - if(!$sql_id) { |
|
337 | - $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;")); |
|
336 | + if (!$sql_id) { |
|
337 | + $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name' LIMIT 1;")); |
|
338 | 338 | $sql_id = $idQuery['id']; |
339 | 339 | } |
340 | 340 | $custom_placeholders[$save_sql_id_as] = $sql_id; |
341 | 341 | } |
342 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
342 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
343 | 343 | } else { |
344 | - if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) { |
|
344 | + if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) { |
|
345 | 345 | $errors += 1; |
346 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
346 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
347 | 347 | return; |
348 | 348 | } |
349 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
350 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
349 | + if (!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
350 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | } |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | |
357 | 357 | // Install Template Variables |
358 | 358 | if (isset ($_POST['tv']) || $installData) { |
359 | - echo "<h3>" . $_lang['tvs'] . ":</h3> "; |
|
359 | + echo "<h3>".$_lang['tvs'].":</h3> "; |
|
360 | 360 | $selTVs = $_POST['tv']; |
361 | 361 | foreach ($moduleTVs as $k=>$moduleTV) { |
362 | 362 | $installSample = in_array('sample', $moduleTV[12]) && $installData == 1; |
363 | - if($installSample || in_array($k, $selTVs)) { |
|
363 | + if ($installSample || in_array($k, $selTVs)) { |
|
364 | 364 | $name = mysqli_real_escape_string($conn, $moduleTV[0]); |
365 | 365 | $caption = mysqli_real_escape_string($conn, $moduleTV[1]); |
366 | 366 | $desc = mysqli_real_escape_string($conn, $moduleTV[2]); |
@@ -378,25 +378,25 @@ discard block |
||
378 | 378 | // Create the category if it does not already exist |
379 | 379 | $category = getCreateDbCategory($category, $sqlParser); |
380 | 380 | |
381 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'"); |
|
381 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name'"); |
|
382 | 382 | if (mysqli_num_rows($rs)) { |
383 | 383 | $insert = true; |
384 | - while($row = mysqli_fetch_assoc($rs)) { |
|
385 | - 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']};")) { |
|
386 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
384 | + while ($row = mysqli_fetch_assoc($rs)) { |
|
385 | + 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']};")) { |
|
386 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
387 | 387 | return; |
388 | 388 | } |
389 | 389 | $insert = false; |
390 | 390 | } |
391 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
391 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
392 | 392 | } else { |
393 | 393 | //$q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',(SELECT (CASE COUNT(*) WHEN 0 THEN 0 ELSE `id` END) `id` FROM $dbase.`" . $table_prefix . "categories` WHERE `category` = '$category'),$locked,'$input_options','$output_widget','$output_widget_params','$input_default');"; |
394 | - $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');"; |
|
394 | + $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');"; |
|
395 | 395 | if (!mysqli_query($sqlParser->conn, $q)) { |
396 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
396 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
397 | 397 | return; |
398 | 398 | } |
399 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
399 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | // add template assignments |
@@ -405,10 +405,10 @@ discard block |
||
405 | 405 | if (count($assignments) > 0) { |
406 | 406 | |
407 | 407 | // remove existing tv -> template assignments |
408 | - $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
408 | + $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
409 | 409 | $row = mysqli_fetch_assoc($ds); |
410 | 410 | $id = $row["id"]; |
411 | - mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\''); |
|
411 | + mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_tmplvar_templates` WHERE tmplvarid = \''.$id.'\''); |
|
412 | 412 | |
413 | 413 | // add tv -> template assignments |
414 | 414 | foreach ($assignments as $assignment) { |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | if ($ds && $ts) { |
418 | 418 | $tRow = mysqli_fetch_assoc($ts); |
419 | 419 | $templateId = $tRow['id']; |
420 | - mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
420 | + mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 | } |
@@ -427,12 +427,12 @@ discard block |
||
427 | 427 | |
428 | 428 | // Install Chunks |
429 | 429 | if (isset ($_POST['chunk']) || $installData) { |
430 | - echo "<h3>" . $_lang['chunks'] . ":</h3> "; |
|
430 | + echo "<h3>".$_lang['chunks'].":</h3> "; |
|
431 | 431 | $selChunks = $_POST['chunk']; |
432 | 432 | foreach ($moduleChunks as $k=>$moduleChunk) { |
433 | 433 | $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1; |
434 | 434 | $count_new_name = 0; |
435 | - if($installSample || in_array($k, $selChunks)) { |
|
435 | + if ($installSample || in_array($k, $selChunks)) { |
|
436 | 436 | |
437 | 437 | $name = mysqli_real_escape_string($conn, $moduleChunk[0]); |
438 | 438 | $desc = mysqli_real_escape_string($conn, $moduleChunk[1]); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | $filecontent = $moduleChunk[2]; |
442 | 442 | |
443 | 443 | if (!file_exists($filecontent)) |
444 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
444 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_chunk']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
445 | 445 | else { |
446 | 446 | |
447 | 447 | // Create the category if it does not already exist |
@@ -449,31 +449,31 @@ discard block |
||
449 | 449 | |
450 | 450 | $chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1); |
451 | 451 | $chunk = mysqli_real_escape_string($conn, $chunk); |
452 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'"); |
|
452 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$name'"); |
|
453 | 453 | $count_original_name = mysqli_num_rows($rs); |
454 | - if($overwrite == 'false') { |
|
455 | - $newname = $name . '-' . str_replace('.', '_', $modx_version); |
|
456 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'"); |
|
454 | + if ($overwrite == 'false') { |
|
455 | + $newname = $name.'-'.str_replace('.', '_', $modx_version); |
|
456 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$newname'"); |
|
457 | 457 | $count_new_name = mysqli_num_rows($rs); |
458 | 458 | } |
459 | 459 | $update = $count_original_name > 0 && $overwrite == 'true'; |
460 | 460 | if ($update) { |
461 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
461 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
462 | 462 | $errors += 1; |
463 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
463 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
464 | 464 | return; |
465 | 465 | } |
466 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
467 | - } elseif($count_new_name == 0) { |
|
468 | - if($count_original_name > 0 && $overwrite == 'false') { |
|
466 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
467 | + } elseif ($count_new_name == 0) { |
|
468 | + if ($count_original_name > 0 && $overwrite == 'false') { |
|
469 | 469 | $name = $newname; |
470 | 470 | } |
471 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) { |
|
471 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) { |
|
472 | 472 | $errors += 1; |
473 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
473 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
474 | 474 | return; |
475 | 475 | } |
476 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
476 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | } |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | |
483 | 483 | // Install Modules |
484 | 484 | if (isset ($_POST['module']) || $installData) { |
485 | - echo "<h3>" . $_lang['modules'] . ":</h3> "; |
|
485 | + echo "<h3>".$_lang['modules'].":</h3> "; |
|
486 | 486 | $selModules = $_POST['module']; |
487 | 487 | foreach ($moduleModules as $k=>$moduleModule) { |
488 | 488 | $installSample = in_array('sample', $moduleModule[7]) && $installData == 1; |
489 | - if($installSample || in_array($k, $selModules)) { |
|
489 | + if ($installSample || in_array($k, $selModules)) { |
|
490 | 490 | $name = mysqli_real_escape_string($conn, $moduleModule[0]); |
491 | 491 | $desc = mysqli_real_escape_string($conn, $moduleModule[1]); |
492 | 492 | $filecontent = $moduleModule[2]; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
496 | 496 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
497 | 497 | if (!file_exists($filecontent)) |
498 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
498 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_module']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
499 | 499 | else { |
500 | 500 | |
501 | 501 | // Create the category if it does not already exist |
@@ -504,22 +504,22 @@ discard block |
||
504 | 504 | $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
505 | 505 | // $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab |
506 | 506 | $module = mysqli_real_escape_string($conn, $module); |
507 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'"); |
|
507 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_modules` WHERE name='$name'"); |
|
508 | 508 | if (mysqli_num_rows($rs)) { |
509 | 509 | $row = mysqli_fetch_assoc($rs); |
510 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
511 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
512 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
510 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
511 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
512 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
513 | 513 | return; |
514 | 514 | } |
515 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
515 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
516 | 516 | } else { |
517 | 517 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
518 | - 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);")) { |
|
519 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
518 | + 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);")) { |
|
519 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
520 | 520 | return; |
521 | 521 | } |
522 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
522 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | } |
@@ -528,11 +528,11 @@ discard block |
||
528 | 528 | |
529 | 529 | // Install Plugins |
530 | 530 | if (isset ($_POST['plugin']) || $installData) { |
531 | - echo "<h3>" . $_lang['plugins'] . ":</h3> "; |
|
531 | + echo "<h3>".$_lang['plugins'].":</h3> "; |
|
532 | 532 | $selPlugs = $_POST['plugin']; |
533 | 533 | foreach ($modulePlugins as $k=>$modulePlugin) { |
534 | 534 | $installSample = in_array('sample', $modulePlugin[8]) && $installData == 1; |
535 | - if($installSample || in_array($k, $selPlugs)) { |
|
535 | + if ($installSample || in_array($k, $selPlugs)) { |
|
536 | 536 | $name = mysqli_real_escape_string($conn, $modulePlugin[0]); |
537 | 537 | $desc = mysqli_real_escape_string($conn, $modulePlugin[1]); |
538 | 538 | $filecontent = $modulePlugin[2]; |
@@ -542,17 +542,17 @@ discard block |
||
542 | 542 | $category = mysqli_real_escape_string($conn, $modulePlugin[6]); |
543 | 543 | $leg_names = ''; |
544 | 544 | $disabled = $modulePlugin[9]; |
545 | - if(array_key_exists(7, $modulePlugin)) { |
|
545 | + if (array_key_exists(7, $modulePlugin)) { |
|
546 | 546 | // parse comma-separated legacy names and prepare them for sql IN clause |
547 | - $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
|
547 | + $leg_names = "'".implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7])))."'"; |
|
548 | 548 | } |
549 | 549 | if (!file_exists($filecontent)) |
550 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
550 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_plugin']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
551 | 551 | else { |
552 | 552 | |
553 | 553 | // disable legacy versions based on legacy_names provided |
554 | - if(!empty($leg_names)) { |
|
555 | - $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
554 | + if (!empty($leg_names)) { |
|
555 | + $update_query = "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
556 | 556 | $rs = mysqli_query($sqlParser->conn, $update_query); |
557 | 557 | } |
558 | 558 | |
@@ -562,50 +562,50 @@ discard block |
||
562 | 562 | $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
563 | 563 | $plugin = removeDocblock($plugin, 'plugin'); |
564 | 564 | $plugin = mysqli_real_escape_string($conn, $plugin); |
565 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'"); |
|
565 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name'"); |
|
566 | 566 | if (mysqli_num_rows($rs)) { |
567 | 567 | $insert = true; |
568 | - while($row = mysqli_fetch_assoc($rs)) { |
|
569 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
570 | - if($row['description'] == $desc){ |
|
571 | - if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
572 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
568 | + while ($row = mysqli_fetch_assoc($rs)) { |
|
569 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
570 | + if ($row['description'] == $desc) { |
|
571 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
572 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
573 | 573 | return; |
574 | 574 | } |
575 | 575 | $insert = false; |
576 | 576 | } else { |
577 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
577 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
578 | 578 | echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
579 | 579 | return; |
580 | 580 | } |
581 | 581 | } |
582 | 582 | } |
583 | - if($insert === true) { |
|
584 | - $properties = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
585 | - 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);")) { |
|
583 | + if ($insert === true) { |
|
584 | + $properties = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
585 | + 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);")) { |
|
586 | 586 | echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
587 | 587 | return; |
588 | 588 | } |
589 | 589 | } |
590 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
590 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
591 | 591 | } else { |
592 | 592 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
593 | - 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);")) { |
|
594 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
593 | + 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);")) { |
|
594 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
595 | 595 | return; |
596 | 596 | } |
597 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
597 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
598 | 598 | } |
599 | 599 | // add system events |
600 | 600 | if (count($events) > 0) { |
601 | - $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';"); |
|
601 | + $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';"); |
|
602 | 602 | if ($ds) { |
603 | 603 | $row = mysqli_fetch_assoc($ds); |
604 | 604 | $id = $row["id"]; |
605 | 605 | // remove existing events |
606 | - mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_plugin_events` WHERE pluginid = \'' . $id . '\''); |
|
606 | + mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_plugin_events` WHERE pluginid = \''.$id.'\''); |
|
607 | 607 | // add new events |
608 | - 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) . "')"); |
|
608 | + 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)."')"); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | } |
@@ -615,18 +615,18 @@ discard block |
||
615 | 615 | |
616 | 616 | // Install Snippets |
617 | 617 | if (isset ($_POST['snippet']) || $installData) { |
618 | - echo "<h3>" . $_lang['snippets'] . ":</h3> "; |
|
618 | + echo "<h3>".$_lang['snippets'].":</h3> "; |
|
619 | 619 | $selSnips = $_POST['snippet']; |
620 | 620 | foreach ($moduleSnippets as $k=>$moduleSnippet) { |
621 | 621 | $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1; |
622 | - if($installSample || in_array($k, $selSnips)) { |
|
622 | + if ($installSample || in_array($k, $selSnips)) { |
|
623 | 623 | $name = mysqli_real_escape_string($conn, $moduleSnippet[0]); |
624 | 624 | $desc = mysqli_real_escape_string($conn, $moduleSnippet[1]); |
625 | 625 | $filecontent = $moduleSnippet[2]; |
626 | 626 | $properties = $moduleSnippet[3]; |
627 | 627 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
628 | 628 | if (!file_exists($filecontent)) |
629 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
629 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_snippet']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
630 | 630 | else { |
631 | 631 | |
632 | 632 | // Create the category if it does not already exist |
@@ -635,22 +635,22 @@ discard block |
||
635 | 635 | $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent))); |
636 | 636 | $snippet = removeDocblock($snippet, 'snippet'); |
637 | 637 | $snippet = mysqli_real_escape_string($conn, $snippet); |
638 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'"); |
|
638 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_snippets` WHERE name='$name'"); |
|
639 | 639 | if (mysqli_num_rows($rs)) { |
640 | 640 | $row = mysqli_fetch_assoc($rs); |
641 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
642 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
643 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
641 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
642 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
643 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
644 | 644 | return; |
645 | 645 | } |
646 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
646 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
647 | 647 | } else { |
648 | 648 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
649 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
|
650 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
649 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
|
650 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
651 | 651 | return; |
652 | 652 | } |
653 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
653 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | } |
@@ -659,24 +659,24 @@ discard block |
||
659 | 659 | |
660 | 660 | // Install demo-site |
661 | 661 | if ($installData && $moduleSQLDataFile) { |
662 | - echo "<p>" . $_lang['installing_demo_site']; |
|
662 | + echo "<p>".$_lang['installing_demo_site']; |
|
663 | 663 | $sqlParser->process($moduleSQLDataFile); |
664 | 664 | // display database results |
665 | 665 | if ($sqlParser->installFailed == true) { |
666 | 666 | $errors += 1; |
667 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
668 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
669 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
667 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
668 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
669 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
670 | 670 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
671 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
671 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
672 | 672 | } |
673 | 673 | echo "</p>"; |
674 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
674 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
675 | 675 | return; |
676 | 676 | } else { |
677 | 677 | $sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", $sqlParser->prefix); |
678 | 678 | $rs = mysqli_query($sqlParser->conn, $sql); |
679 | - if(mysqli_num_rows($rs)) { |
|
679 | + if (mysqli_num_rows($rs)) { |
|
680 | 680 | $row = mysqli_fetch_assoc($rs); |
681 | 681 | $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']); |
682 | 682 | mysqli_query($sqlParser->conn, $sql); |
@@ -687,9 +687,9 @@ discard block |
||
687 | 687 | |
688 | 688 | // Install Dependencies |
689 | 689 | foreach ($moduleDependencies as $dependency) { |
690 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"'); |
|
690 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM '.$dbase.'`'.$sqlParser->prefix.'site_modules` WHERE name="'.$dependency['module'].'"'); |
|
691 | 691 | if (!$ds) { |
692 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
692 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
693 | 693 | return; |
694 | 694 | } else { |
695 | 695 | $row = mysqli_fetch_assoc($ds); |
@@ -697,37 +697,37 @@ discard block |
||
697 | 697 | $moduleGuid = $row["guid"]; |
698 | 698 | } |
699 | 699 | // get extra id |
700 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"'); |
|
700 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE '.$dependency['column'].'="'.$dependency['name'].'"'); |
|
701 | 701 | if (!$ds) { |
702 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
702 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
703 | 703 | return; |
704 | 704 | } else { |
705 | 705 | $row = mysqli_fetch_assoc($ds); |
706 | 706 | $extraId = $row["id"]; |
707 | 707 | } |
708 | 708 | // setup extra as module dependency |
709 | - $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'); |
|
709 | + $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'); |
|
710 | 710 | if (!$ds) { |
711 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
711 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
712 | 712 | return; |
713 | 713 | } else { |
714 | 714 | if (mysqli_num_rows($ds) === 0) { |
715 | - mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')'); |
|
716 | - echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_create'] . '</span></p>'; |
|
715 | + mysqli_query($sqlParser->conn, 'INSERT INTO '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` (module, resource, type) VALUES('.$moduleId.','.$extraId.','.$dependency['type'].')'); |
|
716 | + echo '<p> '.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_create'].'</span></p>'; |
|
717 | 717 | } else { |
718 | - 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']); |
|
719 | - echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_update'] . '</span></p>'; |
|
718 | + 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']); |
|
719 | + echo '<p> '.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_update'].'</span></p>'; |
|
720 | 720 | } |
721 | 721 | if ($dependency['type'] == 30 || $dependency['type'] == 40) { |
722 | 722 | // set extra guid for plugins and snippets |
723 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1'); |
|
723 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE id='.$extraId.' LIMIT 1'); |
|
724 | 724 | if (!$ds) { |
725 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
725 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
726 | 726 | return; |
727 | 727 | } else { |
728 | 728 | if (mysqli_num_rows($ds) != 0) { |
729 | - mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId); |
|
730 | - echo '<p> ' . $dependency['name'] . ': <span class="ok">' . $_lang['guid_set'] . '</span></p>'; |
|
729 | + mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` SET moduleguid = '.$moduleGuid.' WHERE id='.$extraId); |
|
730 | + echo '<p> '.$dependency['name'].': <span class="ok">'.$_lang['guid_set'].'</span></p>'; |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | } |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | |
737 | 737 | // call back function |
738 | 738 | if ($callBackFnc != "") |
739 | - $callBackFnc ($sqlParser); |
|
739 | + $callBackFnc($sqlParser); |
|
740 | 740 | |
741 | 741 | // Setup the MODX API -- needed for the cache processor |
742 | 742 | define('MODX_API_MODE', true); |
@@ -771,20 +771,20 @@ discard block |
||
771 | 771 | } |
772 | 772 | |
773 | 773 | // setup completed! |
774 | -echo "<p><b>" . $_lang['installation_successful'] . "</b></p>"; |
|
775 | -echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>"; |
|
774 | +echo "<p><b>".$_lang['installation_successful']."</b></p>"; |
|
775 | +echo "<p>".$_lang['to_log_into_content_manager']."</p>"; |
|
776 | 776 | if ($installMode == 0) { |
777 | - echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['installation_note'] . "</p>"; |
|
777 | + echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['installation_note']."</p>"; |
|
778 | 778 | } else { |
779 | - echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['upgrade_note'] . "</p>"; |
|
779 | + echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['upgrade_note']."</p>"; |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | // Property Update function |
783 | -function propUpdate($new,$old){ |
|
783 | +function propUpdate($new, $old){ |
|
784 | 784 | $newArr = parseProperties($new); |
785 | 785 | $oldArr = parseProperties($old); |
786 | - foreach ($oldArr as $k => $v){ |
|
787 | - if (isset($v['0']['options'])){ |
|
786 | + foreach ($oldArr as $k => $v) { |
|
787 | + if (isset($v['0']['options'])) { |
|
788 | 788 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
789 | 789 | } |
790 | 790 | } |
@@ -794,30 +794,30 @@ discard block |
||
794 | 794 | return $return; |
795 | 795 | } |
796 | 796 | |
797 | -function parseProperties($propertyString, $json=false) { |
|
798 | - $propertyString = str_replace('{}', '', $propertyString ); |
|
799 | - $propertyString = str_replace('} {', ',', $propertyString ); |
|
797 | +function parseProperties($propertyString, $json = false){ |
|
798 | + $propertyString = str_replace('{}', '', $propertyString); |
|
799 | + $propertyString = str_replace('} {', ',', $propertyString); |
|
800 | 800 | |
801 | - if(empty($propertyString)) return array(); |
|
802 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
801 | + if (empty($propertyString)) return array(); |
|
802 | + if ($propertyString == '{}' || $propertyString == '[]') return array(); |
|
803 | 803 | |
804 | 804 | $jsonFormat = isJson($propertyString, true); |
805 | 805 | $property = array(); |
806 | 806 | // old format |
807 | - if ( $jsonFormat === false) { |
|
808 | - $props= explode('&', $propertyString); |
|
807 | + if ($jsonFormat === false) { |
|
808 | + $props = explode('&', $propertyString); |
|
809 | 809 | foreach ($props as $prop) { |
810 | 810 | $prop = trim($prop); |
811 | - if($prop === '') { |
|
811 | + if ($prop === '') { |
|
812 | 812 | continue; |
813 | 813 | } |
814 | 814 | |
815 | 815 | $arr = explode(';', $prop); |
816 | - if( ! is_array($arr)) { |
|
816 | + if (!is_array($arr)) { |
|
817 | 817 | $arr = array(); |
818 | 818 | } |
819 | 819 | $key = explode('=', isset($arr[0]) ? $arr[0] : ''); |
820 | - if( ! is_array($key) || empty($key[0])) { |
|
820 | + if (!is_array($key) || empty($key[0])) { |
|
821 | 821 | continue; |
822 | 822 | } |
823 | 823 | |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | |
842 | 842 | } |
843 | 843 | // new json-format |
844 | - } else if(!empty($jsonFormat)){ |
|
844 | + } else if (!empty($jsonFormat)) { |
|
845 | 845 | $property = $jsonFormat; |
846 | 846 | } |
847 | 847 | if ($json) { |
@@ -851,25 +851,25 @@ discard block |
||
851 | 851 | return $property; |
852 | 852 | } |
853 | 853 | |
854 | -function isJson($string, $returnData=false) { |
|
854 | +function isJson($string, $returnData = false){ |
|
855 | 855 | $data = json_decode($string, true); |
856 | 856 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
857 | 857 | } |
858 | 858 | |
859 | -function getCreateDbCategory($category, $sqlParser) { |
|
859 | +function getCreateDbCategory($category, $sqlParser){ |
|
860 | 860 | $dbase = $sqlParser->dbname; |
861 | - $dbase = '`' . trim($dbase,'`') . '`'; |
|
861 | + $dbase = '`'.trim($dbase, '`').'`'; |
|
862 | 862 | $table_prefix = $sqlParser->prefix; |
863 | 863 | $category_id = 0; |
864 | - if(!empty($category)) { |
|
864 | + if (!empty($category)) { |
|
865 | 865 | $category = mysqli_real_escape_string($sqlParser->conn, $category); |
866 | 866 | $rs = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."categories` WHERE category = '".$category."'"); |
867 | - if(mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) { |
|
867 | + if (mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) { |
|
868 | 868 | $category_id = $row['id']; |
869 | 869 | } else { |
870 | 870 | $q = "INSERT INTO $dbase.`".$table_prefix."categories` (`category`) VALUES ('{$category}');"; |
871 | 871 | $rs = mysqli_query($sqlParser->conn, $q); |
872 | - if($rs) { |
|
872 | + if ($rs) { |
|
873 | 873 | $category_id = mysqli_insert_id($sqlParser->conn); |
874 | 874 | } |
875 | 875 | } |
@@ -878,12 +878,12 @@ discard block |
||
878 | 878 | } |
879 | 879 | |
880 | 880 | // Remove installer Docblock only from components using plugin FileSource / fileBinding |
881 | -function removeDocblock($code, $type) { |
|
881 | +function removeDocblock($code, $type){ |
|
882 | 882 | |
883 | 883 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
884 | 884 | |
885 | 885 | // Procedure taken from plugin.filesource.php |
886 | - switch($type) { |
|
886 | + switch ($type) { |
|
887 | 887 | case 'snippet': |
888 | 888 | $elm_name = 'snippets'; |
889 | 889 | $include = 'return require'; |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | default: |
900 | 900 | return $cleaned; |
901 | 901 | }; |
902 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
902 | + if (substr(trim($cleaned), 0, $count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
903 | 903 | return $cleaned; |
904 | 904 | |
905 | 905 | // fileBinding not found - return code incl docblock |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0; |
|
2 | +$installMode = isset($_POST['installmode']) ? (int) $_POST['installmode'] : 0; |
|
3 | 3 | |
4 | -if( ! function_exists('getTemplates')) { |
|
4 | +if (!function_exists('getTemplates')) { |
|
5 | 5 | /** |
6 | 6 | * @param array $presets |
7 | 7 | * @return string |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | $i++; |
27 | 27 | } |
28 | 28 | if (0 < count($_)) { |
29 | - return '<h3>[%templates%]</h3>' . implode("\n", $_); |
|
29 | + return '<h3>[%templates%]</h3>'.implode("\n", $_); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | -if( ! function_exists('getTVs')) { |
|
34 | +if (!function_exists('getTVs')) { |
|
35 | 35 | /** |
36 | 36 | * @param array $presets |
37 | 37 | * @return string |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | $i++; |
58 | 58 | } |
59 | 59 | if (0 < count($_)) { |
60 | - return '<h3>[%tvs%]</h3>' . implode("\n", $_); |
|
60 | + return '<h3>[%tvs%]</h3>'.implode("\n", $_); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | -if( ! function_exists('getChunks')) { |
|
65 | +if (!function_exists('getChunks')) { |
|
66 | 66 | /** |
67 | 67 | * display chunks |
68 | 68 | * |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | $i++; |
90 | 90 | } |
91 | 91 | if (0 < count($_)) { |
92 | - return '<h3>[%chunks%]</h3>' . implode("\n", $_); |
|
92 | + return '<h3>[%chunks%]</h3>'.implode("\n", $_); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | -if( ! function_exists('getModules')) { |
|
97 | +if (!function_exists('getModules')) { |
|
98 | 98 | /** |
99 | 99 | * display modules |
100 | 100 | * |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | $i++; |
122 | 122 | } |
123 | 123 | if (0 < count($_)) { |
124 | - return '<h3>[%modules%]</h3>' . implode("\n", $_); |
|
124 | + return '<h3>[%modules%]</h3>'.implode("\n", $_); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | -if( ! function_exists('getPlugins')) { |
|
129 | +if (!function_exists('getPlugins')) { |
|
130 | 130 | /** |
131 | 131 | * display plugins |
132 | 132 | * |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | $i++; |
158 | 158 | } |
159 | 159 | if (0 < count($_)) { |
160 | - return '<h3>[%plugins%]</h3>' . implode("\n", $_); |
|
160 | + return '<h3>[%plugins%]</h3>'.implode("\n", $_); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | -if( ! function_exists('getSnippets')) { |
|
165 | +if (!function_exists('getSnippets')) { |
|
166 | 166 | /** |
167 | 167 | * display snippets |
168 | 168 | * |
@@ -189,24 +189,24 @@ discard block |
||
189 | 189 | $i++; |
190 | 190 | } |
191 | 191 | if (0 < count($_)) { |
192 | - return '<h3>[%snippets%]</h3>' . implode("\n", $_); |
|
192 | + return '<h3>[%snippets%]</h3>'.implode("\n", $_); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | -switch($installMode){ |
|
197 | +switch ($installMode) { |
|
198 | 198 | case 0: |
199 | 199 | case 2: |
200 | 200 | $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci'; |
201 | 201 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
202 | 202 | $_POST['database_connection_charset'] = $database_charset; |
203 | - if(empty($_SESSION['databaseloginpassword'])) |
|
203 | + if (empty($_SESSION['databaseloginpassword'])) |
|
204 | 204 | $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
205 | - if(empty($_SESSION['databaseloginname'])) |
|
205 | + if (empty($_SESSION['databaseloginname'])) |
|
206 | 206 | $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
207 | 207 | break; |
208 | 208 | case 1: |
209 | - include $base_path . MGR_DIR . '/includes/config.inc.php'; |
|
209 | + include $base_path.MGR_DIR.'/includes/config.inc.php'; |
|
210 | 210 | if (@ $conn = mysqli_connect($database_server, $database_user, $database_password)) { |
211 | 211 | if (@ mysqli_query($conn, "USE {$dbase}")) { |
212 | 212 | if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) { |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $ph['checked'] = isset ($_POST['installdata']) && $_POST['installdata'] == "1" ? 'checked' : ''; |
262 | 262 | |
263 | 263 | # load setup information file |
264 | -include($base_path . 'install/setup.info.php'); |
|
264 | +include($base_path.'install/setup.info.php'); |
|
265 | 265 | $ph['templates'] = getTemplates($moduleTemplates); |
266 | 266 | $ph['tvs'] = getTVs($moduleTVs); |
267 | 267 | $ph['chunks'] = getChunks($moduleChunks); |
@@ -271,6 +271,6 @@ discard block |
||
271 | 271 | |
272 | 272 | $ph['action'] = ($installMode == 1) ? 'mode' : 'connection'; |
273 | 273 | |
274 | -$tpl = file_get_contents($base_path . 'install/actions/tpl_options.html'); |
|
275 | -$content = parse($tpl,$ph); |
|
276 | -echo parse($content,$_lang,'[%','%]'); |
|
274 | +$tpl = file_get_contents($base_path.'install/actions/tpl_options.html'); |
|
275 | +$content = parse($tpl, $ph); |
|
276 | +echo parse($content, $_lang, '[%', '%]'); |
@@ -1,23 +1,23 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | 6 | $tpl = array( |
7 | - 'viewForm' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_viewForm.tpl'), |
|
8 | - 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
9 | - 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
10 | - 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
11 | - 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl') |
|
7 | + 'viewForm' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_viewForm.tpl'), |
|
8 | + 'panelGroup' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelGroup.tpl'), |
|
9 | + 'panelHeading' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelHeading.tpl'), |
|
10 | + 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelCollapse.tpl'), |
|
11 | + 'elementsRow' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_elementsRow.tpl') |
|
12 | 12 | ); |
13 | 13 | |
14 | -function parsePh($tpl, $ph) { |
|
14 | +function parsePh($tpl, $ph){ |
|
15 | 15 | global $modx, $_lang; |
16 | 16 | $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); |
17 | 17 | return $modx->parseText($tpl, $ph); |
18 | 18 | } |
19 | 19 | |
20 | -function renderViewSwitchButtons($cssId) { |
|
20 | +function renderViewSwitchButtons($cssId){ |
|
21 | 21 | global $modx, $_lang, $tpl; |
22 | 22 | |
23 | 23 | return parsePh($tpl['viewForm'], array( |
@@ -25,19 +25,19 @@ discard block |
||
25 | 25 | )); |
26 | 26 | } |
27 | 27 | |
28 | -function createResourceList($resourceTable, $resources) { |
|
28 | +function createResourceList($resourceTable, $resources){ |
|
29 | 29 | global $modx, $_lang, $_style, $modx_textdir, $tpl; |
30 | 30 | |
31 | 31 | $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false; |
32 | 32 | |
33 | - if( ! is_array($items) || empty($items)) { |
|
33 | + if (!is_array($items) || empty($items)) { |
|
34 | 34 | return $_lang['no_results']; |
35 | 35 | } |
36 | 36 | |
37 | 37 | // Prepare elements- and categories-list |
38 | 38 | $elements = array(); |
39 | 39 | $categories = array(); |
40 | - foreach($items as $row) { |
|
40 | + foreach ($items as $row) { |
|
41 | 41 | $catid = $row['catid'] ? $row['catid'] : 0; |
42 | 42 | $categories[$catid] = array('name' => stripslashes($row['category'])); |
43 | 43 | $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources); |
@@ -45,18 +45,18 @@ discard block |
||
45 | 45 | |
46 | 46 | // Now render categories / panel-collapse |
47 | 47 | $panelGroup = ''; |
48 | - foreach($elements as $catid => $elList) { |
|
48 | + foreach ($elements as $catid => $elList) { |
|
49 | 49 | // Add panel-heading / category-collapse to output |
50 | 50 | $panelGroup .= parsePh($tpl['panelHeading'], array( |
51 | 51 | 'tab' => $resourceTable, |
52 | 52 | 'category' => $categories[$catid]['name'], |
53 | - 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '', |
|
53 | + 'categoryid' => $catid != '' ? ' <small>('.$catid.')</small>' : '', |
|
54 | 54 | 'catid' => $catid, |
55 | 55 | )); |
56 | 56 | |
57 | 57 | // Prepare content for panel-collapse |
58 | 58 | $panelCollapse = ''; |
59 | - foreach($elList as $el) { |
|
59 | + foreach ($elList as $el) { |
|
60 | 60 | $panelCollapse .= parsePh($tpl['elementsRow'], $el); |
61 | 61 | } |
62 | 62 | |
@@ -74,30 +74,30 @@ discard block |
||
74 | 74 | )); |
75 | 75 | } |
76 | 76 | |
77 | -function createCombinedView($resources) { |
|
77 | +function createCombinedView($resources){ |
|
78 | 78 | global $modx, $_lang, $_style, $modx_textdir; |
79 | 79 | |
80 | 80 | $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false; |
81 | 81 | $types = isset($resources->types) ? $resources->types : false; |
82 | 82 | $categories = isset($resources->categories) ? $resources->categories : false; |
83 | 83 | |
84 | - if(!$itemsPerCategory) { |
|
84 | + if (!$itemsPerCategory) { |
|
85 | 85 | return $_lang['no_results']; |
86 | 86 | } |
87 | 87 | |
88 | 88 | $tpl = array( |
89 | - 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
90 | - 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
91 | - 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
92 | - 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl'), |
|
89 | + 'panelGroup' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelGroup.tpl'), |
|
90 | + 'panelHeading' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelHeading.tpl'), |
|
91 | + 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelCollapse.tpl'), |
|
92 | + 'elementsRow' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_elementsRow.tpl'), |
|
93 | 93 | ); |
94 | 94 | |
95 | 95 | // Easily loop through $itemsPerCategory-Array |
96 | 96 | $panelGroup = ''; |
97 | - foreach($categories as $catid => $category) { |
|
97 | + foreach ($categories as $catid => $category) { |
|
98 | 98 | // Prepare collapse content / elements-list |
99 | 99 | $panelCollapse = ''; |
100 | - foreach($itemsPerCategory[$catid] as $el) { |
|
100 | + foreach ($itemsPerCategory[$catid] as $el) { |
|
101 | 101 | $resourceTable = $el['type']; |
102 | 102 | $ph = prepareElementRowPh($el, $resourceTable, $resources); |
103 | 103 | $panelCollapse .= parsePh($tpl['elementsRow'], $ph); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $panelGroup .= parsePh($tpl['panelHeading'], array( |
108 | 108 | 'tab' => 'categories_list', |
109 | 109 | 'category' => $categories[$catid], |
110 | - 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '', |
|
110 | + 'categoryid' => $catid != '' ? ' <small>('.$catid.')</small>' : '', |
|
111 | 111 | 'catid' => $catid, |
112 | 112 | )); |
113 | 113 | |
@@ -131,14 +131,14 @@ discard block |
||
131 | 131 | * @param $resources |
132 | 132 | * @return array |
133 | 133 | */ |
134 | -function prepareElementRowPh($row, $resourceTable, $resources) { |
|
134 | +function prepareElementRowPh($row, $resourceTable, $resources){ |
|
135 | 135 | global $modx, $modx_textdir, $_style, $_lang; |
136 | 136 | |
137 | 137 | $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; |
138 | 138 | |
139 | 139 | $_lang["confirm_delete"] = $_lang["delete"]; |
140 | 140 | |
141 | - switch($resourceTable){ |
|
141 | + switch ($resourceTable) { |
|
142 | 142 | case 'site_templates': |
143 | 143 | $class = $row['selectable'] ? '' : 'disabledPlugin'; |
144 | 144 | $lockElementType = 1; |
@@ -175,65 +175,65 @@ discard block |
||
175 | 175 | // Prepare displaying user-locks |
176 | 176 | $lockedByUser = ''; |
177 | 177 | $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true); |
178 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
179 | - if($rowLock['sid'] == $modx->sid) { |
|
178 | + if ($rowLock && $modx->hasPermission('display_locks')) { |
|
179 | + if ($rowLock['sid'] == $modx->sid) { |
|
180 | 180 | $title = $modx->parseText($_lang["lock_element_editing"], array( |
181 | - 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
181 | + 'element_type' => $_lang["lock_element_type_".$lockElementType], |
|
182 | 182 | 'lasthit_df' => $rowLock['lasthit_df'] |
183 | 183 | )); |
184 | - $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span> '; |
|
184 | + $lockedByUser = '<span title="'.$title.'" class="editResource" style="cursor:context-menu;">'.$_style['tree_preview_resource'].'</span> '; |
|
185 | 185 | } else { |
186 | 186 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
187 | - 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
187 | + 'element_type' => $_lang["lock_element_type_".$lockElementType], |
|
188 | 188 | 'username' => $rowLock['username'], |
189 | 189 | 'lasthit_df' => $rowLock['lasthit_df'] |
190 | 190 | )); |
191 | - if($modx->hasPermission('remove_locks')) { |
|
192 | - $lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>'; |
|
191 | + if ($modx->hasPermission('remove_locks')) { |
|
192 | + $lockedByUser = '<a href="javascript:;" onclick="unlockElement('.$lockElementType.', '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource"><i class="'.$_style['icons_secured'].'"></i></a>'; |
|
193 | 193 | } else { |
194 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>'; |
|
194 | + $lockedByUser = '<span title="'.$title.'" class="lockedResource" style="cursor:context-menu;"><i class="'.$_style['icons_secured'].'"></i></span>'; |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | } |
198 | - if($lockedByUser) { |
|
199 | - $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>'; |
|
198 | + if ($lockedByUser) { |
|
199 | + $lockedByUser = '<div class="lockCell">'.$lockedByUser.'</div>'; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | // Caption |
203 | - if($resourceTable == 'site_tmplvars') { |
|
204 | - $caption = !empty($row['description']) ? ' ' . $row['caption'] . ' <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption']; |
|
203 | + if ($resourceTable == 'site_tmplvars') { |
|
204 | + $caption = !empty($row['description']) ? ' '.$row['caption'].' <small>('.$row['description'].')</small>' : ' '.$row['caption']; |
|
205 | 205 | } else { |
206 | - $caption = !empty($row['description']) ? ' ' . $row['description'] : ''; |
|
206 | + $caption = !empty($row['description']) ? ' '.$row['description'] : ''; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | // Special marks |
210 | 210 | $tplInfo = array(); |
211 | - if($row['locked']) { |
|
211 | + if ($row['locked']) { |
|
212 | 212 | $tplInfo[] = $_lang['locked']; |
213 | 213 | } |
214 | - if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') { |
|
214 | + if ($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') { |
|
215 | 215 | $tplInfo[] = $_lang['defaulttemplate_title']; |
216 | 216 | } |
217 | - $marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : ''; |
|
217 | + $marks = !empty($tplInfo) ? ' <em>('.implode(', ', $tplInfo).')</em>' : ''; |
|
218 | 218 | |
219 | 219 | /* row buttons */ |
220 | 220 | $buttons = ''; |
221 | - if($modx->hasPermission($types['actions']['edit'][1])) { |
|
222 | - $buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>'; |
|
221 | + if ($modx->hasPermission($types['actions']['edit'][1])) { |
|
222 | + $buttons .= '<li><a title="'.$_lang["edit_resource"].'" href="index.php?a='.$types['actions']['edit'][0].'&id='.$row['id'].'"><i class="fa fa-edit fa-fw"></i></a></li>'; |
|
223 | 223 | } |
224 | - if($modx->hasPermission($types['actions']['duplicate'][1])) { |
|
225 | - $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>'; |
|
224 | + if ($modx->hasPermission($types['actions']['duplicate'][1])) { |
|
225 | + $buttons .= '<li><a onclick="return confirm(\''.$_lang["confirm_duplicate_record"].'\')" title="'.$_lang["resource_duplicate"].'" href="index.php?a='.$types['actions']['duplicate'][0].'&id='.$row['id'].'"><i class="fa fa-clone fa-fw"></i></a></li>'; |
|
226 | 226 | } |
227 | - if($modx->hasPermission($types['actions']['remove'][1])) { |
|
228 | - $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>'; |
|
227 | + if ($modx->hasPermission($types['actions']['remove'][1])) { |
|
228 | + $buttons .= '<li><a onclick="return confirm(\''.$_lang["confirm_delete"].'\')" title="'.$_lang["delete"].'" href="index.php?a='.$types['actions']['remove'][0].'&id='.$row['id'].'"><i class="fa fa-trash fa-fw"></i></a></li>'; |
|
229 | 229 | } |
230 | - $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : ''; |
|
230 | + $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">'.$buttons.'</ul></div>' : ''; |
|
231 | 231 | |
232 | 232 | $catid = $row['catid'] ? $row['catid'] : 0; |
233 | 233 | |
234 | 234 | // Placeholders for elements-row |
235 | 235 | return array( |
236 | - 'class' => $class ? ' class="' . $class . '"' : '', |
|
236 | + 'class' => $class ? ' class="'.$class.'"' : '', |
|
237 | 237 | 'lockedByUser' => $lockedByUser, |
238 | 238 | 'name' => $row['name'], |
239 | 239 | 'caption' => $caption, |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.'); |
4 | 4 | } |
5 | 5 | |
6 | 6 | unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes |
7 | 7 | |
8 | -if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) { |
|
8 | +if ($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) { |
|
9 | 9 | // seems to be a new install - send the user to the configuration page |
10 | 10 | exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>'); |
11 | 11 | } |
@@ -16,50 +16,50 @@ discard block |
||
16 | 16 | $_SESSION['nrnewmessages'] = 0; |
17 | 17 | |
18 | 18 | // setup message info |
19 | -if($modx->hasPermission('messages')) { |
|
20 | - include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php'); |
|
19 | +if ($modx->hasPermission('messages')) { |
|
20 | + include_once(MODX_MANAGER_PATH.'includes/messageCount.inc.php'); |
|
21 | 21 | $_SESSION['nrtotalmessages'] = $nrtotalmessages; |
22 | 22 | $_SESSION['nrnewmessages'] = $nrnewmessages; |
23 | 23 | |
24 | 24 | $msg = array(); |
25 | 25 | $msg[] = sprintf('<a href="index.php?a=10" target="main"><img src="%s" /></a>', $_style['icons_mail_large']); |
26 | - $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">' . $_SESSION['nrnewmessages'] . '</span>)' : ''; |
|
26 | + $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">'.$_SESSION['nrnewmessages'].'</span>)' : ''; |
|
27 | 27 | $msg[] = sprintf('<span style="color:#909090;font-size:15px;font-weight:bold"> <a class="wm_messages_inbox_link" href="index.php?a=10" target="main">[%%inbox%%]</a>%s</span><br />', $nrnewmessages); |
28 | - $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">' . $_SESSION['nrnewmessages'] . '</span>' : '0'; |
|
28 | + $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">'.$_SESSION['nrnewmessages'].'</span>' : '0'; |
|
29 | 29 | $welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages); |
30 | 30 | $msg[] = sprintf('<span class="comment">%s</span>', $welcome_messages); |
31 | 31 | $ph['MessageInfo'] = implode("\n", $msg); |
32 | 32 | } |
33 | 33 | |
34 | 34 | // setup icons |
35 | -if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) { |
|
35 | +if ($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) { |
|
36 | 36 | $icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]'; |
37 | 37 | $ph['SecurityIcon'] = wrapIcon($icon, 75); |
38 | 38 | } |
39 | -if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) { |
|
39 | +if ($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) { |
|
40 | 40 | $icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]'; |
41 | 41 | $ph['WebUserIcon'] = wrapIcon($icon, 99); |
42 | 42 | } |
43 | -if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) { |
|
43 | +if ($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) { |
|
44 | 44 | $icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]'; |
45 | 45 | $ph['ModulesIcon'] = wrapIcon($icon, 106); |
46 | 46 | } |
47 | -if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) { |
|
47 | +if ($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) { |
|
48 | 48 | $icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]'; |
49 | 49 | $ph['ResourcesIcon'] = wrapIcon($icon, 76); |
50 | 50 | } |
51 | -if($modx->hasPermission('bk_manager')) { |
|
51 | +if ($modx->hasPermission('bk_manager')) { |
|
52 | 52 | $icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]'; |
53 | 53 | $ph['BackupIcon'] = wrapIcon($icon, 93); |
54 | 54 | } |
55 | -if($modx->hasPermission('help')) { |
|
55 | +if ($modx->hasPermission('help')) { |
|
56 | 56 | $icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]'; |
57 | 57 | $ph['HelpIcon'] = wrapIcon($icon, 9); |
58 | 58 | } |
59 | 59 | // do some config checks |
60 | -if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) { |
|
61 | - include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php'); |
|
62 | - if($config_check_results != $_lang['configcheck_ok']) { |
|
60 | +if (($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) { |
|
61 | + include_once(MODX_MANAGER_PATH.'includes/config_check.inc.php'); |
|
62 | + if ($config_check_results != $_lang['configcheck_ok']) { |
|
63 | 63 | $ph['config_check_results'] = $config_check_results; |
64 | 64 | $ph['config_display'] = 'block'; |
65 | 65 | } else { |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | // Check logout-reminder |
73 | -if(isset($_SESSION['show_logout_reminder'])) { |
|
74 | - switch($_SESSION['show_logout_reminder']['type']) { |
|
73 | +if (isset($_SESSION['show_logout_reminder'])) { |
|
74 | + switch ($_SESSION['show_logout_reminder']['type']) { |
|
75 | 75 | case 'logout_reminder': |
76 | 76 | $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly'); |
77 | 77 | $ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | </tr> |
126 | 126 | </table>'; |
127 | 127 | |
128 | -$nrnewmessages = '<span class="text-danger">' . $_SESSION['nrnewmessages'] . '</span>'; |
|
128 | +$nrnewmessages = '<span class="text-danger">'.$_SESSION['nrnewmessages'].'</span>'; |
|
129 | 129 | |
130 | 130 | $ph['UserInfo'] = $modx->parseText($tpl, array( |
131 | 131 | 'username' => $modx->getLoginUserName(), |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | $from[] = " us LEFT JOIN [+prefix+]active_users au ON au.sid=us.sid WHERE au.action <> '8'"; |
141 | 141 | $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC'); |
142 | 142 | |
143 | -if($modx->db->getRecordCount($rs) < 1) { |
|
143 | +if ($modx->db->getRecordCount($rs) < 1) { |
|
144 | 144 | $html = '<p>[%no_active_users_found%]</p>'; |
145 | 145 | } else { |
146 | - include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); |
|
146 | + include_once(MODX_MANAGER_PATH.'includes/actionlist.inc.php'); |
|
147 | 147 | $now = $_SERVER['REQUEST_TIME'] + $server_offset_time; |
148 | 148 | $ph['now'] = strftime('%H:%M:%S', $now); |
149 | 149 | $timetocheck = ($now - (60 * 20)); //+$server_offset_time; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $userList = array(); |
169 | 169 | $userCount = array(); |
170 | 170 | // Create userlist with session-count first before output |
171 | - while($activeusers = $modx->db->getRow($rs)) { |
|
171 | + while ($activeusers = $modx->db->getRow($rs)) { |
|
172 | 172 | $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1; |
173 | 173 | |
174 | 174 | $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : ''; |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | $currentaction |
187 | 187 | ); |
188 | 188 | } |
189 | - foreach($userList as $params) { |
|
189 | + foreach ($userList as $params) { |
|
190 | 190 | $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : ''; |
191 | - $html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params); |
|
191 | + $html .= "\n\t\t".vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $html .= ' |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $ph['OnlineInfo'] = $html; |
201 | 201 | |
202 | 202 | // include rss feeds for important forum topics |
203 | -include_once(MODX_MANAGER_PATH . 'includes/rss.inc.php'); |
|
203 | +include_once(MODX_MANAGER_PATH.'includes/rss.inc.php'); |
|
204 | 204 | $ph['modx_security_notices_content'] = $feedData['modx_security_notices_content']; |
205 | 205 | $ph['modx_news_content'] = $feedData['modx_news_content']; |
206 | 206 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | // invoke event OnManagerWelcomePrerender |
233 | 233 | $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender'); |
234 | -if(is_array($evtOut)) { |
|
234 | +if (is_array($evtOut)) { |
|
235 | 235 | $output = implode('', $evtOut); |
236 | 236 | $ph['OnManagerWelcomePrerender'] = $output; |
237 | 237 | } |
@@ -365,57 +365,57 @@ discard block |
||
365 | 365 | |
366 | 366 | // invoke OnManagerWelcomeHome event |
367 | 367 | $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets)); |
368 | -if(is_array($sitewidgets)) { |
|
368 | +if (is_array($sitewidgets)) { |
|
369 | 369 | $newwidgets = array(); |
370 | - foreach($sitewidgets as $widget){ |
|
370 | + foreach ($sitewidgets as $widget) { |
|
371 | 371 | $newwidgets = array_merge($newwidgets, unserialize($widget)); |
372 | 372 | } |
373 | 373 | $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets; |
374 | 374 | } |
375 | 375 | |
376 | -usort($widgets, function ($a, $b) { |
|
376 | +usort($widgets, function($a, $b){ |
|
377 | 377 | return $a['menuindex'] - $b['menuindex']; |
378 | 378 | }); |
379 | 379 | |
380 | 380 | $tpl = getTplWidget(); |
381 | 381 | $output = ''; |
382 | -foreach($widgets as $widget) { |
|
383 | - if ($widget['hide'] != '1'){ |
|
382 | +foreach ($widgets as $widget) { |
|
383 | + if ($widget['hide'] != '1') { |
|
384 | 384 | $output .= $modx->parseText($tpl, $widget); |
385 | 385 | } |
386 | 386 | } |
387 | 387 | $ph['widgets'] = $output; |
388 | 388 | |
389 | 389 | // load template |
390 | -if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) { |
|
391 | - $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'; |
|
390 | +if (!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) { |
|
391 | + $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH.'media/style/common/welcome.tpl'; |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | $target = $modx->config['manager_welcome_tpl']; |
395 | 395 | $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target); |
396 | 396 | $target = $modx->mergeSettingsContent($target); |
397 | 397 | |
398 | -if(substr($target, 0, 1) === '@') { |
|
399 | - if(substr($target, 0, 6) === '@CHUNK') { |
|
398 | +if (substr($target, 0, 1) === '@') { |
|
399 | + if (substr($target, 0, 6) === '@CHUNK') { |
|
400 | 400 | $content = $modx->getChunk(trim(substr($target, 7))); |
401 | - } elseif(substr($target, 0, 5) === '@FILE') { |
|
401 | + } elseif (substr($target, 0, 5) === '@FILE') { |
|
402 | 402 | $content = file_get_contents(trim(substr($target, 6))); |
403 | 403 | } else { |
404 | 404 | $content = ''; |
405 | 405 | } |
406 | 406 | } else { |
407 | 407 | $chunk = $modx->getChunk($target); |
408 | - if($chunk !== false && !empty($chunk)) { |
|
408 | + if ($chunk !== false && !empty($chunk)) { |
|
409 | 409 | $content = $chunk; |
410 | - } elseif(is_file(MODX_BASE_PATH . $target)) { |
|
411 | - $content = file_get_contents(MODX_BASE_PATH . $target); |
|
412 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) { |
|
413 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl'); |
|
414 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible |
|
410 | + } elseif (is_file(MODX_BASE_PATH.$target)) { |
|
411 | + $content = file_get_contents(MODX_BASE_PATH.$target); |
|
412 | + } elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/welcome.tpl')) { |
|
413 | + $content = file_get_contents(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/welcome.tpl'); |
|
414 | + } elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/html/welcome.html')) // ClipperCMS compatible |
|
415 | 415 | { |
416 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); |
|
416 | + $content = file_get_contents(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/html/welcome.html'); |
|
417 | 417 | } else { |
418 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'); |
|
418 | + $content = file_get_contents(MODX_MANAGER_PATH.'media/style/common/welcome.tpl'); |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | $content = $modx->mergeConditionalTagsContent($content); |
424 | 424 | $content = $modx->mergeSettingsContent($content); |
425 | 425 | $content = $modx->parseText($content, $ph); |
426 | -if(strpos($content, '[+') !== false) { |
|
426 | +if (strpos($content, '[+') !== false) { |
|
427 | 427 | $modx->toPlaceholders($ph); |
428 | 428 | $content = $modx->mergePlaceholderContent($content); |
429 | 429 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $content = $modx->parseText($content, $_style, '[&', '&]'); |
433 | 433 | $content = $modx->cleanUpMODXTags($content); //cleanup |
434 | 434 | |
435 | -if($js = $modx->getRegisteredClientScripts()) { |
|
435 | +if ($js = $modx->getRegisteredClientScripts()) { |
|
436 | 436 | $content .= $js; |
437 | 437 | } |
438 | 438 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | // <a href="javascript:;" class="setting"><i class="fa fa-cog"></i></a> |
443 | 443 | // <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a> |
444 | 444 | //</span> |
445 | -function getTplWidget() { // recent document info |
|
445 | +function getTplWidget(){ // recent document info |
|
446 | 446 | return ' |
447 | 447 | <div class="[+cols+]" id="[+id+]"> |
448 | 448 | <div class="card"[+cardAttr+]> |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | '; |
454 | 454 | } |
455 | 455 | |
456 | -function getRecentInfo() { // recent document info |
|
456 | +function getRecentInfo(){ // recent document info |
|
457 | 457 | global $modx; |
458 | 458 | |
459 | 459 | $modx->addSnippet('recentInfoList', 'getRecentInfoList'); |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | return $html; |
480 | 480 | } |
481 | 481 | |
482 | -function getRecentInfoList() { |
|
482 | +function getRecentInfoList(){ |
|
483 | 483 | global $modx; |
484 | 484 | |
485 | 485 | $rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10); |
486 | 486 | |
487 | - if($modx->db->getRecordCount($rs) < 1) { |
|
487 | + if ($modx->db->getRecordCount($rs) < 1) { |
|
488 | 488 | return '<tr><td>[%no_activity_message%]</td></tr>'; |
489 | 489 | } |
490 | 490 | |
@@ -494,20 +494,20 @@ discard block |
||
494 | 494 | $btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> '; |
495 | 495 | |
496 | 496 | $output = array(); |
497 | - while($ph = $modx->db->getRow($rs)) { |
|
497 | + while ($ph = $modx->db->getRow($rs)) { |
|
498 | 498 | $docid = $ph['id']; |
499 | 499 | $_ = $modx->getUserInfo($ph['editedby']); |
500 | 500 | $ph['username'] = $_['username']; |
501 | 501 | |
502 | - if($ph['deleted'] == 1) { |
|
502 | + if ($ph['deleted'] == 1) { |
|
503 | 503 | $ph['status'] = 'deleted text-danger'; |
504 | - } elseif($ph['published'] == 0) { |
|
504 | + } elseif ($ph['published'] == 0) { |
|
505 | 505 | $ph['status'] = 'unpublished font-italic text-muted'; |
506 | 506 | } else { |
507 | 507 | $ph['status'] = 'published'; |
508 | 508 | } |
509 | 509 | |
510 | - if($modx->hasPermission('edit_document')) { |
|
510 | + if ($modx->hasPermission('edit_document')) { |
|
511 | 511 | $ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']); |
512 | 512 | } else { |
513 | 513 | $ph['edit_btn'] = ''; |
@@ -522,8 +522,8 @@ discard block |
||
522 | 522 | $preview_disabled |
523 | 523 | ), $btntpl['preview_btn']); |
524 | 524 | |
525 | - if($modx->hasPermission('delete_document')) { |
|
526 | - if($ph['deleted'] == 0) { |
|
525 | + if ($modx->hasPermission('delete_document')) { |
|
526 | + if ($ph['deleted'] == 0) { |
|
527 | 527 | $delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> '; |
528 | 528 | } else { |
529 | 529 | $delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> '; |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | $ph['delete_btn'] = ''; |
534 | 534 | } |
535 | 535 | |
536 | - if($ph['deleted'] == 1 && $ph['published'] == 0) { |
|
536 | + if ($ph['deleted'] == 1 && $ph['published'] == 0) { |
|
537 | 537 | $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
538 | - } elseif($ph['deleted'] == 1 && $ph['published'] == 1) { |
|
538 | + } elseif ($ph['deleted'] == 1 && $ph['published'] == 1) { |
|
539 | 539 | $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
540 | - } elseif($ph['deleted'] == 0 && $ph['published'] == 0) { |
|
540 | + } elseif ($ph['deleted'] == 0 && $ph['published'] == 0) { |
|
541 | 541 | $publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
542 | 542 | } else { |
543 | 543 | $publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
@@ -546,16 +546,16 @@ discard block |
||
546 | 546 | |
547 | 547 | $ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>'); |
548 | 548 | |
549 | - if($ph['longtitle'] == '') { |
|
549 | + if ($ph['longtitle'] == '') { |
|
550 | 550 | $ph['longtitle'] = '(<i>[%not_set%]</i>)'; |
551 | 551 | } |
552 | - if($ph['description'] == '') { |
|
552 | + if ($ph['description'] == '') { |
|
553 | 553 | $ph['description'] = '(<i>[%not_set%]</i>)'; |
554 | 554 | } |
555 | - if($ph['introtext'] == '') { |
|
555 | + if ($ph['introtext'] == '') { |
|
556 | 556 | $ph['introtext'] = '(<i>[%not_set%]</i>)'; |
557 | 557 | } |
558 | - if($ph['alias'] == '') { |
|
558 | + if ($ph['alias'] == '') { |
|
559 | 559 | $ph['alias'] = '(<i>[%not_set%]</i>)'; |
560 | 560 | } |
561 | 561 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | return implode("\n", $output); |
565 | 565 | } |
566 | 566 | |
567 | -function getRecentInfoRowTpl() { |
|
567 | +function getRecentInfoRowTpl(){ |
|
568 | 568 | $tpl = ' |
569 | 569 | <tr> |
570 | 570 | <td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td> |
@@ -593,11 +593,11 @@ discard block |
||
593 | 593 | } |
594 | 594 | |
595 | 595 | // setup icons |
596 | -function wrapIcon($i, $action) { |
|
596 | +function wrapIcon($i, $action){ |
|
597 | 597 | return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i); |
598 | 598 | } |
599 | 599 | |
600 | -function getStartUpScript() { |
|
600 | +function getStartUpScript(){ |
|
601 | 601 | $script = ' |
602 | 602 | <script type="text/javascript"> |
603 | 603 | function hideConfigCheckWarning(key) { |
@@ -1,17 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('edit_template') && $modx->manager->action == '301') { |
|
5 | +if (!$modx->hasPermission('edit_template') && $modx->manager->action == '301') { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | -if(!$modx->hasPermission('new_template') && $modx->manager->action == '300') { |
|
8 | +if (!$modx->hasPermission('new_template') && $modx->manager->action == '300') { |
|
9 | 9 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
10 | 10 | } |
11 | 11 | |
12 | -$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
13 | -$origin = isset($_REQUEST['or']) ? (int)$_REQUEST['or'] : 76; |
|
14 | -$originId = isset($_REQUEST['oid']) ? (int)$_REQUEST['oid'] : NULL; |
|
12 | +$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
13 | +$origin = isset($_REQUEST['or']) ? (int) $_REQUEST['or'] : 76; |
|
14 | +$originId = isset($_REQUEST['oid']) ? (int) $_REQUEST['oid'] : NULL; |
|
15 | 15 | |
16 | 16 | $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars'); |
17 | 17 | $tbl_site_templates = $modx->getFullTableName('site_templates'); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $tbl_documentgroup_names = $modx->getFullTableName('documentgroup_names'); |
20 | 20 | |
21 | 21 | // check to see the snippet editor isn't locked |
22 | -if($lockedEl = $modx->elementIsLocked(2, $id)) { |
|
22 | +if ($lockedEl = $modx->elementIsLocked(2, $id)) { |
|
23 | 23 | $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['tmplvar'])); |
24 | 24 | } |
25 | 25 | // end check for lock |
@@ -29,25 +29,25 @@ discard block |
||
29 | 29 | |
30 | 30 | global $content; |
31 | 31 | $content = array(); |
32 | -if(isset($_GET['id'])) { |
|
32 | +if (isset($_GET['id'])) { |
|
33 | 33 | $rs = $modx->db->select('*', $tbl_site_tmplvars, "id='{$id}'"); |
34 | 34 | $content = $modx->db->getRow($rs); |
35 | - if(!$content) { |
|
36 | - header("Location: " . MODX_SITE_URL . "index.php?id={$site_start}"); |
|
35 | + if (!$content) { |
|
36 | + header("Location: ".MODX_SITE_URL."index.php?id={$site_start}"); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | $_SESSION['itemname'] = $content['caption']; |
40 | - if($content['locked'] == 1 && $modx->hasPermission('save_role') != 1) { |
|
40 | + if ($content['locked'] == 1 && $modx->hasPermission('save_role') != 1) { |
|
41 | 41 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
42 | 42 | } |
43 | -} else if(isset($_REQUEST['itemname'])) { |
|
43 | +} else if (isset($_REQUEST['itemname'])) { |
|
44 | 44 | $content['name'] = $_REQUEST['itemname']; |
45 | 45 | } else { |
46 | 46 | $_SESSION['itemname'] = $_lang["new_tmplvars"]; |
47 | - $content['category'] = (int)$_REQUEST['catid']; |
|
47 | + $content['category'] = (int) $_REQUEST['catid']; |
|
48 | 48 | } |
49 | 49 | |
50 | -if($modx->manager->hasFormValues()) { |
|
50 | +if ($modx->manager->hasFormValues()) { |
|
51 | 51 | $modx->manager->loadFormValues(); |
52 | 52 | } |
53 | 53 | |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | // Add lock-element JS-Script |
57 | 57 | $lockElementId = $id; |
58 | 58 | $lockElementType = 2; |
59 | -require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php'); |
|
59 | +require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php'); |
|
60 | 60 | |
61 | 61 | // get available RichText Editors |
62 | 62 | $RTEditors = ''; |
63 | 63 | $evtOut = $modx->invokeEvent('OnRichTextEditorRegister', array('forfrontend' => 1)); |
64 | -if(is_array($evtOut)) { |
|
64 | +if (is_array($evtOut)) { |
|
65 | 65 | $RTEditors = implode(',', $evtOut); |
66 | 66 | } |
67 | 67 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | }, |
108 | 108 | cancel: function() { |
109 | 109 | documentDirty = false; |
110 | - document.location.href = 'index.php?a=<?= $origin ?><?=(empty($originId) ? '' : '&id=' . $originId) ?>'; |
|
110 | + document.location.href = 'index.php?a=<?= $origin ?><?=(empty($originId) ? '' : '&id='.$originId) ?>'; |
|
111 | 111 | } |
112 | 112 | }; |
113 | 113 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | <?php |
280 | 280 | // invoke OnTVFormPrerender event |
281 | 281 | $evtOut = $modx->invokeEvent('OnTVFormPrerender', array('id' => $id)); |
282 | - if(is_array($evtOut)) { |
|
282 | + if (is_array($evtOut)) { |
|
283 | 283 | echo implode("", $evtOut); |
284 | 284 | } |
285 | 285 | ?> |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | <input type="hidden" name="params" value="<?= $modx->htmlspecialchars($content['display_params']) ?>"> |
292 | 292 | |
293 | 293 | <h1> |
294 | - <i class="fa fa-list-alt"></i><?= ($content['name'] ? $content['name'] . '<small>(' . $content['id'] . ')</small>' : $_lang['new_tmplvars']) ?><i class="fa fa-question-circle help"></i> |
|
294 | + <i class="fa fa-list-alt"></i><?= ($content['name'] ? $content['name'].'<small>('.$content['id'].')</small>' : $_lang['new_tmplvars']) ?><i class="fa fa-question-circle help"></i> |
|
295 | 295 | </h1> |
296 | 296 | |
297 | 297 | <?= $_style['actionbuttons']['dynamic']['element'] ?> |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | <div class="col-md-9 col-lg-10"> |
315 | 315 | <div class="form-control-name clearfix"> |
316 | 316 | <input name="name" type="text" maxlength="50" value="<?= $modx->htmlspecialchars($content['name']) ?>" class="form-control form-control-lg" onchange="documentDirty=true;" /> |
317 | - <?php if($modx->hasPermission('save_role')): ?> |
|
318 | - <label class="custom-control" title="<?= $_lang['lock_tmplvars'] . "\n" . $_lang['lock_tmplvars_msg'] ?>" tooltip> |
|
317 | + <?php if ($modx->hasPermission('save_role')): ?> |
|
318 | + <label class="custom-control" title="<?= $_lang['lock_tmplvars']."\n".$_lang['lock_tmplvars_msg'] ?>" tooltip> |
|
319 | 319 | <input name="locked" type="checkbox"<?= ($content['locked'] == 1 ? ' checked="checked"' : '') ?> /> |
320 | 320 | <i class="fa fa-lock"></i> |
321 | 321 | </label> |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | <select name="categoryid" class="form-control" onChange="documentDirty=true;"> |
344 | 344 | <option> </option> |
345 | 345 | <?php |
346 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
347 | - foreach(getCategories() as $n => $v) { |
|
348 | - echo "<option value='" . $v['id'] . "'" . ($content["category"] == $v["id"] ? " selected='selected'" : "") . ">" . $modx->htmlspecialchars($v["category"]) . "</option>"; |
|
346 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
347 | + foreach (getCategories() as $n => $v) { |
|
348 | + echo "<option value='".$v['id']."'".($content["category"] == $v["id"] ? " selected='selected'" : "").">".$modx->htmlspecialchars($v["category"])."</option>"; |
|
349 | 349 | } |
350 | 350 | ?> |
351 | 351 | </select> |
@@ -383,11 +383,11 @@ discard block |
||
383 | 383 | <optgroup label="Custom Type"> |
384 | 384 | <option value="custom_tv" <?= ($content['type'] == 'custom_tv' ? "selected='selected'" : "") ?>>Custom Input</option> |
385 | 385 | <?php |
386 | - $custom_tvs = scandir(MODX_BASE_PATH . 'assets/tvs'); |
|
387 | - foreach($custom_tvs as $ctv) { |
|
388 | - if(strpos($ctv, '.') !== 0 && $ctv != 'index.html') { |
|
389 | - $selected = ($content['type'] == 'custom_tv:' . $ctv ? "selected='selected'" : ""); |
|
390 | - echo '<option value="custom_tv:' . $ctv . '" ' . $selected . '>' . $ctv . '</option>'; |
|
386 | + $custom_tvs = scandir(MODX_BASE_PATH.'assets/tvs'); |
|
387 | + foreach ($custom_tvs as $ctv) { |
|
388 | + if (strpos($ctv, '.') !== 0 && $ctv != 'index.html') { |
|
389 | + $selected = ($content['type'] == 'custom_tv:'.$ctv ? "selected='selected'" : ""); |
|
390 | + echo '<option value="custom_tv:'.$ctv.'" '.$selected.'>'.$ctv.'</option>'; |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | ?> |
@@ -462,36 +462,36 @@ discard block |
||
462 | 462 | $tplList = '<ul>'; |
463 | 463 | $preCat = ''; |
464 | 464 | $insideUl = 0; |
465 | - while($row = $modx->db->getRow($rs)) { |
|
465 | + while ($row = $modx->db->getRow($rs)) { |
|
466 | 466 | $row['category'] = stripslashes($row['category']); //pixelchutes |
467 | - if($preCat !== $row['category']) { |
|
467 | + if ($preCat !== $row['category']) { |
|
468 | 468 | $tplList .= $insideUl ? '</ul>' : ''; |
469 | - $tplList .= '<li><strong>' . $row['category'] . ($row['catid'] != '' ? ' <small>(' . $row['catid'] . ')</small>' : '') . '</strong><ul>'; |
|
469 | + $tplList .= '<li><strong>'.$row['category'].($row['catid'] != '' ? ' <small>('.$row['catid'].')</small>' : '').'</strong><ul>'; |
|
470 | 470 | $insideUl = 1; |
471 | 471 | } |
472 | 472 | |
473 | - if($modx->manager->action == '300' && $modx->config['default_template'] == $row['id']) { |
|
473 | + if ($modx->manager->action == '300' && $modx->config['default_template'] == $row['id']) { |
|
474 | 474 | $checked = true; |
475 | - } elseif(isset($_GET['tpl']) && $_GET['tpl'] == $row['id']) { |
|
475 | + } elseif (isset($_GET['tpl']) && $_GET['tpl'] == $row['id']) { |
|
476 | 476 | $checked = true; |
477 | - } elseif($id == 0 && is_array($_POST['template'])) { |
|
477 | + } elseif ($id == 0 && is_array($_POST['template'])) { |
|
478 | 478 | $checked = in_array($row['id'], $_POST['template']); |
479 | 479 | } else { |
480 | 480 | $checked = $row['tmplvarid']; |
481 | 481 | } |
482 | 482 | $selectable = !$row['selectable'] ? ' class="disabled"' : ''; |
483 | 483 | $checked = $checked ? ' checked="checked"' : ''; |
484 | - $tplId = ' <small>(' . $row['id'] . ')</small>'; |
|
485 | - $desc = !empty($row['tpldescription']) ? ' - ' . $row['tpldescription'] : ''; |
|
484 | + $tplId = ' <small>('.$row['id'].')</small>'; |
|
485 | + $desc = !empty($row['tpldescription']) ? ' - '.$row['tpldescription'] : ''; |
|
486 | 486 | |
487 | 487 | $tplInfo = array(); |
488 | - if($row['tpllocked']) { |
|
488 | + if ($row['tpllocked']) { |
|
489 | 489 | $tplInfo[] = $_lang['locked']; |
490 | 490 | } |
491 | - if($row['id'] == $modx->config['default_template']) { |
|
491 | + if ($row['id'] == $modx->config['default_template']) { |
|
492 | 492 | $tplInfo[] = $_lang['defaulttemplate_title']; |
493 | 493 | } |
494 | - $tplInfo = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : ''; |
|
494 | + $tplInfo = !empty($tplInfo) ? ' <em>('.implode(', ', $tplInfo).')</em>' : ''; |
|
495 | 495 | |
496 | 496 | $tplList .= sprintf('<li><label%s><input name="template[]" value="%s" type="checkbox" %s onchange="documentDirty=true;"> %s%s%s%s</label></li>', $selectable, $row['id'], $checked, $row['templatename'], $tplId, $desc, $tplInfo); |
497 | 497 | $tplList .= '</li>'; |
@@ -506,13 +506,13 @@ discard block |
||
506 | 506 | |
507 | 507 | <!-- Access Permissions --> |
508 | 508 | <?php |
509 | - if($use_udperms == 1) { |
|
509 | + if ($use_udperms == 1) { |
|
510 | 510 | // fetch permissions for the variable |
511 | 511 | $rs = $modx->db->select('documentgroup', $modx->getFullTableName('site_tmplvar_access'), "tmplvarid='{$id}'"); |
512 | 512 | $groupsarray = $modx->db->getColumn('documentgroup', $rs); |
513 | 513 | |
514 | 514 | ?> |
515 | - <?php if($modx->hasPermission('access_permissions')) { ?> |
|
515 | + <?php if ($modx->hasPermission('access_permissions')) { ?> |
|
516 | 516 | <script type="text/javascript"> |
517 | 517 | function makePublic(b) { |
518 | 518 | var notPublic = false; |
@@ -541,26 +541,26 @@ discard block |
||
541 | 541 | <?php |
542 | 542 | $chk = ''; |
543 | 543 | $rs = $modx->db->select('name, id', $tbl_documentgroup_names); |
544 | - if(empty($groupsarray) && is_array($_POST['docgroups']) && empty($_POST['id'])) { |
|
544 | + if (empty($groupsarray) && is_array($_POST['docgroups']) && empty($_POST['id'])) { |
|
545 | 545 | $groupsarray = $_POST['docgroups']; |
546 | 546 | } |
547 | - while($row = $modx->db->getRow($rs)) { |
|
547 | + while ($row = $modx->db->getRow($rs)) { |
|
548 | 548 | $checked = in_array($row['id'], $groupsarray); |
549 | - if($modx->hasPermission('access_permissions')) { |
|
550 | - if($checked) { |
|
549 | + if ($modx->hasPermission('access_permissions')) { |
|
550 | + if ($checked) { |
|
551 | 551 | $notPublic = true; |
552 | 552 | } |
553 | - $chks .= "<li><label><input type='checkbox' name='docgroups[]' value='" . $row['id'] . "' " . ($checked ? "checked='checked'" : '') . " onclick=\"makePublic(false)\" /> " . $row['name'] . "</label></li>"; |
|
553 | + $chks .= "<li><label><input type='checkbox' name='docgroups[]' value='".$row['id']."' ".($checked ? "checked='checked'" : '')." onclick=\"makePublic(false)\" /> ".$row['name']."</label></li>"; |
|
554 | 554 | } else { |
555 | - if($checked) { |
|
556 | - echo "<input type='hidden' name='docgroups[]' value='" . $row['id'] . "' />"; |
|
555 | + if ($checked) { |
|
556 | + echo "<input type='hidden' name='docgroups[]' value='".$row['id']."' />"; |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | } |
560 | - if($modx->hasPermission('access_permissions')) { |
|
561 | - $chks = "<li><label><input type='checkbox' name='chkalldocs' " . (!$notPublic ? "checked='checked'" : '') . " onclick=\"makePublic(true)\" /> <span class='warning'>" . $_lang['all_doc_groups'] . "</span></label></li>" . $chks; |
|
560 | + if ($modx->hasPermission('access_permissions')) { |
|
561 | + $chks = "<li><label><input type='checkbox' name='chkalldocs' ".(!$notPublic ? "checked='checked'" : '')." onclick=\"makePublic(true)\" /> <span class='warning'>".$_lang['all_doc_groups']."</span></label></li>".$chks; |
|
562 | 562 | } |
563 | - echo '<ul>' . $chks . '</ul>'; |
|
563 | + echo '<ul>'.$chks.'</ul>'; |
|
564 | 564 | ?> |
565 | 565 | <?php } ?> |
566 | 566 | <?php } ?> |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | <?php |
574 | 574 | // invoke OnTVFormRender event |
575 | 575 | $evtOut = $modx->invokeEvent('OnTVFormRender', array('id' => $id)); |
576 | - if(is_array($evtOut)) { |
|
576 | + if (is_array($evtOut)) { |
|
577 | 577 | echo implode('', $evtOut); |
578 | 578 | } |
579 | 579 | ?> |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('delete_snippet')) { |
|
5 | +if (!$modx->hasPermission('delete_snippet')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
@@ -34,5 +34,5 @@ discard block |
||
34 | 34 | $modx->clearCache('full'); |
35 | 35 | |
36 | 36 | // finished emptying cache - redirect |
37 | -$header="Location: index.php?a=76&r=2"; |
|
37 | +$header = "Location: index.php?a=76&r=2"; |
|
38 | 38 | header($header); |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/'); |
|
3 | +if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/'); |
|
4 | 4 | |
5 | -class MODIFIERS { |
|
5 | +class MODIFIERS{ |
|
6 | 6 | |
7 | 7 | public $placeholders = array(); |
8 | 8 | public $vars = array(); |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | $this->condModifiers = '=,is,eq,equals,ne,neq,notequals,isnot,isnt,not,%,isempty,isnotempty,isntempty,>=,gte,eg,gte,greaterthan,>,gt,isgreaterthan,isgt,lowerthan,<,lt,<=,lte,islte,islowerthan,islt,el,find,in,inarray,in_array,fnmatch,wcard,wcard_match,wildcard,wildcard_match,is_file,is_dir,file_exists,is_readable,is_writable,is_image,regex,preg,preg_match,memberof,mo,isinrole,ir'; |
31 | 31 | } |
32 | 32 | |
33 | - public function phxFilter($key,$value,$modifiers) |
|
33 | + public function phxFilter($key, $value, $modifiers) |
|
34 | 34 | { |
35 | 35 | global $modx; |
36 | - if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value); |
|
36 | + if (substr($modifiers, 0, 3) !== 'id(') $value = $this->parseDocumentSource($value); |
|
37 | 37 | $this->srcValue = $value; |
38 | 38 | $modifiers = trim($modifiers); |
39 | - $modifiers = ':'.trim($modifiers,':'); |
|
40 | - $modifiers = str_replace(array("\r\n","\r"), "\n", $modifiers); |
|
39 | + $modifiers = ':'.trim($modifiers, ':'); |
|
40 | + $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers); |
|
41 | 41 | $modifiers = $this->splitEachModifiers($modifiers); |
42 | 42 | |
43 | 43 | $this->placeholders = array(); |
@@ -45,118 +45,118 @@ discard block |
||
45 | 45 | $this->placeholders['dummy'] = ''; |
46 | 46 | $this->condition = array(); |
47 | 47 | $this->vars = array(); |
48 | - $this->vars['name'] = & $key; |
|
49 | - $value = $this->parsePhx($key,$value,$modifiers); |
|
48 | + $this->vars['name'] = & $key; |
|
49 | + $value = $this->parsePhx($key, $value, $modifiers); |
|
50 | 50 | $this->vars = array(); |
51 | 51 | return $value; |
52 | 52 | } |
53 | 53 | |
54 | - public function _getDelim($mode,$modifiers) { |
|
55 | - $c = substr($modifiers,0,1); |
|
56 | - if(!in_array($c, array('"', "'", '`')) ) return false; |
|
54 | + public function _getDelim($mode, $modifiers){ |
|
55 | + $c = substr($modifiers, 0, 1); |
|
56 | + if (!in_array($c, array('"', "'", '`'))) return false; |
|
57 | 57 | |
58 | - $modifiers = substr($modifiers,1); |
|
59 | - $closure = $mode=='(' ? "{$c})" : $c; |
|
60 | - if(strpos($modifiers, $closure)===false) return false; |
|
58 | + $modifiers = substr($modifiers, 1); |
|
59 | + $closure = $mode == '(' ? "{$c})" : $c; |
|
60 | + if (strpos($modifiers, $closure) === false) return false; |
|
61 | 61 | |
62 | 62 | return $c; |
63 | 63 | } |
64 | 64 | |
65 | - public function _getOpt($mode,$delim,$modifiers) { |
|
66 | - if($delim) { |
|
67 | - if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); |
|
65 | + public function _getOpt($mode, $delim, $modifiers){ |
|
66 | + if ($delim) { |
|
67 | + if ($mode == '(') return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1); |
|
68 | 68 | |
69 | - return substr($modifiers,1,strpos($modifiers,$delim,1)-1); |
|
69 | + return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1); |
|
70 | 70 | } |
71 | 71 | else { |
72 | - if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') ); |
|
72 | + if ($mode == '(') return substr($modifiers, 0, strpos($modifiers, ')')); |
|
73 | 73 | |
74 | 74 | $chars = str_split($modifiers); |
75 | - $opt=''; |
|
76 | - foreach($chars as $c) { |
|
77 | - if($c==':' || $c==')') break; |
|
78 | - $opt .=$c; |
|
75 | + $opt = ''; |
|
76 | + foreach ($chars as $c) { |
|
77 | + if ($c == ':' || $c == ')') break; |
|
78 | + $opt .= $c; |
|
79 | 79 | } |
80 | 80 | return $opt; |
81 | 81 | } |
82 | 82 | } |
83 | - public function _getRemainModifiers($mode,$delim,$modifiers) { |
|
84 | - if($delim) { |
|
85 | - if($mode=='(') |
|
86 | - return $this->_fetchContent($modifiers, $delim . ')'); |
|
83 | + public function _getRemainModifiers($mode, $delim, $modifiers){ |
|
84 | + if ($delim) { |
|
85 | + if ($mode == '(') |
|
86 | + return $this->_fetchContent($modifiers, $delim.')'); |
|
87 | 87 | else { |
88 | 88 | $modifiers = trim($modifiers); |
89 | - $modifiers = substr($modifiers,1); |
|
89 | + $modifiers = substr($modifiers, 1); |
|
90 | 90 | return $this->_fetchContent($modifiers, $delim); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | else { |
94 | - if($mode=='(') return $this->_fetchContent($modifiers, ')'); |
|
94 | + if ($mode == '(') return $this->_fetchContent($modifiers, ')'); |
|
95 | 95 | $chars = str_split($modifiers); |
96 | - foreach($chars as $c) { |
|
97 | - if($c==':') return $modifiers; |
|
98 | - else $modifiers = substr($modifiers,1); |
|
96 | + foreach ($chars as $c) { |
|
97 | + if ($c == ':') return $modifiers; |
|
98 | + else $modifiers = substr($modifiers, 1); |
|
99 | 99 | } |
100 | 100 | return $modifiers; |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - public function _fetchContent($string,$delim) { |
|
104 | + public function _fetchContent($string, $delim){ |
|
105 | 105 | $len = strlen($delim); |
106 | 106 | $string = $this->parseDocumentSource($string); |
107 | - return substr($string,strpos($string, $delim)+$len); |
|
107 | + return substr($string, strpos($string, $delim) + $len); |
|
108 | 108 | } |
109 | 109 | |
110 | - public function splitEachModifiers($modifiers) { |
|
110 | + public function splitEachModifiers($modifiers){ |
|
111 | 111 | global $modx; |
112 | 112 | |
113 | 113 | $cmd = ''; |
114 | 114 | $bt = ''; |
115 | 115 | $result = array(); |
116 | - while($bt!==$modifiers) { |
|
116 | + while ($bt !== $modifiers) { |
|
117 | 117 | $bt = $modifiers; |
118 | - $c = substr($modifiers,0,1); |
|
119 | - $modifiers = substr($modifiers,1); |
|
118 | + $c = substr($modifiers, 0, 1); |
|
119 | + $modifiers = substr($modifiers, 1); |
|
120 | 120 | |
121 | - if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
122 | - $c = substr($modifiers,strlen($match[1]),1); |
|
121 | + if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
122 | + $c = substr($modifiers, strlen($match[1]), 1); |
|
123 | 123 | $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]"; |
124 | - if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1); |
|
125 | - else $modifiers = substr($modifiers,strlen($match[1])); |
|
124 | + if ($c === '(') $modifiers = substr($modifiers, strlen($match[1]) + 1); |
|
125 | + else $modifiers = substr($modifiers, strlen($match[1])); |
|
126 | 126 | |
127 | - $delim = $this->_getDelim($c,$modifiers); |
|
128 | - $opt = $this->_getOpt($c,$delim,$modifiers); |
|
129 | - $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers)); |
|
127 | + $delim = $this->_getDelim($c, $modifiers); |
|
128 | + $opt = $this->_getOpt($c, $delim, $modifiers); |
|
129 | + $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers)); |
|
130 | 130 | |
131 | - $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo); |
|
131 | + $result[] = array('cmd'=>trim($match[1]), 'opt'=>$opt, 'debuginfo'=>$debuginfo); |
|
132 | 132 | $cmd = ''; |
133 | 133 | } |
134 | - elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
135 | - $modifiers = substr($modifiers,strlen($match[0])); |
|
136 | - $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]); |
|
134 | + elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
135 | + $modifiers = substr($modifiers, strlen($match[0])); |
|
136 | + $result[] = array('cmd'=>'math', 'opt'=>'%s'.$c.$match[0]); |
|
137 | 137 | $cmd = ''; |
138 | 138 | } |
139 | - elseif($c==='(' || $c==='=') { |
|
139 | + elseif ($c === '(' || $c === '=') { |
|
140 | 140 | $modifiers = $m1 = trim($modifiers); |
141 | - $delim = $this->_getDelim($c,$modifiers); |
|
142 | - $opt = $this->_getOpt($c,$delim,$modifiers); |
|
143 | - $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers)); |
|
141 | + $delim = $this->_getDelim($c, $modifiers); |
|
142 | + $opt = $this->_getOpt($c, $delim, $modifiers); |
|
143 | + $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers)); |
|
144 | 144 | $debuginfo = "#i=1 #c=[{$c}] #delim=[{$delim}] #m1=[{$m1}] remainMdf=[{$modifiers}]"; |
145 | 145 | |
146 | - $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo); |
|
146 | + $result[] = array('cmd'=>trim($cmd), 'opt'=>$opt, 'debuginfo'=>$debuginfo); |
|
147 | 147 | |
148 | 148 | $cmd = ''; |
149 | 149 | } |
150 | - elseif($c==':') { |
|
150 | + elseif ($c == ':') { |
|
151 | 151 | $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]"; |
152 | - if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
152 | + if ($cmd !== '') $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo); |
|
153 | 153 | |
154 | 154 | $cmd = ''; |
155 | 155 | } |
156 | - elseif(trim($modifiers)=='' && trim($cmd)!=='') { |
|
156 | + elseif (trim($modifiers) == '' && trim($cmd) !== '') { |
|
157 | 157 | $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]"; |
158 | 158 | $cmd .= $c; |
159 | - $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
159 | + $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo); |
|
160 | 160 | |
161 | 161 | break; |
162 | 162 | } |
@@ -165,65 +165,65 @@ discard block |
||
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | - if(empty($result)) return array(); |
|
168 | + if (empty($result)) return array(); |
|
169 | 169 | |
170 | - foreach($result as $i=>$a) |
|
170 | + foreach ($result as $i=>$a) |
|
171 | 171 | { |
172 | 172 | $a['opt'] = $this->parseDocumentSource($a['opt']); |
173 | - $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders); |
|
173 | + $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'], $this->placeholders); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | return $result; |
177 | 177 | } |
178 | 178 | |
179 | - public function parsePhx($key,$value,$modifiers) |
|
179 | + public function parsePhx($key, $value, $modifiers) |
|
180 | 180 | { |
181 | 181 | global $modx; |
182 | 182 | $lastKey = ''; |
183 | - $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true))); |
|
184 | - if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; |
|
185 | - if(empty($modifiers)) return ''; |
|
183 | + $cacheKey = md5(sprintf('parsePhx#%s#%s#%s', $key, $value, print_r($modifiers, true))); |
|
184 | + if (isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; |
|
185 | + if (empty($modifiers)) return ''; |
|
186 | 186 | |
187 | - foreach($modifiers as $m) |
|
187 | + foreach ($modifiers as $m) |
|
188 | 188 | { |
189 | 189 | $lastKey = strtolower($m['cmd']); |
190 | 190 | } |
191 | - $_ = explode(',',$this->condModifiers); |
|
192 | - if(in_array($lastKey,$_)) |
|
191 | + $_ = explode(',', $this->condModifiers); |
|
192 | + if (in_array($lastKey, $_)) |
|
193 | 193 | { |
194 | - $modifiers[] = array('cmd'=>'then','opt'=>'1'); |
|
195 | - $modifiers[] = array('cmd'=>'else','opt'=>'0'); |
|
194 | + $modifiers[] = array('cmd'=>'then', 'opt'=>'1'); |
|
195 | + $modifiers[] = array('cmd'=>'else', 'opt'=>'0'); |
|
196 | 196 | } |
197 | 197 | |
198 | - foreach($modifiers as $i=>$a) |
|
198 | + foreach ($modifiers as $i=>$a) |
|
199 | 199 | { |
200 | - $value = $this->Filter($key,$value, $a['cmd'], $a['opt']); |
|
200 | + $value = $this->Filter($key, $value, $a['cmd'], $a['opt']); |
|
201 | 201 | } |
202 | 202 | $this->tmpCache[$cacheKey] = $value; |
203 | 203 | return $value; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // Parser: modifier detection and eXtended processing if needed |
207 | - public function Filter($key, $value, $cmd, $opt='') |
|
207 | + public function Filter($key, $value, $cmd, $opt = '') |
|
208 | 208 | { |
209 | 209 | global $modx; |
210 | 210 | |
211 | - if($key==='documentObject') $value = $modx->documentIdentifier; |
|
211 | + if ($key === 'documentObject') $value = $modx->documentIdentifier; |
|
212 | 212 | $cmd = $this->parseDocumentSource($cmd); |
213 | - if(preg_match('@^[1-9][/0-9]*$@',$cmd)) |
|
213 | + if (preg_match('@^[1-9][/0-9]*$@', $cmd)) |
|
214 | 214 | { |
215 | - if(strpos($cmd,'/')!==false) |
|
216 | - $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); |
|
215 | + if (strpos($cmd, '/') !== false) |
|
216 | + $cmd = $this->substr($cmd, strrpos($cmd, '/') + 1); |
|
217 | 217 | $opt = $cmd; |
218 | 218 | $cmd = 'id'; |
219 | 219 | } |
220 | 220 | |
221 | - if(isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
222 | - elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
221 | + if (isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
222 | + elseif (isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
223 | 223 | else $this->elmName = ''; |
224 | 224 | |
225 | 225 | $cmd = strtolower($cmd); |
226 | - if($this->elmName!=='') |
|
226 | + if ($this->elmName !== '') |
|
227 | 227 | $value = $this->getValueFromElement($key, $value, $cmd, $opt); |
228 | 228 | else |
229 | 229 | $value = $this->getValueFromPreset($key, $value, $cmd, $opt); |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | return $value; |
234 | 234 | } |
235 | 235 | |
236 | - public function isEmpty($cmd,$value) |
|
236 | + public function isEmpty($cmd, $value) |
|
237 | 237 | { |
238 | - if($value!=='') return false; |
|
238 | + if ($value !== '') return false; |
|
239 | 239 | |
240 | - $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
|
241 | - if(in_array($cmd,$_)) return false; |
|
240 | + $_ = explode(',', $this->condModifiers.',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
|
241 | + if (in_array($cmd, $_)) return false; |
|
242 | 242 | else return true; |
243 | 243 | } |
244 | 244 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | { |
247 | 247 | global $modx; |
248 | 248 | |
249 | - if($this->isEmpty($cmd,$value)) return ''; |
|
249 | + if ($this->isEmpty($cmd, $value)) return ''; |
|
250 | 250 | |
251 | 251 | $this->key = $key; |
252 | 252 | $this->value = $value; |
@@ -257,83 +257,83 @@ discard block |
||
257 | 257 | ##### Conditional Modifiers |
258 | 258 | case 'input': |
259 | 259 | case 'if': |
260 | - if(!$opt) return $value; |
|
260 | + if (!$opt) return $value; |
|
261 | 261 | return $opt; |
262 | 262 | case '=': |
263 | 263 | case 'eq': |
264 | 264 | case 'is': |
265 | 265 | case 'equals': |
266 | - $this->condition[] = (int)($value == $opt); break; |
|
266 | + $this->condition[] = (int) ($value == $opt); break; |
|
267 | 267 | case 'neq': |
268 | 268 | case 'ne': |
269 | 269 | case 'notequals': |
270 | 270 | case 'isnot': |
271 | 271 | case 'isnt': |
272 | 272 | case 'not': |
273 | - $this->condition[] = (int)($value != $opt);break; |
|
273 | + $this->condition[] = (int) ($value != $opt); break; |
|
274 | 274 | case '%': |
275 | - $this->condition[] = (int)($value%$opt==0);break; |
|
275 | + $this->condition[] = (int) ($value % $opt == 0); break; |
|
276 | 276 | case 'isempty': |
277 | - $this->condition[] = (int)(empty($value)); break; |
|
277 | + $this->condition[] = (int) (empty($value)); break; |
|
278 | 278 | case 'isntempty': |
279 | 279 | case 'isnotempty': |
280 | - $this->condition[] = (int)(!empty($value)); break; |
|
280 | + $this->condition[] = (int) (!empty($value)); break; |
|
281 | 281 | case '>=': |
282 | 282 | case 'gte': |
283 | 283 | case 'eg': |
284 | 284 | case 'isgte': |
285 | - $this->condition[] = (int)($value >= $opt);break; |
|
285 | + $this->condition[] = (int) ($value >= $opt); break; |
|
286 | 286 | case '<=': |
287 | 287 | case 'lte': |
288 | 288 | case 'el': |
289 | 289 | case 'islte': |
290 | - $this->condition[] = (int)($value <= $opt);break; |
|
290 | + $this->condition[] = (int) ($value <= $opt); break; |
|
291 | 291 | case '>': |
292 | 292 | case 'gt': |
293 | 293 | case 'greaterthan': |
294 | 294 | case 'isgreaterthan': |
295 | 295 | case 'isgt': |
296 | - $this->condition[] = (int)($value > $opt);break; |
|
296 | + $this->condition[] = (int) ($value > $opt); break; |
|
297 | 297 | case '<': |
298 | 298 | case 'lt': |
299 | 299 | case 'lowerthan': |
300 | 300 | case 'islowerthan': |
301 | 301 | case 'islt': |
302 | - $this->condition[] = (int)($value < $opt);break; |
|
302 | + $this->condition[] = (int) ($value < $opt); break; |
|
303 | 303 | case 'find': |
304 | - $this->condition[] = (int)(strpos($value, $opt)!==false);break; |
|
304 | + $this->condition[] = (int) (strpos($value, $opt) !== false); break; |
|
305 | 305 | case 'inarray': |
306 | 306 | case 'in_array': |
307 | 307 | case 'in': |
308 | 308 | $opt = explode(',', $opt); |
309 | - $this->condition[] = (int)(in_array($value, $opt)!==false);break; |
|
309 | + $this->condition[] = (int) (in_array($value, $opt) !== false); break; |
|
310 | 310 | case 'wildcard_match': |
311 | 311 | case 'wcard_match': |
312 | 312 | case 'wildcard': |
313 | 313 | case 'wcard': |
314 | 314 | case 'fnmatch': |
315 | - $this->condition[] = (int)(fnmatch($opt, $value)!==false);break; |
|
315 | + $this->condition[] = (int) (fnmatch($opt, $value) !== false); break; |
|
316 | 316 | case 'is_file': |
317 | 317 | case 'is_dir': |
318 | 318 | case 'file_exists': |
319 | 319 | case 'is_readable': |
320 | 320 | case 'is_writable': |
321 | - if(!$opt) $path = $value; |
|
321 | + if (!$opt) $path = $value; |
|
322 | 322 | else $path = $opt; |
323 | - if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path'); |
|
324 | - if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/'); |
|
325 | - $this->condition[] = (int)($cmd($path)!==false);break; |
|
323 | + if (strpos($path, MODX_MANAGER_PATH) !== false) exit('Can not read core path'); |
|
324 | + if (strpos($path, $modx->config['base_path']) === false) $path = ltrim($path, '/'); |
|
325 | + $this->condition[] = (int) ($cmd($path) !== false); break; |
|
326 | 326 | case 'is_image': |
327 | - if(!$opt) $path = $value; |
|
327 | + if (!$opt) $path = $value; |
|
328 | 328 | else $path = $opt; |
329 | - if(!is_file($path)) {$this->condition[]='0';break;} |
|
329 | + if (!is_file($path)) {$this->condition[] = '0'; break; } |
|
330 | 330 | $_ = getimagesize($path); |
331 | - $this->condition[] = (int)($_[0]);break; |
|
331 | + $this->condition[] = (int) ($_[0]); break; |
|
332 | 332 | case 'regex': |
333 | 333 | case 'preg': |
334 | 334 | case 'preg_match': |
335 | 335 | case 'isinrole': |
336 | - $this->condition[] = (int)(preg_match($opt,$value));break; |
|
336 | + $this->condition[] = (int) (preg_match($opt, $value)); break; |
|
337 | 337 | case 'ir': |
338 | 338 | case 'memberof': |
339 | 339 | case 'mo': |
@@ -341,50 +341,50 @@ discard block |
||
341 | 341 | $this->condition[] = $this->includeMdfFile('memberof'); |
342 | 342 | break; |
343 | 343 | case 'or': |
344 | - $this->condition[] = '||';break; |
|
344 | + $this->condition[] = '||'; break; |
|
345 | 345 | case 'and': |
346 | - $this->condition[] = '&&';break; |
|
346 | + $this->condition[] = '&&'; break; |
|
347 | 347 | case 'show': |
348 | 348 | case 'this': |
349 | - $conditional = implode(' ',$this->condition); |
|
350 | - $isvalid = (int)(eval("return ({$conditional});")); |
|
349 | + $conditional = implode(' ', $this->condition); |
|
350 | + $isvalid = (int) (eval("return ({$conditional});")); |
|
351 | 351 | if ($isvalid) return $this->srcValue; |
352 | 352 | return NULL; |
353 | 353 | case 'then': |
354 | - $conditional = implode(' ',$this->condition); |
|
355 | - $isvalid = (int)eval("return ({$conditional});"); |
|
354 | + $conditional = implode(' ', $this->condition); |
|
355 | + $isvalid = (int) eval("return ({$conditional});"); |
|
356 | 356 | if ($isvalid) return $opt; |
357 | 357 | return null; |
358 | 358 | case 'else': |
359 | - $conditional = implode(' ',$this->condition); |
|
360 | - $isvalid = (int)eval("return ({$conditional});"); |
|
359 | + $conditional = implode(' ', $this->condition); |
|
360 | + $isvalid = (int) eval("return ({$conditional});"); |
|
361 | 361 | if (!$isvalid) return $opt; |
362 | 362 | break; |
363 | 363 | case 'select': |
364 | 364 | case 'switch': |
365 | - $raw = explode('&',$opt); |
|
365 | + $raw = explode('&', $opt); |
|
366 | 366 | $map = array(); |
367 | 367 | $c = count($raw); |
368 | - for($m=0; $m<$c; $m++) { |
|
369 | - $mi = explode('=',$raw[$m],2); |
|
368 | + for ($m = 0; $m < $c; $m++) { |
|
369 | + $mi = explode('=', $raw[$m], 2); |
|
370 | 370 | $map[$mi[0]] = $mi[1]; |
371 | 371 | } |
372 | - if(isset($map[$value])) return $map[$value]; |
|
372 | + if (isset($map[$value])) return $map[$value]; |
|
373 | 373 | else return ''; |
374 | 374 | ##### End of Conditional Modifiers |
375 | 375 | |
376 | 376 | ##### Encode / Decode / Hash / Escape |
377 | 377 | case 'htmlent': |
378 | 378 | case 'htmlentities': |
379 | - return htmlentities($value,ENT_QUOTES,$modx->config['modx_charset']); |
|
379 | + return htmlentities($value, ENT_QUOTES, $modx->config['modx_charset']); |
|
380 | 380 | case 'html_entity_decode': |
381 | 381 | case 'decode_html': |
382 | 382 | case 'html_decode': |
383 | - return html_entity_decode($value,ENT_QUOTES,$modx->config['modx_charset']); |
|
383 | + return html_entity_decode($value, ENT_QUOTES, $modx->config['modx_charset']); |
|
384 | 384 | case 'esc': |
385 | 385 | case 'escape': |
386 | 386 | $value = preg_replace('/&(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset'])); |
387 | - return str_replace(array('[', ']', '`'),array('[', ']', '`'),$value); |
|
387 | + return str_replace(array('[', ']', '`'), array('[', ']', '`'), $value); |
|
388 | 388 | case 'sql_escape': |
389 | 389 | case 'encode_js': |
390 | 390 | return $modx->db->escape($value); |
@@ -394,39 +394,39 @@ discard block |
||
394 | 394 | case 'html_encode': |
395 | 395 | return preg_replace('/&(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset'])); |
396 | 396 | case 'spam_protect': |
397 | - return str_replace(array('@','.'),array('@','.'),$value); |
|
397 | + return str_replace(array('@', '.'), array('@', '.'), $value); |
|
398 | 398 | case 'strip': |
399 | - if($opt==='') $opt = ' '; |
|
399 | + if ($opt === '') $opt = ' '; |
|
400 | 400 | return preg_replace('/[\n\r\t\s]+/', $opt, $value); |
401 | 401 | case 'strip_linefeeds': |
402 | - return str_replace(array("\n","\r"), '', $value); |
|
402 | + return str_replace(array("\n", "\r"), '', $value); |
|
403 | 403 | case 'notags': |
404 | 404 | case 'strip_tags': |
405 | 405 | case 'remove_html': |
406 | - if($opt!=='') |
|
406 | + if ($opt !== '') |
|
407 | 407 | { |
408 | 408 | $param = array(); |
409 | - foreach(explode(',',$opt) as $v) |
|
409 | + foreach (explode(',', $opt) as $v) |
|
410 | 410 | { |
411 | - $v = trim($v,'</> '); |
|
411 | + $v = trim($v, '</> '); |
|
412 | 412 | $param[] = "<{$v}>"; |
413 | 413 | } |
414 | - $params = implode(',',$param); |
|
414 | + $params = implode(',', $param); |
|
415 | 415 | } |
416 | 416 | else $params = ''; |
417 | - if(!strpos($params,'<br>')===false) { |
|
418 | - $value = preg_replace('@(<br[ /]*>)\n@','$1',$value); |
|
419 | - $value = preg_replace('@<br[ /]*>@',"\n",$value); |
|
417 | + if (!strpos($params, '<br>') === false) { |
|
418 | + $value = preg_replace('@(<br[ /]*>)\n@', '$1', $value); |
|
419 | + $value = preg_replace('@<br[ /]*>@', "\n", $value); |
|
420 | 420 | } |
421 | - return $this->strip_tags($value,$params); |
|
421 | + return $this->strip_tags($value, $params); |
|
422 | 422 | case 'urlencode': |
423 | 423 | case 'url_encode': |
424 | 424 | case 'encode_url': |
425 | 425 | return urlencode($value); |
426 | 426 | case 'base64_decode': |
427 | - if($opt!=='false') $opt = true; |
|
427 | + if ($opt !== 'false') $opt = true; |
|
428 | 428 | else $opt = false; |
429 | - return base64_decode($value,$opt); |
|
429 | + return base64_decode($value, $opt); |
|
430 | 430 | case 'encode_sha1': $cmd = 'sha1'; |
431 | 431 | case 'addslashes': |
432 | 432 | case 'urldecode': |
@@ -450,18 +450,18 @@ discard block |
||
450 | 450 | case 'upper_case': |
451 | 451 | return $this->strtoupper($value); |
452 | 452 | case 'capitalize': |
453 | - $_ = explode(' ',$value); |
|
454 | - foreach($_ as $i=>$v) |
|
453 | + $_ = explode(' ', $value); |
|
454 | + foreach ($_ as $i=>$v) |
|
455 | 455 | { |
456 | 456 | $_[$i] = ucfirst($v); |
457 | 457 | } |
458 | - return implode(' ',$_); |
|
458 | + return implode(' ', $_); |
|
459 | 459 | case 'zenhan': |
460 | - if(empty($opt)) $opt='VKas'; |
|
461 | - return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
|
460 | + if (empty($opt)) $opt = 'VKas'; |
|
461 | + return mb_convert_kana($value, $opt, $modx->config['modx_charset']); |
|
462 | 462 | case 'hanzen': |
463 | - if(empty($opt)) $opt='VKAS'; |
|
464 | - return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
|
463 | + if (empty($opt)) $opt = 'VKAS'; |
|
464 | + return mb_convert_kana($value, $opt, $modx->config['modx_charset']); |
|
465 | 465 | case 'str_shuffle': |
466 | 466 | case 'shuffle': |
467 | 467 | return $this->str_shuffle($value); |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | return $this->strlen($value); |
476 | 476 | case 'count_words': |
477 | 477 | $value = trim($value); |
478 | - return count(preg_split('/\s+/',$value)); |
|
478 | + return count(preg_split('/\s+/', $value)); |
|
479 | 479 | case 'str_word_count': |
480 | 480 | case 'word_count': |
481 | 481 | case 'wordcount': |
@@ -483,55 +483,55 @@ discard block |
||
483 | 483 | case 'count_paragraphs': |
484 | 484 | $value = trim($value); |
485 | 485 | $value = preg_replace('/\r/', '', $value); |
486 | - return count(preg_split('/\n+/',$value)); |
|
486 | + return count(preg_split('/\n+/', $value)); |
|
487 | 487 | case 'strpos': |
488 | - if($opt!=0&&empty($opt)) return $value; |
|
489 | - return $this->strpos($value,$opt); |
|
488 | + if ($opt != 0 && empty($opt)) return $value; |
|
489 | + return $this->strpos($value, $opt); |
|
490 | 490 | case 'wordwrap': |
491 | 491 | // default: 70 |
492 | - $wrapat = (int)$opt > 0 ? (int)$opt : 70; |
|
492 | + $wrapat = (int) $opt > 0 ? (int) $opt : 70; |
|
493 | 493 | if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap'); |
494 | - else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value); |
|
494 | + else return preg_replace("@(\b\w+\b)@e", "wordwrap('\\1',\$wrapat,' ',1)", $value); |
|
495 | 495 | case 'wrap_text': |
496 | - $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70; |
|
497 | - if($modx->config['manager_language']==='japanese-utf8') { |
|
496 | + $width = preg_match('/^[1-9][0-9]*$/', $opt) ? $opt : 70; |
|
497 | + if ($modx->config['manager_language'] === 'japanese-utf8') { |
|
498 | 498 | $chunk = array(); |
499 | - $bt=''; |
|
500 | - while($bt!=$value) { |
|
499 | + $bt = ''; |
|
500 | + while ($bt != $value) { |
|
501 | 501 | $bt = $value; |
502 | - if($this->strlen($value)<$width) { |
|
502 | + if ($this->strlen($value) < $width) { |
|
503 | 503 | $chunk[] = $value; |
504 | 504 | break; |
505 | 505 | } |
506 | - $chunk[] = $this->substr($value,0,$width); |
|
507 | - $value = $this->substr($value,$width); |
|
506 | + $chunk[] = $this->substr($value, 0, $width); |
|
507 | + $value = $this->substr($value, $width); |
|
508 | 508 | } |
509 | - return implode("\n",$chunk); |
|
509 | + return implode("\n", $chunk); |
|
510 | 510 | } |
511 | 511 | else |
512 | - return wordwrap($value,$width,"\n",true); |
|
512 | + return wordwrap($value, $width, "\n", true); |
|
513 | 513 | case 'substr': |
514 | - if(empty($opt)) break; |
|
515 | - if(strpos($opt,',')!==false) { |
|
516 | - list($b,$e) = explode(',',$opt,2); |
|
517 | - return $this->substr($value,$b,(int)$e); |
|
514 | + if (empty($opt)) break; |
|
515 | + if (strpos($opt, ',') !== false) { |
|
516 | + list($b, $e) = explode(',', $opt, 2); |
|
517 | + return $this->substr($value, $b, (int) $e); |
|
518 | 518 | } |
519 | - else return $this->substr($value,$opt); |
|
519 | + else return $this->substr($value, $opt); |
|
520 | 520 | case 'limit': |
521 | 521 | case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html |
522 | - if(strpos($opt,'+')!==false) |
|
523 | - list($len,$str) = explode('+',$opt,2); |
|
522 | + if (strpos($opt, '+') !== false) |
|
523 | + list($len, $str) = explode('+', $opt, 2); |
|
524 | 524 | else { |
525 | 525 | $len = $opt; |
526 | 526 | $str = ''; |
527 | 527 | } |
528 | - if($len==='') $len = 100; |
|
529 | - if(abs($len) > $this->strlen($value)) $str =''; |
|
530 | - if(preg_match('/^[1-9][0-9]*$/',$len)) { |
|
531 | - return $this->substr($value,0,$len) . $str; |
|
528 | + if ($len === '') $len = 100; |
|
529 | + if (abs($len) > $this->strlen($value)) $str = ''; |
|
530 | + if (preg_match('/^[1-9][0-9]*$/', $len)) { |
|
531 | + return $this->substr($value, 0, $len).$str; |
|
532 | 532 | } |
533 | - elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { |
|
534 | - return $str . $this->substr($value,$len); |
|
533 | + elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) { |
|
534 | + return $str.$this->substr($value, $len); |
|
535 | 535 | } |
536 | 536 | break; |
537 | 537 | case 'summary': |
@@ -540,81 +540,81 @@ discard block |
||
540 | 540 | return $this->includeMdfFile('summary'); |
541 | 541 | case 'replace': |
542 | 542 | case 'str_replace': |
543 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
544 | - if (substr_count($opt, ',') ==1) $delim = ','; |
|
545 | - elseif(substr_count($opt, '|') ==1) $delim = '|'; |
|
546 | - elseif(substr_count($opt, '=>')==1) $delim = '=>'; |
|
547 | - elseif(substr_count($opt, '/') ==1) $delim = '/'; |
|
543 | + if (empty($opt) || strpos($opt, ',') === false) break; |
|
544 | + if (substr_count($opt, ',') == 1) $delim = ','; |
|
545 | + elseif (substr_count($opt, '|') == 1) $delim = '|'; |
|
546 | + elseif (substr_count($opt, '=>') == 1) $delim = '=>'; |
|
547 | + elseif (substr_count($opt, '/') == 1) $delim = '/'; |
|
548 | 548 | else break; |
549 | - list($s,$r) = explode($delim,$opt); |
|
550 | - if($value!=='') return str_replace($s,$r,$value); |
|
549 | + list($s, $r) = explode($delim, $opt); |
|
550 | + if ($value !== '') return str_replace($s, $r, $value); |
|
551 | 551 | break; |
552 | 552 | case 'replace_to': |
553 | 553 | case 'tpl': |
554 | - if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); |
|
554 | + if ($value !== '') return str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $value, $opt); |
|
555 | 555 | break; |
556 | 556 | case 'eachtpl': |
557 | - $value = explode('||',$value); |
|
557 | + $value = explode('||', $value); |
|
558 | 558 | $_ = array(); |
559 | - foreach($value as $v) { |
|
560 | - $_[] = str_replace(array('[+value+]','[+output+]','{value}','%s'),$v,$opt); |
|
559 | + foreach ($value as $v) { |
|
560 | + $_[] = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $v, $opt); |
|
561 | 561 | } |
562 | 562 | return implode("\n", $_); |
563 | 563 | case 'array_pop': |
564 | 564 | case 'array_shift': |
565 | - if(strpos($value,'||')!==false) $delim = '||'; |
|
565 | + if (strpos($value, '||') !== false) $delim = '||'; |
|
566 | 566 | else $delim = ','; |
567 | - return $cmd(explode($delim,$value)); |
|
567 | + return $cmd(explode($delim, $value)); |
|
568 | 568 | case 'preg_replace': |
569 | 569 | case 'regex_replace': |
570 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
571 | - list($s,$r) = explode(',',$opt,2); |
|
572 | - if($value!=='') return preg_replace($s,$r,$value); |
|
570 | + if (empty($opt) || strpos($opt, ',') === false) break; |
|
571 | + list($s, $r) = explode(',', $opt, 2); |
|
572 | + if ($value !== '') return preg_replace($s, $r, $value); |
|
573 | 573 | break; |
574 | 574 | case 'cat': |
575 | 575 | case 'concatenate': |
576 | 576 | case '.': |
577 | - if($value!=='') return $value . $opt; |
|
577 | + if ($value !== '') return $value.$opt; |
|
578 | 578 | break; |
579 | 579 | case 'sprintf': |
580 | 580 | case 'string_format': |
581 | - if($value!=='') return sprintf($opt,$value); |
|
581 | + if ($value !== '') return sprintf($opt, $value); |
|
582 | 582 | break; |
583 | 583 | case 'number_format': |
584 | - if($opt=='') $opt = 0; |
|
585 | - return number_format($value,$opt); |
|
584 | + if ($opt == '') $opt = 0; |
|
585 | + return number_format($value, $opt); |
|
586 | 586 | case 'money_format': |
587 | - setlocale(LC_MONETARY,setlocale(LC_TIME,0)); |
|
588 | - if($value!=='') return money_format($opt,(double)$value); |
|
587 | + setlocale(LC_MONETARY, setlocale(LC_TIME, 0)); |
|
588 | + if ($value !== '') return money_format($opt, (double) $value); |
|
589 | 589 | break; |
590 | 590 | case 'tobool': |
591 | 591 | return boolval($value); |
592 | 592 | case 'nl2lf': |
593 | - if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value); |
|
593 | + if ($value !== '') return str_replace(array("\r\n", "\n", "\r"), '\n', $value); |
|
594 | 594 | break; |
595 | 595 | case 'br2nl': |
596 | 596 | return preg_replace('@<br[\s/]*>@i', "\n", $value); |
597 | 597 | case 'nl2br': |
598 | 598 | if (version_compare(PHP_VERSION, '5.3.0', '<')) |
599 | 599 | return nl2br($value); |
600 | - if($opt!=='') |
|
600 | + if ($opt !== '') |
|
601 | 601 | { |
602 | 602 | $opt = trim($opt); |
603 | 603 | $opt = strtolower($opt); |
604 | - if($opt==='false') $opt = false; |
|
605 | - elseif($opt==='0') $opt = false; |
|
604 | + if ($opt === 'false') $opt = false; |
|
605 | + elseif ($opt === '0') $opt = false; |
|
606 | 606 | else $opt = true; |
607 | 607 | } |
608 | - elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') |
|
608 | + elseif (isset($modx->config['mce_element_format']) && $modx->config['mce_element_format'] === 'html') |
|
609 | 609 | $opt = false; |
610 | 610 | else $opt = true; |
611 | - return nl2br($value,$opt); |
|
611 | + return nl2br($value, $opt); |
|
612 | 612 | case 'ltrim': |
613 | 613 | case 'rtrim': |
614 | 614 | case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html |
615 | - if($opt==='') |
|
615 | + if ($opt === '') |
|
616 | 616 | return $cmd($value); |
617 | - else return $cmd($value,$opt); |
|
617 | + else return $cmd($value, $opt); |
|
618 | 618 | // These are all straight wrappers for PHP functions |
619 | 619 | case 'ucfirst': |
620 | 620 | case 'lcfirst': |
@@ -625,58 +625,58 @@ discard block |
||
625 | 625 | case 'strftime': |
626 | 626 | case 'date': |
627 | 627 | case 'dateformat': |
628 | - if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
629 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
630 | - if(strpos($opt,'%')!==false) |
|
631 | - return strftime($opt,0+$value); |
|
628 | + if (empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
629 | + if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value); |
|
630 | + if (strpos($opt, '%') !== false) |
|
631 | + return strftime($opt, 0 + $value); |
|
632 | 632 | else |
633 | - return date($opt,0+$value); |
|
633 | + return date($opt, 0 + $value); |
|
634 | 634 | case 'time': |
635 | - if(empty($opt)) $opt = '%H:%M'; |
|
636 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
637 | - return strftime($opt,0+$value); |
|
635 | + if (empty($opt)) $opt = '%H:%M'; |
|
636 | + if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value); |
|
637 | + return strftime($opt, 0 + $value); |
|
638 | 638 | case 'strtotime': |
639 | 639 | return strtotime($value); |
640 | 640 | ##### mathematical function |
641 | 641 | case 'toint': |
642 | - return (int)$value; |
|
642 | + return (int) $value; |
|
643 | 643 | case 'tofloat': |
644 | 644 | return floatval($value); |
645 | 645 | case 'round': |
646 | - if(!$opt) $opt = 0; |
|
647 | - return $cmd($value,$opt); |
|
646 | + if (!$opt) $opt = 0; |
|
647 | + return $cmd($value, $opt); |
|
648 | 648 | case 'max': |
649 | 649 | case 'min': |
650 | - return $cmd(explode(',',$value)); |
|
650 | + return $cmd(explode(',', $value)); |
|
651 | 651 | case 'floor': |
652 | 652 | case 'ceil': |
653 | 653 | case 'abs': |
654 | 654 | return $cmd($value); |
655 | 655 | case 'math': |
656 | 656 | case 'calc': |
657 | - $value = (int)$value; |
|
658 | - if(empty($value)) $value = '0'; |
|
659 | - $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt); |
|
660 | - $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter); |
|
661 | - if(strpos($filter,'?')===false) $filter = "?{$filter}"; |
|
662 | - $filter = str_replace('?',$value,$filter); |
|
657 | + $value = (int) $value; |
|
658 | + if (empty($value)) $value = '0'; |
|
659 | + $filter = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), '?', $opt); |
|
660 | + $filter = preg_replace('@([a-zA-Z\n\r\t\s])@', '', $filter); |
|
661 | + if (strpos($filter, '?') === false) $filter = "?{$filter}"; |
|
662 | + $filter = str_replace('?', $value, $filter); |
|
663 | 663 | return eval("return {$filter};"); |
664 | 664 | case 'count': |
665 | - if($value=='') return 0; |
|
666 | - $value = explode(',',$value); |
|
665 | + if ($value == '') return 0; |
|
666 | + $value = explode(',', $value); |
|
667 | 667 | return count($value); |
668 | 668 | case 'sort': |
669 | 669 | case 'rsort': |
670 | - if(strpos($value,"\n")!==false) $delim="\n"; |
|
670 | + if (strpos($value, "\n") !== false) $delim = "\n"; |
|
671 | 671 | else $delim = ','; |
672 | - $swap = explode($delim,$value); |
|
673 | - if(!$opt) $opt = SORT_REGULAR; |
|
672 | + $swap = explode($delim, $value); |
|
673 | + if (!$opt) $opt = SORT_REGULAR; |
|
674 | 674 | else $opt = constant($opt); |
675 | - $cmd($swap,$opt); |
|
676 | - return implode($delim,$swap); |
|
675 | + $cmd($swap, $opt); |
|
676 | + return implode($delim, $swap); |
|
677 | 677 | ##### Resource fields |
678 | 678 | case 'id': |
679 | - if($opt) return $this->getDocumentObject($opt,$key); |
|
679 | + if ($opt) return $this->getDocumentObject($opt, $key); |
|
680 | 680 | break; |
681 | 681 | case 'type': |
682 | 682 | case 'contenttype': |
@@ -713,36 +713,36 @@ discard block |
||
713 | 713 | case 'privatemgr': |
714 | 714 | case 'content_dispo': |
715 | 715 | case 'hidemenu': |
716 | - if($cmd==='contenttype') $cmd = 'contentType'; |
|
717 | - return $this->getDocumentObject($value,$cmd); |
|
716 | + if ($cmd === 'contenttype') $cmd = 'contentType'; |
|
717 | + return $this->getDocumentObject($value, $cmd); |
|
718 | 718 | case 'title': |
719 | - $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
|
720 | - $longtitle = $this->getDocumentObject($value,'longtitle'); |
|
719 | + $pagetitle = $this->getDocumentObject($value, 'pagetitle'); |
|
720 | + $longtitle = $this->getDocumentObject($value, 'longtitle'); |
|
721 | 721 | return $longtitle ? $longtitle : $pagetitle; |
722 | 722 | case 'shorttitle': |
723 | - $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
|
724 | - $menutitle = $this->getDocumentObject($value,'menutitle'); |
|
723 | + $pagetitle = $this->getDocumentObject($value, 'pagetitle'); |
|
724 | + $menutitle = $this->getDocumentObject($value, 'menutitle'); |
|
725 | 725 | return $menutitle ? $menutitle : $pagetitle; |
726 | 726 | case 'templatename': |
727 | - $rs = $modx->db->select('templatename','[+prefix+]site_templates',"id='{$value}'"); |
|
727 | + $rs = $modx->db->select('templatename', '[+prefix+]site_templates', "id='{$value}'"); |
|
728 | 728 | $templateName = $modx->db->getValue($rs); |
729 | 729 | return !$templateName ? '(blank)' : $templateName; |
730 | 730 | case 'getfield': |
731 | - if(!$opt) $opt = 'content'; |
|
732 | - return $modx->getField($opt,$value); |
|
731 | + if (!$opt) $opt = 'content'; |
|
732 | + return $modx->getField($opt, $value); |
|
733 | 733 | case 'children': |
734 | 734 | case 'childids': |
735 | - if($value=='') $value = 0; // 値がない場合はルートと見なす |
|
735 | + if ($value == '') $value = 0; // 値がない場合はルートと見なす |
|
736 | 736 | $published = 1; |
737 | - if($opt=='') $opt = 'page'; |
|
738 | - $_ = explode(',',$opt); |
|
737 | + if ($opt == '') $opt = 'page'; |
|
738 | + $_ = explode(',', $opt); |
|
739 | 739 | $where = array(); |
740 | - foreach($_ as $opt) { |
|
741 | - switch(trim($opt)) { |
|
740 | + foreach ($_ as $opt) { |
|
741 | + switch (trim($opt)) { |
|
742 | 742 | case 'page'; case '!folder'; case '!isfolder': $where[] = 'sc.isfolder=0'; break; |
743 | 743 | case 'folder'; case 'isfolder': $where[] = 'sc.isfolder=1'; break; |
744 | - case 'menu'; case 'show_menu': $where[] = 'sc.hidemenu=0'; break; |
|
745 | - case '!menu'; case '!show_menu': $where[] = 'sc.hidemenu=1'; break; |
|
744 | + case 'menu'; case 'show_menu': $where[] = 'sc.hidemenu=0'; break; |
|
745 | + case '!menu'; case '!show_menu': $where[] = 'sc.hidemenu=1'; break; |
|
746 | 746 | case 'published': $published = 1; break; |
747 | 747 | case '!published': $published = 0; break; |
748 | 748 | } |
@@ -750,69 +750,69 @@ discard block |
||
750 | 750 | $where = implode(' AND ', $where); |
751 | 751 | $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where); |
752 | 752 | $result = array(); |
753 | - foreach((array)$children as $child){ |
|
753 | + foreach ((array) $children as $child) { |
|
754 | 754 | $result[] = $child['id']; |
755 | 755 | } |
756 | 756 | return implode(',', $result); |
757 | 757 | case 'fullurl': |
758 | - if(!is_numeric($value)) return $value; |
|
758 | + if (!is_numeric($value)) return $value; |
|
759 | 759 | return $modx->makeUrl($value); |
760 | 760 | case 'makeurl': |
761 | - if(!is_numeric($value)) return $value; |
|
762 | - if(!$opt) $opt = 'full'; |
|
763 | - return $modx->makeUrl($value,'','',$opt); |
|
761 | + if (!is_numeric($value)) return $value; |
|
762 | + if (!$opt) $opt = 'full'; |
|
763 | + return $modx->makeUrl($value, '', '', $opt); |
|
764 | 764 | |
765 | 765 | ##### File system |
766 | 766 | case 'getimageinfo': |
767 | 767 | case 'imageinfo': |
768 | - if(!is_file($value)) return ''; |
|
768 | + if (!is_file($value)) return ''; |
|
769 | 769 | $_ = getimagesize($value); |
770 | - if(!$_[0]) return ''; |
|
770 | + if (!$_[0]) return ''; |
|
771 | 771 | $info['width'] = $_[0]; |
772 | 772 | $info['height'] = $_[1]; |
773 | - if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
774 | - elseif($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
773 | + if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
774 | + elseif ($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
775 | 775 | else $info['aspect'] = 'square'; |
776 | - switch($_[2]) { |
|
776 | + switch ($_[2]) { |
|
777 | 777 | case IMAGETYPE_GIF : $info['type'] = 'gif'; break; |
778 | 778 | case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break; |
779 | 779 | case IMAGETYPE_PNG : $info['type'] = 'png'; break; |
780 | 780 | default : $info['type'] = 'unknown'; |
781 | 781 | } |
782 | 782 | $info['attrib'] = $_[3]; |
783 | - switch($opt) { |
|
783 | + switch ($opt) { |
|
784 | 784 | case 'width' : return $info['width']; |
785 | 785 | case 'height': return $info['height']; |
786 | 786 | case 'aspect': return $info['aspect']; |
787 | 787 | case 'type' : return $info['type']; |
788 | 788 | case 'attrib': return $info['attrib']; |
789 | - default : return print_r($info,true); |
|
789 | + default : return print_r($info, true); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | case 'file_get_contents': |
793 | 793 | case 'readfile': |
794 | - if(!is_file($value)) return $value; |
|
794 | + if (!is_file($value)) return $value; |
|
795 | 795 | $value = realpath($value); |
796 | - if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file'); |
|
797 | - $ext = strtolower(substr($value,-4)); |
|
798 | - if($ext==='.php') exit('Can not read php file'); |
|
799 | - if($ext==='.cgi') exit('Can not read cgi file'); |
|
796 | + if (strpos($value, MODX_MANAGER_PATH) !== false) exit('Can not read core file'); |
|
797 | + $ext = strtolower(substr($value, -4)); |
|
798 | + if ($ext === '.php') exit('Can not read php file'); |
|
799 | + if ($ext === '.cgi') exit('Can not read cgi file'); |
|
800 | 800 | return file_get_contents($value); |
801 | 801 | case 'filesize': |
802 | - if($value == '') return ''; |
|
802 | + if ($value == '') return ''; |
|
803 | 803 | $filename = $value; |
804 | 804 | |
805 | 805 | $site_url = $modx->config['site_url']; |
806 | - if(strpos($filename,$site_url) === 0) |
|
807 | - $filename = substr($filename,0,strlen($site_url)); |
|
808 | - $filename = trim($filename,'/'); |
|
806 | + if (strpos($filename, $site_url) === 0) |
|
807 | + $filename = substr($filename, 0, strlen($site_url)); |
|
808 | + $filename = trim($filename, '/'); |
|
809 | 809 | |
810 | - $opt = trim($opt,'/'); |
|
811 | - if($opt!=='') $opt .= '/'; |
|
810 | + $opt = trim($opt, '/'); |
|
811 | + if ($opt !== '') $opt .= '/'; |
|
812 | 812 | |
813 | 813 | $filename = MODX_BASE_PATH.$opt.$filename; |
814 | 814 | |
815 | - if(is_file($filename)){ |
|
815 | + if (is_file($filename)) { |
|
816 | 816 | clearstatcache(); |
817 | 817 | $size = filesize($filename); |
818 | 818 | return $size; |
@@ -845,10 +845,10 @@ discard block |
||
845 | 845 | $this->opt = $cmd; |
846 | 846 | return $this->includeMdfFile('moduser'); |
847 | 847 | case 'userinfo': |
848 | - if(empty($opt)) $this->opt = 'username'; |
|
848 | + if (empty($opt)) $this->opt = 'username'; |
|
849 | 849 | return $this->includeMdfFile('moduser'); |
850 | 850 | case 'webuserinfo': |
851 | - if(empty($opt)) $this->opt = 'username'; |
|
851 | + if (empty($opt)) $this->opt = 'username'; |
|
852 | 852 | $this->value = -$value; |
853 | 853 | return $this->includeMdfFile('moduser'); |
854 | 854 | ##### Special functions |
@@ -859,27 +859,27 @@ discard block |
||
859 | 859 | case 'ifnotempty': |
860 | 860 | if (!empty($value)) return $opt; break; |
861 | 861 | case 'datagrid': |
862 | - include_once(MODX_CORE_PATH . 'controls/datagrid.class.php'); |
|
862 | + include_once(MODX_CORE_PATH.'controls/datagrid.class.php'); |
|
863 | 863 | $grd = new DataGrid(null, trim($value)); |
864 | 864 | $grd->itemStyle = ''; |
865 | 865 | $grd->altItemStyle = ''; |
866 | - $pos = strpos($value,"\n"); |
|
867 | - if($pos) $_ = substr($value,0,$pos); |
|
866 | + $pos = strpos($value, "\n"); |
|
867 | + if ($pos) $_ = substr($value, 0, $pos); |
|
868 | 868 | else $_ = $pos; |
869 | - $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ','; |
|
869 | + $grd->cdelim = strpos($_, "\t") !== false ? 'tab' : ','; |
|
870 | 870 | return $grd->render(); |
871 | 871 | case 'rotate': |
872 | 872 | case 'evenodd': |
873 | - if(strpos($opt,',')===false) $opt = 'odd,even'; |
|
873 | + if (strpos($opt, ',') === false) $opt = 'odd,even'; |
|
874 | 874 | $_ = explode(',', $opt); |
875 | 875 | $c = count($_); |
876 | 876 | $i = $value + $c; |
877 | 877 | $i = $i % $c; |
878 | 878 | return $_[$i]; |
879 | 879 | case 'takeval': |
880 | - $arr = explode(",",$opt); |
|
880 | + $arr = explode(",", $opt); |
|
881 | 881 | $idx = $value; |
882 | - if(!is_numeric($idx)) return $value; |
|
882 | + if (!is_numeric($idx)) return $value; |
|
883 | 883 | return $arr[$idx]; |
884 | 884 | case 'getimage': |
885 | 885 | return $this->includeMdfFile('getimage'); |
@@ -887,17 +887,17 @@ discard block |
||
887 | 887 | return $modx->nicesize($value); |
888 | 888 | case 'googlemap': |
889 | 889 | case 'googlemaps': |
890 | - if(empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
890 | + if (empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
891 | 891 | $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>'; |
892 | 892 | $ph['style'] = $opt; |
893 | 893 | $ph['value'] = $value; |
894 | - return $modx->parseText($tpl,$ph); |
|
894 | + return $modx->parseText($tpl, $ph); |
|
895 | 895 | case 'youtube': |
896 | 896 | case 'youtube16x9': |
897 | - if(empty($opt)) $opt = 560; |
|
898 | - $h = round($opt*0.5625); |
|
897 | + if (empty($opt)) $opt = 560; |
|
898 | + $h = round($opt * 0.5625); |
|
899 | 899 | $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>'; |
900 | - return sprintf($tpl,$opt,$h,$value); |
|
900 | + return sprintf($tpl, $opt, $h, $value); |
|
901 | 901 | //case 'youtube4x3':%s*0.75+25 |
902 | 902 | case 'setvar': |
903 | 903 | $modx->placeholders[$opt] = $value; |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | return $value; |
928 | 928 | } |
929 | 929 | |
930 | - public function includeMdfFile($cmd) { |
|
930 | + public function includeMdfFile($cmd){ |
|
931 | 931 | global $modx; |
932 | 932 | $key = $this->key; |
933 | 933 | $value = $this->value; |
@@ -938,54 +938,54 @@ discard block |
||
938 | 938 | public function getValueFromElement($key, $value, $cmd, $opt) |
939 | 939 | { |
940 | 940 | global $modx; |
941 | - if( isset($modx->snippetCache[$this->elmName]) ) |
|
941 | + if (isset($modx->snippetCache[$this->elmName])) |
|
942 | 942 | { |
943 | 943 | $php = $modx->snippetCache[$this->elmName]; |
944 | 944 | } |
945 | 945 | else |
946 | 946 | { |
947 | 947 | $esc_elmName = $modx->db->escape($this->elmName); |
948 | - $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'"); |
|
948 | + $result = $modx->db->select('snippet', '[+prefix+]site_snippets', "name='{$esc_elmName}'"); |
|
949 | 949 | $total = $modx->db->getRecordCount($result); |
950 | - if($total == 1) |
|
950 | + if ($total == 1) |
|
951 | 951 | { |
952 | 952 | $row = $modx->db->getRow($result); |
953 | 953 | $php = $row['snippet']; |
954 | 954 | } |
955 | - elseif($total == 0) |
|
955 | + elseif ($total == 0) |
|
956 | 956 | { |
957 | 957 | $assets_path = MODX_BASE_PATH.'assets/'; |
958 | - if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
958 | + if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
959 | 959 | $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; |
960 | - elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
960 | + elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
961 | 961 | $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; |
962 | - elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
962 | + elseif (is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
963 | 963 | $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; |
964 | 964 | else $modifiers_path = false; |
965 | 965 | |
966 | - if($modifiers_path !== false) { |
|
966 | + if ($modifiers_path !== false) { |
|
967 | 967 | $php = @file_get_contents($modifiers_path); |
968 | 968 | $php = trim($php); |
969 | - if(substr($php,0,5)==='<?php') $php = substr($php,6); |
|
970 | - if(substr($php,0,2)==='<?') $php = substr($php,3); |
|
971 | - if(substr($php,-2)==='?>') $php = substr($php,0,-2); |
|
972 | - if($this->elmName!=='') |
|
969 | + if (substr($php, 0, 5) === '<?php') $php = substr($php, 6); |
|
970 | + if (substr($php, 0, 2) === '<?') $php = substr($php, 3); |
|
971 | + if (substr($php, -2) === '?>') $php = substr($php, 0, -2); |
|
972 | + if ($this->elmName !== '') |
|
973 | 973 | $modx->snippetCache[$this->elmName.'Props'] = ''; |
974 | 974 | } |
975 | 975 | else |
976 | 976 | $php = false; |
977 | 977 | } |
978 | 978 | else $php = false; |
979 | - if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php; |
|
979 | + if ($this->elmName !== '') $modx->snippetCache[$this->elmName] = $php; |
|
980 | 980 | } |
981 | - if($php==='') $php=false; |
|
981 | + if ($php === '') $php = false; |
|
982 | 982 | |
983 | - if($php===false) $html = $modx->getChunk($this->elmName); |
|
983 | + if ($php === false) $html = $modx->getChunk($this->elmName); |
|
984 | 984 | else $html = false; |
985 | 985 | |
986 | 986 | $self = '[+output+]'; |
987 | 987 | |
988 | - if($php !== false) |
|
988 | + if ($php !== false) |
|
989 | 989 | { |
990 | 990 | ob_start(); |
991 | 991 | $options = $opt; |
@@ -998,71 +998,71 @@ discard block |
||
998 | 998 | $this->vars['options'] = & $opt; |
999 | 999 | $custom = eval($php); |
1000 | 1000 | $msg = ob_get_contents(); |
1001 | - if($value===$this->bt) $value = $msg . $custom; |
|
1001 | + if ($value === $this->bt) $value = $msg.$custom; |
|
1002 | 1002 | ob_end_clean(); |
1003 | 1003 | } |
1004 | - elseif($html!==false && isset($value) && $value!=='') |
|
1004 | + elseif ($html !== false && isset($value) && $value !== '') |
|
1005 | 1005 | { |
1006 | - $html = str_replace(array($self,'[+value+]'), $value, $html); |
|
1007 | - $value = str_replace(array('[+options+]','[+param+]'), $opt, $html); |
|
1006 | + $html = str_replace(array($self, '[+value+]'), $value, $html); |
|
1007 | + $value = str_replace(array('[+options+]', '[+param+]'), $opt, $html); |
|
1008 | 1008 | } |
1009 | 1009 | else return false; |
1010 | 1010 | |
1011 | - if($php===false && $html===false && $value!=='' |
|
1012 | - && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) |
|
1011 | + if ($php === false && $html === false && $value !== '' |
|
1012 | + && (strpos($cmd, '[+value+]') !== false || strpos($cmd, $self) !== false)) |
|
1013 | 1013 | { |
1014 | - $value = str_replace(array('[+value+]',$self),$value,$cmd); |
|
1014 | + $value = str_replace(array('[+value+]', $self), $value, $cmd); |
|
1015 | 1015 | } |
1016 | 1016 | return $value; |
1017 | 1017 | } |
1018 | 1018 | |
1019 | - public function parseDocumentSource($content='') |
|
1019 | + public function parseDocumentSource($content = '') |
|
1020 | 1020 | { |
1021 | 1021 | global $modx; |
1022 | 1022 | |
1023 | - if(strpos($content,'[')===false && strpos($content,'{')===false) return $content; |
|
1023 | + if (strpos($content, '[') === false && strpos($content, '{') === false) return $content; |
|
1024 | 1024 | |
1025 | - if(!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
1026 | - $bt=''; |
|
1027 | - $i=0; |
|
1028 | - while($bt!==$content) |
|
1025 | + if (!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
1026 | + $bt = ''; |
|
1027 | + $i = 0; |
|
1028 | + while ($bt !== $content) |
|
1029 | 1029 | { |
1030 | 1030 | $bt = $content; |
1031 | - if(strpos($content,'[*')!==false && $modx->documentIdentifier) |
|
1031 | + if (strpos($content, '[*') !== false && $modx->documentIdentifier) |
|
1032 | 1032 | $content = $modx->mergeDocumentContent($content); |
1033 | - if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content); |
|
1034 | - if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content); |
|
1035 | - if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content); |
|
1036 | - if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content); |
|
1033 | + if (strpos($content, '[(') !== false) $content = $modx->mergeSettingsContent($content); |
|
1034 | + if (strpos($content, '{{') !== false) $content = $modx->mergeChunkContent($content); |
|
1035 | + if (strpos($content, '[!') !== false) $content = str_replace(array('[!', '!]'), array('[[', ']]'), $content); |
|
1036 | + if (strpos($content, '[[') !== false) $content = $modx->evalSnippets($content); |
|
1037 | 1037 | |
1038 | - if($content===$bt) break; |
|
1039 | - if($modx->maxParserPasses < $i) break; |
|
1038 | + if ($content === $bt) break; |
|
1039 | + if ($modx->maxParserPasses < $i) break; |
|
1040 | 1040 | $i++; |
1041 | 1041 | } |
1042 | 1042 | return $content; |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - public function getDocumentObject($target='',$field='pagetitle') |
|
1045 | + public function getDocumentObject($target = '', $field = 'pagetitle') |
|
1046 | 1046 | { |
1047 | 1047 | global $modx; |
1048 | 1048 | |
1049 | 1049 | $target = trim($target); |
1050 | - if(empty($target)) $target = $modx->config['site_start']; |
|
1051 | - if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id'; |
|
1050 | + if (empty($target)) $target = $modx->config['site_start']; |
|
1051 | + if (preg_match('@^[1-9][0-9]*$@', $target)) $method = 'id'; |
|
1052 | 1052 | else $method = 'alias'; |
1053 | 1053 | |
1054 | - if(!isset($this->documentObject[$target])) |
|
1054 | + if (!isset($this->documentObject[$target])) |
|
1055 | 1055 | { |
1056 | - $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct'); |
|
1056 | + $this->documentObject[$target] = $modx->getDocumentObject($method, $target, 'direct'); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | - if($this->documentObject[$target]['publishedon']==='0') |
|
1059 | + if ($this->documentObject[$target]['publishedon'] === '0') |
|
1060 | 1060 | return ''; |
1061 | - elseif(isset($this->documentObject[$target][$field])) |
|
1061 | + elseif (isset($this->documentObject[$target][$field])) |
|
1062 | 1062 | { |
1063 | - if(is_array($this->documentObject[$target][$field])) |
|
1063 | + if (is_array($this->documentObject[$target][$field])) |
|
1064 | 1064 | { |
1065 | - $a = $modx->getTemplateVarOutput($field,$target); |
|
1065 | + $a = $modx->getTemplateVarOutput($field, $target); |
|
1066 | 1066 | $this->documentObject[$target][$field] = $a[$field]; |
1067 | 1067 | } |
1068 | 1068 | } |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | return $this->documentObject[$target][$field]; |
1072 | 1072 | } |
1073 | 1073 | |
1074 | - public function setPlaceholders($value = '', $key = '', $path = '') { |
|
1075 | - if($path!=='') $key = "{$path}.{$key}"; |
|
1074 | + public function setPlaceholders($value = '', $key = '', $path = ''){ |
|
1075 | + if ($path !== '') $key = "{$path}.{$key}"; |
|
1076 | 1076 | if (is_array($value)) { |
1077 | 1077 | foreach ($value as $subkey => $subval) { |
1078 | 1078 | $this->setPlaceholders($subval, $subkey, $key); |
@@ -1082,77 +1082,77 @@ discard block |
||
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | // Sets a placeholder variable which can only be access by Modifiers |
1085 | - public function setModifiersVariable($key, $value) { |
|
1085 | + public function setModifiersVariable($key, $value){ |
|
1086 | 1086 | if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value; |
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | //mbstring |
1090 | - public function substr($str, $s, $l = null) { |
|
1090 | + public function substr($str, $s, $l = null){ |
|
1091 | 1091 | global $modx; |
1092 | - if(is_null($l)) $l = $this->strlen($str); |
|
1092 | + if (is_null($l)) $l = $this->strlen($str); |
|
1093 | 1093 | if (function_exists('mb_substr')) |
1094 | 1094 | { |
1095 | - if(strpos($str,"\r")!==false) |
|
1096 | - $str = str_replace(array("\r\n","\r"), "\n", $str); |
|
1095 | + if (strpos($str, "\r") !== false) |
|
1096 | + $str = str_replace(array("\r\n", "\r"), "\n", $str); |
|
1097 | 1097 | return mb_substr($str, $s, $l, $modx->config['modx_charset']); |
1098 | 1098 | } |
1099 | 1099 | return substr($str, $s, $l); |
1100 | 1100 | } |
1101 | - public function strpos($haystack,$needle,$offset=0) { |
|
1101 | + public function strpos($haystack, $needle, $offset = 0){ |
|
1102 | 1102 | global $modx; |
1103 | - if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); |
|
1104 | - return strpos($haystack,$needle,$offset); |
|
1103 | + if (function_exists('mb_strpos')) return mb_strpos($haystack, $needle, $offset, $modx->config['modx_charset']); |
|
1104 | + return strpos($haystack, $needle, $offset); |
|
1105 | 1105 | } |
1106 | - public function strlen($str) { |
|
1106 | + public function strlen($str){ |
|
1107 | 1107 | global $modx; |
1108 | - if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); |
|
1108 | + if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str), $modx->config['modx_charset']); |
|
1109 | 1109 | return strlen($str); |
1110 | 1110 | } |
1111 | - public function strtolower($str) { |
|
1111 | + public function strtolower($str){ |
|
1112 | 1112 | if (function_exists('mb_strtolower')) return mb_strtolower($str); |
1113 | 1113 | return strtolower($str); |
1114 | 1114 | } |
1115 | - public function strtoupper($str) { |
|
1115 | + public function strtoupper($str){ |
|
1116 | 1116 | if (function_exists('mb_strtoupper')) return mb_strtoupper($str); |
1117 | 1117 | return strtoupper($str); |
1118 | 1118 | } |
1119 | - public function ucfirst($str) { |
|
1119 | + public function ucfirst($str){ |
|
1120 | 1120 | if (function_exists('mb_strtoupper')) |
1121 | 1121 | return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
1122 | 1122 | return ucfirst($str); |
1123 | 1123 | } |
1124 | - public function lcfirst($str) { |
|
1124 | + public function lcfirst($str){ |
|
1125 | 1125 | if (function_exists('mb_strtolower')) |
1126 | 1126 | return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
1127 | 1127 | return lcfirst($str); |
1128 | 1128 | } |
1129 | - public function ucwords($str) { |
|
1129 | + public function ucwords($str){ |
|
1130 | 1130 | if (function_exists('mb_convert_case')) |
1131 | 1131 | return mb_convert_case($str, MB_CASE_TITLE); |
1132 | 1132 | return ucwords($str); |
1133 | 1133 | } |
1134 | - public function strrev($str) { |
|
1134 | + public function strrev($str){ |
|
1135 | 1135 | preg_match_all('/./us', $str, $ar); |
1136 | 1136 | return implode(array_reverse($ar[0])); |
1137 | 1137 | } |
1138 | - public function str_shuffle($str) { |
|
1138 | + public function str_shuffle($str){ |
|
1139 | 1139 | preg_match_all('/./us', $str, $ar); |
1140 | 1140 | shuffle($ar[0]); |
1141 | 1141 | return implode($ar[0]); |
1142 | 1142 | } |
1143 | - public function str_word_count($str) { |
|
1144 | - return count(preg_split('~[^\p{L}\p{N}\']+~u',$str)); |
|
1143 | + public function str_word_count($str){ |
|
1144 | + return count(preg_split('~[^\p{L}\p{N}\']+~u', $str)); |
|
1145 | 1145 | } |
1146 | - public function strip_tags($value,$params='') { |
|
1146 | + public function strip_tags($value, $params = ''){ |
|
1147 | 1147 | global $modx; |
1148 | 1148 | |
1149 | - if(stripos($params,'style')===false && stripos($value,'</style>')!==false) { |
|
1149 | + if (stripos($params, 'style') === false && stripos($value, '</style>') !== false) { |
|
1150 | 1150 | $value = preg_replace('@<style.*?>.*?</style>@is', '', $value); |
1151 | 1151 | } |
1152 | - if(stripos($params,'script')===false && stripos($value,'</script>')!==false) { |
|
1152 | + if (stripos($params, 'script') === false && stripos($value, '</script>') !== false) { |
|
1153 | 1153 | $value = preg_replace('@<script.*?>.*?</script>@is', '', $value); |
1154 | 1154 | } |
1155 | 1155 | |
1156 | - return trim(strip_tags($value,$params)); |
|
1156 | + return trim(strip_tags($value, $params)); |
|
1157 | 1157 | } |
1158 | 1158 | } |
@@ -65,26 +65,26 @@ |
||
65 | 65 | $_['macintosh'] = 'Western European (Mac) - macintosh'; |
66 | 66 | $_['Windows-1252'] = 'Western European (Windows) - Windows-1252'; |
67 | 67 | |
68 | -if($modx_charset == 'euc-jp') $_['euc-jp'] = 'Japanese (EUC) - euc-jp'; |
|
69 | -elseif($modx_charset == 'shift_jis') $_['shift_jis'] = 'Japanese (Shift-JIS) - shift_jis'; |
|
70 | -elseif($modx_charset == 'iso-2022-jp') $_['iso-2022-jp'] = 'Japanese (JIS-Allow 1 byte Kana - SO/SI) - iso-2022-jp'; |
|
71 | -elseif($modx_charset == 'csISO2022JP') $_['csISO2022JP'] = 'Japanese (JIS-Allow 1 byte Kana) - csISO2022JP'; |
|
72 | -elseif($modx_charset == 'EUC-CN') $_['EUC-CN'] = 'Chinese Simplified (EUC) - EUC-CN'; |
|
73 | -elseif($modx_charset == 'hz-gb-2312') $_['hz-gb-2312'] = 'Chinese Simplified (HZ) - hz-gb-2312'; |
|
74 | -elseif($modx_charset == 'x-mac-chinesesimp') $_['x-mac-chinesesimp'] = 'Chinese Simplified (Mac) - x-mac-chinesesimp'; |
|
75 | -elseif($modx_charset == 'x-Chinese-CNS') $_['x-Chinese-CNS'] = 'Chinese Traditional (CNS) - x-Chinese-CNS'; |
|
76 | -elseif($modx_charset == 'x-Chinese-Eten') $_['x-Chinese-Eten'] = 'Chinese Traditional (Eten) - x-Chinese-Eten'; |
|
77 | -elseif($modx_charset == 'x-mac-chinesetrad') $_['x-mac-chinesetrad'] = 'Chinese Traditional (Mac) - x-mac-chinesetrad'; |
|
78 | -elseif($modx_charset == 'ks_c_5601-1987') $_['ks_c_5601-1987'] = 'Korean - ks_c_5601-1987'; |
|
79 | -elseif($modx_charset == 'euc-kr') $_['euc-kr'] = 'Korean (EUC) - euc-kr'; |
|
80 | -elseif($modx_charset == 'iso-2022-kr') $_['iso-2022-kr'] = 'Korean (ISO) - iso-2022-kr'; |
|
81 | -elseif($modx_charset == 'Johab') $_['Johab'] = 'Korean (Johab) - Johab'; |
|
82 | -elseif($modx_charset == 'x-mac-korean') $_['x-mac-korean'] = 'Korean (Mac) - x-mac-korean'; |
|
68 | +if ($modx_charset == 'euc-jp') $_['euc-jp'] = 'Japanese (EUC) - euc-jp'; |
|
69 | +elseif ($modx_charset == 'shift_jis') $_['shift_jis'] = 'Japanese (Shift-JIS) - shift_jis'; |
|
70 | +elseif ($modx_charset == 'iso-2022-jp') $_['iso-2022-jp'] = 'Japanese (JIS-Allow 1 byte Kana - SO/SI) - iso-2022-jp'; |
|
71 | +elseif ($modx_charset == 'csISO2022JP') $_['csISO2022JP'] = 'Japanese (JIS-Allow 1 byte Kana) - csISO2022JP'; |
|
72 | +elseif ($modx_charset == 'EUC-CN') $_['EUC-CN'] = 'Chinese Simplified (EUC) - EUC-CN'; |
|
73 | +elseif ($modx_charset == 'hz-gb-2312') $_['hz-gb-2312'] = 'Chinese Simplified (HZ) - hz-gb-2312'; |
|
74 | +elseif ($modx_charset == 'x-mac-chinesesimp') $_['x-mac-chinesesimp'] = 'Chinese Simplified (Mac) - x-mac-chinesesimp'; |
|
75 | +elseif ($modx_charset == 'x-Chinese-CNS') $_['x-Chinese-CNS'] = 'Chinese Traditional (CNS) - x-Chinese-CNS'; |
|
76 | +elseif ($modx_charset == 'x-Chinese-Eten') $_['x-Chinese-Eten'] = 'Chinese Traditional (Eten) - x-Chinese-Eten'; |
|
77 | +elseif ($modx_charset == 'x-mac-chinesetrad') $_['x-mac-chinesetrad'] = 'Chinese Traditional (Mac) - x-mac-chinesetrad'; |
|
78 | +elseif ($modx_charset == 'ks_c_5601-1987') $_['ks_c_5601-1987'] = 'Korean - ks_c_5601-1987'; |
|
79 | +elseif ($modx_charset == 'euc-kr') $_['euc-kr'] = 'Korean (EUC) - euc-kr'; |
|
80 | +elseif ($modx_charset == 'iso-2022-kr') $_['iso-2022-kr'] = 'Korean (ISO) - iso-2022-kr'; |
|
81 | +elseif ($modx_charset == 'Johab') $_['Johab'] = 'Korean (Johab) - Johab'; |
|
82 | +elseif ($modx_charset == 'x-mac-korean') $_['x-mac-korean'] = 'Korean (Mac) - x-mac-korean'; |
|
83 | 83 | |
84 | 84 | $tpl = '<option value="%s" %s>%s</option>'; |
85 | 85 | $options = array(); |
86 | -foreach($_ as $value=>$label) { |
|
87 | - $selected = $value===$modx_charset ? 'selected' : ''; |
|
86 | +foreach ($_ as $value=>$label) { |
|
87 | + $selected = $value === $modx_charset ? 'selected' : ''; |
|
88 | 88 | $options[] = sprintf($tpl, $value, $selected, $label); |
89 | 89 | } |
90 | 90 | echo implode("\n", $options); |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | 6 | // PROCESSOR FIRST |
7 | -if($_SESSION['mgrRole'] == 1) { |
|
8 | - if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
7 | +if ($_SESSION['mgrRole'] == 1) { |
|
8 | + if ($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
9 | 9 | $current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']); |
10 | - if(!empty($current)) { |
|
10 | + if (!empty($current)) { |
|
11 | 11 | $modx->manager->setSystemChecksum($current); |
12 | 12 | $modx->clearCache('full'); |
13 | 13 | $modx->config['sys_files_checksum'] = $current; |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | $warningspresent = 0; |
20 | 20 | |
21 | 21 | $sysfiles_check = $modx->manager->checkSystemChecksum(); |
22 | -if ($sysfiles_check!=='0'){ |
|
22 | +if ($sysfiles_check !== '0') { |
|
23 | 23 | $warningspresent = 1; |
24 | 24 | $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
25 | 25 | } |
26 | 26 | |
27 | -if (is_writable("includes/config.inc.php")){ |
|
27 | +if (is_writable("includes/config.inc.php")) { |
|
28 | 28 | // Warn if world writable |
29 | - if(@fileperms('includes/config.inc.php') & 0x0002) { |
|
29 | + if (@fileperms('includes/config.inc.php') & 0x0002) { |
|
30 | 30 | $warningspresent = 1; |
31 | 31 | $warnings[] = array($_lang['configcheck_configinc']); |
32 | 32 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $warnings[] = array($_lang['configcheck_php_gdzip']); |
43 | 43 | } |
44 | 44 | |
45 | -if(!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | - if(isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
45 | +if (!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | + if (isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
47 | 47 | if ($modx->db->getValue($modx->db->select('COUNT(setting_value)', $modx->getFullTableName('system_settings'), "setting_name='validate_referer' AND setting_value='0'"))) { |
48 | 48 | $warningspresent = 1; |
49 | 49 | $warnings[] = array($_lang['configcheck_validate_referer']); |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | // check for Template Switcher plugin |
55 | -if(!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | - if(isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
55 | +if (!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | + if (isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
57 | 57 | $rs = $modx->db->select('name, disabled', $modx->getFullTableName('site_plugins'), "name IN ('TemplateSwitcher', 'Template Switcher', 'templateswitcher', 'template_switcher', 'template switcher') OR plugincode LIKE '%TemplateSwitcher%'"); |
58 | 58 | $row = $modx->db->getRow($rs); |
59 | - if($row && $row['disabled'] == 0) { |
|
59 | + if ($row && $row['disabled'] == 0) { |
|
60 | 60 | $warningspresent = 1; |
61 | 61 | $warnings[] = array($_lang['configcheck_templateswitcher_present']); |
62 | 62 | $tplName = $row['name']; |
@@ -117,36 +117,36 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | if (!function_exists('checkSiteCache')) { |
120 | - function checkSiteCache() { |
|
120 | + function checkSiteCache(){ |
|
121 | 121 | global $modx; |
122 | - $checked= true; |
|
123 | - if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) { |
|
124 | - $checked= @include_once ($modx->config['base_path'] . 'assets/cache/siteCache.idx.php'); |
|
122 | + $checked = true; |
|
123 | + if (file_exists($modx->config['base_path'].'assets/cache/siteCache.idx.php')) { |
|
124 | + $checked = @include_once ($modx->config['base_path'].'assets/cache/siteCache.idx.php'); |
|
125 | 125 | } |
126 | 126 | return $checked; |
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | -if (!is_writable(MODX_BASE_PATH . "assets/cache/")) { |
|
130 | +if (!is_writable(MODX_BASE_PATH."assets/cache/")) { |
|
131 | 131 | $warningspresent = 1; |
132 | 132 | $warnings[] = array($_lang['configcheck_cache']); |
133 | 133 | } |
134 | 134 | |
135 | 135 | if (!checkSiteCache()) { |
136 | 136 | $warningspresent = 1; |
137 | - $warnings[]= array($lang['configcheck_sitecache_integrity']); |
|
137 | + $warnings[] = array($lang['configcheck_sitecache_integrity']); |
|
138 | 138 | } |
139 | 139 | |
140 | -if (!is_writable(MODX_BASE_PATH . "assets/images/")) { |
|
140 | +if (!is_writable(MODX_BASE_PATH."assets/images/")) { |
|
141 | 141 | $warningspresent = 1; |
142 | 142 | $warnings[] = array($_lang['configcheck_images']); |
143 | 143 | } |
144 | 144 | |
145 | -if(strpos($modx->config['rb_base_dir'],MODX_BASE_PATH)!==0) { |
|
145 | +if (strpos($modx->config['rb_base_dir'], MODX_BASE_PATH) !== 0) { |
|
146 | 146 | $warningspresent = 1; |
147 | 147 | $warnings[] = array($_lang['configcheck_rb_base_dir']); |
148 | 148 | } |
149 | -if(strpos($modx->config['filemanager_path'],MODX_BASE_PATH)!==0) { |
|
149 | +if (strpos($modx->config['filemanager_path'], MODX_BASE_PATH) !== 0) { |
|
150 | 150 | $warningspresent = 1; |
151 | 151 | $warnings[] = array($_lang['configcheck_filemanager_path']); |
152 | 152 | } |
@@ -154,36 +154,36 @@ discard block |
||
154 | 154 | // clear file info cache |
155 | 155 | clearstatcache(); |
156 | 156 | |
157 | -if ($warningspresent==1) { |
|
157 | +if ($warningspresent == 1) { |
|
158 | 158 | |
159 | -if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3'; |
|
159 | +if (!isset($modx->config['send_errormail'])) $modx->config['send_errormail'] = '3'; |
|
160 | 160 | $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>"; |
161 | 161 | |
162 | -for ($i=0;$i<count($warnings);$i++) { |
|
162 | +for ($i = 0; $i < count($warnings); $i++) { |
|
163 | 163 | switch ($warnings[$i][0]) { |
164 | 164 | case $_lang['configcheck_configinc']; |
165 | 165 | $warnings[$i][1] = $_lang['configcheck_configinc_msg']; |
166 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
166 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_configinc']); |
|
167 | 167 | break; |
168 | 168 | case $_lang['configcheck_installer'] : |
169 | 169 | $warnings[$i][1] = $_lang['configcheck_installer_msg']; |
170 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
170 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_installer']); |
|
171 | 171 | break; |
172 | 172 | case $_lang['configcheck_cache'] : |
173 | 173 | $warnings[$i][1] = $_lang['configcheck_cache_msg']; |
174 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
174 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_cache']); |
|
175 | 175 | break; |
176 | 176 | case $_lang['configcheck_images'] : |
177 | 177 | $warnings[$i][1] = $_lang['configcheck_images_msg']; |
178 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
178 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_images']); |
|
179 | 179 | break; |
180 | 180 | case $_lang['configcheck_sysfiles_mod']: |
181 | 181 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
182 | - $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
183 | - if($modx->hasPermission('settings')) { |
|
184 | - $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
182 | + $warnings[$i][2] = '<ul><li>'.implode('</li><li>', $sysfiles_check).'</li></ul>'; |
|
183 | + if ($modx->hasPermission('settings')) { |
|
184 | + $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\''.$_lang["reset_sysfiles_checksum_alert"].'\')">'.$_lang["reset_sysfiles_checksum_button"].'</a></li></ul>'; |
|
185 | 185 | } |
186 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
186 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1]." ".implode(', ', $sysfiles_check), $_lang['configcheck_sysfiles_mod']); |
|
187 | 187 | break; |
188 | 188 | case $_lang['configcheck_lang_difference'] : |
189 | 189 | $warnings[$i][1] = $_lang['configcheck_lang_difference_msg']; |
@@ -205,18 +205,18 @@ discard block |
||
205 | 205 | break; |
206 | 206 | case $_lang['configcheck_validate_referer'] : |
207 | 207 | $msg = $_lang['configcheck_validate_referer_msg']; |
208 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
208 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
209 | 209 | $warnings[$i][1] = "<span id=\"validate_referer_warning_wrapper\">{$msg}</span>\n"; |
210 | 210 | break; |
211 | 211 | case $_lang['configcheck_templateswitcher_present'] : |
212 | 212 | $msg = $_lang["configcheck_templateswitcher_present_msg"]; |
213 | - if(isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
214 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_disable"]; |
|
213 | + if (isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
214 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_disable"]; |
|
215 | 215 | } |
216 | - if(isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
217 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_delete"]; |
|
216 | + if (isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
217 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_delete"]; |
|
218 | 218 | } |
219 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
219 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
220 | 220 | $warnings[$i][1] = "<span id=\"templateswitcher_present_warning_wrapper\">{$msg}</span>\n"; |
221 | 221 | break; |
222 | 222 | case $_lang['configcheck_rb_base_dir'] : |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $warnings[$i][1] = $_lang['configcheck_default_msg']; |
230 | 230 | } |
231 | 231 | |
232 | - $admin_warning = $_SESSION['mgrRole']!=1 ? $_lang['configcheck_admin'] : "" ; |
|
232 | + $admin_warning = $_SESSION['mgrRole'] != 1 ? $_lang['configcheck_admin'] : ""; |
|
233 | 233 | $config_check_results .= " |
234 | 234 | <fieldset> |
235 | 235 | <p><strong>".$_lang['configcheck_warning']."</strong> '".$warnings[$i][0]."'</p> |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | ".(isset($warnings[$i][2]) ? '<div style="padding-left:1em">'.$warnings[$i][2].'</div>' : '')." |
239 | 239 | </fieldset> |
240 | 240 | "; |
241 | - if ($i!=count($warnings)-1) { |
|
241 | + if ($i != count($warnings) - 1) { |
|
242 | 242 | $config_check_results .= "<br />"; |
243 | 243 | } |
244 | 244 | } |
245 | - $_SESSION["mgrConfigCheck"]=true; |
|
245 | + $_SESSION["mgrConfigCheck"] = true; |
|
246 | 246 | } else { |
247 | 247 | $config_check_results = $_lang['configcheck_ok']; |
248 | 248 | } |