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 "Uncategorizedpages"=> new SpecialPage( "Uncategorizedpages" ),
17 "Unusedimages" => new SpecialPage( "Unusedimages" )
19 global $wgDisableCounters;
20 if( !$wgDisableCounters )
22 $wgSpecialPages["Popularpages"] = new SpecialPage( "Popularpages" );
24 $wgSpecialPages = array_merge($wgSpecialPages, array (
25 "Wantedpages" => new SpecialPage( "Wantedpages" ),
26 "Shortpages" => new SpecialPage( "Shortpages" ),
27 "Longpages" => new SpecialPage( "Longpages" ),
28 "Newpages" => new SpecialPage( "Newpages" ),
29 "Ancientpages" => new SpecialPage( "Ancientpages" ),
30 "Deadendpages" => new SpecialPage( "Deadendpages" ),
31 "Allpages" => new SpecialPage( "Allpages" ),
32 "Ipblocklist" => new SpecialPage( "Ipblocklist" ),
33 "Maintenance" => new SpecialPage( "Maintenance" ),
34 "Specialpages" => new UnlistedSpecialPage( "Specialpages" ),
35 "Contributions" => new UnlistedSpecialPage( "Contributions" ),
36 "Emailuser" => new UnlistedSpecialPage( "Emailuser" ),
37 "Whatlinkshere" => new UnlistedSpecialPage( "Whatlinkshere" ),
38 "Recentchangeslinked" => new UnlistedSpecialPage( "Recentchangeslinked" ),
39 "Movepage" => new UnlistedSpecialPage( "Movepage" ),
40 "Blockme" => new UnlistedSpecialPage( "Blockme" ),
41 "Geo" => new UnlistedSpecialPage( "Geo" ),
42 "Validate" => new UnlistedSpecialPage( "Validate" ),
43 "Booksources" => new SpecialPage( "Booksources" ),
44 "Categories" => new SpecialPage( "Categories" ),
45 "Export" => new SpecialPage( "Export" ),
46 "Version" => new SpecialPage( "Version" ),
47 "Allmessages" => new SpecialPage( "Allmessages" ),
48 "Search" => new UnlistedSpecialPage( "Search" ),
49 "Blockip" => new SpecialPage( "Blockip", "sysop" ),
50 "Asksql" => new SpecialPage( "Asksql", "sysop" ),
51 "Undelete" => new SpecialPage( "Undelete", "sysop" ),
52 "Makesysop" => new SpecialPage( "Makesysop", "sysop" ),
53 # "Import" => new SpecialPage( "Import", "sysop" ),
54 "Lockdb" => new SpecialPage( "Lockdb", "developer" ),
55 "Unlockdb" => new SpecialPage( "Unlockdb", "developer" )
60 /* private */ var $mName, $mRestriction, $mListed, $mFunction, $mFile;
62 /* static */ function addPage( &$obj ) {
63 global $wgSpecialPages;
64 $wgSpecialPages[$obj->mName
] = $obj;
67 /* static */ function removePage( $name ) {
68 global $wgSpecialPages;
69 unset( $wgSpecialPages[$name] );
72 /* static */ function &getPage( $name ) {
73 global $wgSpecialPages;
74 if ( array_key_exists( $name, $wgSpecialPages ) ) {
75 return $wgSpecialPages[$name];
81 # Return categorised listable special pages
82 /* static */ function getPages() {
83 global $wgSpecialPages;
87 "developer" => array()
90 foreach ( $wgSpecialPages as $name => $page ) {
91 if ( $page->isListed() ) {
92 $pages[$page->getRestriction()][$page->getName()] =& $wgSpecialPages[$name];
98 # Execute a special page path, which may contain slashes
99 /* static */ function executePath( &$title ) {
100 global $wgSpecialPages, $wgOut, $wgTitle;
102 $bits = split( "/", $title->getDBkey(), 2 );
104 if( empty( $bits[1] ) ) {
110 $page =& SpecialPage
::getPage( $name );
111 if ( is_null( $page ) ) {
112 $wgOut->setArticleRelated( false );
113 $wgOut->setRobotpolicy( "noindex,follow" );
114 $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
117 $wgTitle = Title
::makeTitle( NS_SPECIAL
, $name );
122 $page->execute( $par );
126 function SpecialPage( $name = "", $restriction = "", $listed = true, $function = false, $file = "default" ) {
127 $this->mName
= $name;
128 $this->mRestriction
= $restriction;
129 $this->mListed
= $listed;
130 if ( $function == false ) {
131 $this->mFunction
= "wfSpecial{$name}";
133 $this->mFunction
= $function;
135 if ( $file === "default" ) {
136 $this->mFile
= "Special{$name}.php";
138 $this->mFile
= $file;
142 function getName() { return $this->mName
; }
143 function getRestriction() { return $this->mRestriction
; }
144 function isListed() { return $this->mListed
; }
146 function userCanExecute( &$user ) {
147 if ( $this->mRestriction
== "" ) {
150 if ( in_array( $this->mRestriction
, $user->getRights() ) ) {
158 function displayRestrictionError() {
160 if ( $this->mRestriction
== "developer" ) {
161 $wgOut->developerRequired();
163 $wgOut->sysopRequired();
167 function setHeaders() {
169 $wgOut->setArticleRelated( false );
170 $wgOut->setRobotPolicy( "noindex,follow" );
171 $wgOut->setPageTitle( $this->getDescription() );
174 function execute( $par ) {
175 global $wgUser, $wgOut, $wgTitle;
179 if ( $this->userCanExecute( $wgUser ) ) {
180 if ( $this->mFile
) {
181 require_once( $this->mFile
);
183 $func = $this->mFunction
;
186 $this->displayRestrictionError();
190 function getDescription() {
191 return wfMsg( strtolower( $this->mName
) );
194 function getTitle() {
195 return Title
::makeTitle( NS_SPECIAL
, $this->mName
);
198 function setListed( $listed ) {
199 return wfSetVar( $this->mListed
, $listed );
203 class UnlistedSpecialPage
extends SpecialPage
205 function UnlistedSpecialPage( $name, $restriction = "", $function = false, $file = "default" ) {
206 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );