Don't compound doNext in file control tasks

This commit is contained in:
mattpass
2020-06-13 10:30:02 +01:00
parent 4cc2070eb9
commit 69bb3f2905
2 changed files with 23 additions and 18 deletions

View File

@@ -81,9 +81,10 @@ class File
}
}
public function updateUI($doNext) {
public function updateUI() {
global $fileLoc, $fileName;
$doNext = "";
// Reload file manager, rename tab & remove old file highlighting if it was a new file
if (isset($_POST['newFileName']) && "" != $_POST['newFileName']) {
$doNext .= 'ICEcoder.selectedFiles=[]; ICEcoder.updateFileManagerList(\'add\', \'' . $fileLoc . '\', \'' . $fileName . '\', false, false, false, \'file\');';
@@ -267,7 +268,7 @@ class File
return $script;
}
public function handleSaveLooparound($fileDetails, $finalAction, $doNext, $t) {
public function handleSaveLooparound($fileDetails, $finalAction, $t) {
global $newFileAutoSave;
$docRoot = $fileDetails['docRoot'];
@@ -278,7 +279,7 @@ class File
$fileVersionURLPart = $fileDetails['fileVersionURLPart'];
$ftpSite = $fileDetails['ftpSite'];
$doNext .= '
$doNext = '
ICEcoder.serverMessage();
fileLoc = "' . $fileLoc . '";
overwriteOK = false;
@@ -595,11 +596,11 @@ class File
return $uploads;
}
public function handleMarkdown($doNext) {
public function handleMarkdown() {
// Reload previewWindow window if not a Markdown file
// In doing this, we check on an interval for the page to be complete and if we last saw it loading
// When we are done loading, so set the loading status to false and load plugins on..
$doNext .= 'if (ICEcoder.previewWindow.location && ICEcoder.previewWindow.location.pathname && -1 === ICEcoder.previewWindow.location.pathname.indexOf(".md")) {
$doNext = 'if (ICEcoder.previewWindow.location && ICEcoder.previewWindow.location.pathname && -1 === ICEcoder.previewWindow.location.pathname.indexOf(".md")) {
ICEcoder.previewWindowLoading = false;
ICEcoder.previewWindow.location.reload(true);
@@ -620,9 +621,9 @@ class File
return $doNext;
}
public function handleDiffPane($doNext) {
public function handleDiffPane() {
// Copy over content to diff pane if we have that setting on
$doNext .= '
$doNext = '
cM = ICEcoder.getcMInstance();
cMdiff = ICEcoder.getcMdiffInstance();
if (ICEcoder.updateDiffOnSave) {
@@ -633,9 +634,9 @@ class File
return $doNext;
}
public function finaliseSave($doNext) {
public function finaliseSave() {
// Finally, set previous files, indicate changes, set saved points and redo tabs
$doNext .= '
$doNext = '
ICEcoder.setPreviousFiles();
setTimeout(function(){ICEcoder.indicateChanges()}, 4);
ICEcoder.savedPoints[ICEcoder.selectedTab-1] = cM.changeGeneration();
@@ -645,9 +646,11 @@ class File
return $doNext;
}
public function compileSass($doNext) {
public function compileSass() {
global $docRoot, $fileLoc, $fileName;
$doNext = "";
// Compiling Sass files (.scss to .css, with same name, in same dir)
$filePieces = explode(".", $fileName);
$fileExt = $filePieces[count($filePieces) - 1];
@@ -675,9 +678,11 @@ class File
return $doNext;
}
public function compileLess($doNext) {
public function compileLess() {
global $docRoot, $fileLoc, $fileName;
$doNext = "";
// Compiling LESS files (.less to .css, with same name, in same dir)
$filePieces = explode(".", $fileName);
$fileExt = $filePieces[count($filePieces) - 1];

View File

@@ -116,7 +116,7 @@ if (!$error && "save" === $_GET['action']) {
"fileVersionURLPart" => $fileVersionURLPart,
"ftpSite" => true === isset($ftpSite)
];
$doNext .= $fileClass->handleSaveLooparound($fileDetails, $finalAction, $doNext, $t);
$doNext .= $fileClass->handleSaveLooparound($fileDetails, $finalAction, $t);
// ===================
// FILE CONTENT SAVING
@@ -152,12 +152,12 @@ if (!$error && "save" === $_GET['action']) {
$backupClass->makeBackup($fileLoc, $fileName, $contents);
}
$doNext .= $fileClass->updateUI($doNext);
$doNext .= $fileClass->handleMarkdown($doNext);
$doNext .= $fileClass->handleDiffPane($doNext);
$doNext .= $fileClass->finaliseSave($doNext);
$doNext .= $fileClass->compileSass($doNext);
$doNext .= $fileClass->compileLess($doNext);
$doNext .= $fileClass->updateUI();
$doNext .= $fileClass->handleMarkdown();
$doNext .= $fileClass->handleDiffPane();
$doNext .= $fileClass->finaliseSave();
$doNext .= $fileClass->compileSass();
$doNext .= $fileClass->compileLess();
// Run any extra processes
$extraProcesses = new ExtraProcesses($fileLoc, $fileName);