/** * Smarty modifier * ------------------------------------------------------------- * Name: smarty_modifier_oxformdate<br> * Purpose: Conterts date/timestamp/datetime type value to user defined format * Example: {$object|oxformdate:"foo"} * ------------------------------------------------------------- * * @param object $oConvObject oxField object * @param string $sFieldType additional type if field (this may help to force formatting) * @param bool $blPassedValue bool if true, will simulate object as sometimes we need to apply formatting to some regulat values * * @return string */ function smarty_modifier_oxformdate($oConvObject, $sFieldType = null, $blPassedValue = false) { // creating fake bject if ($blPassedValue || is_string($oConvObject)) { $sValue = $oConvObject; $oConvObject = new oxField(); $oConvObject->fldmax_length = "0"; $oConvObject->fldtype = $sFieldType; $oConvObject->setValue($sValue); } $myConfig = oxConfig::getInstance(); // if such format applies to this type of field - sets formatted value to passed object if (!$myConfig->getConfigParam('blSkipFormatConversion')) { if ($oConvObject->fldtype == "datetime" || $sFieldType == "datetime") { oxDb::getInstance()->convertDBDateTime($oConvObject); } elseif ($oConvObject->fldtype == "timestamp" || $sFieldType == "timestamp") { oxDb::getInstance()->convertDBTimestamp($oConvObject); } elseif ($oConvObject->fldtype == "date" || $sFieldType == "date") { oxDb::getInstance()->convertDBDate($oConvObject); } } return $oConvObject->value; }
/** * Get article long description * * @return object $oField field object */ public function getLongDescription() { if ($this->_oLongDesc === null) { // initializing $this->_oLongDesc = new oxField(); // choosing which to get.. $sOxid = $this->getId(); $sViewName = getViewName('oxartextends', $this->getLanguage()); $oDb = oxDb::getDb(); $sDbValue = $oDb->getOne("select oxlongdesc from {$sViewName} where oxid = " . $oDb->quote($sOxid)); if ($sDbValue != false) { $this->_oLongDesc->setValue($sDbValue, oxField::T_RAW); } elseif ($this->oxarticles__oxparentid->value) { if (!$this->isAdmin() || $this->_blLoadParentData) { $oParent = $this->getParentArticle(); if ($oParent) { $this->_oLongDesc->setValue($oParent->getLongDescription()->getRawValue(), oxField::T_RAW); } } } } return $this->_oLongDesc; }
/** * Converter for datetime field search. If not full time will be searched. * * @param string $sFullDate searched date * * @return string */ protected function _convertTime($sFullDate) { $sDate = substr($sFullDate, 0, 10); $oConvObject = new oxField(); $oConvObject->setValue($sDate); oxDb::getInstance()->convertDBDate($oConvObject, true); $oStr = getStr(); // looking for time field $sTime = substr($sFullDate, 11); if ($oStr->preg_match("/([0-9]{2}):([0-9]{2}) ([AP]{1}[M]{1})\$/", $sTime, $aTimeMatches)) { if ($aTimeMatches[3] == "PM") { $iIntVal = (int) $aTimeMatches[1]; if ($iIntVal < 13) { $sTime = $iIntVal + 12 . ":" . $aTimeMatches[2]; } } else { $sTime = $aTimeMatches[1] . ":" . $aTimeMatches[2]; } } elseif ($oStr->preg_match("/([0-9]{2}) ([AP]{1}[M]{1})\$/", $sTime, $aTimeMatches)) { if ($aTimeMatches[2] == "PM") { $iIntVal = (int) $aTimeMatches[1]; if ($iIntVal < 13) { $sTime = $iIntVal + 12; } } else { $sTime = $aTimeMatches[1]; } } else { $sTime = str_replace(".", ":", $sTime); } return $oConvObject->value . " " . $sTime; }
public function testGetRawValueIfSetAsRaw() { $oField = new oxField(); $oField->setValue("ssss<\n>", oxField::T_RAW); $this->assertEquals("ssss<\n>", $oField->value); $this->assertEquals("ssss<\n>", $oField->getRawValue()); }