Ejemplo n.º 1
0
    $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;
        }
    }
    // delete old file
    $old_filename = CAT_Helper_Directory::sanitizePath(CAT_PATH . PAGES_DIRECTORY . $old_link . PAGE_EXTENSION);
    if (file_exists($old_filename)) {
        unlink($old_filename);
    }
    // create new access file
    $result = CAT_Helper_Page::createAccessFile($options['link'], $page_id, $options['level']);
    // Update child pages
    $old_link_len = strlen($old_link);
    $query_subs = $database->query(sprintf("SELECT `page_id`, `parent`, `link`, `level` FROM `%spages` WHERE `page_trail` LIKE '%s,%%' ORDER BY LEVEL ASC", CAT_TABLE_PREFIX, $options['page_trail']));
Ejemplo n.º 2
0
// Get new order
$options['position'] = $order->get_new($options['parent']);
// ================================
// ! Insert page into pages table
// ================================
$page_id = CAT_Helper_Page::addPage($options);
if (!$page_id) {
    $ajax = array('message' => $backend->lang()->translate('Unable to create the page: ') . $backend->db()->getError(), 'success' => false);
    print json_encode($ajax);
    exit;
}
// Work out root parent
$root_parent = CAT_Helper_Page::getRootParent($page_id);
// Work out page trail
$page_trail = CAT_Helper_Page::getPageTrail($page_id);
$result = CAT_Helper_Page::updatePage($page_id, array('root_parent' => $root_parent, 'page_trail' => $page_trail));
if (!$result) {
    // try to recover = delete page
    CAT_Helper_Page::deletePage($page_id);
    $ajax = array('message' => $backend->db()->getError(), 'success' => false);
    print json_encode($ajax);
    exit;
}
// ====================
// ! Create access file
// ====================
$result = CAT_Helper_Page::createAccessFile($options['link'], $page_id, $options['level']);
if (!$result) {
    // try to recover = delete page
    CAT_Helper_Page::deletePage($page_id);
    $ajax = array('message' => $backend->lang()->translate('Error creating access file in the pages directory, cannot open file'), 'success' => false);