Esempio n. 1
0
 public function ActionDefault()
 {
     if (isset($_REQUEST['details'])) {
         return $this->Details(intval($_REQUEST['details']));
     }
     $template = new Template();
     $template->rss = static::$config['url']['rss'];
     $template->searchbox = new Template('searchbox');
     $template->menu = new Template('menu');
     if (isset($_REQUEST['q']) || isset($_REQUEST['cat']) || isset($_REQUEST['p'])) {
         $render = new PostRender(static::$config['url']['base']);
         // Title
         if (isset($_REQUEST['q']) && !empty($_REQUEST['q'])) {
             $template->title = SafeHTML(trim($_REQUEST['q']));
         } elseif (isset($_REQUEST['cat']) && !empty($_REQUEST['cat'])) {
             $cat = trim($_REQUEST['cat']);
             $template->title = SafeHTML($cat != 'dvd' ? ucfirst($cat) : strtoupper($cat));
         } else {
             $template->title = 'All';
         }
         $template->title .= ' :: ';
         // Search box variables
         $template->searchbox->query = isset($_REQUEST['q']) ? trim($_REQUEST['q']) : '';
         if (isset($_REQUEST['cat']) && !empty($_REQUEST['cat'])) {
             $template->searchbox->cat = array(strtolower(trim($_REQUEST['cat'])) => ' selected="selected"');
         } else {
             $template->searchbox->cat = array('all' => ' selected="selected"');
         }
         // RSS
         if (count($render->link) > 0) {
             $template->rss .= '?' . http_build_query($render->link, '', '&');
         }
         $template->searchbox->rss = '<a href="' . $template->rss . '" title="RSS"><img src="' . static::$config['url']['base'] . 'images/rss.png" width="14" height="14" alt="RSS" /></a>';
         // Result
         $template->body = $render->View();
         // Stop search engines (Google) from complaining a page with no results should return 404
         if ($render->rowcount == 0) {
             $template->meta = '<meta name="robots" content="noindex,nofollow">';
         }
         $template->footer = new Template('footer');
         $template->Display('layout');
     } else {
         $template->Display('layout_splash');
     }
 }
Esempio n. 2
0
    $partial_article = file_get_contents(ROOT . '/templates/' . THEME . '/partials/article.html');
    $partial_category = file_get_contents(ROOT . '/templates/' . THEME . '/partials/category.html');
    $category_id = (int) $args['category_id'];
    $category = isset($args['category_id']) ? $args['category_id'] : Category::getFirst();
    $categories = CategoryRender::render($category_id, $partial_category);
    $articles = PostRender::renderForCategory($category_id, $partial_article);
    $category = new Category($category_id);
    render_content(['articles' => $articles, 'category' => $categories]);
});
// render a post
Route::get('show_post', function ($args) {
    $partial_article = file_get_contents(ROOT . '/templates/' . THEME . '/partials/article.html');
    $partial_category = file_get_contents(ROOT . '/templates/' . THEME . '/partials/category.html');
    $post_id = isset($args['post_id']) ? (int) $args['post_id'] : NULL;
    $post = new Post($post_id);
    $articles = PostRender::renderPost(new Post($post_id), $partial_article);
    $categories = CategoryRender::render($post->category_id, $partial_category);
    render_content(['articles' => $articles, 'category' => $categories]);
});
// default action
Route::get('', function ($args) {
    $category_id = 1;
    $year = !empty($args['year']) ? (int) $args['year'] : date('Y');
    Route::run('show_category', ['category_id' => $category_id, 'year' => $year]);
});
// render page content
function render_content($replaces)
{
    $content = new Content(1);
    $layout_content = file_get_contents(ROOT . '/templates/' . THEME . '/layout.html');
    $layout_content = str_replace('{theme}', THEME, $layout_content);
Esempio n. 3
0
 protected function Init()
 {
     /*
      * Filter
      */
     if (isset($_REQUEST['filter'])) {
         $this->filter = boolval($_REQUEST['filter']);
     }
     /*
      * Format
      */
     if (isset($_REQUEST['format'])) {
         if (trim(strtolower($_REQUEST['format'])) == 'serial') {
             $this->format = self::FORMAT_SERIAL;
         } else {
             $this->format = self::FORMAT_JSON;
         }
     }
     /*
      * Call parent function *last*
      */
     parent::Init();
 }