diff options
author | Ævar Arnfjörð Bjarmason <avar@users.mediawiki.org> | 2005-05-11 03:21:25 +0000 |
---|---|---|
committer | Ævar Arnfjörð Bjarmason <avar@users.mediawiki.org> | 2005-05-11 03:21:25 +0000 |
commit | 0647f546ec860d7950a27e73ef55321db5d77b54 (patch) | |
tree | 8257c1c09a0691c0a49ef77b811d48b80171d899 /includes/SpecialPage.php | |
parent | 3fc37c9e91a999b5df45c9f7a7d74d4ab709d93e (diff) | |
download | mediawikicore-0647f546ec860d7950a27e73ef55321db5d77b54.tar.gz mediawikicore-0647f546ec860d7950a27e73ef55321db5d77b54.zip |
* Added a new associative array ($wgSpecialPageRedirects) that holds
Specialpages to redirect from and to as keys and values respectively,
executePath() now uses it to check if it should redirect the request for a
specialpage to another location.
This removes the need for keeping stub redirects around in case we merge or
rename SpecialPages.
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/8979
Diffstat (limited to 'includes/SpecialPage.php')
-rw-r--r-- | includes/SpecialPage.php | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 00f5142e331d..3c7609b7c6f3 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -19,7 +19,7 @@ /** * */ -global $wgSpecialPages; +global $wgSpecialPages, $wgSpecialPageRedirects; /** * @access private @@ -43,7 +43,6 @@ $wgSpecialPages = array( 'Imagelist' => new SpecialPage( 'Imagelist' ), 'Newimages' => new SpecialPage( 'Newimages' ), 'Listusers' => new SpecialPage( 'Listusers' ), - 'Listadmins' => new UnlistedSpecialPage( 'Listadmins' ), 'Statistics' => new SpecialPage( 'Statistics' ), 'Randompage' => new SpecialPage( 'Randompage' ), 'Lonelypages' => new SpecialPage( 'Lonelypages' ), @@ -80,6 +79,17 @@ $wgSpecialPages = array( 'Groups' => new SpecialPage( 'Groups' ), ); +/** + * Sometimes the functionality of a specialpage is merged into the + * functionality of another or its simply renamed, this allows us to redirect + * the request to the proper place. + * + * @access private + */ +$wgSpecialPageRedirects = array( + 'Listadmins' => 'Listusers' +); + global $wgUseValidation ; if ( $wgUseValidation ) $wgSpecialPages['Validate'] = new SpecialPage( 'Validate' ); @@ -167,6 +177,21 @@ class SpecialPage return NULL; } } + + /** + * + * @static + * @param string $nam + * @return mixed string if the redirect exists, otherwise NULL + */ + function &getRedirect( $name ) { + global $wgSpecialPageRedirects; + if ( array_key_exists( $name, $wgSpecialPageRedirects ) ) { + return $wgSpecialPageRedirects[$name]; + } else { + return NULL; + } + } /** * Return categorised listable special pages @@ -209,9 +234,15 @@ class SpecialPage $page =& SpecialPage::getPage( $name ); if ( is_null( $page ) ) { - $wgOut->setArticleRelated( false ); - $wgOut->setRobotpolicy( "noindex,follow" ); - $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" ); + $redir =& SpecialPage::getRedirect( $name ); + if ( isset( $redir ) ) { + $t = Title::makeTitle( NS_SPECIAL, "Listusers" ); + $wgOut->redirect ($t->getFullURL()); + } else { + $wgOut->setArticleRelated( false ); + $wgOut->setRobotpolicy( "noindex,follow" ); + $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" ); + } } else { if($par !== NULL) { $wgTitle = Title::makeTitle( NS_SPECIAL, $name ); |