コード例 #1
0
 public function recentAction()
 {
     $page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1;
     $limit = 5;
     $posts = new Posts();
     $this->view->posts = $posts->getRecent($page, $limit);
     $total = $posts->getRecent($page, 0, true)->total;
     $this->view->paginator = Zend_Paginator::factory($total);
     $this->view->paginator->setCurrentPageNumber($page);
     $this->view->paginator->setItemCountPerPage($limit);
 }
コード例 #2
0
ファイル: IndexController.php プロジェクト: aprondak/ifphp
 /**
  * Site landing page
  */
 public function indexAction()
 {
     $limit = 5;
     $page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1;
     $posts = new Posts();
     $this->view->posts = $posts->getRecent($page, $limit);
     $total = $posts->getRecent($page, 0, true)->total;
     $this->view->paginator = Zend_Paginator::factory($total);
     $this->view->paginator->setCurrentPageNumber($page);
     $this->view->paginator->setItemCountPerPage($limit);
     $this->view->keywords = implode('', array('ifphp', 'news aggragator', 'support,' . $this->view->term));
 }
コード例 #3
0
ファイル: SearchProvider.php プロジェクト: aprondak/ifphp
 /**
  * Build the post search index
  * 
  * @param boolean $isCount
  * @return boolean
  */
 protected function buildPostSearch($isCount = false)
 {
     $index = Zend_Search_Lucene::create(Zend_Registry::getInstance()->config->search->post);
     require_once 'Ifphp/models/Posts.php';
     require_once 'Ifphp/models/Feeds.php';
     require_once 'Ifphp/models/Categories.php';
     $posts = new Posts();
     $allPosts = $posts->getRecent(1, 0);
     if ($isCount) {
         echo $allPosts->count() . ' posts would have been added to the post index';
         exit;
     }
     foreach ($allPosts as $post) {
         $feed = $post->findParentFeeds();
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::Text('pid', $post->id));
         $doc->addField(Zend_Search_Lucene_Field::Text('title', $post->title));
         $doc->addField(Zend_Search_Lucene_Field::Text('siteUrl', $post->siteUrl));
         $doc->addField(Zend_Search_Lucene_Field::Text('link', $post->link));
         $doc->addField(Zend_Search_Lucene_Field::Text('feedTitle', $feed->title));
         $doc->addField(Zend_Search_Lucene_Field::Text('feedSlug', $feed->slug));
         $doc->addField(Zend_Search_Lucene_Field::Text('feedDescription', $feed->description));
         $doc->addField(Zend_Search_Lucene_Field::keyword('category', $feed->findParentCategories()->title));
         $doc->addField(Zend_Search_Lucene_Field::Text('description', $post->description));
         $doc->addField(Zend_Search_Lucene_Field::unIndexed('publishDate', $post->publishDate));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('type', 'post'));
         $index->addDocument($doc);
     }
     chown(Zend_Registry::getInstance()->search['post'], 'www-data');
     return true;
 }