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

Change subject: EditPage: Factor out getSaveButtonLabel method
......................................................................


EditPage: Factor out getSaveButtonLabel method

Change-Id: I89a2e3b6b8d23b2fafa5eeec59d79e37f61edefd
---
M includes/EditPage.php
1 file changed, 22 insertions(+), 8 deletions(-)

Approvals:
  DLynch: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/EditPage.php b/includes/EditPage.php
index f97f164..a7eeeb6 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -4280,6 +4280,27 @@
        }
 
        /**
+        * Get the message key of the label for the button to save the page
+        *
+        * @return string
+        */
+       private function getSaveButtonLabel() {
+               $labelAsPublish =
+                       $this->mArticle->getContext()->getConfig()->get( 
'EditSubmitButtonLabelPublish' );
+
+               // Can't use $this->isNew as that's also true if we're adding a 
new section to an extant page
+               $newPage = !$this->mTitle->exists();
+
+               if ( $labelAsPublish ) {
+                       $buttonLabelKey =  $newPage ? 'publishpage' : 
'publishchanges';
+               } else {
+                       $buttonLabelKey = $newPage ? 'savearticle' : 
'savechanges';
+               }
+
+               return $buttonLabelKey;
+       }
+
+       /**
         * Returns an array of html code of the following buttons:
         * save, diff and preview
         *
@@ -4290,15 +4311,8 @@
        public function getEditButtons( &$tabindex ) {
                $buttons = [];
 
-               $labelAsPublish =
-                       $this->mArticle->getContext()->getConfig()->get( 
'EditSubmitButtonLabelPublish' );
+               $buttonLabelKey = $this->getSaveButtonLabel();
 
-               // Can't use $this->isNew as that's also true if we're adding a 
new section to an extant page
-               if ( $labelAsPublish ) {
-                       $buttonLabelKey = !$this->mTitle->exists() ? 
'publishpage' : 'publishchanges';
-               } else {
-                       $buttonLabelKey = !$this->mTitle->exists() ? 
'savearticle' : 'savechanges';
-               }
                $attribs = [
                        'id' => 'wpSave',
                        'name' => 'wpSave',

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I89a2e3b6b8d23b2fafa5eeec59d79e37f61edefd
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Bartosz DziewoƄski <matma....@gmail.com>
Gerrit-Reviewer: DLynch <dly...@wikimedia.org>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Tpt <thoma...@hotmail.fr>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to