If a free include, save to pv location, and save live copy if not present or empty If a Page Template, simply save to PTs folder */ switch ($mode) { case "ptchildinclude": // ???????????????? $previewFile = pathFromID($_POST['sourcefile']); $liveFile = False; break; case "pagetemplate": // ???????????????? $previewFile = pathFromID($_POST['sourcefile']); $liveFile = False; break; default: if (isLCI(pathFromID($_POST['sourcefile']))) { // We have an LCI $previewFile = pathFromID($_POST['sourcefile']); $liveFile = getLiveLCIFromPreview(pathFromID($previewFile)); } else { $liveFile = pathFromID($_POST['sourcefile']); $previewFile = getPreviewFileFromLive($liveFile); } break; } /* DEBUGGING echo $previewFile, "\n\n", $liveFile ; exit ; */ // Correct path to include for general, for Pages only
exit; } if (False === @rename(getPreviewFileFromLive($filePath), getPreviewFileFromLive($newFilePath))) { echo 'error:Failed to rename includes version of page: ' . getPreviewFileFromLive($filePath) . ' >>> ' . getPreviewFileFromLive($newFilePath); exit; } $lciRoot = getLCIRootFolderFromPagePath($filePath); $newLciRoot = getLCIRootFolderFromPagePath($newFilePath); if (False === @rename($lciRoot, $newLciRoot)) { echo 'error:Failed to rename page LCI folder: ' . $lciRoot . ' >>> ' . $newLciRoot; exit; } echo 'regular'; exit; } else { if (isLCI($filePath)) { // CHILD INCLUDE --- rename it and its sibling // e.g. includes/page_cms_files/cms_preview/lci.ext $newFilePath = $dir . '/' . $newFileName . '.' . $ext; if (False === @rename($filePath, $newFilePath)) { echo 'error:Failed to rename preview include: ' . $filePath; exit; } if (False === @rename(getLiveLCIFromPreview($filePath), getLiveLCIFromPreview($newFilePath))) { echo 'error:Failed to rename live include: ' . getLiveLCIFromPreview($filePath) . ' >>> ' . getLiveLCIFromPreview($newFilePath); exit; } /* ALSO TRY TO RENAME ANY REFERENCES TO THE LCI IN THE PARENT PAGE */ $parentPagePath = getParentPageFromLCI($filePath); $parentPageSource = file_get_contents($parentPagePath); $newParentPageSource = str_replace(basename($filePath), $newFileName . '.' . $ext, $parentPageSource);