1: <?php
2: /**
3: * A Comment.
4: *
5: * See the enclosed file LICENSE for license information (ASL). If you
6: * did not receive this file, see http://www.horde.org/licenses/apache.
7: *
8: * @author Mike Cochrane <mike@graftonhall.co.nz>
9: * @package Ingo
10: * @todo This and Sieve_If should really extends a Sieve_Block eventually.
11: */
12: class Ingo_Script_Sieve_Comment
13: {
14: /**
15: */
16: protected $_comment;
17:
18: /**
19: * Constructor.
20: *
21: * @param string $comment The comment text.
22: */
23: public function __construct($comment)
24: {
25: $this->_comment = $comment;
26: }
27:
28: /**
29: * Returns a script snippet representing this rule and any sub-rules.
30: *
31: * @return string A Sieve script snippet.
32: */
33: public function toCode()
34: {
35: $code = '';
36: $lines = preg_split('(\r\n|\n|\r)', $this->_comment);
37: foreach ($lines as $line) {
38: $line = trim($line);
39: if (strlen($line)) {
40: $code .= (empty($code) ? '' : "\n") . '# ' . $line;
41: }
42: }
43: return $code;
44: }
45:
46: /**
47: * Checks if the rule parameters are valid.
48: *
49: * @return boolean|string True if this rule is valid, an error message
50: * otherwise.
51: */
52: public function check()
53: {
54: return true;
55: }
56:
57: /**
58: * Returns a list of sieve extensions required for this rule and any
59: * sub-rules.
60: *
61: * @return array A Sieve extension list.
62: */
63: public function requires()
64: {
65: return array();
66: }
67:
68: }
69: