Go to the documentation of this file.00001 <?php
00002
00014 class oxField
00015 {
00019 const T_TEXT = 1;
00020
00024 const T_RAW = 2;
00025
00051 public function __construct($value = null, $type = self::T_TEXT)
00052 {
00053
00054
00055 switch ($type) {
00056 case self::T_TEXT:
00057 default:
00058 $this->rawValue = $value;
00059 break;
00060 case self::T_RAW:
00061 $this->value = $value;
00062 break;
00063 }
00064 }
00065
00073 public function __isset( $sName )
00074 {
00075 switch ( $sName ) {
00076 case 'rawValue':
00077 return ($this->rawValue !== null);
00078 break;
00079 case 'value':
00080 return ($this->value !== null);
00081 break;
00082
00083 }
00084 return false;
00085 }
00086
00094 public function __get( $sName )
00095 {
00096 switch ( $sName ) {
00097 case 'rawValue':
00098 return $this->value;
00099 break;
00100 case 'value':
00101 if (is_string($this->rawValue)) {
00102 $this->value = getStr()->htmlspecialchars( $this->rawValue );
00103 } else {
00104
00105 $this->value = $this->rawValue;
00106 }
00107 if ($this->rawValue == $this->value) {
00108 unset($this->rawValue);
00109 }
00110 return $this->value;
00111 break;
00112 default:
00113 return null;
00114 break;
00115 }
00116 }
00117
00123 public function __toString()
00124 {
00125 return (string)$this->value;
00126 }
00127
00133 public function convertToFormattedDbDate()
00134 {
00135 $this->setValue(oxUtilsDate::getInstance()->formatDBDate( $this->rawValue ), self::T_RAW);
00136 }
00137
00143 public function convertToPseudoHtml()
00144 {
00145 $this->setValue( str_replace( "\r", '', nl2br( getStr()->htmlspecialchars( $this->rawValue ) ) ), self::T_RAW );
00146 }
00147
00156 protected function _initValue( $value = null, $type = self::T_TEXT)
00157 {
00158 switch ($type) {
00159 case self::T_TEXT:
00160 $this->rawValue = $value;
00161 break;
00162 case self::T_RAW:
00163 $this->value = $value;
00164 break;
00165 }
00166 }
00167
00176 public function setValue($value = null, $type = self::T_TEXT)
00177 {
00178 unset($this->rawValue);
00179 unset($this->value);
00180 $this->_initValue($value, $type);
00181 }
00182
00188 public function getRawValue()
00189 {
00190 if (null === $this->rawValue) {
00191 return $this->value;
00192 };
00193 return $this->rawValue;
00194 }
00195 }