MediaWiki  1.23.13
RedirectSpecialPage.php
Go to the documentation of this file.
1 <?php
29 abstract class RedirectSpecialPage extends UnlistedSpecialPage {
30  // Query parameters that can be passed through redirects
32 
33  // Query parameters added by redirects
35 
36  public function execute( $par ) {
37  $redirect = $this->getRedirect( $par );
38  $query = $this->getRedirectQuery();
39  // Redirect to a page title with possible query parameters
40  if ( $redirect instanceof Title ) {
41  $url = $redirect->getFullURL( $query );
42  $this->getOutput()->redirect( $url );
43 
44  return $redirect;
45  } elseif ( $redirect === true ) {
46  // Redirect to index.php with query parameters
47  $url = wfAppendQuery( wfScript( 'index' ), $query );
48  $this->getOutput()->redirect( $url );
49 
50  return $redirect;
51  } else {
52  $class = get_class( $this );
53  throw new MWException( "RedirectSpecialPage $class doesn't redirect!" );
54  }
55  }
56 
64  abstract public function getRedirect( $par );
65 
72  public function getRedirectQuery() {
73  $params = array();
74 
75  foreach ( $this->mAllowedRedirectParams as $arg ) {
76  if ( $this->getRequest()->getVal( $arg, null ) !== null ) {
77  $params[$arg] = $this->getRequest()->getVal( $arg );
78  }
79  }
80 
81  foreach ( $this->mAddedRedirectParams as $arg => $val ) {
82  $params[$arg] = $val;
83  }
84 
85  return count( $params )
86  ? $params
87  : false;
88  }
89 
98  public function personallyIdentifiableTarget() {
99  return false;
100  }
101 }
102 
108  protected $redirName;
109 
111  protected $redirSubpage;
112 
113  function __construct(
114  $name, $redirName, $redirSubpage = false,
115  $allowedRedirectParams = array(), $addedRedirectParams = array()
116  ) {
117  parent::__construct( $name );
118  $this->redirName = $redirName;
119  $this->redirSubpage = $redirSubpage;
120  $this->mAllowedRedirectParams = $allowedRedirectParams;
121  $this->mAddedRedirectParams = $addedRedirectParams;
122  }
123 
124  public function getRedirect( $subpage ) {
125  if ( $this->redirSubpage === false ) {
126  return SpecialPage::getTitleFor( $this->redirName, $subpage );
127  } else {
128  return SpecialPage::getTitleFor( $this->redirName, $this->redirSubpage );
129  }
130  }
131 }
132 
200 abstract class RedirectSpecialArticle extends RedirectSpecialPage {
201  function __construct( $name ) {
202  parent::__construct( $name );
203  $redirectParams = array(
204  'action',
205  'redirect', 'rdfrom',
206  # Options for preloaded edits
207  'preload', 'editintro', 'preloadtitle', 'summary', 'nosummary',
208  # Options for overriding user settings
209  'preview', 'internaledit', 'externaledit', 'mode', 'minor', 'watchthis',
210  # Options for history/diffs
211  'section', 'oldid', 'diff', 'dir',
212  'limit', 'offset', 'feed',
213  # Misc options
214  'redlink', 'debug',
215  # Options for action=raw; missing ctype can break JS or CSS in some browsers
216  'ctype', 'maxage', 'smaxage',
217  );
218 
219  wfRunHooks( "RedirectSpecialArticleRedirectParams", array( &$redirectParams ) );
220  $this->mAllowedRedirectParams = $redirectParams;
221  }
222 }
SpecialRedirectToSpecial\$redirSubpage
string $redirSubpage
Name of subpage of redirect target *.
Definition: RedirectSpecialPage.php:109
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
RedirectSpecialArticle\__construct
__construct( $name)
Definition: RedirectSpecialPage.php:199
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:535
SpecialRedirectToSpecial\__construct
__construct( $name, $redirName, $redirSubpage=false, $allowedRedirectParams=array(), $addedRedirectParams=array())
Definition: RedirectSpecialPage.php:111
SpecialRedirectToSpecial\getRedirect
getRedirect( $subpage)
If the special page is a redirect, then get the Title object it redirects to.
Definition: RedirectSpecialPage.php:122
UnlistedSpecialPage
Shortcut to construct a special page which is unlisted by default.
Definition: UnlistedSpecialPage.php:29
RedirectSpecialPage\execute
execute( $par)
Default execute method Checks user permissions, calls the function given in mFunction.
Definition: RedirectSpecialPage.php:36
SpecialRedirectToSpecial
Definition: RedirectSpecialPage.php:106
$params
$params
Definition: styleTest.css.php:40
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
RedirectSpecialPage\$mAddedRedirectParams
$mAddedRedirectParams
Definition: RedirectSpecialPage.php:34
RedirectSpecialPage
Shortcut to construct a special page alias.
Definition: RedirectSpecialPage.php:29
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:506
edits
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if so it s not worth the trouble Since there is a job queue in the jobs which is used to update link tables of transcluding pages after edits
Definition: deferred.txt:11
RedirectSpecialPage\$mAllowedRedirectParams
$mAllowedRedirectParams
Definition: RedirectSpecialPage.php:31
MWException
MediaWiki exception.
Definition: MWException.php:26
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:3786
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4058
SpecialRedirectToSpecial\$redirName
string $redirName
Name of redirect target *.
Definition: RedirectSpecialPage.php:107
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
settings
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration settings
Definition: globals.txt:25
RedirectSpecialArticle
Superclass for any RedirectSpecialPage which redirects the user to a particular article (as opposed t...
Definition: RedirectSpecialPage.php:198
user
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Definition: distributors.txt:9
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
action
action
Definition: parserTests.txt:378
options
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
some
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for some
Definition: design.txt:79
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:525
Title
Represents a title within MediaWiki.
Definition: Title.php:35
RedirectSpecialPage\getRedirect
getRedirect( $par)
If the special page is a redirect, then get the Title object it redirects to.
in
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning in
Definition: maintenance.txt:1
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
RedirectSpecialPage\getRedirectQuery
getRedirectQuery()
Return part of the request string for a special redirect page This allows passing,...
Definition: RedirectSpecialPage.php:72
$query
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105
RedirectSpecialPage\personallyIdentifiableTarget
personallyIdentifiableTarget()
Indicate if the target of this redirect can be used to identify a particular user of this wiki (e....
Definition: RedirectSpecialPage.php:98