Exemplo n.º 1
0
 public function getPosts($status = null, $limitQuery = null)
 {
     $P = new post();
     $posts = array();
     if (is_null($status) === true) {
         $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, null);
     } else {
         if (is_array($status) === false) {
             $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE status='{$status}'");
         } else {
             $status_sql = "";
             foreach ($status as $st) {
                 $status_sql .= "status ='{$st}' OR ";
             }
             $status_sql = substr($status_sql, 0, -3);
             $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE ({$status_sql})");
         }
     }
     $C = new comment();
     foreach ($posts as $k => $p) {
         $posts[$k]['title'] = htmlspecialchars($posts[$k]['title']);
         $posts[$k]['tags'] = $this->getTags($posts[$k]['ID']);
         $posts[$k]['comments_count'] = $C->countCommentsByPost($posts[$k]['ID'], "publish");
         $U = new user();
         if ($posts[$k]['id_user'] < 2) {
             $posts[$k]['autor'] = $U->find(1);
         } else {
             $posts[$k]['autor'] = $U->find($posts[$k]['id_user']);
         }
     }
     return $posts;
 }
Exemplo n.º 2
0
 public function rss($id = NULL)
 {
     $this->plugin->call('feed_header');
     $post = new post();
     $this->view->conf = $this->conf;
     $this->view->setLayout("feed");
     $posts = $post->findAll("ID,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", "ID DESC", $this->conf['blog_posts_per_page'], "WHERE status = 'publish'");
     $temp = array();
     foreach ($posts as $a_post) {
         $temp[$a_post['ID']] = $a_post;
         $temp[$a_post['ID']]['tags'] = $post->getTags($a_post['ID'], 'string');
     }
     $this->view->posts = $temp;
     $this->render("rss");
 }
Exemplo n.º 3
0
 public function index($id = NULL)
 {
     $P = new post();
     $total_rows = $P->countPosts();
     $page = $id;
     $page = is_null($page) ? 1 : $page;
     $limit = $this->userConf['posts_per_page'];
     $offset = ($page - 1) * $limit;
     $limitQuery = $offset . "," . $limit;
     $targetpage = $this->path . 'admin/index/';
     $pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage);
     $this->title_for_layout("Administraci&oacute;n - Codice CMS");
     $this->view->pagination = $pagination;
     $this->view->posts = $P->findAll(NULL, "ID DESC", $limitQuery, NULL);
     $this->view->blogConfig = $this->blogConfig;
     $this->view->userConf = $this->userConf;
     $this->view->setLayout("admin");
     $this->render();
 }