Code

Updated class location table.
[gosa.git] / include / sieve / class_My_Parser.inc
index 698fbbadf33eebd4fb03ab54ff5346b5c7ce123c..ac99301a6f0406dac55cad68e4cf97fb160530c5 100644 (file)
@@ -1,36 +1,25 @@
 <?php
 
+/* String used to indent the different code blocks */
 define("SIEVE_INDENT_TAB","  ");
 
+
 /* This class is inherited from the original 'Parser'
  *  class written by Heiko Hund
  */
 class My_Parser extends Parser 
 {
+       var $parent = NULL;
+       var $registeredExtensions_ =array();
 
-       function execute()
+       function My_Parser($parent)
        {
-               /* Create dump of current sieve script */
-               if(isset($_POST['Save_Copy'])){
-
-                       /* 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.script"');
-                       } else {
-                               header('Content-Disposition: attachment; filename="dump.script"');
-                       }
-                       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(); 
-               }
+               $this->registeredExtensions_ = array();         
+               $this->parent = $parent;
+       }
 
+       function execute()
+       {
                $ret = $this->dumpParseTree();
                return($ret);
        }
@@ -48,16 +37,20 @@ class My_Parser extends Parser
      */
        function parse($script) 
        {
+               $script = preg_replace("/^###GOSA/","",$script);
+
+               $this->registeredExtensions_ = array();
         $this->status_text = "incomplete";
         $this->script_ = $script;
-        $this->tree_ = new My_Tree(@Scanner::scriptStart());
+        $this->tree_ = new My_Tree(@Scanner::scriptStart(),$this);
         $this->tree_->setDumpFunc(array(&$this, 'dumpToken_'));
-        $this->scanner_ = new Scanner($this->script_);
+        $this->scanner_ = new My_Scanner($this->script_);
         $this->scanner_->setCommentFunc(array($this, 'comment_'));
 
         if ($this->commands_($this->tree_->getRoot()) &&
             $this->scanner_->nextTokenIs('script-end'))
         {
+                       $this->scanner_->nextToken(); 
             return $this->success_('success');
         }
 
@@ -67,7 +60,7 @@ class My_Parser extends Parser
        
        function get_sieve_script()
        {
-               return($this->tree_->get_sieve_script());
+               return("###GOSA\n".$this->tree_->get_sieve_script());
        }               
 
        
@@ -77,22 +70,6 @@ class My_Parser extends Parser
        }
 
 
-       /* Should be obsolete in the end. */
-       function dumpToken_(&$token)
-       {
-               if (is_array($token))
-               {
-                       $str = "<" . $token['text'] . "> ";
-                       foreach ($token as $k => $v)
-                       {
-                               $str .= " $k:$v";
-                       }
-                       return $str;
-               }
-               return strval($token);
-       }
-
-
        function dumpParseTree()
        {
                return $this->tree_->execute();