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 # Execute a special page path, which may contain slashes
72 /* static */ function executePath( &$title ) {
73 global $wgSpecialPages, $wgOut, $wgTitle;
75 $bits = split( "/", $title->getDBkey(), 2 );
77 if( empty( $bits[1] ) ) {
83 $page =& SpecialPage
::getPage( $name );
84 if ( is_null( $page ) ) {
85 $wgOut->setArticleRelated( false );
86 $wgOut->setRobotpolicy( "noindex,follow" );
87 $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
90 $wgTitle = Title
::makeTitle( NS_SPECIAL
, $name );
95 $page->execute( $par );
99 function SpecialPage( $name = "", $restriction = "", $listed = true, $function = false, $file = "default" ) {
100 $this->mName
= $name;
101 $this->mRestriction
= $restriction;
102 $this->mListed
= $listed;
103 if ( $function == false ) {
104 $this->mFunction
= "wfSpecial{$name}";
106 $this->mFunction
= $function;
108 if ( $file === "default" ) {
109 $this->mFile
= "Special{$name}.php";
111 $this->mFile
= $file;
115 function getName() { return $this->mName
; }
116 function getRestriction() { return $this->mRestriction
; }
117 function isListed() { return $this->mListed
; }
119 function userCanExecute( &$user ) {
120 if ( $this->mRestriction
== "" ) {
123 if ( in_array( $this->mRestriction
, $user->getRights() ) ) {
131 function displayRestrictionError() {
132 if ( $this->mRestriction
== "developer" ) {
133 $wgOut->developerRequired();
135 $wgOut->sysopRequired();
139 function setHeaders() {
141 $wgOut->setArticleRelated( false );
142 $wgOut->setRobotPolicy( "noindex,follow" );
143 $wgOut->setPageTitle( $this->getDescription() );
146 function execute( $par ) {
147 global $wgUser, $wgOut, $wgTitle;
151 if ( $this->userCanExecute( $wgUser ) ) {
152 if ( $this->mFile
) {
153 require_once( $this->mFile
);
155 $func = $this->mFunction
;
158 $this->displayRestrictionError();
162 function getDescription() {
163 return wfMsg( strtolower( $this->mName
) );
166 function getTitle() {
167 return Title
::makeTitle( NS_SPECIAL
, $this->mName
);
170 function setListed( $listed ) {
171 return wfSetVar( $this->mListed
, $listed );
175 class UnlistedSpecialPage
extends SpecialPage
177 function UnlistedSpecialPage( $name, $restriction = "", $function = false, $file = "default" ) {
178 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );