From: hickert Date: Fri, 23 Feb 2007 11:36:15 +0000 (+0000) Subject: Some sieve editor changes X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=54eb3e656f66bacbd208d9d655dbd4b2e5de3593;p=gosa.git Some sieve editor changes git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5730 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/sieve/class_My_Parser.inc b/include/sieve/class_My_Parser.inc index 703d44a1f..f0a3f9d89 100644 --- a/include/sieve/class_My_Parser.inc +++ b/include/sieve/class_My_Parser.inc @@ -6,7 +6,7 @@ class My_Parser extends Parser { $this->status_text = "incomplete"; $this->script_ = $script; - $this->tree_ = new My_Tree(Scanner::scriptStart()); + $this->tree_ = new My_Tree(@Scanner::scriptStart()); $this->tree_->setDumpFunc(array(&$this, 'dumpToken_')); $this->scanner_ = new Scanner($this->script_); $this->scanner_->setCommentFunc(array($this, 'comment_')); diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index 396634a61..744f974c0 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -17,10 +17,10 @@ class My_Tree extends Tree $this->pap = array(); $this->doDump_(0, '', true); - $this->dump_ ="
"; + $this->dump_ ="
"; foreach($this->pap as $object){ if(is_object($object)){ - $this->dump_ .= $object->execute()."
"; + $this->dump_ .= preg_replace("/>/",">\n",$object->execute()); } } $this->dump_ .= "
"; @@ -69,7 +69,7 @@ class My_Tree extends Tree } /* Handle identifiers */ - $identifiers = array("if","elsif","end","reject","redirect","vacation","keep","discard","comment","fileinto","require"); + $identifiers = array("if","elsif","end","reject","redirect","vacation","keep","discard","comment","fileinto","require","stop"); if($node['class'] == "identifier" && in_array($node['text'],$identifiers)){ $this->mode_stack[] = array("TYPE" => $node['text']); } @@ -116,5 +116,26 @@ class My_Tree extends Tree } } } + + +function sieve_get_strings($data,$id) +{ + $ret = array(); + if($data[$id]['class'] == "left-bracket"){ + while($data[$id]['class'] != "right-bracket" && $id < count($data)){ + + if($data[$id]['class'] == "quoted-string"){ + $ret[] = $data[$id]['text']; + } + $id ++; + } + }elseif($data[$id]['class'] == "quoted-string"){ + $ret[] = $data[$id]['text']; + }elseif($data[$id]['class'] == "number"){ + $ret[] = $data[$id]['text']; + } + return(array("OFFSET" => $id, "STRINGS" => $ret)); +} + // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/include/sieve/class_sieveElement.inc b/include/sieve/class_sieveElement.inc index b6fde6fb5..596bd6d00 100644 --- a/include/sieve/class_sieveElement.inc +++ b/include/sieve/class_sieveElement.inc @@ -15,7 +15,7 @@ class sieveElement function resolve_to_object($data) { - $this->data = @nl2br($data->dumpParseTree()); + $this->data = @$data->dumpParseTree(); } function execute() diff --git a/include/sieve/class_sieveElements.inc b/include/sieve/class_sieveElements.inc index 1bb693a98..37031994e 100644 --- a/include/sieve/class_sieveElements.inc +++ b/include/sieve/class_sieveElements.inc @@ -1,95 +1,13 @@ "); - } + var $TYPE = "elsif"; } -class sieve_elsif extends sieve_if {} -class sieve_if extends sieve_element -{ - - /* Contains all tests with an uniqe id */ - var $test_list = array(); - - /* Available test types */ - var $TESTS = array("address","allof","anyof","exists","false","header","not","size","true","envelope"); - - var $elements = array(); - - function sieve_if($elements) - { - $this->elements = $elements; - $this->_parse($elements); - } - - function execute() - { - return("-> "._("Condition")); - } - - - function _parse($data,$id = 0) - { - /* Objects that could be tested */ - $av_methods = array("address","allof","anyof","exists","false","header","not","size","true","envelope"); - - /* Tests that could be used */ - $av_match_type= array(":is",":contains",":matches",":over",":count",":value"); - - /* Variable initialization */ - $test_method = ""; // The object that we want to test, like 'header' - $match_type = ""; // The operator like :contains - $obj_attribute = ""; // The attribute we want to check, like 'from' - $obj_match_value= ""; // The value that we want to match for. - $comparator = ""; // The comperator specifies the type of values that should be matched. - - $node = $data['ELEMENTS'][$id]; - - /* Skip the if / else identifier */ - if($node ['class'] == "identifier" && in_array($node['text'],array("if","elsif"))){ - $id ++; - $node = $data['ELEMENTS'][$id]; - } - - /* Get current command like "allof" or "header" */ - if($node ['class'] == "identifier" && in_array($node['text'],$av_methods)){ - $test_method = $node['text']; - } - - echo $id; - - /* switch different types */ - switch($test_method) - { - case "allof" : $this->_parse($elements,$id); - case "anyof" : $this->_parse($elements,$id); - - case "address" : - { - /* header :comparator :optional-operator :operator attribute match-value */ - $tmp = array(); - $tmp['OPTIONAL_OP'] =""; - $tmp['COMPARATOR'] =""; - $tmp['OPERATOR'] =""; - $tmp['ATTRIBUTE'] =""; - $tmp['MATCH-VALUE'] =""; - - - } - default : echo $test_method."
" ; - } - } -}; - - -class sieve_comment extends sieve_element +class sieve_comment { var $data = ""; @@ -103,12 +21,16 @@ class sieve_comment extends sieve_element function execute() { - return(_("Comment")." "); + $str ="
"._("Comment"); + $str .=""; + $str .="
"; + return($str); } } -class sieve_require extends sieve_element +class sieve_require + { var $data = array(); @@ -123,15 +45,16 @@ class sieve_require extends sieve_element function execute() { - $str = _("Sieve includes"); + $str = "
"._("Script includes"); foreach($this->data as $req){ $str .= " ".$req.""; } + $str .="
"; return($str); } } -class sieve_discard extends sieve_element +class sieve_discard { var $data = array(); @@ -141,14 +64,15 @@ class sieve_discard extends sieve_element function execute() { - $str = _("Discard mail"); + $str = "
"._("Discard message"); + $str .="
"; return($str); } } -class sieve_reject extends sieve_element +class sieve_reject { var $data = array(); @@ -165,13 +89,14 @@ class sieve_reject extends sieve_element function execute() { - $str = _("Reject mail"); + $str = "
"._("Reject mail"); $str .= " "; + $str .="
"; return($str); } } -class sieve_redirect extends sieve_element +class sieve_redirect { var $data = array(); @@ -186,15 +111,16 @@ class sieve_redirect extends sieve_element function execute() { - $str = _("Redirect to"); + $str = "
"._("Redirect to"); foreach($this->data as $dest){ $str .= "
"; } + $str .="
"; return($str); } } -class sieve_fileinto extends sieve_element +class sieve_fileinto { var $data = array(); @@ -209,19 +135,19 @@ class sieve_fileinto extends sieve_element function execute() { - $str = _("File into"); - + $str = "
"._("File into"); $str .= ""; + $str .="
"; return($str); } } -class sieve_vacation extends sieve_element +class sieve_vacation { var $days = FALSE; var $subject = FALSE; @@ -293,28 +219,58 @@ class sieve_vacation extends sieve_element } } -class sieve_block_start extends sieve_element +class sieve_block_start { function execute() { - return(" + +
"); + return(" + + +
+ + "); } } -class sieve_block_end extends sieve_element +class sieve_block_end { function execute() { - return("
"); + return("
"); } } /* This class handles the keep statement */ -class sieve_keep extends sieve_element +class sieve_keep +{ + function execute() + { + $str = " + + + +
". + _("Keep message"); + $str .="
"; + return($str); + } +} + +/* This class handles the stop statement */ +class sieve_stop { function execute() { - return("-> "._("Keep message")); + $str = " + + + +
". + _("Stop here"); + $str .="
"; + return($str); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/include/sieve/libsieve.inc b/include/sieve/libsieve.inc index c438a9ce2..3b94e4975 100644 --- a/include/sieve/libsieve.inc +++ b/include/sieve/libsieve.inc @@ -4,4 +4,5 @@ require_once 'class_scanner.inc'; require_once 'class_semantics.inc'; require_once 'class_tree.inc'; require_once 'class_sieve.inc'; +require_once 'class_sieveElement_If.inc'; ?>