00001 <?php
00002 global
$wgSpecialPages;
00003
$wgSpecialPages = array(
00004
"Userlogin" =>
new UnlistedSpecialPage(
"Userlogin" ),
00005
"Userlogout" =>
new UnlistedSpecialPage(
"Userlogout" ),
00006
"Preferences" =>
new SpecialPage(
"Preferences" ),
00007
"Watchlist" =>
new SpecialPage(
"Watchlist" ),
00008
"Recentchanges" =>
new SpecialPage(
"Recentchanges" ),
00009
"Upload" =>
new SpecialPage(
"Upload" ),
00010
"Imagelist" =>
new SpecialPage(
"Imagelist" ),
00011
"Listusers" =>
new SpecialPage(
"Listusers" ),
00012
"Listadmins" =>
new SpecialPage(
"Listadmins" ),
00013
"Statistics" =>
new SpecialPage(
"Statistics" ),
00014
"Randompage" =>
new SpecialPage(
"Randompage" ),
00015
"Lonelypages" =>
new SpecialPage(
"Lonelypages" ),
00016
"Unusedimages" =>
new SpecialPage(
"Unusedimages" )
00017 );
00018 global
$wgDisableCounters;
00019
if( !
$wgDisableCounters )
00020 {
00021
$wgSpecialPages[
"Popularpages"] =
new SpecialPage(
"Popularpages" );
00022 }
00023 $wgSpecialPages = array_merge($wgSpecialPages, array (
00024
"Wantedpages" =>
new SpecialPage(
"Wantedpages" ),
00025
"Shortpages" =>
new SpecialPage(
"Shortpages" ),
00026
"Longpages" =>
new SpecialPage(
"Longpages" ),
00027
"Newpages" =>
new SpecialPage(
"Newpages" ),
00028
"Ancientpages" =>
new SpecialPage(
"Ancientpages" ),
00029
"Deadendpages" =>
new SpecialPage(
"Deadendpages" ),
00030
"Allpages" =>
new SpecialPage(
"Allpages" ),
00031
"Ipblocklist" =>
new SpecialPage(
"Ipblocklist" ),
00032
"Maintenance" =>
new SpecialPage(
"Maintenance" ),
00033
"Specialpages" =>
new UnlistedSpecialPage(
"Specialpages" ),
00034
"Contributions" =>
new UnlistedSpecialPage(
"Contributions" ),
00035
"Emailuser" =>
new UnlistedSpecialPage(
"Emailuser" ),
00036
"Whatlinkshere" =>
new UnlistedSpecialPage(
"Whatlinkshere" ),
00037
"Recentchangeslinked" =>
new UnlistedSpecialPage(
"Recentchangeslinked" ),
00038
"Movepage" =>
new UnlistedSpecialPage(
"Movepage" ),
00039
"Blockme" =>
new UnlistedSpecialPage(
"Blockme" ),
00040
"Booksources" =>
new SpecialPage(
"Booksources" ),
00041
"Categories" =>
new SpecialPage(
"Categories" ),
00042
"Export" =>
new SpecialPage(
"Export" ),
00043
"Version" =>
new SpecialPage(
"Version" ),
00044
"Allmessages" =>
new SpecialPage(
"Allmessages" ),
00045
"Search" =>
new UnlistedSpecialPage(
"Search" ),
00046
"Blockip" =>
new SpecialPage(
"Blockip",
"sysop" ),
00047
"Asksql" =>
new SpecialPage(
"Asksql",
"sysop" ),
00048
"Undelete" =>
new SpecialPage(
"Undelete",
"sysop" ),
00049
"Makesysop" =>
new SpecialPage(
"Makesysop",
"sysop" ),
00050
"Import" =>
new SpecialPage(
"Import",
"sysop" ),
00051
"Lockdb" =>
new SpecialPage(
"Lockdb",
"developer" ),
00052
"Unlockdb" =>
new SpecialPage(
"Unlockdb",
"developer" )
00053 ));
00054
00055 class SpecialPage
00056 {
00057 var
$mName,
$mRestriction,
$mListed,
$mFunction,
$mFile;
00058
00059 function
addPage( &$obj ) {
00060 global
$wgSpecialPages;
00061
$wgSpecialPages[$obj->mName] = $obj;
00062 }
00063
00064 function
removePage( $name ) {
00065 global
$wgSpecialPages;
00066 unset( $wgSpecialPages[$
name] );
00067 }
00068
00069 function &
getPage( $name ) {
00070 global
$wgSpecialPages;
00071
if ( array_key_exists( $
name, $wgSpecialPages ) ) {
00072
return $wgSpecialPages[$name];
00073 }
else {
00074
return NULL;
00075 }
00076 }
00077
00078
# Return categorised listable special pages
00079 function
getPages() {
00080 global
$wgSpecialPages;
00081 $pages = array(
00082
"" => array(),
00083
"sysop" => array(),
00084
"developer" => array()
00085 );
00086
00087 foreach ( $wgSpecialPages as $
name => $
page ) {
00088
if (
$page->isListed() ) {
00089 $pages[
$page->getRestriction()][
$page->getName()] =&
$wgSpecialPages[$name];
00090 }
00091 }
00092
return $pages;
00093 }
00094
00095
# Execute a special page path, which may contain slashes
00096 function
executePath( &$title ) {
00097 global
$wgSpecialPages,
$wgOut,
$wgTitle;
00098
00099
$bits = split(
"/", $
title->getDBkey(), 2 );
00100 $name =
$bits[0];
00101
if( empty( $bits[1] ) ) {
00102 $par = NULL;
00103 }
else {
00104 $par =
$bits[1];
00105 }
00106
00107
$page =&
SpecialPage::getPage( $
name );
00108
if ( is_null( $
page ) ) {
00109
$wgOut->setArticleRelated(
false );
00110
$wgOut->setRobotpolicy(
"noindex,follow" );
00111
$wgOut->errorpage(
"nosuchspecialpage",
"nospecialpagetext" );
00112 }
else {
00113
if($par !== NULL) {
00114
$wgTitle = Title::makeTitle(
NS_SPECIAL, $
name );
00115 }
else {
00116
$wgTitle =
$title;
00117 }
00118
00119
$page->execute( $par );
00120 }
00121 }
00122
00123 function
SpecialPage( $name =
"", $restriction =
"", $listed =
true, $function =
false, $file =
"default" ) {
00124 $this->mName = $name;
00125 $this->mRestriction = $restriction;
00126 $this->mListed = $listed;
00127
if ( $function ==
false ) {
00128 $this->mFunction =
"wfSpecial{$name}";
00129 }
else {
00130 $this->mFunction = $function;
00131 }
00132
if ( $file ===
"default" ) {
00133 $this->mFile =
"Special{$name}.php";
00134 }
else {
00135 $this->mFile = $file;
00136 }
00137 }
00138
00139 function
getName() {
return $this->mName; }
00140 function
getRestriction() {
return $this->mRestriction; }
00141 function
isListed() {
return $this->mListed; }
00142
00143 function
userCanExecute( &$user ) {
00144
if ( $this->mRestriction ==
"" ) {
00145
return true;
00146 }
else {
00147
if ( in_array( $this->mRestriction, $
user->getRights() ) ) {
00148
return true;
00149 }
else {
00150
return false;
00151 }
00152 }
00153 }
00154
00155 function
displayRestrictionError() {
00156 global
$wgOut;
00157
if ( $this->mRestriction ==
"developer" ) {
00158
$wgOut->developerRequired();
00159 }
else {
00160
$wgOut->sysopRequired();
00161 }
00162 }
00163
00164 function
setHeaders() {
00165 global
$wgOut;
00166
$wgOut->setArticleRelated(
false );
00167
$wgOut->setRobotPolicy(
"noindex,follow" );
00168
$wgOut->setPageTitle( $this->getDescription() );
00169 }
00170
00171 function
execute( $par ) {
00172 global
$wgUser,
$wgOut,
$wgTitle;
00173
00174 $this->
setHeaders();
00175
00176
if ( $this->userCanExecute( $wgUser ) ) {
00177
if ( $this->mFile ) {
00178 require_once( $this->mFile );
00179 }
00180 $func = $this->mFunction;
00181 $func( $par );
00182 }
else {
00183 $this->
displayRestrictionError();
00184 }
00185 }
00186
00187 function
getDescription() {
00188
return wfMsg( strtolower( $this->mName ) );
00189 }
00190
00191 function
getTitle() {
00192
return Title::makeTitle(
NS_SPECIAL, $this->mName );
00193 }
00194
00195 function
setListed( $listed ) {
00196
return wfSetVar( $this->mListed, $listed );
00197 }
00198 }
00199
00200 class UnlistedSpecialPage extends SpecialPage
00201 {
00202 function
UnlistedSpecialPage( $name, $restriction =
"", $function =
false, $file =
"default" ) {
00203 SpecialPage::SpecialPage( $
name, $restriction,
false, $function, $file );
00204 }
00205 }