Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -27,62 +27,61 @@ |
28 | 28 | 'BrokenRedirects' => new UnlistedSpecialPage ( 'BrokenRedirects' ), |
29 | 29 | 'Disambiguations' => new UnlistedSpecialPage ( 'Disambiguations' ), |
30 | 30 | |
31 | | - "Userlogin" => new SpecialPage( "Userlogin" ), |
32 | | - "Userlogout" => new UnlistedSpecialPage( "Userlogout" ), |
33 | | - "Preferences" => new SpecialPage( "Preferences" ), |
34 | | - "Watchlist" => new SpecialPage( "Watchlist" ), |
35 | | - "Recentchanges" => new SpecialPage( "Recentchanges" ), |
36 | | - "Upload" => new SpecialPage( "Upload" ), |
37 | | - "Imagelist" => new SpecialPage( "Imagelist" ), |
38 | | - "Newimages" => new SpecialPage( "Newimages" ), |
39 | | - "Listusers" => new SpecialPage( "Listusers" ), |
40 | | - "Listadmins" => new SpecialPage( "Listadmins" ), |
41 | | - "Statistics" => new SpecialPage( "Statistics" ), |
42 | | - "Randompage" => new SpecialPage( "Randompage" ), |
43 | | - "Lonelypages" => new SpecialPage( "Lonelypages" ), |
44 | | - "Uncategorizedpages"=> new SpecialPage( "Uncategorizedpages" ), |
45 | | - "Unusedimages" => new SpecialPage( "Unusedimages" ) |
| 31 | + 'Userlogin' => new SpecialPage( 'Userlogin' ), |
| 32 | + 'Userlogout' => new UnlistedSpecialPage( 'Userlogout' ), |
| 33 | + 'Preferences' => new SpecialPage( 'Preferences' ), |
| 34 | + 'Watchlist' => new SpecialPage( 'Watchlist' ), |
| 35 | + 'Recentchanges' => new SpecialPage( 'Recentchanges' ), |
| 36 | + 'Upload' => new SpecialPage( 'Upload' ), |
| 37 | + 'Imagelist' => new SpecialPage( 'Imagelist' ), |
| 38 | + 'Newimages' => new SpecialPage( 'Newimages' ), |
| 39 | + 'Listusers' => new SpecialPage( 'Listusers' ), |
| 40 | + 'Listadmins' => new SpecialPage( 'Listadmins' ), |
| 41 | + 'Statistics' => new SpecialPage( 'Statistics' ), |
| 42 | + 'Randompage' => new SpecialPage( 'Randompage' ), |
| 43 | + 'Lonelypages' => new SpecialPage( 'Lonelypages' ), |
| 44 | + 'Uncategorizedpages'=> new SpecialPage( 'Uncategorizedpages' ), |
| 45 | + 'Unusedimages' => new SpecialPage( 'Unusedimages' ) |
46 | 46 | ); |
47 | 47 | global $wgDisableCounters; |
48 | 48 | if( !$wgDisableCounters ) { |
49 | | - $wgSpecialPages["Popularpages"] = new SpecialPage( "Popularpages" ); |
| 49 | + $wgSpecialPages['Popularpages'] = new SpecialPage( 'Popularpages' ); |
50 | 50 | } |
51 | 51 | $wgSpecialPages = array_merge($wgSpecialPages, array ( |
52 | | - "Wantedpages" => new SpecialPage( "Wantedpages" ), |
53 | | - "Shortpages" => new SpecialPage( "Shortpages" ), |
54 | | - "Longpages" => new SpecialPage( "Longpages" ), |
55 | | - "Newpages" => new SpecialPage( "Newpages" ), |
56 | | - "Ancientpages" => new SpecialPage( "Ancientpages" ), |
57 | | - "Deadendpages" => new SpecialPage( "Deadendpages" ), |
58 | | - "Allpages" => new SpecialPage( "Allpages" ), |
59 | | - "Ipblocklist" => new SpecialPage( "Ipblocklist" ), |
60 | | - "Maintenance" => new SpecialPage( "Maintenance" ), |
61 | | - "Specialpages" => new UnlistedSpecialPage( "Specialpages" ), |
62 | | - "Contributions" => new UnlistedSpecialPage( "Contributions" ), |
63 | | - "Emailuser" => new UnlistedSpecialPage( "Emailuser" ), |
64 | | - "Whatlinkshere" => new UnlistedSpecialPage( "Whatlinkshere" ), |
65 | | - "Recentchangeslinked" => new UnlistedSpecialPage( "Recentchangeslinked" ), |
66 | | - "Movepage" => new UnlistedSpecialPage( "Movepage" ), |
67 | | - "Blockme" => new UnlistedSpecialPage( "Blockme" ), |
68 | | - "Geo" => new UnlistedSpecialPage( "Geo" ), |
69 | | - "Validate" => new UnlistedSpecialPage( "Validate" ), |
70 | | - "Booksources" => new SpecialPage( "Booksources" ), |
71 | | - "Categories" => new SpecialPage( "Categories" ), |
72 | | - "Export" => new SpecialPage( "Export" ), |
73 | | - "Version" => new SpecialPage( "Version" ), |
74 | | - "Allmessages" => new SpecialPage( "Allmessages" ), |
75 | | - "Search" => new UnlistedSpecialPage( "Search" ), |
76 | | - "Log" => new SpecialPage( "Log" ), |
77 | | - "Blockip" => new SpecialPage( "Blockip", "sysop" ), |
78 | | - "Asksql" => new SpecialPage( "Asksql", "sysop" ), |
79 | | - "Undelete" => new SpecialPage( "Undelete", "sysop" ), |
80 | | - "Makesysop" => new SpecialPage( "Makesysop", "sysop" ), |
| 52 | + 'Wantedpages' => new SpecialPage( 'Wantedpages' ), |
| 53 | + 'Shortpages' => new SpecialPage( 'Shortpages' ), |
| 54 | + 'Longpages' => new SpecialPage( 'Longpages' ), |
| 55 | + 'Newpages' => new SpecialPage( 'Newpages' ), |
| 56 | + 'Ancientpages' => new SpecialPage( 'Ancientpages' ), |
| 57 | + 'Deadendpages' => new SpecialPage( 'Deadendpages' ), |
| 58 | + 'Allpages' => new SpecialPage( 'Allpages' ), |
| 59 | + 'Ipblocklist' => new SpecialPage( 'Ipblocklist' ), |
| 60 | + 'Maintenance' => new SpecialPage( 'Maintenance' ), |
| 61 | + 'Specialpages' => new UnlistedSpecialPage( 'Specialpages' ), |
| 62 | + 'Contributions' => new UnlistedSpecialPage( 'Contributions' ), |
| 63 | + 'Emailuser' => new UnlistedSpecialPage( 'Emailuser' ), |
| 64 | + 'Whatlinkshere' => new UnlistedSpecialPage( 'Whatlinkshere' ), |
| 65 | + 'Recentchangeslinked' => new UnlistedSpecialPage( 'Recentchangeslinked' ), |
| 66 | + 'Movepage' => new UnlistedSpecialPage( 'Movepage' ), |
| 67 | + 'Blockme' => new UnlistedSpecialPage( 'Blockme' ), |
| 68 | + 'Geo' => new UnlistedSpecialPage( 'Geo' ), |
| 69 | + 'Validate' => new UnlistedSpecialPage( 'Validate' ), |
| 70 | + 'Booksources' => new SpecialPage( 'Booksources' ), |
| 71 | + 'Categories' => new SpecialPage( 'Categories' ), |
| 72 | + 'Export' => new SpecialPage( 'Export' ), |
| 73 | + 'Version' => new SpecialPage( 'Version' ), |
| 74 | + 'Allmessages' => new SpecialPage( 'Allmessages' ), |
| 75 | + 'Search' => new UnlistedSpecialPage( 'Search' ), |
| 76 | + 'Log' => new SpecialPage( 'Log' ), |
| 77 | + 'Blockip' => new SpecialPage( 'Blockip', 'sysop' ), |
| 78 | + 'Asksql' => new SpecialPage( 'Asksql', 'sysop' ), |
| 79 | + 'Undelete' => new SpecialPage( 'Undelete', 'sysop' ), |
| 80 | + 'Makesysop' => new SpecialPage( 'Makesysop', 'sysop' ), |
81 | 81 | |
82 | 82 | # Special:Import is half-written |
83 | 83 | # "Import" => new SpecialPage( "Import", "sysop" ), |
84 | | - |
85 | | - "Lockdb" => new SpecialPage( "Lockdb", "developer" ), |
86 | | - "Unlockdb" => new SpecialPage( "Unlockdb", "developer" ), |
| 84 | + 'Lockdb' => new SpecialPage( 'Lockdb', 'developer' ), |
| 85 | + 'Unlockdb' => new SpecialPage( 'Unlockdb', 'developer' ), |
87 | 86 | // "Sitesettings" => new SpecialPage( "Sitesettings" ) |
88 | 87 | )); |
89 | 88 | |
— | — | @@ -93,32 +92,60 @@ |
94 | 93 | */ |
95 | 94 | class SpecialPage |
96 | 95 | { |
97 | | - /* private */ var $mName; # The name of the class, used in the URL. Also used for the default |
98 | | - # <h1> heading, see getDescription() |
99 | | - /* private */ var $mRestriction; # Minimum user level required to access this page, or "" |
100 | | - # for anyone. Also used to categorise the pages in |
101 | | - # Special:Specialpages |
102 | | - /* private */ var $mListed; # Listed in Special:Specialpages? |
103 | | - /* private */ var $mFunction; # Function name called by the default execute() |
104 | | - /* private */ var $mFile; # File which needs to be included before the function above can be called |
| 96 | + /**#@+ |
| 97 | + * @access private |
| 98 | + */ |
| 99 | + /** |
| 100 | + * The name of the class, used in the URL. |
| 101 | + * Also used for the default <h1> heading, @see getDescription() |
| 102 | + */ |
| 103 | + var $mName; |
| 104 | + /** |
| 105 | + * Minimum user level required to access this page, or "" for anyone. |
| 106 | + * Also used to categorise the pages in Special:Specialpages |
| 107 | + */ |
| 108 | + var $mRestriction; |
| 109 | + /** |
| 110 | + * Listed in Special:Specialpages? |
| 111 | + */ |
| 112 | + var $mListed; |
| 113 | + /** |
| 114 | + * Function name called by the default execute() |
| 115 | + */ |
| 116 | + var $mFunction; |
| 117 | + /** |
| 118 | + * File which needs to be included before the function above can be called |
| 119 | + */ |
| 120 | + var $mFile; |
| 121 | + /**#@- */ |
105 | 122 | |
106 | | - # Add a page to the list of valid special pages |
107 | | - # $obj->execute() must send HTML to $wgOut then return |
108 | | - # Use this for a special page extension |
109 | | - /* static */ function addPage( &$obj ) { |
| 123 | + /** |
| 124 | + * Add a page to the list of valid special pages |
| 125 | + * $obj->execute() must send HTML to $wgOut then return |
| 126 | + * Use this for a special page extension |
| 127 | + * @static |
| 128 | + */ |
| 129 | + function addPage( &$obj ) { |
110 | 130 | global $wgSpecialPages; |
111 | 131 | $wgSpecialPages[$obj->mName] = $obj; |
112 | 132 | } |
113 | 133 | |
114 | | - # Remove a special page from the list |
115 | | - # Occasionally used to disable expensive or dangerous special pages |
116 | | - /* static */ function removePage( $name ) { |
| 134 | + /** |
| 135 | + * Remove a special page from the list |
| 136 | + * Occasionally used to disable expensive or dangerous special pages |
| 137 | + * @static |
| 138 | + */ |
| 139 | + function removePage( $name ) { |
117 | 140 | global $wgSpecialPages; |
118 | 141 | unset( $wgSpecialPages[$name] ); |
119 | 142 | } |
120 | 143 | |
121 | | - # Find the object with a given name and return it (or NULL) |
122 | | - /* static */ function &getPage( $name ) { |
| 144 | + /** |
| 145 | + * Find the object with a given name and return it (or NULL) |
| 146 | + * @static |
| 147 | + * @param string $name |
| 148 | + */ |
| 149 | + function &getPage( $name ) { |
123 | 150 | global $wgSpecialPages; |
124 | 151 | if ( array_key_exists( $name, $wgSpecialPages ) ) { |
125 | 152 | return $wgSpecialPages[$name]; |
— | — | @@ -127,14 +154,17 @@ |
128 | 155 | } |
129 | 156 | } |
130 | 157 | |
131 | | - # Return categorised listable special pages |
132 | | - # Returns a 2d array where the first index is the restriction name |
133 | | - /* static */ function getPages() { |
| 158 | + /** |
| 159 | + * Return categorised listable special pages |
| 160 | + * Returns a 2d array where the first index is the restriction name |
| 161 | + * @static |
| 162 | + */ |
| 163 | + function getPages() { |
134 | 164 | global $wgSpecialPages; |
135 | 165 | $pages = array( |
136 | | - "" => array(), |
137 | | - "sysop" => array(), |
138 | | - "developer" => array() |
| 166 | + '' => array(), |
| 167 | + 'sysop' => array(), |
| 168 | + 'developer' => array() |
139 | 169 | ); |
140 | 170 | |
141 | 171 | foreach ( $wgSpecialPages as $name => $page ) { |
— | — | @@ -145,10 +175,14 @@ |
146 | 176 | return $pages; |
147 | 177 | } |
148 | 178 | |
149 | | - # Execute a special page path, which may contain parameters, e.g. Special:Name/Params |
150 | | - # $title should be a title object |
151 | | - # Extracts the special page name and call the execute method, passing the parameters |
152 | | - /* static */ function executePath( &$title ) { |
| 179 | + /** |
| 180 | + * Execute a special page path. |
| 181 | + * The path may contain parameters, e.g. Special:Name/Params |
| 182 | + * Extracts the special page name and call the execute method, passing the parameters |
| 183 | + * |
| 184 | + * @param $title should be a title object |
| 185 | + */ |
| 186 | + function executePath( &$title ) { |
153 | 187 | global $wgSpecialPages, $wgOut, $wgTitle; |
154 | 188 | |
155 | 189 | $bits = split( "/", $title->getDBkey(), 2 ); |
— | — | @@ -175,32 +209,32 @@ |
176 | 210 | } |
177 | 211 | } |
178 | 212 | |
179 | | - # Default constructor for special pages |
180 | | - # Derivative classes should call this from their constructor |
181 | | - # $name - the name of the special page, as seen in links and URLs |
182 | | - # $restriction - the minimum user level required, e.g. "sysop" or "developer". |
183 | | - # |
184 | | - # Note that if the user does not have the required level, an error message will |
185 | | - # be displayed by the default execute() method, without the global function ever |
186 | | - # being called. |
187 | | - # |
188 | | - # If you override execute(), you can recover the default behaviour with userCanExecute() |
189 | | - # and displayRestrictionError() |
190 | | - # |
191 | | - # $listed - whether the page is listed in Special:Specialpages |
192 | | - # $function - the function called by execute(). By default it is constructed from $name |
193 | | - # $file - the file which is included by execute(). It is also constructed from $name by default |
194 | | - # |
195 | | - function SpecialPage( $name = "", $restriction = "", $listed = true, $function = false, $file = "default" ) { |
| 213 | + /** |
| 214 | + * Default constructor for special pages |
| 215 | + * Derivative classes should call this from their constructor |
| 216 | + * Note that if the user does not have the required level, an error message will |
| 217 | + * be displayed by the default execute() method, without the global function ever |
| 218 | + * being called. |
| 219 | + * |
| 220 | + * If you override execute(), you can recover the default behaviour with userCanExecute() |
| 221 | + * and displayRestrictionError() |
| 222 | + * |
| 223 | + * @param string $name Name of the special page, as seen in links and URLs |
| 224 | + * @param string $restriction Minimum user level required, e.g. "sysop" or "developer". |
| 225 | + * @param boolean $listed Whether the page is listed in Special:Specialpages |
| 226 | + * @param string $function Function called by execute(). By default it is constructed from $name |
| 227 | + * @param string $file File which is included by execute(). It is also constructed from $name by default |
| 228 | + */ |
| 229 | + function SpecialPage( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default' ) { |
196 | 230 | $this->mName = $name; |
197 | 231 | $this->mRestriction = $restriction; |
198 | 232 | $this->mListed = $listed; |
199 | 233 | if ( $function == false ) { |
200 | | - $this->mFunction = "wfSpecial{$name}"; |
| 234 | + $this->mFunction = 'wfSpecial'.$name; |
201 | 235 | } else { |
202 | 236 | $this->mFunction = $function; |
203 | 237 | } |
204 | | - if ( $file === "default" ) { |
| 238 | + if ( $file === 'default' ) { |
205 | 239 | $this->mFile = "Special{$name}.php"; |
206 | 240 | } else { |
207 | 241 | $this->mFile = $file; |
— | — | @@ -212,8 +246,10 @@ |
213 | 247 | function getRestriction() { return $this->mRestriction; } |
214 | 248 | function isListed() { return $this->mListed; } |
215 | 249 | |
216 | | - # Checks if the given user (identified by an object) can execute this special page (as |
217 | | - # defined by $mRestriction) |
| 250 | + /** |
| 251 | + * Checks if the given user (identified by an object) can execute this |
| 252 | + * special page (as defined by $mRestriction) |
| 253 | + */ |
218 | 254 | function userCanExecute( &$user ) { |
219 | 255 | if ( $this->mRestriction == "" ) { |
220 | 256 | return true; |
— | — | @@ -226,7 +262,9 @@ |
227 | 263 | } |
228 | 264 | } |
229 | 265 | |
230 | | - # Output an error message telling the user what access level they have to have |
| 266 | + /** |
| 267 | + * Output an error message telling the user what access level they have to have |
| 268 | + */ |
231 | 269 | function displayRestrictionError() { |
232 | 270 | global $wgOut; |
233 | 271 | if ( $this->mRestriction == "developer" ) { |
— | — | @@ -236,7 +274,9 @@ |
237 | 275 | } |
238 | 276 | } |
239 | 277 | |
240 | | - # Sets headers - this should be called from the execute() method of all derived classes! |
| 278 | + /** |
| 279 | + * Sets headers - this should be called from the execute() method of all derived classes! |
| 280 | + */ |
241 | 281 | function setHeaders() { |
242 | 282 | global $wgOut; |
243 | 283 | $wgOut->setArticleRelated( false ); |
— | — | @@ -244,8 +284,10 @@ |
245 | 285 | $wgOut->setPageTitle( $this->getDescription() ); |
246 | 286 | } |
247 | 287 | |
248 | | - # Default execute method |
249 | | - # Checks user permissions, calls the function given in mFunction |
| 288 | + /** |
| 289 | + * Default execute method |
| 290 | + * Checks user permissions, calls the function given in mFunction |
| 291 | + */ |
250 | 292 | function execute( $par ) { |
251 | 293 | global $wgUser, $wgOut, $wgTitle; |
252 | 294 | |
— | — | @@ -271,12 +313,16 @@ |
272 | 314 | return wfMsg( strtolower( $this->mName ) ); |
273 | 315 | } |
274 | 316 | |
275 | | - # Get a self-referential title object |
| 317 | + /** |
| 318 | + * Get a self-referential title object |
| 319 | + */ |
276 | 320 | function getTitle() { |
277 | 321 | return Title::makeTitle( NS_SPECIAL, $this->mName ); |
278 | 322 | } |
279 | 323 | |
280 | | - # Set whether this page is listed in Special:Specialpages, at run-time |
| 324 | + /** |
| 325 | + * Set whether this page is listed in Special:Specialpages, at run-time |
| 326 | + */ |
281 | 327 | function setListed( $listed ) { |
282 | 328 | return wfSetVar( $this->mListed, $listed ); |
283 | 329 | } |
— | — | @@ -288,7 +334,7 @@ |
289 | 335 | */ |
290 | 336 | class UnlistedSpecialPage extends SpecialPage |
291 | 337 | { |
292 | | - function UnlistedSpecialPage( $name, $restriction = "", $function = false, $file = "default" ) { |
| 338 | + function UnlistedSpecialPage( $name, $restriction = '', $function = false, $file = 'default' ) { |
293 | 339 | SpecialPage::SpecialPage( $name, $restriction, false, $function, $file ); |
294 | 340 | } |
295 | 341 | } |