From bb844233edac53db4db5c5b17942e03f2cdc3ff9 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Sat, 25 Jul 2009 14:28:53 +0000 Subject: [PATCH] (bug 10812) Interwiki links can have names and descriptions, fetched from message 'interwiki-desc-PREFIX', not really used anywhere yet though --- RELEASE-NOTES | 2 ++ includes/Interwiki.php | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1cf190a457..f57b8b9df8 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -161,6 +161,8 @@ this. Was used when mwEmbed was going to be an extension. * (bug 19900) The "listgrouprights-key" message is now wrapped in a div with class "mw-listgrouprights-key" * (bug 471) Allow RSS feeds for watchlist, using an opt-in security token +* (bug 10812) Interwiki links can have names and descriptions, fetched from + message 'interwiki-desc-PREFIX', not really used anywhere yet though === Bug fixes in 1.16 === diff --git a/includes/Interwiki.php b/includes/Interwiki.php index 5ca926297a..69bcd1ee23 100644 --- a/includes/Interwiki.php +++ b/includes/Interwiki.php @@ -17,7 +17,7 @@ class Interwiki { 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; @@ -186,7 +186,7 @@ class Interwiki { * @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 ); @@ -194,12 +194,41 @@ class Interwiki { return $url; } - function isLocal() { + /** + * Is this a local link from a sister project, or is + * it something outside, like Google + * @return bool + */ + public function isLocal() { return $this->mLocal; } - function isTranscludable() { + /** + * Can pages from this wiki be transcluded? + * Still requires $wgEnableScaryTransclusion + * @return bool + */ + 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; + } } -- 2.20.1