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                 break;
00049             case 'value':
00050                 return ($this->value !== null);
00051                 break;
00052                 //return true;
00053         }
00054         return false;
00055     }
00056 
00064     public function __get( $sName )
00065     {
00066         switch ( $sName ) {
00067             case 'rawValue':
00068                 return $this->value;
00069                 break;
00070             case 'value':
00071                 if (is_string($this->rawValue)) {
00072                     $this->value = getStr()->htmlspecialchars( $this->rawValue );
00073                 } else {
00074                     // TODO: call htmlentities for each (recursive ???)
00075                     $this->value = $this->rawValue;
00076                 }
00077                 if ($this->rawValue == $this->value) {
00078                     unset($this->rawValue);
00079                 }
00080                 return $this->value;
00081                 break;
00082             default:
00083                 return null;
00084                 break;
00085         }
00086     }
00087 
00093     public function __toString()
00094     {
00095         return $this->value;
00096     }
00097 
00103     public function convertToFormattedDbDate()
00104     {
00105         $this->setValue(oxUtilsDate::getInstance()->formatDBDate( $this->rawValue ), self::T_RAW);
00106     }
00107 
00113     public function convertToPseudoHtml()
00114     {
00115         $this->setValue( str_replace( "\r", '', nl2br( getStr()->htmlspecialchars( $this->rawValue ) ) ), self::T_RAW );
00116     }
00117 
00126     protected function _initValue( $value = null, $type = self::T_TEXT)
00127     {
00128         switch ($type) {
00129             case self::T_TEXT:
00130                 $this->rawValue = $value;
00131                 break;
00132             case self::T_RAW:
00133                 $this->value = $value;
00134                 break;
00135         }
00136     }
00137 
00146     public function setValue($value = null, $type = self::T_TEXT)
00147     {
00148         unset($this->rawValue);
00149         unset($this->value);
00150         $this->_initValue($value, $type);
00151     }
00152 
00158     public function getRawValue()
00159     {
00160         if (null === $this->rawValue) {
00161             return $this->value;
00162         };
00163         return $this->rawValue;
00164     }
00165 }

Generated on Tue Aug 4 09:09:57 2009 for OXID eShop CE by  doxygen 1.5.5