r91810 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91809‎ | r91810 | r91811 >
Date:21:44, 9 July 2011
Author:ashley
Status:deferred
Tags:
Comment:
it's magic, I tell you!
Modified paths:
  • /trunk/extensions/InterwikiMagic (added) (history)
  • /trunk/extensions/InterwikiMagic/InterwikiMagic.php (added) (history)

Diff [purge]

Index: trunk/extensions/InterwikiMagic/InterwikiMagic.php
@@ -0,0 +1,65 @@
 2+<?php
 3+/**
 4+ * Handle global interwikis and local interlanguage links without adding the
 5+ * interwiki table to $wgSharedTables.
 6+ * If we add 'interwiki' to $wgSharedTables, it will mess up inter*language*
 7+ * links.
 8+ * For example, on fi.24.shoutwiki.com, [[fr:]] should point to
 9+ * fr.24.shoutwiki.com, not to fr.shoutwiki.com.
 10+ *
 11+ * @file
 12+ * @ingroup Extensions
 13+ * @version 1.0
 14+ * @date 3 April 2011 (original patch dated July 12/13, 2009)
 15+ * @author Jack Phoenix <jack@countervandalism.net>
 16+ * @license http://en.wikipedia.org/wiki/Public_domain Public domain
 17+ * @link http://www.mediawiki.org/wiki/Extension:ShoutWiki_Interwiki_Magic Documentation
 18+ * @see http://bugzilla.shoutwiki.com/show_bug.cgi?id=12
 19+ */
 20+
 21+if ( !defined( 'MEDIAWIKI' ) ) {
 22+ die( "This is not a valid entry point to MediaWiki.\n" );
 23+}
 24+
 25+// Extension credits that will show up on Special:Version
 26+$wgExtensionCredits['other'][] = array(
 27+ 'name' => 'ShoutWiki Interwiki Magic',
 28+ 'version' => '1.0',
 29+ 'author' => 'Jack Phoenix',
 30+ 'description' => 'Handle global interwikis and local interlanguage links',
 31+ 'url' => 'http://www.mediawiki.org/wiki/Extension:ShoutWiki_Interwiki_Magic',
 32+);
 33+
 34+// This hook was added in r84173, on 17:51, 17 March 2011
 35+$wgHooks['InterwikiLoadPrefix'][] = 'wfShoutWikiInterwikiMagic';
 36+
 37+/**
 38+ * This function does all the magic for non-language interwikis, i.e. stuff
 39+ * that is /not/ something like "en", "fr", etc.
 40+ *
 41+ * @param $prefix String: interwiki prefix we are looking for
 42+ * @param $iwData Array: output array describing the interwiki with keys
 43+ * iw_url, iw_local, iw_trans and optionally iw_api and
 44+ * iw_wikiid.
 45+ * @return Boolean: true by default, false when fetching interwikis from the
 46+ * shared database ($wgSharedDB)
 47+ */
 48+function wfShoutWikiInterwikiMagic( $prefix, &$iwData ) {
 49+ global $wgContLang, $wgSharedDB;
 50+ if( !$wgContLang->getLanguageName( $prefix ) ) {
 51+ $dbr = wfGetDB( DB_SLAVE, array(), $wgSharedDB );
 52+ $res = $dbr->select(
 53+ 'interwiki',
 54+ '*',
 55+ array( 'iw_prefix' => $prefix ),
 56+ __METHOD__
 57+ );
 58+ $iwData = $dbr->fetchRow( $res );
 59+ // docs/hooks.txt says: Return true without providing an interwiki to
 60+ // continue interwiki search.
 61+ // At this point, we can safely return false because we know that we
 62+ // have something
 63+ return false;
 64+ }
 65+ return true;
 66+}
\ No newline at end of file
Property changes on: trunk/extensions/InterwikiMagic/InterwikiMagic.php
___________________________________________________________________
Added: svn:eol-style
167 + native

Status & tagging log