/** * Register additional marshaller implementations. * * @param Io_Mimetype $mimeType_ * @param string $typeMarshaller_ * * @throws Exception_IllegalArgument */ public static function registerForMimetype(Io_Mimetype $mimeType_, $typeMarshaller_) { if (!$typeMarshaller_ instanceof self) { throw new Exception_IllegalArgument('object/marshaller', 'Passed type must extend from ' . __CLASS__ . '.'); } self::$m_marshallerTypes[$mimeType_->name()] = $typeMarshaller_; }
/** * @param \Components\Io_Mimetype $mimeType_ * * @return string */ public function to(Io_Mimetype $mimeType_) { if (isset(self::$m_mapMimetypeSerializers[$mimeType_->name()])) { return $this->{self::$m_mapMimetypeSerializers[$mimeType_->name()]}(); } return $this->__toString(); }
public function __construct(Io_Charset $charset_) { parent::__construct(null, md5(uniqid()), Io_Mimetype::MULTIPART_MIXED($charset_)); $this->date = new \DateTime(); $this->version = self::MIME_VERSION; $this->messageId = md5(uniqid()); }
/** * @return \Components\Io_Mimetype */ public function getMimetype() { if (null === $this->m_mimeType) { if (!($this->m_mimeType = Io_Mimetype::forFileName($this->m_uri->getPath()))) { $this->m_mimeType = Io_Mimetype::TEXT_HTML(Io_Charset::UTF_8()); } } return $this->m_mimeType; }
/** * @param string $filename_ * @param string $content_ * @param \Components\Io_Mimetype $mimeType_ * * @throws \Components\Runtime_Exception * * @return \Components\Mail_Part_Image */ public static function forFileContents($filename_, $content_, Io_Mimetype $mimeType_ = null) { if (null === $mimeType_) { $mimeType_ = Io_Mimetype::forFileName($filename_); } if (null === $mimeType_) { throw new Io_Exception('mail/part/file', sprintf('Unable to resolve mimetype for given filename [filename: %1$s].', $filename_)); } return new static($filename_, $content_, $mimeType_); }
/** * @param string $filename_ * * @return \Components\Io_Mimetype */ public static function mimeType($filename_) { return Io_Mimetype::forFilePath($filename_); }
public function __construct($content_, Io_Charset $charset_) { parent::__construct($content_, md5($content_), Io_Mimetype::TEXT_HTML($charset_)); $this->encoding = Mail_Part::CONTENT_ENCODING_BASE64; }
/** * @see \Components\Io_File::getMimetype() \Components\Io_File::getMimetype() */ public function getMimetype() { return Io_Mimetype::APPLICATION_VND_APPLE_PKPASS(); }
/** * @return boolean */ public function isImage() { if (@is_file($this->m_path)) { return Io_Mimetype::forFilePath($this->m_path)->isImage(); } return Io_Mimetype::forFileName($this->m_path); }
private function isValidMimetype(Io_Mimetype $mimeType_) { if (in_array($mimeType_->name(), $this->mimeTypesForbidden)) { return false; } return in_array($mimeType_->name(), $this->mimeTypesAllowed); }
/** * @return \Components\Mail_Part */ public static function related() { return new self(null, md5(uniqid()), Io_Mimetype::MULTIPART_RELATED()); }
/** * @param string $method_ * @param string $action_ * @param \Components\Io_Mimetype $encType_ * @param string $acceptCharset_ */ public function form($method_ = 'POST', $action_ = null, Io_Mimetype $encType_ = null, $acceptCharset_ = null) { if (null === $acceptCharset_) { $acceptCharset_ = \env\charset(); } if (null === $encType_) { $encType_ = Io_Mimetype::APPLICATION_FORM_URLENCODED(); } $this->m_formProperties = ['method' => $method_, 'accept-charset' => $acceptCharset_, 'enctype' => $encType_->name()]; if (null !== $action_) { $this->m_formProperties['action'] = $action_; } $this->m_form = $this; }
/** * @param string $json_ * @param string $type_ * * @return mixed */ public static function forJson($json_, $type_) { return Object_Marshaller::forMimetype(Io_Mimetype::APPLICATION_JSON())->unmarshal($json_, $type_); }
/** * @return \Components\Io_Mimetype */ public function getMimetype() { if (null === $this->m_mimeType) { if ($this->exists()) { return $this->m_mimeType = Io_Mimetype::forFilePath($this->m_pathAsString); } return $this->m_mimeType = Io_Mimetype::forFileExtension($this->getExtension()); } return $this->m_mimeType; }
public function __construct($content_, Io_Charset $charset_) { parent::__construct($content_, md5($content_), Io_Mimetype::TEXT_PLAIN($charset_)); $this->encoding = Mail::CONTENT_ENCODING_QUOTED_PRINTABLE; }
/** * @param \Components\Uri $uri_ */ public function dispatch(Uri $uri_, $method_ = null) { ob_start(); try { $this->dispatchImpl($uri_, $method_); } catch (\Exception $e) { if (Runtime::isCli()) { throw $e; } Runtime::addException($e); if ($e instanceof Http_Exception) { $e->sendHeader(); } } // FIXME Why?? if (Runtime::isCli()) { echo ob_get_clean(); } else { ob_flush(); /** * Do not corrupt output for other mimetypes - assuming: * - Exceptions are logged * - Debug output & exceptions are sent via headers * * Visualization happens via client side / logging or * custom implementations of http/scriptlet#dispatch. */ if (false === Io_Mimetype::TEXT_HTML()->equals($this->getResponse()->getMimetype())) { Debug::clear(); Runtime::clearExceptions(); } if (session_id()) { session_write_close(); } } }
/** * @see \Components\Io_Image_Engine::save() \Components\Io_Image_Engine::save() * * @return \Components\Io_Image_Engine_Gd */ public function save($path_, Io_Mimetype $type_ = null) { if (null === $type_) { $type_ = Io_Mimetype::forFileExtension(Io::fileExtension($path_)); } if (null === $type_) { $type_ = Io_Mimetype::IMAGE_PNG(); } $typeName = $type_->name(); if (false === isset(self::$m_saveHandler[$typeName])) { throw new Exception_NotSupported('io/image/engine/gd', sprintf('Saving to image of requested type is not supported [%s].', $type_)); } $directory = dirname($path_); if (false === is_dir($directory)) { Io::directoryCreate($directory); } $saveHandler = self::$m_saveHandler[$typeName]; $saveHandler($this->m_resource, $path_); return $this; }