public function findImages($search) { $user_id = \Registry::getCurrentUser()->iduser; $user = \Model\User::model()->findByPk($user_id); $criteria = new \DBCriteria(array('condition' => " description LIKE :match OR\n main_text LIKE :match OR\n title LIKE :match OR ", 'params' => array(':match' => "%{$search}%"))); $criteria->limit = $this->limit; $data = \Model\Pages::model()->with('idpageType')->findAll($criteria); $this->template->assign(['results' => $data, 'count_find' => count($data)]); }
public function handleDeletePage($id) { $this->onBeforeRestrictedFunctionality($this); try { $this->pages->delete($this->pages->findOneBy(['id' => $id])); $this->flashMessage('Stránka byla úspěšně smazána.', 'success'); } catch (\Exception $exc) { $this->flashMessage($exc->getMessage(), 'danger'); } $this->redirect('this'); }
public function pageFormSucceeded($form, $vals) { try { if (!$this->page) { $this->page = new Entity\Page(); $this->page->date = new \DateTime(); } $this->page->title = $vals->title; $this->page->slug = $vals->slug; $this->page->body = $vals->editor; $this->page->draft = FALSE; $this->pages->save($this->page); $this->presenter->flashMessage('Stránka byla úspěšně uložena a publikována.', 'success'); $this->onSave(); } catch (Kdyby\Doctrine\DuplicateEntryException $exc) { //DBALException $this->presenter->flashMessage('Tento URL slug je již v databázi uložen, zvolte prosím jiný.', 'danger'); } catch (Nette\Security\AuthenticationException $exc) { $this->presenter->flashMessage('Myslím to vážně, editovat opravdu **ne**můžete!', 'danger'); $this->redirect('this'); return; } }
public function action_display() { $user_id = \Registry::getCurrentUser()->iduser; if ($item_id = \Utils\Protect::Validate($this->request->param('id'), 'int')) { \Assets::js('page1', base_UI . 'js/pages/page.js'); $page = \Model\Pages::model()->findByPk($item_id); $this->template->assign(['page' => $page]); $this->response->body($this->template->fetch('pages.tpl')); } else { if ($alias = \Utils\Protect::Validate($this->request->param('alias'), 'string')) { /**@var \Model\Item $data*/ \Assets::js('page1', base_UI . 'js/pages/page.js'); $page = \Model\Pages::model()->findByAttributes(['alias' => $alias]); $this->template->assign(['page' => $page]); $this->response->body($this->template->fetch('pages.tpl')); } } }
public function startup() { parent::startup(); $this->template->setting = $this->setting = $this->settings->findAllByKeys(); $this->template->pages = $this->pages->findBy([]); }
public function action_GetJson() { $data = \Model\Pages::model()->with('idpageType')->findAll(); $access = new \Auth\Access(\Registry::getCurrentUser()->access_level); if ($access->get(\Auth\Access::User_Is_Admin)) { $aoColumnsData = []; if (!$data) { $this->response->body(json_encode(['aaData' => $aoColumnsData])); return; } /** @var $item User */ foreach ($data as $key => $item) { $tmp = ['id' => $item->idpages, 'title' => $item->title, 'description' => $item->description, 'type' => $item->idpageType->name]; $aoColumnsData[] = $tmp; } $this->response->body(json_encode(['aaData' => $aoColumnsData])); } else { throw new \HTTP_Exception_403('Admin Only'); } }