diff --git a/lib/WebGUI/AssetHelper/ChangeUrl.pm b/lib/WebGUI/AssetHelper/ChangeUrl.pm
new file mode 100644
index 000000000..784edebf9
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/ChangeUrl.pm
@@ -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 => '
'.$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;
diff --git a/lib/WebGUI/AssetHelper/Copy.pm b/lib/WebGUI/AssetHelper/Copy.pm
new file mode 100644
index 000000000..a57182506
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/Copy.pm
@@ -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;
diff --git a/lib/WebGUI/AssetHelper/Copy/WithChildren.pm b/lib/WebGUI/AssetHelper/Copy/WithChildren.pm
new file mode 100644
index 000000000..880a1e71b
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/Copy/WithChildren.pm
@@ -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;
diff --git a/lib/WebGUI/AssetHelper/Copy/WithDescendants.pm b/lib/WebGUI/AssetHelper/Copy/WithDescendants.pm
new file mode 100644
index 000000000..b0e3600b5
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/Copy/WithDescendants.pm
@@ -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;
diff --git a/lib/WebGUI/AssetHelper/Cut.pm b/lib/WebGUI/AssetHelper/Cut.pm
new file mode 100644
index 000000000..dad38b074
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/Cut.pm
@@ -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;
diff --git a/lib/WebGUI/AssetHelper/Demote.pm b/lib/WebGUI/AssetHelper/Demote.pm
new file mode 100644
index 000000000..5a75f86be
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/Demote.pm
@@ -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;
diff --git a/lib/WebGUI/AssetHelper/EditBranch.pm b/lib/WebGUI/AssetHelper/EditBranch.pm
new file mode 100644
index 000000000..f452969b7
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/EditBranch.pm
@@ -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 = '
'.$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"),
+ },
+ })
+ . ' / '
+ . WebGUI::Form::selectBox($session, {
+ name => "endOfUrl",
+ options => {
+ menuTitle => $i18n->get(411),
+ title => $i18n->get(99),
+ currentUrl => $i18n->get("current url"),
+ }
+ })
+ . q!!
+ );
+ $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;
diff --git a/lib/WebGUI/AssetHelper/ExportHtml.pm b/lib/WebGUI/AssetHelper/ExportHtml.pm
new file mode 100644
index 000000000..bf4948242
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/ExportHtml.pm
@@ -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 = '';
+ return $output;
+}
+
+1;
diff --git a/lib/WebGUI/AssetHelper/Lock.pm b/lib/WebGUI/AssetHelper/Lock.pm
new file mode 100644
index 000000000..131846d7b
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/Lock.pm
@@ -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;
diff --git a/lib/WebGUI/AssetHelper/Manage.pm b/lib/WebGUI/AssetHelper/Manage.pm
new file mode 100644
index 000000000..cdd1aac32
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/Manage.pm
@@ -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;
diff --git a/lib/WebGUI/AssetHelper/Promote.pm b/lib/WebGUI/AssetHelper/Promote.pm
new file mode 100644
index 000000000..943628dc3
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/Promote.pm
@@ -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;
diff --git a/lib/WebGUI/AssetHelper/Revisions.pm b/lib/WebGUI/AssetHelper/Revisions.pm
new file mode 100644
index 000000000..6e09fa715
--- /dev/null
+++ b/lib/WebGUI/AssetHelper/Revisions.pm
@@ -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{
| %s | %s | %s |
|---|