Merged revisions 48503 via svnmerge from

http://svn.silverstripe.com/open/modules/cms/branches/2.2.1asfonz

........
  r48503 | sminnee | 2008-01-24 11:22:14 +1300 (Thu, 24 Jan 2008) | 1 line
  
  Added 'duplicate page and children' context-item in addition to 'duplicate just this page'
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@48524 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-01-24 00:01:52 +00:00
parent 17f796d0af
commit 22f27b5afa
3 changed files with 27 additions and 2 deletions

View File

@ -13,7 +13,7 @@
* @todo Create some base classes to contain the generic functionality that will be replicated.
*/
class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider {
static $tree_class = "SiteTree";
static $subitem_class = "Member";
@ -1202,6 +1202,18 @@ HTML;
user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING);
}
}
function duplicatewithchildren() {
if(($id = $this->urlParams['ID']) && is_numeric($id)) {
$page = DataObject::get_by_id("SiteTree", $id);
$newPage = $page->duplicateWithChildren();
return $this->returnItemToUser($newPage);
} else {
user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING);
}
}
/**
* Switch the cms language and reload the site tree

View File

@ -371,7 +371,11 @@ TreeContextMenu = {
'Edit this page' : function(treeNode) {
treeNode.selectTreeNode();
},
'Duplicate this page' : function(treeNode) {
'Duplicate page and children' : function(treeNode) {
// First save the page silently (without confirmation) and then duplicate the page.
autoSave(false, treeNode.duplicatePageWithChildren.bind(treeNode));
},
'Duplicate just this page' : function(treeNode) {
// First save the page silently (without confirmation) and then duplicate the page.
autoSave(false, treeNode.duplicatePage.bind(treeNode));
},

View File

@ -203,6 +203,15 @@ TreeNodeAPI.prototype = {
errorMessage('Error: ', response);
}
});
},
duplicatePageWithChildren: function() {
new Ajax.Request(baseHref() + 'admin/duplicatewithchildren/' + this.getIdx() + '?ajax=1', {
method : 'get',
onSuccess : Ajax.Evaluator,
onFailure : function(response) {
errorMessage('Error: ', response);
}
});
}
}