public function testFormatCanBeSetToFlowed()
 {
     $part = new Swift_Message_Part("Just some random message");
     $part->setEncoding("8bit");
     $part->setCharset("iso-8859-1");
     $part->setFlowed(true);
     $structure = $part->build()->readFull();
     $this->assertPattern("~Content-Type: text/plain;\\s* charset=iso-8859-1;\\s* format=flowed\r\nContent-Transfer-Encoding: 8bit\r\n\r\nJust some random message~", $structure);
     $part->setFlowed(false);
     $structure = $part->build()->readFull();
     $this->assertPattern("~Content-Type: text/plain;\\s* charset=iso-8859-1\r\nContent-Transfer-Encoding: 8bit\r\n\r\nJust some random message~", $structure);
 }
 /**
  * Move a branch of the tree, containing all it's MIME parts onto another branch
  * @param string The content type on the branch itself
  * @param string The content type which may exist in the branch's parent
  * @param array The array containing all the nodes presently
  * @param string The location of the branch now
  * @param string The location of the branch after moving
  * @param string The key to identify the branch by in it's new location
  */
 protected function moveBranchIn($type, $nested_type, $from, $old_branch, $new_branch, $tag)
 {
     $new = new Swift_Message_Part();
     $new->setContentType($type);
     $this->getReference("parent", $new_branch)->addChild($new, $tag, -1);
     switch ($new_branch) {
         case "related":
             $this->setReference("related", $tag, $new);
             //relatedRefs[$tag] = $new;
             break;
         case "mixed":
             $this->setReference("mixed", $tag, $new);
             //mixedRefs[$tag] = $new;
             break;
     }
     foreach ($from as $id => $ref) {
         if (!$ref) {
             $ref = $this;
         }
         $sign = strtolower($ref->getContentType()) == "text/plain" || strtolower($ref->getContentType()) == $nested_type ? -1 : 1;
         switch ($new_branch) {
             case "related":
                 $this->getReference("related", $tag)->addChild($ref, $id, $sign);
                 break;
             case "mixed":
                 $this->getReference("mixed", $tag)->addChild($ref, $id, $sign);
                 break;
         }
         if ($this->getReference("parent", $old_branch)->hasChild($id)) {
             $this->getReference("parent", $old_branch)->removeChild($id);
         }
     }
     $this->setReference("parent", $old_branch, $new);
     //parentRefs[$old_branch] = $new;
 }
Example #3
0
 /**
  * Move a branch of the tree, containing all it's MIME parts onto another branch
  * @param string The content type on the branch itself
  * @param string The content type which may exist in the branch's parent
  * @param array The array containing all the nodes presently
  * @param string The location of the branch now
  * @param string The location of the branch after moving
  * @param string The key to identify the branch by in it's new location
  */
 protected function moveBranchIn($type, $nested_type, $from, $old_branch, $new_branch, $tag)
 {
     $new = new Swift_Message_Part();
     $new->setContentType($type);
     $this->getReference("parent", $new_branch)->addChild($new, $tag, -1);
     switch ($new_branch) {
         case "related":
             $this->setReference("related", $tag, $new);
             //relatedRefs[$tag] = $new;
             break;
         case "mixed":
             $this->setReference("mixed", $tag, $new);
             //mixedRefs[$tag] = $new;
             break;
     }
     foreach ($from as $id => $ref) {
         if (!$ref) {
             $ref = $this;
         }
         $sign = strtolower($ref->getContentType()) == "text/plain" || strtolower($ref->getContentType()) == $nested_type ? -1 : 1;
         switch ($new_branch) {
             case "related":
                 $this->getReference("related", $tag)->addChild($ref, $id, $sign);
                 break;
             case "mixed":
                 $this->getReference("mixed", $tag)->addChild($ref, $id, $sign);
                 break;
         }
         // Added by PrestaShop http://www.prestashop.com/forums/topic/178615-swift-message-mimeexception-probleme-de-commande-fantome-et-mot-de-passe-oublie/
         if ($this->getReference("parent", $old_branch)->hasChild($id)) {
             $this->getReference("parent", $old_branch)->removeChild($id);
         }
     }
     $this->setReference("parent", $old_branch, $new);
     //parentRefs[$old_branch] = $new;
 }