/** * 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; }