jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/401760 )

Change subject: HTMLTextAreaField: Add 'useeditfont' param
......................................................................


HTMLTextAreaField: Add 'useeditfont' param

Change-Id: I7c76e911b4d71842b49272186e880051eee8de2b
---
M includes/htmlform/fields/HTMLTextAreaField.php
M includes/specials/SpecialExpandTemplates.php
2 files changed, 41 insertions(+), 9 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/htmlform/fields/HTMLTextAreaField.php 
b/includes/htmlform/fields/HTMLTextAreaField.php
index 466a251..3370e4a 100644
--- a/includes/htmlform/fields/HTMLTextAreaField.php
+++ b/includes/htmlform/fields/HTMLTextAreaField.php
@@ -5,12 +5,14 @@
        const DEFAULT_ROWS = 25;
 
        protected $mPlaceholder = '';
+       protected $mUseEditFont = false;
 
        /**
         * @param array $params
         *   - cols, rows: textarea size
         *   - placeholder/placeholder-message: set HTML placeholder attribute
         *   - spellcheck: set HTML spellcheck attribute
+        *   - useeditfont: add CSS classes to use the same font as the 
wikitext editor
         */
        public function __construct( $params ) {
                parent::__construct( $params );
@@ -19,6 +21,10 @@
                        $this->mPlaceholder = $this->getMessage( 
$params['placeholder-message'] )->text();
                } elseif ( isset( $params['placeholder'] ) ) {
                        $this->mPlaceholder = $params['placeholder'];
+               }
+
+               if ( isset( $params['useeditfont'] ) ) {
+                       $this->mUseEditFont = $params['useeditfont'];
                }
        }
 
@@ -40,6 +46,8 @@
        }
 
        public function getInputHTML( $value ) {
+               $classes = [];
+
                $attribs = [
                                'id' => $this->mID,
                                'cols' => $this->getCols(),
@@ -48,10 +56,24 @@
                        ] + $this->getTooltipAndAccessKey();
 
                if ( $this->mClass !== '' ) {
-                       $attribs['class'] = $this->mClass;
+                       array_push( $classes, $this->mClass );
+               }
+               if ( $this->mUseEditFont ) {
+                       // The following classes can be used here:
+                       // * mw-editfont-monospace
+                       // * mw-editfont-sans-serif
+                       // * mw-editfont-serif
+                       array_push(
+                               $classes,
+                               'mw-editfont-' . 
$this->mParent->getUser()->getOption( 'editfont' )
+                       );
+                       $this->mParent->getOutput()->addModuleStyles( 
'mediawiki.editfont.styles' );
                }
                if ( $this->mPlaceholder !== '' ) {
                        $attribs['placeholder'] = $this->mPlaceholder;
+               }
+               if ( count( $classes ) ) {
+                       $attribs['class'] = implode( ' ', $classes );
                }
 
                $allowedParams = [
@@ -67,6 +89,8 @@
        }
 
        function getInputOOUI( $value ) {
+               $classes = [];
+
                if ( isset( $this->mParams['cols'] ) ) {
                        throw new Exception( "OOUIHTMLForm does not support the 
'cols' parameter for textareas" );
                }
@@ -74,11 +98,25 @@
                $attribs = $this->getTooltipAndAccessKeyOOUI();
 
                if ( $this->mClass !== '' ) {
-                       $attribs['classes'] = [ $this->mClass ];
+                       array_push( $classes, $this->mClass );
+               }
+               if ( $this->mUseEditFont ) {
+                       // The following classes can be used here:
+                       // * mw-editfont-monospace
+                       // * mw-editfont-sans-serif
+                       // * mw-editfont-serif
+                       array_push(
+                               $classes,
+                               'mw-editfont-' . 
$this->mParent->getUser()->getOption( 'editfont' )
+                       );
+                       $this->mParent->getOutput()->addModuleStyles( 
'mediawiki.editfont.styles' );
                }
                if ( $this->mPlaceholder !== '' ) {
                        $attribs['placeholder'] = $this->mPlaceholder;
                }
+               if ( count( $classes ) ) {
+                       $attribs['classes'] = $classes;
+               }
 
                $allowedParams = [
                        'tabindex',
diff --git a/includes/specials/SpecialExpandTemplates.php 
b/includes/specials/SpecialExpandTemplates.php
index 35344aa..970c903 100644
--- a/includes/specials/SpecialExpandTemplates.php
+++ b/includes/specials/SpecialExpandTemplates.php
@@ -172,11 +172,7 @@
                                'rows' => 10,
                                'default' => $input,
                                'id' => 'input',
-                               // The following classes can be used here:
-                               // * mw-editfont-monospace
-                               // * mw-editfont-sans-serif
-                               // * mw-editfont-serif
-                               'cssclass' => 'mw-editfont-' . 
$this->getUser()->getOption( 'editfont' ),
+                               'useeditfont' => true,
                        ],
                        'removecomments' => [
                                'type' => 'check',
@@ -207,8 +203,6 @@
                                'default' => $this->generateRawHtml,
                        ],
                ];
-
-               $this->getOutput()->addModuleStyles( 
'mediawiki.editfont.styles' );
 
                $form = HTMLForm::factory( 'ooui', $fields, $this->getContext() 
);
                $form

-- 
To view, visit https://gerrit.wikimedia.org/r/401760
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7c76e911b4d71842b49272186e880051eee8de2b
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to