equal
deleted
inserted
replaced
12 * obtain it through the world-wide-web, please send an email |
12 * obtain it through the world-wide-web, please send an email |
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Mail |
16 * @package Zend_Mail |
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @version $Id: Part.php 20096 2010-01-06 02:05:09Z bkarwin $ |
19 * @version $Id: Part.php 24759 2012-05-05 02:58:55Z adamlundrigan $ |
20 */ |
20 */ |
21 |
21 |
22 |
22 |
23 /** |
23 /** |
24 * @see Zend_Mime_Decode |
24 * @see Zend_Mime_Decode |
32 |
32 |
33 |
33 |
34 /** |
34 /** |
35 * @category Zend |
35 * @category Zend |
36 * @package Zend_Mail |
36 * @package Zend_Mail |
37 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
37 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
38 * @license http://framework.zend.com/license/new-bsd New BSD License |
38 * @license http://framework.zend.com/license/new-bsd New BSD License |
39 */ |
39 */ |
40 class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface |
40 class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface |
41 { |
41 { |
42 /** |
42 /** |
84 /** |
84 /** |
85 * message number for mail handler |
85 * message number for mail handler |
86 * @var int |
86 * @var int |
87 */ |
87 */ |
88 protected $_messageNum = 0; |
88 protected $_messageNum = 0; |
|
89 |
|
90 /** |
|
91 * Class to use when creating message parts |
|
92 * @var string |
|
93 */ |
|
94 protected $_partClass; |
89 |
95 |
90 /** |
96 /** |
91 * Public constructor |
97 * Public constructor |
92 * |
98 * |
93 * Zend_Mail_Part supports different sources for content. The possible params are: |
99 * Zend_Mail_Part supports different sources for content. The possible params are: |
120 } |
126 } |
121 |
127 |
122 $this->_mail = $params['handler']; |
128 $this->_mail = $params['handler']; |
123 $this->_messageNum = $params['id']; |
129 $this->_messageNum = $params['id']; |
124 } |
130 } |
|
131 |
|
132 if (isset($params['partclass'])) { |
|
133 $this->setPartClass($params['partclass']); |
|
134 } |
125 |
135 |
126 if (isset($params['raw'])) { |
136 if (isset($params['raw'])) { |
127 Zend_Mime_Decode::splitMessage($params['raw'], $this->_headers, $this->_content); |
137 Zend_Mime_Decode::splitMessage($params['raw'], $this->_headers, $this->_content); |
128 } else if (isset($params['headers'])) { |
138 } else if (isset($params['headers'])) { |
129 if (is_array($params['headers'])) { |
139 if (is_array($params['headers'])) { |
138 if (isset($params['content'])) { |
148 if (isset($params['content'])) { |
139 $this->_content = $params['content']; |
149 $this->_content = $params['content']; |
140 } |
150 } |
141 } |
151 } |
142 } |
152 } |
|
153 |
|
154 /** |
|
155 * Set name pf class used to encapsulate message parts |
|
156 * @param string $class |
|
157 * @return Zend_Mail_Part |
|
158 */ |
|
159 public function setPartClass($class) |
|
160 { |
|
161 if ( !class_exists($class) ) { |
|
162 /** |
|
163 * @see Zend_Mail_Exception |
|
164 */ |
|
165 require_once 'Zend/Mail/Exception.php'; |
|
166 throw new Zend_Mail_Exception("Class '{$class}' does not exist"); |
|
167 } |
|
168 if ( !is_subclass_of($class, 'Zend_Mail_Part_Interface') ) { |
|
169 /** |
|
170 * @see Zend_Mail_Exception |
|
171 */ |
|
172 require_once 'Zend/Mail/Exception.php'; |
|
173 throw new Zend_Mail_Exception("Class '{$class}' must implement Zend_Mail_Part_Interface"); |
|
174 } |
|
175 |
|
176 $this->_partClass = $class; |
|
177 return $this; |
|
178 } |
|
179 |
|
180 /** |
|
181 * Retrieve the class name used to encapsulate message parts |
|
182 * @return string |
|
183 */ |
|
184 public function getPartClass() |
|
185 { |
|
186 if ( !$this->_partClass ) { |
|
187 $this->_partClass = __CLASS__; |
|
188 } |
|
189 return $this->_partClass; |
|
190 } |
143 |
191 |
144 /** |
192 /** |
145 * Check if part is a multipart message |
193 * Check if part is a multipart message |
146 * |
194 * |
147 * @return bool if part is multipart |
195 * @return bool if part is multipart |
221 } |
269 } |
222 $parts = Zend_Mime_Decode::splitMessageStruct($this->_content, $boundary); |
270 $parts = Zend_Mime_Decode::splitMessageStruct($this->_content, $boundary); |
223 if ($parts === null) { |
271 if ($parts === null) { |
224 return; |
272 return; |
225 } |
273 } |
|
274 $partClass = $this->getPartClass(); |
226 $counter = 1; |
275 $counter = 1; |
227 foreach ($parts as $part) { |
276 foreach ($parts as $part) { |
228 $this->_parts[$counter++] = new self(array('headers' => $part['header'], 'content' => $part['body'])); |
277 $this->_parts[$counter++] = new $partClass(array('headers' => $part['header'], 'content' => $part['body'])); |
229 } |
278 } |
230 } |
279 } |
231 |
280 |
232 /** |
281 /** |
233 * Get part of multipart message |
282 * Get part of multipart message |