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'); $data = $Form->receive($postvars);
public function get_blog() { $Blogs = new PerchBlog_Blogs($this->api); return $Blogs->find((int) $this->blogID()); }
if (!$CurrentUser->has_priv('perch_blog.post.create')) { PerchUtil::redirect($API->app_path()); } if (isset($_GET['id']) && $_GET['id'] != '') { $postID = (int) $_GET['id']; $Post = $Posts->find($postID, true); $details = $Post->to_array(); $template = $Post->postMetaTemplate(); } $Blog = false; if (PERCH_RUNWAY) { if ($Post) { $Blog = $Post->get_blog(); } else { if (PerchUtil::get('blog')) { $Blog = $Blogs->find((int) PerchUtil::get('blog')); } } } if (!$Blog) { $Blog = $Blogs->find(1); } $Sections = new PerchBlog_Sections(); $sections = $Sections->get_by('blogID', $Blog->id()); if (!$template) { $template = $Blog->postMetaTemplate(); } $Template = $API->get('Template'); $Template->set('blog/' . $template, 'blog'); $tags = $Template->find_all_tags_and_repeaters(); $Form = $API->get('Form');
$Blogs = new PerchBlog_Blogs($API); $blogs = $Blogs->all(); if (!PerchUtil::count($blogs)) { $Posts->attempt_install(); $blogs = $Blogs->all(); } $Paging = $API->get('Paging'); $Paging->set_per_page(15); $Blog = false; if (PERCH_RUNWAY) { if (PerchUtil::get('blog')) { $Blog = $Blogs->get_one_by('blogSlug', PerchUtil::get('blog')); } } if (!$Blog) { $Blog = $Blogs->find(1); } $Categories = new PerchCategories_Categories(); $categories = $Categories->get_for_set($Blog->setSlug()); $Sections = new PerchBlog_Sections($API); $sections = $Sections->get_by('blogID', (int) $Blog->id()); $Lang = $API->get('Lang'); $posts = array(); $filter = 'all'; if (isset($_GET['category']) && $_GET['category'] != '') { $filter = 'category'; $category = $_GET['category']; } if (isset($_GET['section']) && $_GET['section'] != '') { $filter = 'section'; $section = $_GET['section'];
} $Blogs = new PerchBlog_Blogs($API); $blogs = $Blogs->all(); if (isset($_GET['id']) && $_GET['id'] != '') { $sectionID = (int) $_GET['id']; $Section = $Sections->find($sectionID); $details = $Section->to_array(); } else { $sectionID = false; $Section = false; $details = array(); } $Blog = false; if (PERCH_RUNWAY) { if ($Section) { $Blog = $Blogs->find((int) $Section->blogID()); } else { if (PerchUtil::get('blog')) { $Blog = $Blogs->find((int) PerchUtil::get('blog')); } } } if (!$Blog) { $Blog = $Blogs->find(1); } $Template = $API->get('Template'); $Template->set('blog/section.html', 'blog'); $Form->handle_empty_block_generation($Template); $tags = $Template->find_all_tags_and_repeaters(); $Form->require_field('sectionTitle', 'Required'); $Form->set_required_fields_from_template($Template, $details);
<?php if (!PERCH_RUNWAY) { exit; } $Blogs = new PerchBlog_Blogs($API); $HTML = $API->get('HTML'); $Form = $API->get('Form'); $Form->set_name('delete'); if (!$CurrentUser->has_priv('perch_blog.blogs.manage')) { PerchUtil::redirect($API->app_path()); } $message = false; if (isset($_GET['id']) && $_GET['id'] != '') { $Blog = $Blogs->find($_GET['id']); } else { PerchUtil::redirect($API->app_path()); } if ($Form->submitted()) { if (is_object($Blog)) { $Blog->delete(); // clear the caches PerchBlog_Cache::expire_all(); if ($Form->submitted_via_ajax) { echo $API->app_path() . '/blogs/'; exit; } else { PerchUtil::redirect($API->app_path() . '/blogs/'); } } else { $message = $HTML->failure_message('Sorry, that blog could not be deleted.');