change AssetHelpers to have short IDs instead of class names
This will make better code reuse: The Asset Manager will instead call the AssetHelper with the id of "cut" or "copy" to get the correct operation.
This commit is contained in:
parent
f249070c50
commit
b9e879b7aa
22 changed files with 156 additions and 115 deletions
|
|
@ -34,14 +34,14 @@ These methods are available from this class:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
=head2 process ( $asset )
|
||||
|
||||
Opens a new tab for displaying the form to change the Asset's URL.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
|
|
@ -51,20 +51,20 @@ sub process {
|
|||
}
|
||||
|
||||
return {
|
||||
openDialog => $asset->getUrl('op=assetHelper;className=WebGUI::AssetHelper::ChangeUrl;method=changeUrl;assetId=' . $asset->getId ),
|
||||
openDialog => $asset->getUrl('op=assetHelper;helperId=' . $self->id . ';method=changeUrl;assetId=' . $asset->getId ),
|
||||
};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_changeUrl ( $class, $asset )
|
||||
=head2 www_changeUrl ( $asset )
|
||||
|
||||
Displays a form to change the URL for this asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_changeUrl {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
|
|
@ -74,7 +74,7 @@ sub www_changeUrl {
|
|||
}
|
||||
my $f = WebGUI::FormBuilder->new($session, method => 'POST', action => $asset->getUrl );
|
||||
$f->addField( "hidden", name => 'op', value => 'assetHelper' );
|
||||
$f->addField( "hidden", name => 'className', value => $class );
|
||||
$f->addField( "hidden", name => 'helperId', value => $self->id );
|
||||
$f->addField( "hidden", name => "method", value=>"changeUrlSave" );
|
||||
$f->addField( "hidden", name => 'assetId', value => $asset->getId );
|
||||
$f->addField( "text",
|
||||
|
|
@ -103,7 +103,7 @@ This actually does the change url of the www_changeUrl() function.
|
|||
=cut
|
||||
|
||||
sub www_changeUrlSave {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
|
|
|
|||
|
|
@ -32,30 +32,30 @@ These methods are available from this class:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
=head2 process ( $asset )
|
||||
|
||||
Open a progress dialog for the copy operation
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
|
||||
return {
|
||||
openDialog => '?op=assetHelper;className=' . $class . ';method=copy;assetId=' . $asset->getId,
|
||||
openDialog => '?op=assetHelper;helperId=' . $self->id . ';method=copy;assetId=' . $asset->getId,
|
||||
};
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_copy ( $class, $asset )
|
||||
=head2 www_copy ( $asset )
|
||||
|
||||
Perform the copy operation, showing the progress.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_copy {
|
||||
my ( $class, $asset ) = @_;
|
||||
my ( $self, $asset ) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
|
||||
|
|
|
|||
|
|
@ -32,36 +32,36 @@ These methods are available from this class:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
=head2 process ( $asset )
|
||||
|
||||
Open a progress dialog for the copy operation
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
|
||||
return {
|
||||
openDialog => '?op=assetHelper;className=' . $class . ';method=getWith;assetId=' . $asset->getId
|
||||
openDialog => '?op=assetHelper;helperId=' . $self->id . ';method=getWith;assetId=' . $asset->getId
|
||||
};
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_getWith ( $class, $asset )
|
||||
=head2 www_getWith ( $asset )
|
||||
|
||||
Get the "with" configuration. "Descendants" or "Children".
|
||||
|
||||
=cut
|
||||
|
||||
sub www_getWith {
|
||||
my ( $class, $asset ) = @_;
|
||||
my ( $self, $asset ) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
|
||||
return '<form style="text-align: center">'
|
||||
. '<input type="hidden" name="op" value="assetHelper" />'
|
||||
. '<input type="hidden" name="className" value="' . $class . '" />'
|
||||
. '<input type="hidden" name="helperId" value="' . $self->id . '" />'
|
||||
. '<input type="hidden" name="assetId" value="' . $asset->getId . '" />'
|
||||
. '<input type="hidden" name="method" value="copy" />'
|
||||
. '<input type="submit" name="with" value="Children" />'
|
||||
|
|
@ -73,14 +73,14 @@ sub www_getWith {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_copy ( $class, $asset )
|
||||
=head2 www_copy ( $asset )
|
||||
|
||||
Perform the copy operation, showing the progress.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_copy {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
|
||||
$asset->forkWithStatusPage({
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ These methods are available from this class:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
=head2 process ( $asset )
|
||||
|
||||
Create a shortcut to the asset on the clipboard.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new( $session, 'WebGUI' );
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ These methods are available from this class:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
=head2 process ( $asset )
|
||||
|
||||
Cuts the asset to the clipboard. If the user cannot edit the asset, or the asset is a
|
||||
system asset, it returns an error message.
|
||||
|
|
@ -40,7 +40,7 @@ system asset, it returns an error message.
|
|||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'WebGUI');
|
||||
|
|
@ -52,20 +52,20 @@ sub process {
|
|||
}
|
||||
|
||||
return {
|
||||
openDialog => '?op=assetHelper;className=' . $class . ';method=cut;assetId=' . $asset->getId,
|
||||
openDialog => '?op=assetHelper;helperId=' . $self->id . ';method=cut;assetId=' . $asset->getId,
|
||||
};
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_cut ( $class, $asset )
|
||||
=head2 www_cut ( $asset )
|
||||
|
||||
Show the progress bar while cutting the asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_cut {
|
||||
my ( $class, $asset ) = @_;
|
||||
my ( $self, $asset ) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ Creates a tabform to edit the Asset Tree. If canEdit returns False, returns insu
|
|||
=cut
|
||||
|
||||
sub www_editBranch {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my ( $style, $url ) = $session->quick( qw( style url ) );
|
||||
$style->setCss( $url->extras('hoverhelp.css'));
|
||||
|
|
@ -84,7 +84,7 @@ ENDHTML
|
|||
my $change = '<br />'.$i18n->get("change") . ' ';
|
||||
my $tabform = WebGUI::TabForm->new($session);
|
||||
$tabform->hidden({name=>"op",value=>"assetHelper"});
|
||||
$tabform->hidden({name=>"className",value=>$class});
|
||||
$tabform->hidden({name=>"helperId",value=>$self->id});
|
||||
$tabform->hidden({name=>"method",value=>"editBranchSave"});
|
||||
$tabform->hidden({name=>"assetId",value=>$asset->getId});
|
||||
$tabform->addTab("properties",$i18n->get("properties"),9);
|
||||
|
|
@ -312,7 +312,7 @@ Verifies proper inputs in the Asset Tree and saves them. Returns ManageAssets me
|
|||
=cut
|
||||
|
||||
sub www_editBranchSave {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
return $session->privilege->insufficient() unless ($asset->canEdit && $session->user->isInGroup('4'));
|
||||
my $form = $session->form;
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ These methods are available from this class:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
=head2 process ( $asset )
|
||||
|
||||
Opens a new tab for displaying the form and the output for exporting a branch.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
|
|
@ -51,7 +51,7 @@ sub process {
|
|||
}
|
||||
|
||||
return {
|
||||
openDialog => '?op=assetHelper;className=' . $class . ';method=export;assetId=' . $asset->getId,
|
||||
openDialog => '?op=assetHelper;helperId=' . $self->id . ';method=export;assetId=' . $asset->getId,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ Displays the export page administrative interface
|
|||
=cut
|
||||
|
||||
sub www_export {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
return $session->privilege->insufficient() unless ($session->user->isInGroup(13));
|
||||
my ( $style, $url ) = $session->quick(qw{ style url });
|
||||
|
|
@ -81,7 +81,7 @@ ENDHTML
|
|||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
my $f = WebGUI::FormBuilder->new($session, action => $asset->getUrl);
|
||||
$f->addField( "hidden", name => 'op', value => 'assetHelper' );
|
||||
$f->addField( "hidden", name => 'className', value => $class );
|
||||
$f->addField( "hidden", name => 'helperId', value => $self->id );
|
||||
$f->addField( "hidden", name => 'assetId', value => $asset->getId );
|
||||
$f->addField( "hidden",
|
||||
name => "method",
|
||||
|
|
@ -155,7 +155,7 @@ Displays the export status page
|
|||
=cut
|
||||
|
||||
sub www_exportStatus {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
return $session->privilege->insufficient
|
||||
unless $session->user->isInGroup(13);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ These methods are available from this class:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
=head2 process ( $asset )
|
||||
|
||||
Locks the asset with a version tag. If the user cannot edit the asset, or the asset is
|
||||
already locked, it returns an error message.
|
||||
|
|
@ -41,7 +41,7 @@ already locked, it returns an error message.
|
|||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my ($self, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue