From 77a475f344ccaa00dd1df757b25847393be4da97 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 14 Mar 2007 14:32:39 +0000 Subject: [PATCH] Some changes git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5784 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/sieve/class_My_Parser.inc | 9 ++++----- include/sieve/class_My_Tree.inc | 14 +++++++++++-- include/sieve/class_sieveManagement.inc | 22 +++++++++++++++++++++ include/sieve/templates/edit_frame_base.tpl | 7 ++++++- include/sieve/templates/element_anyof.tpl | 2 +- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/include/sieve/class_My_Parser.inc b/include/sieve/class_My_Parser.inc index 434a80ff6..698fbbadf 100644 --- a/include/sieve/class_My_Parser.inc +++ b/include/sieve/class_My_Parser.inc @@ -12,15 +12,14 @@ class My_Parser extends Parser { /* 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"'); + header('Content-Disposition: filename="dump.script"'); } else { - header('Content-Disposition: attachment; filename="dump.txt"'); + header('Content-Disposition: attachment; filename="dump.script"'); } header("Content-transfer-encoding: binary\n"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); @@ -31,7 +30,7 @@ class My_Parser extends Parser echo $this->get_sieve_script(); exit(); } - + $ret = $this->dumpParseTree(); return($ret); } diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index c6355d407..b6e59a581 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -20,6 +20,8 @@ class My_Tree extends Tree var $add_new_id = 0; var $add_type = "top"; var $add_element_type = ""; + + var $Mode = "Structured"; function execute() { @@ -47,7 +49,6 @@ class My_Tree extends Tree } } - return($this->dump()); } @@ -173,7 +174,16 @@ class My_Tree extends Tree /* Create html results */ $smarty = get_smarty(); - $smarty->assign("Contents",$this->dump_); + $smarty->assign("Mode",$this->Mode); + if($this->Mode == "Structured"){ + $smarty->assign("Contents",$this->dump_); + }else{ + if(isset($_POST['script_contents'])){ + $smarty->assign("Contents",stripslashes($_POST['script_contents'])); + }else{ + $smarty->assign("Contents",$this->get_sieve_script()); + } + } $ret = $smarty->fetch(get_template_path("templates/edit_frame_base.tpl",TRUE,dirname(__FILE__))); return ($ret); } diff --git a/include/sieve/class_sieveManagement.inc b/include/sieve/class_sieveManagement.inc index c65fdca74..b1980adb7 100644 --- a/include/sieve/class_sieveManagement.inc +++ b/include/sieve/class_sieveManagement.inc @@ -273,6 +273,28 @@ class sieveManagement extends plugin /* Create output for currently opened sieve script */ if($this->current_handler){ + + if(isset($_POST['script_contents']) && $this->current_handler->tree_->Mode == "Source"){ + $script = stripslashes($_POST['script_contents']); + + $new_p = new My_Parser; + if($new_p->parse($script)){ + $this->current_handler->parse($script); + $this->current_handler->tree_->Mode = "Source"; + }else{ + print_red($new_p->status_text); + $this->current_handler->tree_->Mode = "Source"; + } + } + + if(isset($_POST['View_Source'])){ + $this->current_handler->tree_->Mode = "Source"; + } + + if(isset($_POST['View_Structured'])){ + $this->current_handler->tree_->Mode = "Structured"; + } + $ret = $this->current_handler->execute(); return($ret); } diff --git a/include/sieve/templates/edit_frame_base.tpl b/include/sieve/templates/edit_frame_base.tpl index d99edbba0..93953fabc 100644 --- a/include/sieve/templates/edit_frame_base.tpl +++ b/include/sieve/templates/edit_frame_base.tpl @@ -14,7 +14,12 @@ - {$Contents} + + {if $Mode == "Structured"} + {$Contents} + {else} + + {/if} diff --git a/include/sieve/templates/element_anyof.tpl b/include/sieve/templates/element_anyof.tpl index bdef028fc..e0b02054f 100644 --- a/include/sieve/templates/element_anyof.tpl +++ b/include/sieve/templates/element_anyof.tpl @@ -6,12 +6,12 @@ background-color: #AAAAAA; border: solid 1px #EEEEEE '> + {t}Any of{/t} {if $Inverse} {else} {/if} - {$Contents} -- 2.30.2