コード例 #1
0
// ==================================================
// ! save page
// ==================================================
if (CAT_Helper_Page::updatePage($page_id, $options) === false) {
    $ajax = array('message' => 'Database error: ' . $backend->db()->getError(), 'success' => false);
    print json_encode($ajax);
    exit;
}
// Clean old order if needed
if ($options['parent'] != $old_parent) {
    $order->clean($old_parent);
}
// additional settings
$template_variant = $val->sanitizePost('template_variant', NULL, true);
if ($template_variant) {
    CAT_Helper_Page::updatePageSettings($page_id, array('template_variant' => $template_variant));
}
//=====================
// ! Move (rename) page
//=====================
if ($options['link'] !== $old_link) {
    // if a directory exists, rename it; if this fails, we need to recover
    // the changes!
    if (is_dir(CAT_PATH . PAGES_DIRECTORY . $old_link)) {
        if (!CAT_Helper_Directory::moveDirectory(CAT_PATH . PAGES_DIRECTORY . $old_link, CAT_PATH . PAGES_DIRECTORY . $options['link'], true)) {
            CAT_Helper_Page::updatePage($page_id, $page);
            $ajax = array('message' => 'Unable to move the directory', 'success' => false);
            print json_encode($ajax);
            exit;
        }
    }