예제 #1
0
$filter = 'all';
if (isset($_GET['category']) && $_GET['category'] != '') {
    $filter = 'category';
    $category = $_GET['category'];
}
if (isset($_GET['section']) && $_GET['section'] != '') {
    $filter = 'section';
    $section = $_GET['section'];
}
if (isset($_GET['status']) && $_GET['status'] != '') {
    $filter = 'status';
    $status = $_GET['status'];
}
switch ($filter) {
    case 'category':
        $posts = $Blog->get_by_category_slug_for_admin_listing($category, $Paging);
        break;
    case 'section':
        $posts = $Blog->get_by_section_slug_for_admin_listing($section, $Paging);
        break;
    case 'status':
        $posts = $Blog->get_by_status($status, false, $Paging);
        break;
    default:
        $posts = $Blog->all($Paging);
        // Install
        if ($posts == false) {
            $Blog->attempt_install();
        }
        break;
}
        $cats = $db->get_rows('SELECT * FROM ' . PERCH_DB_PREFIX . 'blog_categories');
        if (PerchUtil::count($cats)) {
            foreach ($cats as $cat) {
                $dynfields = '[]';
                if ($cat['categoryDynamicFields']) {
                    $dynfields = $cat['categoryDynamicFields'];
                }
                $NewCat = $Core_Categories->create(array('setID' => $Set->id(), 'catParentID' => 0, 'catTitle' => $cat['categoryTitle'], 'catSlug' => $cat['categorySlug'], 'catPath' => '/blog/' . $cat['categorySlug'] . '/', 'catDynamicFields' => $dynfields));
                if (is_object($NewCat)) {
                    $db->update(PERCH_DB_PREFIX . 'blog_categories', array('categoryCoreID' => $NewCat->id()), 'categoryID', $cat['categoryID']);
                }
            }
        }
    }
}
$Posts = new PerchBlog_Posts($API);
$posts = $Posts->all($Paging);
if (PerchUtil::count($posts)) {
    foreach ($posts as $Post) {
        $Post->import_legacy_categories();
        $Post->index();
    }
}
if ($Paging->is_last_page()) {
    $Sections = new PerchBlog_Sections($API);
    $Sections->update_post_counts();
    $Posts->update_category_counts();
    $Authors = new PerchBlog_Authors($API);
    $Authors->update_post_counts();
    $Settings->set('perch_blog_update', '5.0');
}