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 "Listadmins" => new SpecialPage( "Listadmins" ),
13 "Statistics" => new SpecialPage( "Statistics" ),
14 "Randompage" => new SpecialPage( "Randompage" ),
15 "Lonelypages" => new SpecialPage( "Lonelypages" ),
16 "Unusedimages" => new SpecialPage( "Unusedimages" ),
17 "Popularpages" => new SpecialPage( "Popularpages" ),
18 "Wantedpages" => new SpecialPage( "Wantedpages" ),
19 "Shortpages" => new SpecialPage( "Shortpages" ),
20 "Longpages" => new SpecialPage( "Longpages" ),
21 "Newpages" => new SpecialPage( "Newpages" ),
22 "Ancientpages" => new SpecialPage( "Ancientpages" ),
23 "Deadendpages" => new SpecialPage( "Deadendpages" ),
24 "Allpages" => new SpecialPage( "Allpages" ),
25 "Ipblocklist" => new SpecialPage( "Ipblocklist" ),
26 "Maintenance" => new SpecialPage( "Maintenance" ),
27 "Specialpages" => new UnlistedSpecialPage( "Specialpages" ),
28 "Contributions" => new UnlistedSpecialPage( "Contributions" ),
29 "Emailuser" => new UnlistedSpecialPage( "Emailuser" ),
30 "Whatlinkshere" => new UnlistedSpecialPage( "Whatlinkshere" ),
31 "Recentchangeslinked" => new UnlistedSpecialPage( "Recentchangeslinked" ),
32 "Movepage" => new UnlistedSpecialPage( "Movepage" ),
33 "Blockme" => new UnlistedSpecialPage( "Blockme" ),
34 "Booksources" => new SpecialPage( "Booksources" ),
35 "Categories" => new SpecialPage( "Categories" ),
36 "Export" => new SpecialPage( "Export" ),
37 "Version" => new SpecialPage( "Version" ),
38 "Allmessages" => new SpecialPage( "Allmessages" ),
39 "Search" => new UnlistedSpecialPage( "Search" ),
40 "Blockip" => new SpecialPage( "Blockip", "sysop" ),
41 "Asksql" => new SpecialPage( "Asksql", "sysop" ),
42 "Undelete" => new SpecialPage( "Undelete", "sysop" ),
43 "Makesysop" => new SpecialPage( "Makesysop", "sysop" ),
44 "Import" => new SpecialPage( "Import", "sysop" ),
45 "Lockdb" => new SpecialPage( "Lockdb", "developer" ),
46 "Unlockdb" => new SpecialPage( "Unlockdb", "developer" )
51 /* private */ var $mName, $mRestriction, $mListed, $mFunction, $mFile;
53 /* static */ function addPage( &$obj ) {
54 global $wgSpecialPages;
55 $wgSpecialPages[$obj->mName
] = $obj;
58 /* static */ function removePage( $name ) {
59 global $wgSpecialPages;
60 unset( $wgSpecialPages[$name] );
63 /* static */ function &getPage( $name ) {
64 global $wgSpecialPages;
65 if ( array_key_exists( $name, $wgSpecialPages ) ) {
66 return $wgSpecialPages[$name];
72 # Return categorised listable special pages
73 /* static */ function getPages() {
74 global $wgSpecialPages;
78 "developer" => array()
81 foreach ( $wgSpecialPages as $name => $page ) {
82 if ( $page->isListed() ) {
83 $pages[$page->getRestriction()][$page->getName()] =& $wgSpecialPages[$name];
89 # Execute a special page path, which may contain slashes
90 /* static */ function executePath( &$title ) {
91 global $wgSpecialPages, $wgOut, $wgTitle;
93 $bits = split( "/", $title->getDBkey(), 2 );
95 if( empty( $bits[1] ) ) {
101 $page =& SpecialPage
::getPage( $name );
102 if ( is_null( $page ) ) {
103 $wgOut->setArticleRelated( false );
104 $wgOut->setRobotpolicy( "noindex,follow" );
105 $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
108 $wgTitle = Title
::makeTitle( NS_SPECIAL
, $name );
113 $page->execute( $par );
117 function SpecialPage( $name = "", $restriction = "", $listed = true, $function = false, $file = "default" ) {
118 $this->mName
= $name;
119 $this->mRestriction
= $restriction;
120 $this->mListed
= $listed;
121 if ( $function == false ) {
122 $this->mFunction
= "wfSpecial{$name}";
124 $this->mFunction
= $function;
126 if ( $file === "default" ) {
127 $this->mFile
= "Special{$name}.php";
129 $this->mFile
= $file;
133 function getName() { return $this->mName
; }
134 function getRestriction() { return $this->mRestriction
; }
135 function isListed() { return $this->mListed
; }
137 function userCanExecute( &$user ) {
138 if ( $this->mRestriction
== "" ) {
141 if ( in_array( $this->mRestriction
, $user->getRights() ) ) {
149 function displayRestrictionError() {
151 if ( $this->mRestriction
== "developer" ) {
152 $wgOut->developerRequired();
154 $wgOut->sysopRequired();
158 function setHeaders() {
160 $wgOut->setArticleRelated( false );
161 $wgOut->setRobotPolicy( "noindex,follow" );
162 $wgOut->setPageTitle( $this->getDescription() );
165 function execute( $par ) {
166 global $wgUser, $wgOut, $wgTitle;
170 if ( $this->userCanExecute( $wgUser ) ) {
171 if ( $this->mFile
) {
172 require_once( $this->mFile
);
174 $func = $this->mFunction
;
177 $this->displayRestrictionError();
181 function getDescription() {
182 return wfMsg( strtolower( $this->mName
) );
185 function getTitle() {
186 return Title
::makeTitle( NS_SPECIAL
, $this->mName
);
189 function setListed( $listed ) {
190 return wfSetVar( $this->mListed
, $listed );
194 class UnlistedSpecialPage
extends SpecialPage
196 function UnlistedSpecialPage( $name, $restriction = "", $function = false, $file = "default" ) {
197 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );