Export related assets
This commit is contained in:
parent
5c20e9c0be
commit
76e9693f4b
5 changed files with 91 additions and 3 deletions
|
|
@ -7,6 +7,7 @@
|
|||
- Snippets can now select a template parser (instead of being restricted to the configured default)
|
||||
- fixed #12081: addrees not in addressbook after user change in session
|
||||
- fixed #12089: Cannot refund item in transaction if the sku no longer exists.
|
||||
- rfe #12085: Export Related Story Topics
|
||||
|
||||
7.10.12
|
||||
- fixed #12072: Product, related and accessory assets
|
||||
|
|
|
|||
|
|
@ -240,6 +240,26 @@ sub exportAssetData {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 exportGetRelatedAssetIds
|
||||
|
||||
Overriden to include any topics in which this story would appear.
|
||||
|
||||
=cut
|
||||
|
||||
sub exportGetRelatedAssetIds {
|
||||
my $self = shift;
|
||||
my $rel = $self->SUPER::exportGetRelatedAssetIds(@_);
|
||||
push @$rel, @{
|
||||
WebGUI::Keyword->new($self->session)->getMatchingAssets({
|
||||
keywords => WebGUI::Keyword::string2list($self->get('keywords')),
|
||||
isa => 'WebGUI::Asset::Wobject::StoryTopic',
|
||||
})
|
||||
};
|
||||
return $rel;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 formatDuration ( $lastUpdated )
|
||||
|
||||
Format the time since this story was last updated. If it is longer than 1 week, then
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ sub exportBranch {
|
|||
$asset->$report('done');
|
||||
};
|
||||
|
||||
my $assetIds = $self->exportGetDescendants(undef, $depth);
|
||||
my $assetIds = $self->exportGetAssetIds($options);
|
||||
foreach my $assetId ( @{$assetIds} ) {
|
||||
$exportAsset->( $assetId );
|
||||
}
|
||||
|
|
@ -510,6 +510,33 @@ sub exportCheckExportable {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 exportGetAssetIds ( options )
|
||||
|
||||
Gets the ids of all the assets to be exported in this run as an arrayref.
|
||||
Takes the same options spec as exportBranch.
|
||||
|
||||
=cut
|
||||
|
||||
sub exportGetAssetIds {
|
||||
my ($self, $options) = @_;
|
||||
my $session = $self->session;
|
||||
my $ids = $self->exportGetDescendants( undef, $options->{depth} );
|
||||
return $ids unless $options->{exportRelated};
|
||||
# We want the ids in a descendant order, but we don't want to repeat
|
||||
# assetIds, so we're using Tie::IxHash to get an ordered set.
|
||||
tie my %set, 'Tie::IxHash';
|
||||
while (my $id = shift @$ids) {
|
||||
my $asset = WebGUI::Asset->new($session, $id);
|
||||
undef $set{$id};
|
||||
for my $id (@{ $asset->exportGetRelatedAssetIds }) {
|
||||
push(@$ids, $id) unless exists $set{$id};
|
||||
}
|
||||
}
|
||||
return [ keys %set ];
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 exportGetDescendants ( user, depth )
|
||||
|
||||
Gets the descendants of this asset for exporting, walking the lineage as the
|
||||
|
|
@ -594,6 +621,24 @@ sub exportGetDescendants {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 exportGetRelatedAssetIds
|
||||
|
||||
Normally the empty arrayref, but override if exporting your asset would
|
||||
invalidate other exported assets. If exportRelated is checked, this will be
|
||||
called and any assetIds it returns will be exported when your asset is
|
||||
exported.
|
||||
|
||||
Note: You should NOT include parents as related assets simply because they're
|
||||
your parents. If the user wants to export your parent, he can do that. This is
|
||||
for assets that aren't necessarily in your ancestry. If parents were always
|
||||
related, exporting anything would export everything.
|
||||
|
||||
=cut
|
||||
|
||||
sub exportGetRelatedAssetIds { [] }
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 exportGetUrlAsPath ( index )
|
||||
|
||||
Translates an asset's URL into an appropriate path and filename for exporting. For
|
||||
|
|
@ -670,7 +715,7 @@ sub exportInFork {
|
|||
my $session = $process->session;
|
||||
my $self = WebGUI::Asset->new( $session, delete $args->{assetId} );
|
||||
$args->{indexFileName} = delete $args->{index};
|
||||
my $assetIds = $self->exportGetDescendants( undef, $args->{depth} );
|
||||
my $assetIds = $self->exportGetAssetIds($args);
|
||||
my $tree = WebGUI::ProgressTree->new( $session, $assetIds );
|
||||
$process->update( sub { $tree->json } );
|
||||
my %reports = (
|
||||
|
|
@ -948,6 +993,12 @@ sub www_export {
|
|||
-name => "depth",
|
||||
-value => 99,
|
||||
);
|
||||
$f->yesNo(
|
||||
-label => $i18n->get('Export Related Assets'),
|
||||
-hoverHelp => $i18n->get('Export Related Assets description'),
|
||||
-name => "exportRelated",
|
||||
-value => '',
|
||||
);
|
||||
$f->selectBox(
|
||||
-label => $i18n->get('Export as user'),
|
||||
-hoverHelp => $i18n->get('Export as user description'),
|
||||
|
|
@ -1014,6 +1065,7 @@ sub www_exportStatus {
|
|||
my $form = $session->form;
|
||||
my @vars = qw(
|
||||
index depth userId extrasUploadsAction rootUrlAction exportUrl
|
||||
exportRelated
|
||||
);
|
||||
$self->forkWithStatusPage({
|
||||
plugin => 'ProgressTree',
|
||||
|
|
|
|||
|
|
@ -808,6 +808,15 @@ case of the check box list, then enter one per line. The total amount of data i
|
|||
context => q|Field label for the Export Page operation|,
|
||||
message => q|Depth|,
|
||||
},
|
||||
'Export Related Assets' => {
|
||||
lastUpdated => 1301501028,
|
||||
context => q|Field label for the Export Page operation|,
|
||||
message => q|Export Related Assets|,
|
||||
},
|
||||
'Export Related Assets description' => {
|
||||
lastUpdated => 1301501028,
|
||||
message => q|Include related assets in export?|,
|
||||
},
|
||||
'964' => {
|
||||
lastUpdated => 1052850265,
|
||||
message => q|Manage system trash.|,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ WebGUI::Test->addToCleanup($storage1, $storage2);
|
|||
#
|
||||
############################################################
|
||||
|
||||
my $tests = 46;
|
||||
my $tests = 47;
|
||||
plan tests => 1
|
||||
+ $tests
|
||||
+ $canEditMaker->plan
|
||||
|
|
@ -266,6 +266,12 @@ cmp_deeply(
|
|||
'getCrumbTrail: with topic set'
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$story->exportGetRelatedAssetIds,
|
||||
[ $topic->getId ],
|
||||
'exportGetRelatedAssetIds',
|
||||
);
|
||||
|
||||
$story->topic('');
|
||||
|
||||
############################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue