示例#1
0
文件: page.php 项目: ssrsfs/blg
// get revision id, if any
$revisionid = @$_REQUEST['revisionid'];
// process form
if ('POST' == $_SERVER['REQUEST_METHOD']) {
    if (!empty($_POST['cmd']) && $_POST['cmd'] == 'Preview') {
        Typeframe_Skin::Set(Typeframe_Skin::At(TYPEF_WEB_DIR . $page['uri']));
        Typeframe::CurrentPage()->setPageTemplate('/content/' . $page['settings']['template']);
        return;
    }
    // build content array from post
    $content = Content::ProcessPost($inserts, $groups);
    // add/edit content
    //$content_page = new Content_Page($pageid, $revisionid);
    $content_page = Model_Content_Page::Get($pageid);
    if (!$content_page->exists()) {
        $content_page = Model_Content_Page::Create();
        $content_page['pageid'] = $pageid;
    }
    $content_page['content'] = $content;
    //$content_page->set('content', json_encode($content));
    $content_page->save();
    // done; redirect
    Typeframe::Redirect('Page content updated.', $typef_app_dir);
    return;
}
$page = Model_Content_Page::Get($pageid);
if ($revisionid) {
    $pm->setVariable('revisionid', $revisionid);
    $revision = Model_Content_PageRevision::Get($revisionid);
    $page['content'] = $revision['data']['content'];
}