1 <?php
defined('IN_CMS') or die('No direct access allowed.');
4 This class contains all routing details
8 public function article($slug = '') {
10 $params = array('slug' => $slug);
12 // allow admin to view unpublished posts
13 if(Users
::authed() === false) {
14 $params['status'] = 'published';
17 if(($article = Posts
::find($params)) === false) {
18 Log
::warning('Article connot be found: ' . $slug);
19 return Response
::error(404);
23 if(Input
::method() == 'POST') {
24 if(Comments
::add($article->id
)) {
25 $page = IoC
::resolve('posts_page');
26 return Response
::redirect($page->slug
. '/' . $article->slug
);
30 // register single item for templating functions
31 IoC
::instance('article', $article, true);
33 Template
::render('article');
36 public function page($slug = '') {
37 // allow admin to view unpublished posts
38 if(Users
::authed() === false) {
39 $params['status'] = 'published';
42 // if no slug is set we will use our default page
44 $params['id'] = Config
::get('metadata.home_page');
46 $params['slug'] = $slug;
49 // if we cant find either it looks like we're barney rubble (in trouble)
50 if(($page = Pages
::find($params)) === false) {
51 Log
::warning('Page connot be found: ' . $slug);
52 return Response
::error(404);
55 // store our page for template functions
56 IoC
::instance('page', $page, true);
58 // does the current page host our posts?
59 if($page->id
== Config
::get('metadata.posts_page')) {
60 // render our posts template
61 return Template
::render('posts');
64 // render our page template
65 Template
::render('page');
68 public function rss() {
76 public function search($term = '') {
77 if(Input
::method() == 'POST') {
78 if(Input
::post('term') !== false) {
79 return Response
::redirect('search/' . rawurlencode(Input
::post('term')));
83 $search = Posts
::search($term, array(
84 'status' => 'published',
85 'limit' => Config
::get('metadata.posts_per_page', 10),
86 'offset' => Input
::get('offset', 0)
88 IoC
::instance('search', $search, true);
90 $total = Posts
::search_count($term, array(
91 'status' => 'published'
93 IoC
::instance('total_search', $total, true);
97 $page->title
= 'Search';
98 IoC
::instance('page', $page, true);
99 Template
::render('search');