Exemple #1
0
 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)]);
 }
Exemple #2
0
 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'));
         }
     }
 }
Exemple #3
0
 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');
     }
 }