Code

Added edit frame
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 Mar 2007 14:47:07 +0000 (14:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 Mar 2007 14:47:07 +0000 (14:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5760 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_My_Parser.inc
include/sieve/class_My_Tree.inc
include/sieve/templates/edit_frame_base.tpl [new file with mode: 0644]

index b0ef7ea7654f2a45b273765176e2ab807d934d99..a45d24e83aa2455afb316ad7878c72eea7e82ff9 100644 (file)
@@ -10,6 +10,36 @@ class My_Parser extends Parser
 
        function execute()
        {
+
+
+               /* Add Element requested */
+               if(isset($_POST['Add_Element'])){
+                       $this->tree_->Add_Element();
+                       echo "Move this into Management";
+               }
+
+               /* Create dump of current sieve script */
+               if(isset($_POST['Save_Copy'])){
+                       echo "Move this into Management";
+               
+                       /* force download dialog */
+                       header("Content-type: application/tiff\n");
+                       if (preg_match('/MSIE 5.5/', $HTTP_USER_AGENT) ||
+                                       preg_match('/MSIE 6.0/', $HTTP_USER_AGENT)) {
+                               header('Content-Disposition: filename="dump.txt"');
+                       } else {
+                               header('Content-Disposition: attachment; filename="dump.txt"');
+                       }
+                       header("Content-transfer-encoding: binary\n");
+                       header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+                       header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
+                       header("Cache-Control: no-cache");
+                       header("Pragma: no-cache");
+                       header("Cache-Control: post-check=0, pre-check=0");
+                       echo $this->get_sieve_script(); 
+                       exit(); 
+               }
+       
                $ret = $this->dumpParseTree();
                return($ret);
        }
index 9499fd6416135bd576254eef51f8dda75ea26fc9..a2b169545531d938177355f647bac80930a41a6e 100644 (file)
@@ -32,14 +32,22 @@ class My_Tree extends Tree
     }
 
     /* Create html results */
-    $this->dump_ ="<table width='100%'><tr><td style='background-color:#BBBBBB;border: 0px;padding-left:20px;'>";
+    $smarty = get_smarty();
+    $smarty->fetch(get_template_path("templates/element_stop.tpl",TRUE,dirname(__FILE__)));
+
+    $this -> dump_ = "";
     foreach($this->pap as $key => $object){
       if(is_object($object)){
         $this->dump_ .= preg_replace("/>/",">\n",$object->execute()); 
       }
     }
-    $this->dump_ .= "</td></tr></table>";
-    return $this->dump_;
+    
+
+    /* Create html results */
+    $smarty = get_smarty();
+    $smarty->assign("Contents",$this->dump_);
+    $ret = $smarty->fetch(get_template_path("templates/edit_frame_base.tpl",TRUE,dirname(__FILE__)));
+    return ($ret);
   }
 
 
@@ -177,6 +185,12 @@ class My_Tree extends Tree
     }
     return($tmp);
   }
+
+  function Add_Element()
+  {
+    $tmp = array("ELEMENTS" => array(array("class" => "qouted-string","text"=> "Bla bla, later more")));
+    $this->pap[] = new sieve_comment($tmp,rand(1000,100000));
+  }
 }
 
 
diff --git a/include/sieve/templates/edit_frame_base.tpl b/include/sieve/templates/edit_frame_base.tpl
new file mode 100644 (file)
index 0000000..9de761c
--- /dev/null
@@ -0,0 +1,21 @@
+<table style='width:100%;' cellspacing=0 cellpadding=0>
+
+       <tr>
+               <td style='background-color: #CCCCCC; padding:5px;'>
+                       
+                       <input type='submit' name='Add_Element' value="{t}Add element{/t}">
+                       <input type='submit' name='Save_Copy' value="{t}Save copy{/t}">
+                       <input type='submit' name='Import_Copy' value="{t}Import copy{/t}">
+
+                       
+                       <input type='submit' name='View_Source' value="{t}View source{/t}">
+                       <input type='submit' name='View_Structured' value="{t}View structured{/t}">
+               </td>
+       </tr>
+       <tr>
+               <td style='background-color: #FFFFFF; border: solid 2px #CCCCCC; '>
+                       {$Contents}
+
+               </td>
+       </tr>
+</table>