From 5dc37e418da7d86f0b01f3a085e8ddc7e3734f53 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 16 Sep 2007 15:02:57 +0000 Subject: [PATCH] elofgren: BUGFIX: Fix the following Save/Publish bugs: "Changed icon only shows after Save button is clicked twice" http://support.silverstripe.com/gsoc/ticket/76 "Changed icon sometimes shows after "Save & Publish" button is clicked" http://support.silverstripe.com/gsoc/ticket/31 (merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@42080 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/LeftAndMain.php | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index b8fb5fb2..be47f91e 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -433,8 +433,6 @@ JS; FormResponse::add("$('Form_EditForm').elements.ID.value = \"$record->ID\";"); } - $title = Convert::raw2js($record->TreeTitle()); - if($added = DataObjectLog::getAdded('SiteTree')) { foreach($added as $page) { if($page->ID != $record->ID) $result .= $this->addTreeNodeJS($page); @@ -454,7 +452,6 @@ JS; } } - FormResponse::add("$('sitetree').setNodeTitle(\"$record->ID\", \"$title\");"); $message = _t('LeftAndMain.SAVEDUP'); @@ -486,19 +483,25 @@ JS; $record->write(); - $result .= $this->getActionUpdateJS($record); - FormResponse::status_message($message, "good"); - - FormResponse::update_status($record->Status); - - - } - // If the 'Save & Publish' button was clicked, also publish the page - if (isset($urlParams['publish']) && $urlParams['publish'] == 1) { - $this->performPublish($record); - return $this->tellBrowserAboutPublicationChange($record, "Published '$record->Title' successfully"); - } else { - return FormResponse::respond(); + // If the 'Save & Publish' button was clicked, also publish the page + if (isset($urlParams['publish']) && $urlParams['publish'] == 1) { + $this->performPublish($record); + // BUGFIX: Changed icon sometimes shows after "Save & Publish" button is clicked http://support.silverstripe.com/gsoc/ticket/31 + if(substr($id,0,3) != 'new') { + $publishedRecord = DataObject::get_one($className, "`$className`.ID = $id"); + } else { + $publishedRecord = $this->getNewItem($id, false); + } + return $this->tellBrowserAboutPublicationChange($publishedRecord, "Published '$record->Title' successfully"); + } else { + // BUGFIX: Changed icon only shows after Save button is clicked twice http://support.silverstripe.com/gsoc/ticket/76 + $title = Convert::raw2js($record->TreeTitle()); + FormResponse::add("$('sitetree').setNodeTitle(\"$record->ID\", \"$title\");"); + $result .= $this->getActionUpdateJS($record); + FormResponse::status_message($message, "good"); + FormResponse::update_status($record->Status); + return FormResponse::respond(); + } } }