Exemplo n.º 1
0
 public function getChapters($published = NULL)
 {
     $chapterTbl = new Book_Model_DbTable_Chapters();
     $select = $chapterTbl->select()->where('work_id = ?', $this->getIdentity());
     if ($published != NULL) {
         $select->where('published = ?', $published);
     }
     return $chapterTbl->fetchAll($select);
 }
Exemplo n.º 2
0
 public function getOrder()
 {
     $id = $this->getIdentity();
     $workId = $this->work_id;
     if (!empty($id) && !empty($workId)) {
         $chapterTbl = new Book_Model_DbTable_Chapters();
         $chapterTblName = $chapterTbl->info('name');
         $select = $chapterTbl->select()->setIntegrityCheck(false)->from($chapterTblName, new Zend_Db_Expr('COUNT(chapter_id) AS ordering'))->where("{$chapterTblName}.work_id = ?", $this->work_id)->where("{$chapterTblName}.chapter_id < ?", $this->getIdentity());
         $data = $chapterTbl->fetchRow($select);
         if ($data) {
             return (int) $data->ordering + 1;
         }
     }
 }
Exemplo n.º 3
0
 public function viewAction()
 {
     parent::viewAction();
     $this->view->work = $work = $this->_getSubject();
     $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();
     $chapterTbl = new Book_Model_DbTable_Chapters();
     $chapterSelect = $chapterTbl->select()->where('work_id = ?', $work->getIdentity());
     $workOwner = $work->getOwner();
     if (!$workOwner->isSelf($viewer)) {
         $chapterSelect->where('published = ?', 1);
     }
     $this->view->paginator = $paginator = Zend_Paginator::factory($chapterSelect);
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     $this->_helper->content->setEnabled();
 }