/**
* Factory for handling the special page list and generating SpecialPage objects
* @ingroup SpecialPage
+ * @since 1.17
*/
class SpecialPageFactory {
'Unblock' => 'SpecialUnblock',
'BlockList' => 'SpecialBlockList',
'ChangePassword' => 'SpecialChangePassword',
+ 'PasswordReset' => 'SpecialPasswordReset',
'DeletedContributions' => 'DeletedContributionsPage',
'Preferences' => 'SpecialPreferences',
'Contributions' => 'SpecialContributions',
/**
* Initialise the special page list
* This must be called before accessing SpecialPage::$mList
+ *
+ * @return array
*/
static function getList() {
global $wgSpecialPages;
return self::$mList;
}
+ /**
+ * Initialise and return the list of special page aliases. Returns an object with
+ * properties which can be accessed $obj->pagename - each property is an array of
+ * aliases; the first in the array is the cannonical alias. All registered special
+ * pages are guaranteed to have a property entry, and for that property array to
+ * contain at least one entry (English fallbacks will be added if necessary).
+ * @return Object
+ */
static function getAliasList() {
if ( !is_object( self::$mAliases ) ) {
global $wgContLang;
}
/**
- * Add a page to a certain display group for Special:SpecialPages
+ * Get the group that the special page belongs in on Special:SpecialPage
*
* @param $page SpecialPage
*/
$rec = self::getList()->$realName;
if ( is_string( $rec ) ) {
$className = $rec;
- self::getList()->$realName = new $className;
+ return new $className;
} elseif ( is_array( $rec ) ) {
// @deprecated, officially since 1.18, unofficially since forever
wfDebug( "Array syntax for \$wgSpecialPages is deprecated, define a subclass of SpecialPage instead." );
* @param $title Title object
* @param $context RequestContext
* @param $including Bool output is being captured for use in {{special:whatever}}
+ *
+ * @return bool
*/
public static function executePath( Title &$title, RequestContext &$context, $including = false ) {
wfProfileIn( __METHOD__ );
- // FIXME: redirects broken due to this call
+ // @todo FIXME: Redirects broken due to this call
$bits = explode( '/', $title->getDBkey(), 2 );
$name = $bits[0];
if ( !isset( $bits[1] ) ) { // bug 2087
$page = self::getPage( $name );
// Nonexistent?
if ( !$page ) {
- $context->output->setArticleRelated( false );
- $context->output->setRobotPolicy( 'noindex,nofollow' );
- $context->output->setStatusCode( 404 );
- $context->output->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
+ $context->getOutput()->setArticleRelated( false );
+ $context->getOutput()->setRobotPolicy( 'noindex,nofollow' );
+ $context->getOutput()->setStatusCode( 404 );
+ $context->getOutput()->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
wfProfileOut( __METHOD__ );
return false;
}
// Page exists, set the context
$page->setContext( $context );
- // Check for redirect
if ( !$including ) {
- if( $page instanceof SpecialRedirectToSpecial ){
- $redirect = $page->getRedirect( $par );
- $query = $page->getRedirectQuery();
- if ( $redirect instanceof Title ) {
- $url = $redirect->getFullUrl( $query );
- $context->output->redirect( $url );
- wfProfileOut( __METHOD__ );
- return $redirect;
- } elseif ( $redirect === true ) {
- global $wgScript;
- $url = $wgScript . '?' . wfArrayToCGI( $query );
- $context->output->redirect( $url );
- wfProfileOut( __METHOD__ );
- return $redirect;
- }
- }
-
// 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
// changed.
- if ( $name != $page->getLocalName() && !$context->request->wasPosted() ) {
- $query = $_GET;
+ if ( $name != $page->getLocalName() && !$context->getRequest()->wasPosted() ) {
+ $query = $context->getRequest()->getQueryValues();
unset( $query['title'] );
$query = wfArrayToCGI( $query );
$title = $page->getTitle( $par );
$url = $title->getFullUrl( $query );
- $context->output->redirect( $url );
+ $context->getOutput()->redirect( $url );
wfProfileOut( __METHOD__ );
return $title;
} else {
- $context->title = $page->getTitle();
+ $context->setTitle( $page->getTitle() );
}
} elseif ( !$page->isIncludable() ) {
* Returns false if there was no such special page, or a title object if it was
* a redirect.
*
+ * @param $title Title
+ *
* @return String: HTML fragment
*/
static function capturePath( &$title ) {
- global $wgOut, $wgTitle;
+ global $wgOut, $wgTitle, $wgRequest;
$oldTitle = $wgTitle;
$oldOut = $wgOut;
+ $oldRequest = $wgRequest;
+
+ // Don't want special pages interpreting ?feed=atom parameters.
+ $wgRequest = new FauxRequest( array() );
$context = new RequestContext;
$context->setTitle( $title );
+ $context->setRequest( $wgRequest );
$wgOut = $context->getOutput();
$ret = self::executePath( $title, $context, true );
}
$wgTitle = $oldTitle;
$wgOut = $oldOut;
+ $wgRequest = $oldRequest;
return $ret;
}
static function getLocalNameFor( $name, $subpage = false ) {
global $wgContLang;
$aliases = $wgContLang->getSpecialPageAliases();
+
if ( isset( $aliases[$name][0] ) ) {
$name = $aliases[$name][0];
} else {
/**
* Get a title for a given alias
*
+ * @param $alias String
+ *
* @return Title or null if there is no such alias
*/
static function getTitleForAlias( $alias ) {
$name = self::resolveAlias( $alias );
if ( $name ) {
- return self::getTitleFor( $name );
+ return SpecialPage::getTitleFor( $name );
} else {
return null;
}
}
-}
\ No newline at end of file
+}