Code

Updated class tree to combine multiple comments
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 21 Mar 2007 06:56:34 +0000 (06:56 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 21 Mar 2007 06:56:34 +0000 (06:56 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5842 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_My_Tree.inc
include/sieve/templates/element_size.tpl

index 8525ee32dd5356ae531927789cf301a6b6754549..c94d34cef8d7d8836ab52a657c303b6cec07bd8e 100644 (file)
@@ -87,6 +87,14 @@ class My_Tree extends Tree
     /* Get node */ 
     $node = $this->nodes_[$node_id];
 
+    /* Get last element class */
+    $last_class = "";
+    if(count($this->mode_stack)){
+      $key = key($this->mode_stack);
+      $tmp = array_reverse($this->mode_stack[$key]['ELEMENTS']);
+      $last_class = $tmp[key($tmp)]['class'];
+    }
+
     /* This closes the last mode */
     if($node['class'] == "block-start"){
       $tmp = array_pop($this->mode_stack);
@@ -107,14 +115,30 @@ class My_Tree extends Tree
       $this->handle_elements($tmp,$node_id);
     }
 
-    /* Handle comments */
-    if($node['class'] == "comment"){
-      $this->mode_stack[] = array("TYPE" => $node['class']);
-      $rewoke_last = TRUE;
+
+    /* Comments require special attention.
+     * We do not want to create a single comment element 
+     *  foreach each  "#comment"  string found in the script. 
+     * Sometimes comments are used like this 
+     *   # This is a comment
+     *   #  and it still is a comment 
+     *   #  ...
+     * So we combine them to one single comment.
+     */
+    if($last_class != "comment" && $node['class'] == "comment"){
+      $tmp =array_pop($this->mode_stack);
+      $this->handle_elements($tmp,$node_id);
+      $this->mode_stack[] = array("TYPE" => $node['class']); 
+    }  
+
+    if($last_class == "comment" && $node['class'] != "comment"){
+      $tmp =array_pop($this->mode_stack);
+      $this->handle_elements($tmp,$node_id);
     }
 
+
     /* Handle identifiers */
-    $identifiers = array("else","if","elsif","end","reject","redirect","vacation","keep","discard","comment","fileinto","require","stop");
+    $identifiers = array("else","if","elsif","end","reject","redirect","vacation","keep","discard","fileinto","require","stop");
     if($node['class'] == "identifier" && in_array($node['text'],$identifiers)){
       $this->mode_stack[] = array("TYPE" => $node['text']); 
     }
index a42d77243617268e4077c8c1e23bf3dfd27646c2..fa6a92fbb1915a8cef7dfb65f0135a0d9e1ea496 100644 (file)
@@ -1,7 +1,7 @@
 <table class='sieve_test_case'>
        <tr>
                <td>
-<b>{t}Size{/t}</b>
+                       <b>{t}Size{/t}</b>
                        {if $LastError != ""}
                                <font color='red'>{$LastError}</font>
                                <br>