From: James D. Forrester Date: Tue, 18 Apr 2017 15:37:34 +0000 (-0700) Subject: EditPage: Factor out getSaveButtonLabel method X-Git-Tag: 1.31.0-rc.0~3424^2 X-Git-Url: http://git.cyclocoop.org/%24dirpuce/puce%24spip_lang_rtl.gif?a=commitdiff_plain;h=061ee638845927fcd409956d2a89259532fdda08;p=lhc%2Fweb%2Fwiklou.git EditPage: Factor out getSaveButtonLabel method Change-Id: I89a2e3b6b8d23b2fafa5eeec59d79e37f61edefd --- diff --git a/includes/EditPage.php b/includes/EditPage.php index f97f16469a..a7eeeb6f30 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -4279,6 +4279,27 @@ HTML return $checkboxes; } + /** + * 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 @@ HTML 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',