3 $wgSpecialPages = array(
4 "Userlogin" => new UnlistedSpecialPage( "Userlogin" ),
5 "Userlogout" => new UnlistedSpecialPage( "Userlogout" ),
6 "Preferences" => new SpecialPage( "Preferences" ),
7 "Watchlist" => new SpecialPage( "Watchlist" ),
8 "Recentchanges" => new SpecialPage( "Recentchanges" ),
9 "Upload" => new SpecialPage( "Upload" ),
10 "Imagelist" => new SpecialPage( "Imagelist" ),
11 "Listusers" => new SpecialPage( "Listusers" ),
12 "Statistics" => new SpecialPage( "Statistics" ),
13 "Randompage" => new SpecialPage( "Randompage" ),
14 "Lonelypages" => new SpecialPage( "Lonelypages" ),
15 "Unusedimages" => new SpecialPage( "Unusedimages" ),
16 "Popularpages" => new SpecialPage( "Popularpages" ),
17 "Wantedpages" => new SpecialPage( "Wantedpages" ),
18 "Shortpages" => new SpecialPage( "Shortpages" ),
19 "Longpages" => new SpecialPage( "Longpages" ),
20 "Newpages" => new SpecialPage( "Newpages" ),
21 "Ancientpages" => new SpecialPage( "Ancientpages" ),
22 "Deadendpages" => new SpecialPage( "Deadendpages" ),
23 "Allpages" => new SpecialPage( "Allpages" ),
24 "Ipblocklist" => new SpecialPage( "Ipblocklist" ),
25 "Maintenance" => new SpecialPage( "Maintenance" ),
26 "Specialpages" => new UnlistedSpecialPage( "Specialpages" ),
27 "Contributions" => new UnlistedSpecialPage( "Contributions" ),
28 "Emailuser" => new UnlistedSpecialPage( "Emailuser" ),
29 "Whatlinkshere" => new UnlistedSpecialPage( "Whatlinkshere" ),
30 "Recentchangeslinked" => new UnlistedSpecialPage( "Recentchangeslinked" ),
31 "Movepage" => new UnlistedSpecialPage( "Movepage" ),
32 "Blockme" => new UnlistedSpecialPage( "Blockme" ),
33 "Booksources" => new SpecialPage( "Booksources" ),
34 "Categories" => new SpecialPage( "Categories" ),
35 "Export" => new SpecialPage( "Export" ),
36 "Version" => new SpecialPage( "Version" ),
37 "Allmessages" => new SpecialPage( "Allmessages" ),
38 "Search" => new UnlistedSpecialPage( "Search" ),
39 "Blockip" => new SpecialPage( "Blockip", "sysop" ),
40 "Asksql" => new SpecialPage( "Asksql", "sysop" ),
41 "Undelete" => new SpecialPage( "Undelete", "sysop" ),
42 "Makesysop" => new SpecialPage( "Makesysop", "sysop" ),
43 "Import" => new SpecialPage( "Import", "sysop" ),
44 "Lockdb" => new SpecialPage( "Lockdb", "developer" ),
45 "Unlockdb" => new SpecialPage( "Unlockdb", "developer" )
50 /* private */ var $mName, $mRestriction, $mListed, $mFunction, $mFile;
52 /* static */ function addPage( &$obj ) {
53 global $wgSpecialPages;
54 $wgSpecialPages[$obj->mName
] = $obj;
57 /* static */ function removePage( $name ) {
58 global $wgSpecialPages;
59 unset( $wgSpecialPages[$name] );
62 /* static */ function &getPage( $name ) {
63 global $wgSpecialPages;
64 if ( array_key_exists( $name, $wgSpecialPages ) ) {
65 return $wgSpecialPages[$name];
71 # Return categorised listable special pages
72 /* static */ function getPages() {
73 global $wgSpecialPages;
77 "developer" => array()
80 foreach ( $wgSpecialPages as $name => $page ) {
81 if ( $page->isListed() ) {
82 $pages[$page->getRestriction()][$page->getName()] =& $wgSpecialPages[$name];
88 # Execute a special page path, which may contain slashes
89 /* static */ function executePath( &$title ) {
90 global $wgSpecialPages, $wgOut, $wgTitle;
92 $bits = split( "/", $title->getDBkey(), 2 );
94 if( empty( $bits[1] ) ) {
100 $page =& SpecialPage
::getPage( $name );
101 if ( is_null( $page ) ) {
102 $wgOut->setArticleRelated( false );
103 $wgOut->setRobotpolicy( "noindex,follow" );
104 $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
107 $wgTitle = Title
::makeTitle( NS_SPECIAL
, $name );
112 $page->execute( $par );
116 function SpecialPage( $name = "", $restriction = "", $listed = true, $function = false, $file = "default" ) {
117 $this->mName
= $name;
118 $this->mRestriction
= $restriction;
119 $this->mListed
= $listed;
120 if ( $function == false ) {
121 $this->mFunction
= "wfSpecial{$name}";
123 $this->mFunction
= $function;
125 if ( $file === "default" ) {
126 $this->mFile
= "Special{$name}.php";
128 $this->mFile
= $file;
132 function getName() { return $this->mName
; }
133 function getRestriction() { return $this->mRestriction
; }
134 function isListed() { return $this->mListed
; }
136 function userCanExecute( &$user ) {
137 if ( $this->mRestriction
== "" ) {
140 if ( in_array( $this->mRestriction
, $user->getRights() ) ) {
148 function displayRestrictionError() {
150 if ( $this->mRestriction
== "developer" ) {
151 $wgOut->developerRequired();
153 $wgOut->sysopRequired();
157 function setHeaders() {
159 $wgOut->setArticleRelated( false );
160 $wgOut->setRobotPolicy( "noindex,follow" );
161 $wgOut->setPageTitle( $this->getDescription() );
164 function execute( $par ) {
165 global $wgUser, $wgOut, $wgTitle;
169 if ( $this->userCanExecute( $wgUser ) ) {
170 if ( $this->mFile
) {
171 require_once( $this->mFile
);
173 $func = $this->mFunction
;
176 $this->displayRestrictionError();
180 function getDescription() {
181 return wfMsg( strtolower( $this->mName
) );
184 function getTitle() {
185 return Title
::makeTitle( NS_SPECIAL
, $this->mName
);
188 function setListed( $listed ) {
189 return wfSetVar( $this->mListed
, $listed );
193 class UnlistedSpecialPage
extends SpecialPage
195 function UnlistedSpecialPage( $name, $restriction = "", $function = false, $file = "default" ) {
196 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );