setTitle(Help::langAdmin('Help / Search for a Question')); $this->setKey('help.search'); $this->withSeoSettings('search', 'help'); $this->setTemplate('list.search', 'help'); } public function searchData(array $data = []) { # search query $this->query = $this->input->postget('query', TYPE_NOTAGS); $this->query = $this->input->cleanSearchString($this->query, 80); $data['query'] = $this->query; # search list page number $this->page = $this->input->postget('page', TYPE_UINT); if (! $this->page) { $this->page = 1; } $data['page'] = $this->page; return $data; } public function handle() { $this->searchData(); } public function data() { $data = parent::data(); if (empty($this->query) || mb_strlen($this->query) < 3) { return Redirect::to(Help::url('index')); } $data['titleh1'] = Help::lang('Search results for query "[query]":', [ 'query' => HTML::escape($this->query), ]); $data['num'] = 1; $data['pages'] = ''; $data['total'] = Help::model()->questionsSearch($this->query, true); if ($data['total'] > 0) { $pages = new Pagination( $data['total'], $this->pageSize, Help::url('search', ['query' => $this->query]) . '&page=' . Pagination::PAGE_ID ); $data['questions'] = Help::model()->questionsSearch($this->query, false, $pages->getLimitOffset()); if (! empty($data['questions'])) { foreach ($data['questions'] as &$v) { $v['link'] = Url::dynamic($v['link']); $v['title'] = strtr($v['title'], [$this->query => '' . $this->query . '']); $v['textshort'] = strtr($v['textshort'], [$this->query => '' . $this->query . '']); } unset($v); } $this->page = $pages->getCurrentPage(); $data['pages'] = $pages->view(['pageto' => false, 'arrows' => false]); $data['num'] = ($this->page <= 1 ? 1 : (($this->page - 1) * $this->pageSize) + 1); } $this->breadcrumbs->add(Help::lang('Search results')); return $data; } public function seo() { $this->seo->index(false); $this->seo->with([ 'query' => $this->query, 'page' => $this->page, ]); $this->seoApply(); } public function seoSettings() { $this->seo ->list() ->placeholder('query', Help::lang('Search line')); } public function settingsForm($form) { $form ->number('pageSize', Help::langAdmin('Quantity In the List'), 1, 30, 1, $this->pageSize) ->tip(Help::langAdmin('Number of questions per page in the list')) ->label(Help::langAdmin('per page')) ->width(100); } public function settings() { return [ 'pageSize', ]; } }