r4725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r4724‎ | r4725 | r4726 >
Date:02:48, 13 August 2004
Author:timwi
Status:old
Tags:
Comment:
rephrase the comment a bit to make it clearer.
Modified paths:
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPage.php
@@ -1,13 +1,14 @@
22 <?php
33 # SpecialPage: handling special pages and lists thereof
44
5 -# $wgSpecialPages is a list of all SpecialPage objects. These objects should be derived from
6 -# SpecialPage. At a minimum, they must have an execute() method, which sends the HTML for the
7 -# special page to $wgOut. The parent object has an execute() method which distributes the call
8 -# to the historical global functions.
 5+# $wgSpecialPages is a list of all SpecialPage objects. These objects are either instances of
 6+# SpecialPage or a sub-class thereof. They have an execute() method, which sends the HTML for the
 7+# special page to $wgOut. The parent class has an execute() method which distributes the call to
 8+# the historical global functions. Additionally, execute() also checks if the user has the
 9+# necessary access privileges and bails out if not.
910
10 -# To add a special page at run-time, use SpecialPage::addPage(). DO NOT add objects directly to
11 -# this list.
 11+# To add a special page at run-time, use SpecialPage::addPage().
 12+# DO NOT manipulate this array at run-time.
1213
1314 global $wgSpecialPages;
1415
@@ -72,15 +73,15 @@
7374 # Parent special page class, also static functions for handling the special page list
7475 class SpecialPage
7576 {
76 - /* private */ var $mName; # The name of the class, used in the URL. Also used for the default
 77+ /* private */ var $mName; # The name of the class, used in the URL. Also used for the default
7778 # <h1> heading, see getDescription()
78 - /* private */ var $mRestriction; # Minimum user level required to access this page, or ""
79 - # for anyone. Also used to categorise the pages in
 79+ /* private */ var $mRestriction; # Minimum user level required to access this page, or ""
 80+ # for anyone. Also used to categorise the pages in
8081 # Special:Specialpages
8182 /* private */ var $mListed; # Listed in Special:Specialpages?
8283 /* private */ var $mFunction; # Function name called by the default execute()
8384 /* private */ var $mFile; # File which needs to be included before the function above can be called
84 -
 85+
8586 # Add a page to the list of valid special pages
8687 # $obj->execute() must send HTML to $wgOut then return
8788 # Use this for a special page extension
@@ -157,15 +158,15 @@
158159 # Default constructor for special pages
159160 # Derivative classes should call this from their constructor
160161 # $name - the name of the special page, as seen in links and URLs
161 - # $restriction - the minimum user level required, e.g. "sysop" or "developer".
 162+ # $restriction - the minimum user level required, e.g. "sysop" or "developer".
162163 #
163 - # Note that if the user does not have the required level, an error message will
164 - # be displayed by the default execute() method, without the global function ever
165 - # being called.
 164+ # Note that if the user does not have the required level, an error message will
 165+ # be displayed by the default execute() method, without the global function ever
 166+ # being called.
166167 #
167168 # If you override execute(), you can recover the default behaviour with userCanExecute()
168169 # and displayRestrictionError()
169 - #
 170+ #
170171 # $listed - whether the page is listed in Special:Specialpages
171172 # $function - the function called by execute(). By default it is constructed from $name
172173 # $file - the file which is included by execute(). It is also constructed from $name by default
@@ -179,7 +180,7 @@
180181 } else {
181182 $this->mFunction = $function;
182183 }
183 - if ( $file === "default" ) {
 184+ if ( $file === "default" ) {
184185 $this->mFile = "Special{$name}.php";
185186 } else {
186187 $this->mFile = $file;
@@ -191,7 +192,7 @@
192193 function getRestriction() { return $this->mRestriction; }
193194 function isListed() { return $this->mListed; }
194195
195 - # Checks if the given user (identified by an object) can execute this special page (as
 196+ # Checks if the given user (identified by an object) can execute this special page (as
196197 # defined by $mRestriction)
197198 function userCanExecute( &$user ) {
198199 if ( $this->mRestriction == "" ) {
@@ -204,7 +205,7 @@
205206 }
206207 }
207208 }
208 -
 209+
209210 # Output an error message telling the user what access level they have to have
210211 function displayRestrictionError() {
211212 global $wgOut;
@@ -214,7 +215,7 @@
215216 $wgOut->sysopRequired();
216217 }
217218 }
218 -
 219+
219220 # Sets headers - this should be called from the execute() method of all derived classes!
220221 function setHeaders() {
221222 global $wgOut;
@@ -229,11 +230,11 @@
230231 global $wgUser, $wgOut, $wgTitle;
231232
232233 $this->setHeaders();
233 -
 234+
234235 if ( $this->userCanExecute( $wgUser ) ) {
235236 if ( $this->mFile ) {
236237 require_once( $this->mFile );
237 - }
 238+ }
238239 $func = $this->mFunction;
239240 $func( $par );
240241 } else {
@@ -241,10 +242,10 @@
242243 }
243244 }
244245
245 - # Returns the name that goes in the <h1> in the special page itself, and also the name that
 246+ # Returns the name that goes in the <h1> in the special page itself, and also the name that
246247 # will be listed in Special:Specialpages
247248 #
248 - # Derived classes can override this, but usually it is easier to keep the default behaviour.
 249+ # Derived classes can override this, but usually it is easier to keep the default behaviour.
249250 # Messages can be added at run-time, see MessageCache.php
250251 function getDescription() {
251252 return wfMsg( strtolower( $this->mName ) );

Status & tagging log