コード例 #1
0
                $new_sub_level = count(explode('/', $new_sub_link)) - 2;
                $root_parent = $options['root_parent'] == '0' ? $page_id : $options['root_parent'];
                // Update link and level
                $database->query(sprintf("UPDATE `%spages` SET link='%s', level='%s', root_parent='%s' WHERE page_id='%s' LIMIT 1", CAT_TABLE_PREFIX, $new_sub_link, $new_sub_level, $root_parent, $sub['page_id']));
                // we use reset() to reload the page tree
                CAT_Helper_Page::reset();
                // update trail
                $database->query(sprintf("UPDATE `%spages` SET page_trail='%s' WHERE page_id='%s' LIMIT 1", CAT_TABLE_PREFIX, CAT_Helper_Page::getPageTrail($sub['page_id']), $sub['page_id']));
                // Re-write the access file for this page
                $old_subpage_file = CAT_PATH . PAGES_DIRECTORY . $new_sub_link . PAGE_EXTENSION;
                // remove old file
                if (file_exists($old_subpage_file)) {
                    unlink($old_subpage_file);
                }
                // create new
                CAT_Helper_Page::createAccessFile($new_sub_link, $sub['page_id']);
            }
        }
    }
    // check if source directory is empty now
    $source_dir = pathinfo(CAT_PATH . PAGES_DIRECTORY . $old_link, PATHINFO_DIRNAME);
    if (CAT_Helper_Directory::is_empty($source_dir, true)) {
        CAT_Helper_Directory::removeDirectory($source_dir);
    }
}
// ==============================
// ! Check if there is a db error
// ==============================
if (CAT_Helper_Page::getInstance()->db()->isError()) {
    $ajax = array('message' => CAT_Helper_Page::getInstance()->db()->getError(), 'success' => false);
    print json_encode($ajax);
コード例 #2
0
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
$backend = CAT_Backend::getInstance('Pages', 'pages', false);
$users = CAT_Users::getInstance();
$val = CAT_Helper_Validate::getInstance();
header('Content-type: application/json');
if (!$users->checkPermission('Pages', 'pages')) {
    $ajax = array('message' => $backend->lang()->translate('You do not have the permission to proceed this action'), 'success' => false);
    print json_encode($ajax);
    exit;
}
$page_id = $val->sanitizePost('page_id', 'numeric');
// Get page id
if (!$page_id) {
    $ajax = array('message' => $backend->lang()->translate('You sent an invalid value'), 'success' => false);
    print json_encode($ajax);
    exit;
}
// load page settings
$page = CAT_Helper_Page::getPage($page_id);
// get file name
$filename = CAT_PATH . PAGES_DIRECTORY . $page['link'] . PAGE_EXTENSION;
// create access file
if (CAT_Helper_Page::createAccessFile($filename, $page_id)) {
    $ajax = array('message' => $backend->lang()->translate('Access file created successfully'), 'success' => true);
} else {
    $ajax = array('message' => $backend->lang()->translate('Unable to re-create the access file!'), 'success' => false);
}
print json_encode($ajax);
exit;
コード例 #3
0
ファイル: ajax_add_page.php プロジェクト: ircoco/BlackCatCMS
// 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);
    print json_encode($ajax);
    exit;
}
$module = $val->sanitizePost('type');
// ==========================================
// ! Add new record into the sections table
// ==========================================
$backend->db()->query(sprintf("INSERT INTO `%ssections` (page_id,position,module,block) VALUES ('%d','1', '%s','1')", CAT_TABLE_PREFIX, $page_id, $module));
// ======================
// ! Get the section id
// ======================