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 if ($mode == "page") { $fileContent = correctGeneralInclude(stripslashes($fileContent), $previewFile); $fileContent = unSimplifyContents($fileContent, $previewFile);
function getChildIncludes($liveFile) { global $xmlr; $localRootDir = getLCIRootFolderFromPagePath($liveFile); $localPreviewDir = $localRootDir . '/cms_preview'; $localLiveDir = $localRootDir . '/cms_live'; if (!is_dir($localPreviewDir) || !is_dir($localLiveDir)) { return false; } $localPreviewDirHandle = opendir($localPreviewDir); while (False !== ($lciFile = readdir($localPreviewDirHandle))) { if ($lciFile != '.' & $lciFile != '..' && !is_dir($localPreviewDir . '/' . $lciFile)) { $xmlr .= '<lci>'; $xmlr .= '<type>' . getFileExtension($lciFile) . '</type>'; $xmlr .= '<filename>' . $lciFile . '</filename>'; $xmlr .= '<filestatus>' . matchFiles($localPreviewDir . '/' . $lciFile, getLiveLCIFromPreview($localPreviewDir . '/' . $lciFile)) . '</filestatus>'; $xmlr .= '</lci>'; } } closedir($localPreviewDirHandle); }
$newArray = array(); $newArray[0] = $_POST['template']; $newArray[1] = $newArray[0]; $newArray[2] = $templateArray['cols']; // If it's going to belong to a PT, there's only one copy! if (isset($_POST['parentpage'])) { if (isPageTemplate(pathFromID($_POST['parentpage']))) { // strip the .php and append a / $newPreviewFilePath = stripFileExtension(pathFromID($_POST['parentpage'])) . '/' . $_POST['newfilepath'] . '.set'; $newLiveFilePath = False; $successReturnValue = $newPreviewFilePath; } else { $includesRoot = getLCIRootFolderFromPagePath(pathFromID($_POST['parentpage'])); makeSureFoldersExist($includesRoot); $newPreviewFilePath = $includesRoot . '/cms_preview/' . $_POST['newfilepath'] . '.set'; $newLiveFilePath = getLiveLCIFromPreview($newPreviewFilePath); $successReturnValue = $_POST['parentpage'] . '/' . $_POST['newfilepath'] . '.set'; // Note: Simpler line below works in new text... // $returnFile = $_GET['parentpage'] . '/' . $fileName ; } } else { // FREE INCLUDE: there are also 2 copies (i.e. parentpage not set) $newLiveFilePath = $newFilePath; // echo "debug:$newLiveFilePath" ; exit ; $newPreviewFilePath = getPreviewFileFromLive($newFilePath); $successReturnValue = $newLiveFilePath; } if (False !== $newPreviewFilePath && is_file($newPreviewFilePath)) { print 'error: ' . $newPreviewFilePath . " is a file."; exit; }
} else { /* CHILD INCLUDES (1 or more) Expects: - $_GET['action'] as "publish" or "restore" - $_GET['file'] = relative path to 1 or more PREVIEW INCLUDE file(s) (i.e. includes/path/blah.ext) */ if (!isset($_GET['action'])) { print 'error: No action'; exit; } elseif (!isset($_GET['file'])) { print 'error: No file set'; exit; } $previewFile = pathFromID($_GET['file']); $liveFile = getLiveLCIFromPreview($previewFile); if ($_GET['action'] == 'publish' && file_exists($previewFile)) { // PUBLISH if (False === @copy($previewFile, $liveFile)) { print 'error: Publishing failed - ' . $previewFile . ' -> ' . $liveFile; exit; } } else { // RESTORE if (False === @copy($liveFile, $previewFile)) { print 'error: Restoring failed - ' . $liveFile . ' -> ' . $previewFile; exit; } } // SUCCESS print $_GET['file'];
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); @file_put_contents($parentPagePath, $newParentPageSource); // Success echo 'regular'; exit; } else { if (is_dir($filePath)) { // DIRECTORY --- rename it and its partner in Includes $newDirPath = dirname($filePath) . '/' . $newFileName; if (False === @rename($filePath, $newDirPath)) {