From 0647f546ec860d7950a27e73ef55321db5d77b54 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 11 May 2005 03:21:25 +0000 Subject: [PATCH] * 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. --- includes/SpecialPage.php | 41 +++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 00f5142e33..3c7609b7c6 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 ); -- 2.20.1