diff --git a/lib/WebGUI/Operation/Collateral.pm b/lib/WebGUI/Operation/Collateral.pm
index 7bd02b98d..86f2a13f9 100644
--- a/lib/WebGUI/Operation/Collateral.pm
+++ b/lib/WebGUI/Operation/Collateral.pm
@@ -38,7 +38,8 @@ our @ISA = qw(Exporter);
our @EXPORT = qw(&www_editCollateral &www_editCollateralSave &www_deleteCollateral
&www_deleteCollateralConfirm &www_listCollateral
&www_deleteCollateralFile &www_editCollateralFolder &www_editCollateralFolderSave &www_deleteCollateralFolder
- &www_deleteCollateralFolderConfirm);
+ &www_deleteCollateralFolderConfirm &www_htmlArealistCollateral &www_htmlAreaviewCollateral &www_htmlAreaUpload
+ &www_htmlAreaDelete &www_htmlAreaCreateFolder);
#-------------------------------------------------------------------
sub _submenu {
@@ -465,5 +466,182 @@ sub www_listCollateral {
return _submenu($output);
}
-1;
+#-------------------------------------------------------------------
+sub _htmlAreaCreateTree {
+ my ($output);
+ my ($name, $description, $url, $image, $indent, $target, $delete) = @_;
+ if($delete) {
+ $delete = qq//;
+ $delete .= '
';
+ }
+ $target = ' target="'.$target.'" ' if ($target);
+ $output .= '
';
+ $output .= (' ') x$indent;
+ $output .= ' ';
+ $output .= ''.$name.' | ';
+ $output .= ''.$delete.' |
';
+ return $output;
+}
+#-------------------------------------------------------------------
+sub www_htmlArealistCollateral {
+ my (@parents, $output, $sth, $data, $folderId, $parent, $indent);
+ $session{form}{makePrintable}=1; $session{form}{style}=-10; # Special style for this output
+ return "Only Content Managers are allowed to use WebGUI Collateral" unless (WebGUI::Privilege::isInGroup(4));
+
+ $output .= '';
+ $folderId = $session{form}{fid} || 0;
+ my $parent = $folderId;
+ # push parent folders in array so it can be reversed
+ unshift(@parents, $parent);
+ until($parent == 0) {
+ ($parent) = WebGUI::SQL->quickArray("select parentId from collateralFolder where collateralFolderId=$parent");
+ unshift(@parents, $parent);
+ }
+ # Build tree for opened parent folders
+ foreach $parent (@parents) {
+ my ($name, $description) = WebGUI::SQL->quickArray("select name, description from
+ collateralFolder where collateralFolderId=$parent");
+ my ($itemsInFolder) = WebGUI::SQL->quickArray("select count(*) from collateral where collateralFolderId = $parent");
+ my ($foldersInFolder)=WebGUI::SQL->quickArray("select count(*) from collateralFolder where parentId=$parent");
+ my $delete = "fid=$parent" unless ($itemsInFolder + $foldersInFolder);
+ $output .= _htmlAreaCreateTree($name, $description,
+ WebGUI::URL::page('op=htmlArealistCollateral&fid='.$parent), "opened.gif",
+ $indent++,"" ,$delete);
+ }
+ # Extend tree with closed folders in current folder
+ $sth = WebGUI::SQL->read("select collateralFolderId, name, description from collateralFolder
+ where parentId=$folderId and collateralFolderId<>0 order by name");
+ while ($data = $sth->hashRef) {
+ my ($itemsInFolder) = WebGUI::SQL->quickArray("select count(*) from collateral where
+ collateralFolderId = ".$data->{collateralFolderId});
+ my $delete = 'fid='.$data->{collateralFolderId} unless $itemsInFolder;
+ $output .= _htmlAreaCreateTree($data->{name}, $data->{description},
+ WebGUI::URL::page('op=htmlArealistCollateral&fid='.$data->{collateralFolderId}),
+ "closed.gif", $indent, "", $delete);
+ }
+ # Extend tree with images in current folder
+ $sth = WebGUI::SQL->read('select collateralId, name, filename from collateral where collateralType = "image" '.
+ "and collateralFolderId = $folderId");
+ while ($data = $sth->hashRef) {
+ $data->{filename} =~ /\.([^\.]+)$/; # Get extension
+ my $fileType = $1.'.gif';
+ $output .= _htmlAreaCreateTree($data->{filename}, $data->{name},
+ WebGUI::URL::page('op=htmlAreaviewCollateral&cid='.$data->{collateralId}),
+ $fileType, $indent, "viewer", 'cid='.$data->{collateralId}.'&fid='.$folderId);
+ }
+ $output .= '
';
+ $output .= '\n";
+ $sth->finish;
+ return $output;
+}
+
+#-------------------------------------------------------------------
+sub www_htmlAreaviewCollateral {
+ my($output, $collateral, $file, $x, $y, $image, $error);
+ $session{form}{makePrintable}=1; $session{form}{style}=-10; # Special style for this output
+ $output .= '';
+ if($session{form}{cid} == 0 || ! WebGUI::Privilege::isInGroup(4)) {
+ $output .= '| ';
+ $output .= '
 ';
+ $output .= 'WebGUI Image Manager for htmlArea ';
+ $output .= ' |
';
+ } else {
+ my $c = WebGUI::Collateral->new($session{form}{cid});
+ $collateral = $c->get;
+ $file = WebGUI::Attachment->new($collateral->{filename},"images",$collateral->{collateralId});
+ $output .= '';
+ $output .= ''.$file->getFilename.' ';
+ if ($hasImageMagick) {
+ $image = Image::Magick->new;
+ $error = $image->Read($file->getPath);
+ ($x, $y) = $image->Get('width','height');
+ $output .= $error ? "Error reading image: $error" : "($x × $y)";
+ }
+ $output .= ' |
';
+ $output .= ' ';
+ $output .= ' |
';
+ $output .= '\n";
+ }
+ return $output;
+}
+
+#-------------------------------------------------------------------
+sub www_htmlAreaUpload {
+ $session{form}{makePrintable}=1; $session{form}{style}=-10; # Special style for this output
+ return "Only Content Managers are allowed to use WebGUI Collateral" unless (WebGUI::Privilege::isInGroup(4));
+ return www_htmlArealistCollateral() if ($session{form}{image} eq "");
+ my($test, $file);
+ $session{form}{fid} = $session{form}{collateralFolderId} = $session{form}{path};
+ my $collateral = WebGUI::Collateral->new("new");
+ $session{form}{thumbnailSize} ||= $session{setting}{thumbnailSize};
+ $session{form}{cid} = $collateral->get("collateralId");
+ $collateral->save("image", $session{form}{thumbnailSize});
+ $session{form}{name} = "untitled" if ($session{form}{name} eq "");
+ while (($test) = WebGUI::SQL->quickArray("select name from collateral
+ where name=".quote($session{form}{name})." and collateralId<>".$collateral->get("collateralId"))) {
+ if ($session{form}{name} =~ /(.*)(\d+$)/) {
+ $session{form}{name} = $1.($2+1);
+ } elsif ($test ne "") {
+ $session{form}{name} .= "2";
+ }
+ }
+ $collateral->set($session{form});
+ $session{form}{collateralType} = "";
+ return www_htmlArealistCollateral();
+}
+
+#-------------------------------------------------------------------
+sub www_htmlAreaDelete {
+ $session{form}{makePrintable}=1; $session{form}{style}=-10; # Special style for this output
+ return "Only Content Managers are allowed to use WebGUI Collateral" unless (WebGUI::Privilege::isInGroup(4));
+ if($session{form}{cid}) { # Delete Image
+ my $collateral = WebGUI::Collateral->new($session{form}{cid});
+ $collateral->delete;
+ } elsif($session{form}{fid} and not($session{form}{cid})) {
+ return WebGUI::Privilege::vitalComponent() unless ($session{form}{fid} > 999);
+ my ($parent) = WebGUI::SQL->quickArray("select parentId from collateralFolder
+ where collateralFolderId=".$session{form}{fid});
+ WebGUI::SQL->write("delete from collateralFolder where collateralFolderId=".$session{form}{fid});
+ $session{form}{fid}=$parent;
+ }
+ return www_htmlArealistCollateral();
+}
+
+#-------------------------------------------------------------------
+sub www_htmlAreaCreateFolder {
+ $session{form}{makePrintable}=1; $session{form}{style}=-10; # Special style for this output
+ return "Only Content Managers are allowed to use WebGUI Collateral" unless (WebGUI::Privilege::isInGroup(4));
+ $session{form}{fid} = getNextId("collateralFolderId");
+ WebGUI::Session::setScratch("collateralFolderId",$session{form}{fid});
+ WebGUI::SQL->write("insert into collateralFolder (collateralFolderId) values ($session{form}{fid})");
+ my $folderId = $session{scratch}{collateralFolderId} || 0;
+ $session{form}{name} = $session{form}{folder};
+ $session{form}{name} = "untitled" if ($session{form}{name} eq "");
+ while (my ($test) = WebGUI::SQL->quickArray("select name from collateralFolder
+ where name=".quote($session{form}{name})." and collateralFolderId<>$folderId")) {
+ if ($session{form}{name} =~ /(.*)(\d+$)/) {
+ $session{form}{name} = $1.($2+1);
+ } elsif ($test ne "") {
+ $session{form}{name} .= "2";
+ }
+ }
+ WebGUI::SQL->write("update collateralFolder set parentId=$session{form}{path}, name=".quote($session{form}{name})
+ .", description=".quote($session{form}{description})
+ ." where collateralFolderId=$folderId");
+ $session{form}{fid} = $session{form}{path};
+ return www_htmlArealistCollateral();
+}
+
+
+1;
diff --git a/www/extras/htmlArea/popups/insert_image.html b/www/extras/htmlArea/popups/insert_image.html
index 3edcd3eb7..f3be82456 100644
--- a/www/extras/htmlArea/popups/insert_image.html
+++ b/www/extras/htmlArea/popups/insert_image.html
@@ -1,206 +1,439 @@
-
+
+
+
+
+
-
-
-
-
-
-Insert Image
-
-
-
-
-Image URL:
-
+function OKClick() {
+ var elmImage;
+ var intAlignment;
+ var htmlSelectionControl = "Control";
+ var globalDoc = window.dialogArguments;
+ var grngMaster = globalDoc.selection.createRange();
-Alternate Text:
-
+ // error checking
+ if(!txtFileName.value || txtFileName.value == "http://") {
+ alert("Image URL must be specified.");
+ txtFileName.focus();
+ return;
+ }
+ if(txtHorizontal.value && !_isValidNumber(txtHorizontal.value)) {
+ alert("Horizontal spacing must be a number between 0 and 999.");
+ txtHorizontal.focus();
+ return;
+ }
+ if(txtBorder.value && !_isValidNumber(txtBorder.value)) {
+ alert("Border thickness must be a number between 0 and 999.");
+ txtBorder.focus();
+ return;
+ }
+ if(txtVertical.value && !_isValidNumber(txtVertical.value)) {
+ alert("Vertical spacing must be a number between 0 and 999.");
+ txtVertical.focus();
+ return;
+ }
-
+ // delete selected content and replace with image
+ if(globalDoc.selection.type == htmlSelectionControl && !txtFileName.fImageLoaded) {
+ grngMaster.execCommand('Delete');
+ grngMaster = globalDoc.selection.createRange();
+ }
-
+ idstr = "\" id=\"556e697175657e537472696e67"; // new image creation ID
+ if(!txtFileName.fImageLoaded) {
+ grngMaster.execCommand("InsertImage", false, idstr);
+ elmImage = globalDoc.all['556e697175657e537472696e67'];
+ elmImage.removeAttribute("id");
+ elmImage.removeAttribute("src");
+ grngMaster.moveStart("character", -1);
+ }
+ else {
+ elmImage = grngMaster.item(0);
+ if(elmImage.src != txtFileName.value) {
+ grngMaster.execCommand('Delete');
+ grngMaster = globalDoc.selection.createRange();
+ grngMaster.execCommand("InsertImage", false, idstr);
+ elmImage = globalDoc.all['556e697175657e537472696e67'];
+ elmImage.removeAttribute("id");
+ elmImage.removeAttribute("src");
+ grngMaster.moveStart("character", -1);
+ txtFileName.fImageLoaded = false;
+ }
+ grngMaster = _getTextRange(elmImage);
+ }
-Alignment:
-
+ if(txtFileName.fImageLoaded) {
+ elmImage.style.width = txtFileName.intImageWidth;
+ elmImage.style.height = txtFileName.intImageHeight;
+ }
-Horizontal:
-
+ if(txtFileName.value.length > 2040) {
+ txtFileName.value = txtFileName.value.substring(0,2040);
+ }
-Border Thickness:
-
+ elmImage.src = txtFileName.value;
-Vertical:
-
+ if(txtHorizontal.value != "") {
+ elmImage.hspace = parseInt(txtHorizontal.value);
+ }
+ else {
+ elmImage.hspace = 0;
+ }
-
-
+ if(txtVertical.value != "") {
+ elmImage.vspace = parseInt(txtVertical.value);
+ }
+ else {
+ elmImage.vspace = 0;
+ }
-
-
\ No newline at end of file
+ elmImage.alt = txtAltText.value;
+
+ if(txtBorder.value != "") {
+ elmImage.border = parseInt(txtBorder.value);
+ }
+ else {
+ elmImage.border = 0;
+ }
+
+ elmImage.align = selAlignment.value;
+ grngMaster.collapse(false);
+ grngMaster.select();
+ window.close();
+}
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+ |
+
+ |
+
+
+ |
+
+ |
+
+
+
+
+