X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FHTMLForm.php;h=c8279bcf03c6cbdef3386e89b151d8c40abe519e;hb=de72c4ed1484f2055d6536294ee995893b81a282;hp=f2f514cdc9156066458e56e9b649c47f7fa7b8cc;hpb=707a2fa8fe3aa36e43fc020d57675daa6c073cae;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index f2f514cdc9..c8279bcf03 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -102,7 +102,7 @@ class HTMLForm { protected $mSubmitText; protected $mSubmitTooltip; - protected $mContext; // setTitle() * @param $messagePrefix String a prefix to go in front of default messages */ - public function __construct( $descriptor, /*RequestContext*/ $context = null, $messagePrefix = '' ) { - if( $context instanceof RequestContext ){ + public function __construct( $descriptor, /*IContextSource*/ $context = null, $messagePrefix = '' ) { + if( $context instanceof IContextSource ){ $this->mContext = $context; $this->mTitle = false; // We don't need them to set a title $this->mMessagePrefix = $messagePrefix; @@ -179,7 +179,8 @@ class HTMLForm { /** * Initialise a new Object for the field - * @param $descriptor input Descriptor, as described above + * @param $fieldname string + * @param $descriptor string input Descriptor, as described above * @return HTMLFormField subclass */ static function loadInputFromParameters( $fieldname, $descriptor ) { @@ -429,12 +430,18 @@ class HTMLForm { * @return String HTML. */ function getHiddenFields() { + global $wgUsePathInfo; + $html = ''; if( $this->getMethod() == 'post' ){ $html .= Html::hidden( 'wpEditToken', $this->getUser()->editToken(), array( 'id' => 'wpEditToken' ) ) . "\n"; $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; } + if ( !$wgUsePathInfo && $this->getMethod() == 'get' ) { + $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; + } + foreach ( $this->mHiddenFields as $data ) { list( $value, $attribs ) = $data; $html .= Html::hidden( $attribs['name'], $value, $attribs ) . "\n"; @@ -460,7 +467,7 @@ class HTMLForm { } if ( isset( $this->mSubmitTooltip ) ) { - $attribs += Linker::tooltipAndAccessKeyAttribs( $this->mSubmitTooltip ); + $attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip ); } $attribs['class'] = 'mw-htmlform-submit'; @@ -631,10 +638,10 @@ class HTMLForm { } /** - * @return RequestContext + * @return IContextSource */ public function getContext(){ - return $this->mContext instanceof RequestContext + return $this->mContext instanceof IContextSource ? $this->mContext : RequestContext::getMain(); } @@ -674,9 +681,11 @@ class HTMLForm { /** * TODO: Document - * @param $fields + * @param $fields array of fields (either arrays or objects) + * @param $sectionName string ID attribute of the tag for this section, ignored if empty + * @param $fieldsetIDPrefix string ID prefix for the
tag of each subsection, ignored if empty */ - function displaySection( $fields, $sectionName = '' ) { + function displaySection( $fields, $sectionName = '', $fieldsetIDPrefix = '' ) { $tableHtml = ''; $subsectionHtml = ''; $hasLeftColumn = false; @@ -688,8 +697,9 @@ class HTMLForm { : $value->getDefault(); $tableHtml .= $value->getTableRow( $v ); - if ( $value->getLabel() != ' ' ) + if ( $value->getLabel() != ' ' ) { $hasLeftColumn = true; + } } elseif ( is_array( $value ) ) { $section = $this->displaySection( $value, $key ); $legend = $this->getLegend( $key ); @@ -699,7 +709,11 @@ class HTMLForm { if ( isset( $this->mSectionFooters[$key] ) ) { $section .= $this->mSectionFooters[$key]; } - $subsectionHtml .= Xml::fieldset( $legend, $section ) . "\n"; + $attributes = array(); + if ( $fieldsetIDPrefix ) { + $attributes['id'] = Sanitizer::escapeId( "$fieldsetIDPrefix$key" ); + } + $subsectionHtml .= Xml::fieldset( $legend, $section, $attributes ) . "\n"; } } @@ -1037,7 +1051,7 @@ abstract class HTMLFormField { if ( empty( $this->mParams['tooltip'] ) ) { return array(); } - return Linker::tooltipAndAccessKeyAttribs( $this->mParams['tooltip'] ); + return Linker::tooltipAndAccesskeyAttribs( $this->mParams['tooltip'] ); } /** @@ -1371,7 +1385,8 @@ class HTMLSelectOrOtherField extends HTMLTextField { function __construct( $params ) { if ( !in_array( 'other', $params['options'], true ) ) { - $params['options'][wfMsg( 'htmlform-selectorother-other' )] = 'other'; + $msg = isset( $params['other'] ) ? $params['other'] : wfMsg( 'htmlform-selectorother-other' ); + $params['options'][$msg] = 'other'; } parent::__construct( $params );