Merge "Fix some warnings from phan-taint-check"
[lhc/web/wiklou.git] / includes / htmlform / HTMLFormField.php
index 9034a1a..a88ab99 100644 (file)
@@ -462,6 +462,16 @@ abstract class HTMLFormField {
                if ( isset( $params['hide-if'] ) ) {
                        $this->mHideIf = $params['hide-if'];
                }
+
+               if ( isset( $this->mParams['notice-message'] ) ) {
+                       wfDeprecated( "'notice-message' parameter in HTMLForm", '1.32' );
+               }
+               if ( isset( $this->mParams['notice-messages'] ) ) {
+                       wfDeprecated( "'notice-messages' parameter in HTMLForm", '1.32' );
+               }
+               if ( isset( $this->mParams['notice'] ) ) {
+                       wfDeprecated( "'notice' parameter in HTMLForm", '1.32' );
+               }
        }
 
        /**
@@ -607,7 +617,7 @@ abstract class HTMLFormField {
                        $error = new OOUI\HtmlSnippet( $error );
                }
 
-               $notices = $this->getNotices();
+               $notices = $this->getNotices( 'skip deprecation' );
                foreach ( $notices as &$notice ) {
                        $notice = new OOUI\HtmlSnippet( $notice );
                }
@@ -619,6 +629,7 @@ abstract class HTMLFormField {
                        'errors' => $errors,
                        'notices' => $notices,
                        'infusable' => $infusable,
+                       'helpInline' => $this->isHelpInline(),
                ];
 
                $preloadModules = false;
@@ -679,8 +690,8 @@ abstract class HTMLFormField {
         * @return bool
         */
        protected function shouldInfuseOOUI() {
-               // Always infuse fields with help text, since the interface for it is nicer with JS
-               return $this->getHelpText() !== null;
+               // Always infuse fields with popup help text, since the interface for it is nicer with JS
+               return $this->getHelpText() !== null && !$this->isHelpInline();
        }
 
        /**
@@ -851,6 +862,18 @@ abstract class HTMLFormField {
                return $helptext;
        }
 
+       /**
+        * Determine if the help text should be displayed inline.
+        *
+        * Only applies to OOUI forms.
+        *
+        * @since 1.31
+        * @return bool
+        */
+       public function isHelpInline() {
+               return isset( $this->mParams['help-inline'] ) ? $this->mParams['help-inline'] : true;
+       }
+
        /**
         * Determine form errors to display and their classes
         * @since 1.20
@@ -907,9 +930,16 @@ abstract class HTMLFormField {
         * Determine notices to display for the field.
         *
         * @since 1.28
+        * @deprecated since 1.32
+        * @param string $skipDeprecation Pass 'skip deprecation' to avoid the deprecation
+        *   warning (since 1.32)
         * @return string[]
         */
-       public function getNotices() {
+       public function getNotices( $skipDeprecation = null ) {
+               if ( $skipDeprecation !== 'skip deprecation' ) {
+                       wfDeprecated( __METHOD__, '1.32' );
+               }
+
                $notices = [];
 
                if ( isset( $this->mParams['notice-message'] ) ) {