diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index f182cf8..a7354ee 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -297,23 +297,60 @@ protected function actionsElement(array $form, array &$form_state) { $element['operations']['actions'] = array( '#theme_wrappers' => array('dropbutton_list_wrapper') ); - $element['operations']['actions']['publish'] = array( - '#type' => 'submit', - '#value' => t('Publish'), - '#submit' => array(array($this, 'publish'), array($this, 'submit'), array($this, 'save')), - '#validate' => array(array($this, 'validate')), - '#button_type' => 'primary', - '#prefix' => '
  • ', - '#suffix' => '
  • ', - ); - $element['operations']['actions']['unpublish'] = array( - '#type' => 'submit', - '#value' => t('Unpublish'), - '#submit' => array(array($this, 'unpublish'), array($this, 'submit'), array($this, 'save')), - '#validate' => array(array($this, 'validate')), - '#prefix' => '
  • ', - "#suffix" => '
  • ', - ); + + // Depending on the state of the node (published or unpublished) and + // whether the current user has the permission to change the status, the + // labels and order of the buttons will vary. + if (user_access('administer nodes')) { + $element['operations']['actions']['publish'] = array( + '#type' => 'submit', + '#value' => t('Save and publish'), + '#submit' => array(array($this, 'publish'), array($this, 'submit'), array($this, 'save')), + '#validate' => array(array($this, 'validate')), + '#button_type' => $node->status ? 'primary' : '', + '#weight' => 0, + '#prefix' => '
  • ', + '#suffix' => '
  • ', + ); + $element['operations']['actions']['unpublish'] = array( + '#type' => 'submit', + '#value' => t('Save as unpublished'), + '#submit' => array(array($this, 'unpublish'), array($this, 'submit'), array($this, 'save')), + '#validate' => array(array($this, 'validate')), + '#button_type' => empty($node->status) ? 'primary' : '', + '#weight' => $node->status ? 1 : -1, + '#prefix' => '
  • ', + "#suffix" => '
  • ', + ); + + if (!empty($node->nid)) { + if ($node->status) { + $publish_label = t('Save and keep published'); + $unpublish_label = t('Save and unpublish'); + } + else { + $publish_label = t('Save and publish'); + $unpublish_label = t('Save and keep unpublished'); + } + $element['operations']['actions']['publish']['#value'] = $publish_label; + $element['operations']['actions']['unpublish']['#value'] = $unpublish_label; + } + } + // The user has no permission to change the status of the node. Just + // show a save button without the 'publish' or 'unpublish' callback in + // the #submit definition. + else { + $element['operations']['actions']['save'] = array( + '#type' => 'submit', + '#value' => t('Save'), + '#submit' => array(array($this, 'submit'), array($this, 'save')), + '#validate' => array(array($this, 'validate')), + '#button_type' => 'primary', + '#weight' => 1, + '#prefix' => '
  • ', + "#suffix" => '
  • ', + ); + } unset($element['submit']); diff --git a/core/modules/node/node.admin.css b/core/modules/node/node.admin.css index 866e461..829dd7d 100644 --- a/core/modules/node/node.admin.css +++ b/core/modules/node/node.admin.css @@ -11,14 +11,17 @@ } /** -* Node form dropbuttons. -*/ + * Node form dropbuttons. + */ .form-actions .dropbutton-wrapper { - width: 120px; float: left; margin-right: 1em; } +.dropbutton-wrapper .dropbutton-widget { + position: static; +} + .form-actions .dropbutton-wrapper li a, .form-actions .dropbutton-wrapper input { padding: 4px 17px;