public function savePage(Page $page) { $data = $page->getArrayCopy(); if (!$data['id']) { $this->insert($data); } else { $this->update($data, array("id" => $data['id'])); } }
public function testInputFiltersAreSetCorrectly() { $this->markTestIncomplete('This test has not been implemented yet.'); $album = new Page(); $inputFilter = $album->getInputFilter(); $this->assertSame(3, $inputFilter->count()); $this->assertTrue($inputFilter->has('artist')); $this->assertTrue($inputFilter->has('id')); $this->assertTrue($inputFilter->has('title')); }
/** * Action responsible to display a list of pages with required data. * * @return \Phalcon\Http\ResponseInterface * @throws \Api\Exception\NotImplementedException */ public function listAction() { $pages = \Page\Model\Page::find(); $filter = new \Api\Filter\PagesList(); $payload = new \Api\Model\Payload($filter->filter($pages)); return $this->render($payload); }
public function deleteAction($id) { $model = Page::findFirst($id); if ($this->request->isPost()) { $model->delete(); $this->redirect('/page/admin'); } $this->view->model = $model; $this->view->title = 'Удаление страницы'; $this->helper->title('Удаление страницы'); }
public function contactsAction() { $page = Page::findCachedBySlug('contacts'); if (!$page) { throw new Exception("Page 'contacts' not found"); } $this->helper->title()->append($page->getMeta_title()); $this->helper->meta()->set('description', $page->getMeta_description()); $this->helper->meta()->set('keywords', $page->getMeta_keywords()); $this->view->page = $page; $this->helper->menu->setActive('contacts'); }
public function indexAction() { $this->view->bodyClass = 'home'; $page = Page::findCachedBySlug('index'); if (!$page) { throw new Exception("Page 'index' not found"); } $this->helper->title()->append($page->getMeta_title()); $this->helper->meta()->set('description', $page->getMeta_description()); $this->helper->meta()->set('keywords', $page->getMeta_keywords()); $this->view->page = $page; $this->helper->menu->setActive('index'); }
public function indexAction() { $slug = $this->dispatcher->getParam('slug', 'string'); $page = Page::findCachedBySlug($slug); if (!$page) { throw new Exception("Page '{$slug}.html' not found"); return; } $this->helper->title()->append($page->getMeta_title()); $this->helper->meta()->set('description', $page->getMeta_description()); $this->helper->meta()->set('keywords', $page->getMeta_keywords()); $this->view->page = $page; }
public function addAction() { $form = new PageForm(); //Создаем форму $request = $this->getRequest(); //Обращение к запросу в форме (получение запроса) if ($request->isPost()) { $page = new Model\Page(); $form->setInputFilter($page->getInputFilter()); //Привязываем фильтр //Заполняем форму значениями $form->setData($request->getPost()); //Используем фильтр if ($form->isValid()) { $page->exchangeArray($form->getData()); //Формируем массив $this->getPageTable()->savePage($page); //Возвращаем и сохраняем return $this->redirect()->toRoute('page'); } } return new ViewModel(['form' => $form]); }
public function deleteAction($id) { $model = Page::findFirst($id); if ($model->getSlug() == 'index') { $this->flash->error($this->helper->at('Index page can not be removed')); return $this->redirect($this->url->get() . 'page/admin'); } if ($this->request->isPost()) { $model->delete(); $this->redirect($this->url->get() . 'page/admin'); } $this->view->model = $model; $this->helper->title($this->helper->at('Delete Page'), true); }
/** * * @return \Zend\View\Model\ViewModel */ public function addAction() { $form = new PageForm(); $request = $this->getRequest(); if ($request->isPost()) { $page = new Page(); $form->setInputFilter($page->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $page->exchangeArray($form->getData()); $this->getPageTable()->savePage($page); $this->redirect()->toRoute("page"); } } return new ViewModel(array("form" => $form)); }