function CCParseValue($ParsingValue, $Format, $DataType, $ErrorClass, $FieldName, $isDBFormat = false)
{
    global $CCSLocales;
    $errors = new clsErrors();
    $varResult = "";
    if (CCCheckValue($ParsingValue, $DataType)) {
        $varResult = $ParsingValue;
    } else {
        if (strlen($ParsingValue)) {
            switch ($DataType) {
                case ccsDate:
                    $DateValidation = true;
                    if (CCValidateDateMask($ParsingValue, $Format)) {
                        $varResult = CCParseDate($ParsingValue, $Format);
                        if (!CCValidateDate($varResult)) {
                            $DateValidation = false;
                            $varResult = "";
                        }
                    } else {
                        $DateValidation = false;
                    }
                    if (!$DateValidation && $ErrorClass->Count() == 0) {
                        if (is_array($Format)) {
                            $FormatString = join("", $Format);
                        } else {
                            $FormatString = $Format;
                        }
                        $errors->addError($CCSLocales->GetText('CCS_IncorrectFormat', array($FieldName, $FormatString)));
                    }
                    break;
                case ccsBoolean:
                    if (CCValidateBoolean($ParsingValue, $Format)) {
                        $varResult = CCParseBoolean($ParsingValue, $Format);
                    } else {
                        if ($ErrorClass->Count() == 0) {
                            if (is_array($Format)) {
                                $FormatString = CCGetBooleanFormat($Format);
                            } else {
                                $FormatString = $Format;
                            }
                            $errors->addError($CCSLocales->GetText('CCS_IncorrectFormat', array($FieldName, $FormatString)));
                        }
                    }
                    break;
                case ccsInteger:
                    if (CCValidateNumber($ParsingValue, $Format, $isDBFormat)) {
                        $varResult = CCParseInteger($ParsingValue, $Format, $isDBFormat);
                    } else {
                        if ($ErrorClass->Count() == 0) {
                            $errors->addError($CCSLocales->GetText('CCS_IncorrectFormat', array($FieldName, $Format)));
                        }
                    }
                    break;
                case ccsFloat:
                    if (CCValidateNumber($ParsingValue, $Format, $isDBFormat)) {
                        $varResult = CCParseFloat($ParsingValue, $Format, $isDBFormat);
                    } else {
                        if ($ErrorClass->Count() == 0) {
                            $errors->addError($CCSLocales->GetText('CCS_IncorrectFormat', array($FieldName, $Format)));
                        }
                    }
                    break;
                case ccsText:
                case ccsMemo:
                    $varResult = strval($ParsingValue);
                    break;
            }
        }
    }
    if (is_string($ErrorClass)) {
        return $varResult;
    } else {
        $ErrorClass->AddErrors($errors);
        return array($varResult, $ErrorClass);
    }
}
Exemple #2
0
 function GetParsedValue()
 {
     $varResult = "";
     if (strlen($this->DBValue)) {
         switch ($this->DataType) {
             case ccsDate:
                 if (CCValidateDate($this->DBValue, $this->DBFormat)) {
                     $varResult = CCParseDate($this->DBValue, $this->DBFormat);
                 } else {
                     if (is_array($this->DBFormat)) {
                         $this->Errors->addError("The value in field " . $this->Name . " is not valid. Use the following format: " . join("", $this->DBFormat) . "");
                     } else {
                         $this->Errors->addError("The value in field " . $this->Name . " is not valid.");
                     }
                 }
                 break;
             case ccsBoolean:
                 if (CCValidateBoolean($this->DBValue, $this->DBFormat)) {
                     $varResult = CCParseBoolean($this->DBValue, $this->DBFormat);
                 } else {
                     $this->Errors->addError("The value in field " . $this->Caption . " is not valid.");
                 }
                 break;
             case ccsInteger:
                 if (CCValidateNumber($this->DBValue, $this->DBFormat)) {
                     $varResult = CCParseInteger($this->DBValue, $this->DBFormat);
                 } else {
                     $this->Errors->addError("The value in field " . $this->Name . " is not valid.");
                 }
                 break;
             case ccsFloat:
                 if (CCValidateNumber($this->DBValue, $this->DBFormat)) {
                     $varResult = CCParseFloat($this->DBValue, $this->DBFormat);
                 } else {
                     $this->Errors->addError("The value in field " . $this->Name . " is not valid.");
                 }
                 break;
             case ccsText:
             case ccsMemo:
                 $varResult = strval($this->DBValue);
                 break;
         }
     }
     return $varResult;
 }
Exemple #3
0
 function GetParsedValue()
 {
     global $CCSLocales;
     $varResult = "";
     if (strlen($this->DBValue)) {
         switch ($this->DataType) {
             case ccsDate:
                 $DateValidation = true;
                 if (CCValidateDateMask($this->DBValue, $this->DBFormat)) {
                     $varResult = CCParseDate($this->DBValue, $this->DBFormat);
                     if (!$varResult || !CCValidateDate($varResult)) {
                         $DateValidation = false;
                         $varResult = "";
                     }
                 } else {
                     $DateValidation = false;
                 }
                 if (!$DateValidation) {
                     if (is_array($this->DBFormat)) {
                         $FormatString = join("", $this->DBFormat);
                     } else {
                         $FormatString = $this->DBFormat;
                     }
                     $this->Errors->addError($CCSLocales->GetText('CCS_IncorrectFieldFormat', array($this->Name, $FormatString)));
                 }
                 break;
             case ccsBoolean:
                 if (CCValidateBoolean($this->DBValue, $this->DBFormat)) {
                     $varResult = CCParseBoolean($this->DBValue, $this->DBFormat);
                 } else {
                     if (is_array($this->DBFormat)) {
                         $FormatString = CCGetBooleanFormat($this->DBFormat);
                     } else {
                         $FormatString = $this->DBFormat;
                     }
                     $this->Errors->addError($CCSLocales->GetText('CCS_IncorrectFieldFormat', array($this->Name, $FormatString)));
                 }
                 break;
             case ccsInteger:
                 if (CCValidateNumber($this->DBValue, $this->DBFormat, true)) {
                     $varResult = CCParseInteger($this->DBValue, $this->DBFormat, true);
                 } else {
                     $this->Errors->addError($CCSLocales->GetText('CCS_IncorrectFieldFormat', array($this->Name, $this->DBFormat)));
                 }
                 break;
             case ccsFloat:
                 if (CCValidateNumber($this->DBValue, $this->DBFormat, true)) {
                     $varResult = CCParseFloat($this->DBValue, $this->DBFormat, true);
                 } else {
                     $this->Errors->addError($CCSLocales->GetText('CCS_IncorrectFieldFormat', array($this->Name, $this->DBFormat)));
                 }
                 break;
             case ccsText:
             case ccsMemo:
                 $varResult = strval($this->DBValue);
                 break;
         }
     }
     return $varResult;
 }