use html5 datetime field
Dieser Commit ist enthalten in:
Ursprung
0b20d638f6
Commit
28acb7f004
|
@ -10,34 +10,26 @@ function frontendusers_valid_from_getTitle ()
|
||||||
|
|
||||||
function frontendusers_valid_from_display ()
|
function frontendusers_valid_from_display ()
|
||||||
{
|
{
|
||||||
global $feuser,$db,$belang;
|
global $feuser;
|
||||||
|
|
||||||
$template = '%s';
|
$template = '%s';
|
||||||
|
|
||||||
$currentValue = $feuser->get("valid_from");
|
$currentValue = $feuser->get("valid_from");
|
||||||
|
|
||||||
if ($currentValue == '') {
|
if($currentValue == "0000-00-00 00:00:00" || $currentValue == "") {
|
||||||
$currentValue = '1000-01-01';
|
$currentValue = null;
|
||||||
|
} else {
|
||||||
|
$datetime = new DateTime($currentValue);
|
||||||
|
$currentValue = $datetime->format('Y-m-d\TH:i');
|
||||||
}
|
}
|
||||||
$currentValue = str_replace('00:00:00', '', $currentValue);
|
|
||||||
|
$sValidFrom = '<input
|
||||||
$sValidFrom = '<style type="text/css">@import url(./scripts/jscalendar/calendar-contenido.css);</style>
|
id="valid_from"
|
||||||
<script type="text/javascript" src="./scripts/jscalendar/calendar.js"></script>
|
type="datetime-local"
|
||||||
<script type="text/javascript" src="./scripts/jscalendar/lang/calendar-'.substr(strtolower($belang),0,2).'.js"></script>
|
name="valid_from"
|
||||||
<script type="text/javascript" src="./scripts/jscalendar/calendar-setup.js"></script>';
|
pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}"
|
||||||
$sValidFrom .= '<input type="text" id="valid_from" name="valid_from" value="'.$currentValue.'" /> <img src="images/calendar.gif" id="trigger" /">';
|
value="'.$currentValue.'" />';
|
||||||
$sValidFrom .= '<script type="text/javascript">
|
|
||||||
Calendar.setup(
|
|
||||||
{
|
|
||||||
inputField : "valid_from",
|
|
||||||
ifFormat : "%Y-%m-%d",
|
|
||||||
button : "trigger",
|
|
||||||
weekNumbers : true,
|
|
||||||
firstDay : 1
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>';
|
|
||||||
|
|
||||||
return sprintf($template,$sValidFrom);
|
return sprintf($template,$sValidFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,14 +46,7 @@ function frontendusers_valid_from_wantedVariables ()
|
||||||
*/
|
*/
|
||||||
function frontendusers_valid_from_store ($variables) {
|
function frontendusers_valid_from_store ($variables) {
|
||||||
global $feuser;
|
global $feuser;
|
||||||
|
if(!is_null($variables["valid_from"])) {
|
||||||
if(Contenido_Security::isMySQLDate($variables["valid_from"], true)
|
$feuser->set("valid_from", $variables["valid_from"], false);
|
||||||
|| Contenido_Security::isMySQLDateTime($variables["valid_from"], true)
|
}
|
||||||
|| empty($variables["valid_from"])
|
}
|
||||||
|| $variables["valid_from"] == "0000-00-00"
|
|
||||||
|| $variables["valid_from"] == "1000-01-01") {
|
|
||||||
|
|
||||||
$feuser->set("valid_from", $variables["valid_from"], false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
|
@ -7,33 +7,30 @@ function frontendusers_valid_to_getTitle ()
|
||||||
return i18n("Valid to");
|
return i18n("Valid to");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
function frontendusers_valid_to_display ()
|
function frontendusers_valid_to_display ()
|
||||||
{
|
{
|
||||||
global $feuser,$db,$belang;
|
global $feuser;
|
||||||
|
|
||||||
$template = '%s';
|
$template = '%s';
|
||||||
|
|
||||||
$currentValue = $feuser->get("valid_to");
|
$currentValue = $feuser->get("valid_to");
|
||||||
|
|
||||||
if ($currentValue == '') {
|
if($currentValue == "0000-00-00 00:00:00" || $currentValue == "") {
|
||||||
$currentValue = '1000-01-01';
|
$currentValue = '';
|
||||||
|
} else {
|
||||||
|
$datetime = new DateTime($currentValue);
|
||||||
|
$currentValue = $datetime->format('Y-m-d\TH:i');
|
||||||
}
|
}
|
||||||
$currentValue = str_replace('00:00:00', '', $currentValue);
|
|
||||||
|
$sValidFrom = '<input
|
||||||
// js-includes are defined in valid_from
|
id="valid_to"
|
||||||
$sValidFrom = '<input type="text" id="valid_to" name="valid_to" value="'.$currentValue.'" /> <img src="images/calendar.gif" id="trigger_to" /">';
|
type="datetime-local"
|
||||||
$sValidFrom .= '<script type="text/javascript">
|
name="valid_to"
|
||||||
Calendar.setup(
|
pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}"
|
||||||
{
|
value="'.$currentValue.'" />';
|
||||||
inputField : "valid_to",
|
|
||||||
ifFormat : "%Y-%m-%d",
|
|
||||||
button : "trigger_to",
|
|
||||||
weekNumbers : true,
|
|
||||||
firstDay : 1
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>';
|
|
||||||
|
|
||||||
return sprintf($template,$sValidFrom);
|
return sprintf($template,$sValidFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,14 +47,8 @@ function frontendusers_valid_to_wantedVariables ()
|
||||||
*/
|
*/
|
||||||
function frontendusers_valid_to_store ($variables) {
|
function frontendusers_valid_to_store ($variables) {
|
||||||
global $feuser;
|
global $feuser;
|
||||||
|
|
||||||
if(Contenido_Security::isMySQLDate($variables["valid_to"], true)
|
if(!is_null($variables["valid_to"])) {
|
||||||
|| Contenido_Security::isMySQLDateTime($variables["valid_to"], true)
|
|
||||||
|| empty($variables["valid_to"])
|
|
||||||
|| $variables["valid_to"] == "0000-00-00"
|
|
||||||
|| $variables["valid_to"] == "1000-01-01") {
|
|
||||||
|
|
||||||
$feuser->set("valid_to", $variables["valid_to"], false);
|
$feuser->set("valid_to", $variables["valid_to"], false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
Laden…
In neuem Issue referenzieren