*
* @file
*
- * @since 1.28
+ * @since 1.29
* @ingroup InterwikiLookup
*
* @license GNU GPL v2+
use Interwiki;
use Site;
use SiteLookup;
-use MediawikiSite;
+use MediaWikiSite;
class InterwikiLookupAdapter implements InterwikiLookup {
* @return bool Whether it exists
*/
public function isValidInterwiki( $prefix ) {
-
return array_key_exists( $prefix, $this->getInterwikiMap() );
}
* See InterwikiLookup::getAllPrefixes
*
* @param string|null $local If set, limits output to local/non-local interwikis
- * @return string[] List of prefixes
+ * @return array[] interwiki rows
*/
public function getAllPrefixes( $local = null ) {
- if ( $local === null ) {
- return array_keys( $this->getInterwikiMap() );
- }
$res = [];
foreach ( $this->getInterwikiMap() as $interwikiId => $interwiki ) {
- if ( $interwiki->isLocal() === $local ) {
- $res[] = $interwikiId;
+ if ( $local === null || $interwiki->isLocal() === $local ) {
+ $res[] = [
+ 'iw_prefix' => $interwikiId,
+ 'iw_url' => $interwiki->getURL(),
+ 'iw_api' => $interwiki->getAPI(),
+ 'iw_wikiid' => $interwiki->getWikiID(),
+ 'iw_local' => $interwiki->isLocal(),
+ 'iw_trans' => $interwiki->isTranscludable(),
+ ];
}
}
return $res;
$interwikis = [];
foreach ( $site->getInterwikiIds() as $interwiki ) {
$url = $site->getPageUrl();
- if ( $site instanceof MediawikiSite ) {
+ if ( $site instanceof MediaWikiSite ) {
$path = $site->getFileUrl( 'api.php' );
} else {
$path = '';