Merge branch 'asset-helpers' into 8
Conflicts: README lib/WebGUI/Role/Asset/AlwaysHidden.pm
This commit is contained in:
commit
845ede878a
24 changed files with 2089 additions and 2 deletions
135
lib/WebGUI/AssetHelper/ChangeUrl.pm
Normal file
135
lib/WebGUI/AssetHelper/ChangeUrl.pm
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
package WebGUI::AssetHelper::ChangeUrl;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::ChangeUrl
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Changes the current URL for this Asset, and delete all previous versions of the
|
||||
asset so that it only exists via this URL.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
|
||||
Opens a new tab for displaying the form to change the Asset's URL.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
return {
|
||||
error => $i18n->get('38', 'WebGUI'),
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
open_tab => $asset->getUrl('op=assetHelper;className=WebGUI::AssetHelper::ChangeUrl;func=changeUrl'),
|
||||
};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_changeUrl ( $class, $asset )
|
||||
|
||||
Displays a form to change the URL for this asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_changeUrl {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
return {
|
||||
error => $i18n->get('38', 'WebGUI'),
|
||||
}
|
||||
}
|
||||
my $f = WebGUI::HTMLForm->new($session, action=>$asset->getUrl);
|
||||
$f->hidden(name=>"func", value=>"changeUrlSave");
|
||||
$f->hidden(name=>"proceed", value=>$session->form->param("proceed"));
|
||||
$f->text(
|
||||
name => "url",
|
||||
value => $asset->get('url'),
|
||||
label => $i18n->get("104"),
|
||||
hoverHelp=> $i18n->get('104 description'),
|
||||
);
|
||||
$f->yesNo(
|
||||
name => "confirm",
|
||||
value => 0,
|
||||
label => $i18n->get("confirm change"),
|
||||
hoverHelp=> $i18n->get("confirm change url message"),
|
||||
subtext => '<br />'.$i18n->get("confirm change url message")
|
||||
);
|
||||
$f->submit;
|
||||
return $f->print;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_changeUrlSave ( )
|
||||
|
||||
This actually does the change url of the www_changeUrl() function.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_changeUrlSave {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
return {
|
||||
error => $i18n->get('38', 'WebGUI'),
|
||||
}
|
||||
}
|
||||
$asset->_invokeWorkflowOnExportedFiles($session->setting->get('changeUrlWorkflow'), 1);
|
||||
|
||||
my $newUrl = $session->form->process("url","text");
|
||||
if ($session->form->process("confirm","yesNo") && $newUrl) {
|
||||
$asset->update({url => $newUrl});
|
||||
my $rs = $session->db->read("select revisionDate from assetData where assetId=? and revisionDate<>?",[$asset->getId, $asset->get("revisionDate")]);
|
||||
while (my ($version) = $rs->array) {
|
||||
my $old = WebGUI::Asset->new($session, $asset->getId, $asset->get("className"), $version);
|
||||
$old->purgeRevision if defined $old;
|
||||
}
|
||||
}
|
||||
|
||||
if ($session->form->param("proceed") eq "manageAssets") {
|
||||
$session->http->setRedirect($asset->getManagerUrl);
|
||||
}
|
||||
else {
|
||||
$session->http->setRedirect($asset->getUrl());
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
93
lib/WebGUI/AssetHelper/Copy.pm
Normal file
93
lib/WebGUI/AssetHelper/Copy.pm
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
package WebGUI::AssetHelper::Copy;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::Copy
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Copy an Asset to the Clipboard, with no children.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicate ( $class, $asset )
|
||||
|
||||
Duplicates the asset. Extracted out so that it can be subclassed by copy with children,
|
||||
and copy with descendants.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicate {
|
||||
my ($class, $asset) = @_;
|
||||
return $asset->duplicate;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getMessage ( )
|
||||
|
||||
Returns the name of the i18n message to use
|
||||
|
||||
=cut
|
||||
|
||||
sub getMessage {
|
||||
return 'copied asset';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
|
||||
Copies the asset to the clipboard. There are no privilege or safety checks, since all operations
|
||||
are done on the copy.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
|
||||
my $newAsset = $class->duplicate($asset);
|
||||
$newAsset->update({ title=>sprintf("%s (%s)",$asset->getTitle,$i18n->get('copy'))});
|
||||
$newAsset->cut;
|
||||
|
||||
my $message = sprintf($i18n->get($class->getMessage()), $asset->getTitle);
|
||||
|
||||
my $payload = {
|
||||
message => $message,
|
||||
};
|
||||
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $asset->getUrl,
|
||||
}) eq 'redirect') {
|
||||
$payload->{open_tab} = $session->http->getRedirectLocation;
|
||||
};
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
1;
|
||||
58
lib/WebGUI/AssetHelper/Copy/WithChildren.pm
Normal file
58
lib/WebGUI/AssetHelper/Copy/WithChildren.pm
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package WebGUI::AssetHelper::Copy::WithChildren;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper::Copy/;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::Copy::WithChildren
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Copy an Asset to the Clipboard, with children only.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicate ( $class, $asset )
|
||||
|
||||
Duplicates the asset with children,
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicate {
|
||||
my ($class, $asset) = @_;
|
||||
return $asset->duplicateBranch(1);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getMessage ( )
|
||||
|
||||
Returns the name of the i18n message to use
|
||||
|
||||
=cut
|
||||
|
||||
sub getMessage {
|
||||
return 'copied asset with children';
|
||||
}
|
||||
|
||||
1;
|
||||
58
lib/WebGUI/AssetHelper/Copy/WithDescendants.pm
Normal file
58
lib/WebGUI/AssetHelper/Copy/WithDescendants.pm
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package WebGUI::AssetHelper::Copy::WithDescendants;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper::Copy/;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::Copy::WithDescendants
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Copy an Asset to the Clipboard, with all descendants.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicate ( $class, $asset )
|
||||
|
||||
Duplicates the asset with descendants.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicate {
|
||||
my ($class, $asset) = @_;
|
||||
return $asset->duplicateBranch();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getMessage ( )
|
||||
|
||||
Returns the name of the i18n message to use
|
||||
|
||||
=cut
|
||||
|
||||
sub getMessage {
|
||||
return 'copied asset with descendants';
|
||||
}
|
||||
|
||||
1;
|
||||
69
lib/WebGUI/AssetHelper/Cut.pm
Normal file
69
lib/WebGUI/AssetHelper/Cut.pm
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
package WebGUI::AssetHelper::Cut;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::Cut
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Cuts an Asset to the Clipboard.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $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.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'WebGUI');
|
||||
if (! $asset->canEdit) {
|
||||
return { error => $i18n->get('38'), };
|
||||
}
|
||||
elsif ( $asset->get('isSystem') ) {
|
||||
return { error => $i18n->get('41'), };
|
||||
}
|
||||
|
||||
my $success = $asset->cut();
|
||||
if (! $success) {
|
||||
return { error => $i18n->get('41'), };
|
||||
}
|
||||
|
||||
my $parent = $asset->getContainer;
|
||||
if ($asset->getId eq $parent->getId) {
|
||||
$parent = $asset->getParent;
|
||||
}
|
||||
return {
|
||||
message => sprintf($i18n->get('cut asset', 'Asset'), $asset->getTitle),
|
||||
redirect => $parent->getUrl,
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
62
lib/WebGUI/AssetHelper/Demote.pm
Normal file
62
lib/WebGUI/AssetHelper/Demote.pm
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package WebGUI::AssetHelper::Demote;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::Demote
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Demotes the asset with respect to its siblings.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
|
||||
Demotes the asset. If the user cannot edit the asset it returns an error message.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'WebGUI');
|
||||
if (! $asset->canEdit) {
|
||||
return { error => $i18n->get('38'), };
|
||||
}
|
||||
|
||||
my $success = $asset->demote();
|
||||
if (! $success) {
|
||||
return {
|
||||
error => sprintf($i18n->get('unable to demote assset', 'Asset'), $asset->getTitle),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
message => sprintf($i18n->get('demoted asset', 'Asset'), $asset->getTitle),
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
390
lib/WebGUI/AssetHelper/EditBranch.pm
Normal file
390
lib/WebGUI/AssetHelper/EditBranch.pm
Normal file
|
|
@ -0,0 +1,390 @@
|
|||
package WebGUI::AssetHelper::EditBranch;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
use WebGUI::User;
|
||||
use WebGUI::HTML;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::EditBranch
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Displays the revisions for this asset.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
|
||||
Opens a new tab for displaying the form and the output for editing a branch.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
return {
|
||||
error => $i18n->get('38', 'WebGUI'),
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
open_tab => $asset->getUrl('op=assetHelper;className=WebGUI::AssetHelper::EditBranch;func=editBranch'),
|
||||
};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editBranch ( )
|
||||
|
||||
Creates a tabform to edit the Asset Tree. If canEdit returns False, returns insufficient Privilege page.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editBranch {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $ac = WebGUI::AdminConsole->new($session,"assets");
|
||||
my $i18n = WebGUI::International->new($session,"Asset");
|
||||
my $i18n2 = WebGUI::International->new($session,"Asset_Wobject");
|
||||
return $session->privilege->insufficient() unless ($asset->canEdit);
|
||||
my $change = '<br />'.$i18n->get("change") . ' ';
|
||||
my $tabform = WebGUI::TabForm->new($session);
|
||||
$tabform->hidden({name=>"func",value=>"editBranchSave"});
|
||||
$tabform->addTab("properties",$i18n->get("properties"),9);
|
||||
$tabform->getTab("properties")->readOnly(
|
||||
label => $i18n->get(104),
|
||||
hoverHelp=> $i18n->get('edit branch url help'),
|
||||
uiLevel => 9,
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_url"}),
|
||||
value => WebGUI::Form::selectBox($session, {
|
||||
name => "baseUrlBy",
|
||||
extras => 'onchange="toggleSpecificBaseUrl()"',
|
||||
id => "baseUrlBy",
|
||||
options => {
|
||||
parentUrl => $i18n->get("parent url"),
|
||||
specifiedBase => $i18n->get("specified base"),
|
||||
none => $i18n->get("none"),
|
||||
},
|
||||
})
|
||||
. '<span id="baseUrl"></span> / '
|
||||
. WebGUI::Form::selectBox($session, {
|
||||
name => "endOfUrl",
|
||||
options => {
|
||||
menuTitle => $i18n->get(411),
|
||||
title => $i18n->get(99),
|
||||
currentUrl => $i18n->get("current url"),
|
||||
}
|
||||
})
|
||||
. q!<script type="text/javascript">
|
||||
function toggleSpecificBaseUrl () {
|
||||
if (document.getElementById('baseUrlBy').options[document.getElementById('baseUrlBy').selectedIndex].value == 'specifiedBase') {
|
||||
document.getElementById('baseUrl').innerHTML='<input type="text" name="baseUrl" />';
|
||||
} else {
|
||||
document.getElementById('baseUrl').innerHTML='';
|
||||
}
|
||||
}
|
||||
toggleSpecificBaseUrl();
|
||||
</script>!
|
||||
);
|
||||
$tabform->addTab("display",$i18n->get(105),5);
|
||||
$tabform->getTab("display")->yesNo(
|
||||
name => "isHidden",
|
||||
value => $asset->get("isHidden"),
|
||||
label => $i18n->get(886),
|
||||
uiLevel => 6,
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_isHidden"}),
|
||||
hoverHelp => $i18n->get('886 description',"Asset"),
|
||||
);
|
||||
$tabform->getTab("display")->yesNo(
|
||||
name => "newWindow",
|
||||
value => $asset->get("newWindow"),
|
||||
label => $i18n->get(940),
|
||||
hoverHelp=> $i18n->get('940 description'),
|
||||
uiLevel => 6,
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_newWindow"}),
|
||||
);
|
||||
$tabform->getTab("display")->yesNo(
|
||||
name => "displayTitle",
|
||||
label => $i18n2->get(174),
|
||||
hoverHelp=> $i18n2->get('174 description'),
|
||||
value => $asset->getValue("displayTitle"),
|
||||
uiLevel => 5,
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_displayTitle"})
|
||||
);
|
||||
$tabform->getTab("display")->template(
|
||||
name => "styleTemplateId",
|
||||
label => $i18n2->get(1073),
|
||||
value => $asset->getValue("styleTemplateId"),
|
||||
hoverHelp => $i18n2->get('1073 description'),
|
||||
namespace => 'style',
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_styleTemplateId"})
|
||||
);
|
||||
$tabform->getTab("display")->template(
|
||||
name => "printableStyleTemplateId",
|
||||
label => $i18n2->get(1079),
|
||||
hoverHelp => $i18n2->get('1079 description'),
|
||||
value => $asset->getValue("printableStyleTemplateId"),
|
||||
namespace => 'style',
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_printableStyleTemplateId"})
|
||||
);
|
||||
if ( $session->setting->get('useMobileStyle') ) {
|
||||
$tabform->getTab("display")->template(
|
||||
name => 'mobileStyleTemplateId',
|
||||
label => $i18n2->get('mobileStyleTemplateId label'),
|
||||
hoverHelp => $i18n2->get('mobileStyleTemplateId description'),
|
||||
value => $asset->getValue('mobileStyleTemplateId'),
|
||||
namespace => 'style',
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_mobileStyleTemplateId"}),
|
||||
);
|
||||
}
|
||||
$tabform->addTab("security",$i18n->get(107),6);
|
||||
if ($session->config->get("sslEnabled")) {
|
||||
$tabform->getTab("security")->yesNo(
|
||||
name => "encryptPage",
|
||||
value => $asset->get("encryptPage"),
|
||||
label => $i18n->get('encrypt page'),
|
||||
hoverHelp => $i18n->get('encrypt page description',"Asset"),
|
||||
uiLevel => 6,
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_encryptPage"})
|
||||
);
|
||||
}
|
||||
$tabform->getTab("security")->user(
|
||||
name => "ownerUserId",
|
||||
label => $i18n->get(108),
|
||||
hoverHelp => $i18n->get('108 description',"Asset"),
|
||||
value => $asset->get("ownerUserId"),
|
||||
uiLevel => 6,
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_ownerUserId"})
|
||||
);
|
||||
$tabform->getTab("security")->group(
|
||||
name => "groupIdView",
|
||||
label => $i18n->get(872),
|
||||
hoverHelp => $i18n->get('872 description',"Asset"),
|
||||
value => [$asset->get("groupIdView")],
|
||||
uiLevel => 6,
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_groupIdView"})
|
||||
);
|
||||
$tabform->getTab("security")->group(
|
||||
name => "groupIdEdit",
|
||||
label => $i18n->get(871),
|
||||
hoverHelp => $i18n->get('871 description',"Asset"),
|
||||
value => [$asset->get("groupIdEdit")],
|
||||
excludeGroups => [1,7],
|
||||
uiLevel => 6,
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_groupIdEdit"})
|
||||
);
|
||||
$tabform->addTab("meta",$i18n->get("Metadata"),3);
|
||||
$tabform->getTab("meta")->textarea(
|
||||
name => "extraHeadTags",
|
||||
label => $i18n->get("extra head tags"),
|
||||
hoverHelp => $i18n->get('extra head tags description'),
|
||||
value => $asset->get("extraHeadTags"),
|
||||
uiLevel => 5,
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_extraHeadTags"})
|
||||
);
|
||||
|
||||
|
||||
$tabform->getTab("meta")->yesNo(
|
||||
name => 'usePackedHeadTags',
|
||||
label => $i18n->get('usePackedHeadTags label'),
|
||||
hoverHelp => $i18n->get('usePackedHeadTags description'),
|
||||
uiLevel => 7,
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 0,
|
||||
subtext => $change . WebGUI::Form::yesNo( $session, { name => "change_usePackedHeadTags" } ),
|
||||
);
|
||||
$tabform->getTab("meta")->yesNo(
|
||||
name => 'isPackage',
|
||||
label => $i18n->get("make package"),
|
||||
hoverHelp => $i18n->get('make package description'),
|
||||
uiLevel => 7,
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 0,
|
||||
subtext => $change . WebGUI::Form::yesNo( $session, { name => "change_isPackage" } ),
|
||||
);
|
||||
$tabform->getTab("meta")->yesNo(
|
||||
name => 'isPrototype',
|
||||
label => $i18n->get("make prototype"),
|
||||
hoverHelp => $i18n->get('make prototype description'),
|
||||
uiLevel => 9,
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 0,
|
||||
subtext => $change . WebGUI::Form::yesNo( $session, { name => "change_isPrototype" } ),
|
||||
);
|
||||
$tabform->getTab("meta")->yesNo(
|
||||
name => 'isExportable',
|
||||
label => $i18n->get('make asset exportable'),
|
||||
hoverHelp => $i18n->get('make asset exportable description'),
|
||||
uiLevel => 9,
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 1,
|
||||
subtext => $change . WebGUI::Form::yesNo( $session, { name => "change_isExportable" } ),
|
||||
);
|
||||
$tabform->getTab("meta")->yesNo(
|
||||
name => 'inheritUrlFromParent',
|
||||
label => $i18n->get('does asset inherit URL from parent'),
|
||||
hoverHelp => $i18n->get('does asset inherit URL from parent description'),
|
||||
uiLevel => 9,
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 0,
|
||||
subtext => $change . WebGUI::Form::yesNo( $session, { name => "change_inheritUrlFromParent" } ),
|
||||
);
|
||||
|
||||
if ($session->setting->get("metaDataEnabled")) {
|
||||
my $meta = $asset->getMetaDataFields();
|
||||
foreach my $field (keys %$meta) {
|
||||
my $fieldType = $meta->{$field}{fieldType} || "text";
|
||||
my $options = $meta->{$field}{possibleValues};
|
||||
# Add a "Select..." option on top of a select list to prevent from
|
||||
# saving the value on top of the list when no choice is made.
|
||||
if("\l$fieldType" eq "selectBox") {
|
||||
$options = "|" . $i18n->get("Select") . "\n" . $options;
|
||||
}
|
||||
$tabform->getTab("meta")->dynamicField(
|
||||
fieldType => $fieldType,
|
||||
name => "metadata_".$meta->{$field}{fieldId},
|
||||
label => $meta->{$field}{fieldName},
|
||||
uiLevel => 5,
|
||||
value => $meta->{$field}{value},
|
||||
extras => qq/title="$meta->{$field}{description}"/,
|
||||
options => $options,
|
||||
defaultValue => $meta->{$field}{defaultValue},
|
||||
subtext => $change . WebGUI::Form::yesNo($session,{name=>"change_metadata_".$meta->{$field}{fieldId}}),
|
||||
);
|
||||
}
|
||||
}
|
||||
return $tabform->print;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editBranchSaveStatus ( )
|
||||
|
||||
Verifies proper inputs in the Asset Tree and saves them. Returns ManageAssets method. If canEdit returns False, returns an insufficient privilege page.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editBranchSave {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
return $session->privilege->insufficient() unless ($asset->canEdit && $session->user->isInGroup('4'));
|
||||
my $form = $session->form;
|
||||
my %data;
|
||||
my $pb = WebGUI::ProgressBar->new($session);
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
$data{isHidden} = $form->yesNo("isHidden") if ($form->yesNo("change_isHidden"));
|
||||
$data{newWindow} = $form->yesNo("newWindow") if ($form->yesNo("change_newWindow"));
|
||||
$data{encryptPage} = $form->yesNo("encryptPage") if ($form->yesNo("change_encryptPage"));
|
||||
$data{ownerUserId} = $form->selectBox("ownerUserId") if ($form->yesNo("change_ownerUserId"));
|
||||
$data{groupIdView} = $form->group("groupIdView") if ($form->yesNo("change_groupIdView"));
|
||||
$data{groupIdEdit} = $form->group("groupIdEdit") if ($form->yesNo("change_groupIdEdit"));
|
||||
$data{extraHeadTags} = $form->textarea("extraHeadTags") if $form->yesNo("change_extraHeadTags");
|
||||
$data{usePackedHeadTags} = $form->yesNo("usePackedHeadTags") if $form->yesNo("change_usePackedHeadTags");
|
||||
$data{isPackage} = $form->yesNo("isPackage") if $form->yesNo("change_isPackage");
|
||||
$data{isPrototype} = $form->yesNo("isPrototype") if $form->yesNo("change_isPrototype");
|
||||
$data{isExportable} = $form->yesNo("isExportable") if $form->yesNo("change_isExportable");
|
||||
$data{inheritUrlFromParent} = $form->yesNo("inheritUrlFromParent") if $form->yesNo("change_inheritUrlFromParent");
|
||||
|
||||
my %wobjectData = %data;
|
||||
$wobjectData{displayTitle} = $form->yesNo("displayTitle") if $form->yesNo("change_displayTitle");
|
||||
$wobjectData{styleTemplateId} = $form->template("styleTemplateId") if $form->yesNo("change_styleTemplateId");
|
||||
$wobjectData{printableStyleTemplateId} = $form->template("printableStyleTemplateId") if $form->yesNo("change_printableStyleTemplateId");
|
||||
$wobjectData{mobileStyleTemplateId} = $form->template("mobileStyleTemplateId") if $form->yesNo("change_mobileStyleTemplateId");
|
||||
|
||||
my ($urlBaseBy, $urlBase, $endOfUrl);
|
||||
my $changeUrl = $form->yesNo("change_url");
|
||||
if ($changeUrl) {
|
||||
$urlBaseBy = $form->selectBox("baseUrlBy");
|
||||
$urlBase = $form->text("baseUrl");
|
||||
$endOfUrl = $form->selectBox("endOfUrl");
|
||||
}
|
||||
$pb->start($i18n->get('edit branch'), $session->url->extras('adminConsole/assets.gif'));
|
||||
my $descendants = $asset->getLineage(["self","descendants"],{returnObjects=>1});
|
||||
DESCENDANT: foreach my $descendant (@{$descendants}) {
|
||||
if ( !$descendant->canEdit ) {
|
||||
$pb->update(sprintf $i18n->get('skipping %s'), $descendant->getTitle);
|
||||
next DESCENDANT;
|
||||
}
|
||||
$pb->update(sprintf $i18n->get('editing %s'), $descendant->getTitle);
|
||||
my $url;
|
||||
if ($changeUrl) {
|
||||
if ($urlBaseBy eq "parentUrl") {
|
||||
delete $descendant->{_parent};
|
||||
$data{url} = $descendant->getParent->get("url")."/";
|
||||
}
|
||||
elsif ($urlBaseBy eq "specifiedBase") {
|
||||
$data{url} = $urlBase."/";
|
||||
}
|
||||
else {
|
||||
$data{url} = "";
|
||||
}
|
||||
if ($endOfUrl eq "menuTitle") {
|
||||
$data{url} .= $descendant->get("menuTitle");
|
||||
}
|
||||
elsif ($endOfUrl eq "title") {
|
||||
$data{url} .= $descendant->get("title");
|
||||
}
|
||||
else {
|
||||
$data{url} .= $descendant->get("url");
|
||||
}
|
||||
$wobjectData{url} = $data{url};
|
||||
}
|
||||
my $newData = $descendant->isa('WebGUI::Asset::Wobject') ? \%wobjectData : \%data;
|
||||
my $revision;
|
||||
if (scalar %$newData > 0) {
|
||||
$revision = $descendant->addRevision(
|
||||
$newData,
|
||||
undef,
|
||||
{skipAutoCommitWorkflows => 1, skipNotification => 1},
|
||||
);
|
||||
}
|
||||
else {
|
||||
$revision = $descendant;
|
||||
}
|
||||
foreach my $param ($form->param) {
|
||||
if ($param =~ /^metadata_(.*)$/) {
|
||||
my $fieldName = $1;
|
||||
if ($form->yesNo("change_metadata_".$fieldName)) {
|
||||
$revision->updateMetaData($fieldName,$form->process($form));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $asset->getUrl,
|
||||
}) eq 'redirect') {
|
||||
return undef;
|
||||
};
|
||||
delete $asset->{_parent};
|
||||
$session->asset($asset->getParent);
|
||||
##Since this method originally returned the user to the AssetManager, we don't need
|
||||
##to use $pb->finish to redirect back there.
|
||||
return $asset->getParent->www_manageAssets;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
154
lib/WebGUI/AssetHelper/ExportHtml.pm
Normal file
154
lib/WebGUI/AssetHelper/ExportHtml.pm
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
package WebGUI::AssetHelper::ExportHtml;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
use WebGUI::User;
|
||||
use WebGUI::HTML;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::ExportHtml
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Export this assets, and all children as HTML.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
|
||||
Opens a new tab for displaying the form and the output for exporting a branch.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
return {
|
||||
error => $i18n->get('38', 'WebGUI'),
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
open_tab => $asset->getUrl('op=assetHelper;className=WebGUI::AssetHelper::Export;func=editBranch'),
|
||||
};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_export
|
||||
|
||||
Displays the export page administrative interface
|
||||
|
||||
=cut
|
||||
|
||||
sub www_export {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
return $session->privilege->insufficient() unless ($session->user->isInGroup(13));
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
my $f = WebGUI::HTMLForm->new($session, -action => $asset->getUrl);
|
||||
$f->hidden(
|
||||
name => "func",
|
||||
value => "exportStatus"
|
||||
);
|
||||
$f->integer(
|
||||
label => $i18n->get('Depth'),
|
||||
hoverHelp => $i18n->get('Depth description'),
|
||||
name => "depth",
|
||||
value => 99,
|
||||
);
|
||||
$f->selectBox(
|
||||
label => $i18n->get('Export as user'),
|
||||
hoverHelp => $i18n->get('Export as user description'),
|
||||
name => "userId",
|
||||
options => $session->db->buildHashRef("select userId, username from users"),
|
||||
value => [1],
|
||||
);
|
||||
$f->text(
|
||||
label => $i18n->get("directory index"),
|
||||
hoverHelp => $i18n->get("directory index description"),
|
||||
name => "index",
|
||||
value => "index.html"
|
||||
);
|
||||
|
||||
$f->text(
|
||||
label => $i18n->get("Export site root URL"),
|
||||
name => 'exportUrl',
|
||||
value => '',
|
||||
hoverHelp => $i18n->get("Export site root URL description"),
|
||||
);
|
||||
|
||||
# TODO: maybe add copy options to these boxes alongside symlink
|
||||
$f->selectBox(
|
||||
label => $i18n->get('extrasUploads form label'),
|
||||
hoverHelp => $i18n->get('extrasUploads form hoverHelp'),
|
||||
name => "extrasUploadsAction",
|
||||
options => {
|
||||
'symlink' => $i18n->get('extrasUploads form option symlink'),
|
||||
'none' => $i18n->get('extrasUploads form option none') },
|
||||
value => ['none'],
|
||||
);
|
||||
$f->selectBox(
|
||||
label => $i18n->get('rootUrl form label'),
|
||||
hoverHelp => $i18n->get('rootUrl form hoverHelp'),
|
||||
name => "rootUrlAction",
|
||||
options => {
|
||||
'symlink' => $i18n->get('rootUrl form option symlinkDefault'),
|
||||
'none' => $i18n->get('rootUrl form option none') },
|
||||
value => ['none'],
|
||||
);
|
||||
$f->submit;
|
||||
my $message;
|
||||
eval { $asset->exportCheckPath };
|
||||
if($@) {
|
||||
$message = $@;
|
||||
}
|
||||
return $message . $f->print;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_exportStatus
|
||||
|
||||
Displays the export status page
|
||||
|
||||
=cut
|
||||
|
||||
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 $iframeUrl = $asset->getUrl('func=exportGenerate');
|
||||
foreach my $formVar (qw/index depth userId extrasUploadsAction rootUrlAction exportUrl/) {
|
||||
$iframeUrl = $session->url->append($iframeUrl, $formVar . '=' . $session->form->process($formVar));
|
||||
}
|
||||
|
||||
my $output = '<iframe src="' . $iframeUrl . '" title="' . $i18n->get('Page Export Status') . '" width="100%" height="500"></iframe>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
61
lib/WebGUI/AssetHelper/Lock.pm
Normal file
61
lib/WebGUI/AssetHelper/Lock.pm
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
package WebGUI::AssetHelper::Lock;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::Locks
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Puts an edit lock on an Asset.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $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.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
if (! $asset->canEdit) {
|
||||
return { error => $i18n->get('38', 'WebGUI'), };
|
||||
}
|
||||
elsif ( $asset->isLocked ) {
|
||||
return { error => sprintf $i18n->get('already locked'), $asset->getTitle};
|
||||
}
|
||||
|
||||
$asset = $asset->addRevision;
|
||||
|
||||
return {
|
||||
message => sprintf($i18n->get('locked asset'), $asset->getTitle),
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
58
lib/WebGUI/AssetHelper/Manage.pm
Normal file
58
lib/WebGUI/AssetHelper/Manage.pm
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package WebGUI::AssetHelper::Manage;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
use WebGUI::User;
|
||||
use WebGUI::HTML;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::Manage
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Displays the asset manager, starting at this Asset.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
|
||||
Opens a new tab for displaying the Asset Manager, starting at this Asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
return {
|
||||
error => $i18n->get('38', 'WebGUI'),
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
open_tab => $asset->getManagerUrl,
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
62
lib/WebGUI/AssetHelper/Promote.pm
Normal file
62
lib/WebGUI/AssetHelper/Promote.pm
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package WebGUI::AssetHelper::Promote;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::Promote
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Promotes the asset with respect to its siblings.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
|
||||
Promotes the asset. If the user cannot edit the asset it returns an error message.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'WebGUI');
|
||||
if (! $asset->canEdit) {
|
||||
return { error => $i18n->get('38'), };
|
||||
}
|
||||
|
||||
my $success = $asset->promote();
|
||||
if (! $success) {
|
||||
return {
|
||||
error => sprintf($i18n->get('unable to promote assset', 'Asset'), $asset->getTitle),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
message => sprintf($i18n->get('promoted asset', 'Asset'), $asset->getTitle),
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
97
lib/WebGUI/AssetHelper/Revisions.pm
Normal file
97
lib/WebGUI/AssetHelper/Revisions.pm
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
package WebGUI::AssetHelper::Revisions;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
use WebGUI::User;
|
||||
use WebGUI::HTML;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::Revisions
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Displays the revisions for this asset.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( $class, $asset )
|
||||
|
||||
Opens a new tab for displaying revisions of this asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
return {
|
||||
error => $i18n->get('38', 'WebGUI'),
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
open_tab => $asset->getUrl('op=assetHelper;className=WebGUI::AssetHelper::Revisions;func=manageRevisions'),
|
||||
};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_manageRevisions ( $class, $asset )
|
||||
|
||||
Displays a table of revision data for this asset, along with links to edit each revision, view it, or delete it.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_manageRevisions {
|
||||
my ($class, $asset) = @_;
|
||||
my $session = $asset->session;
|
||||
my $i18n = WebGUI::International->new($session, "Asset");
|
||||
if (! $asset->canEdit) {
|
||||
return {
|
||||
error => $i18n->get('38', 'WebGUI'),
|
||||
}
|
||||
}
|
||||
my $output = sprintf qq{<table style="width: 100%;" class="content">\n
|
||||
<tr><th></th><th>%s</th><th>%s</th><th>%s</th></tr>\n},
|
||||
$i18n->get('revision date'), $i18n->get('revised by'), $i18n->get('tag name');
|
||||
my $sth = $session->db->read("select ad.revisionDate, ad.revisedBy, at.name, ad.tagId from assetData as ad
|
||||
left join assetVersionTag as at on ad.tagId=at.tagId where ad.assetId=? order by revisionDate desc", [$asset->getId]);
|
||||
my $url = $asset->get('url');
|
||||
while (my ($date, $userId, $tagName, $tagId) = $sth->array) {
|
||||
my $user = WebGUI::User->new($session, $userId);
|
||||
$output .= WebGUI::HTML::arrayToRow(
|
||||
$session->icon->delete("func=purgeRevision;revisionDate=".$date, $url, $i18n->get("purge revision prompt"))
|
||||
.$session->icon->view( "func=view;revision=" . $date )
|
||||
.$session->icon->edit( "func=edit;revision=" . $date ),
|
||||
$session->datetime->epochToHuman($date),
|
||||
$user->username,
|
||||
'<a href="'.$asset->getUrl("op=manageRevisionsInTag;tagId=".$tagId).'">'.$tagName.'</a>'
|
||||
);
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -39,6 +39,7 @@ A package for manipulating and massaging HTML.
|
|||
$html = WebGUI::HTML::makeAbsolute($session, $html);
|
||||
$html = WebGUI::HTML::processReplacements($session, $html);
|
||||
$html = WebGUI::HTML::splitTag([$tag,]$html[,$count]); # defaults to ( 'p', $html, 1 )
|
||||
$html = WebGUI::HTML::arrayToRow(@columnData);
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
|
|
@ -47,6 +48,27 @@ These methods are available from this package:
|
|||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 arrayToRow ( @columnData )
|
||||
|
||||
Wraps each element of @columnData in a table cell tag, concatenates them all together,
|
||||
and then wraps that in table row tags.
|
||||
|
||||
=head3 @columnData
|
||||
|
||||
An array of strings to wrap.
|
||||
|
||||
=cut
|
||||
|
||||
sub arrayToRow {
|
||||
my @columnData = @_;
|
||||
my $output = '<tr><td>';
|
||||
$output .= join '</td><td>', @columnData;
|
||||
$output .= '</td></tr>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 cleanSegment ( html , preserveStyleScript )
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ Asset Role that guarantees that the isHidden property is always 1.
|
|||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Despite using OO style methods, there are no AssetHelper objects. This is simply to provide inheritance.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
with WebGUI::Role::Asset::AlwaysHidden;
|
||||
|
||||
=cut
|
||||
|
|
@ -40,6 +44,4 @@ around isHidden => sub {
|
|||
$self->$orig(@_);
|
||||
};
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -1370,6 +1370,66 @@ Couldn't open %-s because %-s <br />
|
|||
context => q{},
|
||||
},
|
||||
|
||||
'cut asset' => {
|
||||
message => q{Asset %s was cut to the clipboard.},
|
||||
lastUpdated => 0,
|
||||
context => q{%s will be replaced by the title of the asset.},
|
||||
},
|
||||
|
||||
'copied asset' => {
|
||||
message => q{Asset %s was copied to the clipboard.},
|
||||
lastUpdated => 0,
|
||||
context => q{%s will be replaced by the title of the asset.},
|
||||
},
|
||||
|
||||
'copied asset with children' => {
|
||||
message => q{Asset %s was copied to the clipboard with its children.},
|
||||
lastUpdated => 0,
|
||||
context => q{%s will be replaced by the title of the asset.},
|
||||
},
|
||||
|
||||
'copied asset with descendants' => {
|
||||
message => q{Asset %s was copied to the clipboard with all descendants.},
|
||||
lastUpdated => 0,
|
||||
context => q{%s will be replaced by the title of the asset.},
|
||||
},
|
||||
|
||||
'promoted asset' => {
|
||||
message => q{Asset %s was promoted.},
|
||||
lastUpdated => 0,
|
||||
context => q{%s will be replaced by the title of the asset.},
|
||||
},
|
||||
|
||||
'unable to promote asset' => {
|
||||
message => q{Unable to promote asset %s.},
|
||||
lastUpdated => 0,
|
||||
context => q{%s will be replaced by the title of the asset.},
|
||||
},
|
||||
|
||||
'demoted asset' => {
|
||||
message => q{Asset %s was demoted.},
|
||||
lastUpdated => 0,
|
||||
context => q{%s will be replaced by the title of the asset.},
|
||||
},
|
||||
|
||||
'unable to demote asset' => {
|
||||
message => q{Unable to demote asset %s.},
|
||||
lastUpdated => 0,
|
||||
context => q{%s will be replaced by the title of the asset.},
|
||||
},
|
||||
|
||||
'already locked' => {
|
||||
message => q{The asset %s is already locked.},
|
||||
lastUpdated => 0,
|
||||
context => q{%s will be replaced by the title of the asset.},
|
||||
},
|
||||
|
||||
'locked asset' => {
|
||||
message => q{Locked the asset %s.},
|
||||
lastUpdated => 0,
|
||||
context => q{%s will be replaced by the title of the asset.},
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
76
t/AssetHelper/Copy.t
Normal file
76
t/AssetHelper/Copy.t
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Copy;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
|
||||
{
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard'),
|
||||
},
|
||||
'AssetHelper/Copy redirects the back to the copied asset'
|
||||
);
|
||||
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
is @{ $clippies }, 1, '... only copied 1 asset to the clipboard, no children';
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
{
|
||||
$session->setting->set('skipCommitComments', 0);
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard'),
|
||||
open_tab => re('^'.$home->getUrl),
|
||||
},
|
||||
'AssetHelper/Copy opens a tab for commit comments'
|
||||
);
|
||||
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
78
t/AssetHelper/Copy/WithChildren.t
Normal file
78
t/AssetHelper/Copy/WithChildren.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Copy::WithChildren;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
{
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy::WithChildren->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard with its children'),
|
||||
},
|
||||
'AssetHelper/Copy/WithChildren redirects the back to the copied asset'
|
||||
);
|
||||
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
is @{ $clippies }, 10, '... only copied the asset to the clipboard with children';
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
{
|
||||
$session->setting->set('skipCommitComments', 0);
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy::WithChildren->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard with its children'),
|
||||
open_tab => re('^'.$home->getUrl),
|
||||
},
|
||||
'AssetHelper/Copy/WithChildren opens a tab for commit comments'
|
||||
);
|
||||
|
||||
my $clippies = $home->getAssetsInClipboard();
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
78
t/AssetHelper/Copy/WithDescendants.t
Normal file
78
t/AssetHelper/Copy/WithDescendants.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Copy::WithDescendants;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
{
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy::WithDescendants->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard with all descendants'),
|
||||
},
|
||||
'AssetHelper/Copy/WithDescendants redirects the back to the copied asset'
|
||||
);
|
||||
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
is @{ $clippies }, 27, '... only copied the asset to the clipboard with children';
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
{
|
||||
$session->setting->set('skipCommitComments', 0);
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy::WithDescendants->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard with all descendants'),
|
||||
open_tab => re('^'.$home->getUrl),
|
||||
},
|
||||
'AssetHelper/Copy/WithDescendants opens a tab for commit comments'
|
||||
);
|
||||
|
||||
my $clippies = $home->getAssetsInClipboard();
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
79
t/AssetHelper/Cut.t
Normal file
79
t/AssetHelper/Cut.t
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Cut;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 5; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Cut->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('You do not have sufficient privileges'),
|
||||
},
|
||||
'AssetHelper/Cut checks for editing privileges'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Cut->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('vital component'),
|
||||
},
|
||||
'AssetHelper/Cut checks for system pages'
|
||||
);
|
||||
|
||||
my $safe_page = $home->getFirstChild;
|
||||
$output = WebGUI::AssetHelper::Cut->process($safe_page);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was cut to the clipboard'),
|
||||
redirect => $home->getUrl,
|
||||
},
|
||||
'AssetHelper/Cut returns a message and a redirect'
|
||||
);
|
||||
is $safe_page->get('state'), 'clipboard', '... and the asset was really cut';
|
||||
|
||||
$home->paste($safe_page->getId);
|
||||
|
||||
$safe_page = $safe_page->cloneFromDb();
|
||||
is $safe_page->get('state'), 'published', 'reset asset for further testing';
|
||||
|
||||
#vim:ft=perl
|
||||
91
t/AssetHelper/Demote.t
Normal file
91
t/AssetHelper/Demote.t
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Demote;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
|
||||
my $newPage = $home->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Layout',
|
||||
title => 'Test page',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article1 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_1',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article2 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_2',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
$versionTag->commit;
|
||||
addToCleanup($versionTag);
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Demote->process($article1);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('You do not have sufficient privileges'),
|
||||
},
|
||||
'AssetHelper/Demote checks for editing privileges'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Demote->process($article1);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was demoted'),
|
||||
},
|
||||
'AssetHelper/Demote returns a message'
|
||||
);
|
||||
|
||||
my $assets = $newPage->getLineage(['children'], { returnObjects => 1 });
|
||||
cmp_deeply(
|
||||
[ map { $_->getTitle } @{ $assets } ],
|
||||
[ qw{Article_2 Article_1} ],
|
||||
'... and assets were rearranged'
|
||||
);
|
||||
|
||||
#vim:ft=perl
|
||||
92
t/AssetHelper/Lock.t
Normal file
92
t/AssetHelper/Lock.t
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Lock;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
|
||||
my $editor = WebGUI::User->create($session);
|
||||
$editor->addToGroups([4]);
|
||||
addToCleanup($editor);
|
||||
|
||||
$session->user({userId => 3});
|
||||
my $newPage = $home->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Layout',
|
||||
title => 'Test page',
|
||||
groupIdEdit => '4',
|
||||
ownerUserId => '3',
|
||||
}, undef, WebGUI::Test->webguiBirthday, { skipAutoCommitWorkflows => 1, });
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->commit;
|
||||
addToCleanup($versionTag);
|
||||
|
||||
$newPage = $newPage->cloneFromDb;
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('You do not have sufficient privileges'),
|
||||
},
|
||||
'AssetHelper/Lock checks for editing privileges'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => 'Locked the asset Test page.',
|
||||
},
|
||||
'... locks the asset'
|
||||
);
|
||||
|
||||
$newPage = $newPage->cloneFromDb;
|
||||
|
||||
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
|
||||
addToCleanup($versionTag2);
|
||||
|
||||
$session->user({userId => $editor->getId});
|
||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => 'The asset Test page is already locked.',
|
||||
},
|
||||
'... returns an error message if the asset is already locked'
|
||||
);
|
||||
84
t/AssetHelper/Manage.t
Normal file
84
t/AssetHelper/Manage.t
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Manage;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 2; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
|
||||
my $newPage = $home->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Layout',
|
||||
title => 'Test page',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article1 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_1',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article2 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_2',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
$versionTag->commit;
|
||||
addToCleanup($versionTag);
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Manage->process($article2);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('You do not have sufficient privileges'),
|
||||
},
|
||||
'AssetHelper/Promote checks for editing privileges'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Manage->process($article2);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
open_tab => $article2->getManagerUrl,
|
||||
},
|
||||
'AssetHelper/Promote returns a message'
|
||||
);
|
||||
|
||||
#vim:ft=perl
|
||||
91
t/AssetHelper/Promote.t
Normal file
91
t/AssetHelper/Promote.t
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Promote;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
|
||||
my $newPage = $home->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Layout',
|
||||
title => 'Test page',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article1 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_1',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article2 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_2',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
$versionTag->commit;
|
||||
addToCleanup($versionTag);
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Promote->process($article2);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('You do not have sufficient privileges'),
|
||||
},
|
||||
'AssetHelper/Promote checks for editing privileges'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Promote->process($article2);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was promoted'),
|
||||
},
|
||||
'AssetHelper/Promote returns a message'
|
||||
);
|
||||
|
||||
my $assets = $newPage->getLineage(['children'], { returnObjects => 1 });
|
||||
cmp_deeply(
|
||||
[ map { $_->getTitle } @{ $assets } ],
|
||||
[ qw{Article_2 Article_1} ],
|
||||
'... and assets were rearranged'
|
||||
);
|
||||
|
||||
#vim:ft=perl
|
||||
37
t/HTML/addToRow.t
Normal file
37
t/HTML/addToRow.t
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::Session;
|
||||
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
plan tests => 3;
|
||||
|
||||
is WebGUI::HTML::arrayToRow(1),
|
||||
'<tr><td>1</td></tr>',
|
||||
'addToRow: 1 element';
|
||||
|
||||
is WebGUI::HTML::arrayToRow(1,2),
|
||||
'<tr><td>1</td><td>2</td></tr>',
|
||||
'... 2 elements';
|
||||
|
||||
is WebGUI::HTML::arrayToRow(),
|
||||
'<tr><td></td></tr>',
|
||||
'... 0 elements';
|
||||
Loading…
Add table
Add a link
Reference in a new issue