コード例 #1
0
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);
}
コード例 #2
0
    $ptContents = @file_get_contents(PTSDIR . '/' . pathFromID($pt));
    if (False === $ptContents) {
        echo 'error: Could not find PT ' . pathFromID($pt);
        exit;
    }
} else {
    $ptContents = '';
    $pt = False;
}
// Check page doesn't already exist
if (is_file($newLivePagePath)) {
    print 'error: Page already exists: ' . $newLivePagePath;
    exit;
}
// Create local page-includes folders
$includesDirectoryRoot = getLCIRootFolderFromPagePath($newLivePagePath);
$previewIncludesDirectory = $includesDirectoryRoot . '/cms_preview/';
$liveIncludesDirectory = $includesDirectoryRoot . '/cms_live/';
if (!is_dir($includesDirectoryRoot)) {
    if (mkdir($includesDirectoryRoot, 0755) === False) {
        print 'error:Couldn\'t create Root Includes folder: ' . $includesDirectoryRoot;
        exit;
    } else {
        chmod($includesDirectoryRoot, 0755);
    }
}
if (!is_dir($previewIncludesDirectory)) {
    if (mkdir($previewIncludesDirectory, 0755) === False) {
        print 'error:Couldn\'t create Preview Includes folder: ' . $previewIncludesDirectory;
        exit;
    } else {
コード例 #3
0
define("DIR", dirname($_POST['newfilepath']));
// Read in template
$templateArray = @unserialize(file_get_contents(STDIR . $_POST['template']));
$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)) {
コード例 #4
0
    exit;
} else {
    $fileContents = simplifyContents($fileContents);
}
// Fixing relative path
// Force $pathToRoot = '' ;
//$fileContents = ereg_replace('\$pathToRoot=\'[./]*\';', '$pathToRoot=\'\';', $fileContents) ;
$newPTFilePath = PTSDIR . '/' . $newPTName . PTEXTENSION;
$newPTHandle = fopen($newPTFilePath, 'w');
if (False === fwrite($newPTHandle, 'blah blah blah' . $fileContents . 'end end end')) {
    fclose($newPTHandle);
    print 'error:Could not save new PT file: ' . $newPTFilePath;
    exit;
}
fclose($newPTHandle);
chmod($newPTFilePath, 0644);
// Copy preview LCIs folder to pagetemplates/newptname/
$pageLCIs = getLCIRootFolderFromPagePath($pagePath) . '/cms_preview/';
$newPTLCIs = PTSDIR . '/' . stripFileExtension(baseName($newPTName));
$newPTLCIsFolder = mkdir($newPTLCIs, 0755);
chmod($newPTLCIs, 0755);
$handle = opendir($pageLCIs);
while (False !== ($file = readdir($handle))) {
    if ($file == '..' || $file == '.') {
        continue;
    }
    copy($pageLCIs . '/' . $file, $newPTLCIs . '/' . $file);
}
// If success, return the name of the new PT!
echo $newPTName;
exit;
コード例 #5
0
    echo 'pt';
    exit;
} else {
    if ($ext == 'php') {
        // PAGE --- rename the page and its LCI folder, and its partner in Includes
        $newFilePath = $dir . '/' . $newFileName . '.' . $ext;
        if (False === @rename($filePath, $newFilePath)) {
            echo 'error:Failed to rename page: ' . $filePath . ' >>> ' . $newFilePath;
            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;
            }