summaryrefslogtreecommitdiff
path: root/includes/SpecialPage.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2008-08-15 01:29:47 +0200
committerPierre Schmitz <pierre@archlinux.de>2008-08-15 01:29:47 +0200
commit370e83bb0dfd0c70de268c93bf07ad5ee0897192 (patch)
tree491674f4c242e4d6ba0d04eafa305174c35a3391 /includes/SpecialPage.php
parentf4debf0f12d0524d2b2427c55ea3f16b680fad97 (diff)
Update auf 1.13.0
Diffstat (limited to 'includes/SpecialPage.php')
-rw-r--r--includes/SpecialPage.php170
1 files changed, 120 insertions, 50 deletions
diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php
index c9037ea7..d6ad6e6e 100644
--- a/includes/SpecialPage.php
+++ b/includes/SpecialPage.php
@@ -2,32 +2,30 @@
/**
* SpecialPage: handling special pages and lists thereof.
*
- * To add a special page in an extension, add to $wgSpecialPages either
- * an object instance or an array containing the name and constructor
- * parameters. The latter is preferred for performance reasons.
+ * To add a special page in an extension, add to $wgSpecialPages either
+ * an object instance or an array containing the name and constructor
+ * parameters. The latter is preferred for performance reasons.
*
- * The object instantiated must be either an instance of SpecialPage or a
- * sub-class thereof. It must have an execute() method, which sends the HTML
- * for the special page to $wgOut. The parent class has an execute() method
- * which distributes the call to the historical global functions. Additionally,
- * execute() also checks if the user has the necessary access privileges
+ * The object instantiated must be either an instance of SpecialPage or a
+ * sub-class thereof. It must have an execute() method, which sends the HTML
+ * for the special page to $wgOut. The parent class has an execute() method
+ * which distributes the call to the historical global functions. Additionally,
+ * execute() also checks if the user has the necessary access privileges
* and bails out if not.
*
- * To add a core special page, use the similar static list in
+ * To add a core special page, use the similar static list in
* SpecialPage::$mList. To remove a core static special page at runtime, use
* a SpecialPage_initList hook.
*
- * @addtogroup SpecialPage
- */
-
-/**
- * @access private
+ * @file
+ * @ingroup SpecialPage
+ * @defgroup SpecialPage SpecialPage
*/
/**
* Parent special page class, also static functions for handling the special
* page list.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
*/
class SpecialPage
{
@@ -72,7 +70,15 @@ class SpecialPage
* Query parameters that can be passed through redirects
*/
var $mAllowedRedirectParams = array();
-
+ /**
+ * List of special pages, followed by parameters.
+ * If the only parameter is a string, that is the page name.
+ * Otherwise, it is an array. The format is one of:
+ ** array( 'SpecialPage', name, right )
+ ** array( 'IncludableSpecialPage', name, right, listed? )
+ ** array( 'UnlistedSpecialPage', name, right )
+ ** array( 'SpecialRedirectToSpecial', name, page to redirect to, special page param, ... )
+ */
static public $mList = array(
'DoubleRedirects' => array( 'SpecialPage', 'DoubleRedirects' ),
'BrokenRedirects' => array( 'SpecialPage', 'BrokenRedirects' ),
@@ -84,11 +90,12 @@ class SpecialPage
'Preferences' => array( 'SpecialPage', 'Preferences' ),
'Watchlist' => array( 'SpecialPage', 'Watchlist' ),
- 'Recentchanges' => array( 'IncludableSpecialPage', 'Recentchanges' ),
+ 'Recentchanges' => 'SpecialRecentchanges',
'Upload' => array( 'SpecialPage', 'Upload' ),
'Imagelist' => array( 'SpecialPage', 'Imagelist' ),
'Newimages' => array( 'IncludableSpecialPage', 'Newimages' ),
'Listusers' => array( 'SpecialPage', 'Listusers' ),
+ 'Listgrouprights' => 'SpecialListGroupRights',
'Statistics' => array( 'SpecialPage', 'Statistics' ),
'Randompage' => 'Randompage',
'Lonelypages' => array( 'SpecialPage', 'Lonelypages' ),
@@ -109,7 +116,7 @@ class SpecialPage
'Fewestrevisions' => array( 'SpecialPage', 'Fewestrevisions' ),
'Shortpages' => array( 'SpecialPage', 'Shortpages' ),
'Longpages' => array( 'SpecialPage', 'Longpages' ),
- 'Newpages' => array( 'IncludableSpecialPage', 'Newpages' ),
+ 'Newpages' => 'SpecialNewpages',
'Ancientpages' => array( 'SpecialPage', 'Ancientpages' ),
'Deadendpages' => array( 'SpecialPage', 'Deadendpages' ),
'Protectedpages' => array( 'SpecialPage', 'Protectedpages' ),
@@ -121,7 +128,7 @@ class SpecialPage
'Contributions' => array( 'SpecialPage', 'Contributions' ),
'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ),
'Whatlinkshere' => array( 'SpecialPage', 'Whatlinkshere' ),
- 'Recentchangeslinked' => array( 'UnlistedSpecialPage', 'Recentchangeslinked' ),
+ 'Recentchangeslinked' => 'SpecialRecentchangeslinked',
'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ),
'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ),
'Resetpass' => array( 'UnlistedSpecialPage', 'Resetpass' ),
@@ -129,6 +136,7 @@ class SpecialPage
'Categories' => array( 'SpecialPage', 'Categories' ),
'Export' => array( 'SpecialPage', 'Export' ),
'Version' => array( 'SpecialPage', 'Version' ),
+ 'Blankpage' => array( 'UnlistedSpecialPage', 'Blankpage' ),
'Allmessages' => array( 'SpecialPage', 'Allmessages' ),
'Log' => array( 'SpecialPage', 'Log' ),
'Blockip' => array( 'SpecialPage', 'Blockip', 'block' ),
@@ -138,6 +146,7 @@ class SpecialPage
'Unlockdb' => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ),
'Userrights' => 'UserrightsPage',
'MIMEsearch' => array( 'SpecialPage', 'MIMEsearch' ),
+ 'FileDuplicateSearch' => array( 'SpecialPage', 'FileDuplicateSearch' ),
'Unwatchedpages' => array( 'SpecialPage', 'Unwatchedpages', 'unwatchedpages' ),
'Listredirects' => array( 'SpecialPage', 'Listredirects' ),
'Revisiondelete' => array( 'UnlistedSpecialPage', 'Revisiondelete', 'deleterevision' ),
@@ -152,7 +161,7 @@ class SpecialPage
'Listadmins' => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
'MergeHistory' => array( 'SpecialPage', 'MergeHistory', 'mergehistory' ),
'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
- );
+ );
static public $mAliases;
static public $mListInitialised = false;
@@ -171,7 +180,7 @@ class SpecialPage
return;
}
wfProfileIn( __METHOD__ );
-
+
# Better to set this now, to avoid infinite recursion in carelessly written hooks
self::$mListInitialised = true;
@@ -185,6 +194,7 @@ class SpecialPage
if( $wgEmailAuthentication ) {
self::$mList['Confirmemail'] = 'EmailConfirmation';
+ self::$mList['Invalidateemail'] = 'EmailInvalidation';
}
# Add extension special pages
@@ -234,7 +244,7 @@ class SpecialPage
}
/**
- * Given a special page name with a possible subpage, return an array
+ * Given a special page name with a possible subpage, return an array
* where the first element is the special page name and the second is the
* subpage.
*/
@@ -250,14 +260,11 @@ class SpecialPage
}
/**
- * Add a page to the list of valid special pages. This used to be the preferred
- * method for adding special pages in extensions. It's now suggested that you add
+ * Add a page to the list of valid special pages. This used to be the preferred
+ * method for adding special pages in extensions. It's now suggested that you add
* an associative record to $wgSpecialPages. This avoids autoloading SpecialPage.
*
- * @param mixed $page Must either be an array specifying a class name and
- * constructor parameters, or an object. The object,
- * when constructed, must have an execute() method which
- * sends HTML to $wgOut.
+ * @param SpecialPage $page
* @static
*/
static function addPage( &$page ) {
@@ -268,10 +275,47 @@ class SpecialPage
}
/**
+ * Add a page to a certain display group for Special:SpecialPages
+ *
+ * @param mixed $page (SpecialPage or string)
+ * @param string $group
+ * @static
+ */
+ static function setGroup( $page, $group ) {
+ global $wgSpecialPageGroups;
+ $name = is_object($page) ? $page->mName : $page;
+ $wgSpecialPageGroups[$name] = $group;
+ }
+
+ /**
+ * Add a page to a certain display group for Special:SpecialPages
+ *
+ * @param SpecialPage $page
+ * @static
+ */
+ static function getGroup( &$page ) {
+ global $wgSpecialPageGroups;
+ static $specialPageGroupsCache = array();
+ if( isset($specialPageGroupsCache[$page->mName]) ) {
+ return $specialPageGroupsCache[$page->mName];
+ }
+ $group = wfMsg('specialpages-specialpagegroup-'.strtolower($page->mName));
+ if( $group == ''
+ || wfEmptyMsg('specialpages-specialpagegroup-'.strtolower($page->mName), $group ) ) {
+ $group = isset($wgSpecialPageGroups[$page->mName])
+ ? $wgSpecialPageGroups[$page->mName]
+ : '-';
+ }
+ if( $group == '-' ) $group = 'other';
+ $specialPageGroupsCache[$page->mName] = $group;
+ return $group;
+ }
+
+ /**
* Remove a special page from the list
- * Formerly used to disable expensive or dangerous special pages. The
+ * Formerly used to disable expensive or dangerous special pages. The
* preferred method is now to add a SpecialPage_initList hook.
- *
+ *
* @static
*/
static function removePage( $name ) {
@@ -343,6 +387,32 @@ class SpecialPage
}
/**
+ * Return categorised listable special pages which are available
+ * for the current user, and everyone.
+ * @static
+ */
+ static function getUsablePages() {
+ global $wgUser;
+ if ( !self::$mListInitialised ) {
+ self::initList();
+ }
+ $pages = array();
+
+ foreach ( self::$mList as $name => $rec ) {
+ $page = self::getPage( $name );
+ if ( $page->isListed()
+ && (
+ !$page->isRestricted()
+ || $page->userCanExecute( $wgUser )
+ )
+ ) {
+ $pages[$name] = $page;
+ }
+ }
+ return $pages;
+ }
+
+ /**
* Return categorised listable special pages for all users
* @static
*/
@@ -368,17 +438,17 @@ class SpecialPage
*/
static function getRestrictedPages() {
global $wgUser;
- if ( !self::$mListInitialised ) {
+ if( !self::$mListInitialised ) {
self::initList();
}
$pages = array();
- foreach ( self::$mList as $name => $rec ) {
+ foreach( self::$mList as $name => $rec ) {
$page = self::getPage( $name );
- if (
+ if(
$page->isListed()
- and $page->isRestricted()
- and $page->userCanExecute( $wgUser )
+ && $page->isRestricted()
+ && $page->userCanExecute( $wgUser )
) {
$pages[$name] = $page;
}
@@ -435,9 +505,9 @@ class SpecialPage
}
# Redirect to canonical alias for GET commands
- # Not for POST, we'd lose the post data, so it's best to just distribute
- # the request. Such POST requests are possible for old extensions that
- # generate self-links without being aware that their default name has
+ # Not for POST, we'd lose the post data, so it's best to just distribute
+ # the request. Such POST requests are possible for old extensions that
+ # generate self-links without being aware that their default name has
# changed.
if ( !$including && $name != $page->getLocalName() && !$wgRequest->wasPosted() ) {
$query = $_GET;
@@ -573,7 +643,7 @@ class SpecialPage
$this->mFunction = $function;
}
if ( $file === 'default' ) {
- $this->mFile = dirname(__FILE__) . "/Special{$name}.php";
+ $this->mFile = dirname(__FILE__) . "/specials/Special$name.php";
} else {
$this->mFile = $file;
}
@@ -657,7 +727,7 @@ class SpecialPage
* Default execute method
* Checks user permissions, calls the function given in mFunction
*
- * This may be overridden by subclasses.
+ * This may be overridden by subclasses.
*/
function execute( $par ) {
global $wgUser;
@@ -670,7 +740,7 @@ class SpecialPage
if(!is_callable($func) and $this->mFile) {
require_once( $this->mFile );
}
- # FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage.
+ # FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage.
if ( wfRunHooks( 'SpecialPageExecuteBeforeHeader', array( &$this, &$par, &$func ) ) )
$this->outputHeader();
if ( ! wfRunHooks( 'SpecialPageExecuteBeforePage', array( &$this, &$par, &$func ) ) )
@@ -689,7 +759,7 @@ class SpecialPage
$msg = $wgContLang->lc( $this->name() ) . '-summary';
$out = wfMsgNoTrans( $msg );
if ( ! wfEmptyMsg( $msg, $out ) and $out !== '' and ! $this->including() ) {
- $wgOut->addWikiText( $out );
+ $wgOut->addWikiMsg( $msg );
}
}
@@ -718,7 +788,7 @@ class SpecialPage
}
/**
- * If the special page is a redirect, then get the Title object it redirects to.
+ * If the special page is a redirect, then get the Title object it redirects to.
* False otherwise.
*/
function getRedirect( $subpage ) {
@@ -738,14 +808,14 @@ class SpecialPage
if( $val = $wgRequest->getVal( $arg, false ) )
$params[] = $arg . '=' . $val;
}
-
+
return count( $params ) ? implode( '&', $params ) : false;
}
}
/**
* Shortcut to construct a special page which is unlisted by default
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
*/
class UnlistedSpecialPage extends SpecialPage
{
@@ -756,7 +826,7 @@ class UnlistedSpecialPage extends SpecialPage
/**
* Shortcut to construct an includable special page
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
*/
class IncludableSpecialPage extends SpecialPage
{
@@ -767,7 +837,7 @@ class IncludableSpecialPage extends SpecialPage
/**
* Shortcut to construct a special page alias.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
*/
class SpecialRedirectToSpecial extends UnlistedSpecialPage {
var $redirName, $redirSubpage;
@@ -797,7 +867,7 @@ class SpecialRedirectToSpecial extends UnlistedSpecialPage {
/**
* Shortcut to construct a special page pointing to current user user's page.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
*/
class SpecialMypage extends UnlistedSpecialPage {
function __construct() {
@@ -817,7 +887,7 @@ class SpecialMypage extends UnlistedSpecialPage {
/**
* Shortcut to construct a special page pointing to current user talk page.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
*/
class SpecialMytalk extends UnlistedSpecialPage {
function __construct() {
@@ -837,7 +907,7 @@ class SpecialMytalk extends UnlistedSpecialPage {
/**
* Shortcut to construct a special page pointing to current user contributions.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
*/
class SpecialMycontributions extends UnlistedSpecialPage {
function __construct() {