/** * This is the main search action. Special:Search points here. */ public function index() { $this->wg->Out->addHTML(F::build('JSSnippets')->addToStack(array("/extensions/wikia/Search/js/WikiaSearch.js"))); $this->wg->SuppressRail = true; $this->handleSkinSettings($this->wg->User->getSkin()); $searchConfig = F::build('WikiaSearchConfig'); $searchConfig->setQuery($this->getVal('query', $this->getVal('search')))->setCityId($this->wg->CityId)->setLimit($this->getVal('limit', self::RESULTS_PER_PAGE))->setPage($this->getVal('page', 1))->setRank($this->getVal('rank', 'default'))->setDebug($this->request->getBool('debug', false))->setSkipCache($this->request->getBool('skipCache', false))->setAdvanced($this->request->getBool('advanced', false))->setHub($this->getVal('nohub') != '1' ? $this->getVal('hub', false) : false)->setRedirs($searchConfig->getAdvanced() ? $this->request->getBool('redirs', false) : false)->setIsInterWiki($this->request->getBool('crossWikia', false) || $this->isCorporateWiki())->setVideoSearch($this->getVal('videoSearch', false))->setGroupResults($searchConfig->isInterWiki() || $this->getVal('grouped', false)); $this->setNamespacesFromRequest($searchConfig, $this->wg->User); if ($this->isCorporateWiki()) { OasisController::addBodyClass('inter-wiki-search'); } if ($searchConfig->getQueryNoQuotes(true)) { $articleMatch = null; $this->wikiaSearch->getArticleMatch($searchConfig); if ($searchConfig->getPage() == 1) { $this->handleArticleMatchTracking($searchConfig); } $this->wikiaSearch->doSearch($searchConfig); $this->app->wg->Out->setPageTitle($this->wf->msg('wikiasearch2-page-title-with-query', array(ucwords($searchConfig->getQuery(WikiaSearchConfig::QUERY_RAW)), $this->wg->Sitename))); } else { if ($searchConfig->getIsInterWiki()) { $this->app->wg->Out->setPageTitle($this->wf->msg('wikiasearch2-page-title-no-query-interwiki')); } else { $this->app->wg->Out->setPageTitle($this->wf->msg('wikiasearch2-page-title-no-query-intrawiki', array($this->wg->Sitename))); } } if (!$searchConfig->getIsInterWiki()) { $this->setVal('advancedSearchBox', $this->sendSelfRequest('advancedBox', array('config' => $searchConfig))); } $format = $this->response->getFormat(); if (($format == 'json' || $format == 'jsonp') && $searchConfig->getResultsFound() > 0) { $searchConfig->setResults($searchConfig->getResults()->toNestedArray()); } $this->setVal('results', $searchConfig->getResults()); $this->setVal('resultsFound', $searchConfig->getResultsFound()); $this->setVal('resultsFoundTruncated', $this->wg->Lang->formatNum($searchConfig->getTruncatedResultsNum())); $this->setVal('isOneResultsPageOnly', $searchConfig->getNumPages() < 2); $this->setVal('pagesCount', $searchConfig->getNumPages()); $this->setVal('currentPage', $searchConfig->getPage()); $this->setVal('paginationLinks', $this->sendSelfRequest('pagination', array('config' => $searchConfig))); $this->setVal('tabs', $this->sendSelfRequest('tabs', array('config' => $searchConfig))); $this->setVal('query', $searchConfig->getQuery(WikiaSearchConfig::QUERY_ENCODED)); $this->setVal('resultsPerPage', $searchConfig->getLimit()); $this->setVal('pageUrl', $this->wg->Title->getFullUrl()); $this->setVal('debug', $searchConfig->getDebug()); $this->setVal('solrHost', $this->wg->SolrHost); $this->setVal('isInterWiki', $searchConfig->getIsInterWiki()); $this->setVal('relevancyFunctionId', WikiaSearch::RELEVANCY_FUNCTION_ID); //@todo do we need this? $this->setVal('namespaces', $searchConfig->getNamespaces()); $this->setVal('hub', $searchConfig->getHub()); $this->setVal('hasArticleMatch', $searchConfig->hasArticleMatch()); $this->setVal('isMonobook', $this->wg->User->getSkin() instanceof SkinMonobook); $this->setVal('isCorporateWiki', $this->isCorporateWiki()); }