<?php

if (!PERCH_RUNWAY) {
    exit;
}
$Blogs = new PerchBlog_Blogs($API);
$CategorySets = new PerchCategories_Sets($API);
$category_sets = $CategorySets->all();
$HTML = $API->get('HTML');
$Form = $API->get('Form');
$message = false;
if (!$CurrentUser->has_priv('perch_blog.blogs.manage')) {
    PerchUtil::redirect($API->app_path());
}
if (isset($_GET['id']) && $_GET['id'] != '') {
    $blogID = (int) $_GET['id'];
    $Blog = $Blogs->find($blogID);
    $details = $Blog->to_array();
} else {
    $blogID = false;
    $Blog = false;
    $details = array();
}
$Template = $API->get('Template');
$Template->set('blog/blog.html', 'blog');
$Form->handle_empty_block_generation($Template);
$tags = $Template->find_all_tags_and_repeaters();
$Form->require_field('blogTitle', 'Required');
$Form->set_required_fields_from_template($Template, $details);
if ($Form->submitted()) {
    $postvars = array('blogTitle', 'setSlug', 'postTemplate');
<?php

$Paging = new PerchPaging();
$Paging->set_per_page(24);
$API = new PerchAPI(1.0, 'categories');
$HTML = $API->get('HTML');
$Sets = new PerchCategories_Sets();
$Categories = new PerchCategories_Categories();
$sets = $Sets->all($Paging);
if (!file_exists(PERCH_TEMPLATE_PATH . '/categories')) {
    $Alert->set('notice', PerchLang::get('The category templates could not be found. Please copy them to %s', '<code>' . PERCH_TEMPLATE_PATH . '/categories' . '</code>'));
}