コード例 #1
0
 /**
  * Constructor
  * @param mixed The input source.  Can be a file or a string
  * @param string The filename to use, optional
  * @param string The MIME type to use, optional
  * @param string The Content-ID to use, optional
  * @param string The encoding format to use, optional
  */
 function Swift_Message_EmbeddedFile($data = null, $name = null, $type = "application/octet-stream", $cid = null, $encoding = "base64")
 {
     $this->Swift_Message_Attachment($data, $name, $type, $encoding, "inline");
     if ($cid === null) {
         $cid = Swift_Message_Attachment::generateFileName("swift-" . uniqid(time()) . ".");
         $cid = urlencode($cid) . "@" . (!empty($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : "swift");
     }
     $this->setContentId($cid);
     if ($name === null && !is_a($data, "Swift_File")) {
         $this->setFileName($cid);
     }
     $this->headers->set("Content-Description", null);
 }
コード例 #2
0
 /**
  * The number of the file should go up by one each time.
  */
 public function testSequenceNumberIsAlwaysIncrementedInFileName()
 {
     $name = Swift_Message_Attachment::generateFileName();
     $id1 = (int) substr($name, -1);
     $name = Swift_Message_Attachment::generateFileName();
     $id2 = (int) substr($name, -1);
     $this->assertTrue($id2 > $id1);
     $name = Swift_Message_Attachment::generateFileName();
     $id3 = (int) substr($name, -1);
     $this->assertTrue($id3 > $id2);
 }
コード例 #3
0
 /**
  * Execute needed logic prior to building
  */
 function preBuild()
 {
     if ($this->getFileName() === null) {
         if (is_a($this->getData(), "Swift_File")) {
             $data =& $this->getData();
             $this->setFileName($data->getFileName());
         } else {
             $this->setFileName(Swift_Message_Attachment::generateFileName("file.att."));
         }
     }
 }