/**
  * Sets values for the view to work with during index method.
  * @param Wikia\Search\Config $searchConfig
  */
 protected function setResponseValuesFromConfig(Wikia\Search\Config $searchConfig)
 {
     global $wgLanguageCode;
     $response = $this->getResponse();
     $format = $response->getFormat();
     if ($format == 'json' || $format == 'jsonp') {
         $results = $searchConfig->getResults();
         if ($results) {
             $response->setData($results->toArray(explode(',', $this->getVal('jsonfields', 'title,url,pageid'))));
         } else {
             $response->setData([]);
         }
         return;
     }
     if (!$searchConfig->getInterWiki()) {
         $this->setVal('advancedSearchBox', $this->sendSelfRequest('advancedBox', array('config' => $searchConfig)));
     }
     $isGridLayoutEnabled = BodyController::isGridLayoutEnabled();
     $tabsArgs = array('config' => $searchConfig, 'by_category' => $this->getVal('by_category', false), 'filters' => $this->getVal('filters', array()));
     $isMonobook = $this->app->checkSkin('monobook');
     $this->setVal('results', $searchConfig->getResults());
     $this->setVal('resultsFound', $searchConfig->getResultsFound());
     $this->setVal('resultsFoundTruncated', $searchConfig->getTruncatedResultsNum(true));
     $this->setVal('isOneResultsPageOnly', $searchConfig->getNumPages() < 2);
     $this->setVal('pagesCount', $searchConfig->getNumPages());
     $this->setVal('currentPage', $searchConfig->getPage());
     $this->setVal('paginationLinks', $this->sendSelfRequest('pagination', $tabsArgs));
     $this->setVal('tabs', $this->sendSelfRequest('tabs', $tabsArgs));
     $this->setVal('query', $searchConfig->getQuery()->getQueryForHtml());
     $this->setVal('resultsPerPage', $searchConfig->getLimit());
     $this->setVal('specialSearchUrl', $this->wg->Title->getFullUrl());
     $this->setVal('isInterWiki', $searchConfig->getInterWiki());
     $this->setVal('namespaces', $searchConfig->getNamespaces());
     $this->setVal('hub', $searchConfig->getHub());
     $this->setVal('hasArticleMatch', $searchConfig->hasArticleMatch());
     $this->setVal('isMonobook', $isMonobook);
     $this->setVal('isCorporateWiki', $this->isCorporateWiki());
     $this->setVal('wgExtensionsPath', $this->wg->ExtensionsPath);
     $this->setVal('isGridLayoutEnabled', $isGridLayoutEnabled);
     $this->setVal('shownResultsBegin', $this->resultsPerPage * $this->currentPage - $this->resultsPerPage + 1);
     if ($this->isCorporateWiki()) {
         $resultsLang = $searchConfig->getLanguageCode();
         if ($resultsLang != $this->app->wg->ContLang->getCode()) {
             $this->setVal('resultsLang', $resultsLang);
         }
     }
     if ($this->currentPage == $this->pagesCount) {
         $this->setVal('shownResultsEnd', $this->resultsFound);
     } else {
         $this->setVal('shownResultsEnd', $this->resultsPerPage * $this->currentPage);
     }
     $sanitizedQuery = $searchConfig->getQuery()->getSanitizedQuery();
     if (strlen($sanitizedQuery) > 0 && in_array(0, $searchConfig->getNamespaces()) && !in_array(6, $searchConfig->getNamespaces())) {
         $combinedMediaResult = $this->sendSelfRequest('combinedMediaSearch', array('q' => $sanitizedQuery, 'videoOnly' => true))->getData();
         if (isset($combinedMediaResult) && sizeof($combinedMediaResult['items']) == 4) {
             $this->setVal('mediaData', $combinedMediaResult);
         }
     } else {
         $this->setVal('mediaData', []);
     }
     if ($this->wg->OnWikiSearchIncludesWikiMatch && $searchConfig->hasWikiMatch()) {
         $this->registerWikiMatch($searchConfig);
     }
     $topWikiArticlesHtml = '';
     if (!$searchConfig->getInterWiki() && $wgLanguageCode == 'en' && !$isMonobook) {
         $dbname = $this->wg->DBName;
         $cacheKey = wfMemcKey(__CLASS__, 'WikiaSearch', 'topWikiArticles', $this->wg->CityId, static::TOP_ARTICLES_CACHE, $isGridLayoutEnabled);
         $topWikiArticlesHtml = WikiaDataAccess::cache($cacheKey, 86400 * 5, function () {
             return $this->app->renderView('WikiaSearchController', 'topWikiArticles');
         });
     }
     $this->setVal('topWikiArticles', $topWikiArticlesHtml);
 }