function query() { global $wgRequest, $wgHTTPProxy; $query = $wgRequest->getText('query'); $page = $wgRequest->getVal('page', 1); $sourceId = $wgRequest->getVal('sourceId'); if ($sourceId == 1) { $flickrAPI = new phpFlickr('bac0bd138f5d0819982149f67c0ca734'); $proxyArr = explode(':', $wgHTTPProxy); $flickrAPI->setProxy($proxyArr[0], $proxyArr[1]); $flickrResult = $flickrAPI->photos_search(array('tags' => $query, 'tag_mode' => 'all', 'page' => $page, 'per_page' => 8, 'license' => '4,5', 'sort' => 'interestingness-desc')); $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/'); $tmpl->set_vars(array('results' => $flickrResult, 'query' => addslashes($query))); return $tmpl->render('results_flickr'); } else { if ($sourceId == 0) { if ((int) $page == 0) { $page = 1; } $mediaService = new MediaQueryService(); $results = $mediaService->searchInTitle($query, $page, 8); $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/'); $tmpl->set_vars(array('results' => $results, 'query' => addslashes($query))); return $tmpl->render('results_thiswiki'); } } }
/** * Return thumbs of images search result */ public static function getSearchResultThumbs($query, $limit = 50) { wfProfileIn(__METHOD__); $images = array(); if (!empty($query)) { $mediaService = new MediaQueryService(); $results = $mediaService->searchInTitle($query, 1, $limit); if (!empty($results['images'])) { foreach ($results['images'] as $img) { $oImageTitle = Title::newFromText($img['title'], NS_FILE); $thumb = self::getResultsThumbnailUrl($oImageTitle); if ($thumb) { $images[] = array('name' => $oImageTitle->getText(), 'thumb' => $thumb); } } } } wfProfileOut(__METHOD__); return $images; }