X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fhtmlform%2FHTMLFormField.php;h=3ba2156022173218c811aee159e56e298edb7126;hp=20d7250f36fef02d3d8eba281b4b8893d4b63420;hb=a2ea9f8b9289f197844e3282c2ac39e59c549996;hpb=3de7e73bd0f0ddf5d7c38fd46edfae96d1a64e40 diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 20d7250f36..3ba2156022 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -11,7 +11,7 @@ abstract class HTMLFormField { protected $mFilterCallback; protected $mName; protected $mDir; - protected $mLabel; # String label. Set on construction + protected $mLabel; # String label, as HTML. Set on construction. protected $mID; protected $mClass = ''; protected $mVFormClass = ''; @@ -49,7 +49,7 @@ abstract class HTMLFormField { * Defaults to false, which getOOUI will interpret as "use the HTML version" * * @param string $value - * @return OOUI\\Widget|false + * @return OOUI\Widget|false */ function getInputOOUI( $value ) { return false; @@ -86,6 +86,15 @@ abstract class HTMLFormField { return call_user_func_array( $callback, $args ); } + /** + * If this field has a user-visible output or not. If not, + * it will not be rendered + * + * @return bool + */ + public function hasVisibleOutput() { + return true; + } /** * Fetch a field value from $alldata for the closest field matching a given @@ -567,7 +576,7 @@ abstract class HTMLFormField { * * @param string $value The value to set the input to. * - * @return OOUI\\FieldLayout|OOUI\\ActionFieldLayout + * @return OOUI\FieldLayout|OOUI\ActionFieldLayout */ public function getOOUI( $value ) { $inputField = $this->getInputOOUI( $value ); @@ -578,7 +587,7 @@ abstract class HTMLFormField { // It might look weird, but it'll work OK. return $this->getFieldLayoutOOUI( new OOUI\Widget( array( 'content' => new OOUI\HtmlSnippet( $this->getDiv( $value ) ) ) ), - array( 'infusable' => false ) + array( 'infusable' => false, 'align' => 'top' ) ); } @@ -601,7 +610,7 @@ abstract class HTMLFormField { $config = array( 'classes' => array( "mw-htmlform-field-$fieldType", $this->mClass ), 'align' => $this->getLabelAlignOOUI(), - 'label' => $this->getLabel(), + 'label' => new OOUI\HtmlSnippet( $this->getLabel() ), 'help' => $helpText !== null ? new OOUI\HtmlSnippet( $helpText ) : null, 'errors' => $errors, 'infusable' => $infusable, @@ -620,7 +629,7 @@ abstract class HTMLFormField { /** * Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output. - * @return OOUI\\FieldLayout|OOUI\\ActionFieldLayout + * @return OOUI\FieldLayout|OOUI\ActionFieldLayout */ protected function getFieldLayoutOOUI( $inputField, $config ) { if ( isset( $this->mClassWithButton ) ) { @@ -837,7 +846,7 @@ abstract class HTMLFormField { } /** - * @return string + * @return string HTML */ function getLabel() { return is_null( $this->mLabel ) ? '' : $this->mLabel; @@ -1045,8 +1054,8 @@ abstract class HTMLFormField { foreach ( $oldoptions as $text => $data ) { $options[] = array( - 'data' => $data, - 'label' => $text, + 'data' => (string)$data, + 'label' => (string)$text, ); }