oxfield.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxField // extends oxSuperCfg
00007 {
00008     const T_TEXT = 1;
00009     const T_RAW  = 2;
00010 
00021     public function __construct($value = null, $type = self::T_TEXT)
00022     {
00023         // duplicate content here is needed for performance.
00024         // as this function is called *many* (a lot) times, it is crucial to be fast here!
00025         switch ($type) {
00026             case self::T_TEXT:
00027             default:
00028                 $this->rawValue = $value;
00029                 break;
00030             case self::T_RAW:
00031                 $this->value = $value;
00032                 break;
00033         }
00034     }
00035 
00043     public function __isset( $sName )
00044     {
00045         switch ( $sName ) {
00046             case 'rawValue':
00047                 return ($this->rawValue !== null);
00048             case 'value':
00049                 return ($this->value !== null);
00050                 //return true;
00051         }
00052         return false;
00053     }
00054 
00062     public function __get( $sName )
00063     {
00064         switch ( $sName ) {
00065             case 'rawValue':
00066                 return $this->value;
00067             case 'value':
00068                 if (is_string($this->rawValue)) {
00069                     $this->value = getStr()->htmlspecialchars( $this->rawValue );
00070                 } else {
00071                     // TODO: call htmlentities for each (recursive ???)
00072                     $this->value = $this->rawValue;
00073                 }
00074                 if ($this->rawValue == $this->value) {
00075                     unset($this->rawValue);
00076                 }
00077                 return $this->value;
00078             default:
00079                 return null;
00080         }
00081     }
00082 
00088     public function __toString()
00089     {
00090         return $this->value;
00091     }
00092 
00098     public function convertToFormattedDbDate()
00099     {
00100         $this->setValue(oxUtilsDate::getInstance()->formatDBDate( $this->rawValue ), self::T_RAW);
00101     }
00102 
00108     public function convertToPseudoHtml()
00109     {
00110         $this->setValue( str_replace( "\r", '', nl2br( getStr()->htmlspecialchars( $this->rawValue ) ) ), self::T_RAW );
00111     }
00112 
00121     protected function _initValue( $value = null, $type = self::T_TEXT)
00122     {
00123         switch ($type) {
00124             case self::T_TEXT:
00125                 $this->rawValue = $value;
00126                 break;
00127             case self::T_RAW:
00128                 $this->value = $value;
00129                 break;
00130         }
00131     }
00132 
00141     public function setValue($value = null, $type = self::T_TEXT)
00142     {
00143         unset($this->rawValue);
00144         unset($this->value);
00145         $this->_initValue($value, $type);
00146     }
00147 
00153     public function getRawValue()
00154     {
00155         if (null === $this->rawValue) {
00156             return $this->value;
00157         };
00158         return $this->rawValue;
00159     }
00160 }

Generated on Wed Apr 22 12:26:31 2009 for OXID eShop CE by  doxygen 1.5.5