r92358 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92357‎ | r92358 | r92359 >
Date:14:51, 16 July 2011
Author:robin
Status:resolved (Comments)
Tags:
Comment:
Add a simple special page that goes to the main page of your test wiki.
Modified paths:
  • /trunk/extensions/WikimediaIncubator/SpecialMyMainPage.php (added) (history)
  • /trunk/extensions/WikimediaIncubator/WikimediaIncubator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.php
@@ -13,7 +13,7 @@
1414 'path' => __FILE__,
1515 'name' => 'Wikimedia Incubator',
1616 'author' => 'SPQRobin',
17 - 'version' => '3.1.1',
 17+ 'version' => '3.2',
1818 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaIncubator',
1919 'descriptionmsg' => 'wminc-desc',
2020 );
@@ -74,6 +74,10 @@
7575 $wgHooks['LanguageGetMagic'][] = 'IncubatorTest::magicWord';
7676 $wgHooks['ParserGetVariableValueSwitch'][] = 'IncubatorTest::magicWordValue';
7777
 78+/* Special:MyMainPage (depending on your test wiki preference) */
 79+$wgAutoloadClasses['SpecialMyMainPage'] = $dir . 'SpecialMyMainPage.php';
 80+$wgSpecialPages['MyMainPage'] = 'SpecialMyMainPage';
 81+
7882 /* Create/move page permissions */
7983 $wgHooks['getUserPermissionsErrors'][] = 'IncubatorTest::checkPrefixCreatePermissions';
8084 $wgHooks['AbortMove'][] = 'IncubatorTest::checkPrefixMovePermissions';
Index: trunk/extensions/WikimediaIncubator/SpecialMyMainPage.php
@@ -0,0 +1,39 @@
 2+<?php
 3+/**
 4+ * Special page to go to the Main Page, depending on your test wiki.
 5+ * Goes to the default Main Page if the test wiki preference
 6+ * is set to None/All or Incubator.
 7+ *
 8+ * @file
 9+ * @ingroup SpecialPage
 10+ */
 11+
 12+class SpecialMyMainPage extends UnlistedSpecialPage {
 13+
 14+ public function __construct() {
 15+ parent::__construct( 'MyMainPage' );
 16+ }
 17+
 18+ public function execute() {
 19+ global $wgOut;
 20+
 21+ $title = '';
 22+ $params = array();
 23+
 24+ if( IncubatorTest::isContentProject() ) {
 25+ global $wgRequest;
 26+ $title = Title::newFromText( IncubatorTest::displayPrefix() );
 27+ if( $wgRequest->getVal( 'goto' ) != 'infopage' ) {
 28+ # Used in development version
 29+ $params = array( 'goto' => 'mainpage' );
 30+ }
 31+ }
 32+
 33+ # Go to the main page if given invalid title, or if it's not a content project
 34+ if ( !$title ) {
 35+ $title = Title::newMainPage();
 36+ }
 37+
 38+ $wgOut->redirect( $title->getLocalURL( $params ) );
 39+ }
 40+}
\ No newline at end of file
Property changes on: trunk/extensions/WikimediaIncubator/SpecialMyMainPage.php
___________________________________________________________________
Added: svn:eol-style
141 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r92363Follow-up r92358: per Jack Phoenix, add default parameter for execute() even ...robin16:02, 16 July 2011
r94466Per CR comment on r92358, add a special page aliases file for WikimediaIncubatorcatrope18:14, 14 August 2011

Comments

#Comment by Raymond (talk | contribs)   14:59, 16 July 2011

Suggestion: Add an alias file for the special page.

#Comment by SPQRobin (talk | contribs)   15:06, 16 July 2011

It's not really needed, as the special page redirects directly to another page, and the chance that this extension is used on a non-English wiki is tiny.

#Comment by Nikerabbit (talk | contribs)   12:47, 20 July 2011

I'm pretty sure that the code will complain if no alias is defined. No need to translate it though.

#Comment by SPQRobin (talk | contribs)   19:11, 22 July 2011

In what way would the code complain? I didn't define an alias for SpecialMyMainPage or SpecialViewUserLang and they both work.

#Comment by Jack Phoenix (talk | contribs)   15:08, 16 July 2011
+	public function execute() {

Needs the default parameter ($par), even if you don't use it, to make PHP happy.

#Comment by SPQRobin (talk | contribs)   16:02, 16 July 2011

Really? Meh. Anyway, done in r92363.

Status & tagging log