コード例 #1
0
function CCCompareValues($Value1, $Value2, $DataType = ccsText, $Format = "")
{
    switch ($DataType) {
        case ccsInteger:
        case ccsFloat:
            if (strcmp(trim($Value1), "") == 0 || strcmp(trim($Value2), "") == 0) {
                return strcmp($Value1, $Value2);
            } else {
                if ($Value1 > $Value2) {
                    return 1;
                } else {
                    if ($Value1 < $Value2) {
                        return -1;
                    } else {
                        return 0;
                    }
                }
            }
        case ccsText:
        case ccsMemo:
            return strcmp($Value1, $Value2);
        case ccsBoolean:
            if (is_bool($Value1)) {
                $val1 = $Value1;
            } else {
                if (strlen($Value1) != 0 && CCValidateBoolean($Value1, $Format)) {
                    $val1 = CCParseBoolean($Value1, $Format);
                } else {
                    return 1;
                }
            }
            if (is_bool($Value2)) {
                $val2 = $Value2;
            } else {
                if (strlen($Value2) != 0 && CCValidateBoolean($Value2, $Format)) {
                    $val2 = CCParseBoolean($Value2, $Format);
                } else {
                    return 1;
                }
            }
            return $val1 xor $val2;
        case ccsDate:
            if (is_array($Value1) && is_array($Value2)) {
                $compare = array(ccsYear, ccsMonth, ccsDay, ccsHour, ccsMinute, ccsSecond);
                foreach ($compare as $ind => $val) {
                    if ($Value1[$val] < $Value2[$val]) {
                        return -1;
                    } elseif ($Value1[$val] > $Value2[$val]) {
                        return 1;
                    }
                }
                return 0;
            } else {
                if (is_array($Value1)) {
                    $FormattedValue = CCFormatValue($Value1, $Format, $DataType);
                    return CCCompareValues($FormattedValue, $Value2);
                } else {
                    if (is_array($Value2)) {
                        $FormattedValue = CCFormatValue($Value2, $Format, $DataType);
                        return CCCompareValues($Value1, $FormattedValue);
                    } else {
                        return CCCompareValues($Value1, $Value2);
                    }
                }
            }
    }
}
コード例 #2
0
ファイル: Classes.php プロジェクト: rayminami/chumanis
 function GetFormattedValue($MaskFormat)
 {
     return CCFormatValue($this->Value, $MaskFormat, $this->DataType);
 }