Beispiel #1
0
 public function showDBValue(&$data, $keylink)
 {
     return format_longdate(db2time($data[$this->field]));
 }
function GetDataInt($value, $data, $field, $format)
{
    global $strTableName;
    if ($format == FORMAT_CUSTOM && $data) {
        return CustomExpression($value, $data, $field, "");
    }
    $ret = "";
    // long binary data?
    if (IsBinaryType(GetFieldType($field))) {
        $ret = mlang_message("LONG_BINARY");
    } else {
        $ret = $value;
    }
    if ($ret === false) {
        $ret = "";
    }
    if ($format == FORMAT_DATE_SHORT) {
        $ret = format_shortdate(db2time($value));
    } else {
        if ($format == FORMAT_DATE_LONG) {
            $ret = format_longdate(db2time($value));
        } else {
            if ($format == FORMAT_DATE_TIME) {
                $ret = str_format_datetime(db2time($value));
            } else {
                if ($format == FORMAT_TIME) {
                    if (IsDateFieldType(GetFieldType($field))) {
                        $ret = str_format_time(db2time($value));
                    } else {
                        $numbers = parsenumbers($value);
                        if (!count($numbers)) {
                            return "";
                        }
                        while (count($numbers) < 3) {
                            $numbers[] = 0;
                        }
                        $ret = str_format_time(array(0, 0, 0, $numbers[0], $numbers[1], $numbers[2]));
                    }
                } else {
                    if ($format == FORMAT_NUMBER) {
                        $ret = str_format_number($value, GetFieldData($strTableName, $field, "DecimalDigits", false));
                    } else {
                        if ($format == FORMAT_CURRENCY) {
                            $ret = str_format_currency($value);
                        } else {
                            if ($format == FORMAT_CHECKBOX) {
                                $ret = "<img src=\"images/check_";
                                if ($value && $value != 0) {
                                    $ret .= "yes";
                                } else {
                                    $ret .= "no";
                                }
                                $ret .= ".gif\" border=0";
                                if (isEnableSection508()) {
                                    $ret .= " alt=\" \"";
                                }
                                $ret .= ">";
                            } else {
                                if ($format == FORMAT_PERCENT) {
                                    if ($value != "") {
                                        $ret = $value * 100 . "%";
                                    }
                                } else {
                                    if ($format == FORMAT_PHONE_NUMBER) {
                                        if (strlen($ret) == 7) {
                                            $ret = substr($ret, 0, 3) . "-" . substr($ret, 3);
                                        } else {
                                            if (strlen($ret) == 10) {
                                                $ret = "(" . substr($ret, 0, 3) . ") " . substr($ret, 3, 3) . "-" . substr($ret, 6);
                                            }
                                        }
                                    } else {
                                        if ($format == FORMAT_FILE_IMAGE) {
                                            if (!CheckImageExtension($ret)) {
                                                return "";
                                            }
                                            $thumbnailed = false;
                                            $thumbprefix = "";
                                            if ($thumbnailed) {
                                                // show thumbnail
                                                $thumbname = $thumbprefix . $ret;
                                                if (substr(GetLinkPrefix($field), 0, 7) != "http://" && !myfile_exists(getabspath(GetLinkPrefix($field) . $thumbname))) {
                                                    $thumbname = $ret;
                                                }
                                                $ret = "<a target=_blank href=\"" . htmlspecialchars(AddLinkPrefix($field, $ret)) . "\">";
                                                $ret .= "<img";
                                                if (isEnableSection508()) {
                                                    $ret .= " alt=\"" . htmlspecialchars($data[$field]) . "\"";
                                                }
                                                $ret .= " border=0";
                                                $ret .= " src=\"" . htmlspecialchars(AddLinkPrefix($field, $thumbname)) . "\"></a>";
                                            } else {
                                                if (isEnableSection508()) {
                                                    $ret = '<img alt=\\"".htmlspecialchars($data[$field])."\\" src="' . AddLinkPrefix($field, $ret) . '" border=0>';
                                                } else {
                                                    $ret = '<img src="' . htmlspecialchars(AddLinkPrefix($field, $ret)) . '" border=0>';
                                                }
                                            }
                                        } else {
                                            if ($format == FORMAT_HYPERLINK) {
                                                if ($data) {
                                                    $ret = GetHyperlink($ret, $field, $data);
                                                }
                                            } else {
                                                if ($format == FORMAT_EMAILHYPERLINK) {
                                                    $link = $ret;
                                                    $title = $ret;
                                                    if (substr($ret, 0, 7) == "mailto:") {
                                                        $title = substr($ret, 8);
                                                    } else {
                                                        $link = "mailto:" . $link;
                                                    }
                                                    $ret = '<a href="' . $link . '">' . $title . '</a>';
                                                } else {
                                                    if ($format == FORMAT_FILE) {
                                                        $iquery = "table=" . GetTableURL($strTableName) . "&field=" . rawurlencode($field);
                                                        $arrKeys = GetTableKeys($strTableName);
                                                        $keylink = "";
                                                        for ($j = 0; $j < count($arrKeys); $j++) {
                                                            $keylink .= "&key" . ($j + 1) . "=" . rawurlencode($data[$arrKeys[$j]]);
                                                        }
                                                        $iquery .= $keylink;
                                                        return '<a href="download.php?' . $iquery . '">' . htmlspecialchars($ret) . '</a>';
                                                    } else {
                                                        if (GetEditFormat($field) == EDIT_FORMAT_CHECKBOX && $format == FORMAT_NONE) {
                                                            if ($ret && $ret != 0) {
                                                                $ret = mlang_message("YES");
                                                            } else {
                                                                $ret = mlang_message("NO");
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return $ret;
}
 /**
  * @param &Array data
  * @return String	 
  */
 public function getTextValue(&$data)
 {
     return format_longdate(db2time($data[$this->field]));
 }