/** * @param int $currentPage */ public function search($currentPage = 1) { $this->loadMainData(); $perPage = 50; $offset = $currentPage > 1 ? ($currentPage - 1) * $perPage : 0; $searchTerm = str_replace('"', '"', htmlspecialchars($_GET['q'])); $this->data['pageType'] = 'search'; $this->data['search'] = true; $this->data['searchTerm'] = $searchTerm; $this->data['tweets'] = $this->model->getSearchResults($searchTerm, $offset, $perPage); $this->data['tweetsTotalCount'] = $this->model->getSearchResults($searchTerm, $offset, $perPage, true); $pageBaseUrl = $this->data['config']['system']['baseUrl'] . '?q=' . urlencode($searchTerm); $this->data['pagination'] = $this->paginator->paginate($pageBaseUrl, $this->data['tweetsTotalCount'], $currentPage, $perPage, false); $this->data['title'] = $this->i18n->trans('search_results', ['ucf']); $this->data['subTitle'] = $searchTerm; $this->render('index.php'); }