<?php // get wiki thumbnail and thumbnail tracking $isOnWikiMatch = isset($result['onWikiMatch']) && $result['onWikiMatch']; $imageFileName = PromoImage::fromPathname($result['image_s'])->ensureCityIdIsSet($result['id'])->getPathname(); $imageOriginalURL = ImagesService::getImageSrcByTitle($corporateWikiId, $imageFileName, WikiaSearchController::CROSS_WIKI_PROMO_THUMBNAIL_WIDTH, WikiaSearchController::CROSS_WIKI_PROMO_THUMBNAIL_HEIGHT); if (!empty($imageOriginalURL)) { $imageURL = ImagesService::overrideThumbnailFormat($imageOriginalURL, ImagesService::EXT_JPG); $thumbTracking = 'class="wiki-thumb-tracking" data-pos="' . $pos . '" data-event="search_click_wiki-thumb"'; } if (empty($imageURL)) { // display placeholder image if no thumbnail $imageURL = $wg->ExtensionsPath . '/wikia/Search/images/wiki_image_placeholder.png'; $thumbTracking = 'class="wiki-thumb-tracking" data-pos="' . $pos . '" data-event="search_click_wiki-no-thumb"'; } $service = new Wikia\Search\MediaWikiService(); $pagesMsg = $service->shortnumForMsg($result['articles_i'] ?: 0, 'wikiasearch2-pages'); $imgMsg = $service->shortnumForMsg($result['images_i'] ?: 0, 'wikiasearch2-images'); $videoMsg = $service->shortnumForMsg($result['videos_i'] ?: 0, 'wikiasearch2-videos'); $title = ($sn = $result->getText('sitename_txt')) ? $sn : $result->getText('headline_txt'); $url = $result->getText('url'); ?> <li class="result"> <?php $suffix = $result['exactWikiMatch'] ? "match" : "wiki"; $trackingData = 'class="result-link" data-pos="' . $pos . '" data-event="search_click_' . $suffix . '"'; ?> <a href="<?php echo $url; ?>
<?php // get wiki thumbnail and thumbnail tracking $image = (new PromoImage(PromoImage::MAIN))->setCityId($result['id'])->getPathname(); $isOnWikiMatch = isset($result['onWikiMatch']) && $result['onWikiMatch']; $thumbTracking = 'class="wiki-thumb-tracking" data-pos="' . $pos . '" data-event="search_click_wiki-thumb"'; $imageURL = ImagesService::getImageSrcByTitle((new CityVisualization())->getTargetWikiId($result['lang_s']), $image, WikiaSearchController::CROSS_WIKI_PROMO_THUMBNAIL_WIDTH, WikiaSearchController::CROSS_WIKI_PROMO_THUMBNAIL_HEIGHT); if (empty($imageURL)) { // display placeholder image if no thumbnail $imageURL = $wg->ExtensionsPath . '/wikia/Search/images/wiki_image_placeholder.png'; $thumbTracking = 'class="wiki-thumb-tracking" data-pos="' . $pos . '" data-event="search_click_wiki-no-thumb"'; } $service = new Wikia\Search\MediaWikiService(); $pagesMsg = $service->shortnumForMsg($result['articles_i'] ?: 0, 'wikiasearch2-pages'); $imgMsg = $service->shortnumForMsg($result['images_i'] ?: 0, 'wikiasearch2-images'); $videoMsg = $service->shortnumForMsg($result['videos_i'] ?: 0, 'wikiasearch2-videos'); $title = ($sn = $result->getText('sitename_txt')) ? $sn : $result->getText('headline_txt'); $url = $result->getText('url'); ?> <div class="Results exact"> <p class="result-count subtle"> <?php echo wfMsg('wikiasearch2-exact-result', '<strong>' . $title . '</strong>'); ?> </p> <div class="result"> <?php $trackingData = 'class="result-link" data-pos="' . $pos . '"';
protected function getImageSrcByTitle($wikiId, $imageTitle, $imgWidth, $imgHeight) { return ImagesService::getImageSrcByTitle($wikiId, $imageTitle, $imgWidth, $imgHeight); }
/** * @desc Uses ImagesService to create an image URL * * @param String $imageTitle * @param int $width optional * @param int $height optional * * @return bool|null|Object|string */ private function getImage($imageTitle, $width = self::IMG_WIDTH_SMALL, $height = self::IMG_HEIGHT_SMALL) { return ImagesService::getImageSrcByTitle($this->cityId, $imageTitle, $width, $height); }