Code

Modified style.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Mar 2007 09:21:36 +0000 (09:21 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Mar 2007 09:21:36 +0000 (09:21 +0000)
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 [new file with mode: 0644]
html/images/sieve_move_object_down.png [new file with mode: 0644]
html/images/sieve_move_object_up.png [new file with mode: 0644]
include/sieve/class_My_Tree.inc
include/sieve/class_sieveElement_If.inc
include/sieve/class_sieveElements.inc
include/sieve/templates/element_block_end.tpl
include/sieve/templates/element_block_start.tpl
include/sieve/templates/object_container.tpl [new file with mode: 0644]
include/sieve/templates/object_container_clear.tpl [new file with mode: 0644]

diff --git a/html/images/sieve_del_object.png b/html/images/sieve_del_object.png
new file mode 100644 (file)
index 0000000..f5cb2b8
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 (file)
index 0000000..586a765
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 (file)
index 0000000..4699e69
Binary files /dev/null and b/html/images/sieve_move_object_up.png differ
index a2b169545531d938177355f647bac80930a41a6e..bcf52cb2d3c93e9c259f48a713f805de54083fcd 100644 (file)
@@ -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()
   {
index 11b5c1b92fb47f089c3bf7f245f76f43b545a89d..21ff52309490c6318a10ce5d9e5a8e92c25d53b7 100644 (file)
@@ -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);
   }
 
   
index 199e03bc7cd8381a82cfa435fa645828c8d85e72..f40d9b8b356f7ab46cb9769f84a19c6b61b496ab 100644 (file)
@@ -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()
   {
index b5af6fbdeb0bec1e4e0acc4f3b7ced293fd5d714..52fbc8c5aa781b277388d65e8005c169e9a8b63d 100644 (file)
@@ -1,3 +1,16 @@
            </td>
     </tr>
 </table>
+<table cellspacing=0 width='100%' style='background-color: #235464; border: solid 1px #346575;'>
+       <tr>
+       <td style='height:4px;width:100%; text-align:center;vertical-align:top; background-color: #000000;'>
+           </td>
+    </tr>
+</table>
+
+<table cellspacing=0 width='100%' style='background-color: #235464; border: solid 1px #346575;'>
+       <tr>
+       <td style='height:4px;width:100%; text-align:center;vertical-align:top; background-color: #FFFFFF;'>
+           </td>
+    </tr>
+</table>
index fd3cea33f29e3af8ef97a5f5fca135d9a54852c7..8d30555498191edfdee56ce09b7c273ba16fa535 100644 (file)
@@ -1,7 +1,20 @@
-<table cellspacing=0 width='100%'>
+
+<table cellspacing=0 width='100%' style='background-color: #235464; border: solid 1px #346575;'>
        <tr>
-       <td style='width:20px; vertical-align:top;'>
-               <img alt='' src='images/forward.png' class='center'>
+       <td style='height:4px;width:100%; text-align:center;vertical-align:top; background-color: #FFFFFF;'>
+           </td>
+    </tr>
+</table>
+<table cellspacing=0 width='100%' style='background-color: #235464; border: solid 1px #346575;'>
+       <tr>
+       <td style='height:4px;width:100%; text-align:center;vertical-align:top; background-color: #000000;'>
+           </td>
+    </tr>
+</table>
+<table cellspacing=0 width='100%' style='background-color: #235464; border: solid 1px #346575;'>
+       <tr>
+       <td style='width:25px; text-align:center;vertical-align:top; color: #FFFFFF;'>
+                       <b>+</b>
         </td>
         <td style=' background-color:#BBBBBB;
                     border: solid 1px #DDDDDD;
diff --git a/include/sieve/templates/object_container.tpl b/include/sieve/templates/object_container.tpl
new file mode 100644 (file)
index 0000000..5b81881
--- /dev/null
@@ -0,0 +1,15 @@
+<table cellspacing=0 style='width:100%;background-color:#EEEEEE;border: solid 1px #346575;'>
+       <tr>
+               <td style='width:20px; background-color: #235464; border: solid 0px #346575;'>  
+                       <input type='image' src='images/sieve_del_object.png' name='Remove_Object_{$ID}' 
+                               title='{t}Remove this object{/t}' alt='R'>
+                       <input type='image' src='images/sieve_move_object_up.png' name='Move_Up_Object_{$ID}' 
+                               title='{t}Move this object one position up{/t}' alt='{t}Up{/t}'>
+                       <input type='image' src='images/sieve_move_object_down.png' name='Move_Down_Object_{$ID}' 
+                               title='{t}Move this object one position down{/t}' alt='{t}Down{/t}'>
+               </td>
+               <td>
+                       %%OBJECT_CONTENT%%
+               </td>
+       </tr>
+</table>
diff --git a/include/sieve/templates/object_container_clear.tpl b/include/sieve/templates/object_container_clear.tpl
new file mode 100644 (file)
index 0000000..dfb8973
--- /dev/null
@@ -0,0 +1,9 @@
+<table cellspacing=0 style='width:100%;background-color:#EEEEEE;border: solid 1px #346575;'>
+       <tr>
+               <td style='width:20px; background-color: #235464; border: solid 0px #346575;'>  
+               </td>
+               <td>
+                       %%OBJECT_CONTENT%%
+               </td>
+       </tr>
+</table>