Exemple #1
0
 /**
  * Debug query action
  */
 public function debugQueryAction()
 {
     $query = $this->param('query');
     $tokens = Query\Token::lexer($query);
     $parsed = Query\Parser::parse($query);
     $model = $this->getServiceLocator()->get('Grid\\Search\\Model\\Result\\Model');
     $this->paragraphLayout();
     return array('query' => $query, 'tokens' => $tokens, 'parsed' => $parsed, 'toRepresentation' => $parsed->toRepresentation(), 'toQueryString' => $tsquery = $parsed->toQueryString(), 'effective' => $model->debugQuery((string) $this->locale(), $tsquery));
 }
 /**
  * Get results for atom & rss actions
  */
 protected function getResults()
 {
     $locale = (string) $this->locale();
     $query = $this->param('query', '');
     $type = $this->param('type', '%') ?: '%';
     $all = (bool) $this->param('all', false);
     $page = (int) abs($this->param('page', 1)) ?: 1;
     $items = min(25, (int) abs($this->param('items', 10)) ?: 10);
     $cindex = ($page - 1) * $items + 1;
     $index = (int) abs($this->param('index', $cindex)) ?: $cindex;
     $parsed = Query\Parser::parse($query);
     $model = $this->getServiceLocator()->get('Grid\\Search\\Model\\Result\\Model');
     $where = array('locale' => (string) $locale, 'query' => (string) $parsed->toQueryString(), 'type' => (string) $type, 'all' => (bool) $all);
     return array('all' => $all, 'type' => $type, 'page' => $page, 'items' => $items, 'index' => $index, 'query' => $parsed->toRepresentation(), 'count' => $count = $model->searchCount($where), 'results' => $count < 1 ? array() : $model->searchResults($where, $items, $index - 1));
 }