Parent5446 has uploaded a new change for review.
https://gerrit.wikimedia.org/r/59720
Change subject: Slight improvements to FormSpecialPage behavior.
......................................................................
Slight improvements to FormSpecialPage behavior.
Added a default implementation of doing nothing
to FormSpecialPage::onSuccess to avoid forms that
don't do anything.
Added a default implementation of FormSpecialPage::setParameter
to store the parameter in a protected variable in
case the child class wants to use it.
Made FormSpecialPage::getForm first check whether the
header message text exists before adding it as header
text, for those forms that don't have header text.
Change-Id: Ifb49c3b2f4079a5fbe379c44b63ee2dcee9eeb48
---
M includes/SpecialPage.php
1 file changed, 16 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/20/59720/1
diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php
index d8f6fd9..386e7dc 100644
--- a/includes/SpecialPage.php
+++ b/includes/SpecialPage.php
@@ -909,6 +909,11 @@
* 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
@@ -949,8 +954,11 @@
$form = new HTMLForm( $this->fields, $this->getContext(),
$this->getMessagePrefix() );
$form->setSubmitCallback( array( $this, 'onSubmit' ) );
$form->setWrapperLegendMsg( $this->getMessagePrefix() .
'-legend' );
- $form->addHeaderText(
- $this->msg( $this->getMessagePrefix() . '-text'
)->parseAsBlock() );
+
+ $headerMsg = $this->msg( $this->getMessagePrefix() . '-text' );
+ if ( !$headerMsg->disabled() ) {
+ $form->addHeaderText( $headerMsg->parseAsBlock() );
+ }
// Retain query parameters (uselang etc)
$params = array_diff_key(
@@ -977,8 +985,9 @@
/**
* 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,
@@ -1000,9 +1009,11 @@
/**
* 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.
--
To view, visit https://gerrit.wikimedia.org/r/59720
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb49c3b2f4079a5fbe379c44b63ee2dcee9eeb48
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Parent5446 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits