mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 23:47:03 +03:00
v1.2.12.435
This commit is contained in:
parent
513936e5f7
commit
93e620e3de
399 changed files with 765 additions and 687 deletions
182
rainloop/v/1.2.12.435/app/libraries/MailSo/Mail/Attachment.php
Normal file
182
rainloop/v/1.2.12.435/app/libraries/MailSo/Mail/Attachment.php
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Mail;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Mail
|
||||
*/
|
||||
class Attachment
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sFolder;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iUid;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Imap\BodyStructure
|
||||
*/
|
||||
private $oBodyStructure;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\Attachment
|
||||
*/
|
||||
public function Clear()
|
||||
{
|
||||
$this->sFolder = '';
|
||||
$this->iUid = 0;
|
||||
$this->oBodyStructure = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Folder()
|
||||
{
|
||||
return $this->sFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function Uid()
|
||||
{
|
||||
return $this->iUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function MimeIndex()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->PartID() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bCalculateOnEmpty = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function FileName($bCalculateOnEmpty = false)
|
||||
{
|
||||
$sFileName = '';
|
||||
if ($this->oBodyStructure)
|
||||
{
|
||||
$sFileName = $this->oBodyStructure->FileName();
|
||||
if ($bCalculateOnEmpty && 0 === \strlen(trim($sFileName)))
|
||||
{
|
||||
$sMimeType = \strtolower(\trim($this->MimeType()));
|
||||
if ('message/rfc822' === $sMimeType)
|
||||
{
|
||||
$sFileName = 'message'.$this->MimeIndex().'.eml';
|
||||
}
|
||||
else if ('text/calendar' === $sMimeType)
|
||||
{
|
||||
$sFileName = 'calendar'.$this->MimeIndex().'.ics';
|
||||
}
|
||||
else if (0 < \strlen($sMimeType))
|
||||
{
|
||||
$sFileName = \str_replace('/', $this->MimeIndex().'.', $sMimeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function MimeType()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->ContentType() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ContentTransferEncoding()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->MailEncodingName() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function EncodedSize()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->Size() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function EstimatedSize()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->EstimatedSize() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Cid()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->ContentID() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsInline()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->IsInline() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\Attachment
|
||||
*/
|
||||
public static function NewInstance()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFolder
|
||||
* @param int $iUid
|
||||
* @param \MailSo\Imap\BodyStructure $oBodyStructure
|
||||
* @return \MailSo\Mail\Attachment
|
||||
*/
|
||||
public static function NewBodyStructureInstance($sFolder, $iUid, $oBodyStructure)
|
||||
{
|
||||
return self::NewInstance()->InitByBodyStructure($sFolder, $iUid, $oBodyStructure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFolder
|
||||
* @param int $iUid
|
||||
* @param \MailSo\Imap\BodyStructure $oBodyStructure
|
||||
* @return \MailSo\Mail\Attachment
|
||||
*/
|
||||
public function InitByBodyStructure($sFolder, $iUid, $oBodyStructure)
|
||||
{
|
||||
$this->sFolder = $sFolder;
|
||||
$this->iUid = $iUid;
|
||||
$this->oBodyStructure = $oBodyStructure;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue