1 <?php
3 /* Sieve comment tag */
4 class sieve_comment
5 {
6 var $data = "";
7 var $object_id= -1;
8 var $small = TRUE;
10 function get_sieve_script_part()
11 {
12 $str = "/*".$this->data."*/\n";
13 return($str);
14 }
16 function sieve_comment($data,$object_id)
17 {
18 $this->object_id = $object_id;
20 if($data == NULL){
21 $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => "/*"._("Your comment here")."*/")));
22 }
24 foreach($data['ELEMENTS'] as $node){
26 $text = $node['text'];
28 /* Convert \t to spaces */
29 $text = preg_replace("#\t#"," ",$text);
31 /* Remove comment indicator '#' but keep spaces */
32 $text = preg_replace("/^([ ]*)\#/","\\1",$text);
34 /* Remove comment indicator '/ *' */
35 $text = preg_replace("#\/\*#","",$text);
37 /* Remove comment indicator '* /' */
38 $text = preg_replace("#\*\/#","",$text);
40 $this->data .= $text."\n";
41 }
42 }
44 function check()
45 {
46 return(array()) ;
47 }
49 function save_object()
50 {
51 if(isset($_POST['comment_'.$this->object_id])){
52 $cm = stripslashes( $_POST['comment_'.$this->object_id]);
53 $this->data = $cm;
54 }
56 if(isset($_POST['toggle_small_'.$this->object_id])){
57 $this->small = !$this->small;
58 }
59 }
61 function execute()
62 {
63 $smarty = get_smarty();
64 $smarty->assign("ID", $this->object_id);
65 $smarty->assign("Small", $this->small);
66 $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
67 $Comment = $this->data;
69 if($this->small){
70 $Comment = nl2br(preg_replace("/ /"," ",$Comment));
71 }
73 /* Create html object */
74 $smarty = get_smarty();
75 $smarty->assign("Comment",$Comment);
76 $smarty->assign("ID",$this->object_id);
77 $object = $smarty->fetch(get_template_path("templates/element_comment.tpl",TRUE,dirname(__FILE__)));
78 $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
79 return($str);
80 }
81 }
82 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
83 ?>