@@ -130,7 +130,7 @@ |
||
| 130 | 130 | * duplicate of method in documentParser class |
| 131 | 131 | * |
| 132 | 132 | * @param string $propertyString |
| 133 | - * @return array |
|
| 133 | + * @return string |
|
| 134 | 134 | */ |
| 135 | 135 | function parseProperties($propertyString) { |
| 136 | 136 | $parameter= array (); |
@@ -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,18 +113,18 @@ 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 | /** |
| 129 | 129 | * parses a resource property string and returns the result as an array |
| 130 | 130 | * duplicate of method in documentParser class |
@@ -132,20 +132,20 @@ discard block |
||
| 132 | 132 | * @param string $propertyString |
| 133 | 133 | * @return array |
| 134 | 134 | */ |
| 135 | - function parseProperties($propertyString) { |
|
| 136 | - $parameter= array (); |
|
| 135 | + function parseProperties($propertyString){ |
|
| 136 | + $parameter = array(); |
|
| 137 | 137 | if (!empty ($propertyString)) { |
| 138 | - $tmpParams= explode("&", $propertyString); |
|
| 138 | + $tmpParams = explode("&", $propertyString); |
|
| 139 | 139 | $countParams = count($tmpParams); |
| 140 | - for ($x= 0; $x < $countParams; $x++) { |
|
| 140 | + for ($x = 0; $x < $countParams; $x++) { |
|
| 141 | 141 | if (strpos($tmpParams[$x], '=', 0)) { |
| 142 | - $pTmp= explode("=", $tmpParams[$x]); |
|
| 143 | - $pvTmp= explode(";", trim($pTmp[1])); |
|
| 142 | + $pTmp = explode("=", $tmpParams[$x]); |
|
| 143 | + $pvTmp = explode(";", trim($pTmp[1])); |
|
| 144 | 144 | if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
| 145 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
| 145 | + $parameter[trim($pTmp[0])] = $pvTmp[3]; //list default |
|
| 146 | 146 | else |
| 147 | 147 | if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
| 148 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 148 | + $parameter[trim($pTmp[0])] = $pvTmp[2]; |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -156,20 +156,20 @@ discard block |
||
| 156 | 156 | // check status of Inherit Parent Template plugin |
| 157 | 157 | $auto_template_logic = 'parent'; |
| 158 | 158 | if ($installMode != 0) { |
| 159 | - $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'"); |
|
| 159 | + $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`".$table_prefix."site_plugins` WHERE name='Inherit Parent Template'"); |
|
| 160 | 160 | $row = mysqli_fetch_row($rs); |
| 161 | - if(!$row) { |
|
| 161 | + if (!$row) { |
|
| 162 | 162 | // not installed |
| 163 | 163 | $auto_template_logic = 'system'; |
| 164 | 164 | } else { |
| 165 | - if($row[1] == 1) { |
|
| 165 | + if ($row[1] == 1) { |
|
| 166 | 166 | // installed but disabled |
| 167 | 167 | $auto_template_logic = 'system'; |
| 168 | 168 | } else { |
| 169 | 169 | // installed, enabled .. see how it's configured |
| 170 | 170 | $properties = parseProperties($row[0]); |
| 171 | - if(isset($properties['inheritTemplate'])) { |
|
| 172 | - if($properties['inheritTemplate'] == 'From First Sibling') { |
|
| 171 | + if (isset($properties['inheritTemplate'])) { |
|
| 172 | + if ($properties['inheritTemplate'] == 'From First Sibling') { |
|
| 173 | 173 | $auto_template_logic = 'sibling'; |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -193,20 +193,20 @@ discard block |
||
| 193 | 193 | $sqlParser->connect(); |
| 194 | 194 | |
| 195 | 195 | // install/update database |
| 196 | -echo "<p>" . $_lang['setup_database_creating_tables']; |
|
| 196 | +echo "<p>".$_lang['setup_database_creating_tables']; |
|
| 197 | 197 | if ($moduleSQLBaseFile) { |
| 198 | 198 | $sqlParser->process($moduleSQLBaseFile); |
| 199 | 199 | // display database results |
| 200 | 200 | if ($sqlParser->installFailed == true) { |
| 201 | 201 | $errors += 1; |
| 202 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 203 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 204 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 202 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
| 203 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
| 204 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
| 205 | 205 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
| 206 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 206 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
| 207 | 207 | } |
| 208 | 208 | echo "</p>"; |
| 209 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 209 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
| 210 | 210 | return; |
| 211 | 211 | } else { |
| 212 | 212 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
@@ -216,12 +216,12 @@ discard block |
||
| 216 | 216 | // custom or not |
| 217 | 217 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
| 218 | 218 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
| 219 | -}else{ |
|
| 219 | +} else { |
|
| 220 | 220 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // write the config.inc.php file if new installation |
| 224 | -echo "<p>" . $_lang['writing_config_file']; |
|
| 224 | +echo "<p>".$_lang['writing_config_file']; |
|
| 225 | 225 | |
| 226 | 226 | $confph = array(); |
| 227 | 227 | $confph['database_server'] = $database_server; |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $chmodSuccess = @chmod($filename, 0404); |
| 254 | 254 | |
| 255 | 255 | if ($configFileFailed == true) { |
| 256 | - echo '<span class="notok">' . $_lang['failed'] . "</span></p>"; |
|
| 256 | + echo '<span class="notok">'.$_lang['failed']."</span></p>"; |
|
| 257 | 257 | $errors += 1; |
| 258 | 258 | ?> |
| 259 | 259 | <p><?php echo $_lang['cant_write_config_file']?><span class="mono"><?php echo MGR_DIR; ?>/includes/config.inc.php</span></p> |
@@ -270,35 +270,35 @@ discard block |
||
| 270 | 270 | // generate new site_id and set manager theme to default |
| 271 | 271 | if ($installMode == 0) { |
| 272 | 272 | $siteid = uniqid(''); |
| 273 | - mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')"); |
|
| 273 | + mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')"); |
|
| 274 | 274 | } else { |
| 275 | 275 | // update site_id if missing |
| 276 | - $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'"); |
|
| 276 | + $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`".$table_prefix."system_settings` WHERE setting_name='site_id'"); |
|
| 277 | 277 | if ($ds) { |
| 278 | 278 | $r = mysqli_fetch_assoc($ds); |
| 279 | 279 | $siteid = $r['setting_value']; |
| 280 | 280 | if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') { |
| 281 | 281 | $siteid = uniqid(''); |
| 282 | - mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')"); |
|
| 282 | + mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')"); |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | // Reset database for installation of demo-site |
| 288 | 288 | if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) { |
| 289 | - echo "<p>" . $_lang['resetting_database']; |
|
| 289 | + echo "<p>".$_lang['resetting_database']; |
|
| 290 | 290 | $sqlParser->process($moduleSQLResetFile); |
| 291 | 291 | // display database results |
| 292 | 292 | if ($sqlParser->installFailed == true) { |
| 293 | 293 | $errors += 1; |
| 294 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 295 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 296 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 294 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
| 295 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
| 296 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
| 297 | 297 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
| 298 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 298 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
| 299 | 299 | } |
| 300 | 300 | echo "</p>"; |
| 301 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 301 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
| 302 | 302 | return; |
| 303 | 303 | } else { |
| 304 | 304 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
@@ -307,11 +307,11 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | // Install Templates |
| 309 | 309 | if (isset ($_POST['template']) || $installData) { |
| 310 | - echo "<h3>" . $_lang['templates'] . ":</h3> "; |
|
| 310 | + echo "<h3>".$_lang['templates'].":</h3> "; |
|
| 311 | 311 | $selTemplates = $_POST['template']; |
| 312 | 312 | foreach ($moduleTemplates as $k=>$moduleTemplate) { |
| 313 | 313 | $installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1; |
| 314 | - if($installSample || in_array($k, $selTemplates)) { |
|
| 314 | + if ($installSample || in_array($k, $selTemplates)) { |
|
| 315 | 315 | $name = mysqli_real_escape_string($conn, $moduleTemplate[0]); |
| 316 | 316 | $desc = mysqli_real_escape_string($conn, $moduleTemplate[1]); |
| 317 | 317 | $category = mysqli_real_escape_string($conn, $moduleTemplate[4]); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | $filecontent = $moduleTemplate[3]; |
| 320 | 320 | $save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site |
| 321 | 321 | if (!file_exists($filecontent)) { |
| 322 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_template'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 322 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_template']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 323 | 323 | } else { |
| 324 | 324 | // Create the category if it does not already exist |
| 325 | 325 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -329,31 +329,31 @@ discard block |
||
| 329 | 329 | $template = mysqli_real_escape_string($conn, $template); |
| 330 | 330 | |
| 331 | 331 | // See if the template already exists |
| 332 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'"); |
|
| 332 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name'"); |
|
| 333 | 333 | |
| 334 | 334 | if (mysqli_num_rows($rs)) { |
| 335 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked' WHERE templatename='$name' LIMIT 1;")) { |
|
| 335 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked' WHERE templatename='$name' LIMIT 1;")) { |
|
| 336 | 336 | $errors += 1; |
| 337 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 337 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 338 | 338 | return; |
| 339 | 339 | } |
| 340 | - if(!is_null($save_sql_id_as)) { |
|
| 340 | + if (!is_null($save_sql_id_as)) { |
|
| 341 | 341 | $sql_id = @mysqli_insert_id($sqlParser->conn); |
| 342 | - if(!$sql_id) { |
|
| 343 | - $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;")); |
|
| 342 | + if (!$sql_id) { |
|
| 343 | + $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name' LIMIT 1;")); |
|
| 344 | 344 | $sql_id = $idQuery['id']; |
| 345 | 345 | } |
| 346 | 346 | $custom_placeholders[$save_sql_id_as] = $sql_id; |
| 347 | 347 | } |
| 348 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 348 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 349 | 349 | } else { |
| 350 | - if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) { |
|
| 350 | + if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) { |
|
| 351 | 351 | $errors += 1; |
| 352 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 352 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 353 | 353 | return; |
| 354 | 354 | } |
| 355 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 356 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 355 | + if (!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 356 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | } |
@@ -362,11 +362,11 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | // Install Template Variables |
| 364 | 364 | if (isset ($_POST['tv']) || $installData) { |
| 365 | - echo "<h3>" . $_lang['tvs'] . ":</h3> "; |
|
| 365 | + echo "<h3>".$_lang['tvs'].":</h3> "; |
|
| 366 | 366 | $selTVs = $_POST['tv']; |
| 367 | 367 | foreach ($moduleTVs as $k=>$moduleTV) { |
| 368 | 368 | $installSample = in_array('sample', $moduleTV[12]) && $installData == 1; |
| 369 | - if($installSample || in_array($k, $selTVs)) { |
|
| 369 | + if ($installSample || in_array($k, $selTVs)) { |
|
| 370 | 370 | $name = mysqli_real_escape_string($conn, $moduleTV[0]); |
| 371 | 371 | $caption = mysqli_real_escape_string($conn, $moduleTV[1]); |
| 372 | 372 | $desc = mysqli_real_escape_string($conn, $moduleTV[2]); |
@@ -384,25 +384,25 @@ discard block |
||
| 384 | 384 | // Create the category if it does not already exist |
| 385 | 385 | $category = getCreateDbCategory($category, $sqlParser); |
| 386 | 386 | |
| 387 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'"); |
|
| 387 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name'"); |
|
| 388 | 388 | if (mysqli_num_rows($rs)) { |
| 389 | 389 | $insert = true; |
| 390 | - while($row = mysqli_fetch_assoc($rs)) { |
|
| 391 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) { |
|
| 392 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 390 | + while ($row = mysqli_fetch_assoc($rs)) { |
|
| 391 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) { |
|
| 392 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 393 | 393 | return; |
| 394 | 394 | } |
| 395 | 395 | $insert = false; |
| 396 | 396 | } |
| 397 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 397 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 398 | 398 | } else { |
| 399 | 399 | //$q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',(SELECT (CASE COUNT(*) WHEN 0 THEN 0 ELSE `id` END) `id` FROM $dbase.`" . $table_prefix . "categories` WHERE `category` = '$category'),$locked,'$input_options','$output_widget','$output_widget_params','$input_default');"; |
| 400 | - $q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');"; |
|
| 400 | + $q = "INSERT INTO $dbase.`".$table_prefix."site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');"; |
|
| 401 | 401 | if (!mysqli_query($sqlParser->conn, $q)) { |
| 402 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 402 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 403 | 403 | return; |
| 404 | 404 | } |
| 405 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 405 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | // add template assignments |
@@ -411,10 +411,10 @@ discard block |
||
| 411 | 411 | if (count($assignments) > 0) { |
| 412 | 412 | |
| 413 | 413 | // remove existing tv -> template assignments |
| 414 | - $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
| 414 | + $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
| 415 | 415 | $row = mysqli_fetch_assoc($ds); |
| 416 | 416 | $id = $row["id"]; |
| 417 | - mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\''); |
|
| 417 | + mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_tmplvar_templates` WHERE tmplvarid = \''.$id.'\''); |
|
| 418 | 418 | |
| 419 | 419 | // add tv -> template assignments |
| 420 | 420 | foreach ($assignments as $assignment) { |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | if ($ds && $ts) { |
| 424 | 424 | $tRow = mysqli_fetch_assoc($ts); |
| 425 | 425 | $templateId = $tRow['id']; |
| 426 | - mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
| 426 | + mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
| 427 | 427 | } |
| 428 | 428 | } |
| 429 | 429 | } |
@@ -433,12 +433,12 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | // Install Chunks |
| 435 | 435 | if (isset ($_POST['chunk']) || $installData) { |
| 436 | - echo "<h3>" . $_lang['chunks'] . ":</h3> "; |
|
| 436 | + echo "<h3>".$_lang['chunks'].":</h3> "; |
|
| 437 | 437 | $selChunks = $_POST['chunk']; |
| 438 | 438 | foreach ($moduleChunks as $k=>$moduleChunk) { |
| 439 | 439 | $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1; |
| 440 | 440 | $count_new_name = 0; |
| 441 | - if($installSample || in_array($k, $selChunks)) { |
|
| 441 | + if ($installSample || in_array($k, $selChunks)) { |
|
| 442 | 442 | |
| 443 | 443 | $name = mysqli_real_escape_string($conn, $moduleChunk[0]); |
| 444 | 444 | $desc = mysqli_real_escape_string($conn, $moduleChunk[1]); |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $filecontent = $moduleChunk[2]; |
| 448 | 448 | |
| 449 | 449 | if (!file_exists($filecontent)) |
| 450 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 450 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_chunk']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 451 | 451 | else { |
| 452 | 452 | |
| 453 | 453 | // Create the category if it does not already exist |
@@ -455,31 +455,31 @@ discard block |
||
| 455 | 455 | |
| 456 | 456 | $chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1); |
| 457 | 457 | $chunk = mysqli_real_escape_string($conn, $chunk); |
| 458 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'"); |
|
| 458 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$name'"); |
|
| 459 | 459 | $count_original_name = mysqli_num_rows($rs); |
| 460 | - if($overwrite == 'false') { |
|
| 461 | - $newname = $name . '-' . str_replace('.', '_', $modx_version); |
|
| 462 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'"); |
|
| 460 | + if ($overwrite == 'false') { |
|
| 461 | + $newname = $name.'-'.str_replace('.', '_', $modx_version); |
|
| 462 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$newname'"); |
|
| 463 | 463 | $count_new_name = mysqli_num_rows($rs); |
| 464 | 464 | } |
| 465 | 465 | $update = $count_original_name > 0 && $overwrite == 'true'; |
| 466 | 466 | if ($update) { |
| 467 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
| 467 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
| 468 | 468 | $errors += 1; |
| 469 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 469 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 470 | 470 | return; |
| 471 | 471 | } |
| 472 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 473 | - } elseif($count_new_name == 0) { |
|
| 474 | - if($count_original_name > 0 && $overwrite == 'false') { |
|
| 472 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 473 | + } elseif ($count_new_name == 0) { |
|
| 474 | + if ($count_original_name > 0 && $overwrite == 'false') { |
|
| 475 | 475 | $name = $newname; |
| 476 | 476 | } |
| 477 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) { |
|
| 477 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) { |
|
| 478 | 478 | $errors += 1; |
| 479 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 479 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 480 | 480 | return; |
| 481 | 481 | } |
| 482 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 482 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | } |
@@ -488,11 +488,11 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | // Install Modules |
| 490 | 490 | if (isset ($_POST['module']) || $installData) { |
| 491 | - echo "<h3>" . $_lang['modules'] . ":</h3> "; |
|
| 491 | + echo "<h3>".$_lang['modules'].":</h3> "; |
|
| 492 | 492 | $selModules = $_POST['module']; |
| 493 | 493 | foreach ($moduleModules as $k=>$moduleModule) { |
| 494 | 494 | $installSample = in_array('sample', $moduleModule[7]) && $installData == 1; |
| 495 | - if($installSample || in_array($k, $selModules)) { |
|
| 495 | + if ($installSample || in_array($k, $selModules)) { |
|
| 496 | 496 | $name = mysqli_real_escape_string($conn, $moduleModule[0]); |
| 497 | 497 | $desc = mysqli_real_escape_string($conn, $moduleModule[1]); |
| 498 | 498 | $filecontent = $moduleModule[2]; |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
| 502 | 502 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
| 503 | 503 | if (!file_exists($filecontent)) |
| 504 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 504 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_module']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 505 | 505 | else { |
| 506 | 506 | |
| 507 | 507 | // Create the category if it does not already exist |
@@ -510,22 +510,22 @@ discard block |
||
| 510 | 510 | $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
| 511 | 511 | // $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab |
| 512 | 512 | $module = mysqli_real_escape_string($conn, $module); |
| 513 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'"); |
|
| 513 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_modules` WHERE name='$name'"); |
|
| 514 | 514 | if (mysqli_num_rows($rs)) { |
| 515 | 515 | $row = mysqli_fetch_assoc($rs); |
| 516 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 517 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
| 518 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 516 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 517 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
| 518 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 519 | 519 | return; |
| 520 | 520 | } |
| 521 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 521 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 522 | 522 | } else { |
| 523 | 523 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 524 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) { |
|
| 525 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 524 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) { |
|
| 525 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 526 | 526 | return; |
| 527 | 527 | } |
| 528 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 528 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | } |
@@ -534,11 +534,11 @@ discard block |
||
| 534 | 534 | |
| 535 | 535 | // Install Plugins |
| 536 | 536 | if (isset ($_POST['plugin']) || $installData) { |
| 537 | - echo "<h3>" . $_lang['plugins'] . ":</h3> "; |
|
| 537 | + echo "<h3>".$_lang['plugins'].":</h3> "; |
|
| 538 | 538 | $selPlugs = $_POST['plugin']; |
| 539 | 539 | foreach ($modulePlugins as $k=>$modulePlugin) { |
| 540 | 540 | $installSample = in_array('sample', $modulePlugin[8]) && $installData == 1; |
| 541 | - if($installSample || in_array($k, $selPlugs)) { |
|
| 541 | + if ($installSample || in_array($k, $selPlugs)) { |
|
| 542 | 542 | $name = mysqli_real_escape_string($conn, $modulePlugin[0]); |
| 543 | 543 | $desc = mysqli_real_escape_string($conn, $modulePlugin[1]); |
| 544 | 544 | $filecontent = $modulePlugin[2]; |
@@ -548,17 +548,17 @@ discard block |
||
| 548 | 548 | $category = mysqli_real_escape_string($conn, $modulePlugin[6]); |
| 549 | 549 | $leg_names = ''; |
| 550 | 550 | $disabled = $modulePlugin[9]; |
| 551 | - if(array_key_exists(7, $modulePlugin)) { |
|
| 551 | + if (array_key_exists(7, $modulePlugin)) { |
|
| 552 | 552 | // parse comma-separated legacy names and prepare them for sql IN clause |
| 553 | - $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
|
| 553 | + $leg_names = "'".implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7])))."'"; |
|
| 554 | 554 | } |
| 555 | 555 | if (!file_exists($filecontent)) |
| 556 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 556 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_plugin']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 557 | 557 | else { |
| 558 | 558 | |
| 559 | 559 | // disable legacy versions based on legacy_names provided |
| 560 | - if(!empty($leg_names)) { |
|
| 561 | - $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
| 560 | + if (!empty($leg_names)) { |
|
| 561 | + $update_query = "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
| 562 | 562 | $rs = mysqli_query($sqlParser->conn, $update_query); |
| 563 | 563 | } |
| 564 | 564 | |
@@ -568,50 +568,50 @@ discard block |
||
| 568 | 568 | $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
| 569 | 569 | $plugin = removeDocblock($plugin, 'plugin'); |
| 570 | 570 | $plugin = mysqli_real_escape_string($conn, $plugin); |
| 571 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'"); |
|
| 571 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name'"); |
|
| 572 | 572 | if (mysqli_num_rows($rs)) { |
| 573 | 573 | $insert = true; |
| 574 | - while($row = mysqli_fetch_assoc($rs)) { |
|
| 575 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 576 | - if($row['description'] == $desc){ |
|
| 577 | - if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
| 578 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 574 | + while ($row = mysqli_fetch_assoc($rs)) { |
|
| 575 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 576 | + if ($row['description'] == $desc) { |
|
| 577 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
| 578 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 579 | 579 | return; |
| 580 | 580 | } |
| 581 | 581 | $insert = false; |
| 582 | 582 | } else { |
| 583 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
| 583 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
| 584 | 584 | echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
| 585 | 585 | return; |
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | - if($insert === true) { |
|
| 590 | - $properties = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 591 | - if(!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) { |
|
| 589 | + if ($insert === true) { |
|
| 590 | + $properties = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 591 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) { |
|
| 592 | 592 | echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
| 593 | 593 | return; |
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 596 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 597 | 597 | } else { |
| 598 | 598 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 599 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) { |
|
| 600 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 599 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) { |
|
| 600 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 601 | 601 | return; |
| 602 | 602 | } |
| 603 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 603 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 604 | 604 | } |
| 605 | 605 | // add system events |
| 606 | 606 | if (count($events) > 0) { |
| 607 | - $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';"); |
|
| 607 | + $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';"); |
|
| 608 | 608 | if ($ds) { |
| 609 | 609 | $row = mysqli_fetch_assoc($ds); |
| 610 | 610 | $id = $row["id"]; |
| 611 | 611 | // remove existing events |
| 612 | - mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_plugin_events` WHERE pluginid = \'' . $id . '\''); |
|
| 612 | + mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_plugin_events` WHERE pluginid = \''.$id.'\''); |
|
| 613 | 613 | // add new events |
| 614 | - mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`" . $table_prefix . "system_eventnames` se WHERE name IN ('" . implode("','", $events) . "')"); |
|
| 614 | + mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`".$table_prefix."system_eventnames` se WHERE name IN ('".implode("','", $events)."')"); |
|
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | 617 | } |
@@ -621,18 +621,18 @@ discard block |
||
| 621 | 621 | |
| 622 | 622 | // Install Snippets |
| 623 | 623 | if (isset ($_POST['snippet']) || $installData) { |
| 624 | - echo "<h3>" . $_lang['snippets'] . ":</h3> "; |
|
| 624 | + echo "<h3>".$_lang['snippets'].":</h3> "; |
|
| 625 | 625 | $selSnips = $_POST['snippet']; |
| 626 | 626 | foreach ($moduleSnippets as $k=>$moduleSnippet) { |
| 627 | 627 | $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1; |
| 628 | - if($installSample || in_array($k, $selSnips)) { |
|
| 628 | + if ($installSample || in_array($k, $selSnips)) { |
|
| 629 | 629 | $name = mysqli_real_escape_string($conn, $moduleSnippet[0]); |
| 630 | 630 | $desc = mysqli_real_escape_string($conn, $moduleSnippet[1]); |
| 631 | 631 | $filecontent = $moduleSnippet[2]; |
| 632 | 632 | $properties = $moduleSnippet[3]; |
| 633 | 633 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
| 634 | 634 | if (!file_exists($filecontent)) |
| 635 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 635 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_snippet']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 636 | 636 | else { |
| 637 | 637 | |
| 638 | 638 | // Create the category if it does not already exist |
@@ -641,22 +641,22 @@ discard block |
||
| 641 | 641 | $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent))); |
| 642 | 642 | $snippet = removeDocblock($snippet, 'snippet'); |
| 643 | 643 | $snippet = mysqli_real_escape_string($conn, $snippet); |
| 644 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'"); |
|
| 644 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_snippets` WHERE name='$name'"); |
|
| 645 | 645 | if (mysqli_num_rows($rs)) { |
| 646 | 646 | $row = mysqli_fetch_assoc($rs); |
| 647 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 648 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
| 649 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 647 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 648 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
| 649 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 650 | 650 | return; |
| 651 | 651 | } |
| 652 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 652 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 653 | 653 | } else { |
| 654 | 654 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 655 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
|
| 656 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 655 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
|
| 656 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 657 | 657 | return; |
| 658 | 658 | } |
| 659 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 659 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | } |
@@ -665,24 +665,24 @@ discard block |
||
| 665 | 665 | |
| 666 | 666 | // Install demo-site |
| 667 | 667 | if ($installData && $moduleSQLDataFile) { |
| 668 | - echo "<p>" . $_lang['installing_demo_site']; |
|
| 668 | + echo "<p>".$_lang['installing_demo_site']; |
|
| 669 | 669 | $sqlParser->process($moduleSQLDataFile); |
| 670 | 670 | // display database results |
| 671 | 671 | if ($sqlParser->installFailed == true) { |
| 672 | 672 | $errors += 1; |
| 673 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 674 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 675 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 673 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
| 674 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
| 675 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
| 676 | 676 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
| 677 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 677 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
| 678 | 678 | } |
| 679 | 679 | echo "</p>"; |
| 680 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 680 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
| 681 | 681 | return; |
| 682 | 682 | } else { |
| 683 | 683 | $sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", $sqlParser->prefix); |
| 684 | 684 | $rs = mysqli_query($sqlParser->conn, $sql); |
| 685 | - if(mysqli_num_rows($rs)) { |
|
| 685 | + if (mysqli_num_rows($rs)) { |
|
| 686 | 686 | $row = mysqli_fetch_assoc($rs); |
| 687 | 687 | $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']); |
| 688 | 688 | mysqli_query($sqlParser->conn, $sql); |
@@ -693,9 +693,9 @@ discard block |
||
| 693 | 693 | |
| 694 | 694 | // Install Dependencies |
| 695 | 695 | foreach ($moduleDependencies as $dependency) { |
| 696 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"'); |
|
| 696 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM '.$dbase.'`'.$sqlParser->prefix.'site_modules` WHERE name="'.$dependency['module'].'"'); |
|
| 697 | 697 | if (!$ds) { |
| 698 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 698 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 699 | 699 | return; |
| 700 | 700 | } else { |
| 701 | 701 | $row = mysqli_fetch_assoc($ds); |
@@ -703,37 +703,37 @@ discard block |
||
| 703 | 703 | $moduleGuid = $row["guid"]; |
| 704 | 704 | } |
| 705 | 705 | // get extra id |
| 706 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"'); |
|
| 706 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE '.$dependency['column'].'="'.$dependency['name'].'"'); |
|
| 707 | 707 | if (!$ds) { |
| 708 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 708 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 709 | 709 | return; |
| 710 | 710 | } else { |
| 711 | 711 | $row = mysqli_fetch_assoc($ds); |
| 712 | 712 | $extraId = $row["id"]; |
| 713 | 713 | } |
| 714 | 714 | // setup extra as module dependency |
| 715 | - $ds = mysqli_query($sqlParser->conn, 'SELECT module FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type'] . ' LIMIT 1'); |
|
| 715 | + $ds = mysqli_query($sqlParser->conn, 'SELECT module FROM '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` WHERE module='.$moduleId.' AND resource='.$extraId.' AND type='.$dependency['type'].' LIMIT 1'); |
|
| 716 | 716 | if (!$ds) { |
| 717 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 717 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 718 | 718 | return; |
| 719 | 719 | } else { |
| 720 | 720 | if (mysqli_num_rows($ds) === 0) { |
| 721 | - mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')'); |
|
| 722 | - echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_create'] . '</span></p>'; |
|
| 721 | + mysqli_query($sqlParser->conn, 'INSERT INTO '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` (module, resource, type) VALUES('.$moduleId.','.$extraId.','.$dependency['type'].')'); |
|
| 722 | + echo '<p> '.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_create'].'</span></p>'; |
|
| 723 | 723 | } else { |
| 724 | - mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` SET module = ' . $moduleId . ', resource = ' . $extraId . ', type = ' . $dependency['type'] . ' WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type']); |
|
| 725 | - echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_update'] . '</span></p>'; |
|
| 724 | + mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` SET module = '.$moduleId.', resource = '.$extraId.', type = '.$dependency['type'].' WHERE module='.$moduleId.' AND resource='.$extraId.' AND type='.$dependency['type']); |
|
| 725 | + echo '<p> '.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_update'].'</span></p>'; |
|
| 726 | 726 | } |
| 727 | 727 | if ($dependency['type'] == 30 || $dependency['type'] == 40) { |
| 728 | 728 | // set extra guid for plugins and snippets |
| 729 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1'); |
|
| 729 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE id='.$extraId.' LIMIT 1'); |
|
| 730 | 730 | if (!$ds) { |
| 731 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 731 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 732 | 732 | return; |
| 733 | 733 | } else { |
| 734 | 734 | if (mysqli_num_rows($ds) != 0) { |
| 735 | - mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId); |
|
| 736 | - echo '<p> ' . $dependency['name'] . ': <span class="ok">' . $_lang['guid_set'] . '</span></p>'; |
|
| 735 | + mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` SET moduleguid = '.$moduleGuid.' WHERE id='.$extraId); |
|
| 736 | + echo '<p> '.$dependency['name'].': <span class="ok">'.$_lang['guid_set'].'</span></p>'; |
|
| 737 | 737 | } |
| 738 | 738 | } |
| 739 | 739 | } |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | |
| 743 | 743 | // call back function |
| 744 | 744 | if ($callBackFnc != "") |
| 745 | - $callBackFnc ($sqlParser); |
|
| 745 | + $callBackFnc($sqlParser); |
|
| 746 | 746 | |
| 747 | 747 | // Setup the MODX API -- needed for the cache processor |
| 748 | 748 | define('MODX_API_MODE', true); |
@@ -777,12 +777,12 @@ discard block |
||
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | // setup completed! |
| 780 | -echo "<p><b>" . $_lang['installation_successful'] . "</b></p>"; |
|
| 781 | -echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>"; |
|
| 780 | +echo "<p><b>".$_lang['installation_successful']."</b></p>"; |
|
| 781 | +echo "<p>".$_lang['to_log_into_content_manager']."</p>"; |
|
| 782 | 782 | if ($installMode == 0) { |
| 783 | - echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['installation_note'] . "</p>"; |
|
| 783 | + echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['installation_note']."</p>"; |
|
| 784 | 784 | } else { |
| 785 | - echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['upgrade_note'] . "</p>"; |
|
| 785 | + echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['upgrade_note']."</p>"; |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | /** |
@@ -792,11 +792,11 @@ discard block |
||
| 792 | 792 | * @param string $old |
| 793 | 793 | * @return string |
| 794 | 794 | */ |
| 795 | -function propUpdate($new,$old){ |
|
| 795 | +function propUpdate($new, $old){ |
|
| 796 | 796 | $newArr = parseProperties($new); |
| 797 | 797 | $oldArr = parseProperties($old); |
| 798 | - foreach ($oldArr as $k => $v){ |
|
| 799 | - if (isset($v['0']['options'])){ |
|
| 798 | + foreach ($oldArr as $k => $v) { |
|
| 799 | + if (isset($v['0']['options'])) { |
|
| 800 | 800 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
| 801 | 801 | } |
| 802 | 802 | } |
@@ -811,30 +811,30 @@ discard block |
||
| 811 | 811 | * @param bool|mixed $json |
| 812 | 812 | * @return string |
| 813 | 813 | */ |
| 814 | -function parseProperties($propertyString, $json=false) { |
|
| 815 | - $propertyString = str_replace('{}', '', $propertyString ); |
|
| 816 | - $propertyString = str_replace('} {', ',', $propertyString ); |
|
| 814 | +function parseProperties($propertyString, $json = false){ |
|
| 815 | + $propertyString = str_replace('{}', '', $propertyString); |
|
| 816 | + $propertyString = str_replace('} {', ',', $propertyString); |
|
| 817 | 817 | |
| 818 | - if(empty($propertyString)) return array(); |
|
| 819 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
| 818 | + if (empty($propertyString)) return array(); |
|
| 819 | + if ($propertyString == '{}' || $propertyString == '[]') return array(); |
|
| 820 | 820 | |
| 821 | 821 | $jsonFormat = isJson($propertyString, true); |
| 822 | 822 | $property = array(); |
| 823 | 823 | // old format |
| 824 | - if ( $jsonFormat === false) { |
|
| 825 | - $props= explode('&', $propertyString); |
|
| 824 | + if ($jsonFormat === false) { |
|
| 825 | + $props = explode('&', $propertyString); |
|
| 826 | 826 | foreach ($props as $prop) { |
| 827 | 827 | $prop = trim($prop); |
| 828 | - if($prop === '') { |
|
| 828 | + if ($prop === '') { |
|
| 829 | 829 | continue; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | $arr = explode(';', $prop); |
| 833 | - if( ! is_array($arr)) { |
|
| 833 | + if (!is_array($arr)) { |
|
| 834 | 834 | $arr = array(); |
| 835 | 835 | } |
| 836 | 836 | $key = explode('=', isset($arr[0]) ? $arr[0] : ''); |
| 837 | - if( ! is_array($key) || empty($key[0])) { |
|
| 837 | + if (!is_array($key) || empty($key[0])) { |
|
| 838 | 838 | continue; |
| 839 | 839 | } |
| 840 | 840 | |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | |
| 859 | 859 | } |
| 860 | 860 | // new json-format |
| 861 | - } else if(!empty($jsonFormat)){ |
|
| 861 | + } else if (!empty($jsonFormat)) { |
|
| 862 | 862 | $property = $jsonFormat; |
| 863 | 863 | } |
| 864 | 864 | if ($json) { |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | * @param bool $returnData |
| 874 | 874 | * @return bool|mixed |
| 875 | 875 | */ |
| 876 | -function isJson($string, $returnData=false) { |
|
| 876 | +function isJson($string, $returnData = false){ |
|
| 877 | 877 | $data = json_decode($string, true); |
| 878 | 878 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
| 879 | 879 | } |
@@ -883,20 +883,20 @@ discard block |
||
| 883 | 883 | * @param SqlParser $sqlParser |
| 884 | 884 | * @return int |
| 885 | 885 | */ |
| 886 | -function getCreateDbCategory($category, $sqlParser) { |
|
| 886 | +function getCreateDbCategory($category, $sqlParser){ |
|
| 887 | 887 | $dbase = $sqlParser->dbname; |
| 888 | - $dbase = '`' . trim($dbase,'`') . '`'; |
|
| 888 | + $dbase = '`'.trim($dbase, '`').'`'; |
|
| 889 | 889 | $table_prefix = $sqlParser->prefix; |
| 890 | 890 | $category_id = 0; |
| 891 | - if(!empty($category)) { |
|
| 891 | + if (!empty($category)) { |
|
| 892 | 892 | $category = mysqli_real_escape_string($sqlParser->conn, $category); |
| 893 | 893 | $rs = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."categories` WHERE category = '".$category."'"); |
| 894 | - if(mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) { |
|
| 894 | + if (mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) { |
|
| 895 | 895 | $category_id = $row['id']; |
| 896 | 896 | } else { |
| 897 | 897 | $q = "INSERT INTO $dbase.`".$table_prefix."categories` (`category`) VALUES ('{$category}');"; |
| 898 | 898 | $rs = mysqli_query($sqlParser->conn, $q); |
| 899 | - if($rs) { |
|
| 899 | + if ($rs) { |
|
| 900 | 900 | $category_id = mysqli_insert_id($sqlParser->conn); |
| 901 | 901 | } |
| 902 | 902 | } |
@@ -911,12 +911,12 @@ discard block |
||
| 911 | 911 | * @param string $type |
| 912 | 912 | * @return string |
| 913 | 913 | */ |
| 914 | -function removeDocblock($code, $type) { |
|
| 914 | +function removeDocblock($code, $type){ |
|
| 915 | 915 | |
| 916 | 916 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
| 917 | 917 | |
| 918 | 918 | // Procedure taken from plugin.filesource.php |
| 919 | - switch($type) { |
|
| 919 | + switch ($type) { |
|
| 920 | 920 | case 'snippet': |
| 921 | 921 | $elm_name = 'snippets'; |
| 922 | 922 | $include = 'return require'; |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | default: |
| 933 | 933 | return $cleaned; |
| 934 | 934 | }; |
| 935 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 935 | + if (substr(trim($cleaned), 0, $count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 936 | 936 | return $cleaned; |
| 937 | 937 | |
| 938 | 938 | // fileBinding not found - return code incl docblock |
@@ -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 | |
@@ -58,13 +58,15 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | // get base path and url |
| 60 | 60 | $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"]))); |
| 61 | -if (count($a) > 1) |
|
| 61 | +if (count($a) > 1) { |
|
| 62 | 62 | array_pop($a); |
| 63 | +} |
|
| 63 | 64 | $url = implode("install", $a); |
| 64 | 65 | reset($a); |
| 65 | 66 | $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__)))); |
| 66 | -if (count($a) > 1) |
|
| 67 | +if (count($a) > 1) { |
|
| 67 | 68 | array_pop($a); |
| 69 | +} |
|
| 68 | 70 | $pth = implode("install", $a); |
| 69 | 71 | unset ($a); |
| 70 | 72 | $base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
@@ -85,7 +87,9 @@ discard block |
||
| 85 | 87 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
| 86 | 88 | $create = true; |
| 87 | 89 | } else { |
| 88 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); |
|
| 90 | + if (function_exists('mysqli_set_charset')) { |
|
| 91 | + mysqli_set_charset($conn, $database_charset); |
|
| 92 | + } |
|
| 89 | 93 | mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
| 90 | 94 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
| 91 | 95 | } |
@@ -132,7 +136,8 @@ discard block |
||
| 132 | 136 | * @param string $propertyString |
| 133 | 137 | * @return array |
| 134 | 138 | */ |
| 135 | - function parseProperties($propertyString) { |
|
| 139 | + function parseProperties($propertyString) |
|
| 140 | + { |
|
| 136 | 141 | $parameter= array (); |
| 137 | 142 | if (!empty ($propertyString)) { |
| 138 | 143 | $tmpParams= explode("&", $propertyString); |
@@ -141,11 +146,14 @@ discard block |
||
| 141 | 146 | if (strpos($tmpParams[$x], '=', 0)) { |
| 142 | 147 | $pTmp= explode("=", $tmpParams[$x]); |
| 143 | 148 | $pvTmp= explode(";", trim($pTmp[1])); |
| 144 | - if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
|
| 145 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
| 149 | + if ($pvTmp[1] == 'list' && $pvTmp[3] != "") { |
|
| 150 | + $parameter[trim($pTmp[0])]= $pvTmp[3]; |
|
| 151 | + } |
|
| 152 | + //list default |
|
| 146 | 153 | else |
| 147 | - if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
|
| 148 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 154 | + if ($pvTmp[1] != 'list' && $pvTmp[2] != "") { |
|
| 155 | + $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 156 | + } |
|
| 149 | 157 | } |
| 150 | 158 | } |
| 151 | 159 | } |
@@ -216,7 +224,7 @@ discard block |
||
| 216 | 224 | // custom or not |
| 217 | 225 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
| 218 | 226 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
| 219 | -}else{ |
|
| 227 | +} else { |
|
| 220 | 228 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
| 221 | 229 | } |
| 222 | 230 | |
@@ -352,7 +360,9 @@ discard block |
||
| 352 | 360 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 353 | 361 | return; |
| 354 | 362 | } |
| 355 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 363 | + if(!is_null($save_sql_id_as)) { |
|
| 364 | + $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 365 | + } |
|
| 356 | 366 | echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
| 357 | 367 | } |
| 358 | 368 | } |
@@ -446,9 +456,9 @@ discard block |
||
| 446 | 456 | $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]); |
| 447 | 457 | $filecontent = $moduleChunk[2]; |
| 448 | 458 | |
| 449 | - if (!file_exists($filecontent)) |
|
| 450 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 451 | - else { |
|
| 459 | + if (!file_exists($filecontent)) { |
|
| 460 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 461 | + } else { |
|
| 452 | 462 | |
| 453 | 463 | // Create the category if it does not already exist |
| 454 | 464 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -500,9 +510,9 @@ discard block |
||
| 500 | 510 | $guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
| 501 | 511 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
| 502 | 512 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
| 503 | - if (!file_exists($filecontent)) |
|
| 504 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 505 | - else { |
|
| 513 | + if (!file_exists($filecontent)) { |
|
| 514 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 515 | + } else { |
|
| 506 | 516 | |
| 507 | 517 | // Create the category if it does not already exist |
| 508 | 518 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -552,9 +562,9 @@ discard block |
||
| 552 | 562 | // parse comma-separated legacy names and prepare them for sql IN clause |
| 553 | 563 | $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
| 554 | 564 | } |
| 555 | - if (!file_exists($filecontent)) |
|
| 556 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 557 | - else { |
|
| 565 | + if (!file_exists($filecontent)) { |
|
| 566 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 567 | + } else { |
|
| 558 | 568 | |
| 559 | 569 | // disable legacy versions based on legacy_names provided |
| 560 | 570 | if(!empty($leg_names)) { |
@@ -573,7 +583,7 @@ discard block |
||
| 573 | 583 | $insert = true; |
| 574 | 584 | while($row = mysqli_fetch_assoc($rs)) { |
| 575 | 585 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
| 576 | - if($row['description'] == $desc){ |
|
| 586 | + if($row['description'] == $desc) { |
|
| 577 | 587 | if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
| 578 | 588 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 579 | 589 | return; |
@@ -631,9 +641,9 @@ discard block |
||
| 631 | 641 | $filecontent = $moduleSnippet[2]; |
| 632 | 642 | $properties = $moduleSnippet[3]; |
| 633 | 643 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
| 634 | - if (!file_exists($filecontent)) |
|
| 635 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 636 | - else { |
|
| 644 | + if (!file_exists($filecontent)) { |
|
| 645 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 646 | + } else { |
|
| 637 | 647 | |
| 638 | 648 | // Create the category if it does not already exist |
| 639 | 649 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -741,13 +751,16 @@ discard block |
||
| 741 | 751 | } |
| 742 | 752 | |
| 743 | 753 | // call back function |
| 744 | -if ($callBackFnc != "") |
|
| 754 | +if ($callBackFnc != "") { |
|
| 745 | 755 | $callBackFnc ($sqlParser); |
| 756 | +} |
|
| 746 | 757 | |
| 747 | 758 | // Setup the MODX API -- needed for the cache processor |
| 748 | 759 | define('MODX_API_MODE', true); |
| 749 | 760 | define('MODX_BASE_PATH', $base_path); |
| 750 | -if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
| 761 | +if (!defined('MODX_MANAGER_PATH')) { |
|
| 762 | + define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
| 763 | +} |
|
| 751 | 764 | $database_type = 'mysqli'; |
| 752 | 765 | // initiate a new document parser |
| 753 | 766 | include_once('../'.MGR_DIR.'/includes/document.parser.class.inc.php'); |
@@ -792,11 +805,12 @@ discard block |
||
| 792 | 805 | * @param string $old |
| 793 | 806 | * @return string |
| 794 | 807 | */ |
| 795 | -function propUpdate($new,$old){ |
|
| 808 | +function propUpdate($new,$old) |
|
| 809 | +{ |
|
| 796 | 810 | $newArr = parseProperties($new); |
| 797 | 811 | $oldArr = parseProperties($old); |
| 798 | - foreach ($oldArr as $k => $v){ |
|
| 799 | - if (isset($v['0']['options'])){ |
|
| 812 | + foreach ($oldArr as $k => $v) { |
|
| 813 | + if (isset($v['0']['options'])) { |
|
| 800 | 814 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
| 801 | 815 | } |
| 802 | 816 | } |
@@ -811,12 +825,17 @@ discard block |
||
| 811 | 825 | * @param bool|mixed $json |
| 812 | 826 | * @return string |
| 813 | 827 | */ |
| 814 | -function parseProperties($propertyString, $json=false) { |
|
| 828 | +function parseProperties($propertyString, $json=false) |
|
| 829 | +{ |
|
| 815 | 830 | $propertyString = str_replace('{}', '', $propertyString ); |
| 816 | 831 | $propertyString = str_replace('} {', ',', $propertyString ); |
| 817 | 832 | |
| 818 | - if(empty($propertyString)) return array(); |
|
| 819 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
| 833 | + if(empty($propertyString)) { |
|
| 834 | + return array(); |
|
| 835 | + } |
|
| 836 | + if($propertyString=='{}' || $propertyString=='[]') { |
|
| 837 | + return array(); |
|
| 838 | + } |
|
| 820 | 839 | |
| 821 | 840 | $jsonFormat = isJson($propertyString, true); |
| 822 | 841 | $property = array(); |
@@ -858,7 +877,7 @@ discard block |
||
| 858 | 877 | |
| 859 | 878 | } |
| 860 | 879 | // new json-format |
| 861 | - } else if(!empty($jsonFormat)){ |
|
| 880 | + } else if(!empty($jsonFormat)) { |
|
| 862 | 881 | $property = $jsonFormat; |
| 863 | 882 | } |
| 864 | 883 | if ($json) { |
@@ -873,7 +892,8 @@ discard block |
||
| 873 | 892 | * @param bool $returnData |
| 874 | 893 | * @return bool|mixed |
| 875 | 894 | */ |
| 876 | -function isJson($string, $returnData=false) { |
|
| 895 | +function isJson($string, $returnData=false) |
|
| 896 | +{ |
|
| 877 | 897 | $data = json_decode($string, true); |
| 878 | 898 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
| 879 | 899 | } |
@@ -883,7 +903,8 @@ discard block |
||
| 883 | 903 | * @param SqlParser $sqlParser |
| 884 | 904 | * @return int |
| 885 | 905 | */ |
| 886 | -function getCreateDbCategory($category, $sqlParser) { |
|
| 906 | +function getCreateDbCategory($category, $sqlParser) |
|
| 907 | +{ |
|
| 887 | 908 | $dbase = $sqlParser->dbname; |
| 888 | 909 | $dbase = '`' . trim($dbase,'`') . '`'; |
| 889 | 910 | $table_prefix = $sqlParser->prefix; |
@@ -911,7 +932,8 @@ discard block |
||
| 911 | 932 | * @param string $type |
| 912 | 933 | * @return string |
| 913 | 934 | */ |
| 914 | -function removeDocblock($code, $type) { |
|
| 935 | +function removeDocblock($code, $type) |
|
| 936 | +{ |
|
| 915 | 937 | |
| 916 | 938 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
| 917 | 939 | |
@@ -932,8 +954,9 @@ discard block |
||
| 932 | 954 | default: |
| 933 | 955 | return $cleaned; |
| 934 | 956 | }; |
| 935 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 936 | - return $cleaned; |
|
| 957 | + if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') { |
|
| 958 | + return $cleaned; |
|
| 959 | + } |
|
| 937 | 960 | |
| 938 | 961 | // fileBinding not found - return code incl docblock |
| 939 | 962 | return $code; |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | |
| 720 | 720 | /** |
| 721 | 721 | * @param string $string |
| 722 | - * @return bool|string |
|
| 722 | + * @return string|false |
|
| 723 | 723 | */ |
| 724 | 724 | function removeLastPath($string) |
| 725 | 725 | { |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | |
| 735 | 735 | /** |
| 736 | 736 | * @param string $string |
| 737 | - * @return bool|string |
|
| 737 | + * @return string|false |
|
| 738 | 738 | */ |
| 739 | 739 | function getExtension($string) |
| 740 | 740 | { |
@@ -1,5 +1,5 @@ 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 | if (!$modx->hasPermission('file_manager')) { |
@@ -9,15 +9,15 @@ discard block |
||
| 9 | 9 | $newToken = makeToken(); |
| 10 | 10 | |
| 11 | 11 | // settings |
| 12 | -$theme_image_path = $modx->config['site_manager_url'] . 'media/style/' . $modx->config['manager_theme'] . '/images/'; |
|
| 12 | +$theme_image_path = $modx->config['site_manager_url'].'media/style/'.$modx->config['manager_theme'].'/images/'; |
|
| 13 | 13 | $excludes = array( |
| 14 | 14 | '.', |
| 15 | 15 | '..', |
| 16 | 16 | '.svn' |
| 17 | 17 | ); |
| 18 | -$alias_suffix = (!empty($friendly_url_suffix)) ? ',' . ltrim($friendly_url_suffix, '.') : ''; |
|
| 19 | -$editablefiles = explode(',', 'txt,php,tpl,less,sass,shtml,html,htm,xml,js,css,pageCache,htaccess,json' . $alias_suffix); |
|
| 20 | -$inlineviewablefiles = explode(',', 'txt,php,tpl,less,sass,html,htm,xml,js,css,pageCache,htaccess,json' . $alias_suffix); |
|
| 18 | +$alias_suffix = (!empty($friendly_url_suffix)) ? ','.ltrim($friendly_url_suffix, '.') : ''; |
|
| 19 | +$editablefiles = explode(',', 'txt,php,tpl,less,sass,shtml,html,htm,xml,js,css,pageCache,htaccess,json'.$alias_suffix); |
|
| 20 | +$inlineviewablefiles = explode(',', 'txt,php,tpl,less,sass,html,htm,xml,js,css,pageCache,htaccess,json'.$alias_suffix); |
|
| 21 | 21 | $viewablefiles = explode(',', 'jpg,gif,png,ico'); |
| 22 | 22 | |
| 23 | 23 | $editablefiles = add_dot($editablefiles); |
@@ -30,31 +30,31 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | */ |
| 32 | 32 | $protected_path[] = $modx->config['site_manager_path']; |
| 33 | -$protected_path[] = $modx->config['base_path'] . 'temp/backup'; |
|
| 34 | -$protected_path[] = $modx->config['base_path'] . 'assets/backup'; |
|
| 33 | +$protected_path[] = $modx->config['base_path'].'temp/backup'; |
|
| 34 | +$protected_path[] = $modx->config['base_path'].'assets/backup'; |
|
| 35 | 35 | |
| 36 | 36 | if (!$modx->hasPermission('save_plugin')) { |
| 37 | - $protected_path[] = $modx->config['base_path'] . 'assets/plugins'; |
|
| 37 | + $protected_path[] = $modx->config['base_path'].'assets/plugins'; |
|
| 38 | 38 | } |
| 39 | 39 | if (!$modx->hasPermission('save_snippet')) { |
| 40 | - $protected_path[] = $modx->config['base_path'] . 'assets/snippets'; |
|
| 40 | + $protected_path[] = $modx->config['base_path'].'assets/snippets'; |
|
| 41 | 41 | } |
| 42 | 42 | if (!$modx->hasPermission('save_template')) { |
| 43 | - $protected_path[] = $modx->config['base_path'] . 'assets/templates'; |
|
| 43 | + $protected_path[] = $modx->config['base_path'].'assets/templates'; |
|
| 44 | 44 | } |
| 45 | 45 | if (!$modx->hasPermission('save_module')) { |
| 46 | - $protected_path[] = $modx->config['base_path'] . 'assets/modules'; |
|
| 46 | + $protected_path[] = $modx->config['base_path'].'assets/modules'; |
|
| 47 | 47 | } |
| 48 | 48 | if (!$modx->hasPermission('empty_cache')) { |
| 49 | - $protected_path[] = $modx->config['base_path'] . 'assets/cache'; |
|
| 49 | + $protected_path[] = $modx->config['base_path'].'assets/cache'; |
|
| 50 | 50 | } |
| 51 | 51 | if (!$modx->hasPermission('import_static')) { |
| 52 | - $protected_path[] = $modx->config['base_path'] . 'temp/import'; |
|
| 53 | - $protected_path[] = $modx->config['base_path'] . 'assets/import'; |
|
| 52 | + $protected_path[] = $modx->config['base_path'].'temp/import'; |
|
| 53 | + $protected_path[] = $modx->config['base_path'].'assets/import'; |
|
| 54 | 54 | } |
| 55 | 55 | if (!$modx->hasPermission('export_static')) { |
| 56 | - $protected_path[] = $modx->config['base_path'] . 'temp/export'; |
|
| 57 | - $protected_path[] = $modx->config['base_path'] . 'assets/export'; |
|
| 56 | + $protected_path[] = $modx->config['base_path'].'temp/export'; |
|
| 57 | + $protected_path[] = $modx->config['base_path'].'assets/export'; |
|
| 58 | 58 | } |
| 59 | 59 | /* |
| 60 | 60 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | $count = count($array); |
| 85 | 85 | for ($i = 0; $i < $count; $i++) { |
| 86 | - $array[$i] = '.' . strtolower(trim($array[$i])); // add a dot :) |
|
| 86 | + $array[$i] = '.'.strtolower(trim($array[$i])); // add a dot :) |
|
| 87 | 87 | } |
| 88 | 88 | return $array; |
| 89 | 89 | } |
@@ -108,15 +108,15 @@ discard block |
||
| 108 | 108 | $rw = realpath('../'); |
| 109 | 109 | $webstart_path = str_replace('\\', '/', str_replace($rw, '', $rf)); |
| 110 | 110 | if (substr($webstart_path, 0, 1) == '/') { |
| 111 | - $webstart_path = '..' . $webstart_path; |
|
| 111 | + $webstart_path = '..'.$webstart_path; |
|
| 112 | 112 | } else { |
| 113 | - $webstart_path = '../' . $webstart_path; |
|
| 113 | + $webstart_path = '../'.$webstart_path; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | ?> |
| 117 | 117 | <script type="text/javascript"> |
| 118 | 118 | |
| 119 | - var current_path = '<?= $startpath;?>'; |
|
| 119 | + var current_path = '<?= $startpath; ?>'; |
|
| 120 | 120 | |
| 121 | 121 | function viewfile (url) |
| 122 | 122 | { |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | function unzipFile (file) |
| 153 | 153 | { |
| 154 | 154 | if (confirmUnzip()) { |
| 155 | - window.location.href = "index.php?a=31&mode=unzip&path=" + current_path + '/&file=' + file + "&token=<?= $newToken;?>"; |
|
| 155 | + window.location.href = "index.php?a=31&mode=unzip&path=" + current_path + '/&file=' + file + "&token=<?= $newToken; ?>"; |
|
| 156 | 156 | return false; |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | function deleteFolder (folder, status) |
| 175 | 175 | { |
| 176 | 176 | if (confirmDeleteFolder(status)) { |
| 177 | - window.location.href = "index.php?a=31&mode=deletefolder&path=" + current_path + "&folderpath=" + current_path + '/' + folder + "&token=<?= $newToken;?>"; |
|
| 177 | + window.location.href = "index.php?a=31&mode=deletefolder&path=" + current_path + "&folderpath=" + current_path + '/' + folder + "&token=<?= $newToken; ?>"; |
|
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | function deleteFile (file) |
| 183 | 183 | { |
| 184 | 184 | if (confirmDelete()) { |
| 185 | - window.location.href = "index.php?a=31&mode=delete&path=" + current_path + '/' + file + "&token=<?= $newToken;?>"; |
|
| 185 | + window.location.href = "index.php?a=31&mode=delete&path=" + current_path + '/' + file + "&token=<?= $newToken; ?>"; |
|
| 186 | 186 | return false; |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | { |
| 192 | 192 | var newFilename = prompt("<?= $_lang["files_dynamic_new_file_name"] ?>", file); |
| 193 | 193 | if (newFilename !== null && newFilename !== file) { |
| 194 | - window.location.href = "index.php?a=31&mode=duplicate&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken;?>"; |
|
| 194 | + window.location.href = "index.php?a=31&mode=duplicate&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken; ?>"; |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | var newDirname = prompt("<?= $_lang["files_dynamic_new_folder_name"] ?>", dir); |
| 201 | 201 | if (newDirname !== null && newDirname !== dir) { |
| 202 | - window.location.href = "index.php?a=31&mode=renameFolder&path=" + current_path + '&dirname=' + dir + "&newDirname=" + newDirname + "&token=<?= $newToken;?>"; |
|
| 202 | + window.location.href = "index.php?a=31&mode=renameFolder&path=" + current_path + '&dirname=' + dir + "&newDirname=" + newDirname + "&token=<?= $newToken; ?>"; |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | { |
| 208 | 208 | var newFilename = prompt("<?= $_lang["files_dynamic_new_file_name"] ?>", file); |
| 209 | 209 | if (newFilename !== null && newFilename !== file) { |
| 210 | - window.location.href = "index.php?a=31&mode=renameFile&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken;?>"; |
|
| 210 | + window.location.href = "index.php?a=31&mode=renameFile&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken; ?>"; |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | <?php endif ?> |
| 227 | 227 | <?php |
| 228 | 228 | if (isset($_GET['mode']) && $_GET['mode'] !== 'drill') { |
| 229 | - $href = 'a=31&path=' . urlencode($_REQUEST['path']); |
|
| 229 | + $href = 'a=31&path='.urlencode($_REQUEST['path']); |
|
| 230 | 230 | } else { |
| 231 | 231 | $href = 'a=2'; |
| 232 | 232 | } |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | $tpl = '<a class="btn btn-secondary" href="[+href+]" onclick="return getFolderName(this);"><i class="[+image+]"></i><span>[+subject+]</span></a>'; |
| 237 | 237 | $ph['image'] = $_style['files_folder-open']; |
| 238 | 238 | $ph['subject'] = $_lang['add_folder']; |
| 239 | - $ph['href'] = 'index.php?a=31&mode=newfolder&path=' . urlencode($startpath) . '&name='; |
|
| 239 | + $ph['href'] = 'index.php?a=31&mode=newfolder&path='.urlencode($startpath).'&name='; |
|
| 240 | 240 | $_ = parsePlaceholder($tpl, $ph); |
| 241 | 241 | |
| 242 | - $tpl = '<a class="btn btn-secondary" href="[+href+]" onclick="return getFileName(this);"><i class="[+image+]"></i><span>' . $_lang['files.dynamic.php1'] . '</span></a>'; |
|
| 242 | + $tpl = '<a class="btn btn-secondary" href="[+href+]" onclick="return getFileName(this);"><i class="[+image+]"></i><span>'.$_lang['files.dynamic.php1'].'</span></a>'; |
|
| 243 | 243 | $ph['image'] = $_style['files_page_html']; |
| 244 | - $ph['href'] = 'index.php?a=31&mode=newfile&path=' . urlencode($startpath) . '&name='; |
|
| 244 | + $ph['href'] = 'index.php?a=31&mode=newfile&path='.urlencode($startpath).'&name='; |
|
| 245 | 245 | $_ .= parsePlaceholder($tpl, $ph); |
| 246 | 246 | echo $_; |
| 247 | 247 | } |
@@ -271,12 +271,12 @@ discard block |
||
| 271 | 271 | $ph = array(); |
| 272 | 272 | $ph['style_path'] = $theme_image_path; |
| 273 | 273 | // To Top Level with folder icon to the left |
| 274 | - if ($startpath == $filemanager_path || $startpath . '/' == $filemanager_path) { |
|
| 275 | - $ph['image'] = '' . $_style['files_top'] . ''; |
|
| 274 | + if ($startpath == $filemanager_path || $startpath.'/' == $filemanager_path) { |
|
| 275 | + $ph['image'] = ''.$_style['files_top'].''; |
|
| 276 | 276 | $ph['subject'] = '<span>Top</span>'; |
| 277 | 277 | } else { |
| 278 | - $ph['image'] = '' . $_style['files_top'] . ''; |
|
| 279 | - $ph['subject'] = '<a href="index.php?a=31&mode=drill&path=' . $filemanager_path . '">Top</a>/'; |
|
| 278 | + $ph['image'] = ''.$_style['files_top'].''; |
|
| 279 | + $ph['subject'] = '<a href="index.php?a=31&mode=drill&path='.$filemanager_path.'">Top</a>/'; |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | echo parsePlaceholder($tpl, $ph); |
@@ -293,12 +293,12 @@ discard block |
||
| 293 | 293 | if (empty($v)) { |
| 294 | 294 | continue; |
| 295 | 295 | } |
| 296 | - $path .= rtrim($v, '/') . '/'; |
|
| 296 | + $path .= rtrim($v, '/').'/'; |
|
| 297 | 297 | if (1 < $count) { |
| 298 | - $href = 'index.php?a=31&mode=drill&path=' . urlencode($filemanager_path . $path); |
|
| 299 | - $pieces[$i] = '<a href="' . $href . '">' . trim($v, '/') . '</a>'; |
|
| 298 | + $href = 'index.php?a=31&mode=drill&path='.urlencode($filemanager_path.$path); |
|
| 299 | + $pieces[$i] = '<a href="'.$href.'">'.trim($v, '/').'</a>'; |
|
| 300 | 300 | } else { |
| 301 | - $pieces[$i] = '<span>' . trim($v, '/') . '</span>'; |
|
| 301 | + $pieces[$i] = '<span>'.trim($v, '/').'</span>'; |
|
| 302 | 302 | } |
| 303 | 303 | $count--; |
| 304 | 304 | } |
@@ -311,16 +311,16 @@ discard block |
||
| 311 | 311 | </div> |
| 312 | 312 | <?php |
| 313 | 313 | // check to see user isn't trying to move below the document_root |
| 314 | - if (substr(strtolower(str_replace('//', '/', $startpath . "/")), 0, $len) != strtolower(str_replace('//', '/', $filemanager_path . '/'))) { |
|
| 314 | + if (substr(strtolower(str_replace('//', '/', $startpath."/")), 0, $len) != strtolower(str_replace('//', '/', $filemanager_path.'/'))) { |
|
| 315 | 315 | $modx->webAlertAndQuit($_lang["files_access_denied"]); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // Unzip .zip files - by Raymond |
| 319 | 319 | if ($enablefileunzip && $_REQUEST['mode'] == 'unzip' && is_writable($startpath)) { |
| 320 | - if (!$err = unzip(realpath("{$startpath}/" . $_REQUEST['file']), realpath($startpath))) { |
|
| 321 | - echo '<span class="warning"><b>' . $_lang['file_unzip_fail'] . ($err === 0 ? 'Missing zip library (php_zip.dll / zip.so)' : '') . '</b></span><br /><br />'; |
|
| 320 | + if (!$err = unzip(realpath("{$startpath}/".$_REQUEST['file']), realpath($startpath))) { |
|
| 321 | + echo '<span class="warning"><b>'.$_lang['file_unzip_fail'].($err === 0 ? 'Missing zip library (php_zip.dll / zip.so)' : '').'</b></span><br /><br />'; |
|
| 322 | 322 | } else { |
| 323 | - echo '<span class="success"><b>' . $_lang['file_unzip'] . '</b></span><br /><br />'; |
|
| 323 | + echo '<span class="success"><b>'.$_lang['file_unzip'].'</b></span><br /><br />'; |
|
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | // End Unzip - Raymond |
@@ -332,9 +332,9 @@ discard block |
||
| 332 | 332 | if ($_REQUEST['mode'] == 'deletefolder') { |
| 333 | 333 | $folder = $_REQUEST['folderpath']; |
| 334 | 334 | if (!$token_check || !@rrmdir($folder)) { |
| 335 | - echo '<span class="warning"><b>' . $_lang['file_folder_not_deleted'] . '</b></span><br /><br />'; |
|
| 335 | + echo '<span class="warning"><b>'.$_lang['file_folder_not_deleted'].'</b></span><br /><br />'; |
|
| 336 | 336 | } else { |
| 337 | - echo '<span class="success"><b>' . $_lang['file_folder_deleted'] . '</b></span><br /><br />'; |
|
| 337 | + echo '<span class="success"><b>'.$_lang['file_folder_deleted'].'</b></span><br /><br />'; |
|
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
@@ -345,10 +345,10 @@ discard block |
||
| 345 | 345 | if (!mkdirs("{$startpath}/{$foldername}", 0777)) { |
| 346 | 346 | echo '<span class="warning"><b>', $_lang['file_folder_not_created'], '</b></span><br /><br />'; |
| 347 | 347 | } else { |
| 348 | - if (!@chmod($startpath . '/' . $foldername, $newfolderaccessmode)) { |
|
| 349 | - echo '<span class="warning"><b>' . $_lang['file_folder_chmod_error'] . '</b></span><br /><br />'; |
|
| 348 | + if (!@chmod($startpath.'/'.$foldername, $newfolderaccessmode)) { |
|
| 349 | + echo '<span class="warning"><b>'.$_lang['file_folder_chmod_error'].'</b></span><br /><br />'; |
|
| 350 | 350 | } else { |
| 351 | - echo '<span class="success"><b>' . $_lang['file_folder_created'] . '</b></span><br /><br />'; |
|
| 351 | + echo '<span class="success"><b>'.$_lang['file_folder_created'].'</b></span><br /><br />'; |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | umask($old_umask); |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $filename = $modx->db->escape($filename); |
| 361 | 361 | |
| 362 | 362 | if (!checkExtension($filename)) { |
| 363 | - echo '<span class="warning"><b>' . $_lang['files_filetype_notok'] . '</b></span><br /><br />'; |
|
| 363 | + echo '<span class="warning"><b>'.$_lang['files_filetype_notok'].'</b></span><br /><br />'; |
|
| 364 | 364 | } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $filename) !== 0) { |
| 365 | 365 | echo $_lang['files.dynamic.php3']; |
| 366 | 366 | } else { |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | $newFilename = $modx->db->escape($newFilename); |
| 383 | 383 | |
| 384 | 384 | if (!checkExtension($newFilename)) { |
| 385 | - echo '<span class="warning"><b>' . $_lang['files_filetype_notok'] . '</b></span><br /><br />'; |
|
| 385 | + echo '<span class="warning"><b>'.$_lang['files_filetype_notok'].'</b></span><br /><br />'; |
|
| 386 | 386 | } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newFilename) !== 0) { |
| 387 | 387 | echo $_lang['files.dynamic.php3']; |
| 388 | 388 | } else { |
| 389 | - if (!copy($filename, MODX_BASE_PATH . $newFilename)) { |
|
| 389 | + if (!copy($filename, MODX_BASE_PATH.$newFilename)) { |
|
| 390 | 390 | echo $_lang['files.dynamic.php5']; |
| 391 | 391 | } |
| 392 | 392 | umask($old_umask); |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | // Rename folder here |
| 396 | 396 | if ($_REQUEST['mode'] == 'renameFolder') { |
| 397 | 397 | $old_umask = umask(0); |
| 398 | - $dirname = $_REQUEST['path'] . '/' . $_REQUEST['dirname']; |
|
| 398 | + $dirname = $_REQUEST['path'].'/'.$_REQUEST['dirname']; |
|
| 399 | 399 | $dirname = $modx->db->escape($dirname); |
| 400 | 400 | $newDirname = str_replace(array( |
| 401 | 401 | '..\\', |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | if (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newDirname) !== 0) { |
| 409 | 409 | echo $_lang['files.dynamic.php3']; |
| 410 | - } else if (!rename($dirname, $_REQUEST['path'] . '/' . $newDirname)) { |
|
| 410 | + } else if (!rename($dirname, $_REQUEST['path'].'/'.$newDirname)) { |
|
| 411 | 411 | echo '<span class="warning"><b>', $_lang['file_folder_not_created'], '</b></span><br /><br />'; |
| 412 | 412 | } |
| 413 | 413 | umask($old_umask); |
@@ -427,11 +427,11 @@ discard block |
||
| 427 | 427 | $newFilename = $modx->db->escape($newFilename); |
| 428 | 428 | |
| 429 | 429 | if (!checkExtension($newFilename)) { |
| 430 | - echo '<span class="warning"><b>' . $_lang['files_filetype_notok'] . '</b></span><br /><br />'; |
|
| 430 | + echo '<span class="warning"><b>'.$_lang['files_filetype_notok'].'</b></span><br /><br />'; |
|
| 431 | 431 | } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newFilename) !== 0) { |
| 432 | 432 | echo $_lang['files.dynamic.php3']; |
| 433 | 433 | } else { |
| 434 | - if (!rename($filename, $path . '/' . $newFilename)) { |
|
| 434 | + if (!rename($filename, $path.'/'.$newFilename)) { |
|
| 435 | 435 | echo $_lang['files.dynamic.php5']; |
| 436 | 436 | } |
| 437 | 437 | umask($old_umask); |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | ls($startpath); |
| 465 | 465 | echo "\n\n\n"; |
| 466 | 466 | if ($folders == 0 && $files == 0) { |
| 467 | - echo '<tr><td colspan="4"><i class="' . $_style['files_deleted_folder'] . ' FilesDeletedFolder"></i> <span style="color:#888;cursor:default;"> ' . $_lang['files_directory_is_empty'] . ' </span></td></tr>'; |
|
| 467 | + echo '<tr><td colspan="4"><i class="'.$_style['files_deleted_folder'].' FilesDeletedFolder"></i> <span style="color:#888;cursor:default;"> '.$_lang['files_directory_is_empty'].' </span></td></tr>'; |
|
| 468 | 468 | } |
| 469 | 469 | ?> |
| 470 | 470 | </table> |
@@ -473,10 +473,10 @@ discard block |
||
| 473 | 473 | <div class="container"> |
| 474 | 474 | <p> |
| 475 | 475 | <?php |
| 476 | - echo $_lang['files_directories'] . ': <b>' . $folders . '</b> '; |
|
| 477 | - echo $_lang['files_files'] . ': <b>' . $files . '</b> '; |
|
| 478 | - echo $_lang['files_data'] . ': <b><span dir="ltr">' . $modx->nicesize($filesizes) . '</span></b> '; |
|
| 479 | - echo $_lang['files_dirwritable'] . ' <b>' . (is_writable($startpath) == 1 ? $_lang['yes'] . '.' : $_lang['no']) . '.</b>' |
|
| 476 | + echo $_lang['files_directories'].': <b>'.$folders.'</b> '; |
|
| 477 | + echo $_lang['files_files'].': <b>'.$files.'</b> '; |
|
| 478 | + echo $_lang['files_data'].': <b><span dir="ltr">'.$modx->nicesize($filesizes).'</span></b> '; |
|
| 479 | + echo $_lang['files_dirwritable'].' <b>'.(is_writable($startpath) == 1 ? $_lang['yes'].'.' : $_lang['no']).'.</b>' |
|
| 480 | 480 | ?> |
| 481 | 481 | </p> |
| 482 | 482 | |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | </form> |
| 502 | 502 | <?php |
| 503 | 503 | } else { |
| 504 | - echo "<p>" . $_lang['files_upload_inhibited_msg'] . "</p>"; |
|
| 504 | + echo "<p>".$_lang['files_upload_inhibited_msg']."</p>"; |
|
| 505 | 505 | } |
| 506 | 506 | ?> |
| 507 | 507 | <div id="imageviewer"></div> |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | if ($file == $selFile) { |
| 587 | 587 | $icon = isset($icons[$mode]) ? $icons[$mode] : $icons['default']; |
| 588 | 588 | } |
| 589 | - return '<i class="' . $icon . ' FilesPage"></i>'; |
|
| 589 | + return '<i class="'.$icon.' FilesPage"></i>'; |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | /** |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | ); |
| 605 | 605 | if ($file == $selFile) { |
| 606 | 606 | $class = isset($classNames[$mode]) ? $classNames[$mode] : $classNames['default']; |
| 607 | - return ' class="' . $class . '"'; |
|
| 607 | + return ' class="'.$class.'"'; |
|
| 608 | 608 | } |
| 609 | 609 | return ''; |
| 610 | 610 | } |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | global $excludes, $protected_path, $editablefiles, $inlineviewablefiles, $viewablefiles, $enablefileunzip, $enablefiledownload, $uploadablefiles, $folders, $files, $filesizes, $len, $dirs_array, $files_array, $webstart_path, $modx; |
| 619 | 619 | $dircounter = 0; |
| 620 | 620 | $filecounter = 0; |
| 621 | - $curpath = str_replace('//', '/', $curpath . '/'); |
|
| 621 | + $curpath = str_replace('//', '/', $curpath.'/'); |
|
| 622 | 622 | |
| 623 | 623 | if (!is_dir($curpath)) { |
| 624 | 624 | echo 'Invalid path "', $curpath, '"<br />'; |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | // first, get info |
| 630 | 630 | foreach ($dir as $file) { |
| 631 | - $newpath = $curpath . $file; |
|
| 631 | + $newpath = $curpath.$file; |
|
| 632 | 632 | if ($file === '..' || $file === '.') { |
| 633 | 633 | continue; |
| 634 | 634 | } |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | if ($file === '..' || $file === '.') { |
| 639 | 639 | continue; |
| 640 | 640 | } elseif (!in_array($file, $excludes) && !in_array($newpath, $protected_path)) { |
| 641 | - $dirs_array[$dircounter]['text'] = '<i class="' . $_style['files_folder'] . ' FilesFolder"></i> <a href="index.php?a=31&mode=drill&path=' . urlencode($newpath) . '"><b>' . $file . '</b></a>'; |
|
| 641 | + $dirs_array[$dircounter]['text'] = '<i class="'.$_style['files_folder'].' FilesFolder"></i> <a href="index.php?a=31&mode=drill&path='.urlencode($newpath).'"><b>'.$file.'</b></a>'; |
|
| 642 | 642 | |
| 643 | 643 | $dfiles = scandir($newpath); |
| 644 | 644 | foreach ($dfiles as $i => $infile) { |
@@ -651,13 +651,13 @@ discard block |
||
| 651 | 651 | } |
| 652 | 652 | $file_exists = (0 < count($dfiles)) ? 'file_exists' : ''; |
| 653 | 653 | |
| 654 | - $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<a href="javascript: deleteFolder(\'' . urlencode($file) . '\',\'' . $file_exists . '\');"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_folder'] . '"></i></a>' : ''; |
|
| 654 | + $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<a href="javascript: deleteFolder(\''.urlencode($file).'\',\''.$file_exists.'\');"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_folder'].'"></i></a>' : ''; |
|
| 655 | 655 | } else { |
| 656 | - $dirs_array[$dircounter]['text'] = '<span><i class="' . $_style['files_deleted_folder'] . ' FilesDeletedFolder"></i> ' . $file . '</span>'; |
|
| 657 | - $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<span class="disabled"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_folder'] . '"></i></span>' : ''; |
|
| 656 | + $dirs_array[$dircounter]['text'] = '<span><i class="'.$_style['files_deleted_folder'].' FilesDeletedFolder"></i> '.$file.'</span>'; |
|
| 657 | + $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<span class="disabled"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_folder'].'"></i></span>' : ''; |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - $dirs_array[$dircounter]['rename'] = is_writable($curpath) ? '<a href="javascript:renameFolder(\'' . urlencode($file) . '\');"><i class="' . $_style['files_rename'] . '" title="' . $_lang['rename'] . '"></i></a> ' : ''; |
|
| 660 | + $dirs_array[$dircounter]['rename'] = is_writable($curpath) ? '<a href="javascript:renameFolder(\''.urlencode($file).'\');"><i class="'.$_style['files_rename'].'" title="'.$_lang['rename'].'"></i></a> ' : ''; |
|
| 661 | 661 | |
| 662 | 662 | // increment the counter |
| 663 | 663 | $dircounter++; |
@@ -665,14 +665,14 @@ discard block |
||
| 665 | 665 | $type = getExtension($newpath); |
| 666 | 666 | $files_array[$filecounter]['file'] = $newpath; |
| 667 | 667 | $files_array[$filecounter]['stats'] = lstat($newpath); |
| 668 | - $files_array[$filecounter]['text'] = determineIcon($newpath, $_REQUEST['path'], $_REQUEST['mode']) . ' ' . $file; |
|
| 669 | - $files_array[$filecounter]['view'] = (in_array($type, $viewablefiles)) ? '<a href="javascript:;" onclick="viewfile(\'' . $webstart_path . substr($newpath, $len, strlen($newpath)) . '\');"><i class="' . $_style['files_view'] . '" title="' . $_lang['files_viewfile'] . '"></i></a>' : (($enablefiledownload && in_array($type, $uploadablefiles)) ? '<a href="' . $webstart_path . implode('/', array_map('rawurlencode', explode('/', substr($newpath, $len, strlen($newpath))))) . '" style="cursor:pointer;"><i class="' . $_style['files_download'] . '" title="' . $_lang['file_download_file'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_view'] . '" title="' . $_lang['files_viewfile'] . '"></i></span>'); |
|
| 670 | - $files_array[$filecounter]['view'] = (in_array($type, $inlineviewablefiles)) ? '<a href="index.php?a=31&mode=view&path=' . urlencode($newpath) . '"><i class="' . $_style['files_view'] . '" title="' . $_lang['files_viewfile'] . '"></i></a>' : $files_array[$filecounter]['view']; |
|
| 671 | - $files_array[$filecounter]['unzip'] = ($enablefileunzip && $type == '.zip') ? '<a href="javascript:unzipFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_unzip'] . '" title="' . $_lang['file_download_unzip'] . '"></i></a>' : ''; |
|
| 672 | - $files_array[$filecounter]['edit'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="index.php?a=31&mode=edit&path=' . urlencode($newpath) . '#file_editfile"><i class="' . $_style['files_edit'] . '" title="' . $_lang['files_editfile'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_edit'] . '" title="' . $_lang['files_editfile'] . '"></i></span>'; |
|
| 673 | - $files_array[$filecounter]['duplicate'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:duplicateFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_duplicate'] . '" title="' . $_lang['duplicate'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_duplicate'] . '" align="absmiddle" title="' . $_lang['duplicate'] . '"></i></span>'; |
|
| 674 | - $files_array[$filecounter]['rename'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:renameFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_rename'] . '" align="absmiddle" title="' . $_lang['rename'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_rename'] . '" align="absmiddle" title="' . $_lang['rename'] . '"></i></span>'; |
|
| 675 | - $files_array[$filecounter]['delete'] = is_writable($curpath) && is_writable($newpath) ? '<a href="javascript:deleteFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_file'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_file'] . '"></i></span>'; |
|
| 668 | + $files_array[$filecounter]['text'] = determineIcon($newpath, $_REQUEST['path'], $_REQUEST['mode']).' '.$file; |
|
| 669 | + $files_array[$filecounter]['view'] = (in_array($type, $viewablefiles)) ? '<a href="javascript:;" onclick="viewfile(\''.$webstart_path.substr($newpath, $len, strlen($newpath)).'\');"><i class="'.$_style['files_view'].'" title="'.$_lang['files_viewfile'].'"></i></a>' : (($enablefiledownload && in_array($type, $uploadablefiles)) ? '<a href="'.$webstart_path.implode('/', array_map('rawurlencode', explode('/', substr($newpath, $len, strlen($newpath))))).'" style="cursor:pointer;"><i class="'.$_style['files_download'].'" title="'.$_lang['file_download_file'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_view'].'" title="'.$_lang['files_viewfile'].'"></i></span>'); |
|
| 670 | + $files_array[$filecounter]['view'] = (in_array($type, $inlineviewablefiles)) ? '<a href="index.php?a=31&mode=view&path='.urlencode($newpath).'"><i class="'.$_style['files_view'].'" title="'.$_lang['files_viewfile'].'"></i></a>' : $files_array[$filecounter]['view']; |
|
| 671 | + $files_array[$filecounter]['unzip'] = ($enablefileunzip && $type == '.zip') ? '<a href="javascript:unzipFile(\''.urlencode($file).'\');"><i class="'.$_style['files_unzip'].'" title="'.$_lang['file_download_unzip'].'"></i></a>' : ''; |
|
| 672 | + $files_array[$filecounter]['edit'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="index.php?a=31&mode=edit&path='.urlencode($newpath).'#file_editfile"><i class="'.$_style['files_edit'].'" title="'.$_lang['files_editfile'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_edit'].'" title="'.$_lang['files_editfile'].'"></i></span>'; |
|
| 673 | + $files_array[$filecounter]['duplicate'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:duplicateFile(\''.urlencode($file).'\');"><i class="'.$_style['files_duplicate'].'" title="'.$_lang['duplicate'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_duplicate'].'" align="absmiddle" title="'.$_lang['duplicate'].'"></i></span>'; |
|
| 674 | + $files_array[$filecounter]['rename'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:renameFile(\''.urlencode($file).'\');"><i class="'.$_style['files_rename'].'" align="absmiddle" title="'.$_lang['rename'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_rename'].'" align="absmiddle" title="'.$_lang['rename'].'"></i></span>'; |
|
| 675 | + $files_array[$filecounter]['delete'] = is_writable($curpath) && is_writable($newpath) ? '<a href="javascript:deleteFile(\''.urlencode($file).'\');"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_file'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_file'].'"></i></span>'; |
|
| 676 | 676 | |
| 677 | 677 | // increment the counter |
| 678 | 678 | $filecounter++; |
@@ -685,9 +685,9 @@ discard block |
||
| 685 | 685 | for ($i = 0; $i < $folders; $i++) { |
| 686 | 686 | $filesizes += $dirs_array[$i]['stats']['7']; |
| 687 | 687 | echo '<tr>'; |
| 688 | - echo '<td>' . $dirs_array[$i]['text'] . '</td>'; |
|
| 689 | - echo '<td class="text-nowrap">' . $modx->toDateFormat($dirs_array[$i]['stats']['9']) . '</td>'; |
|
| 690 | - echo '<td class="text-right">' . $modx->nicesize($dirs_array[$i]['stats']['7']) . '</td>'; |
|
| 688 | + echo '<td>'.$dirs_array[$i]['text'].'</td>'; |
|
| 689 | + echo '<td class="text-nowrap">'.$modx->toDateFormat($dirs_array[$i]['stats']['9']).'</td>'; |
|
| 690 | + echo '<td class="text-right">'.$modx->nicesize($dirs_array[$i]['stats']['7']).'</td>'; |
|
| 691 | 691 | echo '<td class="actions text-right">'; |
| 692 | 692 | echo $dirs_array[$i]['rename']; |
| 693 | 693 | echo $dirs_array[$i]['delete']; |
@@ -700,10 +700,10 @@ discard block |
||
| 700 | 700 | sort($files_array); // sorting the array alphabetically (Thanks pxl8r!) |
| 701 | 701 | for ($i = 0; $i < $files; $i++) { |
| 702 | 702 | $filesizes += $files_array[$i]['stats']['7']; |
| 703 | - echo '<tr ' . markRow($files_array[$i]['file'], $_REQUEST['path'], $_REQUEST['mode']) . '>'; |
|
| 704 | - echo '<td>' . $files_array[$i]['text'] . '</td>'; |
|
| 705 | - echo '<td class="text-nowrap">' . $modx->toDateFormat($files_array[$i]['stats']['9']) . '</td>'; |
|
| 706 | - echo '<td class="text-right">' . $modx->nicesize($files_array[$i]['stats']['7']) . '</td>'; |
|
| 703 | + echo '<tr '.markRow($files_array[$i]['file'], $_REQUEST['path'], $_REQUEST['mode']).'>'; |
|
| 704 | + echo '<td>'.$files_array[$i]['text'].'</td>'; |
|
| 705 | + echo '<td class="text-nowrap">'.$modx->toDateFormat($files_array[$i]['stats']['9']).'</td>'; |
|
| 706 | + echo '<td class="text-right">'.$modx->nicesize($files_array[$i]['stats']['7']).'</td>'; |
|
| 707 | 707 | echo '<td class="actions text-right">'; |
| 708 | 708 | echo $files_array[$i]['unzip']; |
| 709 | 709 | echo $files_array[$i]['view']; |
@@ -840,17 +840,17 @@ discard block |
||
| 840 | 840 | $zip = zip_open($file); |
| 841 | 841 | if ($zip) { |
| 842 | 842 | $old_umask = umask(0); |
| 843 | - $path = rtrim($path, '/') . '/'; |
|
| 843 | + $path = rtrim($path, '/').'/'; |
|
| 844 | 844 | while ($zip_entry = zip_read($zip)) { |
| 845 | 845 | if (zip_entry_filesize($zip_entry) > 0) { |
| 846 | 846 | // str_replace must be used under windows to convert "/" into "\" |
| 847 | 847 | $zip_entry_name = zip_entry_name($zip_entry); |
| 848 | - $complete_path = $path . str_replace('\\', '/', dirname($zip_entry_name)); |
|
| 849 | - $complete_name = $path . str_replace('\\', '/', $zip_entry_name); |
|
| 848 | + $complete_path = $path.str_replace('\\', '/', dirname($zip_entry_name)); |
|
| 849 | + $complete_name = $path.str_replace('\\', '/', $zip_entry_name); |
|
| 850 | 850 | if (!file_exists($complete_path)) { |
| 851 | 851 | $tmp = ''; |
| 852 | 852 | foreach (explode('/', $complete_path) AS $k) { |
| 853 | - $tmp .= $k . '/'; |
|
| 853 | + $tmp .= $k.'/'; |
|
| 854 | 854 | if (!is_dir($tmp)) { |
| 855 | 855 | mkdir($tmp, 0777); |
| 856 | 856 | } |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | */ |
| 876 | 876 | function rrmdir($dir) |
| 877 | 877 | { |
| 878 | - foreach (glob($dir . '/*') as $file) { |
|
| 878 | + foreach (glob($dir.'/*') as $file) { |
|
| 879 | 879 | if (is_dir($file)) { |
| 880 | 880 | rrmdir($file); |
| 881 | 881 | } else { |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | $msg = ''; |
| 895 | 895 | foreach ($_FILES['userfile']['name'] as $i => $name) { |
| 896 | 896 | if (empty($_FILES['userfile']['tmp_name'][$i])) continue; |
| 897 | - $userfile= array(); |
|
| 897 | + $userfile = array(); |
|
| 898 | 898 | |
| 899 | 899 | $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; |
| 900 | 900 | $userfile['error'] = $_FILES['userfile']['error'][$i]; |
@@ -911,12 +911,12 @@ discard block |
||
| 911 | 911 | $userfile['type'] = $_FILES['userfile']['type'][$i]; |
| 912 | 912 | |
| 913 | 913 | // this seems to be an upload action. |
| 914 | - $path = $modx->config['site_url'] . substr($startpath, strlen($filemanager_path), strlen($startpath)); |
|
| 915 | - $path = rtrim($path, '/') . '/' . $userfile['name']; |
|
| 914 | + $path = $modx->config['site_url'].substr($startpath, strlen($filemanager_path), strlen($startpath)); |
|
| 915 | + $path = rtrim($path, '/').'/'.$userfile['name']; |
|
| 916 | 916 | $msg .= $path; |
| 917 | 917 | if ($userfile['error'] == 0) { |
| 918 | - $img = (strpos($userfile['type'], 'image') !== false) ? '<br /><img src="' . $path . '" height="75" />' : ''; |
|
| 919 | - $msg .= "<p>" . $_lang['files_file_type'] . $userfile['type'] . ", " . $modx->nicesize(filesize($userfile['tmp_name'])) . $img . '</p>'; |
|
| 918 | + $img = (strpos($userfile['type'], 'image') !== false) ? '<br /><img src="'.$path.'" height="75" />' : ''; |
|
| 919 | + $msg .= "<p>".$_lang['files_file_type'].$userfile['type'].", ".$modx->nicesize(filesize($userfile['tmp_name'])).$img.'</p>'; |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | $userfilename = $userfile['tmp_name']; |
@@ -924,15 +924,15 @@ discard block |
||
| 924 | 924 | if (is_uploaded_file($userfilename)) { |
| 925 | 925 | // file is uploaded file, process it! |
| 926 | 926 | if (!checkExtension($userfile['name'])) { |
| 927 | - $msg .= '<p><span class="warning">' . $_lang['files_filetype_notok'] . '</span></p>'; |
|
| 927 | + $msg .= '<p><span class="warning">'.$_lang['files_filetype_notok'].'</span></p>'; |
|
| 928 | 928 | } else { |
| 929 | - if (@move_uploaded_file($userfile['tmp_name'], $_POST['path'] . '/' . $userfile['name'])) { |
|
| 929 | + if (@move_uploaded_file($userfile['tmp_name'], $_POST['path'].'/'.$userfile['name'])) { |
|
| 930 | 930 | // Ryan: Repair broken permissions issue with file manager |
| 931 | 931 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
| 932 | - @chmod($_POST['path'] . "/" . $userfile['name'], $new_file_permissions); |
|
| 932 | + @chmod($_POST['path']."/".$userfile['name'], $new_file_permissions); |
|
| 933 | 933 | } |
| 934 | 934 | // Ryan: End |
| 935 | - $msg .= '<p><span class="success">' . $_lang['files_upload_ok'] . '</span></p><hr/>'; |
|
| 935 | + $msg .= '<p><span class="success">'.$_lang['files_upload_ok'].'</span></p><hr/>'; |
|
| 936 | 936 | |
| 937 | 937 | // invoke OnFileManagerUpload event |
| 938 | 938 | $modx->invokeEvent('OnFileManagerUpload', array( |
@@ -940,13 +940,13 @@ discard block |
||
| 940 | 940 | 'filename' => $userfile['name'] |
| 941 | 941 | )); |
| 942 | 942 | // Log the change |
| 943 | - logFileChange('upload', $_POST['path'] . '/' . $userfile['name']); |
|
| 943 | + logFileChange('upload', $_POST['path'].'/'.$userfile['name']); |
|
| 944 | 944 | } else { |
| 945 | - $msg .= '<p><span class="warning">' . $_lang['files_upload_copyfailed'] . '</span> ' . $_lang["files_upload_permissions_error"] . '</p>'; |
|
| 945 | + $msg .= '<p><span class="warning">'.$_lang['files_upload_copyfailed'].'</span> '.$_lang["files_upload_permissions_error"].'</p>'; |
|
| 946 | 946 | } |
| 947 | 947 | } |
| 948 | 948 | } else { |
| 949 | - $msg .= '<br /><span class="warning"><b>' . $_lang['files_upload_error'] . ':</b>'; |
|
| 949 | + $msg .= '<br /><span class="warning"><b>'.$_lang['files_upload_error'].':</b>'; |
|
| 950 | 950 | switch ($userfile['error']) { |
| 951 | 951 | case 0: //no error; possible file attack! |
| 952 | 952 | $msg .= $_lang['files_upload_error0']; |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | $msg .= '</span><br />'; |
| 971 | 971 | } |
| 972 | 972 | } |
| 973 | - return $msg . '<br/>'; |
|
| 973 | + return $msg.'<br/>'; |
|
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | /** |
@@ -986,9 +986,9 @@ discard block |
||
| 986 | 986 | |
| 987 | 987 | // Write $content to our opened file. |
| 988 | 988 | if (file_put_contents($filename, $content) === false) { |
| 989 | - $msg .= '<span class="warning"><b>' . $_lang['file_not_saved'] . '</b></span><br /><br />'; |
|
| 989 | + $msg .= '<span class="warning"><b>'.$_lang['file_not_saved'].'</b></span><br /><br />'; |
|
| 990 | 990 | } else { |
| 991 | - $msg .= '<span class="success"><b>' . $_lang['file_saved'] . '</b></span><br /><br />'; |
|
| 991 | + $msg .= '<span class="success"><b>'.$_lang['file_saved'].'</b></span><br /><br />'; |
|
| 992 | 992 | $_REQUEST['mode'] = 'edit'; |
| 993 | 993 | } |
| 994 | 994 | // Log the change |
@@ -1007,9 +1007,9 @@ discard block |
||
| 1007 | 1007 | |
| 1008 | 1008 | $file = $_REQUEST['path']; |
| 1009 | 1009 | if (!$token_check || !@unlink($file)) { |
| 1010 | - $msg .= '<span class="warning"><b>' . $_lang['file_not_deleted'] . '</b></span><br /><br />'; |
|
| 1010 | + $msg .= '<span class="warning"><b>'.$_lang['file_not_deleted'].'</b></span><br /><br />'; |
|
| 1011 | 1011 | } else { |
| 1012 | - $msg .= '<span class="success"><b>' . $_lang['file_deleted'] . '</b></span><br /><br />'; |
|
| 1012 | + $msg .= '<span class="success"><b>'.$_lang['file_deleted'].'</b></span><br /><br />'; |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | // Log the change |
@@ -893,7 +893,9 @@ |
||
| 893 | 893 | global $modx, $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions; |
| 894 | 894 | $msg = ''; |
| 895 | 895 | foreach ($_FILES['userfile']['name'] as $i => $name) { |
| 896 | - if (empty($_FILES['userfile']['tmp_name'][$i])) continue; |
|
| 896 | + if (empty($_FILES['userfile']['tmp_name'][$i])) { |
|
| 897 | + continue; |
|
| 898 | + } |
|
| 897 | 899 | $userfile= array(); |
| 898 | 900 | |
| 899 | 901 | $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; |
@@ -344,7 +344,7 @@ |
||
| 344 | 344 | |
| 345 | 345 | /** |
| 346 | 346 | * @param string $filepath |
| 347 | - * @return bool|string |
|
| 347 | + * @return null|string |
|
| 348 | 348 | */ |
| 349 | 349 | function getFileContent($filepath) { |
| 350 | 350 | global $_lang; |
@@ -1,17 +1,17 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
| 3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('import_static')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | // Files to upload |
| 10 | 10 | $allowedfiles = array( |
| 11 | - 'html', |
|
| 12 | - 'htm', |
|
| 13 | - 'shtml', |
|
| 14 | - 'xml' |
|
| 11 | + 'html', |
|
| 12 | + 'htm', |
|
| 13 | + 'shtml', |
|
| 14 | + 'xml' |
|
| 15 | 15 | ); |
| 16 | 16 | ?> |
| 17 | 17 | <script language="javascript"> |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | <div class="tab-page"> |
| 44 | 44 | <div class="container container-body"> |
| 45 | 45 | <?php |
| 46 | - if(!isset($_POST['import'])) { |
|
| 47 | - echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 48 | - ?> |
|
| 46 | + if(!isset($_POST['import'])) { |
|
| 47 | + echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 48 | + ?> |
|
| 49 | 49 | <form action="index.php" method="post" name="importFrm"> |
| 50 | 50 | <input type="hidden" name="import" value="import" /> |
| 51 | 51 | <input type="hidden" name="a" value="95" /> |
@@ -85,18 +85,18 @@ discard block |
||
| 85 | 85 | <a href="javascript:;" class="btn btn-primary" onclick="window.importFrm.submit();"><i class="<?= $_style["actions_save"] ?>"></i> <?= $_lang["import_site_start"] ?></a> |
| 86 | 86 | </form> |
| 87 | 87 | <?php |
| 88 | - } else { |
|
| 89 | - run(); |
|
| 90 | - $modx->clearCache('full'); |
|
| 91 | - ?> |
|
| 88 | + } else { |
|
| 89 | + run(); |
|
| 90 | + $modx->clearCache('full'); |
|
| 91 | + ?> |
|
| 92 | 92 | <a href="javascript:;" class="btn btn-primary" onclick="window.location.href='index.php?a=2';"><i class="<?= $_style["actions_close"] ?>"></i> <?= $_lang["close"] ?></a> |
| 93 | 93 | <script type="text/javascript"> |
| 94 | 94 | top.mainMenu.reloadtree(); |
| 95 | 95 | parent.tree.ca = 'open'; |
| 96 | 96 | </script> |
| 97 | 97 | <?php |
| 98 | - } |
|
| 99 | - ?> |
|
| 98 | + } |
|
| 99 | + ?> |
|
| 100 | 100 | </div> |
| 101 | 101 | </div> |
| 102 | 102 | |
@@ -105,64 +105,64 @@ discard block |
||
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | 107 | function run() { |
| 108 | - global $modx, $_lang; |
|
| 108 | + global $modx, $_lang; |
|
| 109 | 109 | |
| 110 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 111 | - $output = ''; |
|
| 112 | - $maxtime = $_POST['maxtime']; |
|
| 110 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 111 | + $output = ''; |
|
| 112 | + $maxtime = $_POST['maxtime']; |
|
| 113 | 113 | |
| 114 | - if(!is_numeric($maxtime)) { |
|
| 115 | - $maxtime = 30; |
|
| 116 | - } |
|
| 114 | + if(!is_numeric($maxtime)) { |
|
| 115 | + $maxtime = 30; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - @set_time_limit($maxtime); |
|
| 118 | + @set_time_limit($maxtime); |
|
| 119 | 119 | |
| 120 | - $mtime = microtime(); |
|
| 121 | - $mtime = explode(' ', $mtime); |
|
| 122 | - $mtime = $mtime[1] + $mtime[0]; |
|
| 123 | - $importstart = $mtime; |
|
| 120 | + $mtime = microtime(); |
|
| 121 | + $mtime = explode(' ', $mtime); |
|
| 122 | + $mtime = $mtime[1] + $mtime[0]; |
|
| 123 | + $importstart = $mtime; |
|
| 124 | 124 | |
| 125 | - if($_POST['reset'] == 'on') { |
|
| 126 | - $modx->db->truncate($tbl_site_content); |
|
| 127 | - $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1"); |
|
| 128 | - } |
|
| 125 | + if($_POST['reset'] == 'on') { |
|
| 126 | + $modx->db->truncate($tbl_site_content); |
|
| 127 | + $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1"); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - $parent = (int)$_POST['parent']; |
|
| 130 | + $parent = (int)$_POST['parent']; |
|
| 131 | 131 | |
| 132 | - if(is_dir(MODX_BASE_PATH . 'temp/import')) { |
|
| 133 | - $filedir = MODX_BASE_PATH . 'temp/import/'; |
|
| 134 | - } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) { |
|
| 135 | - $filedir = MODX_BASE_PATH . 'assets/import/'; |
|
| 136 | - } else { |
|
| 132 | + if(is_dir(MODX_BASE_PATH . 'temp/import')) { |
|
| 133 | + $filedir = MODX_BASE_PATH . 'temp/import/'; |
|
| 134 | + } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) { |
|
| 135 | + $filedir = MODX_BASE_PATH . 'assets/import/'; |
|
| 136 | + } else { |
|
| 137 | 137 | $filedir = ''; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $filesfound = 0; |
|
| 140 | + $filesfound = 0; |
|
| 141 | 141 | |
| 142 | - $files = getFiles($filedir); |
|
| 143 | - $files = pop_index($files); |
|
| 142 | + $files = getFiles($filedir); |
|
| 143 | + $files = pop_index($files); |
|
| 144 | 144 | |
| 145 | - // no. of files to import |
|
| 146 | - $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
| 145 | + // no. of files to import |
|
| 146 | + $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
| 147 | 147 | |
| 148 | - // import files |
|
| 149 | - if(0 < count($files)) { |
|
| 150 | - $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
|
| 151 | - importFiles($parent, $filedir, $files, 'root'); |
|
| 152 | - } |
|
| 148 | + // import files |
|
| 149 | + if(0 < count($files)) { |
|
| 150 | + $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
|
| 151 | + importFiles($parent, $filedir, $files, 'root'); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - $mtime = microtime(); |
|
| 155 | - $mtime = explode(' ', $mtime); |
|
| 156 | - $mtime = $mtime[1] + $mtime[0]; |
|
| 157 | - $importend = $mtime; |
|
| 158 | - $totaltime = ($importend - $importstart); |
|
| 159 | - $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
| 154 | + $mtime = microtime(); |
|
| 155 | + $mtime = explode(' ', $mtime); |
|
| 156 | + $mtime = $mtime[1] + $mtime[0]; |
|
| 157 | + $importend = $mtime; |
|
| 158 | + $totaltime = ($importend - $importstart); |
|
| 159 | + $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
| 160 | 160 | |
| 161 | - if($_POST['convert_link'] == 'on') { |
|
| 162 | - convertLink(); |
|
| 163 | - } |
|
| 161 | + if($_POST['convert_link'] == 'on') { |
|
| 162 | + convertLink(); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - return $output; |
|
| 165 | + return $output; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -172,144 +172,144 @@ discard block |
||
| 172 | 172 | * @param string $mode |
| 173 | 173 | */ |
| 174 | 174 | function importFiles($parent, $filedir, $files, $mode) { |
| 175 | - global $modx; |
|
| 176 | - global $_lang, $allowedfiles; |
|
| 177 | - global $search_default, $cache_default, $publish_default; |
|
| 178 | - |
|
| 179 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 180 | - $tbl_system_settings = $modx->getFullTableName('system_settings'); |
|
| 181 | - |
|
| 182 | - $createdby = $modx->getLoginUserID(); |
|
| 183 | - if(!is_array($files)) { |
|
| 184 | - return; |
|
| 185 | - } |
|
| 186 | - if($_POST['object'] === 'all') { |
|
| 187 | - $modx->config['default_template'] = '0'; |
|
| 188 | - $richtext = '0'; |
|
| 189 | - } else { |
|
| 190 | - $richtext = '1'; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - foreach($files as $id => $value) { |
|
| 194 | - if(is_array($value)) { |
|
| 195 | - // create folder |
|
| 196 | - $alias = $id; |
|
| 197 | - printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 198 | - $field = array(); |
|
| 199 | - $field['type'] = 'document'; |
|
| 200 | - $field['contentType'] = 'text/html'; |
|
| 201 | - $field['published'] = $publish_default; |
|
| 202 | - $field['parent'] = $parent; |
|
| 203 | - $field['alias'] = $modx->stripAlias($alias); |
|
| 204 | - $field['richtext'] = $richtext; |
|
| 205 | - $field['template'] = $modx->config['default_template']; |
|
| 206 | - $field['searchable'] = $search_default; |
|
| 207 | - $field['cacheable'] = $cache_default; |
|
| 208 | - $field['createdby'] = $createdby; |
|
| 209 | - $field['isfolder'] = 1; |
|
| 210 | - $field['menuindex'] = 1; |
|
| 211 | - $find = false; |
|
| 212 | - foreach(array( |
|
| 213 | - 'index.html', |
|
| 214 | - 'index.htm' |
|
| 215 | - ) as $filename) { |
|
| 216 | - $filepath = $filedir . $alias . '/' . $filename; |
|
| 217 | - if($find === false && file_exists($filepath)) { |
|
| 218 | - $file = getFileContent($filepath); |
|
| 219 | - list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 220 | - |
|
| 221 | - $date = filemtime($filepath); |
|
| 222 | - $field['pagetitle'] = $pagetitle; |
|
| 223 | - $field['longtitle'] = $pagetitle; |
|
| 224 | - $field['description'] = $description; |
|
| 225 | - $field['content'] = $modx->db->escape($content); |
|
| 226 | - $field['createdon'] = $date; |
|
| 227 | - $field['editedon'] = $date; |
|
| 228 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 229 | - if($newid) { |
|
| 230 | - $find = true; |
|
| 231 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 232 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 233 | - } else { |
|
| 234 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 235 | - exit; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - if($find === false) { |
|
| 240 | - $date = time(); |
|
| 241 | - $field['pagetitle'] = '---'; |
|
| 242 | - $field['content'] = ''; |
|
| 243 | - $field['createdon'] = $date; |
|
| 244 | - $field['editedon'] = $date; |
|
| 245 | - $field['hidemenu'] = '1'; |
|
| 246 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 247 | - if($newid) { |
|
| 248 | - $find = true; |
|
| 249 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 250 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 251 | - } else { |
|
| 252 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 253 | - exit; |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - } else { |
|
| 257 | - // create document |
|
| 258 | - if($mode == 'sub' && $value == 'index.html') { |
|
| 259 | - continue; |
|
| 260 | - } |
|
| 261 | - $filename = $value; |
|
| 262 | - $fparts = explode('.', $value); |
|
| 263 | - $alias = $fparts[0]; |
|
| 264 | - $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
|
| 265 | - printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 266 | - |
|
| 267 | - if(!in_array($ext, $allowedfiles)) { |
|
| 268 | - echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 269 | - } else { |
|
| 270 | - $filepath = $filedir . $filename; |
|
| 271 | - $file = getFileContent($filepath); |
|
| 272 | - list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 273 | - |
|
| 274 | - $date = filemtime($filepath); |
|
| 275 | - $field = array(); |
|
| 276 | - $field['type'] = 'document'; |
|
| 277 | - $field['contentType'] = 'text/html'; |
|
| 278 | - $field['pagetitle'] = $pagetitle; |
|
| 279 | - $field['longtitle'] = $pagetitle; |
|
| 280 | - $field['description'] = $description; |
|
| 281 | - $field['alias'] = $modx->stripAlias($alias); |
|
| 282 | - $field['published'] = $publish_default; |
|
| 283 | - $field['parent'] = $parent; |
|
| 284 | - $field['content'] = $modx->db->escape($content); |
|
| 285 | - $field['richtext'] = $richtext; |
|
| 286 | - $field['template'] = $modx->config['default_template']; |
|
| 287 | - $field['searchable'] = $search_default; |
|
| 288 | - $field['cacheable'] = $cache_default; |
|
| 289 | - $field['createdby'] = $createdby; |
|
| 290 | - $field['createdon'] = $date; |
|
| 291 | - $field['editedon'] = $date; |
|
| 292 | - $field['isfolder'] = 0; |
|
| 293 | - $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
|
| 294 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 295 | - if($newid) { |
|
| 296 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 297 | - } else { |
|
| 298 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 299 | - exit; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - $is_site_start = false; |
|
| 303 | - if($filename == 'index.html') { |
|
| 304 | - $is_site_start = true; |
|
| 305 | - } |
|
| 306 | - if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 307 | - $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
|
| 308 | - $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - } |
|
| 175 | + global $modx; |
|
| 176 | + global $_lang, $allowedfiles; |
|
| 177 | + global $search_default, $cache_default, $publish_default; |
|
| 178 | + |
|
| 179 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 180 | + $tbl_system_settings = $modx->getFullTableName('system_settings'); |
|
| 181 | + |
|
| 182 | + $createdby = $modx->getLoginUserID(); |
|
| 183 | + if(!is_array($files)) { |
|
| 184 | + return; |
|
| 185 | + } |
|
| 186 | + if($_POST['object'] === 'all') { |
|
| 187 | + $modx->config['default_template'] = '0'; |
|
| 188 | + $richtext = '0'; |
|
| 189 | + } else { |
|
| 190 | + $richtext = '1'; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + foreach($files as $id => $value) { |
|
| 194 | + if(is_array($value)) { |
|
| 195 | + // create folder |
|
| 196 | + $alias = $id; |
|
| 197 | + printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 198 | + $field = array(); |
|
| 199 | + $field['type'] = 'document'; |
|
| 200 | + $field['contentType'] = 'text/html'; |
|
| 201 | + $field['published'] = $publish_default; |
|
| 202 | + $field['parent'] = $parent; |
|
| 203 | + $field['alias'] = $modx->stripAlias($alias); |
|
| 204 | + $field['richtext'] = $richtext; |
|
| 205 | + $field['template'] = $modx->config['default_template']; |
|
| 206 | + $field['searchable'] = $search_default; |
|
| 207 | + $field['cacheable'] = $cache_default; |
|
| 208 | + $field['createdby'] = $createdby; |
|
| 209 | + $field['isfolder'] = 1; |
|
| 210 | + $field['menuindex'] = 1; |
|
| 211 | + $find = false; |
|
| 212 | + foreach(array( |
|
| 213 | + 'index.html', |
|
| 214 | + 'index.htm' |
|
| 215 | + ) as $filename) { |
|
| 216 | + $filepath = $filedir . $alias . '/' . $filename; |
|
| 217 | + if($find === false && file_exists($filepath)) { |
|
| 218 | + $file = getFileContent($filepath); |
|
| 219 | + list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 220 | + |
|
| 221 | + $date = filemtime($filepath); |
|
| 222 | + $field['pagetitle'] = $pagetitle; |
|
| 223 | + $field['longtitle'] = $pagetitle; |
|
| 224 | + $field['description'] = $description; |
|
| 225 | + $field['content'] = $modx->db->escape($content); |
|
| 226 | + $field['createdon'] = $date; |
|
| 227 | + $field['editedon'] = $date; |
|
| 228 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 229 | + if($newid) { |
|
| 230 | + $find = true; |
|
| 231 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 232 | + importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 233 | + } else { |
|
| 234 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 235 | + exit; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + if($find === false) { |
|
| 240 | + $date = time(); |
|
| 241 | + $field['pagetitle'] = '---'; |
|
| 242 | + $field['content'] = ''; |
|
| 243 | + $field['createdon'] = $date; |
|
| 244 | + $field['editedon'] = $date; |
|
| 245 | + $field['hidemenu'] = '1'; |
|
| 246 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 247 | + if($newid) { |
|
| 248 | + $find = true; |
|
| 249 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 250 | + importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 251 | + } else { |
|
| 252 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 253 | + exit; |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + } else { |
|
| 257 | + // create document |
|
| 258 | + if($mode == 'sub' && $value == 'index.html') { |
|
| 259 | + continue; |
|
| 260 | + } |
|
| 261 | + $filename = $value; |
|
| 262 | + $fparts = explode('.', $value); |
|
| 263 | + $alias = $fparts[0]; |
|
| 264 | + $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
|
| 265 | + printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 266 | + |
|
| 267 | + if(!in_array($ext, $allowedfiles)) { |
|
| 268 | + echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 269 | + } else { |
|
| 270 | + $filepath = $filedir . $filename; |
|
| 271 | + $file = getFileContent($filepath); |
|
| 272 | + list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 273 | + |
|
| 274 | + $date = filemtime($filepath); |
|
| 275 | + $field = array(); |
|
| 276 | + $field['type'] = 'document'; |
|
| 277 | + $field['contentType'] = 'text/html'; |
|
| 278 | + $field['pagetitle'] = $pagetitle; |
|
| 279 | + $field['longtitle'] = $pagetitle; |
|
| 280 | + $field['description'] = $description; |
|
| 281 | + $field['alias'] = $modx->stripAlias($alias); |
|
| 282 | + $field['published'] = $publish_default; |
|
| 283 | + $field['parent'] = $parent; |
|
| 284 | + $field['content'] = $modx->db->escape($content); |
|
| 285 | + $field['richtext'] = $richtext; |
|
| 286 | + $field['template'] = $modx->config['default_template']; |
|
| 287 | + $field['searchable'] = $search_default; |
|
| 288 | + $field['cacheable'] = $cache_default; |
|
| 289 | + $field['createdby'] = $createdby; |
|
| 290 | + $field['createdon'] = $date; |
|
| 291 | + $field['editedon'] = $date; |
|
| 292 | + $field['isfolder'] = 0; |
|
| 293 | + $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
|
| 294 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 295 | + if($newid) { |
|
| 296 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 297 | + } else { |
|
| 298 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 299 | + exit; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + $is_site_start = false; |
|
| 303 | + if($filename == 'index.html') { |
|
| 304 | + $is_site_start = true; |
|
| 305 | + } |
|
| 306 | + if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 307 | + $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
|
| 308 | + $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -319,27 +319,27 @@ discard block |
||
| 319 | 319 | * @return array |
| 320 | 320 | */ |
| 321 | 321 | function getFiles($directory, $listing = array(), $count = 0) { |
| 322 | - global $_lang; |
|
| 323 | - global $filesfound; |
|
| 324 | - $dummy = $count; |
|
| 325 | - if( ! empty($directory) && $files = scandir($directory)) { |
|
| 326 | - foreach($files as $file) { |
|
| 327 | - if($file == '.' || $file == '..') { |
|
| 328 | - continue; |
|
| 329 | - } elseif($h = @opendir($directory . $file . "/")) { |
|
| 330 | - closedir($h); |
|
| 331 | - $count = -1; |
|
| 332 | - $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 333 | - } elseif(strpos($file, '.htm') !== false) { |
|
| 334 | - $listing[$dummy] = $file; |
|
| 335 | - $dummy = $dummy + 1; |
|
| 336 | - $filesfound++; |
|
| 337 | - } |
|
| 338 | - } |
|
| 339 | - } else { |
|
| 340 | - echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 341 | - } |
|
| 342 | - return ($listing); |
|
| 322 | + global $_lang; |
|
| 323 | + global $filesfound; |
|
| 324 | + $dummy = $count; |
|
| 325 | + if( ! empty($directory) && $files = scandir($directory)) { |
|
| 326 | + foreach($files as $file) { |
|
| 327 | + if($file == '.' || $file == '..') { |
|
| 328 | + continue; |
|
| 329 | + } elseif($h = @opendir($directory . $file . "/")) { |
|
| 330 | + closedir($h); |
|
| 331 | + $count = -1; |
|
| 332 | + $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 333 | + } elseif(strpos($file, '.htm') !== false) { |
|
| 334 | + $listing[$dummy] = $file; |
|
| 335 | + $dummy = $dummy + 1; |
|
| 336 | + $filesfound++; |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + } else { |
|
| 340 | + echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 341 | + } |
|
| 342 | + return ($listing); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | /** |
@@ -347,13 +347,13 @@ discard block |
||
| 347 | 347 | * @return bool|string |
| 348 | 348 | */ |
| 349 | 349 | function getFileContent($filepath) { |
| 350 | - global $_lang; |
|
| 351 | - // get the file |
|
| 352 | - if(!$buffer = file_get_contents($filepath)) { |
|
| 353 | - echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 354 | - } else { |
|
| 355 | - return $buffer; |
|
| 356 | - } |
|
| 350 | + global $_lang; |
|
| 351 | + // get the file |
|
| 352 | + if(!$buffer = file_get_contents($filepath)) { |
|
| 353 | + echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 354 | + } else { |
|
| 355 | + return $buffer; |
|
| 356 | + } |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -361,20 +361,20 @@ discard block |
||
| 361 | 361 | * @return array |
| 362 | 362 | */ |
| 363 | 363 | function pop_index($array) { |
| 364 | - $new_array = array(); |
|
| 365 | - foreach($array as $k => $v) { |
|
| 366 | - if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 367 | - $new_array[$k] = $v; |
|
| 368 | - } else { |
|
| 369 | - array_unshift($new_array, $v); |
|
| 370 | - } |
|
| 371 | - } |
|
| 372 | - foreach($array as $k => $v) { |
|
| 373 | - if(is_array($v)) { |
|
| 374 | - $new_array[$k] = $v; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - return $new_array; |
|
| 364 | + $new_array = array(); |
|
| 365 | + foreach($array as $k => $v) { |
|
| 366 | + if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 367 | + $new_array[$k] = $v; |
|
| 368 | + } else { |
|
| 369 | + array_unshift($new_array, $v); |
|
| 370 | + } |
|
| 371 | + } |
|
| 372 | + foreach($array as $k => $v) { |
|
| 373 | + if(is_array($v)) { |
|
| 374 | + $new_array[$k] = $v; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + return $new_array; |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -384,108 +384,108 @@ discard block |
||
| 384 | 384 | * @return array |
| 385 | 385 | */ |
| 386 | 386 | function treatContent($src, $filename, $alias) { |
| 387 | - global $modx; |
|
| 388 | - |
|
| 389 | - $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
|
| 390 | - |
|
| 391 | - if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 392 | - $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 393 | - $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
|
| 394 | - } else { |
|
| 395 | - $pagetitle = $alias; |
|
| 396 | - } |
|
| 397 | - if(!$pagetitle) { |
|
| 398 | - $pagetitle = $alias; |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 402 | - $description = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 403 | - $description = str_replace('[*description*]', '', $description); |
|
| 404 | - } else { |
|
| 405 | - $description = ''; |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 409 | - $content = $matches[1]; |
|
| 410 | - } else { |
|
| 411 | - $content = $src; |
|
| 412 | - $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
|
| 413 | - $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 414 | - $content = preg_replace($s, $r, $content); |
|
| 415 | - $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
|
| 416 | - } |
|
| 417 | - $content = str_replace('[*content*]', '[ *content* ]', $content); |
|
| 418 | - $content = trim($content); |
|
| 419 | - $pagetitle = $modx->db->escape($pagetitle); |
|
| 420 | - return array( |
|
| 421 | - $pagetitle, |
|
| 422 | - $content, |
|
| 423 | - $description |
|
| 424 | - ); |
|
| 387 | + global $modx; |
|
| 388 | + |
|
| 389 | + $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
|
| 390 | + |
|
| 391 | + if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 392 | + $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 393 | + $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
|
| 394 | + } else { |
|
| 395 | + $pagetitle = $alias; |
|
| 396 | + } |
|
| 397 | + if(!$pagetitle) { |
|
| 398 | + $pagetitle = $alias; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 402 | + $description = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 403 | + $description = str_replace('[*description*]', '', $description); |
|
| 404 | + } else { |
|
| 405 | + $description = ''; |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 409 | + $content = $matches[1]; |
|
| 410 | + } else { |
|
| 411 | + $content = $src; |
|
| 412 | + $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
|
| 413 | + $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 414 | + $content = preg_replace($s, $r, $content); |
|
| 415 | + $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
|
| 416 | + } |
|
| 417 | + $content = str_replace('[*content*]', '[ *content* ]', $content); |
|
| 418 | + $content = trim($content); |
|
| 419 | + $pagetitle = $modx->db->escape($pagetitle); |
|
| 420 | + return array( |
|
| 421 | + $pagetitle, |
|
| 422 | + $content, |
|
| 423 | + $description |
|
| 424 | + ); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
| 428 | 428 | * @return void |
| 429 | 429 | */ |
| 430 | 430 | function convertLink() { |
| 431 | - global $modx; |
|
| 432 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 431 | + global $modx; |
|
| 432 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 433 | 433 | |
| 434 | - $rs = $modx->db->select('id,content', $tbl_site_content); |
|
| 435 | - $p = array(); |
|
| 434 | + $rs = $modx->db->select('id,content', $tbl_site_content); |
|
| 435 | + $p = array(); |
|
| 436 | 436 | $target = array(); |
| 437 | - $dir = ''; |
|
| 438 | - while($row = $modx->db->getRow($rs)) { |
|
| 439 | - $id = $row['id']; |
|
| 440 | - $array = explode('<a href=', $row['content']); |
|
| 441 | - $c = 0; |
|
| 442 | - foreach($array as $v) { |
|
| 443 | - if($v[0] === '"') { |
|
| 444 | - $v = substr($v, 1); |
|
| 445 | - list($href, $v) = explode('"', $v, 2); |
|
| 446 | - $_ = $href; |
|
| 447 | - if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 448 | - $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 449 | - } |
|
| 450 | - if($_[0] === '/') { |
|
| 451 | - $_ = substr($_, 1); |
|
| 452 | - } |
|
| 453 | - $_ = str_replace('/index.html', '.html', $_); |
|
| 454 | - $level = substr_count($_, '../'); |
|
| 455 | - if(1 < $level) { |
|
| 456 | - if(!isset($p[$id])) { |
|
| 457 | - $p[$id] = $modx->getParentIds($id); |
|
| 458 | - } |
|
| 459 | - $k = array_keys($p[$id]); |
|
| 460 | - while(0 < $level) { |
|
| 461 | - $dir = array_shift($k); |
|
| 462 | - $level--; |
|
| 463 | - } |
|
| 464 | - if($dir != '') { |
|
| 465 | - $dir .= '/'; |
|
| 466 | - } |
|
| 467 | - } else { |
|
| 468 | - $dir = ''; |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - $_ = trim($_, './'); |
|
| 472 | - if(strpos($_, '/') !== false) { |
|
| 473 | - $_ = substr($_, strrpos($_, '/')); |
|
| 474 | - } |
|
| 475 | - $_ = $dir . str_replace('.html', '', $_); |
|
| 476 | - if(!isset($target[$_])) { |
|
| 477 | - $target[$_] = $modx->getIdFromAlias($_); |
|
| 478 | - } |
|
| 479 | - $target[$_] = trim($target[$_]); |
|
| 480 | - if(!empty($target[$_])) { |
|
| 481 | - $href = '[~' . $target[$_] . '~]'; |
|
| 482 | - } |
|
| 483 | - $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 484 | - } |
|
| 485 | - $c++; |
|
| 486 | - } |
|
| 487 | - $content = implode('', $array); |
|
| 488 | - $f['content'] = $modx->db->escape($content); |
|
| 489 | - $modx->db->update($f, $tbl_site_content, "id='{$id}'"); |
|
| 490 | - } |
|
| 437 | + $dir = ''; |
|
| 438 | + while($row = $modx->db->getRow($rs)) { |
|
| 439 | + $id = $row['id']; |
|
| 440 | + $array = explode('<a href=', $row['content']); |
|
| 441 | + $c = 0; |
|
| 442 | + foreach($array as $v) { |
|
| 443 | + if($v[0] === '"') { |
|
| 444 | + $v = substr($v, 1); |
|
| 445 | + list($href, $v) = explode('"', $v, 2); |
|
| 446 | + $_ = $href; |
|
| 447 | + if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 448 | + $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 449 | + } |
|
| 450 | + if($_[0] === '/') { |
|
| 451 | + $_ = substr($_, 1); |
|
| 452 | + } |
|
| 453 | + $_ = str_replace('/index.html', '.html', $_); |
|
| 454 | + $level = substr_count($_, '../'); |
|
| 455 | + if(1 < $level) { |
|
| 456 | + if(!isset($p[$id])) { |
|
| 457 | + $p[$id] = $modx->getParentIds($id); |
|
| 458 | + } |
|
| 459 | + $k = array_keys($p[$id]); |
|
| 460 | + while(0 < $level) { |
|
| 461 | + $dir = array_shift($k); |
|
| 462 | + $level--; |
|
| 463 | + } |
|
| 464 | + if($dir != '') { |
|
| 465 | + $dir .= '/'; |
|
| 466 | + } |
|
| 467 | + } else { |
|
| 468 | + $dir = ''; |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + $_ = trim($_, './'); |
|
| 472 | + if(strpos($_, '/') !== false) { |
|
| 473 | + $_ = substr($_, strrpos($_, '/')); |
|
| 474 | + } |
|
| 475 | + $_ = $dir . str_replace('.html', '', $_); |
|
| 476 | + if(!isset($target[$_])) { |
|
| 477 | + $target[$_] = $modx->getIdFromAlias($_); |
|
| 478 | + } |
|
| 479 | + $target[$_] = trim($target[$_]); |
|
| 480 | + if(!empty($target[$_])) { |
|
| 481 | + $href = '[~' . $target[$_] . '~]'; |
|
| 482 | + } |
|
| 483 | + $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 484 | + } |
|
| 485 | + $c++; |
|
| 486 | + } |
|
| 487 | + $content = implode('', $array); |
|
| 488 | + $f['content'] = $modx->db->escape($content); |
|
| 489 | + $modx->db->update($f, $tbl_site_content, "id='{$id}'"); |
|
| 490 | + } |
|
| 491 | 491 | } |
@@ -1,8 +1,8 @@ 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('import_static')) { |
|
| 5 | +if (!$modx->hasPermission('import_static')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | <div class="tab-page"> |
| 44 | 44 | <div class="container container-body"> |
| 45 | 45 | <?php |
| 46 | - if(!isset($_POST['import'])) { |
|
| 47 | - echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 46 | + if (!isset($_POST['import'])) { |
|
| 47 | + echo "<div class=\"element-edit-message\">".$_lang['import_site_message']."</div>"; |
|
| 48 | 48 | ?> |
| 49 | 49 | <form action="index.php" method="post" name="importFrm"> |
| 50 | 50 | <input type="hidden" name="import" value="import" /> |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | -function run() { |
|
| 107 | +function run(){ |
|
| 108 | 108 | global $modx, $_lang; |
| 109 | 109 | |
| 110 | 110 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 111 | 111 | $output = ''; |
| 112 | 112 | $maxtime = $_POST['maxtime']; |
| 113 | 113 | |
| 114 | - if(!is_numeric($maxtime)) { |
|
| 114 | + if (!is_numeric($maxtime)) { |
|
| 115 | 115 | $maxtime = 30; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -122,17 +122,17 @@ discard block |
||
| 122 | 122 | $mtime = $mtime[1] + $mtime[0]; |
| 123 | 123 | $importstart = $mtime; |
| 124 | 124 | |
| 125 | - if($_POST['reset'] == 'on') { |
|
| 125 | + if ($_POST['reset'] == 'on') { |
|
| 126 | 126 | $modx->db->truncate($tbl_site_content); |
| 127 | 127 | $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1"); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $parent = (int)$_POST['parent']; |
|
| 130 | + $parent = (int) $_POST['parent']; |
|
| 131 | 131 | |
| 132 | - if(is_dir(MODX_BASE_PATH . 'temp/import')) { |
|
| 133 | - $filedir = MODX_BASE_PATH . 'temp/import/'; |
|
| 134 | - } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) { |
|
| 135 | - $filedir = MODX_BASE_PATH . 'assets/import/'; |
|
| 132 | + if (is_dir(MODX_BASE_PATH.'temp/import')) { |
|
| 133 | + $filedir = MODX_BASE_PATH.'temp/import/'; |
|
| 134 | + } elseif (is_dir(MODX_BASE_PATH.'assets/import')) { |
|
| 135 | + $filedir = MODX_BASE_PATH.'assets/import/'; |
|
| 136 | 136 | } else { |
| 137 | 137 | $filedir = ''; |
| 138 | 138 | } |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | $files = pop_index($files); |
| 144 | 144 | |
| 145 | 145 | // no. of files to import |
| 146 | - $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
| 146 | + $output .= sprintf('<p>'.$_lang['import_files_found'].'</p>', $filesfound); |
|
| 147 | 147 | |
| 148 | 148 | // import files |
| 149 | - if(0 < count($files)) { |
|
| 149 | + if (0 < count($files)) { |
|
| 150 | 150 | $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
| 151 | 151 | importFiles($parent, $filedir, $files, 'root'); |
| 152 | 152 | } |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | $mtime = $mtime[1] + $mtime[0]; |
| 157 | 157 | $importend = $mtime; |
| 158 | 158 | $totaltime = ($importend - $importstart); |
| 159 | - $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
| 159 | + $output .= sprintf('<p>'.$_lang['import_site_time'].'</p>', round($totaltime, 3)); |
|
| 160 | 160 | |
| 161 | - if($_POST['convert_link'] == 'on') { |
|
| 161 | + if ($_POST['convert_link'] == 'on') { |
|
| 162 | 162 | convertLink(); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param array $files |
| 172 | 172 | * @param string $mode |
| 173 | 173 | */ |
| 174 | -function importFiles($parent, $filedir, $files, $mode) { |
|
| 174 | +function importFiles($parent, $filedir, $files, $mode){ |
|
| 175 | 175 | global $modx; |
| 176 | 176 | global $_lang, $allowedfiles; |
| 177 | 177 | global $search_default, $cache_default, $publish_default; |
@@ -180,21 +180,21 @@ discard block |
||
| 180 | 180 | $tbl_system_settings = $modx->getFullTableName('system_settings'); |
| 181 | 181 | |
| 182 | 182 | $createdby = $modx->getLoginUserID(); |
| 183 | - if(!is_array($files)) { |
|
| 183 | + if (!is_array($files)) { |
|
| 184 | 184 | return; |
| 185 | 185 | } |
| 186 | - if($_POST['object'] === 'all') { |
|
| 186 | + if ($_POST['object'] === 'all') { |
|
| 187 | 187 | $modx->config['default_template'] = '0'; |
| 188 | 188 | $richtext = '0'; |
| 189 | 189 | } else { |
| 190 | 190 | $richtext = '1'; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - foreach($files as $id => $value) { |
|
| 194 | - if(is_array($value)) { |
|
| 193 | + foreach ($files as $id => $value) { |
|
| 194 | + if (is_array($value)) { |
|
| 195 | 195 | // create folder |
| 196 | 196 | $alias = $id; |
| 197 | - printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 197 | + printf('<span>'.$_lang['import_site_importing_document'].'</span>', $alias); |
|
| 198 | 198 | $field = array(); |
| 199 | 199 | $field['type'] = 'document'; |
| 200 | 200 | $field['contentType'] = 'text/html'; |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | $field['isfolder'] = 1; |
| 210 | 210 | $field['menuindex'] = 1; |
| 211 | 211 | $find = false; |
| 212 | - foreach(array( |
|
| 212 | + foreach (array( |
|
| 213 | 213 | 'index.html', |
| 214 | 214 | 'index.htm' |
| 215 | 215 | ) as $filename) { |
| 216 | - $filepath = $filedir . $alias . '/' . $filename; |
|
| 217 | - if($find === false && file_exists($filepath)) { |
|
| 216 | + $filepath = $filedir.$alias.'/'.$filename; |
|
| 217 | + if ($find === false && file_exists($filepath)) { |
|
| 218 | 218 | $file = getFileContent($filepath); |
| 219 | 219 | list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
| 220 | 220 | |
@@ -226,17 +226,17 @@ discard block |
||
| 226 | 226 | $field['createdon'] = $date; |
| 227 | 227 | $field['editedon'] = $date; |
| 228 | 228 | $newid = $modx->db->insert($field, $tbl_site_content); |
| 229 | - if($newid) { |
|
| 229 | + if ($newid) { |
|
| 230 | 230 | $find = true; |
| 231 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 232 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 231 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
| 232 | + importFiles($newid, $filedir.$alias.'/', $value, 'sub'); |
|
| 233 | 233 | } else { |
| 234 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 234 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
| 235 | 235 | exit; |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | - if($find === false) { |
|
| 239 | + if ($find === false) { |
|
| 240 | 240 | $date = time(); |
| 241 | 241 | $field['pagetitle'] = '---'; |
| 242 | 242 | $field['content'] = ''; |
@@ -244,30 +244,30 @@ discard block |
||
| 244 | 244 | $field['editedon'] = $date; |
| 245 | 245 | $field['hidemenu'] = '1'; |
| 246 | 246 | $newid = $modx->db->insert($field, $tbl_site_content); |
| 247 | - if($newid) { |
|
| 247 | + if ($newid) { |
|
| 248 | 248 | $find = true; |
| 249 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 250 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 249 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
| 250 | + importFiles($newid, $filedir.$alias.'/', $value, 'sub'); |
|
| 251 | 251 | } else { |
| 252 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 252 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
| 253 | 253 | exit; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } else { |
| 257 | 257 | // create document |
| 258 | - if($mode == 'sub' && $value == 'index.html') { |
|
| 258 | + if ($mode == 'sub' && $value == 'index.html') { |
|
| 259 | 259 | continue; |
| 260 | 260 | } |
| 261 | 261 | $filename = $value; |
| 262 | 262 | $fparts = explode('.', $value); |
| 263 | 263 | $alias = $fparts[0]; |
| 264 | 264 | $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
| 265 | - printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 265 | + printf("<span>".$_lang['import_site_importing_document']."</span>", $filename); |
|
| 266 | 266 | |
| 267 | - if(!in_array($ext, $allowedfiles)) { |
|
| 268 | - echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 267 | + if (!in_array($ext, $allowedfiles)) { |
|
| 268 | + echo ' - <span class="fail">'.$_lang["import_site_skip"].'</span><br />'."\n"; |
|
| 269 | 269 | } else { |
| 270 | - $filepath = $filedir . $filename; |
|
| 270 | + $filepath = $filedir.$filename; |
|
| 271 | 271 | $file = getFileContent($filepath); |
| 272 | 272 | list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
| 273 | 273 | |
@@ -292,18 +292,18 @@ discard block |
||
| 292 | 292 | $field['isfolder'] = 0; |
| 293 | 293 | $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
| 294 | 294 | $newid = $modx->db->insert($field, $tbl_site_content); |
| 295 | - if($newid) { |
|
| 296 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 295 | + if ($newid) { |
|
| 296 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
| 297 | 297 | } else { |
| 298 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 298 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
| 299 | 299 | exit; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | $is_site_start = false; |
| 303 | - if($filename == 'index.html') { |
|
| 303 | + if ($filename == 'index.html') { |
|
| 304 | 304 | $is_site_start = true; |
| 305 | 305 | } |
| 306 | - if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 306 | + if ($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 307 | 307 | $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
| 308 | 308 | $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
| 309 | 309 | } |
@@ -318,26 +318,26 @@ discard block |
||
| 318 | 318 | * @param int $count |
| 319 | 319 | * @return array |
| 320 | 320 | */ |
| 321 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
| 321 | +function getFiles($directory, $listing = array(), $count = 0){ |
|
| 322 | 322 | global $_lang; |
| 323 | 323 | global $filesfound; |
| 324 | 324 | $dummy = $count; |
| 325 | - if( ! empty($directory) && $files = scandir($directory)) { |
|
| 326 | - foreach($files as $file) { |
|
| 327 | - if($file == '.' || $file == '..') { |
|
| 325 | + if (!empty($directory) && $files = scandir($directory)) { |
|
| 326 | + foreach ($files as $file) { |
|
| 327 | + if ($file == '.' || $file == '..') { |
|
| 328 | 328 | continue; |
| 329 | - } elseif($h = @opendir($directory . $file . "/")) { |
|
| 329 | + } elseif ($h = @opendir($directory.$file."/")) { |
|
| 330 | 330 | closedir($h); |
| 331 | 331 | $count = -1; |
| 332 | - $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 333 | - } elseif(strpos($file, '.htm') !== false) { |
|
| 332 | + $listing[$file] = getFiles($directory.$file."/", array(), $count + 1); |
|
| 333 | + } elseif (strpos($file, '.htm') !== false) { |
|
| 334 | 334 | $listing[$dummy] = $file; |
| 335 | 335 | $dummy = $dummy + 1; |
| 336 | 336 | $filesfound++; |
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | } else { |
| 340 | - echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 340 | + echo '<p><span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_no_open_dir"].$directory.".</p>"; |
|
| 341 | 341 | } |
| 342 | 342 | return ($listing); |
| 343 | 343 | } |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | * @param string $filepath |
| 347 | 347 | * @return bool|string |
| 348 | 348 | */ |
| 349 | -function getFileContent($filepath) { |
|
| 349 | +function getFileContent($filepath){ |
|
| 350 | 350 | global $_lang; |
| 351 | 351 | // get the file |
| 352 | - if(!$buffer = file_get_contents($filepath)) { |
|
| 353 | - echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 352 | + if (!$buffer = file_get_contents($filepath)) { |
|
| 353 | + echo '<p><span class="fail">'.$_lang['import_site_failed']."</span> ".$_lang["import_site_failed_no_retrieve_file"].$filepath.".</p>"; |
|
| 354 | 354 | } else { |
| 355 | 355 | return $buffer; |
| 356 | 356 | } |
@@ -360,17 +360,17 @@ discard block |
||
| 360 | 360 | * @param array $array |
| 361 | 361 | * @return array |
| 362 | 362 | */ |
| 363 | -function pop_index($array) { |
|
| 363 | +function pop_index($array){ |
|
| 364 | 364 | $new_array = array(); |
| 365 | - foreach($array as $k => $v) { |
|
| 366 | - if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 365 | + foreach ($array as $k => $v) { |
|
| 366 | + if ($v !== 'index.html' && $v !== 'index.htm') { |
|
| 367 | 367 | $new_array[$k] = $v; |
| 368 | 368 | } else { |
| 369 | 369 | array_unshift($new_array, $v); |
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | - foreach($array as $k => $v) { |
|
| 373 | - if(is_array($v)) { |
|
| 372 | + foreach ($array as $k => $v) { |
|
| 373 | + if (is_array($v)) { |
|
| 374 | 374 | $new_array[$k] = $v; |
| 375 | 375 | } |
| 376 | 376 | } |
@@ -383,34 +383,34 @@ discard block |
||
| 383 | 383 | * @param string $alias |
| 384 | 384 | * @return array |
| 385 | 385 | */ |
| 386 | -function treatContent($src, $filename, $alias) { |
|
| 386 | +function treatContent($src, $filename, $alias){ |
|
| 387 | 387 | global $modx; |
| 388 | 388 | |
| 389 | 389 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
| 390 | 390 | |
| 391 | - if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 391 | + if (preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 392 | 392 | $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
| 393 | 393 | $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
| 394 | 394 | } else { |
| 395 | 395 | $pagetitle = $alias; |
| 396 | 396 | } |
| 397 | - if(!$pagetitle) { |
|
| 397 | + if (!$pagetitle) { |
|
| 398 | 398 | $pagetitle = $alias; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 401 | + if (preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 402 | 402 | $description = ($matches[1] !== '') ? $matches[1] : $filename; |
| 403 | 403 | $description = str_replace('[*description*]', '', $description); |
| 404 | 404 | } else { |
| 405 | 405 | $description = ''; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 408 | + if ((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 409 | 409 | $content = $matches[1]; |
| 410 | 410 | } else { |
| 411 | 411 | $content = $src; |
| 412 | 412 | $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
| 413 | - $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 413 | + $r = '$1'.$modx->config['modx_charset'].'$2'; |
|
| 414 | 414 | $content = preg_replace($s, $r, $content); |
| 415 | 415 | $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
| 416 | 416 | } |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | /** |
| 428 | 428 | * @return void |
| 429 | 429 | */ |
| 430 | -function convertLink() { |
|
| 430 | +function convertLink(){ |
|
| 431 | 431 | global $modx; |
| 432 | 432 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 433 | 433 | |
@@ -435,33 +435,33 @@ discard block |
||
| 435 | 435 | $p = array(); |
| 436 | 436 | $target = array(); |
| 437 | 437 | $dir = ''; |
| 438 | - while($row = $modx->db->getRow($rs)) { |
|
| 438 | + while ($row = $modx->db->getRow($rs)) { |
|
| 439 | 439 | $id = $row['id']; |
| 440 | 440 | $array = explode('<a href=', $row['content']); |
| 441 | 441 | $c = 0; |
| 442 | - foreach($array as $v) { |
|
| 443 | - if($v[0] === '"') { |
|
| 442 | + foreach ($array as $v) { |
|
| 443 | + if ($v[0] === '"') { |
|
| 444 | 444 | $v = substr($v, 1); |
| 445 | 445 | list($href, $v) = explode('"', $v, 2); |
| 446 | 446 | $_ = $href; |
| 447 | - if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 448 | - $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 447 | + if (strpos($_, $modx->config['site_url']) !== false) { |
|
| 448 | + $_ = $modx->config['base_url'].str_replace($modx->config['site_url'], '', $_); |
|
| 449 | 449 | } |
| 450 | - if($_[0] === '/') { |
|
| 450 | + if ($_[0] === '/') { |
|
| 451 | 451 | $_ = substr($_, 1); |
| 452 | 452 | } |
| 453 | 453 | $_ = str_replace('/index.html', '.html', $_); |
| 454 | 454 | $level = substr_count($_, '../'); |
| 455 | - if(1 < $level) { |
|
| 456 | - if(!isset($p[$id])) { |
|
| 455 | + if (1 < $level) { |
|
| 456 | + if (!isset($p[$id])) { |
|
| 457 | 457 | $p[$id] = $modx->getParentIds($id); |
| 458 | 458 | } |
| 459 | 459 | $k = array_keys($p[$id]); |
| 460 | - while(0 < $level) { |
|
| 460 | + while (0 < $level) { |
|
| 461 | 461 | $dir = array_shift($k); |
| 462 | 462 | $level--; |
| 463 | 463 | } |
| 464 | - if($dir != '') { |
|
| 464 | + if ($dir != '') { |
|
| 465 | 465 | $dir .= '/'; |
| 466 | 466 | } |
| 467 | 467 | } else { |
@@ -469,18 +469,18 @@ discard block |
||
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | $_ = trim($_, './'); |
| 472 | - if(strpos($_, '/') !== false) { |
|
| 472 | + if (strpos($_, '/') !== false) { |
|
| 473 | 473 | $_ = substr($_, strrpos($_, '/')); |
| 474 | 474 | } |
| 475 | - $_ = $dir . str_replace('.html', '', $_); |
|
| 476 | - if(!isset($target[$_])) { |
|
| 475 | + $_ = $dir.str_replace('.html', '', $_); |
|
| 476 | + if (!isset($target[$_])) { |
|
| 477 | 477 | $target[$_] = $modx->getIdFromAlias($_); |
| 478 | 478 | } |
| 479 | 479 | $target[$_] = trim($target[$_]); |
| 480 | - if(!empty($target[$_])) { |
|
| 481 | - $href = '[~' . $target[$_] . '~]'; |
|
| 480 | + if (!empty($target[$_])) { |
|
| 481 | + $href = '[~'.$target[$_].'~]'; |
|
| 482 | 482 | } |
| 483 | - $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 483 | + $array[$c] = '<a href="'.$href.'"'.$v; |
|
| 484 | 484 | } |
| 485 | 485 | $c++; |
| 486 | 486 | } |
@@ -104,7 +104,8 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | -function run() { |
|
| 107 | +function run() |
|
| 108 | +{ |
|
| 108 | 109 | global $modx, $_lang; |
| 109 | 110 | |
| 110 | 111 | $tbl_site_content = $modx->getFullTableName('site_content'); |
@@ -171,7 +172,8 @@ discard block |
||
| 171 | 172 | * @param array $files |
| 172 | 173 | * @param string $mode |
| 173 | 174 | */ |
| 174 | -function importFiles($parent, $filedir, $files, $mode) { |
|
| 175 | +function importFiles($parent, $filedir, $files, $mode) |
|
| 176 | +{ |
|
| 175 | 177 | global $modx; |
| 176 | 178 | global $_lang, $allowedfiles; |
| 177 | 179 | global $search_default, $cache_default, $publish_default; |
@@ -318,7 +320,8 @@ discard block |
||
| 318 | 320 | * @param int $count |
| 319 | 321 | * @return array |
| 320 | 322 | */ |
| 321 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
| 323 | +function getFiles($directory, $listing = array(), $count = 0) |
|
| 324 | +{ |
|
| 322 | 325 | global $_lang; |
| 323 | 326 | global $filesfound; |
| 324 | 327 | $dummy = $count; |
@@ -346,7 +349,8 @@ discard block |
||
| 346 | 349 | * @param string $filepath |
| 347 | 350 | * @return bool|string |
| 348 | 351 | */ |
| 349 | -function getFileContent($filepath) { |
|
| 352 | +function getFileContent($filepath) |
|
| 353 | +{ |
|
| 350 | 354 | global $_lang; |
| 351 | 355 | // get the file |
| 352 | 356 | if(!$buffer = file_get_contents($filepath)) { |
@@ -360,7 +364,8 @@ discard block |
||
| 360 | 364 | * @param array $array |
| 361 | 365 | * @return array |
| 362 | 366 | */ |
| 363 | -function pop_index($array) { |
|
| 367 | +function pop_index($array) |
|
| 368 | +{ |
|
| 364 | 369 | $new_array = array(); |
| 365 | 370 | foreach($array as $k => $v) { |
| 366 | 371 | if($v !== 'index.html' && $v !== 'index.htm') { |
@@ -383,7 +388,8 @@ discard block |
||
| 383 | 388 | * @param string $alias |
| 384 | 389 | * @return array |
| 385 | 390 | */ |
| 386 | -function treatContent($src, $filename, $alias) { |
|
| 391 | +function treatContent($src, $filename, $alias) |
|
| 392 | +{ |
|
| 387 | 393 | global $modx; |
| 388 | 394 | |
| 389 | 395 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
@@ -427,7 +433,8 @@ discard block |
||
| 427 | 433 | /** |
| 428 | 434 | * @return void |
| 429 | 435 | */ |
| 430 | -function convertLink() { |
|
| 436 | +function convertLink() |
|
| 437 | +{ |
|
| 431 | 438 | global $modx; |
| 432 | 439 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 433 | 440 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php" |
| 257 | 257 | * $extname - extension name in lowercase |
| 258 | 258 | * |
| 259 | - * @param $extname |
|
| 259 | + * @param string $extname |
|
| 260 | 260 | * @param bool $reload |
| 261 | 261 | * @return bool |
| 262 | 262 | */ |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @param int $count_attempts |
| 300 | 300 | * @param string $type $type |
| 301 | 301 | * @param string $responseCode |
| 302 | - * @return bool|null |
|
| 302 | + * @return false|null |
|
| 303 | 303 | * @global string $base_url |
| 304 | 304 | * @global string $site_url |
| 305 | 305 | */ |
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
| 1003 | - * @param $contents |
|
| 1003 | + * @param string $contents |
|
| 1004 | 1004 | * @return mixed |
| 1005 | 1005 | */ |
| 1006 | 1006 | public function RecoveryEscapedTags($contents) |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | /** |
| 1027 | - * @param $tstart |
|
| 1027 | + * @param double $tstart |
|
| 1028 | 1028 | * @return array |
| 1029 | 1029 | */ |
| 1030 | 1030 | public function getTimerStats($tstart) |
@@ -1776,7 +1776,7 @@ discard block |
||
| 1776 | 1776 | |
| 1777 | 1777 | /** |
| 1778 | 1778 | * Remove Comment-Tags from output like <!--@- Comment -@--> |
| 1779 | - * @param $content |
|
| 1779 | + * @param string $content |
|
| 1780 | 1780 | * @param string $left |
| 1781 | 1781 | * @param string $right |
| 1782 | 1782 | * @return mixed |
@@ -1949,7 +1949,7 @@ discard block |
||
| 1949 | 1949 | /** |
| 1950 | 1950 | * Run snippets as per the tags in $documentSource and replace the tags with the returned values. |
| 1951 | 1951 | * |
| 1952 | - * @param $content |
|
| 1952 | + * @param string $content |
|
| 1953 | 1953 | * @return string |
| 1954 | 1954 | * @internal param string $documentSource |
| 1955 | 1955 | */ |
@@ -2981,7 +2981,7 @@ discard block |
||
| 2981 | 2981 | |
| 2982 | 2982 | /** |
| 2983 | 2983 | * @param $templateID |
| 2984 | - * @return mixed |
|
| 2984 | + * @return string |
|
| 2985 | 2985 | */ |
| 2986 | 2986 | public function _getTemplateCodeFromDB($templateID) |
| 2987 | 2987 | { |
@@ -3022,9 +3022,9 @@ discard block |
||
| 3022 | 3022 | } |
| 3023 | 3023 | |
| 3024 | 3024 | /** |
| 3025 | - * @param $id |
|
| 3025 | + * @param integer $id |
|
| 3026 | 3026 | * @param int $top |
| 3027 | - * @return mixed |
|
| 3027 | + * @return string |
|
| 3028 | 3028 | */ |
| 3029 | 3029 | public function getUltimateParentId($id, $top = 0) |
| 3030 | 3030 | { |
@@ -3355,7 +3355,7 @@ discard block |
||
| 3355 | 3355 | * |
| 3356 | 3356 | * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role |
| 3357 | 3357 | * @param int $id Element- / Resource-id |
| 3358 | - * @return bool |
|
| 3358 | + * @return false|null |
|
| 3359 | 3359 | */ |
| 3360 | 3360 | public function lockElement($type, $id) |
| 3361 | 3361 | { |
@@ -3377,7 +3377,7 @@ discard block |
||
| 3377 | 3377 | * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role |
| 3378 | 3378 | * @param int $id Element- / Resource-id |
| 3379 | 3379 | * @param bool $includeAllUsers true = Deletes not only own user-locks |
| 3380 | - * @return bool |
|
| 3380 | + * @return false|null |
|
| 3381 | 3381 | */ |
| 3382 | 3382 | public function unlockElement($type, $id, $includeAllUsers = false) |
| 3383 | 3383 | { |
@@ -3485,7 +3485,7 @@ discard block |
||
| 3485 | 3485 | * @param array $params |
| 3486 | 3486 | * @param string $msg |
| 3487 | 3487 | * @param array $files |
| 3488 | - * @return mixed |
|
| 3488 | + * @return boolean |
|
| 3489 | 3489 | */ |
| 3490 | 3490 | public function sendmail($params = array(), $msg = '', $files = array()) |
| 3491 | 3491 | { |
@@ -3981,7 +3981,7 @@ discard block |
||
| 3981 | 3981 | * |
| 3982 | 3982 | * @param string $type |
| 3983 | 3983 | * @param bool $report |
| 3984 | - * @return bool |
|
| 3984 | + * @return boolean|null |
|
| 3985 | 3985 | */ |
| 3986 | 3986 | public function clearCache($type = '', $report = false) |
| 3987 | 3987 | { |
@@ -4348,7 +4348,7 @@ discard block |
||
| 4348 | 4348 | * - Placeholders prefix. Default: '{'. |
| 4349 | 4349 | * @param string $suffix {string} |
| 4350 | 4350 | * - Placeholders suffix. Default: '}'. |
| 4351 | - * @return bool|mixed|string {string; false} - Parsed chunk or false if $chunkArr is not array. |
|
| 4351 | + * @return false|string {string; false} - Parsed chunk or false if $chunkArr is not array. |
|
| 4352 | 4352 | * - Parsed chunk or false if $chunkArr is not array. |
| 4353 | 4353 | */ |
| 4354 | 4354 | public function parseChunk($chunkName, $chunkArr, $prefix = '{', $suffix = '}') |
@@ -5324,7 +5324,7 @@ discard block |
||
| 5324 | 5324 | * Remove event listener - only for use within the current execution cycle |
| 5325 | 5325 | * |
| 5326 | 5326 | * @param string $evtName |
| 5327 | - * @return boolean |
|
| 5327 | + * @return false|null |
|
| 5328 | 5328 | */ |
| 5329 | 5329 | public function removeEventListener($evtName) |
| 5330 | 5330 | { |
@@ -5348,7 +5348,7 @@ discard block |
||
| 5348 | 5348 | * |
| 5349 | 5349 | * @param string $evtName |
| 5350 | 5350 | * @param array $extParams Parameters available to plugins. Each array key will be the PHP variable name, and the array value will be the variable value. |
| 5351 | - * @return boolean|array |
|
| 5351 | + * @return false|null |
|
| 5352 | 5352 | */ |
| 5353 | 5353 | public function invokeEvent($evtName, $extParams = array()) |
| 5354 | 5354 | { |
@@ -5947,7 +5947,7 @@ discard block |
||
| 5947 | 5947 | |
| 5948 | 5948 | /** |
| 5949 | 5949 | * @param string $str |
| 5950 | - * @return bool|mixed|string |
|
| 5950 | + * @return string |
|
| 5951 | 5951 | */ |
| 5952 | 5952 | public function atBindFileContent($str = '') |
| 5953 | 5953 | { |
@@ -5998,8 +5998,8 @@ discard block |
||
| 5998 | 5998 | } |
| 5999 | 5999 | |
| 6000 | 6000 | /** |
| 6001 | - * @param $str |
|
| 6002 | - * @return bool|string |
|
| 6001 | + * @param string $str |
|
| 6002 | + * @return false|string |
|
| 6003 | 6003 | */ |
| 6004 | 6004 | public function getExtFromFilename($str) |
| 6005 | 6005 | { |
@@ -6027,7 +6027,7 @@ discard block |
||
| 6027 | 6027 | * @param string $text Error message |
| 6028 | 6028 | * @param string $file File where the error was detected |
| 6029 | 6029 | * @param string $line Line number within $file |
| 6030 | - * @return boolean |
|
| 6030 | + * @return boolean|null |
|
| 6031 | 6031 | */ |
| 6032 | 6032 | public function phpError($nr, $text, $file, $line) |
| 6033 | 6033 | { |
@@ -6079,7 +6079,7 @@ discard block |
||
| 6079 | 6079 | * @param string $text |
| 6080 | 6080 | * @param string $line |
| 6081 | 6081 | * @param string $output |
| 6082 | - * @return bool |
|
| 6082 | + * @return null|boolean |
|
| 6083 | 6083 | */ |
| 6084 | 6084 | public function messageQuit($msg = 'unspecified error', $query = '', $is_error = true, $nr = '', $file = '', $source = '', $text = '', $line = '', $output = '') |
| 6085 | 6085 | { |
@@ -6501,7 +6501,7 @@ discard block |
||
| 6501 | 6501 | |
| 6502 | 6502 | /** |
| 6503 | 6503 | * @param string $str |
| 6504 | - * @return bool|mixed|string |
|
| 6504 | + * @return string |
|
| 6505 | 6505 | */ |
| 6506 | 6506 | public function atBindInclude($str = '') |
| 6507 | 6507 | { |
@@ -6552,7 +6552,7 @@ discard block |
||
| 6552 | 6552 | * @param $str |
| 6553 | 6553 | * @param int $flags |
| 6554 | 6554 | * @param string $encode |
| 6555 | - * @return mixed |
|
| 6555 | + * @return string |
|
| 6556 | 6556 | */ |
| 6557 | 6557 | public function htmlspecialchars($str, $flags = ENT_COMPAT, $encode = '') |
| 6558 | 6558 | { |
@@ -6561,7 +6561,7 @@ discard block |
||
| 6561 | 6561 | } |
| 6562 | 6562 | |
| 6563 | 6563 | /** |
| 6564 | - * @param $string |
|
| 6564 | + * @param string $string |
|
| 6565 | 6565 | * @param bool $returnData |
| 6566 | 6566 | * @return bool|mixed |
| 6567 | 6567 | */ |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | function __call($method_name, $arguments) |
| 207 | 207 | { |
| 208 | - include_once(MODX_MANAGER_PATH . 'includes/extenders/deprecated.functions.inc.php'); |
|
| 208 | + include_once(MODX_MANAGER_PATH.'includes/extenders/deprecated.functions.inc.php'); |
|
| 209 | 209 | if (method_exists($this->old, $method_name)) { |
| 210 | 210 | $error_type = 1; |
| 211 | 211 | } else { |
@@ -223,12 +223,12 @@ discard block |
||
| 223 | 223 | $info = debug_backtrace(); |
| 224 | 224 | $m[] = $msg; |
| 225 | 225 | if (!empty($this->currentSnippet)) { |
| 226 | - $m[] = 'Snippet - ' . $this->currentSnippet; |
|
| 226 | + $m[] = 'Snippet - '.$this->currentSnippet; |
|
| 227 | 227 | } elseif (!empty($this->event->activePlugin)) { |
| 228 | - $m[] = 'Plugin - ' . $this->event->activePlugin; |
|
| 228 | + $m[] = 'Plugin - '.$this->event->activePlugin; |
|
| 229 | 229 | } |
| 230 | 230 | $m[] = $this->decoded_request_uri; |
| 231 | - $m[] = str_replace('\\', '/', $info[0]['file']) . '(line:' . $info[0]['line'] . ')'; |
|
| 231 | + $m[] = str_replace('\\', '/', $info[0]['file']).'(line:'.$info[0]['line'].')'; |
|
| 232 | 232 | $msg = implode('<br />', $m); |
| 233 | 233 | $this->logEvent(0, $error_type, $msg, $title); |
| 234 | 234 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | $flag = false; |
| 247 | 247 | if (is_scalar($connector) && !empty($connector) && isset($this->{$connector}) && $this->{$connector} instanceof DBAPI) { |
| 248 | - $flag = (bool)$this->{$connector}->conn; |
|
| 248 | + $flag = (bool) $this->{$connector}->conn; |
|
| 249 | 249 | } |
| 250 | 250 | return $flag; |
| 251 | 251 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | if (!$out && $flag) { |
| 274 | 274 | $extname = trim(str_replace(array('..', '/', '\\'), '', strtolower($extname))); |
| 275 | - $filename = MODX_MANAGER_PATH . "includes/extenders/ex_{$extname}.inc.php"; |
|
| 275 | + $filename = MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php"; |
|
| 276 | 276 | $out = is_file($filename) ? include $filename : false; |
| 277 | 277 | } |
| 278 | 278 | if ($out && !in_array($extname, $this->extensions)) { |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | public function getMicroTime() |
| 290 | 290 | { |
| 291 | 291 | list ($usec, $sec) = explode(' ', microtime()); |
| 292 | - return ((float)$usec + (float)$sec); |
|
| 292 | + return ((float) $usec + (float) $sec); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | // append the redirect count string to the url |
| 314 | 314 | $currentNumberOfRedirects = isset ($_REQUEST['err']) ? $_REQUEST['err'] : 0; |
| 315 | 315 | if ($currentNumberOfRedirects > 3) { |
| 316 | - $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>' . $url . '</i></p>'); |
|
| 316 | + $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>'.$url.'</i></p>'); |
|
| 317 | 317 | } else { |
| 318 | 318 | $currentNumberOfRedirects += 1; |
| 319 | 319 | if (strpos($url, "?") > 0) { |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | if ($type == 'REDIRECT_REFRESH') { |
| 327 | - $header = 'Refresh: 0;URL=' . $url; |
|
| 327 | + $header = 'Refresh: 0;URL='.$url; |
|
| 328 | 328 | } elseif ($type == 'REDIRECT_META') { |
| 329 | - $header = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=' . $url . '" />'; |
|
| 329 | + $header = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL='.$url.'" />'; |
|
| 330 | 330 | echo $header; |
| 331 | 331 | exit; |
| 332 | 332 | } elseif ($type == 'REDIRECT_HEADER' || empty ($type)) { |
@@ -334,10 +334,10 @@ discard block |
||
| 334 | 334 | global $base_url, $site_url; |
| 335 | 335 | if (substr($url, 0, strlen($base_url)) == $base_url) { |
| 336 | 336 | // append $site_url to make it work with Location: |
| 337 | - $url = $site_url . substr($url, strlen($base_url)); |
|
| 337 | + $url = $site_url.substr($url, strlen($base_url)); |
|
| 338 | 338 | } |
| 339 | 339 | if (strpos($url, "\n") === false) { |
| 340 | - $header = 'Location: ' . $url; |
|
| 340 | + $header = 'Location: '.$url; |
|
| 341 | 341 | } else { |
| 342 | 342 | $this->messageQuit('No newline allowed in redirect url.'); |
| 343 | 343 | } |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | header($responseCode); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - if(!empty($header)) { |
|
| 349 | + if (!empty($header)) { |
|
| 350 | 350 | header($header); |
| 351 | 351 | } |
| 352 | 352 | |
@@ -450,8 +450,8 @@ discard block |
||
| 450 | 450 | |
| 451 | 451 | private function recoverySiteCache() |
| 452 | 452 | { |
| 453 | - $site_cache_dir = MODX_BASE_PATH . $this->getCacheFolder(); |
|
| 454 | - $site_cache_path = $site_cache_dir . 'siteCache.idx.php'; |
|
| 453 | + $site_cache_dir = MODX_BASE_PATH.$this->getCacheFolder(); |
|
| 454 | + $site_cache_path = $site_cache_dir.'siteCache.idx.php'; |
|
| 455 | 455 | |
| 456 | 456 | if (is_file($site_cache_path)) { |
| 457 | 457 | include($site_cache_path); |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | return; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - include_once(MODX_MANAGER_PATH . 'processors/cache_sync.class.processor.php'); |
|
| 463 | + include_once(MODX_MANAGER_PATH.'processors/cache_sync.class.processor.php'); |
|
| 464 | 464 | $cache = new synccache(); |
| 465 | 465 | $cache->setCachepath($site_cache_dir); |
| 466 | 466 | $cache->setReport(false); |
@@ -512,8 +512,8 @@ discard block |
||
| 512 | 512 | $this->invokeEvent("OnBeforeManagerPageInit"); |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - if (isset ($_SESSION[$usrType . 'UsrConfigSet'])) { |
|
| 516 | - $usrSettings = &$_SESSION[$usrType . 'UsrConfigSet']; |
|
| 515 | + if (isset ($_SESSION[$usrType.'UsrConfigSet'])) { |
|
| 516 | + $usrSettings = &$_SESSION[$usrType.'UsrConfigSet']; |
|
| 517 | 517 | } else { |
| 518 | 518 | if ($usrType == 'web') { |
| 519 | 519 | $from = $tbl_web_user_settings; |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | $usrSettings[$row['setting_name']] = $row['setting_value']; |
| 534 | 534 | } |
| 535 | 535 | if (isset ($usrType)) { |
| 536 | - $_SESSION[$usrType . 'UsrConfigSet'] = $usrSettings; |
|
| 536 | + $_SESSION[$usrType.'UsrConfigSet'] = $usrSettings; |
|
| 537 | 537 | } // store user settings in session |
| 538 | 538 | } |
| 539 | 539 | } |
@@ -678,10 +678,10 @@ discard block |
||
| 678 | 678 | $suf = $this->config['friendly_url_suffix']; |
| 679 | 679 | $pre = preg_quote($pre, '/'); |
| 680 | 680 | $suf = preg_quote($suf, '/'); |
| 681 | - if ($pre && preg_match('@^' . $pre . '(.*)$@', $q, $_)) { |
|
| 681 | + if ($pre && preg_match('@^'.$pre.'(.*)$@', $q, $_)) { |
|
| 682 | 682 | $q = $_[1]; |
| 683 | 683 | } |
| 684 | - if ($suf && preg_match('@(.*)' . $suf . '$@', $q, $_)) { |
|
| 684 | + if ($suf && preg_match('@(.*)'.$suf.'$@', $q, $_)) { |
|
| 685 | 685 | $q = $_[1]; |
| 686 | 686 | } |
| 687 | 687 | |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */ |
| 704 | 704 | /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */ |
| 705 | 705 | if ($this->config['use_alias_path'] == 1) { |
| 706 | - if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) { |
|
| 706 | + if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir.'/'.$q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) { |
|
| 707 | 707 | $this->documentMethod = 'id'; |
| 708 | 708 | return $q; |
| 709 | 709 | } else { /* not a valid id in terms of virtualDir, treat as alias */ |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | */ |
| 738 | 738 | public function getHashFile($key) |
| 739 | 739 | { |
| 740 | - return $this->getCacheFolder() . "docid_" . $key . ".pageCache.php"; |
|
| 740 | + return $this->getCacheFolder()."docid_".$key.".pageCache.php"; |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | /** |
@@ -748,9 +748,9 @@ discard block |
||
| 748 | 748 | $hash = $id; |
| 749 | 749 | $tmp = null; |
| 750 | 750 | $params = array(); |
| 751 | - if(!empty($this->systemCacheKey)){ |
|
| 751 | + if (!empty($this->systemCacheKey)) { |
|
| 752 | 752 | $hash = $this->systemCacheKey; |
| 753 | - }else { |
|
| 753 | + } else { |
|
| 754 | 754 | if (!empty($_GET)) { |
| 755 | 755 | // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID. |
| 756 | 756 | $params = $_GET; |
@@ -758,8 +758,8 @@ discard block |
||
| 758 | 758 | $hash .= '_'.md5(http_build_query($params)); |
| 759 | 759 | } |
| 760 | 760 | } |
| 761 | - $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params)); |
|
| 762 | - if (is_array($evtOut) && count($evtOut) > 0){ |
|
| 761 | + $evtOut = $this->invokeEvent("OnMakePageCacheKey", array("hash" => $hash, "id" => $id, 'params' => $params)); |
|
| 762 | + if (is_array($evtOut) && count($evtOut) > 0) { |
|
| 763 | 763 | $tmp = array_pop($evtOut); |
| 764 | 764 | } |
| 765 | 765 | return empty($tmp) ? $hash : $tmp; |
@@ -901,12 +901,12 @@ discard block |
||
| 901 | 901 | if ($js = $this->getRegisteredClientStartupScripts()) { |
| 902 | 902 | // change to just before closing </head> |
| 903 | 903 | // $this->documentContent = preg_replace("/(<head[^>]*>)/i", "\\1\n".$js, $this->documentContent); |
| 904 | - $this->documentOutput = preg_replace("/(<\/head>)/i", $js . "\n\\1", $this->documentOutput); |
|
| 904 | + $this->documentOutput = preg_replace("/(<\/head>)/i", $js."\n\\1", $this->documentOutput); |
|
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | // Insert jscripts & html block into template - template must have a </body> tag |
| 908 | 908 | if ($js = $this->getRegisteredClientScripts()) { |
| 909 | - $this->documentOutput = preg_replace("/(<\/body>)/i", $js . "\n\\1", $this->documentOutput); |
|
| 909 | + $this->documentOutput = preg_replace("/(<\/body>)/i", $js."\n\\1", $this->documentOutput); |
|
| 910 | 910 | } |
| 911 | 911 | // End fix by sirlancelot |
| 912 | 912 | |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | // send out content-type and content-disposition headers |
| 918 | 918 | if (IN_PARSER_MODE == "true") { |
| 919 | 919 | $type = !empty ($this->contentTypes[$this->documentIdentifier]) ? $this->contentTypes[$this->documentIdentifier] : "text/html"; |
| 920 | - header('Content-Type: ' . $type . '; charset=' . $this->config['modx_charset']); |
|
| 920 | + header('Content-Type: '.$type.'; charset='.$this->config['modx_charset']); |
|
| 921 | 921 | // if (($this->documentIdentifier == $this->config['error_page']) || $redirect_error) |
| 922 | 922 | // header('HTTP/1.0 404 Not Found'); |
| 923 | 923 | if (!$this->checkPreview() && $this->documentObject['content_dispo'] == 1) { |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | $name = preg_replace('|-+|', '-', $name); |
| 936 | 936 | $name = trim($name, '-'); |
| 937 | 937 | } |
| 938 | - $header = 'Content-Disposition: attachment; filename=' . $name; |
|
| 938 | + $header = 'Content-Disposition: attachment; filename='.$name; |
|
| 939 | 939 | header($header); |
| 940 | 940 | } |
| 941 | 941 | } |
@@ -943,7 +943,7 @@ discard block |
||
| 943 | 943 | |
| 944 | 944 | $stats = $this->getTimerStats($this->tstart); |
| 945 | 945 | |
| 946 | - $out =& $this->documentOutput; |
|
| 946 | + $out = & $this->documentOutput; |
|
| 947 | 947 | $out = str_replace("[^q^]", $stats['queries'], $out); |
| 948 | 948 | $out = str_replace("[^qt^]", $stats['queryTime'], $out); |
| 949 | 949 | $out = str_replace("[^p^]", $stats['phpTime'], $out); |
@@ -982,17 +982,17 @@ discard block |
||
| 982 | 982 | $sc .= sprintf("%s. %s (%s)<br>", $s, $sname, sprintf("%2.2f ms", $t)); // currentSnippet |
| 983 | 983 | $tt += $t; |
| 984 | 984 | } |
| 985 | - echo "<fieldset><legend><b>Snippets</b> (" . count($this->snippetsTime) . " / " . sprintf("%2.2f ms", $tt) . ")</legend>{$sc}</fieldset><br />"; |
|
| 985 | + echo "<fieldset><legend><b>Snippets</b> (".count($this->snippetsTime)." / ".sprintf("%2.2f ms", $tt).")</legend>{$sc}</fieldset><br />"; |
|
| 986 | 986 | echo $this->snippetsCode; |
| 987 | 987 | } |
| 988 | 988 | if ($this->dumpPlugins) { |
| 989 | 989 | $ps = ""; |
| 990 | 990 | $tt = 0; |
| 991 | 991 | foreach ($this->pluginsTime as $s => $t) { |
| 992 | - $ps .= "$s (" . sprintf("%2.2f ms", $t * 1000) . ")<br>"; |
|
| 992 | + $ps .= "$s (".sprintf("%2.2f ms", $t * 1000).")<br>"; |
|
| 993 | 993 | $tt += $t; |
| 994 | 994 | } |
| 995 | - echo "<fieldset><legend><b>Plugins</b> (" . count($this->pluginsTime) . " / " . sprintf("%2.2f ms", $tt * 1000) . ")</legend>{$ps}</fieldset><br />"; |
|
| 995 | + echo "<fieldset><legend><b>Plugins</b> (".count($this->pluginsTime)." / ".sprintf("%2.2f ms", $tt * 1000).")</legend>{$ps}</fieldset><br />"; |
|
| 996 | 996 | echo $this->pluginsCode; |
| 997 | 997 | } |
| 998 | 998 | |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | $srcTags = explode(',', $tags); |
| 1019 | 1019 | $repTags = array(); |
| 1020 | 1020 | foreach ($srcTags as $tag) { |
| 1021 | - $repTags[] = '\\' . $tag[0] . '\\' . $tag[1]; |
|
| 1021 | + $repTags[] = '\\'.$tag[0].'\\'.$tag[1]; |
|
| 1022 | 1022 | } |
| 1023 | 1023 | return array($srcTags, $repTags); |
| 1024 | 1024 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | $stats['phpTime'] = sprintf("%2.4f s", $stats['phpTime']); |
| 1041 | 1041 | $stats['source'] = $this->documentGenerated == 1 ? "database" : "cache"; |
| 1042 | 1042 | $stats['queries'] = isset ($this->executedQueries) ? $this->executedQueries : 0; |
| 1043 | - $stats['phpMemory'] = (memory_get_peak_usage(true) / 1024 / 1024) . " mb"; |
|
| 1043 | + $stats['phpMemory'] = (memory_get_peak_usage(true) / 1024 / 1024)." mb"; |
|
| 1044 | 1044 | |
| 1045 | 1045 | return $stats; |
| 1046 | 1046 | } |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | { |
| 1074 | 1074 | $cacheRefreshTime = 0; |
| 1075 | 1075 | $recent_update = 0; |
| 1076 | - @include(MODX_BASE_PATH . $this->getCacheFolder() . 'sitePublishing.idx.php'); |
|
| 1076 | + @include(MODX_BASE_PATH.$this->getCacheFolder().'sitePublishing.idx.php'); |
|
| 1077 | 1077 | $this->recentUpdate = $recent_update; |
| 1078 | 1078 | |
| 1079 | 1079 | $timeNow = $_SERVER['REQUEST_TIME'] + $this->config['server_offset_time']; |
@@ -1127,8 +1127,8 @@ discard block |
||
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | $docObjSerial = serialize($this->documentObject); |
| 1130 | - $cacheContent = $docObjSerial . "<!--__MODxCacheSpliter__-->" . $this->documentContent; |
|
| 1131 | - $page_cache_path = MODX_BASE_PATH . $this->getHashFile($this->cacheKey); |
|
| 1130 | + $cacheContent = $docObjSerial."<!--__MODxCacheSpliter__-->".$this->documentContent; |
|
| 1131 | + $page_cache_path = MODX_BASE_PATH.$this->getHashFile($this->cacheKey); |
|
| 1132 | 1132 | file_put_contents($page_cache_path, "<?php die('Unauthorized access.'); ?>$cacheContent"); |
| 1133 | 1133 | } |
| 1134 | 1134 | } |
@@ -1170,16 +1170,16 @@ discard block |
||
| 1170 | 1170 | return array(); |
| 1171 | 1171 | } |
| 1172 | 1172 | $spacer = md5('<<<EVO>>>'); |
| 1173 | - if($left==='{{' && strpos($content,';}}')!==false) $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
| 1174 | - if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
| 1175 | - if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
| 1176 | - if($left==='[[' && strpos($content,']]]')!==false) $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
| 1173 | + if ($left === '{{' && strpos($content, ';}}') !== false) $content = str_replace(';}}', sprintf(';}%s}', $spacer), $content); |
|
| 1174 | + if ($left === '{{' && strpos($content, '{{}}') !== false) $content = str_replace('{{}}', sprintf('{%$1s{}%$1s}', $spacer), $content); |
|
| 1175 | + if ($left === '[[' && strpos($content, ']]]]') !== false) $content = str_replace(']]]]', sprintf(']]%s]]', $spacer), $content); |
|
| 1176 | + if ($left === '[[' && strpos($content, ']]]') !== false) $content = str_replace(']]]', sprintf(']%s]]', $spacer), $content); |
|
| 1177 | 1177 | |
| 1178 | 1178 | $pos['<![CDATA['] = strpos($content, '<![CDATA['); |
| 1179 | 1179 | $pos[']]>'] = strpos($content, ']]>'); |
| 1180 | 1180 | |
| 1181 | 1181 | if ($pos['<![CDATA['] !== false && $pos[']]>'] !== false) { |
| 1182 | - $content = substr($content, 0, $pos['<![CDATA[']) . substr($content, $pos[']]>'] + 3); |
|
| 1182 | + $content = substr($content, 0, $pos['<![CDATA[']).substr($content, $pos[']]>'] + 3); |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | $lp = explode($left, $content); |
@@ -1243,8 +1243,8 @@ discard block |
||
| 1243 | 1243 | } |
| 1244 | 1244 | } |
| 1245 | 1245 | } |
| 1246 | - foreach($tags as $i=>$tag) { |
|
| 1247 | - if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag); |
|
| 1246 | + foreach ($tags as $i=>$tag) { |
|
| 1247 | + if (strpos($tag, $spacer) !== false) $tags[$i] = str_replace($spacer, '', $tag); |
|
| 1248 | 1248 | } |
| 1249 | 1249 | return $tags; |
| 1250 | 1250 | } |
@@ -1284,7 +1284,7 @@ discard block |
||
| 1284 | 1284 | } |
| 1285 | 1285 | |
| 1286 | 1286 | foreach ($matches[1] as $i => $key) { |
| 1287 | - if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
| 1287 | + if (strpos($key, '[+') !== false) continue; // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
| 1288 | 1288 | if (substr($key, 0, 1) == '#') { |
| 1289 | 1289 | $key = substr($key, 1); |
| 1290 | 1290 | } // remove # for QuickEdit format |
@@ -1304,8 +1304,8 @@ discard block |
||
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | if (is_array($value)) { |
| 1307 | - include_once(MODX_MANAGER_PATH . 'includes/tmplvars.format.inc.php'); |
|
| 1308 | - include_once(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php'); |
|
| 1307 | + include_once(MODX_MANAGER_PATH.'includes/tmplvars.format.inc.php'); |
|
| 1308 | + include_once(MODX_MANAGER_PATH.'includes/tmplvars.commands.inc.php'); |
|
| 1309 | 1309 | $value = getTVDisplayFormat($value[0], $value[1], $value[2], $value[3], $value[4]); |
| 1310 | 1310 | } |
| 1311 | 1311 | |
@@ -1316,8 +1316,8 @@ discard block |
||
| 1316 | 1316 | |
| 1317 | 1317 | if (strpos($content, $s) !== false) { |
| 1318 | 1318 | $content = str_replace($s, $value, $content); |
| 1319 | - } elseif($this->debug) { |
|
| 1320 | - $this->addLog('mergeDocumentContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1319 | + } elseif ($this->debug) { |
|
| 1320 | + $this->addLog('mergeDocumentContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1321 | 1321 | } |
| 1322 | 1322 | } |
| 1323 | 1323 | |
@@ -1484,8 +1484,8 @@ discard block |
||
| 1484 | 1484 | $s = &$matches[0][$i]; |
| 1485 | 1485 | if (strpos($content, $s) !== false) { |
| 1486 | 1486 | $content = str_replace($s, $value, $content); |
| 1487 | - } elseif($this->debug) { |
|
| 1488 | - $this->addLog('mergeSettingsContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1487 | + } elseif ($this->debug) { |
|
| 1488 | + $this->addLog('mergeSettingsContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1489 | 1489 | } |
| 1490 | 1490 | } |
| 1491 | 1491 | return $content; |
@@ -1538,7 +1538,7 @@ discard block |
||
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | 1540 | $value = $this->parseText($value, $params); // parse local scope placeholers for ConditionalTags |
| 1541 | - $value = $this->mergePlaceholderContent($value, $params); // parse page global placeholers |
|
| 1541 | + $value = $this->mergePlaceholderContent($value, $params); // parse page global placeholers |
|
| 1542 | 1542 | if ($this->config['enable_at_syntax']) { |
| 1543 | 1543 | $value = $this->mergeConditionalTagsContent($value); |
| 1544 | 1544 | } |
@@ -1553,8 +1553,8 @@ discard block |
||
| 1553 | 1553 | $s = &$matches[0][$i]; |
| 1554 | 1554 | if (strpos($content, $s) !== false) { |
| 1555 | 1555 | $content = str_replace($s, $value, $content); |
| 1556 | - } elseif($this->debug) { |
|
| 1557 | - $this->addLog('mergeChunkContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1556 | + } elseif ($this->debug) { |
|
| 1557 | + $this->addLog('mergeChunkContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1558 | 1558 | } |
| 1559 | 1559 | } |
| 1560 | 1560 | return $content; |
@@ -1612,8 +1612,8 @@ discard block |
||
| 1612 | 1612 | $s = &$matches[0][$i]; |
| 1613 | 1613 | if (strpos($content, $s) !== false) { |
| 1614 | 1614 | $content = str_replace($s, $value, $content); |
| 1615 | - } elseif($this->debug) { |
|
| 1616 | - $this->addLog('mergePlaceholderContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1615 | + } elseif ($this->debug) { |
|
| 1616 | + $this->addLog('mergePlaceholderContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1617 | 1617 | } |
| 1618 | 1618 | } |
| 1619 | 1619 | return $content; |
@@ -1637,7 +1637,7 @@ discard block |
||
| 1637 | 1637 | return $content; |
| 1638 | 1638 | } |
| 1639 | 1639 | |
| 1640 | - $sp = '#' . md5('ConditionalTags' . $_SERVER['REQUEST_TIME']) . '#'; |
|
| 1640 | + $sp = '#'.md5('ConditionalTags'.$_SERVER['REQUEST_TIME']).'#'; |
|
| 1641 | 1641 | $content = str_replace(array('<?php', '<?=', '<?', '?>'), array("{$sp}b", "{$sp}p", "{$sp}s", "{$sp}e"), $content); |
| 1642 | 1642 | |
| 1643 | 1643 | $pieces = explode('<@IF:', $content); |
@@ -1648,7 +1648,7 @@ discard block |
||
| 1648 | 1648 | } |
| 1649 | 1649 | list($cmd, $text) = explode('>', $split, 2); |
| 1650 | 1650 | $cmd = str_replace("'", "\'", $cmd); |
| 1651 | - $content .= "<?php if(\$this->_parseCTagCMD('" . $cmd . "')): ?>"; |
|
| 1651 | + $content .= "<?php if(\$this->_parseCTagCMD('".$cmd."')): ?>"; |
|
| 1652 | 1652 | $content .= $text; |
| 1653 | 1653 | } |
| 1654 | 1654 | $pieces = explode('<@ELSEIF:', $content); |
@@ -1659,13 +1659,13 @@ discard block |
||
| 1659 | 1659 | } |
| 1660 | 1660 | list($cmd, $text) = explode('>', $split, 2); |
| 1661 | 1661 | $cmd = str_replace("'", "\'", $cmd); |
| 1662 | - $content .= "<?php elseif(\$this->_parseCTagCMD('" . $cmd . "')): ?>"; |
|
| 1662 | + $content .= "<?php elseif(\$this->_parseCTagCMD('".$cmd."')): ?>"; |
|
| 1663 | 1663 | $content .= $text; |
| 1664 | 1664 | } |
| 1665 | 1665 | |
| 1666 | 1666 | $content = str_replace(array('<@ELSE>', '<@ENDIF>'), array('<?php else:?>', '<?php endif;?>'), $content); |
| 1667 | 1667 | ob_start(); |
| 1668 | - $content = eval('?>' . $content); |
|
| 1668 | + $content = eval('?>'.$content); |
|
| 1669 | 1669 | $content = ob_get_clean(); |
| 1670 | 1670 | $content = str_replace(array("{$sp}b", "{$sp}p", "{$sp}s", "{$sp}e"), array('<?php', '<?=', '<?', '?>'), $content); |
| 1671 | 1671 | |
@@ -1790,7 +1790,7 @@ discard block |
||
| 1790 | 1790 | $matches = $this->getTagsFromContent($content, $left, $right); |
| 1791 | 1791 | if (!empty($matches)) { |
| 1792 | 1792 | foreach ($matches[0] as $i => $v) { |
| 1793 | - $addBreakMatches[$i] = $v . "\n"; |
|
| 1793 | + $addBreakMatches[$i] = $v."\n"; |
|
| 1794 | 1794 | } |
| 1795 | 1795 | $content = str_replace($addBreakMatches, '', $content); |
| 1796 | 1796 | if (strpos($content, $left) !== false) { |
@@ -1823,8 +1823,8 @@ discard block |
||
| 1823 | 1823 | $s = &$matches[0][$i]; |
| 1824 | 1824 | if (strpos($content, $s) !== false) { |
| 1825 | 1825 | $content = str_replace($s, $v, $content); |
| 1826 | - } elseif($this->debug) { |
|
| 1827 | - $this->addLog('ignoreCommentedTagsContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1826 | + } elseif ($this->debug) { |
|
| 1827 | + $this->addLog('ignoreCommentedTagsContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1828 | 1828 | } |
| 1829 | 1829 | } |
| 1830 | 1830 | return $content; |
@@ -1888,7 +1888,7 @@ discard block |
||
| 1888 | 1888 | $msg = ($msg === false) ? 'ob_get_contents() error' : $msg; |
| 1889 | 1889 | $this->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], 'Plugin', $error_info['message'], $error_info['line'], $msg); |
| 1890 | 1890 | if ($this->isBackend()) { |
| 1891 | - $this->event->alert('An error occurred while loading. Please see the event log for more information.<p>' . $msg . '</p>'); |
|
| 1891 | + $this->event->alert('An error occurred while loading. Please see the event log for more information.<p>'.$msg.'</p>'); |
|
| 1892 | 1892 | } |
| 1893 | 1893 | } |
| 1894 | 1894 | } else { |
@@ -1934,7 +1934,7 @@ discard block |
||
| 1934 | 1934 | $echo = ($echo === false) ? 'ob_get_contents() error' : $echo; |
| 1935 | 1935 | $this->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], 'Snippet', $error_info['message'], $error_info['line'], $echo); |
| 1936 | 1936 | if ($this->isBackend()) { |
| 1937 | - $this->event->alert('An error occurred while loading. Please see the event log for more information<p>' . $echo . $return . '</p>'); |
|
| 1937 | + $this->event->alert('An error occurred while loading. Please see the event log for more information<p>'.$echo.$return.'</p>'); |
|
| 1938 | 1938 | } |
| 1939 | 1939 | } |
| 1940 | 1940 | } |
@@ -1942,7 +1942,7 @@ discard block |
||
| 1942 | 1942 | if (is_array($return) || is_object($return)) { |
| 1943 | 1943 | return $return; |
| 1944 | 1944 | } else { |
| 1945 | - return $echo . $return; |
|
| 1945 | + return $echo.$return; |
|
| 1946 | 1946 | } |
| 1947 | 1947 | } |
| 1948 | 1948 | |
@@ -1980,8 +1980,8 @@ discard block |
||
| 1980 | 1980 | } |
| 1981 | 1981 | if (strpos($content, $s) !== false) { |
| 1982 | 1982 | $content = str_replace($s, $value, $content); |
| 1983 | - } elseif($this->debug) { |
|
| 1984 | - $this->addLog('evalSnippetsSGVar parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1983 | + } elseif ($this->debug) { |
|
| 1984 | + $this->addLog('evalSnippetsSGVar parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1985 | 1985 | } |
| 1986 | 1986 | continue; |
| 1987 | 1987 | } |
@@ -1992,8 +1992,8 @@ discard block |
||
| 1992 | 1992 | |
| 1993 | 1993 | if (strpos($content, $s) !== false) { |
| 1994 | 1994 | $content = str_replace($s, $value, $content); |
| 1995 | - } elseif($this->debug) { |
|
| 1996 | - $this->addLog('evalSnippets parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1995 | + } elseif ($this->debug) { |
|
| 1996 | + $this->addLog('evalSnippets parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1997 | 1997 | } |
| 1998 | 1998 | } |
| 1999 | 1999 | |
@@ -2084,7 +2084,7 @@ discard block |
||
| 2084 | 2084 | $eventtime = sprintf('%2.2f ms', $eventtime * 1000); |
| 2085 | 2085 | $code = str_replace("\t", ' ', $this->htmlspecialchars($value)); |
| 2086 | 2086 | $piece = str_replace("\t", ' ', $this->htmlspecialchars($piece)); |
| 2087 | - $print_r_params = str_replace("\t", ' ', $this->htmlspecialchars('$modx->event->params = ' . print_r($params, true))); |
|
| 2087 | + $print_r_params = str_replace("\t", ' ', $this->htmlspecialchars('$modx->event->params = '.print_r($params, true))); |
|
| 2088 | 2088 | $this->snippetsCode .= sprintf('<fieldset style="margin:1em;"><legend><b>%s</b>(%s)</legend><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">[[%s]]</pre><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">%s</pre><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">%s</pre></fieldset>', $snippetObject['name'], $eventtime, $piece, $print_r_params, $code); |
| 2089 | 2089 | $this->snippetsTime[] = array('sname' => $key, 'time' => $eventtime); |
| 2090 | 2090 | } |
@@ -2328,7 +2328,7 @@ discard block |
||
| 2328 | 2328 | $rs = $this->db->select('name,snippet,properties', '[+prefix+]site_snippets', $where); |
| 2329 | 2329 | $count = $this->db->getRecordCount($rs); |
| 2330 | 2330 | if (1 < $count) { |
| 2331 | - exit('Error $modx->_getSnippetObject()' . $snip_name); |
|
| 2331 | + exit('Error $modx->_getSnippetObject()'.$snip_name); |
|
| 2332 | 2332 | } |
| 2333 | 2333 | if ($count) { |
| 2334 | 2334 | $row = $this->db->getRow($rs); |
@@ -2354,7 +2354,7 @@ discard block |
||
| 2354 | 2354 | public function toAlias($text) |
| 2355 | 2355 | { |
| 2356 | 2356 | $suff = $this->config['friendly_url_suffix']; |
| 2357 | - return str_replace(array('.xml' . $suff, '.rss' . $suff, '.js' . $suff, '.css' . $suff, '.txt' . $suff, '.json' . $suff, '.pdf' . $suff), array('.xml', '.rss', '.js', '.css', '.txt', '.json', '.pdf'), $text); |
|
| 2357 | + return str_replace(array('.xml'.$suff, '.rss'.$suff, '.js'.$suff, '.css'.$suff, '.txt'.$suff, '.json'.$suff, '.pdf'.$suff), array('.xml', '.rss', '.js', '.css', '.txt', '.json', '.pdf'), $text); |
|
| 2358 | 2358 | } |
| 2359 | 2359 | |
| 2360 | 2360 | /** |
@@ -2386,7 +2386,7 @@ discard block |
||
| 2386 | 2386 | $suff = '/'; |
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | - $url = ($dir != '' ? $dir . '/' : '') . $pre . $alias . $suff; |
|
| 2389 | + $url = ($dir != '' ? $dir.'/' : '').$pre.$alias.$suff; |
|
| 2390 | 2390 | } |
| 2391 | 2391 | |
| 2392 | 2392 | $evtOut = $this->invokeEvent('OnMakeDocUrl', array( |
@@ -2423,7 +2423,7 @@ discard block |
||
| 2423 | 2423 | preg_match_all('!\[\~([0-9]+)\~\]!ise', $documentSource, $match); |
| 2424 | 2424 | $ids = implode(',', array_unique($match['1'])); |
| 2425 | 2425 | if ($ids) { |
| 2426 | - $res = $this->db->select("id,alias,isfolder,parent,alias_visible", $this->getFullTableName('site_content'), "id IN (" . $ids . ") AND isfolder = '0'"); |
|
| 2426 | + $res = $this->db->select("id,alias,isfolder,parent,alias_visible", $this->getFullTableName('site_content'), "id IN (".$ids.") AND isfolder = '0'"); |
|
| 2427 | 2427 | while ($row = $this->db->getRow($res)) { |
| 2428 | 2428 | if ($this->config['use_alias_path'] == '1' && $row['parent'] != 0) { |
| 2429 | 2429 | $parent = $row['parent']; |
@@ -2434,7 +2434,7 @@ discard block |
||
| 2434 | 2434 | $parent = $this->aliasListing[$parent]['parent']; |
| 2435 | 2435 | } |
| 2436 | 2436 | |
| 2437 | - $aliases[$row['id']] = $path . '/' . $row['alias']; |
|
| 2437 | + $aliases[$row['id']] = $path.'/'.$row['alias']; |
|
| 2438 | 2438 | } else { |
| 2439 | 2439 | $aliases[$row['id']] = $row['alias']; |
| 2440 | 2440 | } |
@@ -2446,7 +2446,7 @@ discard block |
||
| 2446 | 2446 | $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0); |
| 2447 | 2447 | $pref = $this->config['friendly_url_prefix']; |
| 2448 | 2448 | $suff = $this->config['friendly_url_suffix']; |
| 2449 | - $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { |
|
| 2449 | + $documentSource = preg_replace_callback($in, function($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { |
|
| 2450 | 2450 | global $modx; |
| 2451 | 2451 | $thealias = $aliases[$m[1]]; |
| 2452 | 2452 | $thefolder = $isfolder[$m[1]]; |
@@ -2462,7 +2462,7 @@ discard block |
||
| 2462 | 2462 | |
| 2463 | 2463 | } else { |
| 2464 | 2464 | $in = '!\[\~([0-9]+)\~\]!is'; |
| 2465 | - $out = "index.php?id=" . '\1'; |
|
| 2465 | + $out = "index.php?id=".'\1'; |
|
| 2466 | 2466 | $documentSource = preg_replace($in, $out, $documentSource); |
| 2467 | 2467 | } |
| 2468 | 2468 | |
@@ -2483,7 +2483,7 @@ discard block |
||
| 2483 | 2483 | $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; |
| 2484 | 2484 | $len_base_url = strlen($this->config['base_url']); |
| 2485 | 2485 | |
| 2486 | - $url_path = $q;//LANG |
|
| 2486 | + $url_path = $q; //LANG |
|
| 2487 | 2487 | |
| 2488 | 2488 | if (substr($url_path, 0, $len_base_url) === $this->config['base_url']) { |
| 2489 | 2489 | $url_path = substr($url_path, $len_base_url); |
@@ -2495,7 +2495,7 @@ discard block |
||
| 2495 | 2495 | $strictURL = substr($strictURL, $len_base_url); |
| 2496 | 2496 | } |
| 2497 | 2497 | $http_host = $_SERVER['HTTP_HOST']; |
| 2498 | - $requestedURL = "{$scheme}://{$http_host}" . '/' . $q; //LANG |
|
| 2498 | + $requestedURL = "{$scheme}://{$http_host}".'/'.$q; //LANG |
|
| 2499 | 2499 | |
| 2500 | 2500 | $site_url = $this->config['site_url']; |
| 2501 | 2501 | |
@@ -2511,7 +2511,7 @@ discard block |
||
| 2511 | 2511 | } |
| 2512 | 2512 | if ($this->config['base_url'] != $_SERVER['REQUEST_URI']) { |
| 2513 | 2513 | if (empty($_POST)) { |
| 2514 | - if (($this->config['base_url'] . '?' . $qstring) != $_SERVER['REQUEST_URI']) { |
|
| 2514 | + if (($this->config['base_url'].'?'.$qstring) != $_SERVER['REQUEST_URI']) { |
|
| 2515 | 2515 | $this->sendRedirect($url, 0, 'REDIRECT_HEADER', 'HTTP/1.0 301 Moved Permanently'); |
| 2516 | 2516 | exit(0); |
| 2517 | 2517 | } |
@@ -2574,7 +2574,7 @@ discard block |
||
| 2574 | 2574 | $docgrp = implode(",", $docgrp); |
| 2575 | 2575 | } |
| 2576 | 2576 | // get document |
| 2577 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 2577 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 2578 | 2578 | $rs = $this->db->select('sc.*', "{$tblsc} sc |
| 2579 | 2579 | LEFT JOIN {$tbldg} dg ON dg.document = sc.id", "sc.{$method} = '{$identifier}' AND ({$access})", "", 1); |
| 2580 | 2580 | if ($this->db->getRecordCount($rs) < 1) { |
@@ -2610,9 +2610,9 @@ discard block |
||
| 2610 | 2610 | } |
| 2611 | 2611 | if ($documentObject['template']) { |
| 2612 | 2612 | // load TVs and merge with document - Orig by Apodigm - Docvars |
| 2613 | - $rs = $this->db->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars") . " tv |
|
| 2614 | - INNER JOIN " . $this->getFullTableName("site_tmplvar_templates") . " tvtpl ON tvtpl.tmplvarid = tv.id |
|
| 2615 | - LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues") . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'"); |
|
| 2613 | + $rs = $this->db->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars")." tv |
|
| 2614 | + INNER JOIN " . $this->getFullTableName("site_tmplvar_templates")." tvtpl ON tvtpl.tmplvarid = tv.id |
|
| 2615 | + LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues")." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'"); |
|
| 2616 | 2616 | $tmplvars = array(); |
| 2617 | 2617 | while ($row = $this->db->getRow($rs)) { |
| 2618 | 2618 | $tmplvars[$row['name']] = array( |
@@ -2658,7 +2658,7 @@ discard block |
||
| 2658 | 2658 | $st = md5($source); |
| 2659 | 2659 | } |
| 2660 | 2660 | if ($this->dumpSnippets == 1) { |
| 2661 | - $this->snippetsCode .= "<fieldset><legend><b style='color: #821517;'>PARSE PASS " . ($i + 1) . "</b></legend><p>The following snippets (if any) were parsed during this pass.</p>"; |
|
| 2661 | + $this->snippetsCode .= "<fieldset><legend><b style='color: #821517;'>PARSE PASS ".($i + 1)."</b></legend><p>The following snippets (if any) were parsed during this pass.</p>"; |
|
| 2662 | 2662 | } |
| 2663 | 2663 | |
| 2664 | 2664 | // invoke OnParseDocument event |
@@ -2744,7 +2744,7 @@ discard block |
||
| 2744 | 2744 | |
| 2745 | 2745 | // Check use_alias_path and check if $this->virtualDir is set to anything, then parse the path |
| 2746 | 2746 | if ($this->config['use_alias_path'] == 1) { |
| 2747 | - $alias = (strlen($this->virtualDir) > 0 ? $this->virtualDir . '/' : '') . $this->documentIdentifier; |
|
| 2747 | + $alias = (strlen($this->virtualDir) > 0 ? $this->virtualDir.'/' : '').$this->documentIdentifier; |
|
| 2748 | 2748 | if (isset($this->documentListing[$alias])) { |
| 2749 | 2749 | $this->documentIdentifier = $this->documentListing[$alias]; |
| 2750 | 2750 | } else { |
@@ -2805,7 +2805,7 @@ discard block |
||
| 2805 | 2805 | } else { |
| 2806 | 2806 | $docAlias = $this->db->escape($this->documentIdentifier); |
| 2807 | 2807 | $rs = $this->db->select('id', $this->getFullTableName('site_content'), "deleted=0 and alias='{$docAlias}'"); |
| 2808 | - $this->documentIdentifier = (int)$this->db->getValue($rs); |
|
| 2808 | + $this->documentIdentifier = (int) $this->db->getValue($rs); |
|
| 2809 | 2809 | } |
| 2810 | 2810 | } |
| 2811 | 2811 | $this->documentMethod = 'id'; |
@@ -2858,7 +2858,7 @@ discard block |
||
| 2858 | 2858 | $_REQUEST[$n] = $_GET[$n] = $v; |
| 2859 | 2859 | } |
| 2860 | 2860 | } |
| 2861 | - $_SERVER['PHP_SELF'] = $this->config['base_url'] . $qp['path']; |
|
| 2861 | + $_SERVER['PHP_SELF'] = $this->config['base_url'].$qp['path']; |
|
| 2862 | 2862 | $this->q = $qp['path']; |
| 2863 | 2863 | return $qp['path']; |
| 2864 | 2864 | } |
@@ -2952,7 +2952,7 @@ discard block |
||
| 2952 | 2952 | $this->sendErrorPage(); |
| 2953 | 2953 | } else { |
| 2954 | 2954 | // Inculde the necessary files to check document permissions |
| 2955 | - include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 2955 | + include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php'); |
|
| 2956 | 2956 | $udperms = new udperms(); |
| 2957 | 2957 | $udperms->user = $this->getLoginUserID(); |
| 2958 | 2958 | $udperms->document = $this->documentIdentifier; |
@@ -3006,7 +3006,7 @@ discard block |
||
| 3006 | 3006 | while ($id && $height--) { |
| 3007 | 3007 | $thisid = $id; |
| 3008 | 3008 | if ($this->config['aliaslistingfolder'] == 1) { |
| 3009 | - $id = isset($this->aliasListing[$id]['parent']) ? $this->aliasListing[$id]['parent'] : $this->db->getValue("SELECT `parent` FROM " . $this->getFullTableName("site_content") . " WHERE `id` = '{$id}' LIMIT 0,1"); |
|
| 3009 | + $id = isset($this->aliasListing[$id]['parent']) ? $this->aliasListing[$id]['parent'] : $this->db->getValue("SELECT `parent` FROM ".$this->getFullTableName("site_content")." WHERE `id` = '{$id}' LIMIT 0,1"); |
|
| 3010 | 3010 | if (!$id || $id == '0') { |
| 3011 | 3011 | break; |
| 3012 | 3012 | } |
@@ -3057,15 +3057,15 @@ discard block |
||
| 3057 | 3057 | |
| 3058 | 3058 | if ($this->config['aliaslistingfolder'] == 1) { |
| 3059 | 3059 | |
| 3060 | - $res = $this->db->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (" . $id . ") AND deleted = '0'"); |
|
| 3060 | + $res = $this->db->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (".$id.") AND deleted = '0'"); |
|
| 3061 | 3061 | $idx = array(); |
| 3062 | 3062 | while ($row = $this->db->getRow($res)) { |
| 3063 | 3063 | $pAlias = ''; |
| 3064 | 3064 | if (isset($this->aliasListing[$row['parent']])) { |
| 3065 | - $pAlias .= !empty($this->aliasListing[$row['parent']]['path']) ? $this->aliasListing[$row['parent']]['path'] . '/' : ''; |
|
| 3066 | - $pAlias .= !empty($this->aliasListing[$row['parent']]['alias']) ? $this->aliasListing[$row['parent']]['alias'] . '/' : ''; |
|
| 3065 | + $pAlias .= !empty($this->aliasListing[$row['parent']]['path']) ? $this->aliasListing[$row['parent']]['path'].'/' : ''; |
|
| 3066 | + $pAlias .= !empty($this->aliasListing[$row['parent']]['alias']) ? $this->aliasListing[$row['parent']]['alias'].'/' : ''; |
|
| 3067 | 3067 | }; |
| 3068 | - $children[$pAlias . $row['alias']] = $row['id']; |
|
| 3068 | + $children[$pAlias.$row['alias']] = $row['id']; |
|
| 3069 | 3069 | if ($row['isfolder'] == 1) { |
| 3070 | 3070 | $idx[] = $row['id']; |
| 3071 | 3071 | } |
@@ -3097,7 +3097,7 @@ discard block |
||
| 3097 | 3097 | $depth--; |
| 3098 | 3098 | |
| 3099 | 3099 | foreach ($documentMap_cache[$id] as $childId) { |
| 3100 | - $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '') . $this->aliasListing[$childId]['alias']; |
|
| 3100 | + $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '').$this->aliasListing[$childId]['alias']; |
|
| 3101 | 3101 | if (!strlen($pkey)) { |
| 3102 | 3102 | $pkey = "{$childId}"; |
| 3103 | 3103 | } |
@@ -3126,7 +3126,7 @@ discard block |
||
| 3126 | 3126 | if (substr(strtolower($url), 0, 11) == "javascript:") { |
| 3127 | 3127 | $fnc = substr($url, 11); |
| 3128 | 3128 | } elseif ($url) { |
| 3129 | - $fnc = "window.location.href='" . addslashes($url) . "';"; |
|
| 3129 | + $fnc = "window.location.href='".addslashes($url)."';"; |
|
| 3130 | 3130 | } else { |
| 3131 | 3131 | $fnc = "history.back(-1);"; |
| 3132 | 3132 | } |
@@ -3135,7 +3135,7 @@ discard block |
||
| 3135 | 3135 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset={$modx_manager_charset};\"> |
| 3136 | 3136 | <script> |
| 3137 | 3137 | function __alertQuit() { |
| 3138 | - alert('" . addslashes($msg) . "'); |
|
| 3138 | + alert('".addslashes($msg)."'); |
|
| 3139 | 3139 | {$fnc} |
| 3140 | 3140 | } |
| 3141 | 3141 | window.setTimeout('__alertQuit();',100); |
@@ -3159,7 +3159,7 @@ discard block |
||
| 3159 | 3159 | if ($pms) { |
| 3160 | 3160 | $state = ($pms[$pm] === 1); |
| 3161 | 3161 | } |
| 3162 | - return (int)$state; |
|
| 3162 | + return (int) $state; |
|
| 3163 | 3163 | } |
| 3164 | 3164 | |
| 3165 | 3165 | /** |
@@ -3172,8 +3172,8 @@ discard block |
||
| 3172 | 3172 | */ |
| 3173 | 3173 | public function elementIsLocked($type, $id, $includeThisUser = false) |
| 3174 | 3174 | { |
| 3175 | - $id = (int)$id; |
|
| 3176 | - $type = (int)$type; |
|
| 3175 | + $id = (int) $id; |
|
| 3176 | + $type = (int) $type; |
|
| 3177 | 3177 | if (!$type || !$id) { |
| 3178 | 3178 | return null; |
| 3179 | 3179 | } |
@@ -3223,7 +3223,7 @@ discard block |
||
| 3223 | 3223 | return $lockedElements; |
| 3224 | 3224 | } |
| 3225 | 3225 | |
| 3226 | - $type = (int)$type; |
|
| 3226 | + $type = (int) $type; |
|
| 3227 | 3227 | if (isset($lockedElements[$type])) { |
| 3228 | 3228 | return $lockedElements[$type]; |
| 3229 | 3229 | } else { |
@@ -3240,7 +3240,7 @@ discard block |
||
| 3240 | 3240 | $this->lockedElements = array(); |
| 3241 | 3241 | $this->cleanupExpiredLocks(); |
| 3242 | 3242 | |
| 3243 | - $rs = $this->db->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks') . " ul |
|
| 3243 | + $rs = $this->db->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks')." ul |
|
| 3244 | 3244 | LEFT JOIN {$this->getFullTableName('manager_users')} mu on ul.internalKey = mu.id"); |
| 3245 | 3245 | while ($row = $this->db->getRow($rs)) { |
| 3246 | 3246 | $this->lockedElements[$row['elementType']][$row['elementId']] = array( |
@@ -3263,7 +3263,7 @@ discard block |
||
| 3263 | 3263 | public function cleanupExpiredLocks() |
| 3264 | 3264 | { |
| 3265 | 3265 | // Clean-up active_user_sessions first |
| 3266 | - $timeout = (int)$this->config['session_timeout'] < 2 ? 120 : $this->config['session_timeout'] * 60; // session.js pings every 10min, updateMail() in mainMenu pings every minute, so 2min is minimum |
|
| 3266 | + $timeout = (int) $this->config['session_timeout'] < 2 ? 120 : $this->config['session_timeout'] * 60; // session.js pings every 10min, updateMail() in mainMenu pings every minute, so 2min is minimum |
|
| 3267 | 3267 | $validSessionTimeLimit = $this->time - $timeout; |
| 3268 | 3268 | $this->db->delete($this->getFullTableName('active_user_sessions'), "lasthit < {$validSessionTimeLimit}"); |
| 3269 | 3269 | |
@@ -3276,7 +3276,7 @@ discard block |
||
| 3276 | 3276 | foreach ($rs as $row) { |
| 3277 | 3277 | $userSids[] = $row['sid']; |
| 3278 | 3278 | } |
| 3279 | - $userSids = "'" . implode("','", $userSids) . "'"; |
|
| 3279 | + $userSids = "'".implode("','", $userSids)."'"; |
|
| 3280 | 3280 | $this->db->delete($this->getFullTableName('active_user_locks'), "sid NOT IN({$userSids})"); |
| 3281 | 3281 | } else { |
| 3282 | 3282 | $this->db->delete($this->getFullTableName('active_user_locks')); |
@@ -3360,8 +3360,8 @@ discard block |
||
| 3360 | 3360 | public function lockElement($type, $id) |
| 3361 | 3361 | { |
| 3362 | 3362 | $userId = $this->isBackend() && $_SESSION['mgrInternalKey'] ? $_SESSION['mgrInternalKey'] : 0; |
| 3363 | - $type = (int)$type; |
|
| 3364 | - $id = (int)$id; |
|
| 3363 | + $type = (int) $type; |
|
| 3364 | + $id = (int) $id; |
|
| 3365 | 3365 | if (!$type || !$id || !$userId) { |
| 3366 | 3366 | return false; |
| 3367 | 3367 | } |
@@ -3382,8 +3382,8 @@ discard block |
||
| 3382 | 3382 | public function unlockElement($type, $id, $includeAllUsers = false) |
| 3383 | 3383 | { |
| 3384 | 3384 | $userId = $this->isBackend() && $_SESSION['mgrInternalKey'] ? $_SESSION['mgrInternalKey'] : 0; |
| 3385 | - $type = (int)$type; |
|
| 3386 | - $id = (int)$id; |
|
| 3385 | + $type = (int) $type; |
|
| 3386 | + $id = (int) $id; |
|
| 3387 | 3387 | if (!$type || !$id) { |
| 3388 | 3388 | return false; |
| 3389 | 3389 | } |
@@ -3450,8 +3450,8 @@ discard block |
||
| 3450 | 3450 | } |
| 3451 | 3451 | |
| 3452 | 3452 | $usertype = $this->isFrontend() ? 1 : 0; |
| 3453 | - $evtid = (int)$evtid; |
|
| 3454 | - $type = (int)$type; |
|
| 3453 | + $evtid = (int) $evtid; |
|
| 3454 | + $type = (int) $type; |
|
| 3455 | 3455 | |
| 3456 | 3456 | // Types: 1 = information, 2 = warning, 3 = error |
| 3457 | 3457 | if ($type < 1) { |
@@ -3473,8 +3473,8 @@ discard block |
||
| 3473 | 3473 | if (isset($this->config['send_errormail']) && $this->config['send_errormail'] !== '0') { |
| 3474 | 3474 | if ($this->config['send_errormail'] <= $type) { |
| 3475 | 3475 | $this->sendmail(array( |
| 3476 | - 'subject' => 'MODX System Error on ' . $this->config['site_name'], |
|
| 3477 | - 'body' => 'Source: ' . $source . ' - The details of the error could be seen in the MODX system events log.', |
|
| 3476 | + 'subject' => 'MODX System Error on '.$this->config['site_name'], |
|
| 3477 | + 'body' => 'Source: '.$source.' - The details of the error could be seen in the MODX system events log.', |
|
| 3478 | 3478 | 'type' => 'text' |
| 3479 | 3479 | )); |
| 3480 | 3480 | } |
@@ -3522,7 +3522,7 @@ discard block |
||
| 3522 | 3522 | $p['fromname'] = $userinfo['username']; |
| 3523 | 3523 | } |
| 3524 | 3524 | if ($msg === '' && !isset($p['body'])) { |
| 3525 | - $p['body'] = $_SERVER['REQUEST_URI'] . "\n" . $_SERVER['HTTP_USER_AGENT'] . "\n" . $_SERVER['HTTP_REFERER']; |
|
| 3525 | + $p['body'] = $_SERVER['REQUEST_URI']."\n".$_SERVER['HTTP_USER_AGENT']."\n".$_SERVER['HTTP_REFERER']; |
|
| 3526 | 3526 | } elseif (is_string($msg) && 0 < strlen($msg)) { |
| 3527 | 3527 | $p['body'] = $msg; |
| 3528 | 3528 | } |
@@ -3562,8 +3562,8 @@ discard block |
||
| 3562 | 3562 | $files = array(); |
| 3563 | 3563 | } |
| 3564 | 3564 | foreach ($files as $f) { |
| 3565 | - if (file_exists(MODX_BASE_PATH . $f) && is_file(MODX_BASE_PATH . $f) && is_readable(MODX_BASE_PATH . $f)) { |
|
| 3566 | - $this->mail->AddAttachment(MODX_BASE_PATH . $f); |
|
| 3565 | + if (file_exists(MODX_BASE_PATH.$f) && is_file(MODX_BASE_PATH.$f) && is_readable(MODX_BASE_PATH.$f)) { |
|
| 3566 | + $this->mail->AddAttachment(MODX_BASE_PATH.$f); |
|
| 3567 | 3567 | } |
| 3568 | 3568 | } |
| 3569 | 3569 | $rs = $this->mail->send(); |
@@ -3608,7 +3608,7 @@ discard block |
||
| 3608 | 3608 | */ |
| 3609 | 3609 | public function isFrontend() |
| 3610 | 3610 | { |
| 3611 | - return ! $this->isBackend(); |
|
| 3611 | + return !$this->isBackend(); |
|
| 3612 | 3612 | } |
| 3613 | 3613 | |
| 3614 | 3614 | /** |
@@ -3633,14 +3633,14 @@ discard block |
||
| 3633 | 3633 | $tblsc = $this->getFullTableName("site_content"); |
| 3634 | 3634 | $tbldg = $this->getFullTableName("document_groups"); |
| 3635 | 3635 | // modify field names to use sc. table reference |
| 3636 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3637 | - $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3636 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3637 | + $sort = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3638 | 3638 | // get document groups for current user |
| 3639 | 3639 | if ($docgrp = $this->getUserDocGroups()) { |
| 3640 | 3640 | $docgrp = implode(",", $docgrp); |
| 3641 | 3641 | } |
| 3642 | 3642 | // build query |
| 3643 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3643 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3644 | 3644 | $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc |
| 3645 | 3645 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
| 3646 | 3646 | $resourceArray = $this->db->makeArray($result); |
@@ -3670,14 +3670,14 @@ discard block |
||
| 3670 | 3670 | $tbldg = $this->getFullTableName("document_groups"); |
| 3671 | 3671 | |
| 3672 | 3672 | // modify field names to use sc. table reference |
| 3673 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3674 | - $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3673 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3674 | + $sort = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3675 | 3675 | // get document groups for current user |
| 3676 | 3676 | if ($docgrp = $this->getUserDocGroups()) { |
| 3677 | 3677 | $docgrp = implode(",", $docgrp); |
| 3678 | 3678 | } |
| 3679 | 3679 | // build query |
| 3680 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3680 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3681 | 3681 | $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc |
| 3682 | 3682 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND sc.published=1 AND sc.deleted=0 AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
| 3683 | 3683 | $resourceArray = $this->db->makeArray($result); |
@@ -3712,16 +3712,16 @@ discard block |
||
| 3712 | 3712 | return $this->tmpCache[__FUNCTION__][$cacheKey]; |
| 3713 | 3713 | } |
| 3714 | 3714 | |
| 3715 | - $published = ($published !== 'all') ? 'AND sc.published = ' . $published : ''; |
|
| 3716 | - $deleted = ($deleted !== 'all') ? 'AND sc.deleted = ' . $deleted : ''; |
|
| 3715 | + $published = ($published !== 'all') ? 'AND sc.published = '.$published : ''; |
|
| 3716 | + $deleted = ($deleted !== 'all') ? 'AND sc.deleted = '.$deleted : ''; |
|
| 3717 | 3717 | |
| 3718 | 3718 | if ($where != '') { |
| 3719 | - $where = 'AND ' . $where; |
|
| 3719 | + $where = 'AND '.$where; |
|
| 3720 | 3720 | } |
| 3721 | 3721 | |
| 3722 | 3722 | // modify field names to use sc. table reference |
| 3723 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3724 | - $sort = ($sort == '') ? '' : 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3723 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3724 | + $sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3725 | 3725 | |
| 3726 | 3726 | // get document groups for current user |
| 3727 | 3727 | if ($docgrp = $this->getUserDocGroups()) { |
@@ -3729,7 +3729,7 @@ discard block |
||
| 3729 | 3729 | } |
| 3730 | 3730 | |
| 3731 | 3731 | // build query |
| 3732 | - $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="' . $_SESSION['mgrRole'] . '" OR sc.privatemgr=0') . (!$docgrp ? '' : ' OR dg.document_group IN (' . $docgrp . ')'); |
|
| 3732 | + $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')'); |
|
| 3733 | 3733 | |
| 3734 | 3734 | $tblsc = $this->getFullTableName('site_content'); |
| 3735 | 3735 | $tbldg = $this->getFullTableName('document_groups'); |
@@ -3781,10 +3781,10 @@ discard block |
||
| 3781 | 3781 | return false; |
| 3782 | 3782 | } else { |
| 3783 | 3783 | // modify field names to use sc. table reference |
| 3784 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3785 | - $sort = ($sort == '') ? '' : 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3784 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3785 | + $sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3786 | 3786 | if ($where != '') { |
| 3787 | - $where = 'AND ' . $where; |
|
| 3787 | + $where = 'AND '.$where; |
|
| 3788 | 3788 | } |
| 3789 | 3789 | |
| 3790 | 3790 | $published = ($published !== 'all') ? "AND sc.published = '{$published}'" : ''; |
@@ -3795,13 +3795,13 @@ discard block |
||
| 3795 | 3795 | $docgrp = implode(',', $docgrp); |
| 3796 | 3796 | } |
| 3797 | 3797 | |
| 3798 | - $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="' . $_SESSION['mgrRole'] . '" OR sc.privatemgr=0') . (!$docgrp ? '' : ' OR dg.document_group IN (' . $docgrp . ')'); |
|
| 3798 | + $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')'); |
|
| 3799 | 3799 | |
| 3800 | 3800 | $tblsc = $this->getFullTableName('site_content'); |
| 3801 | 3801 | $tbldg = $this->getFullTableName('document_groups'); |
| 3802 | 3802 | |
| 3803 | 3803 | $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc |
| 3804 | - LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (" . implode(',', $ids) . ") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit); |
|
| 3804 | + LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (".implode(',', $ids).") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit); |
|
| 3805 | 3805 | |
| 3806 | 3806 | $resourceArray = $this->db->makeArray($result); |
| 3807 | 3807 | |
@@ -3906,12 +3906,12 @@ discard block |
||
| 3906 | 3906 | $tbldg = $this->getFullTableName("document_groups"); |
| 3907 | 3907 | $activeSql = $active == 1 ? "AND sc.published=1 AND sc.deleted=0" : ""; |
| 3908 | 3908 | // modify field names to use sc. table reference |
| 3909 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3909 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3910 | 3910 | // get document groups for current user |
| 3911 | 3911 | if ($docgrp = $this->getUserDocGroups()) { |
| 3912 | 3912 | $docgrp = implode(",", $docgrp); |
| 3913 | 3913 | } |
| 3914 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3914 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3915 | 3915 | $result = $this->db->select($fields, "{$tblsc} sc LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id='{$pageid}' {$activeSql}) AND ({$access})", "", 1); |
| 3916 | 3916 | $pageInfo = $this->db->getRow($result); |
| 3917 | 3917 | |
@@ -3958,7 +3958,7 @@ discard block |
||
| 3958 | 3958 | { |
| 3959 | 3959 | if ($this->currentSnippet) { |
| 3960 | 3960 | $tbl = $this->getFullTableName("site_snippets"); |
| 3961 | - $rs = $this->db->select('id', $tbl, "name='" . $this->db->escape($this->currentSnippet) . "'", '', 1); |
|
| 3961 | + $rs = $this->db->select('id', $tbl, "name='".$this->db->escape($this->currentSnippet)."'", '', 1); |
|
| 3962 | 3962 | if ($snippetId = $this->db->getValue($rs)) { |
| 3963 | 3963 | return $snippetId; |
| 3964 | 3964 | } |
@@ -3985,23 +3985,23 @@ discard block |
||
| 3985 | 3985 | */ |
| 3986 | 3986 | public function clearCache($type = '', $report = false) |
| 3987 | 3987 | { |
| 3988 | - $cache_dir = MODX_BASE_PATH . $this->getCacheFolder(); |
|
| 3988 | + $cache_dir = MODX_BASE_PATH.$this->getCacheFolder(); |
|
| 3989 | 3989 | if (is_array($type)) { |
| 3990 | 3990 | foreach ($type as $_) { |
| 3991 | 3991 | $this->clearCache($_, $report); |
| 3992 | 3992 | } |
| 3993 | 3993 | } elseif ($type == 'full') { |
| 3994 | - include_once(MODX_MANAGER_PATH . 'processors/cache_sync.class.processor.php'); |
|
| 3994 | + include_once(MODX_MANAGER_PATH.'processors/cache_sync.class.processor.php'); |
|
| 3995 | 3995 | $sync = new synccache(); |
| 3996 | 3996 | $sync->setCachepath($cache_dir); |
| 3997 | 3997 | $sync->setReport($report); |
| 3998 | 3998 | $sync->emptyCache(); |
| 3999 | 3999 | } elseif (preg_match('@^[1-9][0-9]*$@', $type)) { |
| 4000 | 4000 | $key = ($this->config['cache_type'] == 2) ? $this->makePageCacheKey($type) : $type; |
| 4001 | - $file_name = "docid_" . $key . "_*.pageCache.php"; |
|
| 4002 | - $cache_path = $cache_dir . $file_name; |
|
| 4001 | + $file_name = "docid_".$key."_*.pageCache.php"; |
|
| 4002 | + $cache_path = $cache_dir.$file_name; |
|
| 4003 | 4003 | $files = glob($cache_path); |
| 4004 | - $files[] = $cache_dir . "docid_" . $key . ".pageCache.php"; |
|
| 4004 | + $files[] = $cache_dir."docid_".$key.".pageCache.php"; |
|
| 4005 | 4005 | foreach ($files as $file) { |
| 4006 | 4006 | if (!is_file($file)) { |
| 4007 | 4007 | continue; |
@@ -4009,7 +4009,7 @@ discard block |
||
| 4009 | 4009 | unlink($file); |
| 4010 | 4010 | } |
| 4011 | 4011 | } else { |
| 4012 | - $files = glob($cache_dir . '*'); |
|
| 4012 | + $files = glob($cache_dir.'*'); |
|
| 4013 | 4013 | foreach ($files as $file) { |
| 4014 | 4014 | $name = basename($file); |
| 4015 | 4015 | if (strpos($name, '.pageCache.php') === false) { |
@@ -4078,7 +4078,7 @@ discard block |
||
| 4078 | 4078 | $f_url_suffix = '/'; |
| 4079 | 4079 | } |
| 4080 | 4080 | |
| 4081 | - $alPath = !empty ($al['path']) ? $al['path'] . '/' : ''; |
|
| 4081 | + $alPath = !empty ($al['path']) ? $al['path'].'/' : ''; |
|
| 4082 | 4082 | |
| 4083 | 4083 | if ($al && $al['alias']) { |
| 4084 | 4084 | $alias = $al['alias']; |
@@ -4086,7 +4086,7 @@ discard block |
||
| 4086 | 4086 | |
| 4087 | 4087 | } |
| 4088 | 4088 | |
| 4089 | - $alias = $alPath . $f_url_prefix . $alias . $f_url_suffix; |
|
| 4089 | + $alias = $alPath.$f_url_prefix.$alias.$f_url_suffix; |
|
| 4090 | 4090 | $url = "{$alias}{$args}"; |
| 4091 | 4091 | } else { |
| 4092 | 4092 | $url = "index.php?id={$id}{$args}"; |
@@ -4105,7 +4105,7 @@ discard block |
||
| 4105 | 4105 | } |
| 4106 | 4106 | |
| 4107 | 4107 | //TODO: check to make sure that $site_url incudes the url :port (e.g. :8080) |
| 4108 | - $host = $scheme == 'full' ? $this->config['site_url'] : $scheme . '://' . $_SERVER['HTTP_HOST'] . $host; |
|
| 4108 | + $host = $scheme == 'full' ? $this->config['site_url'] : $scheme.'://'.$_SERVER['HTTP_HOST'].$host; |
|
| 4109 | 4109 | } |
| 4110 | 4110 | |
| 4111 | 4111 | //fix strictUrl by Bumkaka |
@@ -4114,9 +4114,9 @@ discard block |
||
| 4114 | 4114 | } |
| 4115 | 4115 | |
| 4116 | 4116 | if ($this->config['xhtml_urls']) { |
| 4117 | - $url = preg_replace("/&(?!amp;)/", "&", $host . $virtualDir . $url); |
|
| 4117 | + $url = preg_replace("/&(?!amp;)/", "&", $host.$virtualDir.$url); |
|
| 4118 | 4118 | } else { |
| 4119 | - $url = $host . $virtualDir . $url; |
|
| 4119 | + $url = $host.$virtualDir.$url; |
|
| 4120 | 4120 | } |
| 4121 | 4121 | |
| 4122 | 4122 | $evtOut = $this->invokeEvent('OnMakeDocUrl', array( |
@@ -4140,21 +4140,21 @@ discard block |
||
| 4140 | 4140 | if (isset($this->aliasListing[$id])) { |
| 4141 | 4141 | $out = $this->aliasListing[$id]; |
| 4142 | 4142 | } else { |
| 4143 | - $q = $this->db->query("SELECT id,alias,isfolder,parent FROM " . $this->getFullTableName("site_content") . " WHERE id=" . (int)$id); |
|
| 4143 | + $q = $this->db->query("SELECT id,alias,isfolder,parent FROM ".$this->getFullTableName("site_content")." WHERE id=".(int) $id); |
|
| 4144 | 4144 | if ($this->db->getRecordCount($q) == '1') { |
| 4145 | 4145 | $q = $this->db->getRow($q); |
| 4146 | 4146 | $this->aliasListing[$id] = array( |
| 4147 | - 'id' => (int)$q['id'], |
|
| 4147 | + 'id' => (int) $q['id'], |
|
| 4148 | 4148 | 'alias' => $q['alias'] == '' ? $q['id'] : $q['alias'], |
| 4149 | - 'parent' => (int)$q['parent'], |
|
| 4150 | - 'isfolder' => (int)$q['isfolder'], |
|
| 4149 | + 'parent' => (int) $q['parent'], |
|
| 4150 | + 'isfolder' => (int) $q['isfolder'], |
|
| 4151 | 4151 | ); |
| 4152 | 4152 | if ($this->aliasListing[$id]['parent'] > 0) { |
| 4153 | 4153 | //fix alias_path_usage |
| 4154 | 4154 | if ($this->config['use_alias_path'] == '1') { |
| 4155 | 4155 | //&& $tmp['path'] != '' - fix error slash with epty path |
| 4156 | 4156 | $tmp = $this->getAliasListing($this->aliasListing[$id]['parent']); |
| 4157 | - $this->aliasListing[$id]['path'] = $tmp['path'] . ($tmp['alias_visible'] ? (($tmp['parent'] > 0 && $tmp['path'] != '') ? '/' : '') . $tmp['alias'] : ''); |
|
| 4157 | + $this->aliasListing[$id]['path'] = $tmp['path'].($tmp['alias_visible'] ? (($tmp['parent'] > 0 && $tmp['path'] != '') ? '/' : '').$tmp['alias'] : ''); |
|
| 4158 | 4158 | } else { |
| 4159 | 4159 | $this->aliasListing[$id]['path'] = ''; |
| 4160 | 4160 | } |
@@ -4195,7 +4195,7 @@ discard block |
||
| 4195 | 4195 | $out = array(); |
| 4196 | 4196 | if (empty($this->version) || !is_array($this->version)) { |
| 4197 | 4197 | //include for compatibility modx version < 1.0.10 |
| 4198 | - include MODX_MANAGER_PATH . "includes/version.inc.php"; |
|
| 4198 | + include MODX_MANAGER_PATH."includes/version.inc.php"; |
|
| 4199 | 4199 | $this->version = array(); |
| 4200 | 4200 | $this->version['version'] = isset($modx_version) ? $modx_version : ''; |
| 4201 | 4201 | $this->version['branch'] = isset($modx_branch) ? $modx_branch : ''; |
@@ -4217,18 +4217,18 @@ discard block |
||
| 4217 | 4217 | { |
| 4218 | 4218 | if (isset ($this->snippetCache[$snippetName])) { |
| 4219 | 4219 | $snippet = $this->snippetCache[$snippetName]; |
| 4220 | - $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : ''; |
|
| 4220 | + $properties = !empty($this->snippetCache[$snippetName."Props"]) ? $this->snippetCache[$snippetName."Props"] : ''; |
|
| 4221 | 4221 | } else { // not in cache so let's check the db |
| 4222 | - $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->db->escape($snippetName) . "' AND ss.disabled=0;"; |
|
| 4222 | + $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM ".$this->getFullTableName("site_snippets")." as ss LEFT JOIN ".$this->getFullTableName('site_modules')." as sm on sm.guid=ss.moduleguid WHERE ss.`name`='".$this->db->escape($snippetName)."' AND ss.disabled=0;"; |
|
| 4223 | 4223 | $result = $this->db->query($sql); |
| 4224 | 4224 | if ($this->db->getRecordCount($result) == 1) { |
| 4225 | 4225 | $row = $this->db->getRow($result); |
| 4226 | 4226 | $snippet = $this->snippetCache[$snippetName] = $row['snippet']; |
| 4227 | 4227 | $mergedProperties = array_merge($this->parseProperties($row['properties']), $this->parseProperties($row['sharedproperties'])); |
| 4228 | - $properties = $this->snippetCache[$snippetName . "Props"] = json_encode($mergedProperties); |
|
| 4228 | + $properties = $this->snippetCache[$snippetName."Props"] = json_encode($mergedProperties); |
|
| 4229 | 4229 | } else { |
| 4230 | 4230 | $snippet = $this->snippetCache[$snippetName] = "return false;"; |
| 4231 | - $properties = $this->snippetCache[$snippetName . "Props"] = ''; |
|
| 4231 | + $properties = $this->snippetCache[$snippetName."Props"] = ''; |
|
| 4232 | 4232 | } |
| 4233 | 4233 | } |
| 4234 | 4234 | // load default params/properties |
@@ -4328,8 +4328,8 @@ discard block |
||
| 4328 | 4328 | } |
| 4329 | 4329 | if (strpos($tpl, $s) !== false) { |
| 4330 | 4330 | $tpl = str_replace($s, $value, $tpl); |
| 4331 | - } elseif($this->debug) { |
|
| 4332 | - $this->addLog('parseText parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 4331 | + } elseif ($this->debug) { |
|
| 4332 | + $this->addLog('parseText parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 4333 | 4333 | } |
| 4334 | 4334 | } |
| 4335 | 4335 | |
@@ -4378,7 +4378,7 @@ discard block |
||
| 4378 | 4378 | case 'CODE': |
| 4379 | 4379 | break; |
| 4380 | 4380 | case 'FILE': |
| 4381 | - $template = file_get_contents(MODX_BASE_PATH . $template); |
|
| 4381 | + $template = file_get_contents(MODX_BASE_PATH.$template); |
|
| 4382 | 4382 | break; |
| 4383 | 4383 | case 'CHUNK': |
| 4384 | 4384 | $template = $this->getChunk($template); |
@@ -4411,7 +4411,7 @@ discard block |
||
| 4411 | 4411 | if ($mode !== 'formatOnly' && empty($timestamp)) { |
| 4412 | 4412 | return '-'; |
| 4413 | 4413 | } |
| 4414 | - $timestamp = (int)$timestamp; |
|
| 4414 | + $timestamp = (int) $timestamp; |
|
| 4415 | 4415 | |
| 4416 | 4416 | switch ($this->config['datetime_format']) { |
| 4417 | 4417 | case 'YYYY/mm/dd': |
@@ -4431,7 +4431,7 @@ discard block |
||
| 4431 | 4431 | } |
| 4432 | 4432 | |
| 4433 | 4433 | if (empty($mode)) { |
| 4434 | - $strTime = strftime($dateFormat . " %H:%M:%S", $timestamp); |
|
| 4434 | + $strTime = strftime($dateFormat." %H:%M:%S", $timestamp); |
|
| 4435 | 4435 | } elseif ($mode == 'dateOnly') { |
| 4436 | 4436 | $strTime = strftime($dateFormat, $timestamp); |
| 4437 | 4437 | } elseif ($mode == 'formatOnly') { |
@@ -4485,7 +4485,7 @@ discard block |
||
| 4485 | 4485 | $S = 0; |
| 4486 | 4486 | } |
| 4487 | 4487 | $timeStamp = mktime($H, $M, $S, $m, $d, $Y); |
| 4488 | - $timeStamp = (int)$timeStamp; |
|
| 4488 | + $timeStamp = (int) $timeStamp; |
|
| 4489 | 4489 | return $timeStamp; |
| 4490 | 4490 | } |
| 4491 | 4491 | |
@@ -4527,7 +4527,7 @@ discard block |
||
| 4527 | 4527 | if ($v === 'value') { |
| 4528 | 4528 | unset($_[$i]); |
| 4529 | 4529 | } else { |
| 4530 | - $_[$i] = 'tv.' . $v; |
|
| 4530 | + $_[$i] = 'tv.'.$v; |
|
| 4531 | 4531 | } |
| 4532 | 4532 | } |
| 4533 | 4533 | $fields = implode(',', $_); |
@@ -4536,12 +4536,12 @@ discard block |
||
| 4536 | 4536 | } |
| 4537 | 4537 | |
| 4538 | 4538 | if ($tvsort != '') { |
| 4539 | - $tvsort = 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $tvsort)))); |
|
| 4539 | + $tvsort = 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $tvsort)))); |
|
| 4540 | 4540 | } |
| 4541 | 4541 | if ($tvidnames == "*") { |
| 4542 | 4542 | $query = "tv.id<>0"; |
| 4543 | 4543 | } else { |
| 4544 | - $query = (is_numeric($tvidnames[0]) ? "tv.id" : "tv.name") . " IN ('" . implode("','", $tvidnames) . "')"; |
|
| 4544 | + $query = (is_numeric($tvidnames[0]) ? "tv.id" : "tv.name")." IN ('".implode("','", $tvidnames)."')"; |
|
| 4545 | 4545 | } |
| 4546 | 4546 | |
| 4547 | 4547 | $this->getUserDocGroups(); |
@@ -4685,7 +4685,7 @@ discard block |
||
| 4685 | 4685 | return $this->tmpCache[__FUNCTION__][$cacheKey]; |
| 4686 | 4686 | } |
| 4687 | 4687 | |
| 4688 | - if (($idnames != '*' && !is_array($idnames)) || empty($idnames) ) { |
|
| 4688 | + if (($idnames != '*' && !is_array($idnames)) || empty($idnames)) { |
|
| 4689 | 4689 | return false; |
| 4690 | 4690 | } else { |
| 4691 | 4691 | |
@@ -4703,23 +4703,23 @@ discard block |
||
| 4703 | 4703 | } |
| 4704 | 4704 | |
| 4705 | 4705 | // get user defined template variables |
| 4706 | - $fields = ($fields == '') ? 'tv.*' : 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 4707 | - $sort = ($sort == '') ? '' : 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 4706 | + $fields = ($fields == '') ? 'tv.*' : 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 4707 | + $sort = ($sort == '') ? '' : 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 4708 | 4708 | |
| 4709 | 4709 | if ($idnames == '*') { |
| 4710 | 4710 | $query = 'tv.id<>0'; |
| 4711 | 4711 | } else { |
| 4712 | - $query = (is_numeric($idnames[0]) ? 'tv.id' : 'tv.name') . " IN ('" . implode("','", $idnames) . "')"; |
|
| 4712 | + $query = (is_numeric($idnames[0]) ? 'tv.id' : 'tv.name')." IN ('".implode("','", $idnames)."')"; |
|
| 4713 | 4713 | } |
| 4714 | 4714 | |
| 4715 | - $rs = $this->db->select("{$fields}, IF(tvc.value != '', tvc.value, tv.default_text) as value", $this->getFullTableName('site_tmplvars') . " tv |
|
| 4716 | - INNER JOIN " . $this->getFullTableName('site_tmplvar_templates') . " tvtpl ON tvtpl.tmplvarid = tv.id |
|
| 4717 | - LEFT JOIN " . $this->getFullTableName('site_tmplvar_contentvalues') . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$docid}'", "{$query} AND tvtpl.templateid = '{$docRow['template']}'", ($sort ? "{$sort} {$dir}" : "")); |
|
| 4715 | + $rs = $this->db->select("{$fields}, IF(tvc.value != '', tvc.value, tv.default_text) as value", $this->getFullTableName('site_tmplvars')." tv |
|
| 4716 | + INNER JOIN " . $this->getFullTableName('site_tmplvar_templates')." tvtpl ON tvtpl.tmplvarid = tv.id |
|
| 4717 | + LEFT JOIN " . $this->getFullTableName('site_tmplvar_contentvalues')." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$docid}'", "{$query} AND tvtpl.templateid = '{$docRow['template']}'", ($sort ? "{$sort} {$dir}" : "")); |
|
| 4718 | 4718 | |
| 4719 | 4719 | $result = $this->db->makeArray($rs); |
| 4720 | 4720 | |
| 4721 | 4721 | // get default/built-in template variables |
| 4722 | - if(is_array($docRow)){ |
|
| 4722 | + if (is_array($docRow)) { |
|
| 4723 | 4723 | ksort($docRow); |
| 4724 | 4724 | |
| 4725 | 4725 | foreach ($docRow as $key => $value) { |
@@ -4757,22 +4757,22 @@ discard block |
||
| 4757 | 4757 | */ |
| 4758 | 4758 | public function getTemplateVarOutput($idnames = array(), $docid = '', $published = 1, $sep = '') |
| 4759 | 4759 | { |
| 4760 | - if (is_array($idnames) && empty($idnames) ) { |
|
| 4760 | + if (is_array($idnames) && empty($idnames)) { |
|
| 4761 | 4761 | return false; |
| 4762 | 4762 | } else { |
| 4763 | 4763 | $output = array(); |
| 4764 | 4764 | $vars = ($idnames == '*' || is_array($idnames)) ? $idnames : array($idnames); |
| 4765 | 4765 | |
| 4766 | - $docid = (int)$docid > 0 ? (int)$docid : $this->documentIdentifier; |
|
| 4766 | + $docid = (int) $docid > 0 ? (int) $docid : $this->documentIdentifier; |
|
| 4767 | 4767 | // remove sort for speed |
| 4768 | 4768 | $result = $this->getTemplateVars($vars, '*', $docid, $published, '', ''); |
| 4769 | 4769 | |
| 4770 | 4770 | if ($result == false) { |
| 4771 | 4771 | return false; |
| 4772 | 4772 | } else { |
| 4773 | - $baspath = MODX_MANAGER_PATH . 'includes'; |
|
| 4774 | - include_once $baspath . '/tmplvars.format.inc.php'; |
|
| 4775 | - include_once $baspath . '/tmplvars.commands.inc.php'; |
|
| 4773 | + $baspath = MODX_MANAGER_PATH.'includes'; |
|
| 4774 | + include_once $baspath.'/tmplvars.format.inc.php'; |
|
| 4775 | + include_once $baspath.'/tmplvars.commands.inc.php'; |
|
| 4776 | 4776 | |
| 4777 | 4777 | for ($i = 0; $i < count($result); $i++) { |
| 4778 | 4778 | $row = $result[$i]; |
@@ -4797,7 +4797,7 @@ discard block |
||
| 4797 | 4797 | */ |
| 4798 | 4798 | public function getFullTableName($tbl) |
| 4799 | 4799 | { |
| 4800 | - return $this->db->config['dbase'] . ".`" . $this->db->config['table_prefix'] . $tbl . "`"; |
|
| 4800 | + return $this->db->config['dbase'].".`".$this->db->config['table_prefix'].$tbl."`"; |
|
| 4801 | 4801 | } |
| 4802 | 4802 | |
| 4803 | 4803 | /** |
@@ -4876,7 +4876,7 @@ discard block |
||
| 4876 | 4876 | public function getCachePath() |
| 4877 | 4877 | { |
| 4878 | 4878 | global $base_url; |
| 4879 | - $pth = $base_url . $this->getCacheFolder(); |
|
| 4879 | + $pth = $base_url.$this->getCacheFolder(); |
|
| 4880 | 4880 | return $pth; |
| 4881 | 4881 | } |
| 4882 | 4882 | |
@@ -4928,8 +4928,8 @@ discard block |
||
| 4928 | 4928 | $out = false; |
| 4929 | 4929 | |
| 4930 | 4930 | if (!empty($context)) { |
| 4931 | - if (is_scalar($context) && isset($_SESSION[$context . 'Validated'])) { |
|
| 4932 | - $out = $_SESSION[$context . 'InternalKey']; |
|
| 4931 | + if (is_scalar($context) && isset($_SESSION[$context.'Validated'])) { |
|
| 4932 | + $out = $_SESSION[$context.'InternalKey']; |
|
| 4933 | 4933 | } |
| 4934 | 4934 | } else { |
| 4935 | 4935 | switch (true) { |
@@ -4957,8 +4957,8 @@ discard block |
||
| 4957 | 4957 | $out = false; |
| 4958 | 4958 | |
| 4959 | 4959 | if (!empty($context)) { |
| 4960 | - if (is_scalar($context) && isset($_SESSION[$context . 'Validated'])) { |
|
| 4961 | - $out = $_SESSION[$context . 'Shortname']; |
|
| 4960 | + if (is_scalar($context) && isset($_SESSION[$context.'Validated'])) { |
|
| 4961 | + $out = $_SESSION[$context.'Shortname']; |
|
| 4962 | 4962 | } |
| 4963 | 4963 | } else { |
| 4964 | 4964 | switch (true) { |
@@ -5029,8 +5029,8 @@ discard block |
||
| 5029 | 5029 | */ |
| 5030 | 5030 | public function getWebUserInfo($uid) |
| 5031 | 5031 | { |
| 5032 | - $rs = $this->db->select('wu.username, wu.password, wua.*', $this->getFullTableName("web_users") . " wu |
|
| 5033 | - INNER JOIN " . $this->getFullTableName("web_user_attributes") . " wua ON wua.internalkey=wu.id", "wu.id='{$uid}'"); |
|
| 5032 | + $rs = $this->db->select('wu.username, wu.password, wua.*', $this->getFullTableName("web_users")." wu |
|
| 5033 | + INNER JOIN " . $this->getFullTableName("web_user_attributes")." wua ON wua.internalkey=wu.id", "wu.id='{$uid}'"); |
|
| 5034 | 5034 | if ($row = $this->db->getRow($rs)) { |
| 5035 | 5035 | if (!isset($row['usertype']) or !$row["usertype"]) { |
| 5036 | 5036 | $row["usertype"] = "web"; |
@@ -5066,7 +5066,7 @@ discard block |
||
| 5066 | 5066 | } else if (is_array($dg)) { |
| 5067 | 5067 | // resolve ids to names |
| 5068 | 5068 | $dgn = array(); |
| 5069 | - $ds = $this->db->select('name', $this->getFullTableName("documentgroup_names"), "id IN (" . implode(",", $dg) . ")"); |
|
| 5069 | + $ds = $this->db->select('name', $this->getFullTableName("documentgroup_names"), "id IN (".implode(",", $dg).")"); |
|
| 5070 | 5070 | while ($row = $this->db->getRow($ds)) { |
| 5071 | 5071 | $dgn[] = $row['name']; |
| 5072 | 5072 | } |
@@ -5094,7 +5094,7 @@ discard block |
||
| 5094 | 5094 | $rt = false; |
| 5095 | 5095 | if ($_SESSION["webValidated"] == 1) { |
| 5096 | 5096 | $tbl = $this->getFullTableName("web_users"); |
| 5097 | - $ds = $this->db->select('id, username, password', $tbl, "id='" . $this->getLoginUserID() . "'"); |
|
| 5097 | + $ds = $this->db->select('id, username, password', $tbl, "id='".$this->getLoginUserID()."'"); |
|
| 5098 | 5098 | if ($row = $this->db->getRow($ds)) { |
| 5099 | 5099 | if ($row["password"] == md5($oldPwd)) { |
| 5100 | 5100 | if (strlen($newPwd) < 6) { |
@@ -5104,7 +5104,7 @@ discard block |
||
| 5104 | 5104 | } else { |
| 5105 | 5105 | $this->db->update(array( |
| 5106 | 5106 | 'password' => $this->db->escape($newPwd), |
| 5107 | - ), $tbl, "id='" . $this->getLoginUserID() . "'"); |
|
| 5107 | + ), $tbl, "id='".$this->getLoginUserID()."'"); |
|
| 5108 | 5108 | // invoke OnWebChangePassword event |
| 5109 | 5109 | $this->invokeEvent("OnWebChangePassword", array( |
| 5110 | 5110 | "userid" => $row["id"], |
@@ -5135,8 +5135,8 @@ discard block |
||
| 5135 | 5135 | // check cache |
| 5136 | 5136 | $grpNames = isset ($_SESSION['webUserGroupNames']) ? $_SESSION['webUserGroupNames'] : false; |
| 5137 | 5137 | if (!is_array($grpNames)) { |
| 5138 | - $rs = $this->db->select('wgn.name', $this->getFullTableName("webgroup_names") . " wgn |
|
| 5139 | - INNER JOIN " . $this->getFullTableName("web_groups") . " wg ON wg.webgroup=wgn.id AND wg.webuser='" . $this->getLoginUserID() . "'"); |
|
| 5138 | + $rs = $this->db->select('wgn.name', $this->getFullTableName("webgroup_names")." wgn |
|
| 5139 | + INNER JOIN " . $this->getFullTableName("web_groups")." wg ON wg.webgroup=wgn.id AND wg.webuser='".$this->getLoginUserID()."'"); |
|
| 5140 | 5140 | $grpNames = $this->db->getColumn("name", $rs); |
| 5141 | 5141 | // save to cache |
| 5142 | 5142 | $_SESSION['webUserGroupNames'] = $grpNames; |
@@ -5169,7 +5169,7 @@ discard block |
||
| 5169 | 5169 | if (strpos(strtolower($src), "<style") !== false || strpos(strtolower($src), "<link") !== false) { |
| 5170 | 5170 | $this->sjscripts[$nextpos] = $src; |
| 5171 | 5171 | } else { |
| 5172 | - $this->sjscripts[$nextpos] = "\t" . '<link rel="stylesheet" type="text/css" href="' . $src . '" ' . ($media ? 'media="' . $media . '" ' : '') . '/>'; |
|
| 5172 | + $this->sjscripts[$nextpos] = "\t".'<link rel="stylesheet" type="text/css" href="'.$src.'" '.($media ? 'media="'.$media.'" ' : '').'/>'; |
|
| 5173 | 5173 | } |
| 5174 | 5174 | } |
| 5175 | 5175 | |
@@ -5248,7 +5248,7 @@ discard block |
||
| 5248 | 5248 | } |
| 5249 | 5249 | |
| 5250 | 5250 | if ($useThisVer && $plaintext != true && (strpos(strtolower($src), "<script") === false)) { |
| 5251 | - $src = "\t" . '<script type="text/javascript" src="' . $src . '"></script>'; |
|
| 5251 | + $src = "\t".'<script type="text/javascript" src="'.$src.'"></script>'; |
|
| 5252 | 5252 | } |
| 5253 | 5253 | if ($startup) { |
| 5254 | 5254 | $pos = isset($overwritepos) ? $overwritepos : max(array_merge(array(0), array_keys($this->sjscripts))) + 1; |
@@ -5395,7 +5395,7 @@ discard block |
||
| 5395 | 5395 | $eventtime = $this->getMicroTime() - $eventtime; |
| 5396 | 5396 | $this->pluginsCode .= sprintf('<fieldset><legend><b>%s / %s</b> (%2.2f ms)</legend>', $evtName, $pluginName, $eventtime * 1000); |
| 5397 | 5397 | foreach ($parameter as $k => $v) { |
| 5398 | - $this->pluginsCode .= "{$k} => " . print_r($v, true) . '<br>'; |
|
| 5398 | + $this->pluginsCode .= "{$k} => ".print_r($v, true).'<br>'; |
|
| 5399 | 5399 | } |
| 5400 | 5400 | $this->pluginsCode .= '</fieldset><br />'; |
| 5401 | 5401 | $this->pluginsTime["{$evtName} / {$pluginName}"] += $eventtime; |
@@ -5423,13 +5423,13 @@ discard block |
||
| 5423 | 5423 | $plugin = array(); |
| 5424 | 5424 | if (isset ($this->pluginCache[$pluginName])) { |
| 5425 | 5425 | $pluginCode = $this->pluginCache[$pluginName]; |
| 5426 | - $pluginProperties = isset($this->pluginCache[$pluginName . "Props"]) ? $this->pluginCache[$pluginName . "Props"] : ''; |
|
| 5426 | + $pluginProperties = isset($this->pluginCache[$pluginName."Props"]) ? $this->pluginCache[$pluginName."Props"] : ''; |
|
| 5427 | 5427 | } else { |
| 5428 | 5428 | $pluginName = $this->db->escape($pluginName); |
| 5429 | 5429 | $result = $this->db->select('name, plugincode, properties', $this->getFullTableName("site_plugins"), "name='{$pluginName}' AND disabled=0"); |
| 5430 | 5430 | if ($row = $this->db->getRow($result)) { |
| 5431 | 5431 | $pluginCode = $this->pluginCache[$row['name']] = $row['plugincode']; |
| 5432 | - $pluginProperties = $this->pluginCache[$row['name'] . "Props"] = $row['properties']; |
|
| 5432 | + $pluginProperties = $this->pluginCache[$row['name']."Props"] = $row['properties']; |
|
| 5433 | 5433 | } else { |
| 5434 | 5434 | $pluginCode = $this->pluginCache[$pluginName] = "return false;"; |
| 5435 | 5435 | $pluginProperties = ''; |
@@ -5536,7 +5536,7 @@ discard block |
||
| 5536 | 5536 | public function parseDocBlockFromFile($element_dir, $filename, $escapeValues = false) |
| 5537 | 5537 | { |
| 5538 | 5538 | $params = array(); |
| 5539 | - $fullpath = $element_dir . '/' . $filename; |
|
| 5539 | + $fullpath = $element_dir.'/'.$filename; |
|
| 5540 | 5540 | if (is_readable($fullpath)) { |
| 5541 | 5541 | $tpl = @fopen($fullpath, "r"); |
| 5542 | 5542 | if ($tpl) { |
@@ -5703,8 +5703,8 @@ discard block |
||
| 5703 | 5703 | $ph = array('site_url' => MODX_SITE_URL); |
| 5704 | 5704 | $regexUrl = "/((http|https|ftp|ftps)\:\/\/[^\/]+(\/[^\s]+[^,.?!:;\s])?)/"; |
| 5705 | 5705 | $regexEmail = '#([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)#i'; |
| 5706 | - $emailSubject = isset($parsed['name']) ? '?subject=' . $parsed['name'] : ''; |
|
| 5707 | - $emailSubject .= isset($parsed['version']) ? ' v' . $parsed['version'] : ''; |
|
| 5706 | + $emailSubject = isset($parsed['name']) ? '?subject='.$parsed['name'] : ''; |
|
| 5707 | + $emailSubject .= isset($parsed['version']) ? ' v'.$parsed['version'] : ''; |
|
| 5708 | 5708 | foreach ($parsed as $key => $val) { |
| 5709 | 5709 | if (is_array($val)) { |
| 5710 | 5710 | foreach ($val as $key2 => $val2) { |
@@ -5713,7 +5713,7 @@ discard block |
||
| 5713 | 5713 | $val2 = preg_replace($regexUrl, "<a href=\"{$url[0]}\" target=\"_blank\">{$url[0]}</a> ", $val2); |
| 5714 | 5714 | } |
| 5715 | 5715 | if (preg_match($regexEmail, $val2, $url)) { |
| 5716 | - $val2 = preg_replace($regexEmail, '<a href="mailto:\\1' . $emailSubject . '">\\1</a>', $val2); |
|
| 5716 | + $val2 = preg_replace($regexEmail, '<a href="mailto:\\1'.$emailSubject.'">\\1</a>', $val2); |
|
| 5717 | 5717 | } |
| 5718 | 5718 | $parsed[$key][$key2] = $val2; |
| 5719 | 5719 | } |
@@ -5723,7 +5723,7 @@ discard block |
||
| 5723 | 5723 | $val = preg_replace($regexUrl, "<a href=\"{$url[0]}\" target=\"_blank\">{$url[0]}</a> ", $val); |
| 5724 | 5724 | } |
| 5725 | 5725 | if (preg_match($regexEmail, $val, $url)) { |
| 5726 | - $val = preg_replace($regexEmail, '<a href="mailto:\\1' . $emailSubject . '">\\1</a>', $val); |
|
| 5726 | + $val = preg_replace($regexEmail, '<a href="mailto:\\1'.$emailSubject.'">\\1</a>', $val); |
|
| 5727 | 5727 | } |
| 5728 | 5728 | $parsed[$key] = $val; |
| 5729 | 5729 | } |
@@ -5737,32 +5737,32 @@ discard block |
||
| 5737 | 5737 | ); |
| 5738 | 5738 | |
| 5739 | 5739 | $nl = "\n"; |
| 5740 | - $list = isset($parsed['logo']) ? '<img src="' . $this->config['base_url'] . ltrim($parsed['logo'], "/") . '" style="float:right;max-width:100px;height:auto;" />' . $nl : ''; |
|
| 5741 | - $list .= '<p>' . $nl; |
|
| 5742 | - $list .= isset($parsed['name']) ? '<strong>' . $parsed['name'] . '</strong><br/>' . $nl : ''; |
|
| 5743 | - $list .= isset($parsed['description']) ? $parsed['description'] . $nl : ''; |
|
| 5744 | - $list .= '</p><br/>' . $nl; |
|
| 5745 | - $list .= isset($parsed['version']) ? '<p><strong>' . $_lang['version'] . ':</strong> ' . $parsed['version'] . '</p>' . $nl : ''; |
|
| 5746 | - $list .= isset($parsed['license']) ? '<p><strong>' . $_lang['license'] . ':</strong> ' . $parsed['license'] . '</p>' . $nl : ''; |
|
| 5747 | - $list .= isset($parsed['lastupdate']) ? '<p><strong>' . $_lang['last_update'] . ':</strong> ' . $parsed['lastupdate'] . '</p>' . $nl : ''; |
|
| 5748 | - $list .= '<br/>' . $nl; |
|
| 5740 | + $list = isset($parsed['logo']) ? '<img src="'.$this->config['base_url'].ltrim($parsed['logo'], "/").'" style="float:right;max-width:100px;height:auto;" />'.$nl : ''; |
|
| 5741 | + $list .= '<p>'.$nl; |
|
| 5742 | + $list .= isset($parsed['name']) ? '<strong>'.$parsed['name'].'</strong><br/>'.$nl : ''; |
|
| 5743 | + $list .= isset($parsed['description']) ? $parsed['description'].$nl : ''; |
|
| 5744 | + $list .= '</p><br/>'.$nl; |
|
| 5745 | + $list .= isset($parsed['version']) ? '<p><strong>'.$_lang['version'].':</strong> '.$parsed['version'].'</p>'.$nl : ''; |
|
| 5746 | + $list .= isset($parsed['license']) ? '<p><strong>'.$_lang['license'].':</strong> '.$parsed['license'].'</p>'.$nl : ''; |
|
| 5747 | + $list .= isset($parsed['lastupdate']) ? '<p><strong>'.$_lang['last_update'].':</strong> '.$parsed['lastupdate'].'</p>'.$nl : ''; |
|
| 5748 | + $list .= '<br/>'.$nl; |
|
| 5749 | 5749 | $first = true; |
| 5750 | 5750 | foreach ($arrayParams as $param => $label) { |
| 5751 | 5751 | if (isset($parsed[$param])) { |
| 5752 | 5752 | if ($first) { |
| 5753 | - $list .= '<p><strong>' . $_lang['references'] . '</strong></p>' . $nl; |
|
| 5754 | - $list .= '<ul class="docBlockList">' . $nl; |
|
| 5753 | + $list .= '<p><strong>'.$_lang['references'].'</strong></p>'.$nl; |
|
| 5754 | + $list .= '<ul class="docBlockList">'.$nl; |
|
| 5755 | 5755 | $first = false; |
| 5756 | 5756 | } |
| 5757 | - $list .= ' <li><strong>' . $label . '</strong>' . $nl; |
|
| 5758 | - $list .= ' <ul>' . $nl; |
|
| 5757 | + $list .= ' <li><strong>'.$label.'</strong>'.$nl; |
|
| 5758 | + $list .= ' <ul>'.$nl; |
|
| 5759 | 5759 | foreach ($parsed[$param] as $val) { |
| 5760 | - $list .= ' <li>' . $val . '</li>' . $nl; |
|
| 5760 | + $list .= ' <li>'.$val.'</li>'.$nl; |
|
| 5761 | 5761 | } |
| 5762 | - $list .= ' </ul></li>' . $nl; |
|
| 5762 | + $list .= ' </ul></li>'.$nl; |
|
| 5763 | 5763 | } |
| 5764 | 5764 | } |
| 5765 | - $list .= !$first ? '</ul>' . $nl : ''; |
|
| 5765 | + $list .= !$first ? '</ul>'.$nl : ''; |
|
| 5766 | 5766 | |
| 5767 | 5767 | return $list; |
| 5768 | 5768 | } |
@@ -5838,7 +5838,7 @@ discard block |
||
| 5838 | 5838 | */ |
| 5839 | 5839 | public function addSnippet($name, $phpCode) |
| 5840 | 5840 | { |
| 5841 | - $this->snippetCache['#' . $name] = $phpCode; |
|
| 5841 | + $this->snippetCache['#'.$name] = $phpCode; |
|
| 5842 | 5842 | } |
| 5843 | 5843 | |
| 5844 | 5844 | /** |
@@ -5847,7 +5847,7 @@ discard block |
||
| 5847 | 5847 | */ |
| 5848 | 5848 | public function addChunk($name, $text) |
| 5849 | 5849 | { |
| 5850 | - $this->chunkCache['#' . $name] = $text; |
|
| 5850 | + $this->chunkCache['#'.$name] = $text; |
|
| 5851 | 5851 | } |
| 5852 | 5852 | |
| 5853 | 5853 | /** |
@@ -5883,7 +5883,7 @@ discard block |
||
| 5883 | 5883 | } |
| 5884 | 5884 | |
| 5885 | 5885 | if (!$isSafe) { |
| 5886 | - $msg = $phpcode . "\n" . $this->currentSnippet . "\n" . print_r($_SERVER, true); |
|
| 5886 | + $msg = $phpcode."\n".$this->currentSnippet."\n".print_r($_SERVER, true); |
|
| 5887 | 5887 | $title = sprintf('Unknown eval was executed (%s)', $this->htmlspecialchars(substr(trim($phpcode), 0, 50))); |
| 5888 | 5888 | $this->messageQuit($title, '', true, '', '', 'Parser', $msg); |
| 5889 | 5889 | return; |
@@ -5897,7 +5897,7 @@ discard block |
||
| 5897 | 5897 | return 'array()'; |
| 5898 | 5898 | } |
| 5899 | 5899 | |
| 5900 | - $output = $echo . $return; |
|
| 5900 | + $output = $echo.$return; |
|
| 5901 | 5901 | modx_sanitize_gpc($output); |
| 5902 | 5902 | return $this->htmlspecialchars($output); // Maybe, all html tags are dangerous |
| 5903 | 5903 | } |
@@ -5915,8 +5915,8 @@ discard block |
||
| 5915 | 5915 | |
| 5916 | 5916 | $safe = explode(',', $safe_functions); |
| 5917 | 5917 | |
| 5918 | - $phpcode = rtrim($phpcode, ';') . ';'; |
|
| 5919 | - $tokens = token_get_all('<?php ' . $phpcode); |
|
| 5918 | + $phpcode = rtrim($phpcode, ';').';'; |
|
| 5919 | + $tokens = token_get_all('<?php '.$phpcode); |
|
| 5920 | 5920 | foreach ($tokens as $i => $token) { |
| 5921 | 5921 | if (!is_array($token)) { |
| 5922 | 5922 | continue; |
@@ -5952,7 +5952,7 @@ discard block |
||
| 5952 | 5952 | public function atBindFileContent($str = '') |
| 5953 | 5953 | { |
| 5954 | 5954 | |
| 5955 | - $search_path = array('assets/tvs/', 'assets/chunks/', 'assets/templates/', $this->config['rb_base_url'] . 'files/', ''); |
|
| 5955 | + $search_path = array('assets/tvs/', 'assets/chunks/', 'assets/templates/', $this->config['rb_base_url'].'files/', ''); |
|
| 5956 | 5956 | |
| 5957 | 5957 | if (stripos($str, '@FILE') !== 0) { |
| 5958 | 5958 | return $str; |
@@ -5975,7 +5975,7 @@ discard block |
||
| 5975 | 5975 | $errorMsg = sprintf("Could not retrieve string '%s'.", $str); |
| 5976 | 5976 | |
| 5977 | 5977 | foreach ($search_path as $path) { |
| 5978 | - $file_path = MODX_BASE_PATH . $path . $str; |
|
| 5978 | + $file_path = MODX_BASE_PATH.$path.$str; |
|
| 5979 | 5979 | if (strpos($file_path, MODX_MANAGER_PATH) === 0) { |
| 5980 | 5980 | return $errorMsg; |
| 5981 | 5981 | } elseif (is_file($file_path)) { |
@@ -5989,7 +5989,7 @@ discard block |
||
| 5989 | 5989 | return $errorMsg; |
| 5990 | 5990 | } |
| 5991 | 5991 | |
| 5992 | - $content = (string)file_get_contents($file_path); |
|
| 5992 | + $content = (string) file_get_contents($file_path); |
|
| 5993 | 5993 | if ($content === false) { |
| 5994 | 5994 | return $errorMsg; |
| 5995 | 5995 | } |
@@ -6102,22 +6102,22 @@ discard block |
||
| 6102 | 6102 | |
| 6103 | 6103 | $version = isset ($GLOBALS['modx_version']) ? $GLOBALS['modx_version'] : ''; |
| 6104 | 6104 | $release_date = isset ($GLOBALS['release_date']) ? $GLOBALS['release_date'] : ''; |
| 6105 | - $request_uri = "http://" . $_SERVER['HTTP_HOST'] . ($_SERVER["SERVER_PORT"] == 80 ? "" : (":" . $_SERVER["SERVER_PORT"])) . $_SERVER['REQUEST_URI']; |
|
| 6105 | + $request_uri = "http://".$_SERVER['HTTP_HOST'].($_SERVER["SERVER_PORT"] == 80 ? "" : (":".$_SERVER["SERVER_PORT"])).$_SERVER['REQUEST_URI']; |
|
| 6106 | 6106 | $request_uri = $this->htmlspecialchars($request_uri, ENT_QUOTES, $this->config['modx_charset']); |
| 6107 | 6107 | $ua = $this->htmlspecialchars($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, $this->config['modx_charset']); |
| 6108 | 6108 | $referer = $this->htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES, $this->config['modx_charset']); |
| 6109 | 6109 | if ($is_error) { |
| 6110 | 6110 | $str = '<h2 style="color:red">« Evo Parse Error »</h2>'; |
| 6111 | 6111 | if ($msg != 'PHP Parse Error') { |
| 6112 | - $str .= '<h3 style="color:red">' . $msg . '</h3>'; |
|
| 6112 | + $str .= '<h3 style="color:red">'.$msg.'</h3>'; |
|
| 6113 | 6113 | } |
| 6114 | 6114 | } else { |
| 6115 | 6115 | $str = '<h2 style="color:#003399">« Evo Debug/ stop message »</h2>'; |
| 6116 | - $str .= '<h3 style="color:#003399">' . $msg . '</h3>'; |
|
| 6116 | + $str .= '<h3 style="color:#003399">'.$msg.'</h3>'; |
|
| 6117 | 6117 | } |
| 6118 | 6118 | |
| 6119 | 6119 | if (!empty ($query)) { |
| 6120 | - $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">SQL > <span id="sqlHolder">' . $query . '</span></div>'; |
|
| 6120 | + $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">SQL > <span id="sqlHolder">'.$query.'</span></div>'; |
|
| 6121 | 6121 | } |
| 6122 | 6122 | |
| 6123 | 6123 | $errortype = array( |
@@ -6140,13 +6140,13 @@ discard block |
||
| 6140 | 6140 | |
| 6141 | 6141 | if (!empty($nr) || !empty($file)) { |
| 6142 | 6142 | if ($text != '') { |
| 6143 | - $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">Error : ' . $text . '</div>'; |
|
| 6143 | + $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">Error : '.$text.'</div>'; |
|
| 6144 | 6144 | } |
| 6145 | 6145 | if ($output != '') { |
| 6146 | - $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">' . $output . '</div>'; |
|
| 6146 | + $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">'.$output.'</div>'; |
|
| 6147 | 6147 | } |
| 6148 | 6148 | if ($nr !== '') { |
| 6149 | - $table[] = array('ErrorType[num]', $errortype [$nr] . "[" . $nr . "]"); |
|
| 6149 | + $table[] = array('ErrorType[num]', $errortype [$nr]."[".$nr."]"); |
|
| 6150 | 6150 | } |
| 6151 | 6151 | if ($file) { |
| 6152 | 6152 | $table[] = array('File', $file); |
@@ -6166,7 +6166,7 @@ discard block |
||
| 6166 | 6166 | } |
| 6167 | 6167 | |
| 6168 | 6168 | if (!empty($this->event->activePlugin)) { |
| 6169 | - $table[] = array('Current Plugin', $this->event->activePlugin . '(' . $this->event->name . ')'); |
|
| 6169 | + $table[] = array('Current Plugin', $this->event->activePlugin.'('.$this->event->name.')'); |
|
| 6170 | 6170 | } |
| 6171 | 6171 | |
| 6172 | 6172 | $str .= $MakeTable->create($table, array('Error information', '')); |
@@ -6176,17 +6176,17 @@ discard block |
||
| 6176 | 6176 | $table[] = array('REQUEST_URI', $request_uri); |
| 6177 | 6177 | |
| 6178 | 6178 | if ($this->manager->action) { |
| 6179 | - include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); |
|
| 6179 | + include_once(MODX_MANAGER_PATH.'includes/actionlist.inc.php'); |
|
| 6180 | 6180 | global $action_list; |
| 6181 | 6181 | $actionName = (isset($action_list[$this->manager->action])) ? " - {$action_list[$this->manager->action]}" : ''; |
| 6182 | 6182 | |
| 6183 | - $table[] = array('Manager action', $this->manager->action . $actionName); |
|
| 6183 | + $table[] = array('Manager action', $this->manager->action.$actionName); |
|
| 6184 | 6184 | } |
| 6185 | 6185 | |
| 6186 | 6186 | if (preg_match('@^[0-9]+@', $this->documentIdentifier)) { |
| 6187 | 6187 | $resource = $this->getDocumentObject('id', $this->documentIdentifier); |
| 6188 | 6188 | $url = $this->makeUrl($this->documentIdentifier, '', '', 'full'); |
| 6189 | - $table[] = array('Resource', '[' . $this->documentIdentifier . '] <a href="' . $url . '" target="_blank">' . $resource['pagetitle'] . '</a>'); |
|
| 6189 | + $table[] = array('Resource', '['.$this->documentIdentifier.'] <a href="'.$url.'" target="_blank">'.$resource['pagetitle'].'</a>'); |
|
| 6190 | 6190 | } |
| 6191 | 6191 | $table[] = array('Referer', $referer); |
| 6192 | 6192 | $table[] = array('User Agent', $ua); |
@@ -6207,7 +6207,7 @@ discard block |
||
| 6207 | 6207 | |
| 6208 | 6208 | $mem = memory_get_peak_usage(true); |
| 6209 | 6209 | $total_mem = $mem - $this->mstart; |
| 6210 | - $total_mem = ($total_mem / 1024 / 1024) . ' mb'; |
|
| 6210 | + $total_mem = ($total_mem / 1024 / 1024).' mb'; |
|
| 6211 | 6211 | |
| 6212 | 6212 | $queryTime = $this->queryTime; |
| 6213 | 6213 | $phpTime = $totalTime - $queryTime; |
@@ -6228,18 +6228,18 @@ discard block |
||
| 6228 | 6228 | $str .= $this->get_backtrace(debug_backtrace()); |
| 6229 | 6229 | // Log error |
| 6230 | 6230 | if (!empty($this->currentSnippet)) { |
| 6231 | - $source = 'Snippet - ' . $this->currentSnippet; |
|
| 6231 | + $source = 'Snippet - '.$this->currentSnippet; |
|
| 6232 | 6232 | } elseif (!empty($this->event->activePlugin)) { |
| 6233 | - $source = 'Plugin - ' . $this->event->activePlugin; |
|
| 6233 | + $source = 'Plugin - '.$this->event->activePlugin; |
|
| 6234 | 6234 | } elseif ($source !== '') { |
| 6235 | - $source = 'Parser - ' . $source; |
|
| 6235 | + $source = 'Parser - '.$source; |
|
| 6236 | 6236 | } elseif ($query !== '') { |
| 6237 | 6237 | $source = 'SQL Query'; |
| 6238 | 6238 | } else { |
| 6239 | 6239 | $source = 'Parser'; |
| 6240 | 6240 | } |
| 6241 | 6241 | if ($msg) { |
| 6242 | - $source .= ' / ' . $msg; |
|
| 6242 | + $source .= ' / '.$msg; |
|
| 6243 | 6243 | } |
| 6244 | 6244 | if (isset($actionName) && !empty($actionName)) { |
| 6245 | 6245 | $source .= $actionName; |
@@ -6271,12 +6271,12 @@ discard block |
||
| 6271 | 6271 | |
| 6272 | 6272 | // Display error |
| 6273 | 6273 | if (isset($_SESSION['mgrValidated'])) { |
| 6274 | - echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>EVO Content Manager ' . $version . ' » ' . $release_date . '</title> |
|
| 6274 | + echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>EVO Content Manager '.$version.' » '.$release_date.'</title> |
|
| 6275 | 6275 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6276 | - <link rel="stylesheet" type="text/css" href="' . $this->config['site_manager_url'] . 'media/style/' . $this->config['manager_theme'] . '/style.css" /> |
|
| 6276 | + <link rel="stylesheet" type="text/css" href="' . $this->config['site_manager_url'].'media/style/'.$this->config['manager_theme'].'/style.css" /> |
|
| 6277 | 6277 | <style type="text/css">body { padding:10px; } td {font:inherit;}</style> |
| 6278 | 6278 | </head><body> |
| 6279 | - ' . $str . '</body></html>'; |
|
| 6279 | + ' . $str.'</body></html>'; |
|
| 6280 | 6280 | |
| 6281 | 6281 | } else { |
| 6282 | 6282 | echo 'Error'; |
@@ -6314,7 +6314,7 @@ discard block |
||
| 6314 | 6314 | switch ($val['type']) { |
| 6315 | 6315 | case '->': |
| 6316 | 6316 | case '::': |
| 6317 | - $functionName = $val['function'] = $val['class'] . $val['type'] . $val['function']; |
|
| 6317 | + $functionName = $val['function'] = $val['class'].$val['type'].$val['function']; |
|
| 6318 | 6318 | break; |
| 6319 | 6319 | default: |
| 6320 | 6320 | $functionName = $val['function']; |
@@ -6324,7 +6324,7 @@ discard block |
||
| 6324 | 6324 | $args = array_pad(array(), $_, '$var'); |
| 6325 | 6325 | $args = implode(", ", $args); |
| 6326 | 6326 | $modx = &$this; |
| 6327 | - $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) { |
|
| 6327 | + $args = preg_replace_callback('/\$var/', function() use ($modx, &$tmp, $val) { |
|
| 6328 | 6328 | $arg = $val['args'][$tmp - 1]; |
| 6329 | 6329 | switch (true) { |
| 6330 | 6330 | case is_null($arg): { |
@@ -6336,7 +6336,7 @@ discard block |
||
| 6336 | 6336 | break; |
| 6337 | 6337 | } |
| 6338 | 6338 | case is_scalar($arg): { |
| 6339 | - $out = strlen($arg) > 20 ? 'string $var' . $tmp : ("'" . $this->htmlspecialchars(str_replace("'", "\\'", $arg)) . "'"); |
|
| 6339 | + $out = strlen($arg) > 20 ? 'string $var'.$tmp : ("'".$this->htmlspecialchars(str_replace("'", "\\'", $arg))."'"); |
|
| 6340 | 6340 | break; |
| 6341 | 6341 | } |
| 6342 | 6342 | case is_bool($arg): { |
@@ -6344,23 +6344,23 @@ discard block |
||
| 6344 | 6344 | break; |
| 6345 | 6345 | } |
| 6346 | 6346 | case is_array($arg): { |
| 6347 | - $out = 'array $var' . $tmp; |
|
| 6347 | + $out = 'array $var'.$tmp; |
|
| 6348 | 6348 | break; |
| 6349 | 6349 | } |
| 6350 | 6350 | case is_object($arg): { |
| 6351 | - $out = get_class($arg) . ' $var' . $tmp; |
|
| 6351 | + $out = get_class($arg).' $var'.$tmp; |
|
| 6352 | 6352 | break; |
| 6353 | 6353 | } |
| 6354 | 6354 | default: { |
| 6355 | - $out = '$var' . $tmp; |
|
| 6355 | + $out = '$var'.$tmp; |
|
| 6356 | 6356 | } |
| 6357 | 6357 | } |
| 6358 | 6358 | $tmp++; |
| 6359 | 6359 | return $out; |
| 6360 | 6360 | }, $args); |
| 6361 | 6361 | $line = array( |
| 6362 | - "<strong>" . $functionName . "</strong>(" . $args . ")", |
|
| 6363 | - $path . " on line " . $val['line'] |
|
| 6362 | + "<strong>".$functionName."</strong>(".$args.")", |
|
| 6363 | + $path." on line ".$val['line'] |
|
| 6364 | 6364 | ); |
| 6365 | 6365 | $table[] = array(implode("<br />", $line)); |
| 6366 | 6366 | } |
@@ -6401,7 +6401,7 @@ discard block |
||
| 6401 | 6401 | $alias = strip_tags($alias); // strip HTML |
| 6402 | 6402 | $alias = preg_replace('/[^\.A-Za-z0-9 _-]/', '', $alias); // strip non-alphanumeric characters |
| 6403 | 6403 | $alias = preg_replace('/\s+/', '-', $alias); // convert white-space to dash |
| 6404 | - $alias = preg_replace('/-+/', '-', $alias); // convert multiple dashes to one |
|
| 6404 | + $alias = preg_replace('/-+/', '-', $alias); // convert multiple dashes to one |
|
| 6405 | 6405 | $alias = trim($alias, '-'); // trim excess |
| 6406 | 6406 | return $alias; |
| 6407 | 6407 | } |
@@ -6417,7 +6417,7 @@ discard block |
||
| 6417 | 6417 | $precisions = count($sizes) - 1; |
| 6418 | 6418 | foreach ($sizes as $unit => $bytes) { |
| 6419 | 6419 | if ($size >= $bytes) { |
| 6420 | - return number_format($size / $bytes, $precisions) . ' ' . $unit; |
|
| 6420 | + return number_format($size / $bytes, $precisions).' '.$unit; |
|
| 6421 | 6421 | } |
| 6422 | 6422 | $precisions--; |
| 6423 | 6423 | } |
@@ -6521,10 +6521,10 @@ discard block |
||
| 6521 | 6521 | |
| 6522 | 6522 | if (strpos($str, MODX_MANAGER_PATH) === 0) { |
| 6523 | 6523 | return false; |
| 6524 | - } elseif (is_file(MODX_BASE_PATH . $str)) { |
|
| 6525 | - $file_path = MODX_BASE_PATH . $str; |
|
| 6526 | - } elseif (is_file(MODX_BASE_PATH . "{$tpl_dir}{$str}")) { |
|
| 6527 | - $file_path = MODX_BASE_PATH . $tpl_dir . $str; |
|
| 6524 | + } elseif (is_file(MODX_BASE_PATH.$str)) { |
|
| 6525 | + $file_path = MODX_BASE_PATH.$str; |
|
| 6526 | + } elseif (is_file(MODX_BASE_PATH."{$tpl_dir}{$str}")) { |
|
| 6527 | + $file_path = MODX_BASE_PATH.$tpl_dir.$str; |
|
| 6528 | 6528 | } else { |
| 6529 | 6529 | return false; |
| 6530 | 6530 | } |
@@ -6650,7 +6650,7 @@ discard block |
||
| 6650 | 6650 | $title = 'no title'; |
| 6651 | 6651 | } |
| 6652 | 6652 | if (is_array($msg)) { |
| 6653 | - $msg = '<pre>' . print_r($msg, true) . '</pre>'; |
|
| 6653 | + $msg = '<pre>'.print_r($msg, true).'</pre>'; |
|
| 6654 | 6654 | } elseif ($msg === '') { |
| 6655 | 6655 | $msg = $_SERVER['REQUEST_URI']; |
| 6656 | 6656 | } |
@@ -6695,7 +6695,7 @@ discard block |
||
| 6695 | 6695 | if (is_array($SystemAlertMsgQueque)) { |
| 6696 | 6696 | $title = ''; |
| 6697 | 6697 | if ($this->name && $this->activePlugin) { |
| 6698 | - $title = "<div><b>" . $this->activePlugin . "</b> - <span style='color:maroon;'>" . $this->name . "</span></div>"; |
|
| 6698 | + $title = "<div><b>".$this->activePlugin."</b> - <span style='color:maroon;'>".$this->name."</span></div>"; |
|
| 6699 | 6699 | } |
| 6700 | 6700 | $SystemAlertMsgQueque[] = "$title<div style='margin-left:10px;margin-top:3px;'>$msg</div>"; |
| 6701 | 6701 | } |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | - * @param string|array $fields |
|
| 244 | - * @param string|array $from |
|
| 245 | - * @param string|array $where |
|
| 243 | + * @param string $fields |
|
| 244 | + * @param string $from |
|
| 245 | + * @param string $where |
|
| 246 | 246 | * @param string $orderBy |
| 247 | 247 | * @param string $limit |
| 248 | 248 | * @return bool|mysqli_result |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param string $fromtable |
| 327 | 327 | * @param string $where |
| 328 | 328 | * @param string $limit |
| 329 | - * @return mixed |
|
| 329 | + * @return null|integer |
|
| 330 | 330 | */ |
| 331 | 331 | public function insert($fields, $intotable, $fromfields = "*", $fromtable = "", $where = "", $limit = "") |
| 332 | 332 | { |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | |
| 436 | 436 | /** |
| 437 | 437 | * @param null|mysqli $conn |
| 438 | - * @return mixed |
|
| 438 | + * @return integer |
|
| 439 | 439 | */ |
| 440 | 440 | public function getInsertId($conn = null) |
| 441 | 441 | { |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /** |
| 516 | - * @param $name |
|
| 516 | + * @param string $name |
|
| 517 | 517 | * @param mysqli_result|string $dsq |
| 518 | 518 | * @return array |
| 519 | 519 | */ |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | |
| 573 | 573 | /** |
| 574 | 574 | * @param string $table |
| 575 | - * @return array |
|
| 575 | + * @return boolean |
|
| 576 | 576 | */ |
| 577 | 577 | public function getTableMetaData($table) |
| 578 | 578 | { |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
| 622 | - * @param string|mysqli_result $rs |
|
| 622 | + * @param string $rs |
|
| 623 | 623 | * @param bool $index |
| 624 | 624 | * @return array |
| 625 | 625 | */ |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $pre = null, |
| 31 | 31 | $charset = '', |
| 32 | 32 | $connection_method = 'SET CHARACTER SET' |
| 33 | - ) { |
|
| 33 | + ){ |
|
| 34 | 34 | $this->config['host'] = $host ? $host : $GLOBALS['database_server']; |
| 35 | 35 | $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase']; |
| 36 | 36 | $this->config['user'] = $uid ? $uid : $GLOBALS['database_user']; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $ua = $modx->htmlspecialchars($_SERVER['HTTP_USER_AGENT']); |
| 71 | 71 | $referer = $modx->htmlspecialchars($_SERVER['HTTP_REFERER']); |
| 72 | 72 | $modx->sendmail(array( |
| 73 | - 'subject' => 'Missing to create the database connection! from ' . $modx->config['site_name'], |
|
| 73 | + 'subject' => 'Missing to create the database connection! from '.$modx->config['site_name'], |
|
| 74 | 74 | 'body' => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}", |
| 75 | 75 | 'type' => 'text' |
| 76 | 76 | )); |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | $tend = $modx->getMicroTime(); |
| 86 | 86 | $totaltime = $tend - $tstart; |
| 87 | 87 | if ($modx->dumpSQL) { |
| 88 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s", |
|
| 89 | - $totaltime) . "</fieldset><br />"; |
|
| 88 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s", |
|
| 89 | + $totaltime)."</fieldset><br />"; |
|
| 90 | 90 | } |
| 91 | 91 | $this->conn->set_charset($this->config['charset']); |
| 92 | 92 | $this->isConnected = true; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | if (1000 < $safeCount) { |
| 120 | 120 | exit("Too many loops '{$safeCount}'"); |
| 121 | 121 | } |
| 122 | - if ( ! ($this->conn instanceof mysqli)) { |
|
| 122 | + if (!($this->conn instanceof mysqli)) { |
|
| 123 | 123 | $this->connect(); |
| 124 | 124 | } |
| 125 | 125 | if (is_array($s)) { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public function query($sql, $watchError = true) |
| 146 | 146 | { |
| 147 | 147 | global $modx; |
| 148 | - if ( ! ($this->conn instanceof mysqli)) { |
|
| 148 | + if (!($this->conn instanceof mysqli)) { |
|
| 149 | 149 | $this->connect(); |
| 150 | 150 | } |
| 151 | 151 | $tStart = $modx->getMicroTime(); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | case 1091: |
| 166 | 166 | break; |
| 167 | 167 | default: |
| 168 | - $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql); |
|
| 168 | + $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql); |
|
| 169 | 169 | } |
| 170 | 170 | } else { |
| 171 | 171 | $tend = $modx->getMicroTime(); |
@@ -179,24 +179,24 @@ discard block |
||
| 179 | 179 | $debug_path[] = $line['function']; |
| 180 | 180 | } |
| 181 | 181 | $debug_path = implode(' > ', array_reverse($debug_path)); |
| 182 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms", |
|
| 183 | - $totalTime * 1000) . "</legend>"; |
|
| 184 | - $modx->queryCode .= $sql . '<br><br>'; |
|
| 182 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms", |
|
| 183 | + $totalTime * 1000)."</legend>"; |
|
| 184 | + $modx->queryCode .= $sql.'<br><br>'; |
|
| 185 | 185 | if ($modx->event->name) { |
| 186 | - $modx->queryCode .= 'Current Event => ' . $modx->event->name . '<br>'; |
|
| 186 | + $modx->queryCode .= 'Current Event => '.$modx->event->name.'<br>'; |
|
| 187 | 187 | } |
| 188 | 188 | if ($modx->event->activePlugin) { |
| 189 | - $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>'; |
|
| 189 | + $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>'; |
|
| 190 | 190 | } |
| 191 | 191 | if ($modx->currentSnippet) { |
| 192 | - $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>'; |
|
| 192 | + $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>'; |
|
| 193 | 193 | } |
| 194 | 194 | if (stripos($sql, 'select') === 0) { |
| 195 | - $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>'; |
|
| 195 | + $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>'; |
|
| 196 | 196 | } else { |
| 197 | - $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>'; |
|
| 197 | + $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>'; |
|
| 198 | 198 | } |
| 199 | - $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>'; |
|
| 199 | + $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>'; |
|
| 200 | 200 | $modx->queryCode .= "</fieldset><br />"; |
| 201 | 201 | } |
| 202 | 202 | $modx->executedQueries++; |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | if ($value === null || strtolower($value) === 'null') { |
| 304 | 304 | $f = 'NULL'; |
| 305 | 305 | } else { |
| 306 | - $f = "'" . $value . "'"; |
|
| 306 | + $f = "'".$value."'"; |
|
| 307 | 307 | } |
| 308 | - $fields[$key] = "`{$key}` = " . $f; |
|
| 308 | + $fields[$key] = "`{$key}` = ".$f; |
|
| 309 | 309 | } |
| 310 | 310 | $fields = implode(',', $fields); |
| 311 | 311 | } |
@@ -340,12 +340,12 @@ discard block |
||
| 340 | 340 | $this->query("INSERT INTO {$intotable} {$fields}"); |
| 341 | 341 | } else { |
| 342 | 342 | if (empty($fromtable)) { |
| 343 | - $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '", |
|
| 344 | - array_values($fields)) . "')"; |
|
| 343 | + $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '", |
|
| 344 | + array_values($fields))."')"; |
|
| 345 | 345 | $this->query("INSERT INTO {$intotable} {$fields}"); |
| 346 | 346 | } else { |
| 347 | 347 | $fromtable = $this->replaceFullTableName($fromtable); |
| 348 | - $fields = "(" . implode(",", array_keys($fields)) . ")"; |
|
| 348 | + $fields = "(".implode(",", array_keys($fields)).")"; |
|
| 349 | 349 | $where = trim($where); |
| 350 | 350 | $limit = trim($limit); |
| 351 | 351 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | */ |
| 440 | 440 | public function getInsertId($conn = null) |
| 441 | 441 | { |
| 442 | - if (! ($conn instanceof mysqli)) { |
|
| 443 | - $conn =& $this->conn; |
|
| 442 | + if (!($conn instanceof mysqli)) { |
|
| 443 | + $conn = & $this->conn; |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | return $conn->insert_id; |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | public function getAffectedRows($conn = null) |
| 454 | 454 | { |
| 455 | - if (! ($conn instanceof mysqli)) { |
|
| 456 | - $conn =& $this->conn; |
|
| 455 | + if (!($conn instanceof mysqli)) { |
|
| 456 | + $conn = & $this->conn; |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | return $conn->affected_rows; |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | public function getLastError($conn = null) |
| 467 | 467 | { |
| 468 | - if (! ($conn instanceof mysqli)) { |
|
| 469 | - $conn =& $this->conn; |
|
| 468 | + if (!($conn instanceof mysqli)) { |
|
| 469 | + $conn = & $this->conn; |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | return $conn->error; |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | { |
| 491 | 491 | $out = false; |
| 492 | 492 | if ($ds instanceof mysqli_result) { |
| 493 | - switch($mode){ |
|
| 493 | + switch ($mode) { |
|
| 494 | 494 | case 'assoc': |
| 495 | 495 | $out = $ds->fetch_assoc(); |
| 496 | 496 | break; |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | public function getColumn($name, $dsq) |
| 521 | 521 | { |
| 522 | 522 | $col = array(); |
| 523 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
| 523 | + if (!($dsq instanceof mysqli_result)) { |
|
| 524 | 524 | $dsq = $this->query($dsq); |
| 525 | 525 | } |
| 526 | 526 | if ($dsq) { |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | public function getColumnNames($dsq) |
| 540 | 540 | { |
| 541 | 541 | $names = array(); |
| 542 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
| 542 | + if (!($dsq instanceof mysqli_result)) { |
|
| 543 | 543 | $dsq = $this->query($dsq); |
| 544 | 544 | } |
| 545 | 545 | if ($dsq) { |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | public function getValue($dsq) |
| 560 | 560 | { |
| 561 | 561 | $out = false; |
| 562 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
| 562 | + if (!($dsq instanceof mysqli_result)) { |
|
| 563 | 563 | $dsq = $this->query($dsq); |
| 564 | 564 | } |
| 565 | 565 | if ($dsq) { |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | $tableName = trim($tableName); |
| 658 | 658 | $dbase = trim($this->config['dbase'], '`'); |
| 659 | 659 | $prefix = $this->config['table_prefix']; |
| 660 | - if ((bool)$force === true) { |
|
| 660 | + if ((bool) $force === true) { |
|
| 661 | 661 | $result = "`{$dbase}`.`{$prefix}{$tableName}`"; |
| 662 | 662 | } elseif (strpos($tableName, '[+prefix+]') !== false) { |
| 663 | 663 | $result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $tableName); |
@@ -373,7 +373,8 @@ discard block |
||
| 373 | 373 | * @return bool|mixed|mysqli_result |
| 374 | 374 | */ |
| 375 | 375 | public function save($fields, $table, $where = '') |
| 376 | - { // This is similar to "replace into table". |
|
| 376 | + { |
|
| 377 | +// This is similar to "replace into table". |
|
| 377 | 378 | |
| 378 | 379 | if ($where === '') { |
| 379 | 380 | $mode = 'insert'; |
@@ -490,7 +491,7 @@ discard block |
||
| 490 | 491 | { |
| 491 | 492 | $out = false; |
| 492 | 493 | if ($ds instanceof mysqli_result) { |
| 493 | - switch($mode){ |
|
| 494 | + switch($mode) { |
|
| 494 | 495 | case 'assoc': |
| 495 | 496 | $out = $ds->fetch_assoc(); |
| 496 | 497 | break; |
@@ -225,13 +225,13 @@ discard block |
||
| 225 | 225 | $orderBy = trim($orderBy); |
| 226 | 226 | $limit = trim($limit); |
| 227 | 227 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
| 228 | - $where = "WHERE {$where}"; |
|
| 228 | + $where = "where {$where}"; |
|
| 229 | 229 | } |
| 230 | 230 | if ($orderBy !== '' && stripos($orderBy, 'ORDER BY') !== 0) { |
| 231 | 231 | $orderBy = "ORDER BY {$orderBy}"; |
| 232 | 232 | } |
| 233 | 233 | if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) { |
| 234 | - $limit = "LIMIT {$limit}"; |
|
| 234 | + $limit = "limit {$limit}"; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $out = $this->query("DELETE FROM {$from} {$where} {$orderBy} {$limit}"); |
@@ -272,16 +272,16 @@ discard block |
||
| 272 | 272 | $orderBy = trim($orderBy); |
| 273 | 273 | $limit = trim($limit); |
| 274 | 274 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
| 275 | - $where = "WHERE {$where}"; |
|
| 275 | + $where = "where {$where}"; |
|
| 276 | 276 | } |
| 277 | 277 | if ($orderBy !== '' && stripos($orderBy, 'ORDER') !== 0) { |
| 278 | 278 | $orderBy = "ORDER BY {$orderBy}"; |
| 279 | 279 | } |
| 280 | 280 | if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) { |
| 281 | - $limit = "LIMIT {$limit}"; |
|
| 281 | + $limit = "limit {$limit}"; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - return $this->query("SELECT {$fields} FROM {$from} {$where} {$orderBy} {$limit}"); |
|
| 284 | + return $this->query("select {$fields} FROM {$from} {$where} {$orderBy} {$limit}"); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -349,10 +349,10 @@ discard block |
||
| 349 | 349 | $where = trim($where); |
| 350 | 350 | $limit = trim($limit); |
| 351 | 351 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
| 352 | - $where = "WHERE {$where}"; |
|
| 352 | + $where = "where {$where}"; |
|
| 353 | 353 | } |
| 354 | 354 | if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) { |
| 355 | - $limit = "LIMIT {$limit}"; |
|
| 355 | + $limit = "limit {$limit}"; |
|
| 356 | 356 | } |
| 357 | 357 | $this->query("INSERT INTO {$intotable} {$fields} SELECT {$fromfields} FROM {$fromtable} {$where} {$limit}"); |
| 358 | 358 | } |
@@ -278,8 +278,7 @@ discard block |
||
| 278 | 278 | /** |
| 279 | 279 | * Sets the width attribute of each column in the array. |
| 280 | 280 | * |
| 281 | - * @param array $value An Array of column widths in the order of the keys in the |
|
| 282 | - * source table array. |
|
| 281 | + * @param string[] $widthArray |
|
| 283 | 282 | */ |
| 284 | 283 | public function setColumnWidths($widthArray) |
| 285 | 284 | { |
@@ -289,7 +288,6 @@ discard block |
||
| 289 | 288 | /** |
| 290 | 289 | * An optional array of values that can be preselected when using |
| 291 | 290 | * |
| 292 | - * @param array $value Indicates the INPUT form element type attribute. |
|
| 293 | 291 | */ |
| 294 | 292 | public function setSelectedValues($valueArray) |
| 295 | 293 | { |
@@ -326,7 +324,7 @@ discard block |
||
| 326 | 324 | /** |
| 327 | 325 | * Determines what class the current row should have applied. |
| 328 | 326 | * |
| 329 | - * @param int $value The position of the current row being rendered. |
|
| 327 | + * @param integer $position |
|
| 330 | 328 | * @return string |
| 331 | 329 | */ |
| 332 | 330 | public function determineRowClass($position) |
@@ -353,7 +351,6 @@ discard block |
||
| 353 | 351 | * Generates an onclick action applied to the current cell, to execute |
| 354 | 352 | * any specified cell actions. |
| 355 | 353 | * |
| 356 | - * @param string $value Indicates the INPUT form element type attribute. |
|
| 357 | 354 | * @return string |
| 358 | 355 | */ |
| 359 | 356 | public function getCellAction($currentActionFieldValue) |
@@ -395,7 +392,7 @@ discard block |
||
| 395 | 392 | /** |
| 396 | 393 | * Function to prepare a link generated in the table cell/link actions. |
| 397 | 394 | * |
| 398 | - * @param string $value Indicates the INPUT form element type attribute. |
|
| 395 | + * @param string $link |
|
| 399 | 396 | * @return string |
| 400 | 397 | */ |
| 401 | 398 | public function prepareLink($link) |
@@ -414,7 +411,7 @@ discard block |
||
| 414 | 411 | * |
| 415 | 412 | * @param array $fieldsArray The associative array representing the table rows |
| 416 | 413 | * and columns. |
| 417 | - * @param array $fieldHeadersArray An optional array of values for providing |
|
| 414 | + * @param string[] $fieldHeadersArray An optional array of values for providing |
|
| 418 | 415 | * alternative field headers; this is an associative arrays of keys from |
| 419 | 416 | * the $fieldsArray where the values represent the alt heading content |
| 420 | 417 | * for each column. |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function setTableWidth($value) |
| 132 | 132 | { |
| 133 | - $this->tableWidth = (int)$value; |
|
| 133 | + $this->tableWidth = (int) $value; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | { |
| 318 | 318 | $currentWidth = ''; |
| 319 | 319 | if (is_array($this->columnWidths)) { |
| 320 | - $currentWidth = $this->columnWidths[$columnPosition] ? ' width="' . $this->columnWidths[$columnPosition] . '" ' : ''; |
|
| 320 | + $currentWidth = $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : ''; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | return $currentWidth; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | $currentClass = $this->rowAlternateClass; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - return ' class="' . $currentClass . '"'; |
|
| 349 | + return ' class="'.$currentClass.'"'; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | { |
| 361 | 361 | $cellAction = ''; |
| 362 | 362 | if ($this->cellAction) { |
| 363 | - $cellAction = ' onClick="javascript:window.location=\'' . $this->cellAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '\'" '; |
|
| 363 | + $cellAction = ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" '; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | return $cellAction; |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | { |
| 378 | 378 | $cell = $value; |
| 379 | 379 | if ($this->linkAction) { |
| 380 | - $cell = '<a href="' . $this->linkAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '">' . $cell . '</a>'; |
|
| 380 | + $cell = '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>'; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | return $cell; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | $end = '?'; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - return $link . $end; |
|
| 409 | + return $link.$end; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | if (is_array($fieldsArray)) { |
| 427 | 427 | $i = 0; |
| 428 | 428 | foreach ($fieldsArray as $fieldName => $fieldValue) { |
| 429 | - $table .= "\t<tr" . $this->determineRowClass($i) . ">\n"; |
|
| 429 | + $table .= "\t<tr".$this->determineRowClass($i).">\n"; |
|
| 430 | 430 | $currentActionFieldValue = $fieldValue[$this->actionField]; |
| 431 | 431 | if (is_array($this->selectedValues)) { |
| 432 | 432 | $isChecked = array_search($currentActionFieldValue, $this->selectedValues) === false ? 0 : 1; |
@@ -437,15 +437,15 @@ discard block |
||
| 437 | 437 | $colPosition = 0; |
| 438 | 438 | foreach ($fieldValue as $key => $value) { |
| 439 | 439 | if (!in_array($key, $this->excludeFields)) { |
| 440 | - $table .= "\t\t<td" . $this->getCellAction($currentActionFieldValue) . ">"; |
|
| 440 | + $table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">"; |
|
| 441 | 441 | $table .= $this->createCellText($currentActionFieldValue, $value); |
| 442 | 442 | $table .= "</td>\n"; |
| 443 | 443 | if ($i == 0) { |
| 444 | 444 | if (empty ($header) && $this->formElementType) { |
| 445 | - $header .= "\t\t<th style=\"width:32px\" " . ($this->thClass ? 'class="' . $this->thClass . '"' : '') . ">" . ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '') . "</th>\n"; |
|
| 445 | + $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">".($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n"; |
|
| 446 | 446 | } |
| 447 | 447 | $headerText = array_key_exists($key, $fieldHeadersArray) ? $fieldHeadersArray[$key] : $key; |
| 448 | - $header .= "\t\t<th" . $this->getColumnWidth($colPosition) . ($this->thClass ? ' class="' . $this->thClass . '" ' : '') . ">" . $headerText . "</th>\n"; |
|
| 448 | + $header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n"; |
|
| 449 | 449 | } |
| 450 | 450 | $colPosition++; |
| 451 | 451 | } |
@@ -453,9 +453,9 @@ discard block |
||
| 453 | 453 | $i++; |
| 454 | 454 | $table .= "\t</tr>\n"; |
| 455 | 455 | } |
| 456 | - $table = "\n" . '<table' . ($this->tableWidth > 0 ? ' width="' . $this->tableWidth . '"' : '') . ($this->tableClass ? ' class="' . $this->tableClass . '"' : '') . ($this->tableID ? ' id="' . $this->tableID . '"' : '') . ">\n" . ($header ? "\t<thead>\n\t<tr class=\"" . $this->rowHeaderClass . "\">\n" . $header . "\t</tr>\n\t</thead>\n" : '') . $table . "</table>\n"; |
|
| 456 | + $table = "\n".'<table'.($this->tableWidth > 0 ? ' width="'.$this->tableWidth.'"' : '').($this->tableClass ? ' class="'.$this->tableClass.'"' : '').($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n".($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n"; |
|
| 457 | 457 | if ($this->formElementType) { |
| 458 | - $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table; |
|
| 458 | + $table = "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table; |
|
| 459 | 459 | } |
| 460 | 460 | if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
| 461 | 461 | /* commented this part because of cookie |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | |
| 470 | 470 | $table .= '</select>'.$_lang["pagination_table_perpage"].'</div>'; |
| 471 | 471 | */ |
| 472 | - $table .= '<div id="pagination" class="paginate">' . $_lang["pagination_table_gotopage"] . '<ul>' . $this->pageNav . '</ul></div>'; |
|
| 472 | + $table .= '<div id="pagination" class="paginate">'.$_lang["pagination_table_gotopage"].'<ul>'.$this->pageNav.'</ul></div>'; |
|
| 473 | 473 | //$table .= '<script language="javascript">function updatePageSize(size){window.location = \''.$this->prepareLink($linkpage).'pageSize=\'+size;}</script>'; |
| 474 | 474 | |
| 475 | 475 | } |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | <script language="javascript"> |
| 479 | 479 | toggled = 0; |
| 480 | 480 | function clickAll() { |
| 481 | - myform = document.getElementById("' . $this->formName . '"); |
|
| 481 | + myform = document.getElementById("' . $this->formName.'"); |
|
| 482 | 482 | for(i=0;i<myform.length;i++) { |
| 483 | 483 | if(myform.elements[i].type==\'checkbox\') { |
| 484 | 484 | myform.elements[i].checked=(toggled?false:true); |
@@ -490,9 +490,9 @@ discard block |
||
| 490 | 490 | } |
| 491 | 491 | if ($this->formElementType) { |
| 492 | 492 | if ($this->extra) { |
| 493 | - $table .= "\n" . $this->extra . "\n"; |
|
| 493 | + $table .= "\n".$this->extra."\n"; |
|
| 494 | 494 | } |
| 495 | - $table .= "\n" . '</form>' . "\n"; |
|
| 495 | + $table .= "\n".'</form>'."\n"; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | return $table; |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $numPages = ceil($numRecords / MAX_DISPLAY_RECORDS_NUM); |
| 516 | 516 | $nav = ''; |
| 517 | 517 | if ($numPages > 1) { |
| 518 | - $currentURL = empty($qs) ? '' : '?' . $qs; |
|
| 518 | + $currentURL = empty($qs) ? '' : '?'.$qs; |
|
| 519 | 519 | if ($currentPage > 6) { |
| 520 | 520 | $nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]); |
| 521 | 521 | } |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]); |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | - $this->pageNav = ' ' . $nav; |
|
| 543 | + $this->pageNav = ' '.$nav; |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
@@ -556,14 +556,14 @@ discard block |
||
| 556 | 556 | public function createPageLink($link = '', $pageNum, $displayText, $currentPage = false, $qs = '') |
| 557 | 557 | { |
| 558 | 558 | global $modx; |
| 559 | - $orderBy = !empty($_GET['orderby']) ? '&orderby=' . $_GET['orderby'] : ''; |
|
| 560 | - $orderDir = !empty($_GET['orderdir']) ? '&orderdir=' . $_GET['orderdir'] : ''; |
|
| 559 | + $orderBy = !empty($_GET['orderby']) ? '&orderby='.$_GET['orderby'] : ''; |
|
| 560 | + $orderDir = !empty($_GET['orderdir']) ? '&orderdir='.$_GET['orderdir'] : ''; |
|
| 561 | 561 | if (!empty($qs)) { |
| 562 | 562 | $qs = "?$qs"; |
| 563 | 563 | } |
| 564 | 564 | $link = empty($link) ? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], |
| 565 | - $qs . "page=$pageNum$orderBy$orderDir") : $this->prepareLink($link) . "page=$pageNum"; |
|
| 566 | - $nav = '<li' . ($currentPage ? ' class="currentPage"' : '') . '><a' . ($currentPage ? ' class="currentPage"' : '') . ' href="' . $link . '">' . $displayText . '</a></li>' . "\n"; |
|
| 565 | + $qs."page=$pageNum$orderBy$orderDir") : $this->prepareLink($link)."page=$pageNum"; |
|
| 566 | + $nav = '<li'.($currentPage ? ' class="currentPage"' : '').'><a'.($currentPage ? ' class="currentPage"' : '').' href="'.$link.'">'.$displayText.'</a></li>'."\n"; |
|
| 567 | 567 | |
| 568 | 568 | return $nav; |
| 569 | 569 | } |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | $field = ''; |
| 582 | 582 | if ($this->formElementType) { |
| 583 | 583 | $checked = $isChecked ? "checked " : ""; |
| 584 | - $field = "\t\t" . '<td><input type="' . $this->formElementType . '" name="' . ($this->formElementName ? $this->formElementName : $value) . '" value="' . $value . '" ' . $checked . '/></td>' . "\n"; |
|
| 584 | + $field = "\t\t".'<td><input type="'.$this->formElementType.'" name="'.($this->formElementName ? $this->formElementName : $value).'" value="'.$value.'" '.$checked.'/></td>'."\n"; |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | return $field; |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | public function handlePaging() |
| 596 | 596 | { |
| 597 | 597 | $offset = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0; |
| 598 | - $limitClause = ' LIMIT ' . ($offset * MAX_DISPLAY_RECORDS_NUM) . ', ' . MAX_DISPLAY_RECORDS_NUM; |
|
| 598 | + $limitClause = ' LIMIT '.($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM; |
|
| 599 | 599 | |
| 600 | 600 | return $limitClause; |
| 601 | 601 | } |
@@ -610,10 +610,10 @@ discard block |
||
| 610 | 610 | public function handleSorting($natural_order = false) |
| 611 | 611 | { |
| 612 | 612 | $orderByClause = ''; |
| 613 | - if ((bool)$natural_order === false) { |
|
| 613 | + if ((bool) $natural_order === false) { |
|
| 614 | 614 | $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : "id"; |
| 615 | 615 | $orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "DESC"; |
| 616 | - $orderByClause = !empty($orderby) ? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ' : ""; |
|
| 616 | + $orderByClause = !empty($orderby) ? ' ORDER BY '.$orderby.' '.$orderdir.' ' : ""; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | return $orderByClause; |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - return '<a href="[~' . $modx->documentIdentifier . '~]?' . $qs . 'orderby=' . $key . $orderDir . '">' . $text . '</a>'; |
|
| 645 | + return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>'; |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | } |
@@ -457,7 +457,8 @@ |
||
| 457 | 457 | if ($this->formElementType) { |
| 458 | 458 | $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table; |
| 459 | 459 | } |
| 460 | - if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
|
| 460 | + if (strlen($this->pageNav) > 1) { |
|
| 461 | +//changed to display the pagination if exists. |
|
| 461 | 462 | /* commented this part because of cookie |
| 462 | 463 | $table .= '<div id="max-display-records" ><select style="display:inline" onchange="javascript:updatePageSize(this[this.selectedIndex].value);">'; |
| 463 | 464 | $pageSizes= array (10, 25, 50, 100, 250); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | /** |
| 96 | 96 | * @param string $mode |
| 97 | 97 | * @param string $modifiers |
| 98 | - * @return bool|string |
|
| 98 | + * @return false|string |
|
| 99 | 99 | */ |
| 100 | 100 | public function _getDelim($mode,$modifiers) { |
| 101 | 101 | $c = substr($modifiers,0,1); |
@@ -132,6 +132,14 @@ discard block |
||
| 132 | 132 | return $opt; |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * @param string $mode |
|
| 138 | + * @param false|string $delim |
|
| 139 | + * @param string $modifiers |
|
| 140 | + * |
|
| 141 | + * @return string |
|
| 142 | + */ |
|
| 135 | 143 | public function _getRemainModifiers($mode,$delim,$modifiers) { |
| 136 | 144 | if($delim) { |
| 137 | 145 | if($mode=='(') |
@@ -159,6 +167,9 @@ discard block |
||
| 159 | 167 | return substr($string,strpos($string, $delim)+$len); |
| 160 | 168 | } |
| 161 | 169 | |
| 170 | + /** |
|
| 171 | + * @param string $modifiers |
|
| 172 | + */ |
|
| 162 | 173 | public function splitEachModifiers($modifiers) { |
| 163 | 174 | global $modx; |
| 164 | 175 | |
@@ -228,6 +239,9 @@ discard block |
||
| 228 | 239 | return $result; |
| 229 | 240 | } |
| 230 | 241 | |
| 242 | + /** |
|
| 243 | + * @param string $key |
|
| 244 | + */ |
|
| 231 | 245 | public function parsePhx($key,$value,$modifiers) |
| 232 | 246 | { |
| 233 | 247 | global $modx; |
@@ -294,6 +308,9 @@ discard block |
||
| 294 | 308 | else return true; |
| 295 | 309 | } |
| 296 | 310 | |
| 311 | + /** |
|
| 312 | + * @param string $cmd |
|
| 313 | + */ |
|
| 297 | 314 | public function getValueFromPreset($key, $value, $cmd, $opt) |
| 298 | 315 | { |
| 299 | 316 | global $modx; |
@@ -979,6 +996,9 @@ discard block |
||
| 979 | 996 | return $value; |
| 980 | 997 | } |
| 981 | 998 | |
| 999 | + /** |
|
| 1000 | + * @param string $cmd |
|
| 1001 | + */ |
|
| 982 | 1002 | public function includeMdfFile($cmd) { |
| 983 | 1003 | global $modx; |
| 984 | 1004 | $key = $this->key; |
@@ -1134,6 +1154,10 @@ discard block |
||
| 1134 | 1154 | } |
| 1135 | 1155 | |
| 1136 | 1156 | // Sets a placeholder variable which can only be access by Modifiers |
| 1157 | + |
|
| 1158 | + /** |
|
| 1159 | + * @param string $value |
|
| 1160 | + */ |
|
| 1137 | 1161 | public function setModifiersVariable($key, $value) { |
| 1138 | 1162 | if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value; |
| 1139 | 1163 | } |
@@ -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 | * @var array |
| 8 | 8 | */ |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | * @param string $modifiers |
| 72 | 72 | * @return bool|mixed|string |
| 73 | 73 | */ |
| 74 | - public function phxFilter($key,$value,$modifiers) |
|
| 74 | + public function phxFilter($key, $value, $modifiers) |
|
| 75 | 75 | { |
| 76 | 76 | global $modx; |
| 77 | - if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value); |
|
| 77 | + if (substr($modifiers, 0, 3) !== 'id(') $value = $this->parseDocumentSource($value); |
|
| 78 | 78 | $this->srcValue = $value; |
| 79 | 79 | $modifiers = trim($modifiers); |
| 80 | - $modifiers = ':'.trim($modifiers,':'); |
|
| 81 | - $modifiers = str_replace(array("\r\n","\r"), "\n", $modifiers); |
|
| 80 | + $modifiers = ':'.trim($modifiers, ':'); |
|
| 81 | + $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers); |
|
| 82 | 82 | $modifiers = $this->splitEachModifiers($modifiers); |
| 83 | 83 | |
| 84 | 84 | $this->placeholders = array(); |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | $this->placeholders['dummy'] = ''; |
| 87 | 87 | $this->condition = array(); |
| 88 | 88 | $this->vars = array(); |
| 89 | - $this->vars['name'] = & $key; |
|
| 90 | - $value = $this->parsePhx($key,$value,$modifiers); |
|
| 89 | + $this->vars['name'] = & $key; |
|
| 90 | + $value = $this->parsePhx($key, $value, $modifiers); |
|
| 91 | 91 | $this->vars = array(); |
| 92 | 92 | return $value; |
| 93 | 93 | } |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | * @param string $modifiers |
| 98 | 98 | * @return bool|string |
| 99 | 99 | */ |
| 100 | - public function _getDelim($mode,$modifiers) { |
|
| 101 | - $c = substr($modifiers,0,1); |
|
| 102 | - if(!in_array($c, array('"', "'", '`')) ) return false; |
|
| 100 | + public function _getDelim($mode, $modifiers){ |
|
| 101 | + $c = substr($modifiers, 0, 1); |
|
| 102 | + if (!in_array($c, array('"', "'", '`'))) return false; |
|
| 103 | 103 | |
| 104 | - $modifiers = substr($modifiers,1); |
|
| 105 | - $closure = $mode=='(' ? "{$c})" : $c; |
|
| 106 | - if(strpos($modifiers, $closure)===false) return false; |
|
| 104 | + $modifiers = substr($modifiers, 1); |
|
| 105 | + $closure = $mode == '(' ? "{$c})" : $c; |
|
| 106 | + if (strpos($modifiers, $closure) === false) return false; |
|
| 107 | 107 | |
| 108 | 108 | return $c; |
| 109 | 109 | } |
@@ -114,101 +114,101 @@ discard block |
||
| 114 | 114 | * @param string $modifiers |
| 115 | 115 | * @return bool|string |
| 116 | 116 | */ |
| 117 | - public function _getOpt($mode,$delim,$modifiers) { |
|
| 118 | - if($delim) { |
|
| 119 | - if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); |
|
| 117 | + public function _getOpt($mode, $delim, $modifiers){ |
|
| 118 | + if ($delim) { |
|
| 119 | + if ($mode == '(') return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1); |
|
| 120 | 120 | |
| 121 | - return substr($modifiers,1,strpos($modifiers,$delim,1)-1); |
|
| 121 | + return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1); |
|
| 122 | 122 | } |
| 123 | 123 | else { |
| 124 | - if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') ); |
|
| 124 | + if ($mode == '(') return substr($modifiers, 0, strpos($modifiers, ')')); |
|
| 125 | 125 | |
| 126 | 126 | $chars = str_split($modifiers); |
| 127 | - $opt=''; |
|
| 128 | - foreach($chars as $c) { |
|
| 129 | - if($c==':' || $c==')') break; |
|
| 130 | - $opt .=$c; |
|
| 127 | + $opt = ''; |
|
| 128 | + foreach ($chars as $c) { |
|
| 129 | + if ($c == ':' || $c == ')') break; |
|
| 130 | + $opt .= $c; |
|
| 131 | 131 | } |
| 132 | 132 | return $opt; |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | - public function _getRemainModifiers($mode,$delim,$modifiers) { |
|
| 136 | - if($delim) { |
|
| 137 | - if($mode=='(') |
|
| 138 | - return $this->_fetchContent($modifiers, $delim . ')'); |
|
| 135 | + public function _getRemainModifiers($mode, $delim, $modifiers){ |
|
| 136 | + if ($delim) { |
|
| 137 | + if ($mode == '(') |
|
| 138 | + return $this->_fetchContent($modifiers, $delim.')'); |
|
| 139 | 139 | else { |
| 140 | 140 | $modifiers = trim($modifiers); |
| 141 | - $modifiers = substr($modifiers,1); |
|
| 141 | + $modifiers = substr($modifiers, 1); |
|
| 142 | 142 | return $this->_fetchContent($modifiers, $delim); |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | else { |
| 146 | - if($mode=='(') return $this->_fetchContent($modifiers, ')'); |
|
| 146 | + if ($mode == '(') return $this->_fetchContent($modifiers, ')'); |
|
| 147 | 147 | $chars = str_split($modifiers); |
| 148 | - foreach($chars as $c) { |
|
| 149 | - if($c==':') return $modifiers; |
|
| 150 | - else $modifiers = substr($modifiers,1); |
|
| 148 | + foreach ($chars as $c) { |
|
| 149 | + if ($c == ':') return $modifiers; |
|
| 150 | + else $modifiers = substr($modifiers, 1); |
|
| 151 | 151 | } |
| 152 | 152 | return $modifiers; |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function _fetchContent($string,$delim) { |
|
| 156 | + public function _fetchContent($string, $delim){ |
|
| 157 | 157 | $len = strlen($delim); |
| 158 | 158 | $string = $this->parseDocumentSource($string); |
| 159 | - return substr($string,strpos($string, $delim)+$len); |
|
| 159 | + return substr($string, strpos($string, $delim) + $len); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public function splitEachModifiers($modifiers) { |
|
| 162 | + public function splitEachModifiers($modifiers){ |
|
| 163 | 163 | global $modx; |
| 164 | 164 | |
| 165 | 165 | $cmd = ''; |
| 166 | 166 | $bt = ''; |
| 167 | 167 | $result = array(); |
| 168 | - while($bt!==$modifiers) { |
|
| 168 | + while ($bt !== $modifiers) { |
|
| 169 | 169 | $bt = $modifiers; |
| 170 | - $c = substr($modifiers,0,1); |
|
| 171 | - $modifiers = substr($modifiers,1); |
|
| 170 | + $c = substr($modifiers, 0, 1); |
|
| 171 | + $modifiers = substr($modifiers, 1); |
|
| 172 | 172 | |
| 173 | - if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
| 174 | - $c = substr($modifiers,strlen($match[1]),1); |
|
| 173 | + if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
| 174 | + $c = substr($modifiers, strlen($match[1]), 1); |
|
| 175 | 175 | $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]"; |
| 176 | - if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1); |
|
| 177 | - else $modifiers = substr($modifiers,strlen($match[1])); |
|
| 176 | + if ($c === '(') $modifiers = substr($modifiers, strlen($match[1]) + 1); |
|
| 177 | + else $modifiers = substr($modifiers, strlen($match[1])); |
|
| 178 | 178 | |
| 179 | - $delim = $this->_getDelim($c,$modifiers); |
|
| 180 | - $opt = $this->_getOpt($c,$delim,$modifiers); |
|
| 181 | - $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers)); |
|
| 179 | + $delim = $this->_getDelim($c, $modifiers); |
|
| 180 | + $opt = $this->_getOpt($c, $delim, $modifiers); |
|
| 181 | + $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers)); |
|
| 182 | 182 | |
| 183 | - $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo); |
|
| 183 | + $result[] = array('cmd'=>trim($match[1]), 'opt'=>$opt, 'debuginfo'=>$debuginfo); |
|
| 184 | 184 | $cmd = ''; |
| 185 | 185 | } |
| 186 | - elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
| 187 | - $modifiers = substr($modifiers,strlen($match[0])); |
|
| 188 | - $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]); |
|
| 186 | + elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
| 187 | + $modifiers = substr($modifiers, strlen($match[0])); |
|
| 188 | + $result[] = array('cmd'=>'math', 'opt'=>'%s'.$c.$match[0]); |
|
| 189 | 189 | $cmd = ''; |
| 190 | 190 | } |
| 191 | - elseif($c==='(' || $c==='=') { |
|
| 191 | + elseif ($c === '(' || $c === '=') { |
|
| 192 | 192 | $modifiers = $m1 = trim($modifiers); |
| 193 | - $delim = $this->_getDelim($c,$modifiers); |
|
| 194 | - $opt = $this->_getOpt($c,$delim,$modifiers); |
|
| 195 | - $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers)); |
|
| 193 | + $delim = $this->_getDelim($c, $modifiers); |
|
| 194 | + $opt = $this->_getOpt($c, $delim, $modifiers); |
|
| 195 | + $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers)); |
|
| 196 | 196 | $debuginfo = "#i=1 #c=[{$c}] #delim=[{$delim}] #m1=[{$m1}] remainMdf=[{$modifiers}]"; |
| 197 | 197 | |
| 198 | - $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo); |
|
| 198 | + $result[] = array('cmd'=>trim($cmd), 'opt'=>$opt, 'debuginfo'=>$debuginfo); |
|
| 199 | 199 | |
| 200 | 200 | $cmd = ''; |
| 201 | 201 | } |
| 202 | - elseif($c==':') { |
|
| 202 | + elseif ($c == ':') { |
|
| 203 | 203 | $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]"; |
| 204 | - if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
| 204 | + if ($cmd !== '') $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo); |
|
| 205 | 205 | |
| 206 | 206 | $cmd = ''; |
| 207 | 207 | } |
| 208 | - elseif(trim($modifiers)=='' && trim($cmd)!=='') { |
|
| 208 | + elseif (trim($modifiers) == '' && trim($cmd) !== '') { |
|
| 209 | 209 | $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]"; |
| 210 | 210 | $cmd .= $c; |
| 211 | - $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
| 211 | + $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo); |
|
| 212 | 212 | |
| 213 | 213 | break; |
| 214 | 214 | } |
@@ -217,65 +217,65 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if(empty($result)) return array(); |
|
| 220 | + if (empty($result)) return array(); |
|
| 221 | 221 | |
| 222 | - foreach($result as $i=>$a) |
|
| 222 | + foreach ($result as $i=>$a) |
|
| 223 | 223 | { |
| 224 | 224 | $a['opt'] = $this->parseDocumentSource($a['opt']); |
| 225 | - $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders); |
|
| 225 | + $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'], $this->placeholders); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | return $result; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - public function parsePhx($key,$value,$modifiers) |
|
| 231 | + public function parsePhx($key, $value, $modifiers) |
|
| 232 | 232 | { |
| 233 | 233 | global $modx; |
| 234 | 234 | $lastKey = ''; |
| 235 | - $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true))); |
|
| 236 | - if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; |
|
| 237 | - if(empty($modifiers)) return ''; |
|
| 235 | + $cacheKey = md5(sprintf('parsePhx#%s#%s#%s', $key, $value, print_r($modifiers, true))); |
|
| 236 | + if (isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; |
|
| 237 | + if (empty($modifiers)) return ''; |
|
| 238 | 238 | |
| 239 | - foreach($modifiers as $m) |
|
| 239 | + foreach ($modifiers as $m) |
|
| 240 | 240 | { |
| 241 | 241 | $lastKey = strtolower($m['cmd']); |
| 242 | 242 | } |
| 243 | - $_ = explode(',',$this->condModifiers); |
|
| 244 | - if(in_array($lastKey,$_)) |
|
| 243 | + $_ = explode(',', $this->condModifiers); |
|
| 244 | + if (in_array($lastKey, $_)) |
|
| 245 | 245 | { |
| 246 | - $modifiers[] = array('cmd'=>'then','opt'=>'1'); |
|
| 247 | - $modifiers[] = array('cmd'=>'else','opt'=>'0'); |
|
| 246 | + $modifiers[] = array('cmd'=>'then', 'opt'=>'1'); |
|
| 247 | + $modifiers[] = array('cmd'=>'else', 'opt'=>'0'); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - foreach($modifiers as $i=>$a) |
|
| 250 | + foreach ($modifiers as $i=>$a) |
|
| 251 | 251 | { |
| 252 | - $value = $this->Filter($key,$value, $a['cmd'], $a['opt']); |
|
| 252 | + $value = $this->Filter($key, $value, $a['cmd'], $a['opt']); |
|
| 253 | 253 | } |
| 254 | 254 | $this->tmpCache[$cacheKey] = $value; |
| 255 | 255 | return $value; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | // Parser: modifier detection and eXtended processing if needed |
| 259 | - public function Filter($key, $value, $cmd, $opt='') |
|
| 259 | + public function Filter($key, $value, $cmd, $opt = '') |
|
| 260 | 260 | { |
| 261 | 261 | global $modx; |
| 262 | 262 | |
| 263 | - if($key==='documentObject') $value = $modx->documentIdentifier; |
|
| 263 | + if ($key === 'documentObject') $value = $modx->documentIdentifier; |
|
| 264 | 264 | $cmd = $this->parseDocumentSource($cmd); |
| 265 | - if(preg_match('@^[1-9][/0-9]*$@',$cmd)) |
|
| 265 | + if (preg_match('@^[1-9][/0-9]*$@', $cmd)) |
|
| 266 | 266 | { |
| 267 | - if(strpos($cmd,'/')!==false) |
|
| 268 | - $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); |
|
| 267 | + if (strpos($cmd, '/') !== false) |
|
| 268 | + $cmd = $this->substr($cmd, strrpos($cmd, '/') + 1); |
|
| 269 | 269 | $opt = $cmd; |
| 270 | 270 | $cmd = 'id'; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if(isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
| 274 | - elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
| 273 | + if (isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
| 274 | + elseif (isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
| 275 | 275 | else $this->elmName = ''; |
| 276 | 276 | |
| 277 | 277 | $cmd = strtolower($cmd); |
| 278 | - if($this->elmName!=='') |
|
| 278 | + if ($this->elmName !== '') |
|
| 279 | 279 | $value = $this->getValueFromElement($key, $value, $cmd, $opt); |
| 280 | 280 | else |
| 281 | 281 | $value = $this->getValueFromPreset($key, $value, $cmd, $opt); |
@@ -285,12 +285,12 @@ discard block |
||
| 285 | 285 | return $value; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - public function isEmpty($cmd,$value) |
|
| 288 | + public function isEmpty($cmd, $value) |
|
| 289 | 289 | { |
| 290 | - if($value!=='') return false; |
|
| 290 | + if ($value !== '') return false; |
|
| 291 | 291 | |
| 292 | - $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
|
| 293 | - if(in_array($cmd,$_)) return false; |
|
| 292 | + $_ = explode(',', $this->condModifiers.',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
|
| 293 | + if (in_array($cmd, $_)) return false; |
|
| 294 | 294 | else return true; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | { |
| 299 | 299 | global $modx; |
| 300 | 300 | |
| 301 | - if($this->isEmpty($cmd,$value)) return ''; |
|
| 301 | + if ($this->isEmpty($cmd, $value)) return ''; |
|
| 302 | 302 | |
| 303 | 303 | $this->key = $key; |
| 304 | 304 | $this->value = $value; |
@@ -309,83 +309,83 @@ discard block |
||
| 309 | 309 | ##### Conditional Modifiers |
| 310 | 310 | case 'input': |
| 311 | 311 | case 'if': |
| 312 | - if(!$opt) return $value; |
|
| 312 | + if (!$opt) return $value; |
|
| 313 | 313 | return $opt; |
| 314 | 314 | case '=': |
| 315 | 315 | case 'eq': |
| 316 | 316 | case 'is': |
| 317 | 317 | case 'equals': |
| 318 | - $this->condition[] = (int)($value == $opt); break; |
|
| 318 | + $this->condition[] = (int) ($value == $opt); break; |
|
| 319 | 319 | case 'neq': |
| 320 | 320 | case 'ne': |
| 321 | 321 | case 'notequals': |
| 322 | 322 | case 'isnot': |
| 323 | 323 | case 'isnt': |
| 324 | 324 | case 'not': |
| 325 | - $this->condition[] = (int)($value != $opt);break; |
|
| 325 | + $this->condition[] = (int) ($value != $opt); break; |
|
| 326 | 326 | case '%': |
| 327 | - $this->condition[] = (int)($value%$opt==0);break; |
|
| 327 | + $this->condition[] = (int) ($value % $opt == 0); break; |
|
| 328 | 328 | case 'isempty': |
| 329 | - $this->condition[] = (int)(empty($value)); break; |
|
| 329 | + $this->condition[] = (int) (empty($value)); break; |
|
| 330 | 330 | case 'isntempty': |
| 331 | 331 | case 'isnotempty': |
| 332 | - $this->condition[] = (int)(!empty($value)); break; |
|
| 332 | + $this->condition[] = (int) (!empty($value)); break; |
|
| 333 | 333 | case '>=': |
| 334 | 334 | case 'gte': |
| 335 | 335 | case 'eg': |
| 336 | 336 | case 'isgte': |
| 337 | - $this->condition[] = (int)($value >= $opt);break; |
|
| 337 | + $this->condition[] = (int) ($value >= $opt); break; |
|
| 338 | 338 | case '<=': |
| 339 | 339 | case 'lte': |
| 340 | 340 | case 'el': |
| 341 | 341 | case 'islte': |
| 342 | - $this->condition[] = (int)($value <= $opt);break; |
|
| 342 | + $this->condition[] = (int) ($value <= $opt); break; |
|
| 343 | 343 | case '>': |
| 344 | 344 | case 'gt': |
| 345 | 345 | case 'greaterthan': |
| 346 | 346 | case 'isgreaterthan': |
| 347 | 347 | case 'isgt': |
| 348 | - $this->condition[] = (int)($value > $opt);break; |
|
| 348 | + $this->condition[] = (int) ($value > $opt); break; |
|
| 349 | 349 | case '<': |
| 350 | 350 | case 'lt': |
| 351 | 351 | case 'lowerthan': |
| 352 | 352 | case 'islowerthan': |
| 353 | 353 | case 'islt': |
| 354 | - $this->condition[] = (int)($value < $opt);break; |
|
| 354 | + $this->condition[] = (int) ($value < $opt); break; |
|
| 355 | 355 | case 'find': |
| 356 | - $this->condition[] = (int)(strpos($value, $opt)!==false);break; |
|
| 356 | + $this->condition[] = (int) (strpos($value, $opt) !== false); break; |
|
| 357 | 357 | case 'inarray': |
| 358 | 358 | case 'in_array': |
| 359 | 359 | case 'in': |
| 360 | 360 | $opt = explode(',', $opt); |
| 361 | - $this->condition[] = (int)(in_array($value, $opt)!==false);break; |
|
| 361 | + $this->condition[] = (int) (in_array($value, $opt) !== false); break; |
|
| 362 | 362 | case 'wildcard_match': |
| 363 | 363 | case 'wcard_match': |
| 364 | 364 | case 'wildcard': |
| 365 | 365 | case 'wcard': |
| 366 | 366 | case 'fnmatch': |
| 367 | - $this->condition[] = (int)(fnmatch($opt, $value)!==false);break; |
|
| 367 | + $this->condition[] = (int) (fnmatch($opt, $value) !== false); break; |
|
| 368 | 368 | case 'is_file': |
| 369 | 369 | case 'is_dir': |
| 370 | 370 | case 'file_exists': |
| 371 | 371 | case 'is_readable': |
| 372 | 372 | case 'is_writable': |
| 373 | - if(!$opt) $path = $value; |
|
| 373 | + if (!$opt) $path = $value; |
|
| 374 | 374 | else $path = $opt; |
| 375 | - if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path'); |
|
| 376 | - if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/'); |
|
| 377 | - $this->condition[] = (int)($cmd($path)!==false);break; |
|
| 375 | + if (strpos($path, MODX_MANAGER_PATH) !== false) exit('Can not read core path'); |
|
| 376 | + if (strpos($path, $modx->config['base_path']) === false) $path = ltrim($path, '/'); |
|
| 377 | + $this->condition[] = (int) ($cmd($path) !== false); break; |
|
| 378 | 378 | case 'is_image': |
| 379 | - if(!$opt) $path = $value; |
|
| 379 | + if (!$opt) $path = $value; |
|
| 380 | 380 | else $path = $opt; |
| 381 | - if(!is_file($path)) {$this->condition[]='0';break;} |
|
| 381 | + if (!is_file($path)) {$this->condition[] = '0'; break; } |
|
| 382 | 382 | $_ = getimagesize($path); |
| 383 | - $this->condition[] = (int)($_[0]);break; |
|
| 383 | + $this->condition[] = (int) ($_[0]); break; |
|
| 384 | 384 | case 'regex': |
| 385 | 385 | case 'preg': |
| 386 | 386 | case 'preg_match': |
| 387 | 387 | case 'isinrole': |
| 388 | - $this->condition[] = (int)(preg_match($opt,$value));break; |
|
| 388 | + $this->condition[] = (int) (preg_match($opt, $value)); break; |
|
| 389 | 389 | case 'ir': |
| 390 | 390 | case 'memberof': |
| 391 | 391 | case 'mo': |
@@ -393,50 +393,50 @@ discard block |
||
| 393 | 393 | $this->condition[] = $this->includeMdfFile('memberof'); |
| 394 | 394 | break; |
| 395 | 395 | case 'or': |
| 396 | - $this->condition[] = '||';break; |
|
| 396 | + $this->condition[] = '||'; break; |
|
| 397 | 397 | case 'and': |
| 398 | - $this->condition[] = '&&';break; |
|
| 398 | + $this->condition[] = '&&'; break; |
|
| 399 | 399 | case 'show': |
| 400 | 400 | case 'this': |
| 401 | - $conditional = implode(' ',$this->condition); |
|
| 402 | - $isvalid = (int)(eval("return ({$conditional});")); |
|
| 401 | + $conditional = implode(' ', $this->condition); |
|
| 402 | + $isvalid = (int) (eval("return ({$conditional});")); |
|
| 403 | 403 | if ($isvalid) return $this->srcValue; |
| 404 | 404 | return NULL; |
| 405 | 405 | case 'then': |
| 406 | - $conditional = implode(' ',$this->condition); |
|
| 407 | - $isvalid = (int)eval("return ({$conditional});"); |
|
| 406 | + $conditional = implode(' ', $this->condition); |
|
| 407 | + $isvalid = (int) eval("return ({$conditional});"); |
|
| 408 | 408 | if ($isvalid) return $opt; |
| 409 | 409 | return null; |
| 410 | 410 | case 'else': |
| 411 | - $conditional = implode(' ',$this->condition); |
|
| 412 | - $isvalid = (int)eval("return ({$conditional});"); |
|
| 411 | + $conditional = implode(' ', $this->condition); |
|
| 412 | + $isvalid = (int) eval("return ({$conditional});"); |
|
| 413 | 413 | if (!$isvalid) return $opt; |
| 414 | 414 | break; |
| 415 | 415 | case 'select': |
| 416 | 416 | case 'switch': |
| 417 | - $raw = explode('&',$opt); |
|
| 417 | + $raw = explode('&', $opt); |
|
| 418 | 418 | $map = array(); |
| 419 | 419 | $c = count($raw); |
| 420 | - for($m=0; $m<$c; $m++) { |
|
| 421 | - $mi = explode('=',$raw[$m],2); |
|
| 420 | + for ($m = 0; $m < $c; $m++) { |
|
| 421 | + $mi = explode('=', $raw[$m], 2); |
|
| 422 | 422 | $map[$mi[0]] = $mi[1]; |
| 423 | 423 | } |
| 424 | - if(isset($map[$value])) return $map[$value]; |
|
| 424 | + if (isset($map[$value])) return $map[$value]; |
|
| 425 | 425 | else return ''; |
| 426 | 426 | ##### End of Conditional Modifiers |
| 427 | 427 | |
| 428 | 428 | ##### Encode / Decode / Hash / Escape |
| 429 | 429 | case 'htmlent': |
| 430 | 430 | case 'htmlentities': |
| 431 | - return htmlentities($value,ENT_QUOTES,$modx->config['modx_charset']); |
|
| 431 | + return htmlentities($value, ENT_QUOTES, $modx->config['modx_charset']); |
|
| 432 | 432 | case 'html_entity_decode': |
| 433 | 433 | case 'decode_html': |
| 434 | 434 | case 'html_decode': |
| 435 | - return html_entity_decode($value,ENT_QUOTES,$modx->config['modx_charset']); |
|
| 435 | + return html_entity_decode($value, ENT_QUOTES, $modx->config['modx_charset']); |
|
| 436 | 436 | case 'esc': |
| 437 | 437 | case 'escape': |
| 438 | 438 | $value = preg_replace('/&(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset'])); |
| 439 | - return str_replace(array('[', ']', '`'),array('[', ']', '`'),$value); |
|
| 439 | + return str_replace(array('[', ']', '`'), array('[', ']', '`'), $value); |
|
| 440 | 440 | case 'sql_escape': |
| 441 | 441 | case 'encode_js': |
| 442 | 442 | return $modx->db->escape($value); |
@@ -446,39 +446,39 @@ discard block |
||
| 446 | 446 | case 'html_encode': |
| 447 | 447 | return preg_replace('/&(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset'])); |
| 448 | 448 | case 'spam_protect': |
| 449 | - return str_replace(array('@','.'),array('@','.'),$value); |
|
| 449 | + return str_replace(array('@', '.'), array('@', '.'), $value); |
|
| 450 | 450 | case 'strip': |
| 451 | - if($opt==='') $opt = ' '; |
|
| 451 | + if ($opt === '') $opt = ' '; |
|
| 452 | 452 | return preg_replace('/[\n\r\t\s]+/', $opt, $value); |
| 453 | 453 | case 'strip_linefeeds': |
| 454 | - return str_replace(array("\n","\r"), '', $value); |
|
| 454 | + return str_replace(array("\n", "\r"), '', $value); |
|
| 455 | 455 | case 'notags': |
| 456 | 456 | case 'strip_tags': |
| 457 | 457 | case 'remove_html': |
| 458 | - if($opt!=='') |
|
| 458 | + if ($opt !== '') |
|
| 459 | 459 | { |
| 460 | 460 | $param = array(); |
| 461 | - foreach(explode(',',$opt) as $v) |
|
| 461 | + foreach (explode(',', $opt) as $v) |
|
| 462 | 462 | { |
| 463 | - $v = trim($v,'</> '); |
|
| 463 | + $v = trim($v, '</> '); |
|
| 464 | 464 | $param[] = "<{$v}>"; |
| 465 | 465 | } |
| 466 | - $params = implode(',',$param); |
|
| 466 | + $params = implode(',', $param); |
|
| 467 | 467 | } |
| 468 | 468 | else $params = ''; |
| 469 | - if(!strpos($params,'<br>')===false) { |
|
| 470 | - $value = preg_replace('@(<br[ /]*>)\n@','$1',$value); |
|
| 471 | - $value = preg_replace('@<br[ /]*>@',"\n",$value); |
|
| 469 | + if (!strpos($params, '<br>') === false) { |
|
| 470 | + $value = preg_replace('@(<br[ /]*>)\n@', '$1', $value); |
|
| 471 | + $value = preg_replace('@<br[ /]*>@', "\n", $value); |
|
| 472 | 472 | } |
| 473 | - return $this->strip_tags($value,$params); |
|
| 473 | + return $this->strip_tags($value, $params); |
|
| 474 | 474 | case 'urlencode': |
| 475 | 475 | case 'url_encode': |
| 476 | 476 | case 'encode_url': |
| 477 | 477 | return urlencode($value); |
| 478 | 478 | case 'base64_decode': |
| 479 | - if($opt!=='false') $opt = true; |
|
| 479 | + if ($opt !== 'false') $opt = true; |
|
| 480 | 480 | else $opt = false; |
| 481 | - return base64_decode($value,$opt); |
|
| 481 | + return base64_decode($value, $opt); |
|
| 482 | 482 | case 'encode_sha1': $cmd = 'sha1'; |
| 483 | 483 | case 'addslashes': |
| 484 | 484 | case 'urldecode': |
@@ -502,18 +502,18 @@ discard block |
||
| 502 | 502 | case 'upper_case': |
| 503 | 503 | return $this->strtoupper($value); |
| 504 | 504 | case 'capitalize': |
| 505 | - $_ = explode(' ',$value); |
|
| 506 | - foreach($_ as $i=>$v) |
|
| 505 | + $_ = explode(' ', $value); |
|
| 506 | + foreach ($_ as $i=>$v) |
|
| 507 | 507 | { |
| 508 | 508 | $_[$i] = ucfirst($v); |
| 509 | 509 | } |
| 510 | - return implode(' ',$_); |
|
| 510 | + return implode(' ', $_); |
|
| 511 | 511 | case 'zenhan': |
| 512 | - if(empty($opt)) $opt='VKas'; |
|
| 513 | - return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
|
| 512 | + if (empty($opt)) $opt = 'VKas'; |
|
| 513 | + return mb_convert_kana($value, $opt, $modx->config['modx_charset']); |
|
| 514 | 514 | case 'hanzen': |
| 515 | - if(empty($opt)) $opt='VKAS'; |
|
| 516 | - return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
|
| 515 | + if (empty($opt)) $opt = 'VKAS'; |
|
| 516 | + return mb_convert_kana($value, $opt, $modx->config['modx_charset']); |
|
| 517 | 517 | case 'str_shuffle': |
| 518 | 518 | case 'shuffle': |
| 519 | 519 | return $this->str_shuffle($value); |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | return $this->strlen($value); |
| 528 | 528 | case 'count_words': |
| 529 | 529 | $value = trim($value); |
| 530 | - return count(preg_split('/\s+/',$value)); |
|
| 530 | + return count(preg_split('/\s+/', $value)); |
|
| 531 | 531 | case 'str_word_count': |
| 532 | 532 | case 'word_count': |
| 533 | 533 | case 'wordcount': |
@@ -535,55 +535,55 @@ discard block |
||
| 535 | 535 | case 'count_paragraphs': |
| 536 | 536 | $value = trim($value); |
| 537 | 537 | $value = preg_replace('/\r/', '', $value); |
| 538 | - return count(preg_split('/\n+/',$value)); |
|
| 538 | + return count(preg_split('/\n+/', $value)); |
|
| 539 | 539 | case 'strpos': |
| 540 | - if($opt!=0&&empty($opt)) return $value; |
|
| 541 | - return $this->strpos($value,$opt); |
|
| 540 | + if ($opt != 0 && empty($opt)) return $value; |
|
| 541 | + return $this->strpos($value, $opt); |
|
| 542 | 542 | case 'wordwrap': |
| 543 | 543 | // default: 70 |
| 544 | - $wrapat = (int)$opt > 0 ? (int)$opt : 70; |
|
| 544 | + $wrapat = (int) $opt > 0 ? (int) $opt : 70; |
|
| 545 | 545 | if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap'); |
| 546 | - else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value); |
|
| 546 | + else return preg_replace("@(\b\w+\b)@e", "wordwrap('\\1',\$wrapat,' ',1)", $value); |
|
| 547 | 547 | case 'wrap_text': |
| 548 | - $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70; |
|
| 549 | - if($modx->config['manager_language']==='japanese-utf8') { |
|
| 548 | + $width = preg_match('/^[1-9][0-9]*$/', $opt) ? $opt : 70; |
|
| 549 | + if ($modx->config['manager_language'] === 'japanese-utf8') { |
|
| 550 | 550 | $chunk = array(); |
| 551 | - $bt=''; |
|
| 552 | - while($bt!=$value) { |
|
| 551 | + $bt = ''; |
|
| 552 | + while ($bt != $value) { |
|
| 553 | 553 | $bt = $value; |
| 554 | - if($this->strlen($value)<$width) { |
|
| 554 | + if ($this->strlen($value) < $width) { |
|
| 555 | 555 | $chunk[] = $value; |
| 556 | 556 | break; |
| 557 | 557 | } |
| 558 | - $chunk[] = $this->substr($value,0,$width); |
|
| 559 | - $value = $this->substr($value,$width); |
|
| 558 | + $chunk[] = $this->substr($value, 0, $width); |
|
| 559 | + $value = $this->substr($value, $width); |
|
| 560 | 560 | } |
| 561 | - return implode("\n",$chunk); |
|
| 561 | + return implode("\n", $chunk); |
|
| 562 | 562 | } |
| 563 | 563 | else |
| 564 | - return wordwrap($value,$width,"\n",true); |
|
| 564 | + return wordwrap($value, $width, "\n", true); |
|
| 565 | 565 | case 'substr': |
| 566 | - if(empty($opt)) break; |
|
| 567 | - if(strpos($opt,',')!==false) { |
|
| 568 | - list($b,$e) = explode(',',$opt,2); |
|
| 569 | - return $this->substr($value,$b,(int)$e); |
|
| 566 | + if (empty($opt)) break; |
|
| 567 | + if (strpos($opt, ',') !== false) { |
|
| 568 | + list($b, $e) = explode(',', $opt, 2); |
|
| 569 | + return $this->substr($value, $b, (int) $e); |
|
| 570 | 570 | } |
| 571 | - else return $this->substr($value,$opt); |
|
| 571 | + else return $this->substr($value, $opt); |
|
| 572 | 572 | case 'limit': |
| 573 | 573 | case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html |
| 574 | - if(strpos($opt,'+')!==false) |
|
| 575 | - list($len,$str) = explode('+',$opt,2); |
|
| 574 | + if (strpos($opt, '+') !== false) |
|
| 575 | + list($len, $str) = explode('+', $opt, 2); |
|
| 576 | 576 | else { |
| 577 | 577 | $len = $opt; |
| 578 | 578 | $str = ''; |
| 579 | 579 | } |
| 580 | - if($len==='') $len = 100; |
|
| 581 | - if(abs($len) > $this->strlen($value)) $str =''; |
|
| 582 | - if(preg_match('/^[1-9][0-9]*$/',$len)) { |
|
| 583 | - return $this->substr($value,0,$len) . $str; |
|
| 580 | + if ($len === '') $len = 100; |
|
| 581 | + if (abs($len) > $this->strlen($value)) $str = ''; |
|
| 582 | + if (preg_match('/^[1-9][0-9]*$/', $len)) { |
|
| 583 | + return $this->substr($value, 0, $len).$str; |
|
| 584 | 584 | } |
| 585 | - elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { |
|
| 586 | - return $str . $this->substr($value,$len); |
|
| 585 | + elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) { |
|
| 586 | + return $str.$this->substr($value, $len); |
|
| 587 | 587 | } |
| 588 | 588 | break; |
| 589 | 589 | case 'summary': |
@@ -592,81 +592,81 @@ discard block |
||
| 592 | 592 | return $this->includeMdfFile('summary'); |
| 593 | 593 | case 'replace': |
| 594 | 594 | case 'str_replace': |
| 595 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
| 596 | - if (substr_count($opt, ',') ==1) $delim = ','; |
|
| 597 | - elseif(substr_count($opt, '|') ==1) $delim = '|'; |
|
| 598 | - elseif(substr_count($opt, '=>')==1) $delim = '=>'; |
|
| 599 | - elseif(substr_count($opt, '/') ==1) $delim = '/'; |
|
| 595 | + if (empty($opt) || strpos($opt, ',') === false) break; |
|
| 596 | + if (substr_count($opt, ',') == 1) $delim = ','; |
|
| 597 | + elseif (substr_count($opt, '|') == 1) $delim = '|'; |
|
| 598 | + elseif (substr_count($opt, '=>') == 1) $delim = '=>'; |
|
| 599 | + elseif (substr_count($opt, '/') == 1) $delim = '/'; |
|
| 600 | 600 | else break; |
| 601 | - list($s,$r) = explode($delim,$opt); |
|
| 602 | - if($value!=='') return str_replace($s,$r,$value); |
|
| 601 | + list($s, $r) = explode($delim, $opt); |
|
| 602 | + if ($value !== '') return str_replace($s, $r, $value); |
|
| 603 | 603 | break; |
| 604 | 604 | case 'replace_to': |
| 605 | 605 | case 'tpl': |
| 606 | - if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); |
|
| 606 | + if ($value !== '') return str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $value, $opt); |
|
| 607 | 607 | break; |
| 608 | 608 | case 'eachtpl': |
| 609 | - $value = explode('||',$value); |
|
| 609 | + $value = explode('||', $value); |
|
| 610 | 610 | $_ = array(); |
| 611 | - foreach($value as $v) { |
|
| 612 | - $_[] = str_replace(array('[+value+]','[+output+]','{value}','%s'),$v,$opt); |
|
| 611 | + foreach ($value as $v) { |
|
| 612 | + $_[] = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $v, $opt); |
|
| 613 | 613 | } |
| 614 | 614 | return implode("\n", $_); |
| 615 | 615 | case 'array_pop': |
| 616 | 616 | case 'array_shift': |
| 617 | - if(strpos($value,'||')!==false) $delim = '||'; |
|
| 617 | + if (strpos($value, '||') !== false) $delim = '||'; |
|
| 618 | 618 | else $delim = ','; |
| 619 | - return $cmd(explode($delim,$value)); |
|
| 619 | + return $cmd(explode($delim, $value)); |
|
| 620 | 620 | case 'preg_replace': |
| 621 | 621 | case 'regex_replace': |
| 622 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
| 623 | - list($s,$r) = explode(',',$opt,2); |
|
| 624 | - if($value!=='') return preg_replace($s,$r,$value); |
|
| 622 | + if (empty($opt) || strpos($opt, ',') === false) break; |
|
| 623 | + list($s, $r) = explode(',', $opt, 2); |
|
| 624 | + if ($value !== '') return preg_replace($s, $r, $value); |
|
| 625 | 625 | break; |
| 626 | 626 | case 'cat': |
| 627 | 627 | case 'concatenate': |
| 628 | 628 | case '.': |
| 629 | - if($value!=='') return $value . $opt; |
|
| 629 | + if ($value !== '') return $value.$opt; |
|
| 630 | 630 | break; |
| 631 | 631 | case 'sprintf': |
| 632 | 632 | case 'string_format': |
| 633 | - if($value!=='') return sprintf($opt,$value); |
|
| 633 | + if ($value !== '') return sprintf($opt, $value); |
|
| 634 | 634 | break; |
| 635 | 635 | case 'number_format': |
| 636 | - if($opt=='') $opt = 0; |
|
| 637 | - return number_format($value,$opt); |
|
| 636 | + if ($opt == '') $opt = 0; |
|
| 637 | + return number_format($value, $opt); |
|
| 638 | 638 | case 'money_format': |
| 639 | - setlocale(LC_MONETARY,setlocale(LC_TIME,0)); |
|
| 640 | - if($value!=='') return money_format($opt,(double)$value); |
|
| 639 | + setlocale(LC_MONETARY, setlocale(LC_TIME, 0)); |
|
| 640 | + if ($value !== '') return money_format($opt, (double) $value); |
|
| 641 | 641 | break; |
| 642 | 642 | case 'tobool': |
| 643 | 643 | return boolval($value); |
| 644 | 644 | case 'nl2lf': |
| 645 | - if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value); |
|
| 645 | + if ($value !== '') return str_replace(array("\r\n", "\n", "\r"), '\n', $value); |
|
| 646 | 646 | break; |
| 647 | 647 | case 'br2nl': |
| 648 | 648 | return preg_replace('@<br[\s/]*>@i', "\n", $value); |
| 649 | 649 | case 'nl2br': |
| 650 | 650 | if (version_compare(PHP_VERSION, '5.3.0', '<')) |
| 651 | 651 | return nl2br($value); |
| 652 | - if($opt!=='') |
|
| 652 | + if ($opt !== '') |
|
| 653 | 653 | { |
| 654 | 654 | $opt = trim($opt); |
| 655 | 655 | $opt = strtolower($opt); |
| 656 | - if($opt==='false') $opt = false; |
|
| 657 | - elseif($opt==='0') $opt = false; |
|
| 656 | + if ($opt === 'false') $opt = false; |
|
| 657 | + elseif ($opt === '0') $opt = false; |
|
| 658 | 658 | else $opt = true; |
| 659 | 659 | } |
| 660 | - elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') |
|
| 660 | + elseif (isset($modx->config['mce_element_format']) && $modx->config['mce_element_format'] === 'html') |
|
| 661 | 661 | $opt = false; |
| 662 | 662 | else $opt = true; |
| 663 | - return nl2br($value,$opt); |
|
| 663 | + return nl2br($value, $opt); |
|
| 664 | 664 | case 'ltrim': |
| 665 | 665 | case 'rtrim': |
| 666 | 666 | case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html |
| 667 | - if($opt==='') |
|
| 667 | + if ($opt === '') |
|
| 668 | 668 | return $cmd($value); |
| 669 | - else return $cmd($value,$opt); |
|
| 669 | + else return $cmd($value, $opt); |
|
| 670 | 670 | // These are all straight wrappers for PHP functions |
| 671 | 671 | case 'ucfirst': |
| 672 | 672 | case 'lcfirst': |
@@ -677,58 +677,58 @@ discard block |
||
| 677 | 677 | case 'strftime': |
| 678 | 678 | case 'date': |
| 679 | 679 | case 'dateformat': |
| 680 | - if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
| 681 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
| 682 | - if(strpos($opt,'%')!==false) |
|
| 683 | - return strftime($opt,0+$value); |
|
| 680 | + if (empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
| 681 | + if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value); |
|
| 682 | + if (strpos($opt, '%') !== false) |
|
| 683 | + return strftime($opt, 0 + $value); |
|
| 684 | 684 | else |
| 685 | - return date($opt,0+$value); |
|
| 685 | + return date($opt, 0 + $value); |
|
| 686 | 686 | case 'time': |
| 687 | - if(empty($opt)) $opt = '%H:%M'; |
|
| 688 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
| 689 | - return strftime($opt,0+$value); |
|
| 687 | + if (empty($opt)) $opt = '%H:%M'; |
|
| 688 | + if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value); |
|
| 689 | + return strftime($opt, 0 + $value); |
|
| 690 | 690 | case 'strtotime': |
| 691 | 691 | return strtotime($value); |
| 692 | 692 | ##### mathematical function |
| 693 | 693 | case 'toint': |
| 694 | - return (int)$value; |
|
| 694 | + return (int) $value; |
|
| 695 | 695 | case 'tofloat': |
| 696 | 696 | return floatval($value); |
| 697 | 697 | case 'round': |
| 698 | - if(!$opt) $opt = 0; |
|
| 699 | - return $cmd($value,$opt); |
|
| 698 | + if (!$opt) $opt = 0; |
|
| 699 | + return $cmd($value, $opt); |
|
| 700 | 700 | case 'max': |
| 701 | 701 | case 'min': |
| 702 | - return $cmd(explode(',',$value)); |
|
| 702 | + return $cmd(explode(',', $value)); |
|
| 703 | 703 | case 'floor': |
| 704 | 704 | case 'ceil': |
| 705 | 705 | case 'abs': |
| 706 | 706 | return $cmd($value); |
| 707 | 707 | case 'math': |
| 708 | 708 | case 'calc': |
| 709 | - $value = (int)$value; |
|
| 710 | - if(empty($value)) $value = '0'; |
|
| 711 | - $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt); |
|
| 712 | - $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter); |
|
| 713 | - if(strpos($filter,'?')===false) $filter = "?{$filter}"; |
|
| 714 | - $filter = str_replace('?',$value,$filter); |
|
| 709 | + $value = (int) $value; |
|
| 710 | + if (empty($value)) $value = '0'; |
|
| 711 | + $filter = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), '?', $opt); |
|
| 712 | + $filter = preg_replace('@([a-zA-Z\n\r\t\s])@', '', $filter); |
|
| 713 | + if (strpos($filter, '?') === false) $filter = "?{$filter}"; |
|
| 714 | + $filter = str_replace('?', $value, $filter); |
|
| 715 | 715 | return eval("return {$filter};"); |
| 716 | 716 | case 'count': |
| 717 | - if($value=='') return 0; |
|
| 718 | - $value = explode(',',$value); |
|
| 717 | + if ($value == '') return 0; |
|
| 718 | + $value = explode(',', $value); |
|
| 719 | 719 | return count($value); |
| 720 | 720 | case 'sort': |
| 721 | 721 | case 'rsort': |
| 722 | - if(strpos($value,"\n")!==false) $delim="\n"; |
|
| 722 | + if (strpos($value, "\n") !== false) $delim = "\n"; |
|
| 723 | 723 | else $delim = ','; |
| 724 | - $swap = explode($delim,$value); |
|
| 725 | - if(!$opt) $opt = SORT_REGULAR; |
|
| 724 | + $swap = explode($delim, $value); |
|
| 725 | + if (!$opt) $opt = SORT_REGULAR; |
|
| 726 | 726 | else $opt = constant($opt); |
| 727 | - $cmd($swap,$opt); |
|
| 728 | - return implode($delim,$swap); |
|
| 727 | + $cmd($swap, $opt); |
|
| 728 | + return implode($delim, $swap); |
|
| 729 | 729 | ##### Resource fields |
| 730 | 730 | case 'id': |
| 731 | - if($opt) return $this->getDocumentObject($opt,$key); |
|
| 731 | + if ($opt) return $this->getDocumentObject($opt, $key); |
|
| 732 | 732 | break; |
| 733 | 733 | case 'type': |
| 734 | 734 | case 'contenttype': |
@@ -765,36 +765,36 @@ discard block |
||
| 765 | 765 | case 'privatemgr': |
| 766 | 766 | case 'content_dispo': |
| 767 | 767 | case 'hidemenu': |
| 768 | - if($cmd==='contenttype') $cmd = 'contentType'; |
|
| 769 | - return $this->getDocumentObject($value,$cmd); |
|
| 768 | + if ($cmd === 'contenttype') $cmd = 'contentType'; |
|
| 769 | + return $this->getDocumentObject($value, $cmd); |
|
| 770 | 770 | case 'title': |
| 771 | - $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
|
| 772 | - $longtitle = $this->getDocumentObject($value,'longtitle'); |
|
| 771 | + $pagetitle = $this->getDocumentObject($value, 'pagetitle'); |
|
| 772 | + $longtitle = $this->getDocumentObject($value, 'longtitle'); |
|
| 773 | 773 | return $longtitle ? $longtitle : $pagetitle; |
| 774 | 774 | case 'shorttitle': |
| 775 | - $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
|
| 776 | - $menutitle = $this->getDocumentObject($value,'menutitle'); |
|
| 775 | + $pagetitle = $this->getDocumentObject($value, 'pagetitle'); |
|
| 776 | + $menutitle = $this->getDocumentObject($value, 'menutitle'); |
|
| 777 | 777 | return $menutitle ? $menutitle : $pagetitle; |
| 778 | 778 | case 'templatename': |
| 779 | - $rs = $modx->db->select('templatename','[+prefix+]site_templates',"id='{$value}'"); |
|
| 779 | + $rs = $modx->db->select('templatename', '[+prefix+]site_templates', "id='{$value}'"); |
|
| 780 | 780 | $templateName = $modx->db->getValue($rs); |
| 781 | 781 | return !$templateName ? '(blank)' : $templateName; |
| 782 | 782 | case 'getfield': |
| 783 | - if(!$opt) $opt = 'content'; |
|
| 784 | - return $modx->getField($opt,$value); |
|
| 783 | + if (!$opt) $opt = 'content'; |
|
| 784 | + return $modx->getField($opt, $value); |
|
| 785 | 785 | case 'children': |
| 786 | 786 | case 'childids': |
| 787 | - if($value=='') $value = 0; // 値がない場合はルートと見なす |
|
| 787 | + if ($value == '') $value = 0; // 値がない場合はルートと見なす |
|
| 788 | 788 | $published = 1; |
| 789 | - if($opt=='') $opt = 'page'; |
|
| 790 | - $_ = explode(',',$opt); |
|
| 789 | + if ($opt == '') $opt = 'page'; |
|
| 790 | + $_ = explode(',', $opt); |
|
| 791 | 791 | $where = array(); |
| 792 | - foreach($_ as $opt) { |
|
| 793 | - switch(trim($opt)) { |
|
| 792 | + foreach ($_ as $opt) { |
|
| 793 | + switch (trim($opt)) { |
|
| 794 | 794 | case 'page'; case '!folder'; case '!isfolder': $where[] = 'sc.isfolder=0'; break; |
| 795 | 795 | case 'folder'; case 'isfolder': $where[] = 'sc.isfolder=1'; break; |
| 796 | - case 'menu'; case 'show_menu': $where[] = 'sc.hidemenu=0'; break; |
|
| 797 | - case '!menu'; case '!show_menu': $where[] = 'sc.hidemenu=1'; break; |
|
| 796 | + case 'menu'; case 'show_menu': $where[] = 'sc.hidemenu=0'; break; |
|
| 797 | + case '!menu'; case '!show_menu': $where[] = 'sc.hidemenu=1'; break; |
|
| 798 | 798 | case 'published': $published = 1; break; |
| 799 | 799 | case '!published': $published = 0; break; |
| 800 | 800 | } |
@@ -802,69 +802,69 @@ discard block |
||
| 802 | 802 | $where = implode(' AND ', $where); |
| 803 | 803 | $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where); |
| 804 | 804 | $result = array(); |
| 805 | - foreach((array)$children as $child){ |
|
| 805 | + foreach ((array) $children as $child) { |
|
| 806 | 806 | $result[] = $child['id']; |
| 807 | 807 | } |
| 808 | 808 | return implode(',', $result); |
| 809 | 809 | case 'fullurl': |
| 810 | - if(!is_numeric($value)) return $value; |
|
| 810 | + if (!is_numeric($value)) return $value; |
|
| 811 | 811 | return $modx->makeUrl($value); |
| 812 | 812 | case 'makeurl': |
| 813 | - if(!is_numeric($value)) return $value; |
|
| 814 | - if(!$opt) $opt = 'full'; |
|
| 815 | - return $modx->makeUrl($value,'','',$opt); |
|
| 813 | + if (!is_numeric($value)) return $value; |
|
| 814 | + if (!$opt) $opt = 'full'; |
|
| 815 | + return $modx->makeUrl($value, '', '', $opt); |
|
| 816 | 816 | |
| 817 | 817 | ##### File system |
| 818 | 818 | case 'getimageinfo': |
| 819 | 819 | case 'imageinfo': |
| 820 | - if(!is_file($value)) return ''; |
|
| 820 | + if (!is_file($value)) return ''; |
|
| 821 | 821 | $_ = getimagesize($value); |
| 822 | - if(!$_[0]) return ''; |
|
| 822 | + if (!$_[0]) return ''; |
|
| 823 | 823 | $info['width'] = $_[0]; |
| 824 | 824 | $info['height'] = $_[1]; |
| 825 | - if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
| 826 | - elseif($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
| 825 | + if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
| 826 | + elseif ($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
| 827 | 827 | else $info['aspect'] = 'square'; |
| 828 | - switch($_[2]) { |
|
| 828 | + switch ($_[2]) { |
|
| 829 | 829 | case IMAGETYPE_GIF : $info['type'] = 'gif'; break; |
| 830 | 830 | case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break; |
| 831 | 831 | case IMAGETYPE_PNG : $info['type'] = 'png'; break; |
| 832 | 832 | default : $info['type'] = 'unknown'; |
| 833 | 833 | } |
| 834 | 834 | $info['attrib'] = $_[3]; |
| 835 | - switch($opt) { |
|
| 835 | + switch ($opt) { |
|
| 836 | 836 | case 'width' : return $info['width']; |
| 837 | 837 | case 'height': return $info['height']; |
| 838 | 838 | case 'aspect': return $info['aspect']; |
| 839 | 839 | case 'type' : return $info['type']; |
| 840 | 840 | case 'attrib': return $info['attrib']; |
| 841 | - default : return print_r($info,true); |
|
| 841 | + default : return print_r($info, true); |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | case 'file_get_contents': |
| 845 | 845 | case 'readfile': |
| 846 | - if(!is_file($value)) return $value; |
|
| 846 | + if (!is_file($value)) return $value; |
|
| 847 | 847 | $value = realpath($value); |
| 848 | - if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file'); |
|
| 849 | - $ext = strtolower(substr($value,-4)); |
|
| 850 | - if($ext==='.php') exit('Can not read php file'); |
|
| 851 | - if($ext==='.cgi') exit('Can not read cgi file'); |
|
| 848 | + if (strpos($value, MODX_MANAGER_PATH) !== false) exit('Can not read core file'); |
|
| 849 | + $ext = strtolower(substr($value, -4)); |
|
| 850 | + if ($ext === '.php') exit('Can not read php file'); |
|
| 851 | + if ($ext === '.cgi') exit('Can not read cgi file'); |
|
| 852 | 852 | return file_get_contents($value); |
| 853 | 853 | case 'filesize': |
| 854 | - if($value == '') return ''; |
|
| 854 | + if ($value == '') return ''; |
|
| 855 | 855 | $filename = $value; |
| 856 | 856 | |
| 857 | 857 | $site_url = $modx->config['site_url']; |
| 858 | - if(strpos($filename,$site_url) === 0) |
|
| 859 | - $filename = substr($filename,0,strlen($site_url)); |
|
| 860 | - $filename = trim($filename,'/'); |
|
| 858 | + if (strpos($filename, $site_url) === 0) |
|
| 859 | + $filename = substr($filename, 0, strlen($site_url)); |
|
| 860 | + $filename = trim($filename, '/'); |
|
| 861 | 861 | |
| 862 | - $opt = trim($opt,'/'); |
|
| 863 | - if($opt!=='') $opt .= '/'; |
|
| 862 | + $opt = trim($opt, '/'); |
|
| 863 | + if ($opt !== '') $opt .= '/'; |
|
| 864 | 864 | |
| 865 | 865 | $filename = MODX_BASE_PATH.$opt.$filename; |
| 866 | 866 | |
| 867 | - if(is_file($filename)){ |
|
| 867 | + if (is_file($filename)) { |
|
| 868 | 868 | clearstatcache(); |
| 869 | 869 | $size = filesize($filename); |
| 870 | 870 | return $size; |
@@ -897,10 +897,10 @@ discard block |
||
| 897 | 897 | $this->opt = $cmd; |
| 898 | 898 | return $this->includeMdfFile('moduser'); |
| 899 | 899 | case 'userinfo': |
| 900 | - if(empty($opt)) $this->opt = 'username'; |
|
| 900 | + if (empty($opt)) $this->opt = 'username'; |
|
| 901 | 901 | return $this->includeMdfFile('moduser'); |
| 902 | 902 | case 'webuserinfo': |
| 903 | - if(empty($opt)) $this->opt = 'username'; |
|
| 903 | + if (empty($opt)) $this->opt = 'username'; |
|
| 904 | 904 | $this->value = -$value; |
| 905 | 905 | return $this->includeMdfFile('moduser'); |
| 906 | 906 | ##### Special functions |
@@ -911,27 +911,27 @@ discard block |
||
| 911 | 911 | case 'ifnotempty': |
| 912 | 912 | if (!empty($value)) return $opt; break; |
| 913 | 913 | case 'datagrid': |
| 914 | - include_once(MODX_CORE_PATH . 'controls/datagrid.class.php'); |
|
| 914 | + include_once(MODX_CORE_PATH.'controls/datagrid.class.php'); |
|
| 915 | 915 | $grd = new DataGrid(null, trim($value)); |
| 916 | 916 | $grd->itemStyle = ''; |
| 917 | 917 | $grd->altItemStyle = ''; |
| 918 | - $pos = strpos($value,"\n"); |
|
| 919 | - if($pos) $_ = substr($value,0,$pos); |
|
| 918 | + $pos = strpos($value, "\n"); |
|
| 919 | + if ($pos) $_ = substr($value, 0, $pos); |
|
| 920 | 920 | else $_ = $pos; |
| 921 | - $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ','; |
|
| 921 | + $grd->cdelim = strpos($_, "\t") !== false ? 'tab' : ','; |
|
| 922 | 922 | return $grd->render(); |
| 923 | 923 | case 'rotate': |
| 924 | 924 | case 'evenodd': |
| 925 | - if(strpos($opt,',')===false) $opt = 'odd,even'; |
|
| 925 | + if (strpos($opt, ',') === false) $opt = 'odd,even'; |
|
| 926 | 926 | $_ = explode(',', $opt); |
| 927 | 927 | $c = count($_); |
| 928 | 928 | $i = $value + $c; |
| 929 | 929 | $i = $i % $c; |
| 930 | 930 | return $_[$i]; |
| 931 | 931 | case 'takeval': |
| 932 | - $arr = explode(",",$opt); |
|
| 932 | + $arr = explode(",", $opt); |
|
| 933 | 933 | $idx = $value; |
| 934 | - if(!is_numeric($idx)) return $value; |
|
| 934 | + if (!is_numeric($idx)) return $value; |
|
| 935 | 935 | return $arr[$idx]; |
| 936 | 936 | case 'getimage': |
| 937 | 937 | return $this->includeMdfFile('getimage'); |
@@ -939,17 +939,17 @@ discard block |
||
| 939 | 939 | return $modx->nicesize($value); |
| 940 | 940 | case 'googlemap': |
| 941 | 941 | case 'googlemaps': |
| 942 | - if(empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
| 942 | + if (empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
| 943 | 943 | $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>'; |
| 944 | 944 | $ph['style'] = $opt; |
| 945 | 945 | $ph['value'] = $value; |
| 946 | - return $modx->parseText($tpl,$ph); |
|
| 946 | + return $modx->parseText($tpl, $ph); |
|
| 947 | 947 | case 'youtube': |
| 948 | 948 | case 'youtube16x9': |
| 949 | - if(empty($opt)) $opt = 560; |
|
| 950 | - $h = round($opt*0.5625); |
|
| 949 | + if (empty($opt)) $opt = 560; |
|
| 950 | + $h = round($opt * 0.5625); |
|
| 951 | 951 | $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>'; |
| 952 | - return sprintf($tpl,$opt,$h,$value); |
|
| 952 | + return sprintf($tpl, $opt, $h, $value); |
|
| 953 | 953 | //case 'youtube4x3':%s*0.75+25 |
| 954 | 954 | case 'setvar': |
| 955 | 955 | $modx->placeholders[$opt] = $value; |
@@ -979,7 +979,7 @@ discard block |
||
| 979 | 979 | return $value; |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | - public function includeMdfFile($cmd) { |
|
| 982 | + public function includeMdfFile($cmd){ |
|
| 983 | 983 | global $modx; |
| 984 | 984 | $key = $this->key; |
| 985 | 985 | $value = $this->value; |
@@ -990,54 +990,54 @@ discard block |
||
| 990 | 990 | public function getValueFromElement($key, $value, $cmd, $opt) |
| 991 | 991 | { |
| 992 | 992 | global $modx; |
| 993 | - if( isset($modx->snippetCache[$this->elmName]) ) |
|
| 993 | + if (isset($modx->snippetCache[$this->elmName])) |
|
| 994 | 994 | { |
| 995 | 995 | $php = $modx->snippetCache[$this->elmName]; |
| 996 | 996 | } |
| 997 | 997 | else |
| 998 | 998 | { |
| 999 | 999 | $esc_elmName = $modx->db->escape($this->elmName); |
| 1000 | - $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'"); |
|
| 1000 | + $result = $modx->db->select('snippet', '[+prefix+]site_snippets', "name='{$esc_elmName}'"); |
|
| 1001 | 1001 | $total = $modx->db->getRecordCount($result); |
| 1002 | - if($total == 1) |
|
| 1002 | + if ($total == 1) |
|
| 1003 | 1003 | { |
| 1004 | 1004 | $row = $modx->db->getRow($result); |
| 1005 | 1005 | $php = $row['snippet']; |
| 1006 | 1006 | } |
| 1007 | - elseif($total == 0) |
|
| 1007 | + elseif ($total == 0) |
|
| 1008 | 1008 | { |
| 1009 | 1009 | $assets_path = MODX_BASE_PATH.'assets/'; |
| 1010 | - if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
| 1010 | + if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
| 1011 | 1011 | $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; |
| 1012 | - elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
| 1012 | + elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
| 1013 | 1013 | $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; |
| 1014 | - elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
| 1014 | + elseif (is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
| 1015 | 1015 | $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; |
| 1016 | 1016 | else $modifiers_path = false; |
| 1017 | 1017 | |
| 1018 | - if($modifiers_path !== false) { |
|
| 1018 | + if ($modifiers_path !== false) { |
|
| 1019 | 1019 | $php = @file_get_contents($modifiers_path); |
| 1020 | 1020 | $php = trim($php); |
| 1021 | - if(substr($php,0,5)==='<?php') $php = substr($php,6); |
|
| 1022 | - if(substr($php,0,2)==='<?') $php = substr($php,3); |
|
| 1023 | - if(substr($php,-2)==='?>') $php = substr($php,0,-2); |
|
| 1024 | - if($this->elmName!=='') |
|
| 1021 | + if (substr($php, 0, 5) === '<?php') $php = substr($php, 6); |
|
| 1022 | + if (substr($php, 0, 2) === '<?') $php = substr($php, 3); |
|
| 1023 | + if (substr($php, -2) === '?>') $php = substr($php, 0, -2); |
|
| 1024 | + if ($this->elmName !== '') |
|
| 1025 | 1025 | $modx->snippetCache[$this->elmName.'Props'] = ''; |
| 1026 | 1026 | } |
| 1027 | 1027 | else |
| 1028 | 1028 | $php = false; |
| 1029 | 1029 | } |
| 1030 | 1030 | else $php = false; |
| 1031 | - if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php; |
|
| 1031 | + if ($this->elmName !== '') $modx->snippetCache[$this->elmName] = $php; |
|
| 1032 | 1032 | } |
| 1033 | - if($php==='') $php=false; |
|
| 1033 | + if ($php === '') $php = false; |
|
| 1034 | 1034 | |
| 1035 | - if($php===false) $html = $modx->getChunk($this->elmName); |
|
| 1035 | + if ($php === false) $html = $modx->getChunk($this->elmName); |
|
| 1036 | 1036 | else $html = false; |
| 1037 | 1037 | |
| 1038 | 1038 | $self = '[+output+]'; |
| 1039 | 1039 | |
| 1040 | - if($php !== false) |
|
| 1040 | + if ($php !== false) |
|
| 1041 | 1041 | { |
| 1042 | 1042 | ob_start(); |
| 1043 | 1043 | $options = $opt; |
@@ -1050,71 +1050,71 @@ discard block |
||
| 1050 | 1050 | $this->vars['options'] = & $opt; |
| 1051 | 1051 | $custom = eval($php); |
| 1052 | 1052 | $msg = ob_get_contents(); |
| 1053 | - if($value===$this->bt) $value = $msg . $custom; |
|
| 1053 | + if ($value === $this->bt) $value = $msg.$custom; |
|
| 1054 | 1054 | ob_end_clean(); |
| 1055 | 1055 | } |
| 1056 | - elseif($html!==false && isset($value) && $value!=='') |
|
| 1056 | + elseif ($html !== false && isset($value) && $value !== '') |
|
| 1057 | 1057 | { |
| 1058 | - $html = str_replace(array($self,'[+value+]'), $value, $html); |
|
| 1059 | - $value = str_replace(array('[+options+]','[+param+]'), $opt, $html); |
|
| 1058 | + $html = str_replace(array($self, '[+value+]'), $value, $html); |
|
| 1059 | + $value = str_replace(array('[+options+]', '[+param+]'), $opt, $html); |
|
| 1060 | 1060 | } |
| 1061 | 1061 | else return false; |
| 1062 | 1062 | |
| 1063 | - if($php===false && $html===false && $value!=='' |
|
| 1064 | - && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) |
|
| 1063 | + if ($php === false && $html === false && $value !== '' |
|
| 1064 | + && (strpos($cmd, '[+value+]') !== false || strpos($cmd, $self) !== false)) |
|
| 1065 | 1065 | { |
| 1066 | - $value = str_replace(array('[+value+]',$self),$value,$cmd); |
|
| 1066 | + $value = str_replace(array('[+value+]', $self), $value, $cmd); |
|
| 1067 | 1067 | } |
| 1068 | 1068 | return $value; |
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | - public function parseDocumentSource($content='') |
|
| 1071 | + public function parseDocumentSource($content = '') |
|
| 1072 | 1072 | { |
| 1073 | 1073 | global $modx; |
| 1074 | 1074 | |
| 1075 | - if(strpos($content,'[')===false && strpos($content,'{')===false) return $content; |
|
| 1075 | + if (strpos($content, '[') === false && strpos($content, '{') === false) return $content; |
|
| 1076 | 1076 | |
| 1077 | - if(!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
| 1078 | - $bt=''; |
|
| 1079 | - $i=0; |
|
| 1080 | - while($bt!==$content) |
|
| 1077 | + if (!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
| 1078 | + $bt = ''; |
|
| 1079 | + $i = 0; |
|
| 1080 | + while ($bt !== $content) |
|
| 1081 | 1081 | { |
| 1082 | 1082 | $bt = $content; |
| 1083 | - if(strpos($content,'[*')!==false && $modx->documentIdentifier) |
|
| 1083 | + if (strpos($content, '[*') !== false && $modx->documentIdentifier) |
|
| 1084 | 1084 | $content = $modx->mergeDocumentContent($content); |
| 1085 | - if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content); |
|
| 1086 | - if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content); |
|
| 1087 | - if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content); |
|
| 1088 | - if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content); |
|
| 1085 | + if (strpos($content, '[(') !== false) $content = $modx->mergeSettingsContent($content); |
|
| 1086 | + if (strpos($content, '{{') !== false) $content = $modx->mergeChunkContent($content); |
|
| 1087 | + if (strpos($content, '[!') !== false) $content = str_replace(array('[!', '!]'), array('[[', ']]'), $content); |
|
| 1088 | + if (strpos($content, '[[') !== false) $content = $modx->evalSnippets($content); |
|
| 1089 | 1089 | |
| 1090 | - if($content===$bt) break; |
|
| 1091 | - if($modx->maxParserPasses < $i) break; |
|
| 1090 | + if ($content === $bt) break; |
|
| 1091 | + if ($modx->maxParserPasses < $i) break; |
|
| 1092 | 1092 | $i++; |
| 1093 | 1093 | } |
| 1094 | 1094 | return $content; |
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | - public function getDocumentObject($target='',$field='pagetitle') |
|
| 1097 | + public function getDocumentObject($target = '', $field = 'pagetitle') |
|
| 1098 | 1098 | { |
| 1099 | 1099 | global $modx; |
| 1100 | 1100 | |
| 1101 | 1101 | $target = trim($target); |
| 1102 | - if(empty($target)) $target = $modx->config['site_start']; |
|
| 1103 | - if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id'; |
|
| 1102 | + if (empty($target)) $target = $modx->config['site_start']; |
|
| 1103 | + if (preg_match('@^[1-9][0-9]*$@', $target)) $method = 'id'; |
|
| 1104 | 1104 | else $method = 'alias'; |
| 1105 | 1105 | |
| 1106 | - if(!isset($this->documentObject[$target])) |
|
| 1106 | + if (!isset($this->documentObject[$target])) |
|
| 1107 | 1107 | { |
| 1108 | - $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct'); |
|
| 1108 | + $this->documentObject[$target] = $modx->getDocumentObject($method, $target, 'direct'); |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | - if($this->documentObject[$target]['publishedon']==='0') |
|
| 1111 | + if ($this->documentObject[$target]['publishedon'] === '0') |
|
| 1112 | 1112 | return ''; |
| 1113 | - elseif(isset($this->documentObject[$target][$field])) |
|
| 1113 | + elseif (isset($this->documentObject[$target][$field])) |
|
| 1114 | 1114 | { |
| 1115 | - if(is_array($this->documentObject[$target][$field])) |
|
| 1115 | + if (is_array($this->documentObject[$target][$field])) |
|
| 1116 | 1116 | { |
| 1117 | - $a = $modx->getTemplateVarOutput($field,$target); |
|
| 1117 | + $a = $modx->getTemplateVarOutput($field, $target); |
|
| 1118 | 1118 | $this->documentObject[$target][$field] = $a[$field]; |
| 1119 | 1119 | } |
| 1120 | 1120 | } |
@@ -1123,8 +1123,8 @@ discard block |
||
| 1123 | 1123 | return $this->documentObject[$target][$field]; |
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | - public function setPlaceholders($value = '', $key = '', $path = '') { |
|
| 1127 | - if($path!=='') $key = "{$path}.{$key}"; |
|
| 1126 | + public function setPlaceholders($value = '', $key = '', $path = ''){ |
|
| 1127 | + if ($path !== '') $key = "{$path}.{$key}"; |
|
| 1128 | 1128 | if (is_array($value)) { |
| 1129 | 1129 | foreach ($value as $subkey => $subval) { |
| 1130 | 1130 | $this->setPlaceholders($subval, $subkey, $key); |
@@ -1134,77 +1134,77 @@ discard block |
||
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | // Sets a placeholder variable which can only be access by Modifiers |
| 1137 | - public function setModifiersVariable($key, $value) { |
|
| 1137 | + public function setModifiersVariable($key, $value){ |
|
| 1138 | 1138 | if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | //mbstring |
| 1142 | - public function substr($str, $s, $l = null) { |
|
| 1142 | + public function substr($str, $s, $l = null){ |
|
| 1143 | 1143 | global $modx; |
| 1144 | - if(is_null($l)) $l = $this->strlen($str); |
|
| 1144 | + if (is_null($l)) $l = $this->strlen($str); |
|
| 1145 | 1145 | if (function_exists('mb_substr')) |
| 1146 | 1146 | { |
| 1147 | - if(strpos($str,"\r")!==false) |
|
| 1148 | - $str = str_replace(array("\r\n","\r"), "\n", $str); |
|
| 1147 | + if (strpos($str, "\r") !== false) |
|
| 1148 | + $str = str_replace(array("\r\n", "\r"), "\n", $str); |
|
| 1149 | 1149 | return mb_substr($str, $s, $l, $modx->config['modx_charset']); |
| 1150 | 1150 | } |
| 1151 | 1151 | return substr($str, $s, $l); |
| 1152 | 1152 | } |
| 1153 | - public function strpos($haystack,$needle,$offset=0) { |
|
| 1153 | + public function strpos($haystack, $needle, $offset = 0){ |
|
| 1154 | 1154 | global $modx; |
| 1155 | - if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); |
|
| 1156 | - return strpos($haystack,$needle,$offset); |
|
| 1155 | + if (function_exists('mb_strpos')) return mb_strpos($haystack, $needle, $offset, $modx->config['modx_charset']); |
|
| 1156 | + return strpos($haystack, $needle, $offset); |
|
| 1157 | 1157 | } |
| 1158 | - public function strlen($str) { |
|
| 1158 | + public function strlen($str){ |
|
| 1159 | 1159 | global $modx; |
| 1160 | - if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); |
|
| 1160 | + if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str), $modx->config['modx_charset']); |
|
| 1161 | 1161 | return strlen($str); |
| 1162 | 1162 | } |
| 1163 | - public function strtolower($str) { |
|
| 1163 | + public function strtolower($str){ |
|
| 1164 | 1164 | if (function_exists('mb_strtolower')) return mb_strtolower($str); |
| 1165 | 1165 | return strtolower($str); |
| 1166 | 1166 | } |
| 1167 | - public function strtoupper($str) { |
|
| 1167 | + public function strtoupper($str){ |
|
| 1168 | 1168 | if (function_exists('mb_strtoupper')) return mb_strtoupper($str); |
| 1169 | 1169 | return strtoupper($str); |
| 1170 | 1170 | } |
| 1171 | - public function ucfirst($str) { |
|
| 1171 | + public function ucfirst($str){ |
|
| 1172 | 1172 | if (function_exists('mb_strtoupper')) |
| 1173 | 1173 | return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
| 1174 | 1174 | return ucfirst($str); |
| 1175 | 1175 | } |
| 1176 | - public function lcfirst($str) { |
|
| 1176 | + public function lcfirst($str){ |
|
| 1177 | 1177 | if (function_exists('mb_strtolower')) |
| 1178 | 1178 | return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
| 1179 | 1179 | return lcfirst($str); |
| 1180 | 1180 | } |
| 1181 | - public function ucwords($str) { |
|
| 1181 | + public function ucwords($str){ |
|
| 1182 | 1182 | if (function_exists('mb_convert_case')) |
| 1183 | 1183 | return mb_convert_case($str, MB_CASE_TITLE); |
| 1184 | 1184 | return ucwords($str); |
| 1185 | 1185 | } |
| 1186 | - public function strrev($str) { |
|
| 1186 | + public function strrev($str){ |
|
| 1187 | 1187 | preg_match_all('/./us', $str, $ar); |
| 1188 | 1188 | return implode(array_reverse($ar[0])); |
| 1189 | 1189 | } |
| 1190 | - public function str_shuffle($str) { |
|
| 1190 | + public function str_shuffle($str){ |
|
| 1191 | 1191 | preg_match_all('/./us', $str, $ar); |
| 1192 | 1192 | shuffle($ar[0]); |
| 1193 | 1193 | return implode($ar[0]); |
| 1194 | 1194 | } |
| 1195 | - public function str_word_count($str) { |
|
| 1196 | - return count(preg_split('~[^\p{L}\p{N}\']+~u',$str)); |
|
| 1195 | + public function str_word_count($str){ |
|
| 1196 | + return count(preg_split('~[^\p{L}\p{N}\']+~u', $str)); |
|
| 1197 | 1197 | } |
| 1198 | - public function strip_tags($value,$params='') { |
|
| 1198 | + public function strip_tags($value, $params = ''){ |
|
| 1199 | 1199 | global $modx; |
| 1200 | 1200 | |
| 1201 | - if(stripos($params,'style')===false && stripos($value,'</style>')!==false) { |
|
| 1201 | + if (stripos($params, 'style') === false && stripos($value, '</style>') !== false) { |
|
| 1202 | 1202 | $value = preg_replace('@<style.*?>.*?</style>@is', '', $value); |
| 1203 | 1203 | } |
| 1204 | - if(stripos($params,'script')===false && stripos($value,'</script>')!==false) { |
|
| 1204 | + if (stripos($params, 'script') === false && stripos($value, '</script>') !== false) { |
|
| 1205 | 1205 | $value = preg_replace('@<script.*?>.*?</script>@is', '', $value); |
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | - return trim(strip_tags($value,$params)); |
|
| 1208 | + return trim(strip_tags($value, $params)); |
|
| 1209 | 1209 | } |
| 1210 | 1210 | } |
@@ -1,8 +1,11 @@ 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')) { |
|
| 4 | + define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/'); |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | -class MODIFIERS { |
|
| 7 | +class MODIFIERS |
|
| 8 | +{ |
|
| 6 | 9 | /** |
| 7 | 10 | * @var array |
| 8 | 11 | */ |
@@ -61,7 +64,9 @@ discard block |
||
| 61 | 64 | { |
| 62 | 65 | global $modx; |
| 63 | 66 | |
| 64 | - if (function_exists('mb_internal_encoding')) mb_internal_encoding($modx->config['modx_charset']); |
|
| 67 | + if (function_exists('mb_internal_encoding')) { |
|
| 68 | + mb_internal_encoding($modx->config['modx_charset']); |
|
| 69 | + } |
|
| 65 | 70 | $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'; |
| 66 | 71 | } |
| 67 | 72 | |
@@ -74,7 +79,9 @@ discard block |
||
| 74 | 79 | public function phxFilter($key,$value,$modifiers) |
| 75 | 80 | { |
| 76 | 81 | global $modx; |
| 77 | - if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value); |
|
| 82 | + if(substr($modifiers,0,3)!=='id(') { |
|
| 83 | + $value = $this->parseDocumentSource($value); |
|
| 84 | + } |
|
| 78 | 85 | $this->srcValue = $value; |
| 79 | 86 | $modifiers = trim($modifiers); |
| 80 | 87 | $modifiers = ':'.trim($modifiers,':'); |
@@ -97,13 +104,18 @@ discard block |
||
| 97 | 104 | * @param string $modifiers |
| 98 | 105 | * @return bool|string |
| 99 | 106 | */ |
| 100 | - public function _getDelim($mode,$modifiers) { |
|
| 107 | + public function _getDelim($mode,$modifiers) |
|
| 108 | + { |
|
| 101 | 109 | $c = substr($modifiers,0,1); |
| 102 | - if(!in_array($c, array('"', "'", '`')) ) return false; |
|
| 110 | + if(!in_array($c, array('"', "'", '`')) ) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 103 | 113 | |
| 104 | 114 | $modifiers = substr($modifiers,1); |
| 105 | 115 | $closure = $mode=='(' ? "{$c})" : $c; |
| 106 | - if(strpos($modifiers, $closure)===false) return false; |
|
| 116 | + if(strpos($modifiers, $closure)===false) { |
|
| 117 | + return false; |
|
| 118 | + } |
|
| 107 | 119 | |
| 108 | 120 | return $c; |
| 109 | 121 | } |
@@ -114,52 +126,65 @@ discard block |
||
| 114 | 126 | * @param string $modifiers |
| 115 | 127 | * @return bool|string |
| 116 | 128 | */ |
| 117 | - public function _getOpt($mode,$delim,$modifiers) { |
|
| 129 | + public function _getOpt($mode,$delim,$modifiers) |
|
| 130 | + { |
|
| 118 | 131 | if($delim) { |
| 119 | - if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); |
|
| 132 | + if($mode=='(') { |
|
| 133 | + return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); |
|
| 134 | + } |
|
| 120 | 135 | |
| 121 | 136 | return substr($modifiers,1,strpos($modifiers,$delim,1)-1); |
| 122 | - } |
|
| 123 | - else { |
|
| 124 | - if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') ); |
|
| 137 | + } else { |
|
| 138 | + if($mode=='(') { |
|
| 139 | + return substr($modifiers,0,strpos($modifiers, ')') ); |
|
| 140 | + } |
|
| 125 | 141 | |
| 126 | 142 | $chars = str_split($modifiers); |
| 127 | 143 | $opt=''; |
| 128 | 144 | foreach($chars as $c) { |
| 129 | - if($c==':' || $c==')') break; |
|
| 145 | + if($c==':' || $c==')') { |
|
| 146 | + break; |
|
| 147 | + } |
|
| 130 | 148 | $opt .=$c; |
| 131 | 149 | } |
| 132 | 150 | return $opt; |
| 133 | 151 | } |
| 134 | 152 | } |
| 135 | - public function _getRemainModifiers($mode,$delim,$modifiers) { |
|
| 153 | + public function _getRemainModifiers($mode,$delim,$modifiers) |
|
| 154 | + { |
|
| 136 | 155 | if($delim) { |
| 137 | - if($mode=='(') |
|
| 138 | - return $this->_fetchContent($modifiers, $delim . ')'); |
|
| 139 | - else { |
|
| 156 | + if($mode=='(') { |
|
| 157 | + return $this->_fetchContent($modifiers, $delim . ')'); |
|
| 158 | + } else { |
|
| 140 | 159 | $modifiers = trim($modifiers); |
| 141 | 160 | $modifiers = substr($modifiers,1); |
| 142 | 161 | return $this->_fetchContent($modifiers, $delim); |
| 143 | 162 | } |
| 144 | - } |
|
| 145 | - else { |
|
| 146 | - if($mode=='(') return $this->_fetchContent($modifiers, ')'); |
|
| 163 | + } else { |
|
| 164 | + if($mode=='(') { |
|
| 165 | + return $this->_fetchContent($modifiers, ')'); |
|
| 166 | + } |
|
| 147 | 167 | $chars = str_split($modifiers); |
| 148 | 168 | foreach($chars as $c) { |
| 149 | - if($c==':') return $modifiers; |
|
| 150 | - else $modifiers = substr($modifiers,1); |
|
| 169 | + if($c==':') { |
|
| 170 | + return $modifiers; |
|
| 171 | + } else { |
|
| 172 | + $modifiers = substr($modifiers,1); |
|
| 173 | + } |
|
| 151 | 174 | } |
| 152 | 175 | return $modifiers; |
| 153 | 176 | } |
| 154 | 177 | } |
| 155 | 178 | |
| 156 | - public function _fetchContent($string,$delim) { |
|
| 179 | + public function _fetchContent($string,$delim) |
|
| 180 | + { |
|
| 157 | 181 | $len = strlen($delim); |
| 158 | 182 | $string = $this->parseDocumentSource($string); |
| 159 | 183 | return substr($string,strpos($string, $delim)+$len); |
| 160 | 184 | } |
| 161 | 185 | |
| 162 | - public function splitEachModifiers($modifiers) { |
|
| 186 | + public function splitEachModifiers($modifiers) |
|
| 187 | + { |
|
| 163 | 188 | global $modx; |
| 164 | 189 | |
| 165 | 190 | $cmd = ''; |
@@ -170,11 +195,15 @@ discard block |
||
| 170 | 195 | $c = substr($modifiers,0,1); |
| 171 | 196 | $modifiers = substr($modifiers,1); |
| 172 | 197 | |
| 173 | - if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
| 198 | + if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { |
|
| 199 | +// :=, :!=, :<=, :>=, :!<=, :!>= |
|
| 174 | 200 | $c = substr($modifiers,strlen($match[1]),1); |
| 175 | 201 | $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]"; |
| 176 | - if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1); |
|
| 177 | - else $modifiers = substr($modifiers,strlen($match[1])); |
|
| 202 | + if($c==='(') { |
|
| 203 | + $modifiers = substr($modifiers,strlen($match[1])+1); |
|
| 204 | + } else { |
|
| 205 | + $modifiers = substr($modifiers,strlen($match[1])); |
|
| 206 | + } |
|
| 178 | 207 | |
| 179 | 208 | $delim = $this->_getDelim($c,$modifiers); |
| 180 | 209 | $opt = $this->_getOpt($c,$delim,$modifiers); |
@@ -182,13 +211,12 @@ discard block |
||
| 182 | 211 | |
| 183 | 212 | $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo); |
| 184 | 213 | $cmd = ''; |
| 185 | - } |
|
| 186 | - elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
| 214 | + } elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { |
|
| 215 | +// :+3, :-3, :*3 ... |
|
| 187 | 216 | $modifiers = substr($modifiers,strlen($match[0])); |
| 188 | 217 | $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]); |
| 189 | 218 | $cmd = ''; |
| 190 | - } |
|
| 191 | - elseif($c==='(' || $c==='=') { |
|
| 219 | + } elseif($c==='(' || $c==='=') { |
|
| 192 | 220 | $modifiers = $m1 = trim($modifiers); |
| 193 | 221 | $delim = $this->_getDelim($c,$modifiers); |
| 194 | 222 | $opt = $this->_getOpt($c,$delim,$modifiers); |
@@ -198,29 +226,29 @@ discard block |
||
| 198 | 226 | $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo); |
| 199 | 227 | |
| 200 | 228 | $cmd = ''; |
| 201 | - } |
|
| 202 | - elseif($c==':') { |
|
| 229 | + } elseif($c==':') { |
|
| 203 | 230 | $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]"; |
| 204 | - if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
| 231 | + if($cmd!=='') { |
|
| 232 | + $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
| 233 | + } |
|
| 205 | 234 | |
| 206 | 235 | $cmd = ''; |
| 207 | - } |
|
| 208 | - elseif(trim($modifiers)=='' && trim($cmd)!=='') { |
|
| 236 | + } elseif(trim($modifiers)=='' && trim($cmd)!=='') { |
|
| 209 | 237 | $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]"; |
| 210 | 238 | $cmd .= $c; |
| 211 | 239 | $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
| 212 | 240 | |
| 213 | 241 | break; |
| 214 | - } |
|
| 215 | - else { |
|
| 242 | + } else { |
|
| 216 | 243 | $cmd .= $c; |
| 217 | 244 | } |
| 218 | 245 | } |
| 219 | 246 | |
| 220 | - if(empty($result)) return array(); |
|
| 247 | + if(empty($result)) { |
|
| 248 | + return array(); |
|
| 249 | + } |
|
| 221 | 250 | |
| 222 | - foreach($result as $i=>$a) |
|
| 223 | - { |
|
| 251 | + foreach($result as $i=>$a) { |
|
| 224 | 252 | $a['opt'] = $this->parseDocumentSource($a['opt']); |
| 225 | 253 | $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders); |
| 226 | 254 | } |
@@ -233,22 +261,23 @@ discard block |
||
| 233 | 261 | global $modx; |
| 234 | 262 | $lastKey = ''; |
| 235 | 263 | $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true))); |
| 236 | - if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; |
|
| 237 | - if(empty($modifiers)) return ''; |
|
| 264 | + if(isset($this->tmpCache[$cacheKey])) { |
|
| 265 | + return $this->tmpCache[$cacheKey]; |
|
| 266 | + } |
|
| 267 | + if(empty($modifiers)) { |
|
| 268 | + return ''; |
|
| 269 | + } |
|
| 238 | 270 | |
| 239 | - foreach($modifiers as $m) |
|
| 240 | - { |
|
| 271 | + foreach($modifiers as $m) { |
|
| 241 | 272 | $lastKey = strtolower($m['cmd']); |
| 242 | 273 | } |
| 243 | 274 | $_ = explode(',',$this->condModifiers); |
| 244 | - if(in_array($lastKey,$_)) |
|
| 245 | - { |
|
| 275 | + if(in_array($lastKey,$_)) { |
|
| 246 | 276 | $modifiers[] = array('cmd'=>'then','opt'=>'1'); |
| 247 | 277 | $modifiers[] = array('cmd'=>'else','opt'=>'0'); |
| 248 | 278 | } |
| 249 | 279 | |
| 250 | - foreach($modifiers as $i=>$a) |
|
| 251 | - { |
|
| 280 | + foreach($modifiers as $i=>$a) { |
|
| 252 | 281 | $value = $this->Filter($key,$value, $a['cmd'], $a['opt']); |
| 253 | 282 | } |
| 254 | 283 | $this->tmpCache[$cacheKey] = $value; |
@@ -260,25 +289,32 @@ discard block |
||
| 260 | 289 | { |
| 261 | 290 | global $modx; |
| 262 | 291 | |
| 263 | - if($key==='documentObject') $value = $modx->documentIdentifier; |
|
| 292 | + if($key==='documentObject') { |
|
| 293 | + $value = $modx->documentIdentifier; |
|
| 294 | + } |
|
| 264 | 295 | $cmd = $this->parseDocumentSource($cmd); |
| 265 | - if(preg_match('@^[1-9][/0-9]*$@',$cmd)) |
|
| 266 | - { |
|
| 267 | - if(strpos($cmd,'/')!==false) |
|
| 268 | - $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); |
|
| 296 | + if(preg_match('@^[1-9][/0-9]*$@',$cmd)) { |
|
| 297 | + if(strpos($cmd,'/')!==false) { |
|
| 298 | + $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); |
|
| 299 | + } |
|
| 269 | 300 | $opt = $cmd; |
| 270 | 301 | $cmd = 'id'; |
| 271 | 302 | } |
| 272 | 303 | |
| 273 | - if(isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
| 274 | - elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
| 275 | - else $this->elmName = ''; |
|
| 304 | + if(isset($modx->snippetCache["phx:{$cmd}"])) { |
|
| 305 | + $this->elmName = "phx:{$cmd}"; |
|
| 306 | + } elseif(isset($modx->chunkCache["phx:{$cmd}"])) { |
|
| 307 | + $this->elmName = "phx:{$cmd}"; |
|
| 308 | + } else { |
|
| 309 | + $this->elmName = ''; |
|
| 310 | + } |
|
| 276 | 311 | |
| 277 | 312 | $cmd = strtolower($cmd); |
| 278 | - if($this->elmName!=='') |
|
| 279 | - $value = $this->getValueFromElement($key, $value, $cmd, $opt); |
|
| 280 | - else |
|
| 281 | - $value = $this->getValueFromPreset($key, $value, $cmd, $opt); |
|
| 313 | + if($this->elmName!=='') { |
|
| 314 | + $value = $this->getValueFromElement($key, $value, $cmd, $opt); |
|
| 315 | + } else { |
|
| 316 | + $value = $this->getValueFromPreset($key, $value, $cmd, $opt); |
|
| 317 | + } |
|
| 282 | 318 | |
| 283 | 319 | $value = str_replace('[+key+]', $key, $value); |
| 284 | 320 | |
@@ -287,29 +323,37 @@ discard block |
||
| 287 | 323 | |
| 288 | 324 | public function isEmpty($cmd,$value) |
| 289 | 325 | { |
| 290 | - if($value!=='') return false; |
|
| 326 | + if($value!=='') { |
|
| 327 | + return false; |
|
| 328 | + } |
|
| 291 | 329 | |
| 292 | 330 | $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
| 293 | - if(in_array($cmd,$_)) return false; |
|
| 294 | - else return true; |
|
| 331 | + if(in_array($cmd,$_)) { |
|
| 332 | + return false; |
|
| 333 | + } else { |
|
| 334 | + return true; |
|
| 335 | + } |
|
| 295 | 336 | } |
| 296 | 337 | |
| 297 | 338 | public function getValueFromPreset($key, $value, $cmd, $opt) |
| 298 | 339 | { |
| 299 | 340 | global $modx; |
| 300 | 341 | |
| 301 | - if($this->isEmpty($cmd,$value)) return ''; |
|
| 342 | + if($this->isEmpty($cmd,$value)) { |
|
| 343 | + return ''; |
|
| 344 | + } |
|
| 302 | 345 | |
| 303 | 346 | $this->key = $key; |
| 304 | 347 | $this->value = $value; |
| 305 | 348 | $this->opt = $opt; |
| 306 | 349 | |
| 307 | - switch ($cmd) |
|
| 308 | - { |
|
| 350 | + switch ($cmd) { |
|
| 309 | 351 | ##### Conditional Modifiers |
| 310 | 352 | case 'input': |
| 311 | 353 | case 'if': |
| 312 | - if(!$opt) return $value; |
|
| 354 | + if(!$opt) { |
|
| 355 | + return $value; |
|
| 356 | + } |
|
| 313 | 357 | return $opt; |
| 314 | 358 | case '=': |
| 315 | 359 | case 'eq': |
@@ -370,14 +414,24 @@ discard block |
||
| 370 | 414 | case 'file_exists': |
| 371 | 415 | case 'is_readable': |
| 372 | 416 | case 'is_writable': |
| 373 | - if(!$opt) $path = $value; |
|
| 374 | - else $path = $opt; |
|
| 375 | - if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path'); |
|
| 376 | - if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/'); |
|
| 417 | + if(!$opt) { |
|
| 418 | + $path = $value; |
|
| 419 | + } else { |
|
| 420 | + $path = $opt; |
|
| 421 | + } |
|
| 422 | + if(strpos($path,MODX_MANAGER_PATH)!==false) { |
|
| 423 | + exit('Can not read core path'); |
|
| 424 | + } |
|
| 425 | + if(strpos($path,$modx->config['base_path'])===false) { |
|
| 426 | + $path = ltrim($path,'/'); |
|
| 427 | + } |
|
| 377 | 428 | $this->condition[] = (int)($cmd($path)!==false);break; |
| 378 | 429 | case 'is_image': |
| 379 | - if(!$opt) $path = $value; |
|
| 380 | - else $path = $opt; |
|
| 430 | + if(!$opt) { |
|
| 431 | + $path = $value; |
|
| 432 | + } else { |
|
| 433 | + $path = $opt; |
|
| 434 | + } |
|
| 381 | 435 | if(!is_file($path)) {$this->condition[]='0';break;} |
| 382 | 436 | $_ = getimagesize($path); |
| 383 | 437 | $this->condition[] = (int)($_[0]);break; |
@@ -400,17 +454,23 @@ discard block |
||
| 400 | 454 | case 'this': |
| 401 | 455 | $conditional = implode(' ',$this->condition); |
| 402 | 456 | $isvalid = (int)(eval("return ({$conditional});")); |
| 403 | - if ($isvalid) return $this->srcValue; |
|
| 457 | + if ($isvalid) { |
|
| 458 | + return $this->srcValue; |
|
| 459 | + } |
|
| 404 | 460 | return NULL; |
| 405 | 461 | case 'then': |
| 406 | 462 | $conditional = implode(' ',$this->condition); |
| 407 | 463 | $isvalid = (int)eval("return ({$conditional});"); |
| 408 | - if ($isvalid) return $opt; |
|
| 464 | + if ($isvalid) { |
|
| 465 | + return $opt; |
|
| 466 | + } |
|
| 409 | 467 | return null; |
| 410 | 468 | case 'else': |
| 411 | 469 | $conditional = implode(' ',$this->condition); |
| 412 | 470 | $isvalid = (int)eval("return ({$conditional});"); |
| 413 | - if (!$isvalid) return $opt; |
|
| 471 | + if (!$isvalid) { |
|
| 472 | + return $opt; |
|
| 473 | + } |
|
| 414 | 474 | break; |
| 415 | 475 | case 'select': |
| 416 | 476 | case 'switch': |
@@ -421,8 +481,11 @@ discard block |
||
| 421 | 481 | $mi = explode('=',$raw[$m],2); |
| 422 | 482 | $map[$mi[0]] = $mi[1]; |
| 423 | 483 | } |
| 424 | - if(isset($map[$value])) return $map[$value]; |
|
| 425 | - else return ''; |
|
| 484 | + if(isset($map[$value])) { |
|
| 485 | + return $map[$value]; |
|
| 486 | + } else { |
|
| 487 | + return ''; |
|
| 488 | + } |
|
| 426 | 489 | ##### End of Conditional Modifiers |
| 427 | 490 | |
| 428 | 491 | ##### Encode / Decode / Hash / Escape |
@@ -448,24 +511,25 @@ discard block |
||
| 448 | 511 | case 'spam_protect': |
| 449 | 512 | return str_replace(array('@','.'),array('@','.'),$value); |
| 450 | 513 | case 'strip': |
| 451 | - if($opt==='') $opt = ' '; |
|
| 514 | + if($opt==='') { |
|
| 515 | + $opt = ' '; |
|
| 516 | + } |
|
| 452 | 517 | return preg_replace('/[\n\r\t\s]+/', $opt, $value); |
| 453 | 518 | case 'strip_linefeeds': |
| 454 | 519 | return str_replace(array("\n","\r"), '', $value); |
| 455 | 520 | case 'notags': |
| 456 | 521 | case 'strip_tags': |
| 457 | 522 | case 'remove_html': |
| 458 | - if($opt!=='') |
|
| 459 | - { |
|
| 523 | + if($opt!=='') { |
|
| 460 | 524 | $param = array(); |
| 461 | - foreach(explode(',',$opt) as $v) |
|
| 462 | - { |
|
| 525 | + foreach(explode(',',$opt) as $v) { |
|
| 463 | 526 | $v = trim($v,'</> '); |
| 464 | 527 | $param[] = "<{$v}>"; |
| 465 | 528 | } |
| 466 | 529 | $params = implode(',',$param); |
| 530 | + } else { |
|
| 531 | + $params = ''; |
|
| 467 | 532 | } |
| 468 | - else $params = ''; |
|
| 469 | 533 | if(!strpos($params,'<br>')===false) { |
| 470 | 534 | $value = preg_replace('@(<br[ /]*>)\n@','$1',$value); |
| 471 | 535 | $value = preg_replace('@<br[ /]*>@',"\n",$value); |
@@ -476,8 +540,11 @@ discard block |
||
| 476 | 540 | case 'encode_url': |
| 477 | 541 | return urlencode($value); |
| 478 | 542 | case 'base64_decode': |
| 479 | - if($opt!=='false') $opt = true; |
|
| 480 | - else $opt = false; |
|
| 543 | + if($opt!=='false') { |
|
| 544 | + $opt = true; |
|
| 545 | + } else { |
|
| 546 | + $opt = false; |
|
| 547 | + } |
|
| 481 | 548 | return base64_decode($value,$opt); |
| 482 | 549 | case 'encode_sha1': $cmd = 'sha1'; |
| 483 | 550 | case 'addslashes': |
@@ -503,16 +570,19 @@ discard block |
||
| 503 | 570 | return $this->strtoupper($value); |
| 504 | 571 | case 'capitalize': |
| 505 | 572 | $_ = explode(' ',$value); |
| 506 | - foreach($_ as $i=>$v) |
|
| 507 | - { |
|
| 573 | + foreach($_ as $i=>$v) { |
|
| 508 | 574 | $_[$i] = ucfirst($v); |
| 509 | 575 | } |
| 510 | 576 | return implode(' ',$_); |
| 511 | 577 | case 'zenhan': |
| 512 | - if(empty($opt)) $opt='VKas'; |
|
| 578 | + if(empty($opt)) { |
|
| 579 | + $opt='VKas'; |
|
| 580 | + } |
|
| 513 | 581 | return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
| 514 | 582 | case 'hanzen': |
| 515 | - if(empty($opt)) $opt='VKAS'; |
|
| 583 | + if(empty($opt)) { |
|
| 584 | + $opt='VKAS'; |
|
| 585 | + } |
|
| 516 | 586 | return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
| 517 | 587 | case 'str_shuffle': |
| 518 | 588 | case 'shuffle': |
@@ -537,13 +607,18 @@ discard block |
||
| 537 | 607 | $value = preg_replace('/\r/', '', $value); |
| 538 | 608 | return count(preg_split('/\n+/',$value)); |
| 539 | 609 | case 'strpos': |
| 540 | - if($opt!=0&&empty($opt)) return $value; |
|
| 610 | + if($opt!=0&&empty($opt)) { |
|
| 611 | + return $value; |
|
| 612 | + } |
|
| 541 | 613 | return $this->strpos($value,$opt); |
| 542 | 614 | case 'wordwrap': |
| 543 | 615 | // default: 70 |
| 544 | 616 | $wrapat = (int)$opt > 0 ? (int)$opt : 70; |
| 545 | - if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap'); |
|
| 546 | - else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value); |
|
| 617 | + if (version_compare(PHP_VERSION, '5.3.0') >= 0) { |
|
| 618 | + return $this->includeMdfFile('wordwrap'); |
|
| 619 | + } else { |
|
| 620 | + return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value); |
|
| 621 | + } |
|
| 547 | 622 | case 'wrap_text': |
| 548 | 623 | $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70; |
| 549 | 624 | if($modx->config['manager_language']==='japanese-utf8') { |
@@ -559,30 +634,36 @@ discard block |
||
| 559 | 634 | $value = $this->substr($value,$width); |
| 560 | 635 | } |
| 561 | 636 | return implode("\n",$chunk); |
| 637 | + } else { |
|
| 638 | + return wordwrap($value,$width,"\n",true); |
|
| 562 | 639 | } |
| 563 | - else |
|
| 564 | - return wordwrap($value,$width,"\n",true); |
|
| 565 | 640 | case 'substr': |
| 566 | - if(empty($opt)) break; |
|
| 641 | + if(empty($opt)) { |
|
| 642 | + break; |
|
| 643 | + } |
|
| 567 | 644 | if(strpos($opt,',')!==false) { |
| 568 | 645 | list($b,$e) = explode(',',$opt,2); |
| 569 | 646 | return $this->substr($value,$b,(int)$e); |
| 647 | + } else { |
|
| 648 | + return $this->substr($value,$opt); |
|
| 570 | 649 | } |
| 571 | - else return $this->substr($value,$opt); |
|
| 572 | 650 | case 'limit': |
| 573 | 651 | case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html |
| 574 | - if(strpos($opt,'+')!==false) |
|
| 575 | - list($len,$str) = explode('+',$opt,2); |
|
| 576 | - else { |
|
| 652 | + if(strpos($opt,'+')!==false) { |
|
| 653 | + list($len,$str) = explode('+',$opt,2); |
|
| 654 | + } else { |
|
| 577 | 655 | $len = $opt; |
| 578 | 656 | $str = ''; |
| 579 | 657 | } |
| 580 | - if($len==='') $len = 100; |
|
| 581 | - if(abs($len) > $this->strlen($value)) $str =''; |
|
| 658 | + if($len==='') { |
|
| 659 | + $len = 100; |
|
| 660 | + } |
|
| 661 | + if(abs($len) > $this->strlen($value)) { |
|
| 662 | + $str =''; |
|
| 663 | + } |
|
| 582 | 664 | if(preg_match('/^[1-9][0-9]*$/',$len)) { |
| 583 | 665 | return $this->substr($value,0,$len) . $str; |
| 584 | - } |
|
| 585 | - elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { |
|
| 666 | + } elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { |
|
| 586 | 667 | return $str . $this->substr($value,$len); |
| 587 | 668 | } |
| 588 | 669 | break; |
@@ -592,18 +673,30 @@ discard block |
||
| 592 | 673 | return $this->includeMdfFile('summary'); |
| 593 | 674 | case 'replace': |
| 594 | 675 | case 'str_replace': |
| 595 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
| 596 | - if (substr_count($opt, ',') ==1) $delim = ','; |
|
| 597 | - elseif(substr_count($opt, '|') ==1) $delim = '|'; |
|
| 598 | - elseif(substr_count($opt, '=>')==1) $delim = '=>'; |
|
| 599 | - elseif(substr_count($opt, '/') ==1) $delim = '/'; |
|
| 600 | - else break; |
|
| 676 | + if(empty($opt) || strpos($opt,',')===false) { |
|
| 677 | + break; |
|
| 678 | + } |
|
| 679 | + if (substr_count($opt, ',') ==1) { |
|
| 680 | + $delim = ','; |
|
| 681 | + } elseif(substr_count($opt, '|') ==1) { |
|
| 682 | + $delim = '|'; |
|
| 683 | + } elseif(substr_count($opt, '=>')==1) { |
|
| 684 | + $delim = '=>'; |
|
| 685 | + } elseif(substr_count($opt, '/') ==1) { |
|
| 686 | + $delim = '/'; |
|
| 687 | + } else { |
|
| 688 | + break; |
|
| 689 | + } |
|
| 601 | 690 | list($s,$r) = explode($delim,$opt); |
| 602 | - if($value!=='') return str_replace($s,$r,$value); |
|
| 691 | + if($value!=='') { |
|
| 692 | + return str_replace($s,$r,$value); |
|
| 693 | + } |
|
| 603 | 694 | break; |
| 604 | 695 | case 'replace_to': |
| 605 | 696 | case 'tpl': |
| 606 | - if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); |
|
| 697 | + if($value!=='') { |
|
| 698 | + return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); |
|
| 699 | + } |
|
| 607 | 700 | break; |
| 608 | 701 | case 'eachtpl': |
| 609 | 702 | $value = explode('||',$value); |
@@ -614,59 +707,83 @@ discard block |
||
| 614 | 707 | return implode("\n", $_); |
| 615 | 708 | case 'array_pop': |
| 616 | 709 | case 'array_shift': |
| 617 | - if(strpos($value,'||')!==false) $delim = '||'; |
|
| 618 | - else $delim = ','; |
|
| 710 | + if(strpos($value,'||')!==false) { |
|
| 711 | + $delim = '||'; |
|
| 712 | + } else { |
|
| 713 | + $delim = ','; |
|
| 714 | + } |
|
| 619 | 715 | return $cmd(explode($delim,$value)); |
| 620 | 716 | case 'preg_replace': |
| 621 | 717 | case 'regex_replace': |
| 622 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
| 718 | + if(empty($opt) || strpos($opt,',')===false) { |
|
| 719 | + break; |
|
| 720 | + } |
|
| 623 | 721 | list($s,$r) = explode(',',$opt,2); |
| 624 | - if($value!=='') return preg_replace($s,$r,$value); |
|
| 722 | + if($value!=='') { |
|
| 723 | + return preg_replace($s,$r,$value); |
|
| 724 | + } |
|
| 625 | 725 | break; |
| 626 | 726 | case 'cat': |
| 627 | 727 | case 'concatenate': |
| 628 | 728 | case '.': |
| 629 | - if($value!=='') return $value . $opt; |
|
| 729 | + if($value!=='') { |
|
| 730 | + return $value . $opt; |
|
| 731 | + } |
|
| 630 | 732 | break; |
| 631 | 733 | case 'sprintf': |
| 632 | 734 | case 'string_format': |
| 633 | - if($value!=='') return sprintf($opt,$value); |
|
| 735 | + if($value!=='') { |
|
| 736 | + return sprintf($opt,$value); |
|
| 737 | + } |
|
| 634 | 738 | break; |
| 635 | 739 | case 'number_format': |
| 636 | - if($opt=='') $opt = 0; |
|
| 740 | + if($opt=='') { |
|
| 741 | + $opt = 0; |
|
| 742 | + } |
|
| 637 | 743 | return number_format($value,$opt); |
| 638 | 744 | case 'money_format': |
| 639 | 745 | setlocale(LC_MONETARY,setlocale(LC_TIME,0)); |
| 640 | - if($value!=='') return money_format($opt,(double)$value); |
|
| 746 | + if($value!=='') { |
|
| 747 | + return money_format($opt,(double)$value); |
|
| 748 | + } |
|
| 641 | 749 | break; |
| 642 | 750 | case 'tobool': |
| 643 | 751 | return boolval($value); |
| 644 | 752 | case 'nl2lf': |
| 645 | - if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value); |
|
| 753 | + if($value!=='') { |
|
| 754 | + return str_replace(array("\r\n","\n", "\r"), '\n', $value); |
|
| 755 | + } |
|
| 646 | 756 | break; |
| 647 | 757 | case 'br2nl': |
| 648 | 758 | return preg_replace('@<br[\s/]*>@i', "\n", $value); |
| 649 | 759 | case 'nl2br': |
| 650 | - if (version_compare(PHP_VERSION, '5.3.0', '<')) |
|
| 651 | - return nl2br($value); |
|
| 652 | - if($opt!=='') |
|
| 653 | - { |
|
| 760 | + if (version_compare(PHP_VERSION, '5.3.0', '<')) { |
|
| 761 | + return nl2br($value); |
|
| 762 | + } |
|
| 763 | + if($opt!=='') { |
|
| 654 | 764 | $opt = trim($opt); |
| 655 | 765 | $opt = strtolower($opt); |
| 656 | - if($opt==='false') $opt = false; |
|
| 657 | - elseif($opt==='0') $opt = false; |
|
| 658 | - else $opt = true; |
|
| 766 | + if($opt==='false') { |
|
| 767 | + $opt = false; |
|
| 768 | + } elseif($opt==='0') { |
|
| 769 | + $opt = false; |
|
| 770 | + } else { |
|
| 771 | + $opt = true; |
|
| 772 | + } |
|
| 773 | + } elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') { |
|
| 774 | + $opt = false; |
|
| 775 | + } else { |
|
| 776 | + $opt = true; |
|
| 659 | 777 | } |
| 660 | - elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') |
|
| 661 | - $opt = false; |
|
| 662 | - else $opt = true; |
|
| 663 | 778 | return nl2br($value,$opt); |
| 664 | 779 | case 'ltrim': |
| 665 | 780 | case 'rtrim': |
| 666 | 781 | case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html |
| 667 | - if($opt==='') |
|
| 668 | - return $cmd($value); |
|
| 669 | - else return $cmd($value,$opt); |
|
| 782 | + if($opt==='') { |
|
| 783 | + return $cmd($value); |
|
| 784 | + } else { |
|
| 785 | + return $cmd($value,$opt); |
|
| 786 | + } |
|
| 670 | 787 | // These are all straight wrappers for PHP functions |
| 671 | 788 | case 'ucfirst': |
| 672 | 789 | case 'lcfirst': |
@@ -677,15 +794,24 @@ discard block |
||
| 677 | 794 | case 'strftime': |
| 678 | 795 | case 'date': |
| 679 | 796 | case 'dateformat': |
| 680 | - if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
| 681 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
| 682 | - if(strpos($opt,'%')!==false) |
|
| 683 | - return strftime($opt,0+$value); |
|
| 684 | - else |
|
| 685 | - return date($opt,0+$value); |
|
| 797 | + if(empty($opt)) { |
|
| 798 | + $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
| 799 | + } |
|
| 800 | + if(!preg_match('@^[0-9]+$@',$value)) { |
|
| 801 | + $value = strtotime($value); |
|
| 802 | + } |
|
| 803 | + if(strpos($opt,'%')!==false) { |
|
| 804 | + return strftime($opt,0+$value); |
|
| 805 | + } else { |
|
| 806 | + return date($opt,0+$value); |
|
| 807 | + } |
|
| 686 | 808 | case 'time': |
| 687 | - if(empty($opt)) $opt = '%H:%M'; |
|
| 688 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
| 809 | + if(empty($opt)) { |
|
| 810 | + $opt = '%H:%M'; |
|
| 811 | + } |
|
| 812 | + if(!preg_match('@^[0-9]+$@',$value)) { |
|
| 813 | + $value = strtotime($value); |
|
| 814 | + } |
|
| 689 | 815 | return strftime($opt,0+$value); |
| 690 | 816 | case 'strtotime': |
| 691 | 817 | return strtotime($value); |
@@ -695,7 +821,9 @@ discard block |
||
| 695 | 821 | case 'tofloat': |
| 696 | 822 | return floatval($value); |
| 697 | 823 | case 'round': |
| 698 | - if(!$opt) $opt = 0; |
|
| 824 | + if(!$opt) { |
|
| 825 | + $opt = 0; |
|
| 826 | + } |
|
| 699 | 827 | return $cmd($value,$opt); |
| 700 | 828 | case 'max': |
| 701 | 829 | case 'min': |
@@ -707,28 +835,42 @@ discard block |
||
| 707 | 835 | case 'math': |
| 708 | 836 | case 'calc': |
| 709 | 837 | $value = (int)$value; |
| 710 | - if(empty($value)) $value = '0'; |
|
| 838 | + if(empty($value)) { |
|
| 839 | + $value = '0'; |
|
| 840 | + } |
|
| 711 | 841 | $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt); |
| 712 | 842 | $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter); |
| 713 | - if(strpos($filter,'?')===false) $filter = "?{$filter}"; |
|
| 843 | + if(strpos($filter,'?')===false) { |
|
| 844 | + $filter = "?{$filter}"; |
|
| 845 | + } |
|
| 714 | 846 | $filter = str_replace('?',$value,$filter); |
| 715 | 847 | return eval("return {$filter};"); |
| 716 | 848 | case 'count': |
| 717 | - if($value=='') return 0; |
|
| 849 | + if($value=='') { |
|
| 850 | + return 0; |
|
| 851 | + } |
|
| 718 | 852 | $value = explode(',',$value); |
| 719 | 853 | return count($value); |
| 720 | 854 | case 'sort': |
| 721 | 855 | case 'rsort': |
| 722 | - if(strpos($value,"\n")!==false) $delim="\n"; |
|
| 723 | - else $delim = ','; |
|
| 856 | + if(strpos($value,"\n")!==false) { |
|
| 857 | + $delim="\n"; |
|
| 858 | + } else { |
|
| 859 | + $delim = ','; |
|
| 860 | + } |
|
| 724 | 861 | $swap = explode($delim,$value); |
| 725 | - if(!$opt) $opt = SORT_REGULAR; |
|
| 726 | - else $opt = constant($opt); |
|
| 862 | + if(!$opt) { |
|
| 863 | + $opt = SORT_REGULAR; |
|
| 864 | + } else { |
|
| 865 | + $opt = constant($opt); |
|
| 866 | + } |
|
| 727 | 867 | $cmd($swap,$opt); |
| 728 | 868 | return implode($delim,$swap); |
| 729 | 869 | ##### Resource fields |
| 730 | 870 | case 'id': |
| 731 | - if($opt) return $this->getDocumentObject($opt,$key); |
|
| 871 | + if($opt) { |
|
| 872 | + return $this->getDocumentObject($opt,$key); |
|
| 873 | + } |
|
| 732 | 874 | break; |
| 733 | 875 | case 'type': |
| 734 | 876 | case 'contenttype': |
@@ -765,7 +907,9 @@ discard block |
||
| 765 | 907 | case 'privatemgr': |
| 766 | 908 | case 'content_dispo': |
| 767 | 909 | case 'hidemenu': |
| 768 | - if($cmd==='contenttype') $cmd = 'contentType'; |
|
| 910 | + if($cmd==='contenttype') { |
|
| 911 | + $cmd = 'contentType'; |
|
| 912 | + } |
|
| 769 | 913 | return $this->getDocumentObject($value,$cmd); |
| 770 | 914 | case 'title': |
| 771 | 915 | $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
@@ -780,13 +924,20 @@ discard block |
||
| 780 | 924 | $templateName = $modx->db->getValue($rs); |
| 781 | 925 | return !$templateName ? '(blank)' : $templateName; |
| 782 | 926 | case 'getfield': |
| 783 | - if(!$opt) $opt = 'content'; |
|
| 927 | + if(!$opt) { |
|
| 928 | + $opt = 'content'; |
|
| 929 | + } |
|
| 784 | 930 | return $modx->getField($opt,$value); |
| 785 | 931 | case 'children': |
| 786 | 932 | case 'childids': |
| 787 | - if($value=='') $value = 0; // 値がない場合はルートと見なす |
|
| 933 | + if($value=='') { |
|
| 934 | + $value = 0; |
|
| 935 | + } |
|
| 936 | + // 値がない場合はルートと見なす |
|
| 788 | 937 | $published = 1; |
| 789 | - if($opt=='') $opt = 'page'; |
|
| 938 | + if($opt=='') { |
|
| 939 | + $opt = 'page'; |
|
| 940 | + } |
|
| 790 | 941 | $_ = explode(',',$opt); |
| 791 | 942 | $where = array(); |
| 792 | 943 | foreach($_ as $opt) { |
@@ -802,29 +953,43 @@ discard block |
||
| 802 | 953 | $where = implode(' AND ', $where); |
| 803 | 954 | $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where); |
| 804 | 955 | $result = array(); |
| 805 | - foreach((array)$children as $child){ |
|
| 956 | + foreach((array)$children as $child) { |
|
| 806 | 957 | $result[] = $child['id']; |
| 807 | 958 | } |
| 808 | 959 | return implode(',', $result); |
| 809 | 960 | case 'fullurl': |
| 810 | - if(!is_numeric($value)) return $value; |
|
| 961 | + if(!is_numeric($value)) { |
|
| 962 | + return $value; |
|
| 963 | + } |
|
| 811 | 964 | return $modx->makeUrl($value); |
| 812 | 965 | case 'makeurl': |
| 813 | - if(!is_numeric($value)) return $value; |
|
| 814 | - if(!$opt) $opt = 'full'; |
|
| 966 | + if(!is_numeric($value)) { |
|
| 967 | + return $value; |
|
| 968 | + } |
|
| 969 | + if(!$opt) { |
|
| 970 | + $opt = 'full'; |
|
| 971 | + } |
|
| 815 | 972 | return $modx->makeUrl($value,'','',$opt); |
| 816 | 973 | |
| 817 | 974 | ##### File system |
| 818 | 975 | case 'getimageinfo': |
| 819 | 976 | case 'imageinfo': |
| 820 | - if(!is_file($value)) return ''; |
|
| 977 | + if(!is_file($value)) { |
|
| 978 | + return ''; |
|
| 979 | + } |
|
| 821 | 980 | $_ = getimagesize($value); |
| 822 | - if(!$_[0]) return ''; |
|
| 981 | + if(!$_[0]) { |
|
| 982 | + return ''; |
|
| 983 | + } |
|
| 823 | 984 | $info['width'] = $_[0]; |
| 824 | 985 | $info['height'] = $_[1]; |
| 825 | - if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
| 826 | - elseif($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
| 827 | - else $info['aspect'] = 'square'; |
|
| 986 | + if ($_[0] > $_[1]) { |
|
| 987 | + $info['aspect'] = 'landscape'; |
|
| 988 | + } elseif($_[0] < $_[1]) { |
|
| 989 | + $info['aspect'] = 'portrait'; |
|
| 990 | + } else { |
|
| 991 | + $info['aspect'] = 'square'; |
|
| 992 | + } |
|
| 828 | 993 | switch($_[2]) { |
| 829 | 994 | case IMAGETYPE_GIF : $info['type'] = 'gif'; break; |
| 830 | 995 | case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break; |
@@ -843,33 +1008,47 @@ discard block |
||
| 843 | 1008 | |
| 844 | 1009 | case 'file_get_contents': |
| 845 | 1010 | case 'readfile': |
| 846 | - if(!is_file($value)) return $value; |
|
| 1011 | + if(!is_file($value)) { |
|
| 1012 | + return $value; |
|
| 1013 | + } |
|
| 847 | 1014 | $value = realpath($value); |
| 848 | - if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file'); |
|
| 1015 | + if(strpos($value,MODX_MANAGER_PATH)!==false) { |
|
| 1016 | + exit('Can not read core file'); |
|
| 1017 | + } |
|
| 849 | 1018 | $ext = strtolower(substr($value,-4)); |
| 850 | - if($ext==='.php') exit('Can not read php file'); |
|
| 851 | - if($ext==='.cgi') exit('Can not read cgi file'); |
|
| 1019 | + if($ext==='.php') { |
|
| 1020 | + exit('Can not read php file'); |
|
| 1021 | + } |
|
| 1022 | + if($ext==='.cgi') { |
|
| 1023 | + exit('Can not read cgi file'); |
|
| 1024 | + } |
|
| 852 | 1025 | return file_get_contents($value); |
| 853 | 1026 | case 'filesize': |
| 854 | - if($value == '') return ''; |
|
| 1027 | + if($value == '') { |
|
| 1028 | + return ''; |
|
| 1029 | + } |
|
| 855 | 1030 | $filename = $value; |
| 856 | 1031 | |
| 857 | 1032 | $site_url = $modx->config['site_url']; |
| 858 | - if(strpos($filename,$site_url) === 0) |
|
| 859 | - $filename = substr($filename,0,strlen($site_url)); |
|
| 1033 | + if(strpos($filename,$site_url) === 0) { |
|
| 1034 | + $filename = substr($filename,0,strlen($site_url)); |
|
| 1035 | + } |
|
| 860 | 1036 | $filename = trim($filename,'/'); |
| 861 | 1037 | |
| 862 | 1038 | $opt = trim($opt,'/'); |
| 863 | - if($opt!=='') $opt .= '/'; |
|
| 1039 | + if($opt!=='') { |
|
| 1040 | + $opt .= '/'; |
|
| 1041 | + } |
|
| 864 | 1042 | |
| 865 | 1043 | $filename = MODX_BASE_PATH.$opt.$filename; |
| 866 | 1044 | |
| 867 | - if(is_file($filename)){ |
|
| 1045 | + if(is_file($filename)) { |
|
| 868 | 1046 | clearstatcache(); |
| 869 | 1047 | $size = filesize($filename); |
| 870 | 1048 | return $size; |
| 1049 | + } else { |
|
| 1050 | + return ''; |
|
| 871 | 1051 | } |
| 872 | - else return ''; |
|
| 873 | 1052 | ##### User info |
| 874 | 1053 | case 'username': |
| 875 | 1054 | case 'fullname': |
@@ -897,32 +1076,47 @@ discard block |
||
| 897 | 1076 | $this->opt = $cmd; |
| 898 | 1077 | return $this->includeMdfFile('moduser'); |
| 899 | 1078 | case 'userinfo': |
| 900 | - if(empty($opt)) $this->opt = 'username'; |
|
| 1079 | + if(empty($opt)) { |
|
| 1080 | + $this->opt = 'username'; |
|
| 1081 | + } |
|
| 901 | 1082 | return $this->includeMdfFile('moduser'); |
| 902 | 1083 | case 'webuserinfo': |
| 903 | - if(empty($opt)) $this->opt = 'username'; |
|
| 1084 | + if(empty($opt)) { |
|
| 1085 | + $this->opt = 'username'; |
|
| 1086 | + } |
|
| 904 | 1087 | $this->value = -$value; |
| 905 | 1088 | return $this->includeMdfFile('moduser'); |
| 906 | 1089 | ##### Special functions |
| 907 | 1090 | case 'ifempty': |
| 908 | 1091 | case '_default': |
| 909 | 1092 | case 'default': |
| 910 | - if (empty($value)) return $opt; break; |
|
| 1093 | + if (empty($value)) { |
|
| 1094 | + return $opt; |
|
| 1095 | + } |
|
| 1096 | + break; |
|
| 911 | 1097 | case 'ifnotempty': |
| 912 | - if (!empty($value)) return $opt; break; |
|
| 1098 | + if (!empty($value)) { |
|
| 1099 | + return $opt; |
|
| 1100 | + } |
|
| 1101 | + break; |
|
| 913 | 1102 | case 'datagrid': |
| 914 | 1103 | include_once(MODX_CORE_PATH . 'controls/datagrid.class.php'); |
| 915 | 1104 | $grd = new DataGrid(null, trim($value)); |
| 916 | 1105 | $grd->itemStyle = ''; |
| 917 | 1106 | $grd->altItemStyle = ''; |
| 918 | 1107 | $pos = strpos($value,"\n"); |
| 919 | - if($pos) $_ = substr($value,0,$pos); |
|
| 920 | - else $_ = $pos; |
|
| 1108 | + if($pos) { |
|
| 1109 | + $_ = substr($value,0,$pos); |
|
| 1110 | + } else { |
|
| 1111 | + $_ = $pos; |
|
| 1112 | + } |
|
| 921 | 1113 | $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ','; |
| 922 | 1114 | return $grd->render(); |
| 923 | 1115 | case 'rotate': |
| 924 | 1116 | case 'evenodd': |
| 925 | - if(strpos($opt,',')===false) $opt = 'odd,even'; |
|
| 1117 | + if(strpos($opt,',')===false) { |
|
| 1118 | + $opt = 'odd,even'; |
|
| 1119 | + } |
|
| 926 | 1120 | $_ = explode(',', $opt); |
| 927 | 1121 | $c = count($_); |
| 928 | 1122 | $i = $value + $c; |
@@ -931,7 +1125,9 @@ discard block |
||
| 931 | 1125 | case 'takeval': |
| 932 | 1126 | $arr = explode(",",$opt); |
| 933 | 1127 | $idx = $value; |
| 934 | - if(!is_numeric($idx)) return $value; |
|
| 1128 | + if(!is_numeric($idx)) { |
|
| 1129 | + return $value; |
|
| 1130 | + } |
|
| 935 | 1131 | return $arr[$idx]; |
| 936 | 1132 | case 'getimage': |
| 937 | 1133 | return $this->includeMdfFile('getimage'); |
@@ -939,14 +1135,18 @@ discard block |
||
| 939 | 1135 | return $modx->nicesize($value); |
| 940 | 1136 | case 'googlemap': |
| 941 | 1137 | case 'googlemaps': |
| 942 | - if(empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
| 1138 | + if(empty($opt)) { |
|
| 1139 | + $opt = 'border:none;width:500px;height:350px;'; |
|
| 1140 | + } |
|
| 943 | 1141 | $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>'; |
| 944 | 1142 | $ph['style'] = $opt; |
| 945 | 1143 | $ph['value'] = $value; |
| 946 | 1144 | return $modx->parseText($tpl,$ph); |
| 947 | 1145 | case 'youtube': |
| 948 | 1146 | case 'youtube16x9': |
| 949 | - if(empty($opt)) $opt = 560; |
|
| 1147 | + if(empty($opt)) { |
|
| 1148 | + $opt = 560; |
|
| 1149 | + } |
|
| 950 | 1150 | $h = round($opt*0.5625); |
| 951 | 1151 | $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>'; |
| 952 | 1152 | return sprintf($tpl,$opt,$h,$value); |
@@ -979,7 +1179,8 @@ discard block |
||
| 979 | 1179 | return $value; |
| 980 | 1180 | } |
| 981 | 1181 | |
| 982 | - public function includeMdfFile($cmd) { |
|
| 1182 | + public function includeMdfFile($cmd) |
|
| 1183 | + { |
|
| 983 | 1184 | global $modx; |
| 984 | 1185 | $key = $this->key; |
| 985 | 1186 | $value = $this->value; |
@@ -990,55 +1191,65 @@ discard block |
||
| 990 | 1191 | public function getValueFromElement($key, $value, $cmd, $opt) |
| 991 | 1192 | { |
| 992 | 1193 | global $modx; |
| 993 | - if( isset($modx->snippetCache[$this->elmName]) ) |
|
| 994 | - { |
|
| 1194 | + if( isset($modx->snippetCache[$this->elmName]) ) { |
|
| 995 | 1195 | $php = $modx->snippetCache[$this->elmName]; |
| 996 | - } |
|
| 997 | - else |
|
| 998 | - { |
|
| 1196 | + } else { |
|
| 999 | 1197 | $esc_elmName = $modx->db->escape($this->elmName); |
| 1000 | 1198 | $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'"); |
| 1001 | 1199 | $total = $modx->db->getRecordCount($result); |
| 1002 | - if($total == 1) |
|
| 1003 | - { |
|
| 1200 | + if($total == 1) { |
|
| 1004 | 1201 | $row = $modx->db->getRow($result); |
| 1005 | 1202 | $php = $row['snippet']; |
| 1006 | - } |
|
| 1007 | - elseif($total == 0) |
|
| 1008 | - { |
|
| 1203 | + } elseif($total == 0) { |
|
| 1009 | 1204 | $assets_path = MODX_BASE_PATH.'assets/'; |
| 1010 | - if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
| 1011 | - $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; |
|
| 1012 | - elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
| 1013 | - $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; |
|
| 1014 | - elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
| 1015 | - $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; |
|
| 1016 | - else $modifiers_path = false; |
|
| 1205 | + if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) { |
|
| 1206 | + $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; |
|
| 1207 | + } elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) { |
|
| 1208 | + $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; |
|
| 1209 | + } elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) { |
|
| 1210 | + $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; |
|
| 1211 | + } else { |
|
| 1212 | + $modifiers_path = false; |
|
| 1213 | + } |
|
| 1017 | 1214 | |
| 1018 | 1215 | if($modifiers_path !== false) { |
| 1019 | 1216 | $php = @file_get_contents($modifiers_path); |
| 1020 | 1217 | $php = trim($php); |
| 1021 | - if(substr($php,0,5)==='<?php') $php = substr($php,6); |
|
| 1022 | - if(substr($php,0,2)==='<?') $php = substr($php,3); |
|
| 1023 | - if(substr($php,-2)==='?>') $php = substr($php,0,-2); |
|
| 1024 | - if($this->elmName!=='') |
|
| 1025 | - $modx->snippetCache[$this->elmName.'Props'] = ''; |
|
| 1026 | - } |
|
| 1027 | - else |
|
| 1028 | - $php = false; |
|
| 1218 | + if(substr($php,0,5)==='<?php') { |
|
| 1219 | + $php = substr($php,6); |
|
| 1220 | + } |
|
| 1221 | + if(substr($php,0,2)==='<?') { |
|
| 1222 | + $php = substr($php,3); |
|
| 1223 | + } |
|
| 1224 | + if(substr($php,-2)==='?>') { |
|
| 1225 | + $php = substr($php,0,-2); |
|
| 1226 | + } |
|
| 1227 | + if($this->elmName!=='') { |
|
| 1228 | + $modx->snippetCache[$this->elmName.'Props'] = ''; |
|
| 1229 | + } |
|
| 1230 | + } else { |
|
| 1231 | + $php = false; |
|
| 1232 | + } |
|
| 1233 | + } else { |
|
| 1234 | + $php = false; |
|
| 1235 | + } |
|
| 1236 | + if($this->elmName!=='') { |
|
| 1237 | + $modx->snippetCache[$this->elmName]= $php; |
|
| 1029 | 1238 | } |
| 1030 | - else $php = false; |
|
| 1031 | - if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php; |
|
| 1032 | 1239 | } |
| 1033 | - if($php==='') $php=false; |
|
| 1240 | + if($php==='') { |
|
| 1241 | + $php=false; |
|
| 1242 | + } |
|
| 1034 | 1243 | |
| 1035 | - if($php===false) $html = $modx->getChunk($this->elmName); |
|
| 1036 | - else $html = false; |
|
| 1244 | + if($php===false) { |
|
| 1245 | + $html = $modx->getChunk($this->elmName); |
|
| 1246 | + } else { |
|
| 1247 | + $html = false; |
|
| 1248 | + } |
|
| 1037 | 1249 | |
| 1038 | 1250 | $self = '[+output+]'; |
| 1039 | 1251 | |
| 1040 | - if($php !== false) |
|
| 1041 | - { |
|
| 1252 | + if($php !== false) { |
|
| 1042 | 1253 | ob_start(); |
| 1043 | 1254 | $options = $opt; |
| 1044 | 1255 | $output = $value; |
@@ -1050,19 +1261,19 @@ discard block |
||
| 1050 | 1261 | $this->vars['options'] = & $opt; |
| 1051 | 1262 | $custom = eval($php); |
| 1052 | 1263 | $msg = ob_get_contents(); |
| 1053 | - if($value===$this->bt) $value = $msg . $custom; |
|
| 1264 | + if($value===$this->bt) { |
|
| 1265 | + $value = $msg . $custom; |
|
| 1266 | + } |
|
| 1054 | 1267 | ob_end_clean(); |
| 1055 | - } |
|
| 1056 | - elseif($html!==false && isset($value) && $value!=='') |
|
| 1057 | - { |
|
| 1268 | + } elseif($html!==false && isset($value) && $value!=='') { |
|
| 1058 | 1269 | $html = str_replace(array($self,'[+value+]'), $value, $html); |
| 1059 | 1270 | $value = str_replace(array('[+options+]','[+param+]'), $opt, $html); |
| 1271 | + } else { |
|
| 1272 | + return false; |
|
| 1060 | 1273 | } |
| 1061 | - else return false; |
|
| 1062 | 1274 | |
| 1063 | 1275 | if($php===false && $html===false && $value!=='' |
| 1064 | - && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) |
|
| 1065 | - { |
|
| 1276 | + && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) { |
|
| 1066 | 1277 | $value = str_replace(array('[+value+]',$self),$value,$cmd); |
| 1067 | 1278 | } |
| 1068 | 1279 | return $value; |
@@ -1072,23 +1283,39 @@ discard block |
||
| 1072 | 1283 | { |
| 1073 | 1284 | global $modx; |
| 1074 | 1285 | |
| 1075 | - if(strpos($content,'[')===false && strpos($content,'{')===false) return $content; |
|
| 1286 | + if(strpos($content,'[')===false && strpos($content,'{')===false) { |
|
| 1287 | + return $content; |
|
| 1288 | + } |
|
| 1076 | 1289 | |
| 1077 | - if(!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
| 1290 | + if(!$modx->maxParserPasses) { |
|
| 1291 | + $modx->maxParserPasses = 10; |
|
| 1292 | + } |
|
| 1078 | 1293 | $bt=''; |
| 1079 | 1294 | $i=0; |
| 1080 | - while($bt!==$content) |
|
| 1081 | - { |
|
| 1295 | + while($bt!==$content) { |
|
| 1082 | 1296 | $bt = $content; |
| 1083 | - if(strpos($content,'[*')!==false && $modx->documentIdentifier) |
|
| 1084 | - $content = $modx->mergeDocumentContent($content); |
|
| 1085 | - if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content); |
|
| 1086 | - if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content); |
|
| 1087 | - if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content); |
|
| 1088 | - if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content); |
|
| 1089 | - |
|
| 1090 | - if($content===$bt) break; |
|
| 1091 | - if($modx->maxParserPasses < $i) break; |
|
| 1297 | + if(strpos($content,'[*')!==false && $modx->documentIdentifier) { |
|
| 1298 | + $content = $modx->mergeDocumentContent($content); |
|
| 1299 | + } |
|
| 1300 | + if(strpos($content,'[(')!==false) { |
|
| 1301 | + $content = $modx->mergeSettingsContent($content); |
|
| 1302 | + } |
|
| 1303 | + if(strpos($content,'{{')!==false) { |
|
| 1304 | + $content = $modx->mergeChunkContent($content); |
|
| 1305 | + } |
|
| 1306 | + if(strpos($content,'[!')!==false) { |
|
| 1307 | + $content = str_replace(array('[!','!]'),array('[[',']]'),$content); |
|
| 1308 | + } |
|
| 1309 | + if(strpos($content,'[[')!==false) { |
|
| 1310 | + $content = $modx->evalSnippets($content); |
|
| 1311 | + } |
|
| 1312 | + |
|
| 1313 | + if($content===$bt) { |
|
| 1314 | + break; |
|
| 1315 | + } |
|
| 1316 | + if($modx->maxParserPasses < $i) { |
|
| 1317 | + break; |
|
| 1318 | + } |
|
| 1092 | 1319 | $i++; |
| 1093 | 1320 | } |
| 1094 | 1321 | return $content; |
@@ -1099,103 +1326,138 @@ discard block |
||
| 1099 | 1326 | global $modx; |
| 1100 | 1327 | |
| 1101 | 1328 | $target = trim($target); |
| 1102 | - if(empty($target)) $target = $modx->config['site_start']; |
|
| 1103 | - if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id'; |
|
| 1104 | - else $method = 'alias'; |
|
| 1329 | + if(empty($target)) { |
|
| 1330 | + $target = $modx->config['site_start']; |
|
| 1331 | + } |
|
| 1332 | + if(preg_match('@^[1-9][0-9]*$@',$target)) { |
|
| 1333 | + $method='id'; |
|
| 1334 | + } else { |
|
| 1335 | + $method = 'alias'; |
|
| 1336 | + } |
|
| 1105 | 1337 | |
| 1106 | - if(!isset($this->documentObject[$target])) |
|
| 1107 | - { |
|
| 1338 | + if(!isset($this->documentObject[$target])) { |
|
| 1108 | 1339 | $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct'); |
| 1109 | 1340 | } |
| 1110 | 1341 | |
| 1111 | - if($this->documentObject[$target]['publishedon']==='0') |
|
| 1112 | - return ''; |
|
| 1113 | - elseif(isset($this->documentObject[$target][$field])) |
|
| 1114 | - { |
|
| 1115 | - if(is_array($this->documentObject[$target][$field])) |
|
| 1116 | - { |
|
| 1342 | + if($this->documentObject[$target]['publishedon']==='0') { |
|
| 1343 | + return ''; |
|
| 1344 | + } elseif(isset($this->documentObject[$target][$field])) { |
|
| 1345 | + if(is_array($this->documentObject[$target][$field])) { |
|
| 1117 | 1346 | $a = $modx->getTemplateVarOutput($field,$target); |
| 1118 | 1347 | $this->documentObject[$target][$field] = $a[$field]; |
| 1119 | 1348 | } |
| 1349 | + } else { |
|
| 1350 | + $this->documentObject[$target][$field] = false; |
|
| 1120 | 1351 | } |
| 1121 | - else $this->documentObject[$target][$field] = false; |
|
| 1122 | 1352 | |
| 1123 | 1353 | return $this->documentObject[$target][$field]; |
| 1124 | 1354 | } |
| 1125 | 1355 | |
| 1126 | - public function setPlaceholders($value = '', $key = '', $path = '') { |
|
| 1127 | - if($path!=='') $key = "{$path}.{$key}"; |
|
| 1356 | + public function setPlaceholders($value = '', $key = '', $path = '') |
|
| 1357 | + { |
|
| 1358 | + if($path!=='') { |
|
| 1359 | + $key = "{$path}.{$key}"; |
|
| 1360 | + } |
|
| 1128 | 1361 | if (is_array($value)) { |
| 1129 | 1362 | foreach ($value as $subkey => $subval) { |
| 1130 | 1363 | $this->setPlaceholders($subval, $subkey, $key); |
| 1131 | 1364 | } |
| 1365 | + } else { |
|
| 1366 | + $this->setModifiersVariable($key, $value); |
|
| 1132 | 1367 | } |
| 1133 | - else $this->setModifiersVariable($key, $value); |
|
| 1134 | 1368 | } |
| 1135 | 1369 | |
| 1136 | 1370 | // Sets a placeholder variable which can only be access by Modifiers |
| 1137 | - public function setModifiersVariable($key, $value) { |
|
| 1138 | - if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value; |
|
| 1371 | + public function setModifiersVariable($key, $value) |
|
| 1372 | + { |
|
| 1373 | + if ($key != 'phx' && $key != 'dummy') { |
|
| 1374 | + $this->placeholders[$key] = $value; |
|
| 1375 | + } |
|
| 1139 | 1376 | } |
| 1140 | 1377 | |
| 1141 | 1378 | //mbstring |
| 1142 | - public function substr($str, $s, $l = null) { |
|
| 1379 | + public function substr($str, $s, $l = null) |
|
| 1380 | + { |
|
| 1143 | 1381 | global $modx; |
| 1144 | - if(is_null($l)) $l = $this->strlen($str); |
|
| 1145 | - if (function_exists('mb_substr')) |
|
| 1146 | - { |
|
| 1147 | - if(strpos($str,"\r")!==false) |
|
| 1148 | - $str = str_replace(array("\r\n","\r"), "\n", $str); |
|
| 1382 | + if(is_null($l)) { |
|
| 1383 | + $l = $this->strlen($str); |
|
| 1384 | + } |
|
| 1385 | + if (function_exists('mb_substr')) { |
|
| 1386 | + if(strpos($str,"\r")!==false) { |
|
| 1387 | + $str = str_replace(array("\r\n","\r"), "\n", $str); |
|
| 1388 | + } |
|
| 1149 | 1389 | return mb_substr($str, $s, $l, $modx->config['modx_charset']); |
| 1150 | 1390 | } |
| 1151 | 1391 | return substr($str, $s, $l); |
| 1152 | 1392 | } |
| 1153 | - public function strpos($haystack,$needle,$offset=0) { |
|
| 1393 | + public function strpos($haystack,$needle,$offset=0) |
|
| 1394 | + { |
|
| 1154 | 1395 | global $modx; |
| 1155 | - if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); |
|
| 1396 | + if (function_exists('mb_strpos')) { |
|
| 1397 | + return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); |
|
| 1398 | + } |
|
| 1156 | 1399 | return strpos($haystack,$needle,$offset); |
| 1157 | 1400 | } |
| 1158 | - public function strlen($str) { |
|
| 1401 | + public function strlen($str) |
|
| 1402 | + { |
|
| 1159 | 1403 | global $modx; |
| 1160 | - if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); |
|
| 1404 | + if (function_exists('mb_strlen')) { |
|
| 1405 | + return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); |
|
| 1406 | + } |
|
| 1161 | 1407 | return strlen($str); |
| 1162 | 1408 | } |
| 1163 | - public function strtolower($str) { |
|
| 1164 | - if (function_exists('mb_strtolower')) return mb_strtolower($str); |
|
| 1409 | + public function strtolower($str) |
|
| 1410 | + { |
|
| 1411 | + if (function_exists('mb_strtolower')) { |
|
| 1412 | + return mb_strtolower($str); |
|
| 1413 | + } |
|
| 1165 | 1414 | return strtolower($str); |
| 1166 | 1415 | } |
| 1167 | - public function strtoupper($str) { |
|
| 1168 | - if (function_exists('mb_strtoupper')) return mb_strtoupper($str); |
|
| 1416 | + public function strtoupper($str) |
|
| 1417 | + { |
|
| 1418 | + if (function_exists('mb_strtoupper')) { |
|
| 1419 | + return mb_strtoupper($str); |
|
| 1420 | + } |
|
| 1169 | 1421 | return strtoupper($str); |
| 1170 | 1422 | } |
| 1171 | - public function ucfirst($str) { |
|
| 1172 | - if (function_exists('mb_strtoupper')) |
|
| 1173 | - return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
|
| 1423 | + public function ucfirst($str) |
|
| 1424 | + { |
|
| 1425 | + if (function_exists('mb_strtoupper')) { |
|
| 1426 | + return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
|
| 1427 | + } |
|
| 1174 | 1428 | return ucfirst($str); |
| 1175 | 1429 | } |
| 1176 | - public function lcfirst($str) { |
|
| 1177 | - if (function_exists('mb_strtolower')) |
|
| 1178 | - return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
|
| 1430 | + public function lcfirst($str) |
|
| 1431 | + { |
|
| 1432 | + if (function_exists('mb_strtolower')) { |
|
| 1433 | + return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
|
| 1434 | + } |
|
| 1179 | 1435 | return lcfirst($str); |
| 1180 | 1436 | } |
| 1181 | - public function ucwords($str) { |
|
| 1182 | - if (function_exists('mb_convert_case')) |
|
| 1183 | - return mb_convert_case($str, MB_CASE_TITLE); |
|
| 1437 | + public function ucwords($str) |
|
| 1438 | + { |
|
| 1439 | + if (function_exists('mb_convert_case')) { |
|
| 1440 | + return mb_convert_case($str, MB_CASE_TITLE); |
|
| 1441 | + } |
|
| 1184 | 1442 | return ucwords($str); |
| 1185 | 1443 | } |
| 1186 | - public function strrev($str) { |
|
| 1444 | + public function strrev($str) |
|
| 1445 | + { |
|
| 1187 | 1446 | preg_match_all('/./us', $str, $ar); |
| 1188 | 1447 | return implode(array_reverse($ar[0])); |
| 1189 | 1448 | } |
| 1190 | - public function str_shuffle($str) { |
|
| 1449 | + public function str_shuffle($str) |
|
| 1450 | + { |
|
| 1191 | 1451 | preg_match_all('/./us', $str, $ar); |
| 1192 | 1452 | shuffle($ar[0]); |
| 1193 | 1453 | return implode($ar[0]); |
| 1194 | 1454 | } |
| 1195 | - public function str_word_count($str) { |
|
| 1455 | + public function str_word_count($str) |
|
| 1456 | + { |
|
| 1196 | 1457 | return count(preg_split('~[^\p{L}\p{N}\']+~u',$str)); |
| 1197 | 1458 | } |
| 1198 | - public function strip_tags($value,$params='') { |
|
| 1459 | + public function strip_tags($value,$params='') |
|
| 1460 | + { |
|
| 1199 | 1461 | global $modx; |
| 1200 | 1462 | |
| 1201 | 1463 | if(stripos($params,'style')===false && stripos($value,'</style>')!==false) { |
@@ -149,7 +149,7 @@ |
||
| 149 | 149 | /** |
| 150 | 150 | * This function returns the current page number. |
| 151 | 151 | * |
| 152 | - * @return int |
|
| 152 | + * @return string |
|
| 153 | 153 | */ |
| 154 | 154 | public function getCurrentPage() |
| 155 | 155 | { |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | $array_paging['total'] = $this->int_nbr_row; |
| 102 | 102 | |
| 103 | 103 | if ($this->int_cur_position != 0) { |
| 104 | - $array_paging['first_link'] = "<a href=\"$PHP_SELF?int_cur_position=0" . $this->str_ext_argv . "\">"; |
|
| 105 | - $array_paging['previous_link'] = "<a href=\"$PHP_SELF?int_cur_position=" . ($this->int_cur_position - $this->int_num_result) . $this->str_ext_argv . "\">"; |
|
| 104 | + $array_paging['first_link'] = "<a href=\"$PHP_SELF?int_cur_position=0".$this->str_ext_argv."\">"; |
|
| 105 | + $array_paging['previous_link'] = "<a href=\"$PHP_SELF?int_cur_position=".($this->int_cur_position - $this->int_num_result).$this->str_ext_argv."\">"; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | if (($this->int_nbr_row - $this->int_cur_position) > $this->int_num_result) { |
| 109 | 109 | $int_new_position = $this->int_cur_position + $this->int_num_result; |
| 110 | - $array_paging['last_link'] = "<a href=\"$PHP_SELF?int_cur_position=" . $this->int_nbr_row . $this->str_ext_argv . "\">"; |
|
| 111 | - $array_paging['next_link'] = "<a href=\"$PHP_SELF?int_cur_position=$int_new_position" . $this->str_ext_argv . "\">"; |
|
| 110 | + $array_paging['last_link'] = "<a href=\"$PHP_SELF?int_cur_position=".$this->int_nbr_row.$this->str_ext_argv."\">"; |
|
| 111 | + $array_paging['next_link'] = "<a href=\"$PHP_SELF?int_cur_position=$int_new_position".$this->str_ext_argv."\">"; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | return $array_paging; |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | for ($i = 0; $i < $this->getNumberOfPage(); $i++) { |
| 127 | 127 | // if current page, do not make a link |
| 128 | 128 | if ($i == $this->getCurrentPage()) { |
| 129 | - $array_all_page[$i] = "<b>" . ($i + 1) . "</b> "; |
|
| 129 | + $array_all_page[$i] = "<b>".($i + 1)."</b> "; |
|
| 130 | 130 | } else { |
| 131 | 131 | $int_new_position = ($i * $this->int_num_result); |
| 132 | - $array_all_page[$i] = "<a href=\"" . $PHP_SELF . "?int_cur_position=$int_new_position$this->str_ext_argv\">" . ($i + 1) . "</a> "; |
|
| 132 | + $array_all_page[$i] = "<a href=\"".$PHP_SELF."?int_cur_position=$int_new_position$this->str_ext_argv\">".($i + 1)."</a> "; |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | // sanitize array |
| 17 | 17 | if (!function_exists('modx_sanitize_gpc')) { |
| 18 | 18 | /** |
| 19 | - * @param array|string $values |
|
| 19 | + * @param string $values |
|
| 20 | 20 | * @param int $depth |
| 21 | 21 | * @return array|string |
| 22 | 22 | */ |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | global $sanitize_seed; |
| 14 | -$sanitize_seed = 'sanitize_seed_' . base_convert(md5(__FILE__), 16, 36); |
|
| 14 | +$sanitize_seed = 'sanitize_seed_'.base_convert(md5(__FILE__), 16, 36); |
|
| 15 | 15 | |
| 16 | 16 | // sanitize array |
| 17 | 17 | if (!function_exists('modx_sanitize_gpc')) { |