diff --git a/include/sieve/class_sieveElement_Comment.inc b/include/sieve/class_sieveElement_Comment.inc
index 0b718b80489b401cf5b21ae011f1e88c6cdb5990..e8caa157ca64ec0c812864e80bfefb046c663470 100644 (file)
{
var $data = "";
var $object_id= -1;
+ var $small = TRUE;
function get_sieve_script_part()
{
- return($this->data."\n");
+ $str = "\n/*".$this->data."*/";
+ return($str);
}
function sieve_comment($data,$object_id)
$this->object_id = $object_id;
if($data == NULL){
- $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => _("Your comment here"))));
+ $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => "/*"._("Your comment here")."*/")));
}
foreach($data['ELEMENTS'] as $node){
- $this->data .= $node['text'];
+
+ $text = $node['text'];
+
+ /* Convert \t to spaces */
+ $text = preg_replace("#\t#"," ",$text);
+
+ /* Remove comment indicator '#' but keep spaces */
+ $text = preg_replace("/^([ ]*)\#/","\\1",$text);
+
+ /* Remove comment indicator '/ *' */
+ $text = preg_replace("#\/\*#","",$text);
+
+ /* Remove comment indicator '* /' */
+ $text = preg_replace("#\*\/#","",$text);
+
+ $this->data .= $text."\n";
}
+ $this->data = rtrim($this->data)."\n";
}
function check()
function save_object()
{
if(isset($_POST['comment_'.$this->object_id])){
- $cm = $_POST['comment_'.$this->object_id];
- $this->data = "/*".$cm."*/";
+ $cm = stripslashes( $_POST['comment_'.$this->object_id]);
+ $this->data = $cm;
+ }
+
+ if(isset($_POST['toggle_small_'.$this->object_id])){
+ $this->small = !$this->small;
}
}
{
$smarty = get_smarty();
$smarty->assign("ID", $this->object_id);
+ $smarty->assign("Small", $this->small);
$object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
$Comment = $this->data;
- /* Remove comment tags */
- if(preg_match("/^#/",$Comment)){
- $Comment = preg_replace("/^#/","",$Comment);
- }elseif(preg_match("#\/\*#",$Comment)){
- $Comment = preg_replace("#^\/\*#","",$Comment);
- $Comment = preg_replace("#\*\/$#","",$Comment);
+ if($this->small){
+ $Comment = nl2br(preg_replace("/ /"," ",$Comment));
}
/* Create html object */
- $smarty = get_smarty();
$smarty->assign("Comment",$Comment);
$smarty->assign("ID",$this->object_id);
$object = $smarty->fetch(get_template_path("templates/element_comment.tpl",TRUE,dirname(__FILE__)));
- $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+ $str = preg_replace("/%%OBJECT_CONTENT%%/",addcslashes($object,"\\"),$object_container);
return($str);
}
}