• Модуль: support
  • Путь к файлу: ~/bitrix/modules/support/classes/general/tablefields.php
  • Класс: CSupportTableFields
  • Вызов: CSupportTableFields::Convert
static function Convert($type, $value, $op)
{
	$maxStrLen = (array_key_exists("MAX_STR_LEN", $op) ? $op["MAX_STR_LEN"] : 0);
	$list = (array_key_exists("LIST", $op) ? $op["LIST"] : null);
	$defVal = (array_key_exists("DEF_VAL", $op) ? $op["DEF_VAL"] : null);
	$res = null;
	switch($type)
	{
		case self::VT_NUMBER:		
			$res = (intval($value) == floatval($value)) ? intval($value) : floatval($value);
			break;
		case self::VT_STRING:
			$res = ($maxStrLen == 0 ? $value : substr($value, 0, $maxStrLen)) ;
			break;
		case self::VT_Y_N_NULL:
			$res = ($value == "Y") ? "Y" : ($value === null ? null : "N");
			break;
		case self::VT_Y_N:
			$res = ($value == "Y") ? "Y" : "N";
			break;
		case self::VT_DATE:
			$res = (is_int($value) || $value===null) ? $value : MakeTimeStamp($value , FORMAT_DATE);
			$res = (is_int($res) || $res===null) ? $res : null;
			break;
		case self::VT_DATE_TIME:
			$res = (is_int($value) || $value===null) ? $value : MakeTimeStamp($value , FORMAT_DATETIME);
			$res = (is_int($res) || $res===null) ? $res : null;
			break;
	}
	if($list != null) $res = (in_array($res, $list) ? $res : $defVal);
			
	return $res;
}