readded packages system
This commit is contained in:
parent
22d3404b30
commit
3671e3f29d
10 changed files with 125 additions and 57 deletions
|
|
@ -947,6 +947,9 @@ sub walkTree {
|
|||
my $contentPositions = join("\.",@positions);
|
||||
WebGUI::SQL->write("update Layout set contentPositions=".quote($contentPositions)." where assetId=".quote($pageId));
|
||||
}
|
||||
if ($page->{parentId} eq "5") {
|
||||
WebGUI::SQL->write("update asset set isPackage=1 where assetId=".quote($pageId));
|
||||
}
|
||||
walkTree($page->{pageId},$pageId,$pageLineage,$rank);
|
||||
$myRank++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ delete from template where templateId='1' and namespace='richEditor/pagetree';
|
|||
INSERT INTO template VALUES ('1','Rich Editor Page Tree','<html>\r\n\r\n<script language=\"javascript\" src=\"<tmpl_var session.config.extrasURL>/tinymce/jscripts/tiny_mce/tiny_mce_popup.js\"></script>\r\n\r\n<script language=\"javascript\">\r\n\r\nfunction setLink(page) {\r\n document.getElementById(\"url\").value=\"^\" + \"/\" + \";\" + page;\r\n}\r\n\r\nfunction createLink() {\r\n if (window.opener) { \r\n if (document.getElementById(\"url\").value == \"\") {\r\n alert(\"You must enter a link url\");\r\n document.getElementById(\"url\").focus();\r\n }\r\n\r\ntinyMCE.insertLink(document.getElementById(\"url\").value,document.getElementById(\"target\").value);\r\n window.close();\r\n }\r\n}\r\n\r\n</script>\r\n\r\n<body>\r\n\r\n<fieldset>\r\n<legend>Insert/Edit Link</legend>\r\n\r\n <fieldset>\r\n <legend>Link Settings</legend>\r\n <form name=\"linkchooser\">\r\n <table border=\"0\">\r\n <tr>\r\n <td>Link URL:</td>\r\n <td><input id=\"url\" name=\"url\" type=\"text value=\"\" style=\"width: 200px\"></td>\r\n </tr>\r\n <tr>\r\n <td>Link Target:</td>\r\n <td><select id=\"target\" name=\"target\" style=\"width: 200px\">\r\n <option value=\"_self\">Open link in same window</option>\r\n <option value=\"_blank\">Open link in new window</option>\r\n </select>\r\n </td>\r\n </tr>\r\n <tr><td colspan=\"2\"> </td></tr>\r\n <tr>\r\n <td colspan=\"2\" align=\"right\"><input type=\"button\" value=\"Cancel\" onClick=\"window.close()\"><input type=\"button\" value=\"Create Link\" onClick=\"createLink()\"></td>\r\n </tr>\r\n </table>\r\n </form>\r\n \r\n\r\n </fieldset> \r\n<br>\r\n\r\n\r\n <fieldset>\r\n <legend>Available Page Tree</legend>\r\n\r\n<tmpl_loop page_loop>\r\n <tmpl_var indent><a href=\"#\" onClick=\"setLink(\'<tmpl_var url>\')\"><tmpl_var title></a><br />\r\n</tmpl_loop>\r\n\r\n </fieldset>\r\n \r\n</fieldset>\r\n</body>\r\n</html>','richEditor/pagetree',1,1);
|
||||
UPDATE template set template = '<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r\n <html>\r\n <head>\r\n <title><tmpl_var session.page.title> - <tmpl_var session.setting.companyName></title>\r\n <tmpl_var head.tags>\r\n <style type=\"text/css\">\r\nTD { font: 8pt \'MS Shell Dlg\', Helvetica, sans-serif; }\r\nTD.delete { font: italic 7pt \'MS Shell Dlg\', Helvetica, sans-serif; }\r\nTD.label { font: 8pt \'MS Shell Dlg\', Helvetica, sans-serif; background-color: #c0c0c0; }\r\nTD.none { font: italic 12pt \'MS Shell Dlg\', Helvetica, sans-serif; }\r\n\r\n</style>\r\n\r\n </head>\r\n <script language=\"javascript\">\r\n</script>\r\n<script language=\"javascript\">\r\n\r\nfunction actionComplete(action, path, error, info) {\r\n\r\n if (window.parent && window.parent.resetForm) {\r\n window.parent.resetForm();\r\n }\r\n\r\n}\r\n</script>\r\n\r\n<script language=\"javascript\">\r\nfunction deleteCollateral(options) {\r\n var lister = window.parent.document.getElementById(\"lister\");\r\n\r\n if(lister && confirm(\"Are you sure you want to delete this item ?\"))\r\n lister.src=\'^/;?op=htmlAreaDelete&\' + options;\r\n}\r\n</script>\r\n</head>\r\n<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\r\n\r\n <tmpl_var body.content>\r\n \r\n</body>\r\n </html>\r\n ' where templateId = '10' and namespace='style';
|
||||
delete from userProfileField where fieldName='richEditor';
|
||||
INSERT INTO userProfileField VALUES ('richEditor','WebGUI::International::get(496)',1,0,'selectList','{5=>WebGUI::International::get(880),\r\nnone=>WebGUI::International::get(881),\r\n\'tinymce\'=>WebGUI::International::get(\"tinymce\")\n}','[\'tinymce\']',11,'4',0,1);
|
||||
update userProfileData set fieldData='tinyMCE' where fieldName='richEditor';
|
||||
INSERT INTO userProfileField VALUES ('richEditor','WebGUI::International::get(496)',1,0,'selectList','{\'PBtmpl0000000000000126\'=>WebGUI::International::get(880),\r\nnone=>WebGUI::International::get(881),\r\n\'PBtmpl0000000000000138\'=>WebGUI::International::get(\"tinymce\")\n}','[\'PBtmpl0000000000000138\']',11,'4',0,1);
|
||||
update userProfileData set fieldData='PBtmpl0000000000000138' where fieldName='richEditor';
|
||||
UPDATE template set template = '<html>\r\n\r\n<script language=\"javascript\" src=\"<tmpl_var session.config.extrasURL>/tinymce/jscripts/tiny_mce/tiny_mce_popup.js\"></script>\r\n\r\n<script language=\"javascript\">\r\n\r\nfunction setLink(page) {\r\n document.getElementById(\"url\").value=\"^/;\" + page;\r\n}\r\n\r\nfunction createLink() {\r\n if (window.opener) { \r\n if (document.getElementById(\"url\").value == \"\") {\r\n alert(\"You must enter a link url\");\r\n document.getElementById(\"url\").focus();\r\n }\r\n\r\ntinyMCE.insertLink(document.getElementById(\"url\").value,document.getElementById(\"target\").value);\r\n window.close();\r\n }\r\n}\r\n\r\n</script>\r\n\r\n<body>\r\n\r\n<fieldset>\r\n<legend>Insert/Edit Link</legend>\r\n\r\n <fieldset>\r\n <legend>Link Settings</legend>\r\n <form name=\"linkchooser\">\r\n <table border=\"0\">\r\n <tr>\r\n <td>Link URL:</td>\r\n <td><input id=\"url\" name=\"url\" type=\"text value=\"\" style=\"width: 200px\"></td>\r\n </tr>\r\n <tr>\r\n <td>Link Target:</td>\r\n <td><select id=\"target\" name=\"target\" style=\"width: 200px\">\r\n <option value=\"_self\">Open link in same window</option>\r\n <option value=\"_blank\">Open link in new window</option>\r\n </select>\r\n </td>\r\n </tr>\r\n <tr><td colspan=\"2\"> </td></tr>\r\n <tr>\r\n <td colspan=\"2\" align=\"right\"><input type=\"button\" value=\"Cancel\" onClick=\"window.close()\"><input type=\"button\" value=\"Create Link\" onClick=\"createLink()\"></td>\r\n </tr>\r\n </table>\r\n </form>\r\n \r\n\r\n </fieldset> \r\n<br>\r\n\r\n\r\n <fieldset>\r\n <legend>Available Page Tree</legend>\r\n<div id=\"pagetree\" style=\"overflow: auto; height: 280; width: 441\">\r\n<tmpl_loop page_loop>\r\n <tmpl_var indent><a href=\"#\" onClick=\"setLink(\'<tmpl_var url>\')\"><tmpl_var title></a><br />\r\n</tmpl_loop>\r\n</div>\r\n </fieldset>\r\n \r\n</fieldset>\r\n</body>\r\n</html>' where namespace='richEditor/pagetree' && templateId = '1';
|
||||
|
||||
INSERT INTO template VALUES ('adminConsole','Admin Console','<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\r\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n <title>WebGUI <tmpl_var session.webgui.version>-<tmpl_var session.webgui.status> Admin Console</title>\r\n <tmpl_var head.tags> \r\n</head>\r\n<body>\r\n<tmpl_var body.content>\r\n</body>\r\n</html>\r\n','style',1,0);
|
||||
|
|
@ -65,6 +65,7 @@ create table asset (
|
|||
assetSize int not null default 0,
|
||||
lastUpdated bigint not null default 0,
|
||||
lastUpdatedBy varchar(22),
|
||||
isPackage int not null default 0,
|
||||
unique index (lineage asc),
|
||||
unique index (url),
|
||||
index (parentId)
|
||||
|
|
|
|||
|
|
@ -200,15 +200,6 @@ sub getAdminFunction {
|
|||
op=>"listGroups",
|
||||
group=>"11"
|
||||
},
|
||||
"packages"=>{
|
||||
title=>{
|
||||
id=>"packages",
|
||||
namespace=>"WebGUI"
|
||||
},
|
||||
icon=>"packages.gif",
|
||||
op=>"managePackages",
|
||||
group=>"4"
|
||||
},
|
||||
"settings"=>{
|
||||
title=>{
|
||||
id=>"settings",
|
||||
|
|
|
|||
|
|
@ -319,6 +319,10 @@ sub definition {
|
|||
assetSize=>{
|
||||
fieldType=>'hidden',
|
||||
defaultValue=>0
|
||||
},
|
||||
isPackage=>{
|
||||
fieldType=>'yesNo',
|
||||
defaultValue=>0
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -344,6 +348,9 @@ sub demote {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 DESTROY ( )
|
||||
|
|
@ -359,17 +366,46 @@ sub DESTROY {
|
|||
$self->{_lastChild}->DESTROY if (exists $self->{_lastChild});
|
||||
$self = undef;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicate ( )
|
||||
=head2 duplicate ( asset )
|
||||
|
||||
Duplicates an argument. Calls addChild with itself as an argument. Returns a new Asset object.
|
||||
Duplicates an asset. Calls addChild with self as an arguement. Returns a new Asset object.
|
||||
|
||||
=head3 asset
|
||||
|
||||
The asset to duplicate. Defaults to self.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->addChild($self->get);
|
||||
my $assetToDuplicate = shift || $self;
|
||||
my $newAsset = $self->addChild($assetToDuplicate->get);
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicateTree ( asset )
|
||||
|
||||
Duplicates an asset and all it's descendants. Calls addChild with asset as an argument. Returns a new Asset object.
|
||||
|
||||
=head3 asset
|
||||
|
||||
The asset to duplicate. Defaults to self.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicateTree {
|
||||
my $self = shift;
|
||||
my $assetToDuplicate = shift || $self;
|
||||
my $newAsset = $self->duplicate($assetToDuplicate);
|
||||
foreach my $child (@{$assetToDuplicate->getLineage(["children"],{returnObjects=>1})}) {
|
||||
$newAsset->duplicateTree($child);
|
||||
}
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
|
|
@ -770,6 +806,12 @@ sub getEditForm {
|
|||
-excludeGroups=>[1,7],
|
||||
-uiLevel=>6
|
||||
);
|
||||
$tabform->getTab("properties")->yesNo(
|
||||
-name=>"isPackage",
|
||||
-label=>"Make available as package?",
|
||||
-value=>$self->getValue("isPackage"),
|
||||
-uiLevel=>7
|
||||
);
|
||||
return $tabform;
|
||||
}
|
||||
|
||||
|
|
@ -1014,6 +1056,30 @@ sub getNextChildRank {
|
|||
return $self->formatRank($rank);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head getPackageList ( )
|
||||
|
||||
Returns an array of hashes containing title, assetId, and className for all assets defined as packages.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPackageList {
|
||||
my $self = shift;
|
||||
my @assets;
|
||||
my $sth = WebGUI::SQL->read("select assetId, title, className from asset where isPackage=1 order by lastUpdated desc");
|
||||
while (my ($id, $title, $class) = $sth->array) {
|
||||
push(@assets, {
|
||||
title => $title,
|
||||
assetId => $id,
|
||||
className => $class
|
||||
});
|
||||
}
|
||||
$sth->finish;
|
||||
return \@assets;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getParent ( )
|
||||
|
|
@ -1837,6 +1903,28 @@ sub www_demote {
|
|||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deployPackage ( )
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deployPackage {
|
||||
my $self = shift;
|
||||
return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit;
|
||||
my $packageMasterAssetId = $session{form}{assetId};
|
||||
if (defined $packageMasterAssetId) {
|
||||
my $packageMasterAsset = WebGUI::Asset->newByDynamicClass($packageMasterAssetId);
|
||||
if (defined $packageMasterAsset && $packageMasterAsset->canView) {
|
||||
my $deployedTreeMaster = $self->duplicateTree($packageMasterAsset);
|
||||
$deployedTreeMaster->update({isPackage=>0});
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit ( )
|
||||
|
|
|
|||
|
|
@ -97,6 +97,16 @@ sub getBox {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub duplicate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->SUPER::duplicate(shift);
|
||||
my $newStorage = $self->getStorageLocation->copy;
|
||||
$newAsset->update({storageId=>$newStorage->getId,olderVersions=>''});
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditForm ()
|
||||
|
|
|
|||
|
|
@ -166,21 +166,15 @@ sub confirm {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicate ( [ pageId ] )
|
||||
=head2 duplicate ( asset )
|
||||
|
||||
Duplicates this wobject with a new wobject Id. Returns the new wobject Id.
|
||||
|
||||
B<NOTE:> This method is meant to be extended by all sub-classes.
|
||||
|
||||
=head3 pageId
|
||||
|
||||
If specified the wobject will be duplicated to this pageId, otherwise it will be duplicated to the clipboard.
|
||||
Extends the Asset duplicate method to also duplicate meta data.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->SUPER::duplicate();
|
||||
my $newAsset = $self->SUPER::duplicate(shift);
|
||||
WebGUI::MetaData::MetaDataDuplicate($self->getId, $newAsset->getId);
|
||||
return $newAsset;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ sub definition {
|
|||
#-------------------------------------------------------------------
|
||||
sub duplicate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->SUPER::duplicate;
|
||||
my $newAsset = $self->SUPER::duplicate(shift);
|
||||
my (%dataField, %dataTab, $sthField, $sthTab, $newTabId);
|
||||
tie %dataTab, 'Tie::CPHash';
|
||||
tie %dataField, 'Tie::CPHash';
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ sub definition {
|
|||
#-------------------------------------------------------------------
|
||||
sub duplcate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->SUPER::duplicate;
|
||||
my $newAsset = $self->SUPER::duplicate(shift);
|
||||
my $sth = WebGUI::SQL->read("select * from Poll_answer where assetId=".quote($self->getId));
|
||||
while (my $data = $sth->hashRef) {
|
||||
$newAsset->setVote($data->{answer}, $data->{userId}, $data->{ipAddress});
|
||||
|
|
|
|||
|
|
@ -1051,20 +1051,11 @@ This will be used if no value is specified.
|
|||
sub HTMLArea {
|
||||
my $params = shift;
|
||||
my ($output, $rows, $columns, $htmlArea);
|
||||
my $browser = HTTP::BrowserDetect->new($session{env}{HTTP_USER_AGENT});
|
||||
my %var;
|
||||
|
||||
# Store all scalar options in template variables
|
||||
foreach (keys %{$params}) {
|
||||
$var{"form.".$_} = $params->{$_} unless (ref $params->{$_});
|
||||
}
|
||||
|
||||
# Supported Rich Editors
|
||||
$var{"htmlArea.supported"} = ($browser->ie && $browser->version >= 5.5);
|
||||
$var{"midas.supported"} = (($browser->ie && $browser->version >= 6) || ($browser->gecko && $browser->version >= 1.3));
|
||||
$var{"htmlArea3.supported"} = (($browser->ie && $browser->version >= 5.5) || $var{"midas.supported"});
|
||||
$var{"classic.supported"} = ($browser->ie && $browser->version >= 5);
|
||||
|
||||
# Textarea field
|
||||
$rows = $params->{rows} || ($session{setting}{textAreaRows}+15);
|
||||
$columns = $params->{columns} || ($session{setting}{textAreaCols}+5);
|
||||
|
|
@ -1077,7 +1068,6 @@ sub HTMLArea {
|
|||
extras=>$params->{extras}.' onBlur="fixChars(this.form.'.$params->{name}.')" id="'.$params->{name}.'"'.' mce_editable="true" ',
|
||||
defaultValue=>$params->{defaultValue}
|
||||
});
|
||||
|
||||
# Other variables
|
||||
$var{"button"} = '<input type="button" onClick="openEditWindow(this.form.'.$params->{name}.')" value="'
|
||||
.WebGUI::International::get(171).'" style="font-size: 8pt;" /><br />';
|
||||
|
|
|
|||
|
|
@ -34,38 +34,29 @@ sub process {
|
|||
tie %hash, "Tie::IxHash";
|
||||
tie %hash2, "Tie::IxHash";
|
||||
tie %cphash, "Tie::CPHash";
|
||||
#--packages adder
|
||||
$var{'packages.canAdd'} = ($session{user}{uiLevel} >= 7);
|
||||
$var{'packages.label'} = WebGUI::International::get(376);
|
||||
my @packages;
|
||||
my $i;
|
||||
# my $sth = WebGUI::SQL->read("select pageId,title from page where parentId='5'");
|
||||
# while (my %data = $sth->hash) {
|
||||
# $data{title} =~ s/'//g;
|
||||
# push(@packages, {
|
||||
# 'package.url'=>WebGUI::URL::page('op=deployPackage&pid='.$data{pageId}),
|
||||
# 'package.label'=>$data{title},
|
||||
# 'package.count'=>$i
|
||||
# });
|
||||
# $i++;
|
||||
# }
|
||||
# $sth->finish;
|
||||
# $var{package_loop} = \@packages;
|
||||
#--contenttypes adder
|
||||
$var{'contentTypes.label'} = WebGUI::International::get(1083);
|
||||
$var{'addcontent.label'} = WebGUI::International::get(1);
|
||||
foreach my $link (@{$session{asset}->getAssetAdderLinks}) {
|
||||
push(@{$var{'contenttypes_loop'}},{'contenttype.url'=>$link->{url},'contenttype.label'=>$link->{label}});
|
||||
}
|
||||
#--clipboard paster
|
||||
$var{'clipboard.label'} = WebGUI::International::get(1082);
|
||||
if (exists $session{asset}) {
|
||||
foreach my $package (@{$session{asset}->getPackageList}) {
|
||||
my $title = $package->{title};
|
||||
$title =~ s/'//g; # stops it from breaking the javascript menus
|
||||
push(@{$var{'package_loop'}},{
|
||||
'package.url'=>$session{asset}->getUrl("func=deployPackage&assetId=".$package->{assetId}),
|
||||
'package.label'=>$title
|
||||
});
|
||||
}
|
||||
foreach my $link (@{$session{asset}->getAssetAdderLinks}) {
|
||||
push(@{$var{'contenttypes_loop'}},{'contenttype.url'=>$link->{url},'contenttype.label'=>$link->{label}});
|
||||
}
|
||||
foreach my $item (@{$session{asset}->getAssetsInClipboard(1)}) {
|
||||
my $title = $item->{title};
|
||||
$title =~ s/'//g; # stops it from breaking the javascript menus
|
||||
push(@{$var{clipboard_loop}}, {
|
||||
'clipboard.label'=>$title,
|
||||
'clipboard.url'=>WebGUI::URL::page("func=paste&assetId=".$item->{assetId})
|
||||
'clipboard.url'=>$session{asset}->getUrl("func=paste&assetId=".$item->{assetId})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +80,7 @@ sub process {
|
|||
);
|
||||
$var{'admin.label'} = WebGUI::International::get(82);
|
||||
my @admin;
|
||||
$i = 0;
|
||||
my $i = 0;
|
||||
foreach my $key (keys %hash) {
|
||||
push(@admin,{
|
||||
'admin.url'=>$key,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue