|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of SwiftMailer. |
|
|
5 |
* (c) 2004-2009 Chris Corbyn |
|
|
6 |
* |
|
|
7 |
* For the full copyright and license information, please view the LICENSE |
|
|
8 |
* file that was distributed with this source code. |
|
|
9 |
*/ |
|
|
10 |
|
|
|
11 |
|
|
|
12 |
/** |
|
|
13 |
* A Simple MIME Header. |
|
|
14 |
* @package Swift |
|
|
15 |
* @subpackage Mime |
|
|
16 |
* @author Chris Corbyn |
|
|
17 |
*/ |
|
|
18 |
class Swift_Mime_Headers_UnstructuredHeader |
|
|
19 |
extends Swift_Mime_Headers_AbstractHeader |
|
|
20 |
{ |
|
|
21 |
|
|
|
22 |
/** |
|
|
23 |
* The value of this Header. |
|
|
24 |
* @var string |
|
|
25 |
* @access private |
|
|
26 |
*/ |
|
|
27 |
private $_value; |
|
|
28 |
|
|
|
29 |
/** |
|
|
30 |
* Creates a new SimpleHeader with $name. |
|
|
31 |
* @param string $name |
|
|
32 |
* @param Swift_Mime_HeaderEncoder $encoder |
|
|
33 |
* @param Swift_Mime_Grammar $grammar |
|
|
34 |
*/ |
|
|
35 |
public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Mime_Grammar $grammar) |
|
|
36 |
{ |
|
|
37 |
$this->setFieldName($name); |
|
|
38 |
$this->setEncoder($encoder); |
|
|
39 |
parent::__construct($grammar); |
|
|
40 |
} |
|
|
41 |
|
|
|
42 |
/** |
|
|
43 |
* Get the type of Header that this instance represents. |
|
|
44 |
* @return int |
|
|
45 |
* @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX |
|
|
46 |
* @see TYPE_DATE, TYPE_ID, TYPE_PATH |
|
|
47 |
*/ |
|
|
48 |
public function getFieldType() |
|
|
49 |
{ |
|
|
50 |
return self::TYPE_TEXT; |
|
|
51 |
} |
|
|
52 |
|
|
|
53 |
/** |
|
|
54 |
* Set the model for the field body. |
|
|
55 |
* This method takes a string for the field value. |
|
|
56 |
* @param string $model |
|
|
57 |
*/ |
|
|
58 |
public function setFieldBodyModel($model) |
|
|
59 |
{ |
|
|
60 |
$this->setValue($model); |
|
|
61 |
} |
|
|
62 |
|
|
|
63 |
/** |
|
|
64 |
* Get the model for the field body. |
|
|
65 |
* This method returns a string. |
|
|
66 |
* @return string |
|
|
67 |
*/ |
|
|
68 |
public function getFieldBodyModel() |
|
|
69 |
{ |
|
|
70 |
return $this->getValue(); |
|
|
71 |
} |
|
|
72 |
|
|
|
73 |
/** |
|
|
74 |
* Get the (unencoded) value of this header. |
|
|
75 |
* @return string |
|
|
76 |
*/ |
|
|
77 |
public function getValue() |
|
|
78 |
{ |
|
|
79 |
return $this->_value; |
|
|
80 |
} |
|
|
81 |
|
|
|
82 |
/** |
|
|
83 |
* Set the (unencoded) value of this header. |
|
|
84 |
* @param string $value |
|
|
85 |
*/ |
|
|
86 |
public function setValue($value) |
|
|
87 |
{ |
|
|
88 |
$this->clearCachedValueIf($this->_value != $value); |
|
|
89 |
$this->_value = $value; |
|
|
90 |
} |
|
|
91 |
|
|
|
92 |
/** |
|
|
93 |
* Get the value of this header prepared for rendering. |
|
|
94 |
* @return string |
|
|
95 |
*/ |
|
|
96 |
public function getFieldBody() |
|
|
97 |
{ |
|
|
98 |
if (!$this->getCachedValue()) |
|
|
99 |
{ |
|
|
100 |
$this->setCachedValue( |
|
|
101 |
str_replace('\\', '\\\\', $this->encodeWords( |
|
|
102 |
$this, $this->_value |
|
|
103 |
)) |
|
|
104 |
); |
|
|
105 |
} |
|
|
106 |
return $this->getCachedValue(); |
|
|
107 |
} |
|
|
108 |
|
|
|
109 |
} |