From ecb50ed3c91a9d35d6459e29a91e90a377d54418 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Tue, 6 Mar 2012 15:36:08 +0000 Subject: [PATCH] follow up to r113113, get rid of code ducpliation and fix docs to reflect actual behaviour --- includes/HTMLForm.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index b1ae4eaede..e896c01332 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -30,13 +30,14 @@ * the message. * 'label' -- alternatively, a raw text message. Overridden by * label-message + * 'help' -- message text for a message to use as a help text. * 'help-message' -- message key for a message to use as a help text. * can be an array of msg key and then parameters to * the message. - * Overwrites 'help-messages'. + * Overwrites 'help-messages' and 'help'. * 'help-messages' -- array of message key. As above, each item can * be an array of msg key and then parameters. - * Overwrites 'help-message'. + * Overwrites 'help'. * 'required' -- passed through to the object, indicating that it * is a required field. * 'size' -- the length of text fields @@ -1086,31 +1087,29 @@ abstract class HTMLFormField { $helptext = null; if ( isset( $this->mParams['help-message'] ) ) { - $helpMessage = (array)$this->mParams['help-message']; - $msg = wfMessage( array_shift( $helpMessage ), $helpMessage ); + $this->mParams['help-messages'] = (array)$this->mParams['help-message']; + } - if ( $msg->exists() ) { - $helptext = $msg->parse(); - } - } elseif ( isset( $this->mParams['help-messages'] ) ) { - # help-message can be passed a message key (string) or an array containing - # a message key and additional parameters. This makes it impossible to pass - # an array of message key + if ( isset( $this->mParams['help-messages'] ) ) { foreach( $this->mParams['help-messages'] as $name ) { $helpMessage = (array)$name; $msg = wfMessage( array_shift( $helpMessage ), $helpMessage ); if( $msg->exists() ) { - $helptext .= $msg->parse(); // append message + $helptext .= $msg->parse(); // Append message } } - } elseif ( isset( $this->mParams['help'] ) ) { + } + elseif ( isset( $this->mParams['help'] ) ) { $helptext = $this->mParams['help']; } if ( !is_null( $helptext ) ) { - $row = Html::rawElement( 'td', array( 'colspan' => 2, 'class' => 'htmlform-tip' ), - $helptext ); + $row = Html::rawElement( + 'td', + array( 'colspan' => 2, 'class' => 'htmlform-tip' ), + $helptext + ); $row = Html::rawElement( 'tr', array(), $row ); $html .= "$row\n"; } -- 2.20.1