EditPage: Match the Save/Publish button's tooltip to its label
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 17 Jan 2018 16:38:09 +0000 (17:38 +0100)
committerJforrester <jforrester@wikimedia.org>
Wed, 17 Jan 2018 17:46:18 +0000 (17:46 +0000)
Change 9ca9c7ee931ec7fde5518d91593a69b16d98b13d introduced the
localisation messages for this, but they were never used.

If $wgEditSubmitButtonLabelPublish is true, the button will now use
'tooltip-publish' for title and 'accesskey-publish' for accesskey.

Bug: T185071
Change-Id: I7dd4edf99c97b2b12d8b18603bb29786c72283a5

includes/EditPage.php

index 6b02c0f..72c3c14 100644 (file)
@@ -4392,7 +4392,11 @@ class EditPage {
        public function getEditButtons( &$tabindex ) {
                $buttons = [];
 
+               $labelAsPublish =
+                       $this->context->getConfig()->get( 'EditSubmitButtonLabelPublish' );
+
                $buttonLabel = $this->context->msg( $this->getSubmitButtonLabel() )->text();
+               $buttonTooltip = $labelAsPublish ? 'publish' : 'save';
 
                $buttons['save'] = new OOUI\ButtonInputWidget( [
                        'name' => 'wpSave',
@@ -4405,8 +4409,10 @@ class EditPage {
                        'label' => $buttonLabel,
                        'infusable' => true,
                        'type' => 'submit',
-                       'title' => Linker::titleAttrib( 'save' ),
-                       'accessKey' => Linker::accesskey( 'save' ),
+                       // Messages used: tooltip-save, tooltip-publish
+                       'title' => Linker::titleAttrib( $buttonTooltip ),
+                       // Messages used: accesskey-save, accesskey-publish
+                       'accessKey' => Linker::accesskey( $buttonTooltip ),
                ] );
 
                $buttons['preview'] = new OOUI\ButtonInputWidget( [
@@ -4419,7 +4425,9 @@ class EditPage {
                        'label' => $this->context->msg( 'showpreview' )->text(),
                        'infusable' => true,
                        'type' => 'submit',
+                       // Message used: tooltip-preview
                        'title' => Linker::titleAttrib( 'preview' ),
+                       // Message used: accesskey-preview
                        'accessKey' => Linker::accesskey( 'preview' ),
                ] );
 
@@ -4433,7 +4441,9 @@ class EditPage {
                        'label' => $this->context->msg( 'showdiff' )->text(),
                        'infusable' => true,
                        'type' => 'submit',
+                       // Message used: tooltip-diff
                        'title' => Linker::titleAttrib( 'diff' ),
+                       // Message used: accesskey-diff
                        'accessKey' => Linker::accesskey( 'diff' ),
                ] );