Code

Put each class in a single file.
[gosa.git] / include / sieve / class_sieveElement_Comment.inc
1 <?php
3 /* Sieve comment tag */
4 class sieve_comment 
5 {
6   var $data = "";
7   var $object_id= -1;
9   function get_sieve_script_part()
10   {
11     return($this->data."\n");
12   } 
13     
14   function sieve_comment($data,$object_id)
15   {
16     $this->object_id = $object_id;
17     foreach($data['ELEMENTS'] as $node){
18        $this->data .= $node['text'];
19     }
20   }
22   function save_object()
23   {
24     if(isset($_POST['comment_'.$this->object_id])){
25       $cm = $_POST['comment_'.$this->object_id];
26       $this->data = "/*".$cm."*/";
27     }
28   }
30   function execute()
31   {
32     $smarty = get_smarty();
33     $smarty->assign("ID", $this->object_id);
34     $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
35     $Comment = $this->data;
37     /* Remove comment tags */
38     if(preg_match("/^#/",$Comment)){
39       $Comment = preg_replace("/^#/","",$Comment);
40     }elseif(preg_match("#\/\*#",$Comment)){
41       $Comment = preg_replace("#^\/\*#","",$Comment);
42       $Comment = preg_replace("#\*\/$#","",$Comment);
43     }
44  
45     /* Create html object */ 
46     $smarty = get_smarty();
47     $smarty->assign("Comment",$Comment);
48     $smarty->assign("ID",$this->object_id);
49     $object = $smarty->fetch(get_template_path("templates/element_comment.tpl",TRUE,dirname(__FILE__)));    
50     $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
51     return($str);
52   }
53 }
54 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
55 ?>