TYPO3 API  SVNRelease
UnstructuredHeader.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * This file is part of SwiftMailer.
00005  * (c) 2004-2009 Chris Corbyn
00006  *
00007  * For the full copyright and license information, please view the LICENSE
00008  * file that was distributed with this source code.
00009  */
00010 
00011 //@require 'Swift/Mime/Headers/AbstractHeader.php';
00012 //@require 'Swift/Mime/HeaderEncoder.php';
00013 
00014 /**
00015  * A Simple MIME Header.
00016  * @package Swift
00017  * @subpackage Mime
00018  * @author Chris Corbyn
00019  */
00020 class Swift_Mime_Headers_UnstructuredHeader
00021   extends Swift_Mime_Headers_AbstractHeader
00022 {
00023 
00024   /**
00025    * The value of this Header.
00026    * @var string
00027    * @access private
00028    */
00029   private $_value;
00030 
00031   /**
00032    * Creates a new SimpleHeader with $name.
00033    * @param string $name
00034    * @param Swift_Mime_HeaderEncoder $encoder
00035    */
00036   public function __construct($name, Swift_Mime_HeaderEncoder $encoder)
00037   {
00038     $this->setFieldName($name);
00039     $this->setEncoder($encoder);
00040   }
00041   /**
00042    * Get the type of Header that this instance represents.
00043    * @return int
00044    * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
00045    * @see TYPE_DATE, TYPE_ID, TYPE_PATH
00046    */
00047   public function getFieldType()
00048   {
00049     return self::TYPE_TEXT;
00050   }
00051 
00052   /**
00053    * Set the model for the field body.
00054    * This method takes a string for the field value.
00055    * @param string $model
00056    */
00057   public function setFieldBodyModel($model)
00058   {
00059     $this->setValue($model);
00060   }
00061 
00062   /**
00063    * Get the model for the field body.
00064    * This method returns a string.
00065    * @return string
00066    */
00067   public function getFieldBodyModel()
00068   {
00069     return $this->getValue();
00070   }
00071 
00072   /**
00073    * Get the (unencoded) value of this header.
00074    * @return string
00075    */
00076   public function getValue()
00077   {
00078     return $this->_value;
00079   }
00080 
00081   /**
00082    * Set the (unencoded) value of this header.
00083    * @param string $value
00084    */
00085   public function setValue($value)
00086   {
00087     $this->clearCachedValueIf($this->_value != $value);
00088     $this->_value = $value;
00089   }
00090 
00091   /**
00092    * Get the value of this header prepared for rendering.
00093    * @return string
00094    */
00095   public function getFieldBody()
00096   {
00097     if (!$this->getCachedValue())
00098     {
00099       $this->setCachedValue(
00100         str_replace('\\', '\\\\', $this->encodeWords(
00101           $this, $this->_value, -1, $this->getCharset(), $this->getEncoder()
00102           ))
00103         );
00104     }
00105     return $this->getCachedValue();
00106   }
00107 
00108 }