r45625 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45624‎ | r45625 | r45626 >
Date:00:54, 10 January 2009
Author:siebrand
Status:deferred
Tags:
Comment:
* Add extension Redirect for easy configuration of redirects on account creation and logout
* Add support for Redirect to Configure and Translate
Modified paths:
  • /trunk/extensions/Configure/CHANGELOG (modified) (history)
  • /trunk/extensions/Configure/Configure.php (modified) (history)
  • /trunk/extensions/Configure/Configure.settings-ext.php (modified) (history)
  • /trunk/extensions/Redirect (added) (history)
  • /trunk/extensions/Redirect/Redirect.class.php (added) (history)
  • /trunk/extensions/Redirect/Redirect.i18n.php (added) (history)
  • /trunk/extensions/Redirect/Redirect.php (added) (history)
  • /trunk/extensions/Translate/groups/mediawiki-defines.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/Redirect/Redirect.i18n.php
@@ -0,0 +1,18 @@
 2+<?php
 3+/**
 4+ * Internationalisation file for the Redirect extension.
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+$messages = array();
 11+
 12+/** English
 13+ * @author Siebrand Mazeland
 14+ */
 15+$messages['en'] = array(
 16+ 'redirect-desc' => 'Allows easy configuration of redirects on [[MediaWiki:Redirect-addnewaccount|account creation]] and [[MediaWiki:Redirect-userlogoutcomplete|logout]]',
 17+ 'redirect-addnewaccount' => '', # do not translate or duplicate this message to other languages
 18+ 'redirect-userlogoutcomplete' => '', # do not translate or duplicate this message to other languages
 19+);
Property changes on: trunk/extensions/Redirect/Redirect.i18n.php
___________________________________________________________________
Name: svn:eol-style
120 + native
Index: trunk/extensions/Redirect/Redirect.php
@@ -0,0 +1,34 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
 4+/**
 5+ * An extension for easy customisation of redirects on various events
 6+ *
 7+ * Simple, default scenario:
 8+ * For redirect on account creation: add the title of a local wiki page to [[MediaWiki:Redirect-addnewaccount]]
 9+ * For redirect after logout: add the title of a local wiki page to [[MediaWiki:Redirect-userlogoutcomplete]]
 10+ *
 11+ * This extension is a adaptation of 2 previously published extensions:
 12+ * http://www.mediawiki.org/wiki/Extension:RedirectOnAccountCreation (Public Domain)
 13+ * http://www.mediawiki.org/wiki/Extension:RedirectAfterLogout (Public Domain)
 14+ *
 15+ * @addtogroup Extensions
 16+ *
 17+ * @author Marcel Minke
 18+ * @author Siebrand Mazeland
 19+ * @license Creative Commons Attribution 3.0 Unported (http://creativecommons.org/licenses/by/3.0/)
 20+ */
 21+
 22+$wgExtensionCredits['other'][] = array(
 23+ 'name' => 'Redirect',
 24+ 'version' => '1.0',
 25+ 'author' => array( 'Marcel Minke', 'Siebrand Mazeland' ),
 26+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Redirect',
 27+ 'descriptionmsg' => 'redirect-desc',
 28+);
 29+
 30+$dir = dirname( __FILE__ ) . '/';
 31+$wgExtensionMessagesFiles['Redirect'] = $dir . 'Redirect.i18n.php';
 32+$wgAutoloadClasses['RedirectHooks'] = $dir . 'Redirect.class.php';
 33+
 34+$wgHooks['AddNewAccount'][] = 'RedirectHooks::afterAddNewAccount';
 35+$wgHooks['UserLogout'][] = 'RedirectHooks::afterUserLogoutComplete';
Property changes on: trunk/extensions/Redirect/Redirect.php
___________________________________________________________________
Name: svn:eol-style
136 + native
Index: trunk/extensions/Redirect/Redirect.class.php
@@ -0,0 +1,43 @@
 2+<?php
 3+/**
 4+ * Hooks for Redirect extension
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+class RedirectHooks {
 11+ public static function afterAddNewAccount( $user, $byEmail ) {
 12+ // Do nothing if account creation was by e-mail
 13+ if ( $byEmail ) {
 14+ return true;
 15+ }
 16+
 17+ return self::addRedirect( 'addnewaccount' );
 18+ }
 19+
 20+ public static function afterUserLogoutComplete( &$user ) {
 21+ return self::addRedirect( 'userlogoutcomplete' );
 22+ }
 23+
 24+ private static function addRedirect( $hookName ) {
 25+ global $wgOut, $wgServer, $wgScript;
 26+
 27+ wfLoadExtensionMessages( 'Redirect' );
 28+
 29+ $targetPage = wfMsgForContent( 'redirect-' . $hookName );
 30+
 31+ // Default for message is empty. Do nothing.
 32+ if ( $targetPage == '' ) {
 33+ return true;
 34+ }
 35+
 36+ $target = Title::newFromText( $targetPage );
 37+
 38+ if ( $target->isKnown() ) {
 39+ $wgOut->redirect( $wgServer . $wgScript . "?title=" . $target );
 40+ }
 41+
 42+ return true;
 43+ }
 44+}
Property changes on: trunk/extensions/Redirect/Redirect.class.php
___________________________________________________________________
Name: svn:eol-style
145 + native
Index: trunk/extensions/Configure/CHANGELOG
@@ -1,6 +1,9 @@
22 This file lists changes on this extension.
33 Localisation updates are done on betawiki and aren't listed here.
44
 5+0.11.7 - 10 January 2009
 6+ * Added support for Redirect
 7+
58 0.11.6 - 7 January 2009
69 * Added support for OpenID, NewUserMessage and ReplaceText extensions.
710 * Updated GoogleAdSense extension.
Index: trunk/extensions/Configure/Configure.php
@@ -17,7 +17,7 @@
1818 'url' => 'http://www.mediawiki.org/wiki/Extension:Configure',
1919 'description' => 'Allow authorised users to configure the wiki via a web-based interface',
2020 'descriptionmsg' => 'configure-desc',
21 - 'version' => '0.11.6',
 21+ 'version' => '0.11.7',
2222 );
2323
2424 # Configuration part
Index: trunk/extensions/Configure/Configure.settings-ext.php
@@ -928,6 +928,10 @@
929929
930930 // R
931931 array(
 932+ 'name' => 'Redirect',
 933+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Redirect',
 934+ ),
 935+ array(
932936 'name' => 'Renameuser',
933937 'file' => 'SpecialRenameuser.php',
934938 'url' => 'http://www.mediawiki.org/wiki/Extension:Renameuser',
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt
@@ -590,6 +590,9 @@
591591
592592 Record Admin
593593
 594+Redirect
 595+ignored = redirect-addnewaccount, redirect-userlogincomplete, redirect-userlogoutcomplete
 596+
594597 Refresh Special
595598
596599 Regex Block

Status & tagging log