From dd85e115075661e9e0bb92c7f6d4ab9604efd980 Mon Sep 17 00:00:00 2001 From: parent5446 Date: Wed, 17 Apr 2013 16:45:51 -0400 Subject: [PATCH] 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 --- includes/SpecialPage.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index c2814e6309..71ee4e60a1 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -924,6 +924,11 @@ class SpecialPage { * 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 @@ -973,8 +978,11 @@ abstract class FormSpecialPage extends SpecialPage { $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( @@ -1001,8 +1009,9 @@ abstract class FormSpecialPage extends SpecialPage { /** * 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, @@ -1024,9 +1033,11 @@ abstract class FormSpecialPage extends SpecialPage { /** * 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. -- 2.20.1