public function indexAction() { $guestbookMapper = new GuestbookMapper(); if ($this->getRequest()->getPost('check_entries')) { if ($this->getRequest()->getPost('action') == 'delete') { foreach ($this->getRequest()->getPost('check_entries') as $entryId) { $guestbookMapper->delete($entryId); } $this->redirect(array('action' => 'index')); } if ($this->getRequest()->getPost('action') == 'setfree') { foreach ($this->getRequest()->getPost('check_entries') as $entryId) { $model = new \Modules\Guestbook\Models\Entry(); $model->setId($entryId); $model->setFree(1); $guestbookMapper->save($model); } $this->redirect(array('action' => 'index')); } } if ($this->getRequest()->getParam('showsetfree')) { $entries = $guestbookMapper->getEntries(array('setfree' => 0)); } else { $entries = $guestbookMapper->getEntries(array('setfree' => 1)); } $this->getView()->set('entries', $entries); $this->getView()->set('badge', count($guestbookMapper->getEntries(array('setfree' => 0)))); }
public function indexAction() { $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('guestbook'), array('action' => 'index')); $guestbookMapper = new GuestbookMapper(); $pagination = new \Ilch\Pagination(); $pagination->setPage($this->getRequest()->getParam('page')); $this->getView()->set('entries', $guestbookMapper->getEntries(array('setfree' => 1), $pagination)); $this->getView()->set('pagination', $pagination); }