protected $mPrefix, $mURL, $mLocal, $mTrans;
- function __construct( $prefix = null, $url = '', $local = 0, $trans = 0 ) {
+ public function __construct( $prefix = null, $url = '', $local = 0, $trans = 0 ) {
$this->mPrefix = $prefix;
$this->mURL = $url;
$this->mLocal = $local;
/**
* Check whether an interwiki prefix exists
- *
- * @return bool Whether it exists
- * @param $prefix string Interwiki prefix to use
+ *
+ * @param $prefix String: interwiki prefix to use
+ * @return Boolean: whether it exists
*/
static public function isValidInterwiki( $prefix ) {
$result = self::fetch( $prefix );
/**
* Fetch an Interwiki object
- *
+ *
+ * @param $prefix String: interwiki prefix to use
* @return Interwiki Object, or null if not valid
- * @param $prefix string Interwiki prefix to use
*/
static public function fetch( $prefix ) {
global $wgContLang;
*
* @note More logic is explained in DefaultSettings.
*
- * @param $prefix \type{\string} Interwiki prefix
- * @return \type{\Interwiki} An interwiki object
+ * @param $prefix String: interwiki prefix
+ * @return Interwiki object
*/
protected static function getInterwikiCached( $prefix ) {
$value = self::getInterwikiCacheEntry( $prefix );
*
* @note More logic is explained in DefaultSettings.
*
- * @param $prefix \type{\string} Database key
- * @return \type{\string) The entry
+ * @param $prefix String: database key
+ * @return String: the entry
*/
protected static function getInterwikiCacheEntry( $prefix ) {
global $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite;
wfDebug( __METHOD__ . "( $prefix )\n" );
if( !$db ) {
- $db = dba_open( $wgInterwikiCache, 'r', 'cdb' );
+ $db = CdbReader::open( $wgInterwikiCache );
}
/* Resolve site name */
if( $wgInterwikiScopes>=3 && !$site ) {
- $site = dba_fetch( '__sites:' . wfWikiID(), $db );
+ $site = $db->get( '__sites:' . wfWikiID() );
if ( $site == '' ) {
$site = $wgInterwikiFallbackSite;
}
}
- $value = dba_fetch( wfMemcKey( $prefix ), $db );
+ $value = $db->get( wfMemcKey( $prefix ) );
// Site level
if ( $value == '' && $wgInterwikiScopes >= 3 ) {
- $value = dba_fetch( "_{$site}:{$prefix}", $db );
+ $value = $db->get( "_{$site}:{$prefix}" );
}
// Global Level
if ( $value == '' && $wgInterwikiScopes >= 2 ) {
- $value = dba_fetch( "__global:{$prefix}", $db );
+ $value = $db->get( "__global:{$prefix}" );
}
if ( $value == 'undef' )
$value = '';
* Load the interwiki, trying first memcached then the DB
*
* @param $prefix The interwiki prefix
- * @return bool The prefix is valid
- * @static
+ * @return Boolean: the prefix is valid
*/
protected static function load( $prefix ) {
global $wgMemc, $wgInterwikiExpiry;
/**
* Fill in member variables from an array (e.g. memcached result, Database::fetchRow, etc)
*
- * @return bool Whether everything was there
- * @param $res ResultWrapper Row from the interwiki table
- * @static
+ * @param $mc Associative array: row from the interwiki table
+ * @return Boolean: whether everything was there
*/
protected static function loadFromArray( $mc ) {
if( isset( $mc['iw_url'] ) && isset( $mc['iw_local'] ) && isset( $mc['iw_trans'] ) ) {
/**
* Get the URL for a particular title (or with $1 if no title given)
*
- * @param $title string What text to put for the article name
- * @return string The URL
+ * @param $title String: what text to put for the article name
+ * @return String: the URL
*/
- function getURL( $title = null ) {
+ public function getURL( $title = null ) {
$url = $this->mURL;
if( $title != null ) {
$url = str_replace( "$1", $title, $url );
return $url;
}
- function isLocal() {
+ /**
+ * Is this a local link from a sister project, or is
+ * it something outside, like Google
+ *
+ * @return Boolean
+ */
+ public function isLocal() {
return $this->mLocal;
}
- function isTranscludable() {
+ /**
+ * Can pages from this wiki be transcluded?
+ * Still requires $wgEnableScaryTransclusion
+ *
+ * @return Boolean
+ */
+ public function isTranscludable() {
return $this->mTrans;
}
+ /**
+ * Get the name for the interwiki site
+ *
+ * @return String
+ */
+ public function getName() {
+ $key = 'interwiki-name-' . $this->mPrefix;
+ $msg = wfMsgForContent( $key );
+ return wfEmptyMsg( $key, $msg ) ? '' : $msg;
+ }
+
+ /**
+ * Get a description for this interwiki
+ *
+ * @return String
+ */
+ public function getDescription() {
+ $key = 'interwiki-desc-' . $this->mPrefix;
+ $msg = wfMsgForContent( $key );
+ return wfEmptyMsg( $key, $msg ) ? '' : $msg;
+ }
}