summaryrefslogtreecommitdiff
path: root/includes/SpecialPageFactory.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2012-05-03 13:01:35 +0200
committerPierre Schmitz <pierre@archlinux.de>2012-05-03 13:01:35 +0200
commitd9022f63880ce039446fba8364f68e656b7bf4cb (patch)
tree16b40fbf17bf7c9ee6f4ead25b16dd192378050a /includes/SpecialPageFactory.php
parent27cf83d177256813e2e802241085fce5dd0f3fb9 (diff)
Update to MediaWiki 1.19.0
Diffstat (limited to 'includes/SpecialPageFactory.php')
-rw-r--r--includes/SpecialPageFactory.php83
1 files changed, 54 insertions, 29 deletions
diff --git a/includes/SpecialPageFactory.php b/includes/SpecialPageFactory.php
index 2a2e6a4c..0a1631b0 100644
--- a/includes/SpecialPageFactory.php
+++ b/includes/SpecialPageFactory.php
@@ -138,6 +138,7 @@ class SpecialPageFactory {
'Blankpage' => 'SpecialBlankpage',
'Blockme' => 'SpecialBlockme',
'Emailuser' => 'SpecialEmailUser',
+ 'JavaScriptTest' => 'SpecialJavaScriptTest',
'Movepage' => 'MovePageForm',
'Mycontributions' => 'SpecialMycontributions',
'Mypage' => 'SpecialMypage',
@@ -160,6 +161,7 @@ class SpecialPageFactory {
static function getList() {
global $wgSpecialPages;
global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication;
+ global $wgEnableEmail;
if ( !is_object( self::$mList ) ) {
wfProfileIn( __METHOD__ );
@@ -177,6 +179,10 @@ class SpecialPageFactory {
self::$mList['Invalidateemail'] = 'EmailInvalidation';
}
+ if ( $wgEnableEmail ) {
+ self::$mList['ChangeEmail'] = 'SpecialChangeEmail';
+ }
+
// Add extension special pages
self::$mList = array_merge( self::$mList, $wgSpecialPages );
@@ -262,7 +268,7 @@ class SpecialPageFactory {
*/
public static function setGroup( $page, $group ) {
global $wgSpecialPageGroups;
- $name = is_object( $page ) ? $page->mName : $page;
+ $name = is_object( $page ) ? $page->getName() : $page;
$wgSpecialPageGroups[$name] = $group;
}
@@ -272,23 +278,25 @@ class SpecialPageFactory {
* @param $page SpecialPage
*/
public static function getGroup( &$page ) {
+ $name = $page->getName();
+
global $wgSpecialPageGroups;
static $specialPageGroupsCache = array();
- if ( isset( $specialPageGroupsCache[$page->mName] ) ) {
- return $specialPageGroupsCache[$page->mName];
+ if ( isset( $specialPageGroupsCache[$name] ) ) {
+ return $specialPageGroupsCache[$name];
}
- $msg = wfMessage( 'specialpages-specialpagegroup-' . strtolower( $page->mName ) );
+ $msg = wfMessage( 'specialpages-specialpagegroup-' . strtolower( $name ) );
if ( !$msg->isBlank() ) {
$group = $msg->text();
} else {
- $group = isset( $wgSpecialPageGroups[$page->mName] )
- ? $wgSpecialPageGroups[$page->mName]
+ $group = isset( $wgSpecialPageGroups[$name] )
+ ? $wgSpecialPageGroups[$name]
: '-';
}
if ( $group == '-' ) {
$group = 'other';
}
- $specialPageGroupsCache[$page->mName] = $group;
+ $specialPageGroupsCache[$name] = $group;
return $group;
}
@@ -332,16 +340,21 @@ class SpecialPageFactory {
* Return categorised listable special pages which are available
* for the current user, and everyone.
*
+ * @param $user User object to check permissions, $wgUser will be used
+ * if not provided
* @return Array( String => Specialpage )
*/
- public static function getUsablePages() {
- global $wgUser;
+ public static function getUsablePages( User $user = null ) {
$pages = array();
+ if ( $user === null ) {
+ global $wgUser;
+ $user = $wgUser;
+ }
foreach ( self::getList() as $name => $rec ) {
$page = self::getPage( $name );
if ( $page // not null
&& $page->isListed()
- && ( !$page->isRestricted() || $page->userCanExecute( $wgUser ) )
+ && ( !$page->isRestricted() || $page->userCanExecute( $user ) )
) {
$pages[$name] = $page;
}
@@ -417,7 +430,12 @@ class SpecialPageFactory {
if ( !$page ) {
$context->getOutput()->setArticleRelated( false );
$context->getOutput()->setRobotPolicy( 'noindex,nofollow' );
- $context->getOutput()->setStatusCode( 404 );
+
+ global $wgSend404Code;
+ if ( $wgSend404Code ) {
+ $context->getOutput()->setStatusCode( 404 );
+ }
+
$context->getOutput()->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
wfProfileOut( __METHOD__ );
return false;
@@ -462,40 +480,47 @@ class SpecialPageFactory {
}
/**
- * Just like executePath() except it returns the HTML instead of outputting it
- * Returns false if there was no such special page, or a title object if it was
- * a redirect.
+ * Just like executePath() but will override global variables and execute
+ * the page in "inclusion" mode. Returns true if the execution was
+ * successful or false if there was no such special page, or a title object
+ * if it was a redirect.
*
- * Also saves the current $wgTitle, $wgOut, and $wgRequest variables so that
- * the special page will get the context it'd expect on a normal request,
- * and then restores them to their previous values after.
+ * Also saves the current $wgTitle, $wgOut, $wgRequest, $wgUser and $wgLang
+ * variables so that the special page will get the context it'd expect on a
+ * normal request, and then restores them to their previous values after.
*
* @param $title Title
+ * @param $context IContextSource
*
* @return String: HTML fragment
*/
- static function capturePath( &$title ) {
- global $wgOut, $wgTitle, $wgRequest;
+ static function capturePath( Title $title, IContextSource $context ) {
+ global $wgOut, $wgTitle, $wgRequest, $wgUser, $wgLang;
+ // Save current globals
$oldTitle = $wgTitle;
$oldOut = $wgOut;
$oldRequest = $wgRequest;
+ $oldUser = $wgUser;
+ $oldLang = $wgLang;
- // Don't want special pages interpreting ?feed=atom parameters.
- $wgRequest = new FauxRequest( array() );
-
- $context = new RequestContext;
- $context->setTitle( $title );
- $context->setRequest( $wgRequest );
+ // Set the globals to the current context
+ $wgTitle = $title;
$wgOut = $context->getOutput();
+ $wgRequest = $context->getRequest();
+ $wgUser = $context->getUser();
+ $wgLang = $context->getLanguage();
+ // The useful part
$ret = self::executePath( $title, $context, true );
- if ( $ret === true ) {
- $ret = $wgOut->getHTML();
- }
+
+ // And restore the old globals
$wgTitle = $oldTitle;
$wgOut = $oldOut;
$wgRequest = $oldRequest;
+ $wgUser = $oldUser;
+ $wgLang = $oldLang;
+
return $ret;
}
@@ -510,7 +535,7 @@ class SpecialPageFactory {
static function getLocalNameFor( $name, $subpage = false ) {
global $wgContLang;
$aliases = $wgContLang->getSpecialPageAliases();
-
+
if ( isset( $aliases[$name][0] ) ) {
$name = $aliases[$name][0];
} else {