From 09a39dbf7ee8dce26fdcd4f1f4b7c140e386bc07 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 9 Mar 2007 09:21:36 +0000 Subject: [PATCH] Modified style. Tried to add some edit functionality- git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5761 594d385d-05f5-0310-b6e9-bd551577e9d8 --- html/images/sieve_del_object.png | Bin 0 -> 691 bytes html/images/sieve_move_object_down.png | Bin 0 -> 685 bytes html/images/sieve_move_object_up.png | Bin 0 -> 662 bytes include/sieve/class_My_Tree.inc | 115 ++++++++++++++++++ include/sieve/class_sieveElement_If.inc | 10 +- include/sieve/class_sieveElements.inc | 64 +++++++++- include/sieve/templates/element_block_end.tpl | 13 ++ .../sieve/templates/element_block_start.tpl | 19 ++- include/sieve/templates/object_container.tpl | 15 +++ .../templates/object_container_clear.tpl | 9 ++ 10 files changed, 236 insertions(+), 9 deletions(-) create mode 100644 html/images/sieve_del_object.png create mode 100644 html/images/sieve_move_object_down.png create mode 100644 html/images/sieve_move_object_up.png create mode 100644 include/sieve/templates/object_container.tpl create mode 100644 include/sieve/templates/object_container_clear.tpl diff --git a/html/images/sieve_del_object.png b/html/images/sieve_del_object.png new file mode 100644 index 0000000000000000000000000000000000000000..f5cb2b8b9128f0c6135942d53f1843e5f4d3f65b GIT binary patch literal 691 zcmV;k0!;mhP)_Ox2j_4W_xGK1 z&k^j_wWmF)vFU}WG2=oq7Czqa#GqYoQmn}0?~Tlt&G%29q&r&4Ve-+8Y~5d0RscDn zSGofrYZXfa4Ir=KX92P$a6AZ!*0!T&Yd4nE`vFQ){k@AJAYwpQ7(zzN?E4T3LDdG! z+HV54=|~`;l^RWu%0o8-OhaIX4WbdKX;8A&YY)J-wUmI;P_DpM&L#6pQMELVs|f;+ zgCl*!%mj{hIw!ELimW+cD^LntR{#+rVS|u}V9Pq+f0U?I6xL3?^9l{!)KWpof@U+o zG);QC!kA$Y0%Gwvw(ApBIndS4FDU7%gxzE!ZerPjY6B_`hz5j1&>IPuN(mOmN0?g< zboqZkF`M34OK<6m)2XgAgFbm>P?X>Y5R1atpr9`bFW=?daz2}5KPAWKm+n4TEu`12 zKR#DFYyd0geCw0y;@V zK~y-)rIX7`RACs#f8Td5b7nk_UBF0?+K5H9X;B3I6E50Cn=V8$(YjpNLI$dxQ`vZh#4#1mZwYH3q;ekO9J`X3Y^h-GkMzkDy!zxEC>k4nr#o z5h;t!`ux`)vhcbS$S9>qBog%Y_U-`e{AbQy`-nDeRKT$_2fd@KIUlWIWxc}NCz&lD zq}Dx^O3~QZh^_&0(`m+29at7P7M|x78JpQ;Y-G=$z*Z|0I20}9~ggn z8BKwRV-R;WZdBvg3bhmN?x6n$0Bs9jUbJS%hT?9MOGC^c>S%1+0PzKA22NB1ZUuCh z!TIa2-YG>(Ai|-xbM2NY5sPX9AH2;1kpt~Vtm8KyRKzg+N;&Xn9$!Ly3CDQ#JvUCZ z@UV41OwBGmyEMf)N zjs^|7C>YI6WJ`+4iA8=6C%R-MoeX`ohoM0$o-gOE9^W@`9gX8?Vo?J(Zj)WyU}Er2 zpTC^$**%F6pw%`+LD$l6GbN&kIvTgZ;MbDJX#d^*;@m)I{mzE~k?jJg1SGOKb5JYI z+N#IM%LnQF_r5FDb*6sj0SM~usZ>!HvpI7({iff}j3zGt1@@5I;}ZW#n*Y=vvw!XU T8A|YM00000NkvXXu0mjfafK#? literal 0 HcmV?d00001 diff --git a/html/images/sieve_move_object_up.png b/html/images/sieve_move_object_up.png new file mode 100644 index 0000000000000000000000000000000000000000..4699e69b112b2583263f060a822c9133acba89cb GIT binary patch literal 662 zcmV;H0%`q;P)R#C^hyZrB(m{0wYO8 zK~y-)rISlYlu;DNfA@RLe3*}6EM@G4kEF~VE=DjRXiNwxqJm72$`(@LCWv5YkqdDh z*kDj?!d*n$+C>rVTtq=)ZIT3q2%U$Y-^{(Ig@ZF1y79o_UO4x0{^$SyD-mHQVX?zd zTbG>Zu}i79i5tU#@6)RkE9KS6tJ`-_(a@EA)zd!^k3|aIAxEYFELFu;vgb!XzbqzcksIB+NWHl?kK`EiWrZ6HfrVW^~x!dKJ z?YhLnll_k$G#!ef^BNIB0a_p&5ZaE7IWgoVi@4U1f*K(BBR!v*$sdIfb(Yh)u8#-Gm z`0!=n@50Rc8A~ZdnEyCAcm==#6r!{G$CDuq5nZz)vOz*C7~S4)_Xu0~S%X3WBu(W^3vc6GTYeq*$%c*rXrM=mBB7%tU4@JG&u|{`Mi~s-t07*qoM6N<$f=0q4VgLXD literal 0 HcmV?d00001 diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index a2b169545..bcf52cb2d 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -149,9 +149,124 @@ class My_Tree extends Tree if(in_array(get_class($obj),array("sieve_if","sieve_elsif","sieve_vacation","sieve_comment","sieve_reject","sieve_fileinto","sieve_require","sieve_redirect"))){ $this->pap[$key]->save_object(); } + + $once = TRUE; + foreach($_POST as $name => $value){ + + if(isset($obj->object_id) && preg_match("/^Remove_Object_".$obj->object_id."_/",$name) && $once){ + $once = FALSE; + $this->remove_object($key); + } + if(isset($obj->object_id) && preg_match("/^Move_Up_Object_".$obj->object_id."_/",$name) && $once){ + $this->move_object_up($key); + $once = FALSE; + } + if(isset($obj->object_id) && preg_match("/^Move_Down_Object_".$obj->object_id."_/",$name) && $once){ + $this->move_object_down($key); + $once = FALSE; + } + } } } + + function remove_object($key_id){ + unset($this->pap[$key_id]); + } + + + function move_object_up($key_id) + { + $new = array(); + $add_now = NULL; + $key_id --; + + if(!$key_id < 0) return; + + foreach($this->pap as $key => $data){ + if($key == $key_id){ + $add_now = $data; + continue; + }else{ + $new[] = $data; + } + + if($add_now != NULL){ + + $new[] = $add_now; + $add_now = NULL; + } + } + if($add_now != NULL){ + $new[] = $add_now; + } + $this->pap = $new; + } + + + /* This function moves the given element one position down + * if the next position is between + * '}' 'else[if]' or 'if' '{' use next available + */ + function move_object_down($key_id) + { + $new = array(); + $add_now = NULL; + + /* Walk through all elements, till we found the given id. + * If we found it, skip adding the current element, + * first add the next element followed by the current. + */ + foreach($this->pap as $key => $data){ + + /* Have we found the given id */ + if($key == $key_id){ + $add_now = $data; + $last_class = get_class($data); + continue; + }else{ + + /* Add entry */ + $new[] = $data; + } + + /* We have skipped adding an element before, + * try to add it now, if the position allows this. + */ + if($add_now != NULL){ + + /* Don't allow adding an element directly after + * if/else/elsif + */ + if(in_array(get_class($data),array("sieve_if","sieve_elsif","sieve_else"))){ + continue; + } + + /* If this is an block end, check if there + * follows an if/else/elsif and skip adding the element in this case. + */ + $next =""; + if(isset($this->pap[$key+1])){ + $next = get_class($this->pap[$key+1]); + } + if(in_array(get_class($data),array("sieve_block_end")) && in_array($next,array("sieve_elsif","sieve_else"))){ + continue; + } + + /* Add element, position seems to be ok */ + $new[] = $add_now; + $add_now = NULL; + } + } + + /* Element wasn't added, add it as last element */ + if($add_now != NULL){ + $new[] = $add_now; + } + $this->pap = $new; + } + + /* Need to be reviewed */ function get_sieve_script() { diff --git a/include/sieve/class_sieveElement_If.inc b/include/sieve/class_sieveElement_If.inc index 11b5c1b92..21ff52309 100644 --- a/include/sieve/class_sieveElement_If.inc +++ b/include/sieve/class_sieveElement_If.inc @@ -615,9 +615,17 @@ class sieve_if } $smarty = get_smarty(); + $smarty->assign("ID", $this->id); + $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__))); + $smarty->assign("Name", $name); $smarty->assign("Contents", $this->get_as_html()); - return($smarty->fetch(get_template_path("templates/element_if_else.tpl",TRUE,dirname(__FILE__)))); + $object = $smarty->fetch(get_template_path("templates/element_if_else.tpl",TRUE,dirname(__FILE__))); + + $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); + + + return($str); } diff --git a/include/sieve/class_sieveElements.inc b/include/sieve/class_sieveElements.inc index 199e03bc7..f40d9b8b3 100644 --- a/include/sieve/class_sieveElements.inc +++ b/include/sieve/class_sieveElements.inc @@ -8,10 +8,25 @@ class sieve_elsif extends sieve_if class sieve_else { + var $object_id = -1; + + function sieve_else($data,$object_id) + { + $this->object_id = $object_id; + } + + function save_object() + { + } + function execute() { $smarty = get_smarty(); - return($smarty->fetch(get_template_path("templates/element_else.tpl",TRUE,dirname(__FILE__)))); + $smarty->assign("ID", $this->object_id); + $object_container = $smarty->fetch(get_template_path("templates/object_container_clear.tpl",TRUE,dirname(__FILE__))); + $object= $smarty->fetch(get_template_path("templates/element_else.tpl",TRUE,dirname(__FILE__))); + $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); + return($str); } function get_sieve_script_part() @@ -50,6 +65,9 @@ class sieve_comment function execute() { + $smarty = get_smarty(); + $smarty->assign("ID", $this->object_id); + $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__))); $Comment = $this->data; /* Remove comment tags */ @@ -64,7 +82,9 @@ class sieve_comment $smarty = get_smarty(); $smarty->assign("Comment",$Comment); $smarty->assign("ID",$this->object_id); - return($smarty->fetch(get_template_path("templates/element_comment.tpl",TRUE,dirname(__FILE__)))); + $object = $smarty->fetch(get_template_path("templates/element_comment.tpl",TRUE,dirname(__FILE__))); + $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); + return($str); } } @@ -123,9 +143,11 @@ class sieve_require class sieve_discard { var $data = array(); + var $object_id = -1; - function sieve_discard($data) + function sieve_discard($data,$object_id) { + $this->object_id = $object_id; } function get_sieve_script_part() @@ -133,10 +155,19 @@ class sieve_discard return("discard;\n"); } + function save_object() + { + + } + function execute() { $smarty = get_smarty(); - return($smarty->fetch(get_template_path("templates/element_discard.tpl",TRUE,dirname(__FILE__)))); + $smarty->assign("ID", $this->object_id); + $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__))); + $object = $smarty->fetch(get_template_path("templates/element_discard.tpl",TRUE,dirname(__FILE__))); + $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); + return($str); } } @@ -442,6 +473,10 @@ class sieve_block_start return($smarty->fetch(get_template_path("templates/element_block_start.tpl",TRUE,dirname(__FILE__)))); } + function save_object() + { + } + function get_sieve_script_part() { return("{\n"); @@ -459,15 +494,34 @@ class sieve_block_end { return("}\n"); } + function save_object() + { + } + } /* This class handles the keep statement */ class sieve_keep { + var $object_id = -1; + + function sieve_keep($data,$object_id) + { + $this->object_id = $object_id; + } + + function save_object() + { + } + function execute() { $smarty = get_smarty(); - return($smarty->fetch(get_template_path("templates/element_keep.tpl",TRUE,dirname(__FILE__)))); + $smarty->assign("ID", $this->object_id); + $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__))); + $object = $smarty->fetch(get_template_path("templates/element_keep.tpl",TRUE,dirname(__FILE__))); + $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); + return($str); } function get_sieve_script_part() { diff --git a/include/sieve/templates/element_block_end.tpl b/include/sieve/templates/element_block_end.tpl index b5af6fbde..52fbc8c5a 100644 --- a/include/sieve/templates/element_block_end.tpl +++ b/include/sieve/templates/element_block_end.tpl @@ -1,3 +1,16 @@ + + + + +
+
+ + + + + +
+
diff --git a/include/sieve/templates/element_block_start.tpl b/include/sieve/templates/element_block_start.tpl index fd3cea33f..8d3055549 100644 --- a/include/sieve/templates/element_block_start.tpl +++ b/include/sieve/templates/element_block_start.tpl @@ -1,7 +1,20 @@ - + +
- + +
- + +
+ + + + +
+
+ + + + + + +
+ + +
+ + + + + %%OBJECT_CONTENT%% +
diff --git a/include/sieve/templates/object_container_clear.tpl b/include/sieve/templates/object_container_clear.tpl new file mode 100644 index 000000000..dfb897357 --- /dev/null +++ b/include/sieve/templates/object_container_clear.tpl @@ -0,0 +1,9 @@ + + + + + +
+ + %%OBJECT_CONTENT%% +
-- 2.30.2