* @ingroup SpecialPage
*/
class SpecialPage {
-
// The canonical name of this special page
// Also used for the default <h1> heading, @see getDescription()
protected $mName;
* If you override execute(), you can recover the default behavior with userCanExecute()
* and displayRestrictionError()
*
- * @param string $name name of the special page, as seen in links and URLs
- * @param string $restriction user right required, e.g. "block" or "delete"
- * @param bool $listed whether the page is listed in Special:Specialpages
- * @param $function Callback|Bool: function called by execute(). By default it is constructed from $name
- * @param string $file file which is included by execute(). It is also constructed from $name by default
- * @param bool $includable whether the page can be included in normal pages
+ * @param string $name Name of the special page, as seen in links and URLs
+ * @param string $restriction User right required, e.g. "block" or "delete"
+ * @param bool $listed Whether the page is listed in Special:Specialpages
+ * @param Callback|Bool $function Function called by execute(). By default
+ * it is constructed from $name
+ * @param string $file File which is included by execute(). It is also
+ * constructed from $name by default
+ * @param bool $includable Whether the page can be included in normal pages
*/
public function __construct(
$name = '', $restriction = '', $listed = true,
/**
* Do the real work for the constructor, mainly so __call() can intercept
* calls to SpecialPage()
- * @param string $name name of the special page, as seen in links and URLs
- * @param string $restriction user right required, e.g. "block" or "delete"
- * @param bool $listed whether the page is listed in Special:Specialpages
- * @param $function Callback|Bool: function called by execute(). By default it is constructed from $name
- * @param string $file file which is included by execute(). It is also constructed from $name by default
- * @param bool $includable whether the page can be included in normal pages
+ * @param string $name Name of the special page, as seen in links and URLs
+ * @param string $restriction User right required, e.g. "block" or "delete"
+ * @param bool $listed Whether the page is listed in Special:Specialpages
+ * @param Callback|Bool $function Function called by execute(). By default
+ * it is constructed from $name
+ * @param string $file File which is included by execute(). It is also
+ * constructed from $name by default
+ * @param bool $includable Whether the page can be included in normal pages
*/
private function init( $name, $restriction, $listed, $function, $file, $includable ) {
$this->mName = $name;
* @return Mixed
* @deprecated since 1.18
*/
- function name( $x = null ) { wfDeprecated( __METHOD__, '1.18' ); return wfSetVar( $this->mName, $x ); }
+ function name( $x = null ) {
+ wfDeprecated( __METHOD__, '1.18' );
+ return wfSetVar( $this->mName, $x );
+ }
/**
* These mutators are very evil, as the relevant variables should not mutate. So
* @return Mixed
* @deprecated since 1.18
*/
- function restriction( $x = null ) { wfDeprecated( __METHOD__, '1.18' ); return wfSetVar( $this->mRestriction, $x ); }
+ function restriction( $x = null ) {
+ wfDeprecated( __METHOD__, '1.18' );
+ return wfSetVar( $this->mRestriction, $x );
+ }
/**
* These mutators are very evil, as the relevant variables should not mutate. So
* @return Mixed
* @deprecated since 1.18
*/
- function func( $x = null ) { wfDeprecated( __METHOD__, '1.18' ); return wfSetVar( $this->mFunction, $x ); }
+ function func( $x = null ) {
+ wfDeprecated( __METHOD__, '1.18' );
+ return wfSetVar( $this->mFunction, $x );
+ }
/**
* These mutators are very evil, as the relevant variables should not mutate. So
* @return Mixed
* @deprecated since 1.18
*/
- function file( $x = null ) { wfDeprecated( __METHOD__, '1.18' ); return wfSetVar( $this->mFile, $x ); }
+ function file( $x = null ) {
+ wfDeprecated( __METHOD__, '1.18' );
+ return wfSetVar( $this->mFile, $x );
+ }
/**
* These mutators are very evil, as the relevant variables should not mutate. So
* @return Mixed
* @deprecated since 1.18
*/
- function includable( $x = null ) { wfDeprecated( __METHOD__, '1.18' ); return wfSetVar( $this->mIncludable, $x ); }
+ function includable( $x = null ) {
+ wfDeprecated( __METHOD__, '1.18' );
+ return wfSetVar( $this->mIncludable, $x );
+ }
/**
* Whether the special page is being evaluated via transclusion
$func = $this->mFunction;
// only load file if the function does not exist
if ( !is_callable( $func ) && $this->mFile ) {
- require_once( $this->mFile );
+ require_once $this->mFile;
}
$this->outputHeader();
call_user_func( $func, $subPage, $this );
if ( $this->mContext instanceof IContextSource ) {
return $this->mContext;
} else {
- wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
+ wfDebug( __METHOD__ . " called and \$mContext is null. " .
+ "Return RequestContext::getMain(); for sanity\n" );
return RequestContext::getMain();
}
}
/**
* Shortcut to get user's language
*
- * @deprecated 1.19 Use getLanguage instead
+ * @deprecated since 1.19 Use getLanguage instead
* @return Language
* @since 1.18
*/
protected function addFeedLinks( $params ) {
global $wgFeedClasses;
- $feedTemplate = wfScript( 'api' ) . '?';
+ $feedTemplate = wfScript( 'api' );
foreach ( $wgFeedClasses as $format => $class ) {
$theseParams = $params + array( 'feedformat' => $format );
- $url = $feedTemplate . wfArrayToCgi( $theseParams );
+ $url = wfAppendQuery( $feedTemplate, $theseParams );
$this->getOutput()->addFeedLink( $format, $url );
}
}
* a new structure for SpecialPages
*/
abstract class FormSpecialPage extends SpecialPage {
+ /**
+ * The sub-page of the special page.
+ * @var string
+ */
+ protected $par = null;
/**
* Get an HTMLForm descriptor array
abstract protected function getFormFields();
/**
- * Add pre- or post-text to the form
+ * Add pre-text to the form
* @return String HTML which will be sent to $form->addPreText()
*/
- protected function preText() { return ''; }
- protected function postText() { return ''; }
+ protected function preText() {
+ return '';
+ }
+
+ /**
+ * Add post-text to the form
+ * @return String HTML which will be sent to $form->addPostText()
+ */
+ protected function postText() {
+ return '';
+ }
/**
* Play with the HTMLForm if you need to more substantially
* @param $form HTMLForm
*/
- protected function alterForm( HTMLForm $form ) {}
+ protected function alterForm( HTMLForm $form ) {
+ }
/**
* Get message prefix for HTMLForm
$form = new HTMLForm( $this->fields, $this->getContext(), $this->getMessagePrefix() );
$form->setSubmitCallback( array( $this, 'onSubmit' ) );
- $form->setWrapperLegend( $this->msg( $this->getMessagePrefix() . '-legend' ) );
- $form->addHeaderText(
- $this->msg( $this->getMessagePrefix() . '-text' )->parseAsBlock() );
+ $form->setWrapperLegendMsg( $this->getMessagePrefix() . '-legend' );
+
+ $headerMsg = $this->msg( $this->getMessagePrefix() . '-text' );
+ if ( !$headerMsg->isDisabled() ) {
+ $form->addHeaderText( $headerMsg->parseAsBlock() );
+ }
// Retain query parameters (uselang etc)
$params = array_diff_key(
/**
* Do something exciting on successful processing of the form, most likely to show a
* confirmation message
+ * @since 1.22 Default is to do nothing
*/
- abstract public function onSuccess();
+ public function onSuccess() {
+ }
/**
* Basic SpecialPage workflow: get a form, send it to the user; get some data back,
/**
* Maybe do something interesting with the subpage parameter
- * @param $par String
+ * @param string $par
*/
- protected function setParameter( $par ) {}
+ protected function setParameter( $par ) {
+ $this->par = $par;
+ }
/**
* Called from execute() to check if the given user can perform this action.
$url = $redirect->getFullURL( $query );
$this->getOutput()->redirect( $url );
return $redirect;
- // Redirect to index.php with query parameters
} elseif ( $redirect === true ) {
- global $wgScript;
- $url = $wgScript . '?' . wfArrayToCgi( $query );
+ // Redirect to index.php with query parameters
+ $url = wfAppendQuery( wfScript( 'index' ), $query );
$this->getOutput()->redirect( $url );
return $redirect;
} else {
}
abstract class SpecialRedirectToSpecial extends RedirectSpecialPage {
+ // @todo FIXME: Visibility must be declared
var $redirName, $redirSubpage;
function __construct(
* - limit, offset: Useful for linking to history of one's own user page or
* user talk page. For example, this would be a link to "the last edit to your
* user talk page in the year 2010":
- * http://en.wikipedia.org/w/index.php?title=Special:MyPage&offset=20110000000000&limit=1&action=history
+ * http://en.wikipedia.org/wiki/Special:MyPage?offset=20110000000000&limit=1&action=history
*
* - feed: would allow linking to the current user's RSS feed for their user
* talk page:
'action',
'redirect', 'rdfrom',
# Options for preloaded edits
- 'preload', 'editintro', 'preloadtitle', 'summary',
+ 'preload', 'editintro', 'preloadtitle', 'summary', 'nosummary',
# Options for overriding user settings
- 'preview', 'internaledit', 'externaledit', 'mode',
+ 'preview', 'internaledit', 'externaledit', 'mode', 'minor', 'watchthis',
# Options for history/diffs
'section', 'oldid', 'diff', 'dir',
'limit', 'offset', 'feed',