Beispiel #1
0
 public static function initialize($param)
 {
     $tag = strtolower($param['action']);
     $page = (int) ($param['parameter'] ?: '1');
     $pages = ceil(\BWBlog\Post::count(['ltags' => $tag]) / P_POSTS_PER_PAGE);
     $posts = \BWBlog\Post::list_all(['ltags' => $tag], $page);
     \BWBlog\Service\Template::render('pages/list', ['POSTS' => $posts, 'PAGE' => $page, 'PAGE_COUNT' => $pages, 'TAG' => $tag, 'TITLE' => ucwords($tag), 'BASE_URI' => '/tag/' . $param['action'] . '/']);
     return false;
 }
Beispiel #2
0
 public static function indexAction()
 {
     $rss = new \UniversalFeedCreator();
     $rss->useCached('RSS1.0', ROOT_DIR . '/runtime/rss.xml');
     $rss->title = P_TITLE;
     $rss->link = ENV_PREFERED_PROTOCOL . '://' . CONFIG_HOST . P_PREFIX;
     $rss->syndicationURL = $rss->link . '/feed';
     $posts = \BWBlog\Post::list_all([], 1, 0);
     foreach ($posts as $post) {
         $item = new \FeedItem();
         $item->title = $post['title'];
         $item->link = ENV_PREFERED_PROTOCOL . '://' . CONFIG_HOST . P_PREFIX . $post['rest_url'];
         $item->description = $post['content']['html'];
         $item->date = $post['time']['main'];
         $rss->addItem($item);
     }
     echo $rss->saveFeed('RSS1.0', ROOT_DIR . '/runtime/rss.xml');
 }
Beispiel #3
0
 public static function initialize($param)
 {
     if (is_numeric($param['action'])) {
         // page/1
         $page = (int) $param['action'];
         $pages = ceil(\BWBlog\Post::count() / P_POSTS_PER_PAGE);
         $posts = \BWBlog\Post::list_all([], $page);
         \BWBlog\Service\Template::render('pages/list', ['CATEGORY' => 'home', 'POSTS' => $posts, 'PAGE' => $page, 'PAGE_COUNT' => $pages, 'BASE_URI' => '/page/']);
     } else {
         // page/custom_page
         $post = \BWBlog\Post::get($param['raw']);
         if ($post == null) {
             throw new \ReflectionException();
             return false;
         }
         \BWBlog\Service\Template::render('pages/page', ['TITLE' => $post['title'], 'POST' => $post]);
     }
     return false;
 }