* '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'.
+ * 'help-messages' -- array of message key. As above, each item can
+ * be an array of msg key and then parameters.
+ * Overwrites 'help-message'.
* 'required' -- passed through to the object, indicating that it
* is a required field.
* 'size' -- the length of text fields
protected $mPre = '';
protected $mHeader = '';
protected $mFooter = '';
+ protected $mSectionHeaders = array();
+ protected $mSectionFooters = array();
protected $mPost = '';
protected $mId;
* Add header text, inside the form.
* @param $msg String complete text of message to display
*/
- function addHeaderText( $msg ) { $this->mHeader .= $msg; }
+ function addHeaderText( $msg, $section = null ) {
+ if ( is_null( $section ) ) {
+ $this->mHeader .= $msg;
+ } else {
+ if ( !isset( $this->mSectionHeaders[$section] ) ) {
+ $this->mSectionHeaders[$section] = '';
+ }
+ $this->mSectionHeaders[$section] .= $msg;
+ }
+ }
/**
* Add footer text, inside the form.
* @param $msg String complete text of message to display
*/
- function addFooterText( $msg ) { $this->mFooter .= $msg; }
+ function addFooterText( $msg, $section = null ) {
+ if ( is_null( $section ) ) {
+ $this->mFooter .= $msg;
+ } else {
+ if ( !isset( $this->mSectionFooters[$section] ) ) {
+ $this->mSectionFooters[$section] = '';
+ }
+ $this->mSectionFooters[$section] .= $msg;
+ }
+ }
/**
* Add text to the end of the display.
function displayForm( $submitResult ) {
global $wgOut;
+ # For good measure (it is the default)
+ $wgOut->preventClickjacking();
+
$html = ''
. $this->getErrors( $submitResult )
. $this->mHeader
function getErrors( $errors ) {
if ( $errors instanceof Status ) {
global $wgOut;
- $errorstr = $wgOut->parse( $errors->getWikiText() );
+ if ( $errors->isOK() ) {
+ $errorstr = '';
+ } else {
+ $errorstr = $wgOut->parse( $errors->getWikiText() );
+ }
} elseif ( is_array( $errors ) ) {
$errorstr = $this->formatErrors( $errors );
} else {
} elseif ( is_array( $value ) ) {
$section = $this->displaySection( $value, $key );
$legend = wfMsg( "{$this->mMessagePrefix}-$key" );
- $subsectionHtml .= Xml::fieldset( $legend, $section ) . "\n";
+ if ( isset( $this->mSectionHeaders[$key] ) ) {
+ $section = $this->mSectionHeaders[$key] . $section;
+ }
+ if ( isset( $this->mSectionFooters[$key] ) ) {
+ $section .= $this->mSectionFooters[$key];
+ }
+ $subsectionHtml .= Xml::fieldset( $legend, $section ) . "\n";
}
}
# Never mind
$helptext = null;
}
+ } 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
+ foreach( $this->mParams['help-messages'] as $msg ) {
+ $candidate = wfMsgExt( $msg, 'parseinline' );
+ if( wfEmptyMsg( $msg ) ) {
+ $candidate = null;
+ }
+ $helptext .= $candidate; // append message
+ }
} elseif ( isset( $this->mParams['help'] ) ) {
$helptext = $this->mParams['help'];
}
# If one of the options' 'name' is int(0), it is automatically selected.
# because PHP sucks and things int(0) == 'some string'.
# Working around this by forcing all of them to strings.
- $options = array_map(
- create_function('$opt', 'return is_int($opt) ? strval($opt) : $opt;'),
- $this->mParams['options']
- );
+ foreach( $this->mParams['options'] as $key => &$opt ){
+ if( is_int( $opt ) ){
+ $opt = strval( $opt );
+ }
+ }
+ unset( $opt ); # PHP keeps $opt around as a reference, which is a bit scary
if ( !empty( $this->mParams['disabled'] ) ) {
$select->setAttribute( 'disabled', 'disabled' );
}
- $select->addOptions( $options );
+ $select->addOptions( $this->mParams['options'] );
return $select->getHTML();
}
}
public function getTableRow( $value ) {
- return "<tr><td></td><td class=\"mw-input\">"
+ if ( empty( $this->mParams['message'] ) ) {
+ $msg = wfMessage( 'edittools' );
+ } else {
+ $msg = wfMessage( $this->mParams['message'] );
+ if ( $msg->isDisabled() ) {
+ $msg = wfMessage( 'edittools' );
+ }
+ }
+ $msg->inContentLanguage();
+
+
+ return '<tr><td></td><td class="mw-input">'
. '<div class="mw-editTools">'
- . wfMsgExt( empty( $this->mParams['message'] )
- ? 'edittools' : $this->mParams['message'],
- array( 'parse', 'content' ) )
+ . $msg->parseAsBlock()
. "</div></td></tr>\n";
}
}