Thread:Extension talk:GlobalUsage/Links under Global file usage/reply (2)

I have put a version that should work on all database naming conventions here, please test

the patch: -- diff -u GlobalUsage/ApiQueryGlobalUsage.php mediawiki-extensions-GlobalUsage/ApiQueryGlobalUsage.php --- GlobalUsage/ApiQueryGlobalUsage.php	2014-09-11 14:58:21.571751756 +0200 +++ mediawiki-extensions-GlobalUsage/ApiQueryGlobalUsage.php	2014-09-11 14:56:48.934133602 +0200 @@ -30,6 +30,7 @@ 	public function execute { $params = $this->extractRequestParams; $prop = array_flip( $params['prop'] ); +		foreach(Interwiki::getAllPrefixes(1) as $k) { $interWikis[$k[iw_wikiid]] = $k[iw_prefix];}; $pageIds = $this->getPageSet->getAllTitlesByNamespace; if ( !empty( $pageIds[NS_FILE] ) ) { @@ -52,6 +53,7 @@ 			foreach ( $query->getResult as $image => $wikis ) { $pageId = intval( $pageIds[$image] ); foreach ( $wikis as $wiki => $result ) { +					$interwiki = Interwiki::fetch($interWikis[$wiki]); foreach ( $result as $item ) { if ( $item['namespace'] ) { $title = "{$item['namespace']}:{$item['title']}"; @@ -60,11 +62,11 @@ 						} 						$result = array( 							'title' => $title, -							'wiki' => WikiMap::getWikiName( $wiki ) +							'wiki' => parse_url($interwiki->getURL, PHP_URL_HOST) 						); if ( isset( $prop['url'] ) ) { /* We expand the url because we don't want protocol relative urls in API results */ -							$result['url'] = wfExpandUrl( WikiMap::getForeignUrl( $item['wiki'], $title ), PROTO_CURRENT ); +							$result['url'] = $interwiki->getURL($title); } 						if ( isset( $prop['pageid'] ) ) { $result['pageid'] = $item['id']; Gemeenschappelijke submappen: GlobalUsage/.git en mediawiki-extensions-GlobalUsage/.git diff -u GlobalUsage/GlobalUsageImagePageHooks.php mediawiki-extensions-GlobalUsage/GlobalUsageImagePageHooks.php --- GlobalUsage/GlobalUsageImagePageHooks.php	2014-09-11 14:58:21.571751756 +0200 +++ mediawiki-extensions-GlobalUsage/GlobalUsageImagePageHooks.php	2014-09-11 14:56:48.938133662 +0200 @@ -42,18 +42,20 @@ 		$context = $imagePage->getContext; $title = $imagePage->getFile->getTitle; $targetName = $title->getText; +		foreach(Interwiki::getAllPrefixes(1) as $k) { $interWikis[$k[iw_wikiid]] = $k[iw_prefix];}; $query = self::getImagePageQuery( $title ); $guHtml = ''; foreach ( $query->getSingleImageResult as $wiki => $result ) { -			$wikiName = WikiMap::getWikiName( $wiki ); +		       $interwiki = Interwiki::fetch($interWikis[$wiki]); +                      $wikiName = parse_url($interwiki->getURL, PHP_URL_HOST); $escWikiName = Sanitizer::escapeClass( $wikiName ); $guHtml .= "". $context->msg( 				'globalusage-on-wiki', 				$targetName, $wikiName )->parse. "\n"; foreach ( $result as $item ) -				$guHtml .= "\t". SpecialGlobalUsage::formatItem( $item ). "\n"; +				$guHtml .= "\t". SpecialGlobalUsage::formatItem( $item, $interwiki ). "\n"; $guHtml .= "\n"; } Gemeenschappelijke submappen: GlobalUsage/i18n en mediawiki-extensions-GlobalUsage/i18n Gemeenschappelijke submappen: GlobalUsage/patches en mediawiki-extensions-GlobalUsage/patches diff -u GlobalUsage/SpecialGlobalUsage.php mediawiki-extensions-GlobalUsage/SpecialGlobalUsage.php --- GlobalUsage/SpecialGlobalUsage.php	2014-09-11 14:58:21.571751756 +0200 +++ mediawiki-extensions-GlobalUsage/SpecialGlobalUsage.php	2014-09-11 14:56:48.938133662 +0200 @@ -91,6 +91,7 @@ 	private function showResult { $query = new GlobalUsageQuery( $this->target ); $request = $this->getRequest; +              foreach(Interwiki::getAllPrefixes(1) as $k) {  $interWikis[$k[iw_wikiid]] = $k[iw_prefix];}; // Extract params from $request. if ( $request->getText( 'from' ) ) { @@ -119,13 +120,14 @@ 		$out->addHtml( ' ' ); foreach ( $query->getSingleImageResult as $wiki => $result ) { +			$interwiki = Interwiki::fetch($interWikis[$wiki]); $out->addHtml( 				' ' . $this->msg( 'globalusage-on-wiki', -					$targetName, WikiMap::getWikiName( $wiki ) )->parse +                                      $targetName,  parse_url($interwiki->getURL, PHP_URL_HOST)  )->parse . " \n" ); 			foreach ( $result as $item ) { -				$out->addHtml( "\t". self::formatItem( $item ). "\n" ); +				$out->addHtml( "\t". self::formatItem( $item, $interwiki ). "\n" ); 			} 			$out->addHtml( "\n" ); 		} @@ -140,15 +142,14 @@ 	 * @param $item array 	 * @return String 	 */ -	public static function formatItem( $item ) { +	public static function formatItem( $item, $interwiki ) { 		if ( !$item['namespace'] ) { 			$page = $item['title']; 		} else { 			$page = "{$item['namespace']}:{$item['title']}"; 		} -		$link = WikiMap::makeForeignLink( $item['wiki'], $page, -			str_replace( '_', ' ', $page ) ); +              $link = Linker::makeExternalLink( $interwiki->getURL($page), str_replace( '_', ' ', $page )); 		// Return only the title if no link can be constructed 		return $link === false ? $page : $link; 	}

--