r113142 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113141‎ | r113142 | r113143 >
Date:15:36, 6 March 2012
Author:jeroendedauw
Status:ok
Tags:
Comment:
follow up to r113113, get rid of code ducpliation and fix docs to reflect actual behaviour
Modified paths:
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HTMLForm.php
@@ -30,13 +30,14 @@
3131 * the message.
3232 * 'label' -- alternatively, a raw text message. Overridden by
3333 * label-message
 34+ * 'help' -- message text for a message to use as a help text.
3435 * 'help-message' -- message key for a message to use as a help text.
3536 * can be an array of msg key and then parameters to
3637 * the message.
37 - * Overwrites 'help-messages'.
 38+ * Overwrites 'help-messages' and 'help'.
3839 * 'help-messages' -- array of message key. As above, each item can
3940 * be an array of msg key and then parameters.
40 - * Overwrites 'help-message'.
 41+ * Overwrites 'help'.
4142 * 'required' -- passed through to the object, indicating that it
4243 * is a required field.
4344 * 'size' -- the length of text fields
@@ -1086,31 +1087,29 @@
10871088 $helptext = null;
10881089
10891090 if ( isset( $this->mParams['help-message'] ) ) {
1090 - $helpMessage = (array)$this->mParams['help-message'];
1091 - $msg = wfMessage( array_shift( $helpMessage ), $helpMessage );
 1091+ $this->mParams['help-messages'] = (array)$this->mParams['help-message'];
 1092+ }
10921093
1093 - if ( $msg->exists() ) {
1094 - $helptext = $msg->parse();
1095 - }
1096 - } elseif ( isset( $this->mParams['help-messages'] ) ) {
1097 - # help-message can be passed a message key (string) or an array containing
1098 - # a message key and additional parameters. This makes it impossible to pass
1099 - # an array of message key
 1094+ if ( isset( $this->mParams['help-messages'] ) ) {
11001095 foreach( $this->mParams['help-messages'] as $name ) {
11011096 $helpMessage = (array)$name;
11021097 $msg = wfMessage( array_shift( $helpMessage ), $helpMessage );
11031098
11041099 if( $msg->exists() ) {
1105 - $helptext .= $msg->parse(); // append message
 1100+ $helptext .= $msg->parse(); // Append message
11061101 }
11071102 }
1108 - } elseif ( isset( $this->mParams['help'] ) ) {
 1103+ }
 1104+ elseif ( isset( $this->mParams['help'] ) ) {
11091105 $helptext = $this->mParams['help'];
11101106 }
11111107
11121108 if ( !is_null( $helptext ) ) {
1113 - $row = Html::rawElement( 'td', array( 'colspan' => 2, 'class' => 'htmlform-tip' ),
1114 - $helptext );
 1109+ $row = Html::rawElement(
 1110+ 'td',
 1111+ array( 'colspan' => 2, 'class' => 'htmlform-tip' ),
 1112+ $helptext
 1113+ );
11151114 $row = Html::rawElement( 'tr', array(), $row );
11161115 $html .= "$row\n";
11171116 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r113271Follow up to r113142; fix incorrect conversion to array (value can be array a...jeroendedauw19:07, 7 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r113113fix support for passing args to help-message(s), which was documented to be t...jeroendedauw00:32, 6 March 2012

Status & tagging log