Example #1
0
 /**
  * Does a little prep on a result object, applies highlighting if exists, and adds to result array.
  * @param  Result $result
  * @throws WikiaException
  * @return Base provides fluent interface
  */
 protected function addResult(Result $result)
 {
     $id = $result['id'];
     $highlighting = $this->searchResultObject->getHighlighting();
     if ($highlighting !== null && ($hlResult = $highlighting->getResult($id)) && ($field = $hlResult->getField(Utilities::field('html')))) {
         $result->setText($field[0]);
     }
     if ($result['created']) {
         $result->setVar('fmt_timestamp', $this->service->getMediaWikiFormattedTimestamp($result['created']));
         $result->setVar('created_30daysago', time() - strtotime($result['created']) > 2592000);
     }
     $result->setVar('cityArticlesNum', $result['wikiarticles'])->setVar('wikititle', $result[Utilities::field('wikititle')]);
     $this->results[$id] = $result;
     return $this;
 }
Example #2
0
 /**
  * Creates a result instance.
  * @see \Wikia\Search\Match\AbstractMatch::createResult()
  * @return Result
  */
 public function createResult()
 {
     /**@var $this->service Wikia\Search\MediaWikiService*/
     $wikiId = $this->service->getWikiId();
     $pageId = $this->service->getCanonicalPageIdFromPageId($this->id);
     $solrData = $this->getDataFromSolr($wikiId, $pageId);
     $fieldsArray = array('id' => sprintf('%s_%s', $wikiId, $pageId), 'pageid' => $pageId, 'wid' => $wikiId, 'title' => $this->service->getTitleStringFromPageId($this->id), 'url' => $this->service->getUrlFromPageId($this->id), 'score' => 'PTT', 'isArticleMatch' => true, 'ns' => $this->service->getNamespaceFromPageId($this->id), 'created' => $this->service->getFirstRevisionTimestampForPageId($this->id), 'touched' => $this->service->getLastRevisionTimestampForPageId($this->id), 'article_quality_i' => $solrData['article_quality_i']);
     $result = new Result($fieldsArray);
     $snippet = $this->service->getSnippetForPageId($this->id);
     $result->setText($this->matchFoundText($snippet));
     if ($this->hasRedirect()) {
         $result->setVar('redirectTitle', $this->service->getNonCanonicalTitleStringFromPageId($this->id));
         $result->setVar('redirectUrl', $this->service->getNonCanonicalUrlFromPageId($this->id));
     }
     return $result;
 }