copy asset pop-up menu
This commit is contained in:
parent
de4da68884
commit
f33e7533f4
5 changed files with 79 additions and 21 deletions
|
|
@ -1102,7 +1102,24 @@ sub getToolbar {
|
|||
$toolbar .= $self->session->icon->locked('func=manageRevisions',$self->get("url")) if ($userUiLevel >= $uiLevels->{"revisions"});
|
||||
}
|
||||
$toolbar .= $self->session->icon->cut('func=cut',$self->get("url")) if ($userUiLevel >= $uiLevels->{"cut"});
|
||||
$toolbar .= $self->session->icon->copy('func=copy',$self->get("url")) if ($userUiLevel >= $uiLevels->{"copy"});
|
||||
|
||||
# if this asset has children, create a more full-featured menu for copying
|
||||
if ($self->getChildCount) {
|
||||
my $copy = '<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var contextMenu = new contextMenu_createWithImage("'.$self->session->icon->getBaseURL().'copy.gif","'.$self->getId.'_2","'.$i18n->get('copy').'",true);';
|
||||
$copy .= 'contextMenu.addLink("'.$self->getUrl("func=copy").'","'.$i18n->get("this asset only").'");';
|
||||
$copy .= 'contextMenu.addLink("'.$self->getUrl("func=copy;with=children").'","'.$i18n->get("with children").'");';
|
||||
$copy .= 'contextMenu.addLink("'.$self->getUrl("func=copy;with=descendants").'","'.$i18n->get("with descendants").'");';
|
||||
$copy .= 'contextMenu.print();
|
||||
//]]>
|
||||
</script>';
|
||||
$toolbar .= $copy;
|
||||
}
|
||||
else {
|
||||
$toolbar .= $self->session->icon->copy('func=copy',$self->get("url")) if ($userUiLevel >= $uiLevels->{"copy"});
|
||||
}
|
||||
|
||||
$toolbar .= $self->session->icon->shortcut('func=createShortcut',$self->get("url")) if ($userUiLevel >= $uiLevels->{"shortcut"} && !($self->get("className") =~ /Shortcut/));
|
||||
$self->session->style->setLink($self->session->url->extras('contextMenu/contextMenu.css'), {rel=>"stylesheet",type=>"text/css"});
|
||||
$self->session->style->setScript($self->session->url->extras('contextMenu/contextMenu.js'), {type=>"text/javascript"});
|
||||
|
|
|
|||
|
|
@ -45,22 +45,24 @@ Duplicates this asset and the entire subtree below it. Returns the root of the
|
|||
=cut
|
||||
|
||||
sub duplicateBranch {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->duplicate({skipAutoCommitWorkflows=>1});
|
||||
my $contentPositions = $self->get("contentPositions");
|
||||
my $assetsToHide = $self->get("assetsToHide");
|
||||
my $self = shift;
|
||||
my $childrenOnly = shift || 0;
|
||||
|
||||
foreach my $child (@{$self->getLineage(["children"],{returnObjects=>1})}) {
|
||||
my $newChild = $child->duplicateBranch;
|
||||
$newChild->setParent($newAsset);
|
||||
my ($oldChildId, $newChildId) = ($child->getId, $newChild->getId);
|
||||
$contentPositions =~ s/\Q${oldChildId}\E/${newChildId}/g if ($contentPositions);
|
||||
$assetsToHide =~ s/\Q${oldChildId}\E/${newChildId}/g if ($assetsToHide);
|
||||
}
|
||||
my $newAsset = $self->duplicate({skipAutoCommitWorkflows=>1});
|
||||
my $contentPositions = $self->get("contentPositions");
|
||||
my $assetsToHide = $self->get("assetsToHide");
|
||||
|
||||
$newAsset->update({contentPositions=>$contentPositions}) if $contentPositions;
|
||||
$newAsset->update({assetsToHide=>$assetsToHide}) if $assetsToHide;
|
||||
return $newAsset;
|
||||
foreach my $child (@{$self->getLineage(["children"],{returnObjects=>1})}) {
|
||||
my $newChild = $childrenOnly ? $child->duplicate({skipAutoCommitWorkflows=>1}) : $child->duplicateBranch;
|
||||
$newChild->setParent($newAsset);
|
||||
my ($oldChildId, $newChildId) = ($child->getId, $newChild->getId);
|
||||
$contentPositions =~ s/\Q${oldChildId}\E/${newChildId}/g if ($contentPositions);
|
||||
$assetsToHide =~ s/\Q${oldChildId}\E/${newChildId}/g if ($assetsToHide);
|
||||
}
|
||||
|
||||
$newAsset->update({contentPositions=>$contentPositions}) if $contentPositions;
|
||||
$newAsset->update({assetsToHide=>$assetsToHide}) if $assetsToHide;
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -185,10 +185,23 @@ Duplicates self, cuts duplicate, returns self->getContainer->www_view if canEdit
|
|||
sub www_copy {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
my $newAsset = $self->duplicate({skipAutoCommitWorkflows => 1});
|
||||
$newAsset->update({ title=>$self->getTitle.' (copy)'});
|
||||
$newAsset->cut;
|
||||
return $self->session->asset($self->getContainer)->www_view;
|
||||
|
||||
# with: 'children' || 'descendants' || ''
|
||||
my $with = $self->session->form->get('with') || '';
|
||||
|
||||
if ($with) {
|
||||
my $childrenOnly = $with eq 'children';
|
||||
my $newAsset = $self->duplicateBranch($childrenOnly);
|
||||
$newAsset->update({ title=>$self->getTitle.' (copy)'});
|
||||
$newAsset->cut;
|
||||
return $self->session->asset($self->getContainer)->www_view;
|
||||
}
|
||||
else {
|
||||
my $newAsset = $self->duplicate({skipAutoCommitWorkflows => 1});
|
||||
$newAsset->update({ title=>$self->getTitle.' (copy)'});
|
||||
$newAsset->cut;
|
||||
return $self->session->asset($self->getContainer)->www_view;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -241,6 +241,24 @@ our $I18N = {
|
|||
context => q|Used in asset context menus.|
|
||||
},
|
||||
|
||||
'this asset only' => {
|
||||
message => q|This Asset Only|,
|
||||
lastUpdated => 0,
|
||||
context => q|Used in the small pop-up copy menu.|
|
||||
},
|
||||
|
||||
'with children' => {
|
||||
message => q|With Children|,
|
||||
lastUpdated => 0,
|
||||
context => q|Used in the small pop-up copy menu.|
|
||||
},
|
||||
|
||||
'with descendants' => {
|
||||
message => q|With Descendants|,
|
||||
lastUpdated => 0,
|
||||
context => q|Used in the small pop-up copy menu.|
|
||||
},
|
||||
|
||||
'create shortcut' => {
|
||||
message => q|Create Shortcut|,
|
||||
lastUpdated => 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue