mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-03 07:13:59 +01:00
lineEnding setting added
Now replacing \r\n, \r and \n with whatever we chose to be the lineEnding setting lineEnding is \n by default
This commit is contained in:
@@ -54,9 +54,10 @@ if ($_GET['action']=="load") {
|
||||
// Get the contents of a remote URL
|
||||
if ($_GET['action']=="getRemoteFile") {
|
||||
if ($remoteFile = file_get_contents($file)) {
|
||||
// replace \r\n (Windows) and \r (old Mac) line endings with \n (Linux)
|
||||
$remoteFile = str_replace("\r\n", "\n", $remoteFile);
|
||||
$remoteFile = str_replace("\r", "\n", $remoteFile);
|
||||
// replace \r\n (Windows), \r (old Mac) and \n (Linux) line endings with whatever we chose to be lineEnding
|
||||
$remoteFile = str_replace("\r\n", $ICEcoder["lineEnding"], $remoteFile);
|
||||
$remoteFile = str_replace("\r", $ICEcoder["lineEnding"], $remoteFile);
|
||||
$remoteFile = str_replace("\n", $ICEcoder["lineEnding"], $remoteFile);
|
||||
echo '<script>top.ICEcoder.newTab();</script>';
|
||||
echo '<textarea name="remoteFile" id="remoteFile">'.str_replace("</textarea>","<ICEcoder:/:textarea>",str_replace("&","&",$remoteFile)).'</textarea>';
|
||||
echo '<script>top.ICEcoder.getcMInstance().setValue(document.getElementById("remoteFile").value);action="getRemoteFile";</script>';
|
||||
@@ -270,10 +271,11 @@ if ($_GET['action']=="save") {
|
||||
$filemtime = $serverType=="Linux" ? filemtime($file) : "1000000";
|
||||
if (!(isset($_GET['fileMDT']))||$filemtime==$_GET['fileMDT']) {
|
||||
$fh = fopen($file, 'w') or die("Sorry, cannot save");
|
||||
// replace \r\n (Windows) and \r (old Mac) line endings with \n (Linux)
|
||||
// replace \r\n (Windows), \r (old Mac) and \n (Linux) line endings with whatever we chose to be lineEnding
|
||||
$contents = $_POST['contents'];
|
||||
$contents = str_replace("\r\n", "\n", $contents);
|
||||
$contents = str_replace("\r", "\n", $contents);
|
||||
$contents = str_replace("\r\n", $ICEcoder["lineEnding"], $contents);
|
||||
$contents = str_replace("\r", $ICEcoder["lineEnding"], $contents);
|
||||
$contents = str_replace("\n", $ICEcoder["lineEnding"], $contents);
|
||||
// Now write that content, close the file and clear the statcache
|
||||
fwrite($fh, $contents);
|
||||
fclose($fh);
|
||||
|
||||
@@ -66,7 +66,8 @@ $ICEcoder = array(
|
||||
"versionNo" => "2.4",
|
||||
"codeMirrorDir" => "CodeMirror-3.12",
|
||||
"demoMode" => false,
|
||||
"devMode" => false
|
||||
"devMode" => false,
|
||||
"lineEnding" => "\n"
|
||||
)+$ICEcoder;
|
||||
|
||||
$onLoadExtras = "";
|
||||
|
||||
Reference in New Issue
Block a user