From a9ea6549c3b0819c45a160e128eae763834b5588 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Mon, 4 May 2009 01:27:35 +0000 Subject: [PATCH] Merged from branches/2.3 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@75905 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/LeftAndMain.php | 5 ++++ code/sitefeatures/PageCommentInterface.php | 4 +++ javascript/CMSMain_right.js | 30 ++++++++++++++++++---- javascript/LeftAndMain_left.js | 9 +++++++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 572b1e98..07c8ca8e 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -594,6 +594,7 @@ JS; // HACK: This should be turned into something more general $originalClass = $record->ClassName; $originalStatus = $record->Status; + $originalParentID = $record->ParentID; $record->HasBrokenLink = 0; $record->HasBrokenFile = 0; @@ -660,6 +661,10 @@ JS; if($originalStatus != $record->Status) { $message .= sprintf(_t('LeftAndMain.STATUSTO'," Status changed to '%s'"),$record->Status); } + + if($originalParentID != $record->ParentID) { + FormResponse::add("if(\$('sitetree').setNodeParentID) \$('sitetree').setNodeParentID($record->ID, $record->ParentID);"); + } $record->write(); diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index 30cf5d04..386a2bd1 100755 --- a/code/sitefeatures/PageCommentInterface.php +++ b/code/sitefeatures/PageCommentInterface.php @@ -153,6 +153,9 @@ class PageCommentInterface extends RequestHandler { new FormAction("postcomment", _t('PageCommentInterface.POST', 'Post')) )); + // Set it so the user gets redirected back down to the form upon form fail + $form->setRedirectToFormOnValidationError(true); + // Optional Spam Protection. if(class_exists('SpamProtecterManager')) { // Update the form to add the protecter field to it @@ -295,6 +298,7 @@ class PageCommentInterface_Form extends Form { return Director::redirect(Director::baseURL(). $page->URLSegment.'#PageComment_'.$comment->ID); } } + return Director::redirectBack(); // worst case, just go back to the page } } diff --git a/javascript/CMSMain_right.js b/javascript/CMSMain_right.js index b26e2e2c..de246c55 100755 --- a/javascript/CMSMain_right.js +++ b/javascript/CMSMain_right.js @@ -85,14 +85,34 @@ Behaviour.register({ onchange: function() { alert('The page type will be updated after the page is saved'); } - } -}); + }, -Behaviour.register({ '#Form_EditForm' : { changeDetection_fieldsToIgnore : { 'restricted-chars[Form_EditForm_URLSegment]' : true, 'Sort' : true } - } -}); + }, + + // ParentType / ParentID field combination + '#Form_EditForm_ParentType' : { + initialize : function() { + $('Form_EditForm_ParentType_root').onclick = this.rootClick.bind(this); + $('Form_EditForm_ParentType_subpage').onclick = this.showHide; + this.showHide(); + }, + + rootClick : function() { + $('Form_EditForm_ParentID').setValue(0); + this.showHide(); + }, + + showHide : function() { + if($('Form_EditForm_ParentType_root').checked) { + Element.hide('ParentID'); + } else { + Element.show('ParentID'); + } + } + } +}); \ No newline at end of file diff --git a/javascript/LeftAndMain_left.js b/javascript/LeftAndMain_left.js index 8ec1b7a9..bba33a72 100755 --- a/javascript/LeftAndMain_left.js +++ b/javascript/LeftAndMain_left.js @@ -102,6 +102,15 @@ TreeAPI.prototype = { }); }, + /** + * Set the parent ID of a tree node + */ + setNodeParentID: function (idx, parentID) { + var treeNode = this.getTreeNodeByIdx(idx); + var parentNode = this.getTreeNodeByIdx(parentID); + parentNode.appendTreeNode(treeNode); + }, + setCurrentByIdx : function(idx) { if(this.selected) { var i,item;