コード例 #1
0
 /**
  * Search action method
  *
  * @return void
  */
 public function search()
 {
     $search = new Model\Search();
     $fields = $this->request->isPost() ? $this->request->getPost() : $this->request->getQuery();
     $search->user_role_id = isset($this->sess->user) ? $this->sess->user->role_id : -1;
     $search->filters = $this->application->module('phire-content')->config()['filters'];
     if (isset($fields['title'])) {
         $items = $search->search($fields, $this->application->modules());
         if (count($items) > $this->config->pagination) {
             $page = $this->request->getQuery('page');
             $limit = $this->config->pagination;
             $pages = new Paginator(count($items), $limit);
             $pages->useInput(true);
             $offset = null !== $page && (int) $page > 1 ? $page * $limit - $limit : 0;
             $items = array_slice($items, $offset, $limit, true);
         } else {
             $pages = null;
         }
         $this->prepareView('search-public/search.phtml');
         $this->view->title = 'Search';
         $this->view->pages = $pages;
         $this->view->items = $items;
         $this->send();
     } else {
         $this->redirect(BASE_PATH . (BASE_PATH == '' ? '/' : ''));
     }
 }
コード例 #2
0
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $search = new Model\Search();
     if ($this->request->isPost()) {
         $search->remove($this->request->getPost());
         $this->sess->setRequestValue('removed', true);
         $this->redirect(BASE_PATH . APP_URI . '/searches');
     } else {
         if ($search->hasPages($this->config->pagination)) {
             $limit = $this->config->pagination;
             $pages = new Paginator($search->getCount(), $limit);
             $pages->useInput(true);
         } else {
             $limit = null;
             $pages = null;
         }
         $this->prepareView('search/index.phtml');
         $this->view->title = 'Searches';
         $this->view->pages = $pages;
         $this->view->searches = $search->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
         $this->send();
     }
 }