Skip to content

Commit

Permalink
Merged revisions 48503 via svnmerge from
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Sam Minnee committed Jan 24, 2008
1 parent 17f796d commit 22f27b5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
14 changes: 13 additions & 1 deletion code/CMSMain.php
Expand Up @@ -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";
Expand Down Expand Up @@ -1202,6 +1202,18 @@ function duplicate() {
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
Expand Down
6 changes: 5 additions & 1 deletion javascript/CMSMain_left.js
Expand Up @@ -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));
},
Expand Down
9 changes: 9 additions & 0 deletions javascript/LeftAndMain_left.js
Expand Up @@ -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);
}
});
}
}

Expand Down

0 comments on commit 22f27b5

Please sign in to comment.