2 global $wgSpecialPages;
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" )
18 global $wgDisableCounters;
19 if( !$wgDisableCounters )
21 $wgSpecialPages["Popularpages"] = new SpecialPage( "Popularpages" );
23 $wgSpecialPages = array_merge($wgSpecialPages, array (
24 "Wantedpages" => new SpecialPage( "Wantedpages" ),
25 "Shortpages" => new SpecialPage( "Shortpages" ),
26 "Longpages" => new SpecialPage( "Longpages" ),
27 "Newpages" => new SpecialPage( "Newpages" ),
28 "Ancientpages" => new SpecialPage( "Ancientpages" ),
29 "Deadendpages" => new SpecialPage( "Deadendpages" ),
30 "Allpages" => new SpecialPage( "Allpages" ),
31 "Ipblocklist" => new SpecialPage( "Ipblocklist" ),
32 "Maintenance" => new SpecialPage( "Maintenance" ),
33 "Specialpages" => new UnlistedSpecialPage( "Specialpages" ),
34 "Contributions" => new UnlistedSpecialPage( "Contributions" ),
35 "Emailuser" => new UnlistedSpecialPage( "Emailuser" ),
36 "Whatlinkshere" => new UnlistedSpecialPage( "Whatlinkshere" ),
37 "Recentchangeslinked" => new UnlistedSpecialPage( "Recentchangeslinked" ),
38 "Movepage" => new UnlistedSpecialPage( "Movepage" ),
39 "Blockme" => new UnlistedSpecialPage( "Blockme" ),
40 "Geo" => new SpecialPage( "Geo" ),
41 "Booksources" => new SpecialPage( "Booksources" ),
42 "Categories" => new SpecialPage( "Categories" ),
43 "Export" => new SpecialPage( "Export" ),
44 "Version" => new SpecialPage( "Version" ),
45 "Allmessages" => new SpecialPage( "Allmessages" ),
46 "Search" => new UnlistedSpecialPage( "Search" ),
47 "Blockip" => new SpecialPage( "Blockip", "sysop" ),
48 "Asksql" => new SpecialPage( "Asksql", "sysop" ),
49 "Undelete" => new SpecialPage( "Undelete", "sysop" ),
50 "Makesysop" => new SpecialPage( "Makesysop", "sysop" ),
51 "Import" => new SpecialPage( "Import", "sysop" ),
52 "Lockdb" => new SpecialPage( "Lockdb", "developer" ),
53 "Unlockdb" => new SpecialPage( "Unlockdb", "developer" )
58 /* private */ var $mName, $mRestriction, $mListed, $mFunction, $mFile;
60 /* static */ function addPage( &$obj ) {
61 global $wgSpecialPages;
62 $wgSpecialPages[$obj->mName
] = $obj;
65 /* static */ function removePage( $name ) {
66 global $wgSpecialPages;
67 unset( $wgSpecialPages[$name] );
70 /* static */ function &getPage( $name ) {
71 global $wgSpecialPages;
72 if ( array_key_exists( $name, $wgSpecialPages ) ) {
73 return $wgSpecialPages[$name];
79 # Return categorised listable special pages
80 /* static */ function getPages() {
81 global $wgSpecialPages;
85 "developer" => array()
88 foreach ( $wgSpecialPages as $name => $page ) {
89 if ( $page->isListed() ) {
90 $pages[$page->getRestriction()][$page->getName()] =& $wgSpecialPages[$name];
96 # Execute a special page path, which may contain slashes
97 /* static */ function executePath( &$title ) {
98 global $wgSpecialPages, $wgOut, $wgTitle;
100 $bits = split( "/", $title->getDBkey(), 2 );
102 if( empty( $bits[1] ) ) {
108 $page =& SpecialPage
::getPage( $name );
109 if ( is_null( $page ) ) {
110 $wgOut->setArticleRelated( false );
111 $wgOut->setRobotpolicy( "noindex,follow" );
112 $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
115 $wgTitle = Title
::makeTitle( NS_SPECIAL
, $name );
120 $page->execute( $par );
124 function SpecialPage( $name = "", $restriction = "", $listed = true, $function = false, $file = "default" ) {
125 $this->mName
= $name;
126 $this->mRestriction
= $restriction;
127 $this->mListed
= $listed;
128 if ( $function == false ) {
129 $this->mFunction
= "wfSpecial{$name}";
131 $this->mFunction
= $function;
133 if ( $file === "default" ) {
134 $this->mFile
= "Special{$name}.php";
136 $this->mFile
= $file;
140 function getName() { return $this->mName
; }
141 function getRestriction() { return $this->mRestriction
; }
142 function isListed() { return $this->mListed
; }
144 function userCanExecute( &$user ) {
145 if ( $this->mRestriction
== "" ) {
148 if ( in_array( $this->mRestriction
, $user->getRights() ) ) {
156 function displayRestrictionError() {
158 if ( $this->mRestriction
== "developer" ) {
159 $wgOut->developerRequired();
161 $wgOut->sysopRequired();
165 function setHeaders() {
167 $wgOut->setArticleRelated( false );
168 $wgOut->setRobotPolicy( "noindex,follow" );
169 $wgOut->setPageTitle( $this->getDescription() );
172 function execute( $par ) {
173 global $wgUser, $wgOut, $wgTitle;
177 if ( $this->userCanExecute( $wgUser ) ) {
178 if ( $this->mFile
) {
179 require_once( $this->mFile
);
181 $func = $this->mFunction
;
184 $this->displayRestrictionError();
188 function getDescription() {
189 return wfMsg( strtolower( $this->mName
) );
192 function getTitle() {
193 return Title
::makeTitle( NS_SPECIAL
, $this->mName
);
196 function setListed( $listed ) {
197 return wfSetVar( $this->mListed
, $listed );
201 class UnlistedSpecialPage
extends SpecialPage
203 function UnlistedSpecialPage( $name, $restriction = "", $function = false, $file = "default" ) {
204 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );