From: hickert Date: Fri, 9 Mar 2007 09:21:36 +0000 (+0000) Subject: Modified style. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=09a39dbf7ee8dce26fdcd4f1f4b7c140e386bc07;p=gosa.git Modified style. Tried to add some edit functionality- git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5761 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/html/images/sieve_del_object.png b/html/images/sieve_del_object.png new file mode 100644 index 000000000..f5cb2b8b9 Binary files /dev/null and b/html/images/sieve_del_object.png differ diff --git a/html/images/sieve_move_object_down.png b/html/images/sieve_move_object_down.png new file mode 100644 index 000000000..586a7657e Binary files /dev/null and b/html/images/sieve_move_object_down.png differ diff --git a/html/images/sieve_move_object_up.png b/html/images/sieve_move_object_up.png new file mode 100644 index 000000000..4699e69b1 Binary files /dev/null and b/html/images/sieve_move_object_up.png differ 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%% +