|
+ |
+
| + + | +
';
+}
+
+#-------------------------------------------------------------------
+
=head2 editIcon ( urlParameters [, pageURL ] )
Generates a button with the word "Edit" printed on it.
@@ -471,7 +484,7 @@ Generates an icon that looks like a wobject. It's purpose is to represent whethe
=cut
sub wobjectIcon {
- return '
';
+ return '
';
}
diff --git a/lib/WebGUI/Operation/Page.pm b/lib/WebGUI/Operation/Page.pm
index 4764ed540..4205e0379 100644
--- a/lib/WebGUI/Operation/Page.pm
+++ b/lib/WebGUI/Operation/Page.pm
@@ -29,7 +29,7 @@ use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_viewPageTree &www_movePageUp &www_movePageDown
&www_cutPage &www_deletePage &www_deletePageConfirm &www_editPage
- &www_editPageSave &www_pastePage &www_moveTreePageUp
+ &www_editPageSave &www_pastePage &www_moveTreePageUp &www_rearrangeWobjects
&www_moveTreePageDown &www_moveTreePageLeft &www_moveTreePageRight);
#-------------------------------------------------------------------
@@ -608,6 +608,30 @@ sub www_pastePage {
}
}
+#-------------------------------------------------------------------
+sub www_rearrangeWobjects {
+ return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage($session{page}{pageId}));
+ $session{page}{styleId} = 2;
+ my @contentAreas = split(/\./,$session{form}{map});
+ my $templatePosition = 1;
+ foreach my $position (@contentAreas) {
+ my @sequence = split(",",$position);
+ my $sequenceNumber = 1;
+ foreach my $wobjectId (@sequence) {
+ $wobjectId =~ s/td(\d+)/$1/;
+ WebGUI::SQL->setRow("wobject","wobjectId",{
+ wobjectId=>$wobjectId,
+ sequenceNumber=>$sequenceNumber,
+ templatePosition=>$templatePosition
+ });
+ $sequenceNumber++;
+ }
+ $templatePosition++;
+ }
+ return $session{form}{map};
+}
+
+
#-------------------------------------------------------------------
sub www_viewPageTree {
my ($output);
diff --git a/lib/WebGUI/Page.pm b/lib/WebGUI/Page.pm
index eba018125..ceb42fe30 100644
--- a/lib/WebGUI/Page.pm
+++ b/lib/WebGUI/Page.pm
@@ -278,7 +278,6 @@ sub generate {
.moveUpIcon('op=movePageUp')
.moveDownIcon('op=movePageDown')
.cutIcon('op=cutPage');
- my @wobjectsinpage;
my $sth = WebGUI::SQL->read("select * from wobject where pageId=".$session{page}{pageId}." order by sequenceNumber, wobjectId");
while (my $wobject = $sth->hashRef) {
my $wobjectToolbar = wobjectIcon()
@@ -325,16 +324,15 @@ sub generate {
'wobject.canView'=>WebGUI::Privilege::canViewWobject($wobject->{wobjectId}),
'wobject.canEdit'=>WebGUI::Privilege::canEditWobject($wobject->{wobjectId}),
'wobject.controls'=>$wobjectToolbar,
+ 'wobject.controls.drag'=>dragIcon(),
'wobject.namespace'=>$wobject->{namespace},
'wobject.id'=>$wobject->{wobjectId},
'wobject.isInDateRange'=>$w->inDateRange,
'wobject.content'=>eval{$w->www_view}
});
WebGUI::ErrorHandler::fatalError("Wobject runtime error: ${$wobject}{namespace}. Root cause: ".$@) if($@);
- push(@wobjectsinpage,{'wobject.id'=>${$wobject}{wobjectId}});
}
$sth->finish;
- $var{"wobjectid_list"} = \@wobjectsinpage;
return WebGUI::Template::process(getTemplate(),\%var);
}
diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm
index 18a95a276..5216ec1d9 100644
--- a/lib/WebGUI/SQL.pm
+++ b/lib/WebGUI/SQL.pm
@@ -645,7 +645,9 @@ sub setRow {
push(@pairs, $key.'='.quote($data->{$key}));
}
}
- WebGUI::SQL->write("update $table set ".join(", ", @pairs)." where ".$keyColumn."=".quote($data->{$keyColumn}), $dbh);
+ if ($pairs[0] ne "") {
+ WebGUI::SQL->write("update $table set ".join(", ", @pairs)." where ".$keyColumn."=".quote($data->{$keyColumn}), $dbh);
+ }
return $data->{$keyColumn};
}
diff --git a/www/extras/draggable.js b/www/extras/draggable.js
new file mode 100644
index 000000000..c0bed0773
--- /dev/null
+++ b/www/extras/draggable.js
@@ -0,0 +1,391 @@
+//Confugration
+//sets the drag accruacy
+//a value of 0 is most accurate. The number can be raised to improve performance.
+var accuracy = 2;
+
+//list of the content item names. Could be searched for, but hard coded for performance
+var wobjectList=new Array();
+var dragableList=new Array();
+//Internal Config (Do not Edit)
+
+//browser check
+var dom=document.getElementById&&!document.all
+var pageURL = "";
+var dragging=false;
+var z,x,y
+var accuracyCount =0;
+var startTD = null;
+var endTD = null;
+var topelement=dom? "HTML" : "BODY"
+var currentDiv = null;
+var clipboard = null;
+var contra = "";
+
+//checks the key Events for copy and paste operations
+//ctrlC ctrlV shiftP shiftY
+function dragable_checkKeyEvent(e) {
+ e=dom? e : event;
+
+ if (e.keyCode == 38 || e.keyCode == 40 || e.keyCode==37 || e.keyCode==39 || e.keyCode == 66 || e.keyCode == 65){
+ contra+=e.keyCode;
+ if (contra.indexOf("38403840373937396665") != -1) {
+ alert("WebGUI was created by Plain Black LLC");
+ contra="";
+ }
+ }else {
+ contra = "";
+ }
+
+ if (currentDiv == null) {
+ return;
+ }
+
+ if ((e.keyCode == 67 && e.ctrlKey) || (e.keyCode==89 && e.shiftKey)) {
+ clipboard=currentDiv;
+ return;
+ }else if ((e.keyCode == 86 && e.ctrlKey) || (e.keyCode==80 && e.shiftKey)) {
+ if (clipboard != currentDiv && !dragable_isBlank(clipboard)) {
+ dragable_moveContent(clipboard,currentDiv);
+ }
+ }
+
+}
+
+//goes up the parent tree until class is found. If not found, returns null
+function dragable_getObjectByClass(target,clazz) {
+ while (target.tagName!=topelement&&target.className!=clazz){
+ target=dom? target.parentNode : target.parentElement
+ }
+
+ if (target.className==clazz){
+ return target;
+ }else {
+ return null;
+ }
+
+}
+
+//initialization routine, must be called on load. Sets up event handlers
+function dragable_init(url) {
+ pageURL = url;
+ //window.scroll(10,500);
+ //set up event handlers
+ document.onmouseup=dragable_dragStop;
+ document.onkeydown=dragable_checkKeyEvent;
+ document.onmousemove=dragable_move;
+
+ //fill the wobject list
+ obj = document.getElementById("position1");
+ contentCount=2;
+ while (obj != null) {
+ tbody = dragable_getElementChildren(obj);
+ children = dragable_getElementChildren(tbody[0]);
+
+ if (children.length == 0) {
+ //stick in a blank
+ dragable_appendBlankRow(tbody[0]);
+ }else {
+ for (i = 0; i< children.length;i++) {
+ wobjectList[wobjectList.length] = children[i];
+ dragableList[dragableList.length]=document.getElementById(children[i].id + "_div");
+ }
+ }
+ obj = document.getElementById("positionArea" + contentCount);
+ contentCount++;
+ }
+
+ for (i=0;i