Changeset 950
- Timestamp:
- 07/24/08 07:22:45 (2 months ago)
- Files:
-
- branches/action_mailer/lib/AkActionMailer/AkMailBase.php (modified) (7 diffs)
- branches/action_mailer/lib/AkActionMailer/AkMailComposer.php (modified) (1 diff)
- branches/action_mailer/lib/AkActionMailer/AkMailParser.php (modified) (1 diff)
- branches/action_mailer/lib/AkActionMailer/AkMailPart.php (modified) (2 diffs)
- branches/action_mailer/test/unit/lib/AkActionMailer.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/action_mailer/lib/AkActionMailer/AkMailBase.php
r946 r950 13 13 var $parts = array(); 14 14 var $attachments = array(); 15 16 var $attach_html_images = true; 15 17 16 18 function AkMailBase() … … 50 52 $content_type = @$this->content_type; 51 53 $this->body = stristr($content_type,'text/') ? str_replace(array("\r\n","\r"),"\n", $body) : $body; 52 if($ content_type == 'text/html'){54 if($this->attach_html_images && $content_type == 'text/html'){ 53 55 $Parser = new AkMailParser(); 54 56 $Parser->extractImagesIntoInlineParts($this); … … 135 137 { 136 138 return empty($this->content_type) ? ($this->isMultipart()?'multipart/alternative':null) : $this->content_type.$this->getContenttypeAttributes(); 139 } 140 141 function hasContentType() 142 { 143 return !empty($this->content_type); 137 144 } 138 145 … … 291 298 } 292 299 293 function getRawHeaders( )300 function getRawHeaders($options = array()) 294 301 { 295 302 if(empty($this->raw_headers)){ 303 296 304 $this->headers = $this->getHeaders(true); 297 305 if($this->isPart()){ 298 $this->prepareHeadersForRendering(); 306 $this->prepareHeadersForRendering(array( 307 'skip' => (array)@$options['skip'], 308 'only' => (array)@$options['only'] 309 )); 299 310 } 300 311 unset($this->headers['Charset']); … … 309 320 $this->loadHeaders(); 310 321 $this->_addHeaderAttributes(); 322 311 323 } 312 324 return $this->headers; … … 515 527 unset($this->$k); 516 528 } 529 517 530 $this->_multipart_message = true; 518 531 $this->setPart($options, 'preppend'); … … 587 600 $this->setPart($options); 588 601 } 589 602 590 603 function setAttachments($attachments = array()) 591 604 { branches/action_mailer/lib/AkActionMailer/AkMailComposer.php
r946 r950 169 169 $raw_body = ''; 170 170 $this->openMultipartBlock(); 171 171 if(!$Message->hasContentType()){ 172 $Message->setContentType('multipart/related'); 173 } 172 174 $Message->content_type_attributes['boundary'] = $this->getBoundary(); 173 175 $Message->_skip_adding_date_to_headers = !$Message->isMainMessage(); branches/action_mailer/lib/AkActionMailer/AkMailParser.php
r915 r950 334 334 if($modified_html != $html){ 335 335 $html = $modified_html; 336 $Mail->_moveBodyToInlinePart( false);336 $Mail->_moveBodyToInlinePart(); 337 337 } 338 338 } branches/action_mailer/lib/AkActionMailer/AkMailPart.php
r946 r950 4 4 { 5 5 6 7 function prepareHeadersForRendering( )6 7 function prepareHeadersForRendering($options = array()) 8 8 { 9 $this->_removeUnnecesaryHeaders(); 9 if($this->isMultipart()){ 10 $this->filterHeaders(array('only' => array('Content-Type'))); 11 }else{ 12 $this->filterHeaders(); 13 } 10 14 } 11 15 12 function _removeUnnecesaryHeaders()16 function filterHeaders($options = array()) 13 17 { 14 $ headers = $this->getHeaders();18 $default_options = array( 15 19 16 $this->headers = array(); 17 foreach (array( 20 'only' => empty($options['include']) ? array( 18 21 'Content-Type', 19 22 'Content-Transfer-Encoding', … … 21 24 'Content-Disposition', 22 25 'Content-Description', 23 ) as $allowed_header){ 24 if(isset($headers[$allowed_header])){ 25 $this->headers[$allowed_header] = $headers[$allowed_header]; 26 27 ) : array() 28 ); 29 30 $options = array_merge($default_options, $options); 31 32 if(!empty($options['only'])){ 33 $headers = $this->getHeaders(); 34 $this->headers = array(); 35 foreach ($options['only'] as $allowed_header){ 36 if(isset($headers[$allowed_header])){ 37 $this->headers[$allowed_header] = $headers[$allowed_header]; 38 } 39 } 40 }elseif (!empty($options['except'])){ 41 $this->headers = array(); 42 foreach ($options['except'] as $skip_header){ 43 unset($this->headers[$skip_header]); 26 44 } 27 45 } branches/action_mailer/test/unit/lib/AkActionMailer.php
r946 r950 183 183 184 184 185 /** /185 /**/ 186 186 function test_nested_parts() 187 187 { … … 738 738 739 739 740 function _test_should_encode_alternative_message_from_templates()740 function test_should_encode_alternative_message_from_templates() 741 741 { 742 742 $TestMailer =& new TestMailer(); … … 744 744 $rendered_message = $TestMailer->getRawMessage(); 745 745 746 746 747 $this->assertPattern( '/Content-Type: multipart\/alternative;charset=UTF-8;boundary=[a-f0-9]{32}\r\n'. 747 748 'Mime-Version: 1.0\r\n'. … … 749 750 $this->assertPattern('/To:/', $rendered_message); 750 751 $this->assertPattern('/Date:/', $rendered_message); 751 $this->assertPattern('/--[a-f0-9]{32}\r\nContent-Type: text\/plain;charset=UTF-8\r\nContent- Disposition: inline/', $rendered_message);752 $this->assertPattern('/--[a-f0-9]{32}\r\nContent-Type: text\/html;charset=UTF-8\r\nContent- Disposition: inline/', $rendered_message);752 $this->assertPattern('/--[a-f0-9]{32}\r\nContent-Type: text\/plain;charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\nContent-Disposition: inline/', $rendered_message); 753 $this->assertPattern('/--[a-f0-9]{32}\r\nContent-Type: text\/html;charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\nContent-Disposition: inline/', $rendered_message); 753 754 $this->assertPattern('/--[a-f0-9]{32}--/', $rendered_message); 754 755 } 755 */756 /**/ 756 757 function test_should_encode_alternative_message_from_templates_with_embeded_images() 757 758 { … … 759 760 $Message = $TestMailer->create('alternative_message_from_templates', $this->recipient, true); 760 761 761 $TestMailer->delivery_method = 'smtp';762 //$TestMailer->delivery_method = 'smtp'; 762 763 763 764 $TestMailer->deliver($Message); … … 765 766 $rendered_message = $TestMailer->getRawMessage(); 766 767 767 echo $rendered_message;768 //echo $rendered_message; 768 769 return ; 769 770 … … 784 785 } 785 786 786 //Ak::test('Tests_for_Mailers');787 Ak::test('Tests_for_Mailers'); 787 788 Ak::test('Tests_for_AkActionMailer'); 788 789
