Exemplo n.º 1
0
 /**
  * Override to filter out videos with the same title.
  * @param Result $result
  * @return $this
  */
 protected function addResult(Result $result)
 {
     if (sizeof($this->titleSet) >= $this->searchConfig->getLimit() || isset($this->titleSet[$result->getTitle()])) {
         return $this;
     } else {
         if (wfFindFile(\Title::newFromText($result->getTitle(), NS_FILE)) === false) {
             // file is deleted on this wiki
             return $this;
         } else {
             $this->titleSet[$result->getTitle()] = true;
             return parent::addResult($result);
         }
     }
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 /**
  * @group Slow
  * @slowExecutionTime 0.0991 ms
  * @covers Wikia\Search\Result::replaceUnusualEscapes
  * @covers Wikia\Search\Result::replaceUnusualEscapesCallback
  */
 public function testReplaceUnusualEscapes()
 {
     $this->assertEquals('%5Bfoo+bar%25_%3F!', Result::replaceUnusualEscapes(urlencode('[foo bar%_?!')));
     $this->assertEquals('100%25+Completion', Result::replaceUnusualEscapes(urlencode('100% Completion')));
 }