r71071 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71070‎ | r71071 | r71072 >
Date:14:04, 14 August 2010
Author:jeroendedauw
Status:resolved (Comments)
Tags:
Comment:
Added function to get extension type messages
Modified paths:
  • /trunk/phase3/includes/specials/SpecialVersion.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialVersion.php
@@ -27,23 +27,26 @@
2828 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
2929 */
3030 class SpecialVersion extends SpecialPage {
31 - private $firstExtOpened = false;
 31+
 32+ protected $firstExtOpened = false;
3233
33 - static $viewvcUrls = array(
 34+ protected static $extensionTypes = false;
 35+
 36+ protected static $viewvcUrls = array(
3437 'svn+ssh://svn.wikimedia.org/svnroot/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki',
3538 'http://svn.wikimedia.org/svnroot/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki',
3639 # Doesn't work at the time of writing but maybe some day:
3740 'https://svn.wikimedia.org/viewvc/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki',
3841 );
3942
40 - function __construct(){
 43+ public function __construct(){
4144 parent::__construct( 'Version' );
4245 }
4346
4447 /**
4548 * main()
4649 */
47 - function execute( $par ) {
 50+ public function execute( $par ) {
4851 global $wgOut, $wgSpecialVersionShowHooks, $wgContLang;
4952
5053 $this->setHeaders();
@@ -210,20 +213,36 @@
211214 * @return array
212215 */
213216 public static function getExtensionTypes() {
214 - $extensionTypes = array(
215 - 'specialpage' => wfMsg( 'version-specialpages' ),
216 - 'parserhook' => wfMsg( 'version-parserhooks' ),
217 - 'variable' => wfMsg( 'version-variables' ),
218 - 'media' => wfMsg( 'version-mediahandlers' ),
219 - 'other' => wfMsg( 'version-other' ),
220 - );
 217+ if ( self::$extensionTypes === false ) {
 218+ self::$extensionTypes = array(
 219+ 'specialpage' => wfMsg( 'version-specialpages' ),
 220+ 'parserhook' => wfMsg( 'version-parserhooks' ),
 221+ 'variable' => wfMsg( 'version-variables' ),
 222+ 'media' => wfMsg( 'version-mediahandlers' ),
 223+ 'other' => wfMsg( 'version-other' ),
 224+ );
 225+
 226+ wfRunHooks( 'ExtensionTypes', array( &self::$extensionTypes ) );
 227+ }
221228
222 - wfRunHooks( 'ExtensionTypes', array( &$extensionTypes ) );
223 -
224 - return $extensionTypes;
 229+ return self::$extensionTypes;
225230 }
226231
227232 /**
 233+ * Returns the internationalized name for an extension type.
 234+ *
 235+ * @since 1.17
 236+ *
 237+ * @param $type String
 238+ *
 239+ * @return string
 240+ */
 241+ public static function getExtensionTypeName( $type ) {
 242+ $types = self::getExtensionTypes();
 243+ return $types[$type];
 244+ }
 245+
 246+ /**
228247 * Generate wikitext showing extensions name, URL, author and description.
229248 *
230249 * @return String: Wikitext

Follow-up revisions

RevisionCommit summaryAuthorDate
r79704Fix fixme on r71071, if passed type is not in the array returned by getExtens...reedy02:30, 6 January 2011

Comments

#Comment by Nikerabbit (talk | contribs)   15:46, 14 August 2010
+		$types = self::getExtensionTypes();
+		return $types[$type];

Can produce PHP notice with undefined index.

#Comment by Reedy (talk | contribs)   02:07, 30 December 2010

Marking as fixme per Nikerabbit

#Comment by Reedy (talk | contribs)   02:30, 6 January 2011

Returning the 'other' type if the type provided isn't found in the array

Status & tagging log