/** * Used in the related videos module to get both premium and on-wiki videos. * @param WikiaSearchConfig $searchConfig * @return WikiaSearchResultSet */ public function getRelatedVideos(WikiaSearchConfig $searchConfig) { wfProfileIn(__METHOD__); $filterQuery = sprintf('(%s OR %s) AND %s', self::valueForField('wid', $searchConfig->getCityId()), self::valueForField('wid', self::VIDEO_WIKI_ID, array('boost' => 2)), self::valueForField('is_video', 'true')); $query = self::valueForField('wid', $searchConfig->getCityId()); if ($searchConfig->getPageId() != false) { $query .= sprintf(' AND %s', self::valueForField('pageid', $searchConfig->getPageId())); } else { // tweakable heuristic: // the document frequency for the interesting terms needs to be at least 50% of the wiki's pages $data = $this->callMediaWikiAPI(array('action' => 'query', 'prop' => 'info|categories', 'inprop' => 'url|created|views|revcount', 'meta' => 'siteinfo', 'siprop' => 'statistics|wikidesc|variables|namespaces|category')); if (isset($data['query']) && isset($data['query']['statistics']) && isset($data['query']['statistics']['articles'])) { $searchConfig->setMindf((int) ($data['query']['statistics']['articles'] * 0.5)); } $query .= ' AND ' . self::valueForField('iscontent', 'true'); } $searchConfig->setQuery($query)->setMltFilterQuery($filterQuery)->setMltFields(array(self::field('title'), self::field('html'), 'title')); wfProfileOut(__METHOD__); return $this->moreLikeThis($searchConfig); }