Better integration of Fork into AssetHelpers, fork startup
This commit is contained in:
parent
bb8753cd2a
commit
a4edea1e3c
12 changed files with 162 additions and 160 deletions
|
|
@ -80,59 +80,21 @@ Perform the copy operation, showing the progress.
|
|||
=cut
|
||||
|
||||
sub www_copy {
|
||||
my ( $class, $asset ) = @_;
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
|
||||
my $childrenOnly = lc $session->form->get('with') eq 'children';
|
||||
|
||||
return $session->response->stream( sub {
|
||||
my ( $session ) = @_;
|
||||
my @stack;
|
||||
|
||||
my $pb = WebGUI::ProgressBar->new($session);
|
||||
return $pb->run(
|
||||
admin => 1,
|
||||
title => $i18n->get('Copy Assets'),
|
||||
icon => $session->url->extras('adminConsole/assets.gif'),
|
||||
code => sub {
|
||||
my $bar = shift;
|
||||
# First calculate the total
|
||||
$bar->update("Preparing copy (i18n)");
|
||||
$bar->total( $asset->getDescendantCount + 1 );
|
||||
my $newAsset = $asset->duplicateBranch( $childrenOnly );
|
||||
$bar->update($i18n->get('cut'));
|
||||
my $title = sprintf("%s (%s)", $asset->getTitle, $i18n->get('copy'));
|
||||
$newAsset->update({ title => $title });
|
||||
$newAsset->cut;
|
||||
my $result = WebGUI::VersionTag->autoCommitWorkingIfEnabled(
|
||||
$session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $asset->getUrl,
|
||||
}
|
||||
);
|
||||
if ( $result eq 'redirect' ) {
|
||||
return $asset->getUrl;
|
||||
}
|
||||
return;
|
||||
},
|
||||
wrap => {
|
||||
'WebGUI::Asset::duplicateBranch' => sub {
|
||||
my ($bar, $original, $asset, @args) = @_;
|
||||
push(@stack, $asset->getTitle);
|
||||
my $ret = $asset->$original(@args);
|
||||
pop(@stack);
|
||||
return $ret;
|
||||
},
|
||||
'WebGUI::Asset::duplicate' => sub {
|
||||
my ($bar, $original, $asset, @args) = @_;
|
||||
my $name = join '/', @stack, $asset->getTitle;
|
||||
$bar->update($name);
|
||||
return $asset->$original(@args);
|
||||
},
|
||||
$asset->forkWithStatusPage({
|
||||
plugin => 'ProgressTree',
|
||||
title => 'Copy Assets',
|
||||
method => 'copyInFork',
|
||||
dialog => 1,
|
||||
message => 'Your assets are now copied!',
|
||||
args => {
|
||||
childrenOnly => $session->form->get('with') eq 'Children',
|
||||
assetId => $asset->getId,
|
||||
}
|
||||
);
|
||||
} );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -157,50 +157,25 @@ Displays the export status page
|
|||
sub www_exportStatus {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
return $session->privilege->insufficient() unless ($session->user->isInGroup(13));
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
my $pb = WebGUI::ProgressBar->new( $session );
|
||||
|
||||
my $args = {
|
||||
quiet => 1, # We'll wrap subs to update the ProgressBar
|
||||
userId => $session->form->process('userId'),
|
||||
indexFileName => $session->form->process('index'),
|
||||
extrasUploadAction => $session->form->process('extrasUploadsAction'),
|
||||
rootUrlAction => $session->form->process('rootUrlAction'),
|
||||
depth => $session->form->process('depth'),
|
||||
exportUrl => $session->form->process('exportUrl'),
|
||||
};
|
||||
|
||||
return $session->response->stream( sub {
|
||||
my ( $session ) = @_;
|
||||
return $pb->run(
|
||||
admin => 1,
|
||||
title => $i18n->get('edit branch'),
|
||||
icon => $session->url->extras('adminConsole/assets.gif'),
|
||||
code => sub {
|
||||
my ( $bar ) = @_;
|
||||
$bar->update( 'Preparing...' );
|
||||
$bar->total( $asset->getDescendantCount );
|
||||
$bar->update( 'Asset ID ' . $asset->getId );
|
||||
|
||||
my $message;
|
||||
eval {
|
||||
$message = $asset->exportAsHtml( $args );
|
||||
};
|
||||
if ( $@ ) {
|
||||
return { error => "$@" };
|
||||
}
|
||||
return { message => $message || "Export successful!" };
|
||||
},
|
||||
wrap => {
|
||||
'WebGUI::Asset::exportWriteFile' => sub {
|
||||
my ($bar, $original, $asset, @args) = @_;
|
||||
$bar->update( "Exporting " . $asset->getTitle );
|
||||
return $asset->$original(@args);
|
||||
},
|
||||
},
|
||||
);
|
||||
} );
|
||||
return $session->privilege->insufficient
|
||||
unless $session->user->isInGroup(13);
|
||||
my $form = $session->form;
|
||||
my @vars = qw(
|
||||
index depth userId extrasUploadsAction rootUrlAction exportUrl
|
||||
);
|
||||
$asset->forkWithStatusPage({
|
||||
plugin => 'ProgressTree',
|
||||
title => 'Page Export Status',
|
||||
method => 'exportInFork',
|
||||
dialog => 1,
|
||||
message => 'Your assets have been exported!',
|
||||
groupId => 13,
|
||||
args => {
|
||||
assetId => $asset->getId,
|
||||
map { $_ => scalar $form->get($_) } @vars
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue