2 global $wgSpecialPages, $wgWhitelistAccount;
4 # Special:Userlogin is a peculiar case: If the site options tell us to allow only sysops to
5 # create new accounts, we want it displayed under "For sysop use only". If it's for developers
6 # only, display it there. If anyone can create an account, we don't want it listed at all,
7 # because there would already be a "create account or login" link in the top-right corner of
8 # the page. If nobody can create an account, we don't want it listed either.
10 $userlogin_listed = true;
11 $userlogin_restr = '';
12 if ( $wgWhitelistAccount && $wgWhitelistAccount['sysop'] && !$wgWhitelistAccount['user'] )
13 $userlogin_restr = 'sysop';
14 else if ( $wgWhitelistAccount && $wgWhitelistAccount['developer'] &&
15 !$wgWhitelistAccount['sysop'] && !$wgWhitelistAccount['user'] )
16 $userlogin_restr = 'developer';
18 $userlogin_listed = false;
20 $wgSpecialPages = array(
21 "Userlogin" => new SpecialPage( "Userlogin", $userlogin_restr, $userlogin_listed ),
22 "Userlogout" => new UnlistedSpecialPage( "Userlogout" ),
23 "Preferences" => new SpecialPage( "Preferences" ),
24 "Watchlist" => new SpecialPage( "Watchlist" ),
25 "Recentchanges" => new SpecialPage( "Recentchanges" ),
26 "Upload" => new SpecialPage( "Upload" ),
27 "Imagelist" => new SpecialPage( "Imagelist" ),
28 "Listusers" => new SpecialPage( "Listusers" ),
29 "Listadmins" => new SpecialPage( "Listadmins" ),
30 "Statistics" => new SpecialPage( "Statistics" ),
31 "Randompage" => new SpecialPage( "Randompage" ),
32 "Lonelypages" => new SpecialPage( "Lonelypages" ),
33 "Uncategorizedpages"=> new SpecialPage( "Uncategorizedpages" ),
34 "Unusedimages" => new SpecialPage( "Unusedimages" )
36 global $wgDisableCounters;
37 if( !$wgDisableCounters )
39 $wgSpecialPages["Popularpages"] = new SpecialPage( "Popularpages" );
41 $wgSpecialPages = array_merge($wgSpecialPages, array (
42 "Wantedpages" => new SpecialPage( "Wantedpages" ),
43 "Shortpages" => new SpecialPage( "Shortpages" ),
44 "Longpages" => new SpecialPage( "Longpages" ),
45 "Newpages" => new SpecialPage( "Newpages" ),
46 "Ancientpages" => new SpecialPage( "Ancientpages" ),
47 "Deadendpages" => new SpecialPage( "Deadendpages" ),
48 "Allpages" => new SpecialPage( "Allpages" ),
49 "Ipblocklist" => new SpecialPage( "Ipblocklist" ),
50 "Maintenance" => new SpecialPage( "Maintenance" ),
51 "Specialpages" => new UnlistedSpecialPage( "Specialpages" ),
52 "Contributions" => new UnlistedSpecialPage( "Contributions" ),
53 "Emailuser" => new UnlistedSpecialPage( "Emailuser" ),
54 "Whatlinkshere" => new UnlistedSpecialPage( "Whatlinkshere" ),
55 "Recentchangeslinked" => new UnlistedSpecialPage( "Recentchangeslinked" ),
56 "Movepage" => new UnlistedSpecialPage( "Movepage" ),
57 "Blockme" => new UnlistedSpecialPage( "Blockme" ),
58 "Geo" => new UnlistedSpecialPage( "Geo" ),
59 "Validate" => new UnlistedSpecialPage( "Validate" ),
60 "Booksources" => new SpecialPage( "Booksources" ),
61 "Categories" => new SpecialPage( "Categories" ),
62 "Export" => new SpecialPage( "Export" ),
63 "Version" => new SpecialPage( "Version" ),
64 "Allmessages" => new SpecialPage( "Allmessages" ),
65 "Search" => new UnlistedSpecialPage( "Search" ),
66 "Blockip" => new SpecialPage( "Blockip", "sysop" ),
67 "Asksql" => new SpecialPage( "Asksql", "sysop" ),
68 "Undelete" => new SpecialPage( "Undelete", "sysop" ),
69 "Makesysop" => new SpecialPage( "Makesysop", "sysop" ),
70 # "Import" => new SpecialPage( "Import", "sysop" ),
71 "Lockdb" => new SpecialPage( "Lockdb", "developer" ),
72 "Unlockdb" => new SpecialPage( "Unlockdb", "developer" )
77 /* private */ var $mName, $mRestriction, $mListed, $mFunction, $mFile;
79 /* static */ function addPage( &$obj ) {
80 global $wgSpecialPages;
81 $wgSpecialPages[$obj->mName
] = $obj;
84 /* static */ function removePage( $name ) {
85 global $wgSpecialPages;
86 unset( $wgSpecialPages[$name] );
89 /* static */ function &getPage( $name ) {
90 global $wgSpecialPages;
91 if ( array_key_exists( $name, $wgSpecialPages ) ) {
92 return $wgSpecialPages[$name];
98 # Return categorised listable special pages
99 /* static */ function getPages() {
100 global $wgSpecialPages;
104 "developer" => array()
107 foreach ( $wgSpecialPages as $name => $page ) {
108 if ( $page->isListed() ) {
109 $pages[$page->getRestriction()][$page->getName()] =& $wgSpecialPages[$name];
115 # Execute a special page path, which may contain slashes
116 /* static */ function executePath( &$title ) {
117 global $wgSpecialPages, $wgOut, $wgTitle;
119 $bits = split( "/", $title->getDBkey(), 2 );
121 if( empty( $bits[1] ) ) {
127 $page =& SpecialPage
::getPage( $name );
128 if ( is_null( $page ) ) {
129 $wgOut->setArticleRelated( false );
130 $wgOut->setRobotpolicy( "noindex,follow" );
131 $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
134 $wgTitle = Title
::makeTitle( NS_SPECIAL
, $name );
139 $page->execute( $par );
143 function SpecialPage( $name = "", $restriction = "", $listed = true, $function = false, $file = "default" ) {
144 $this->mName
= $name;
145 $this->mRestriction
= $restriction;
146 $this->mListed
= $listed;
147 if ( $function == false ) {
148 $this->mFunction
= "wfSpecial{$name}";
150 $this->mFunction
= $function;
152 if ( $file === "default" ) {
153 $this->mFile
= "Special{$name}.php";
155 $this->mFile
= $file;
159 function getName() { return $this->mName
; }
160 function getRestriction() { return $this->mRestriction
; }
161 function isListed() { return $this->mListed
; }
163 function userCanExecute( &$user ) {
164 if ( $this->mRestriction
== "" ) {
167 if ( in_array( $this->mRestriction
, $user->getRights() ) ) {
175 function displayRestrictionError() {
177 if ( $this->mRestriction
== "developer" ) {
178 $wgOut->developerRequired();
180 $wgOut->sysopRequired();
184 function setHeaders() {
186 $wgOut->setArticleRelated( false );
187 $wgOut->setRobotPolicy( "noindex,follow" );
188 $wgOut->setPageTitle( $this->getDescription() );
191 function execute( $par ) {
192 global $wgUser, $wgOut, $wgTitle;
196 if ( $this->userCanExecute( $wgUser ) ) {
197 if ( $this->mFile
) {
198 require_once( $this->mFile
);
200 $func = $this->mFunction
;
203 $this->displayRestrictionError();
207 function getDescription() {
208 return wfMsg( strtolower( $this->mName
) );
211 function getTitle() {
212 return Title
::makeTitle( NS_SPECIAL
, $this->mName
);
215 function setListed( $listed ) {
216 return wfSetVar( $this->mListed
, $listed );
220 class UnlistedSpecialPage
extends SpecialPage
222 function UnlistedSpecialPage( $name, $restriction = "", $function = false, $file = "default" ) {
223 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );