add support for configurable date format

This commit is contained in:
Uwe Steinmann 2020-12-17 13:41:00 +01:00
parent d624b3c9ef
commit d9fa867582
16 changed files with 61 additions and 42 deletions

View File

@ -59,6 +59,11 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
if($attrdef = $dms->getAttributeDefinition($attrdefid)) {
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
if($attribute) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_date:
$attribute = date('Y-m-d', makeTsFromDate($attribute));
break;
}
if(!$attrdef->validate($attribute)) {
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
return false;
@ -78,6 +83,11 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
if($attrdef = $dms->getAttributeDefinition($attrdefid)) {
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
if($attribute) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_date:
$attribute = date('Y-m-d', makeTsFromDate($attribute));
break;
}
if(!$attrdef->validate($attribute)) {
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
return false;

View File

@ -120,6 +120,11 @@ class SeedDMS_Controller_EditDocument extends SeedDMS_Controller_Common {
if($attrdef = $dms->getAttributeDefinition($attrdefid)) {
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
if($attribute) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_date:
$attribute = date('Y-m-d', makeTsFromDate($attribute));
break;
}
if(!$attrdef->validate($attribute, $document, true)) {
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
return false;

View File

@ -135,10 +135,11 @@ if (!is_numeric($sequence)) {
switch($_POST["presetexpdate"]) {
case "date":
$tmp = explode('-', $_POST["expdate"]);
if(count($tmp) != 3)
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("malformed_expiration_date"));
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
$expires = makeTsFromDate($_POST["expdate"]);
// $tmp = explode('-', $_POST["expdate"]);
// if(count($tmp) != 3)
// UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("malformed_expiration_date"));
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
break;
case "1w":
$tmp = explode('-', date('Y-m-d'));

View File

@ -49,14 +49,16 @@ if (!isset($_POST["name"]) || !isset($_POST["comment"]) ) {
$name = $_POST["name"];
$comment = $_POST["comment"];
if(isset($_POST["from"])) {
$tmp = explode('-', $_POST["from"]);
$from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
$from = makeTsFromDate($_POST["from"]);
// $tmp = explode('-', $_POST["from"]);
// $from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
} else {
$from = mktime(0,0,0, intval($_POST["frommonth"]), intval($_POST["fromday"]), intval($_POST["fromyear"]));
}
if(isset($_POST["to"])) {
$tmp = explode('-', $_POST["to"]);
$to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
$to = makeTsFromDate($_POST["to"])+86400;
// $tmp = explode('-', $_POST["to"]);
// $to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
} else {
$to = mktime(23,59,59, intval($_POST["tomonth"]), intval($_POST["today"]), intval($_POST["toyear"]));
}

View File

@ -71,6 +71,11 @@ if($attributes) {
foreach($attributes as $attrdefid=>$attribute) {
$attrdef = $dms->getAttributeDefinition($attrdefid);
if($attribute) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_date:
$attribute = date('Y-m-d', makeTsFromDate($attribute));
break;
}
if(!$attrdef->validate($attribute, $version, true)) {
$errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute);
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg);

View File

@ -79,8 +79,9 @@ else
if(isset($_POST['presetexpdate'])) {
switch($_POST["presetexpdate"]) {
case "date":
$tmp = explode('-', $_POST["expdate"]);
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
$expires = makeTsFromDate($_POST["expdate"]);
// $tmp = explode('-', $_POST["expdate"]);
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
break;
case "1w":
$tmp = explode('-', date('Y-m-d'));

View File

@ -61,15 +61,17 @@ else
$comment = $_POST["comment"];
if(isset($_POST["from"])) {
$from = explode('T', $_POST["from"]);
$tmp = explode('-', $from[0]);
$from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
$from = makeTsFromDate($_POST["from"]);
// $from = explode('T', $_POST["from"]);
// $tmp = explode('-', $from[0]);
// $from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
} else {
UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
}
if(isset($_POST["to"])) {
$tmp = explode('-', $_POST["to"]);
$to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
$to = makeTsFromDate($_POST["to"])+86400;
// $tmp = explode('-', $_POST["to"]);
// $to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
} else {
$to = $event['stop'] - $event['start'] + $from;;
}

View File

@ -49,7 +49,7 @@ if (!isset($_POST["presetexpdate"]) || $_POST["presetexpdate"] == "") {
switch($_POST["presetexpdate"]) {
case "date":
$expires = strtotime($_POST["expdate"]);
$expires = makeTsFromDate($_POST["expdate"]);
// $tmp = explode('-', $_POST["expdate"]);
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
break;

View File

@ -141,8 +141,9 @@ else
$oldexpires = $document->getExpires();
switch($_POST["presetexpdate"]) {
case "date":
$tmp = explode('-', $_POST["expdate"]);
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
$expires = makeTsFromDate($_POST["expdate"]);
// $tmp = explode('-', $_POST["expdate"]);
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
break;
case "1w":
$tmp = explode('-', date('Y-m-d'));
@ -270,6 +271,11 @@ default:
foreach($attributes as $attrdefid=>$attribute) {
$attrdef = $dms->getAttributeDefinition($attrdefid);
if($attribute) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_date:
$attribute = date('Y-m-d', makeTsFromDate($attribute));
break;
}
if(!$attrdef->validate($attribute)) {
$errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute);
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg);

View File

@ -286,7 +286,7 @@ $(document).ready(function() {
);
$this->formField(
getMLText("expires"),
$this->getDateChooser(($expts ? date('Y-m-d', $expts) : ''), "expdate", $this->params['session']->getLanguage())
$this->getDateChooser(($expts ? getReadableDate($expts) : ''), "expdate", $this->params['session']->getLanguage())
);
}
if($user->isAdmin()) {

View File

@ -80,7 +80,7 @@ $(document).ready(function() {
$this->contentHeading(getMLText("add_event"));
$this->contentContainerStart();
$expdate = date('Y-m-d');
$expdate = getReadableDate();
?>
<form class="form-horizontal" action="../op/op.AddEvent.php" id="form1" name="form1" method="post">

View File

@ -1567,7 +1567,9 @@ $(document).ready(function() {
break;
case SeedDMS_Core_AttributeDefinition::type_date:
$objvalue = $attribute ? (is_object($attribute) ? $attribute->getValue() : $attribute) : '';
$content .= '<span class="input-append date datepicker" data-date="'.date('Y-m-d').'" data-date-format="yyyy-mm-dd" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
if(!$dateformat)
$dateformat = getConvertDateFormat();
$content .= '<span class="input-append date datepicker" data-date="'.getReadableDate().'" data-date-format="'.$dateformat.'" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
<input id="'.$fieldname.'_'.$attrdef->getId().'" class="span9" size="16" name="'.$fieldname.'['.$attrdef->getId().']" type="text" value="'.($objvalue ? $objvalue : '').'">
<span class="add-on"><i class="fa fa-calendar"></i></span>
</span>';

View File

@ -74,11 +74,11 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
<?php
$this->formField(
getMLText("from"),
$this->getDateChooser(date('Y-m-d', $event["start"]), "from")
$this->getDateChooser(getReadableDate($event["start"]), "from")
);
$this->formField(
getMLText("to"),
$this->getDateChooser(date('Y-m-d', $event["stop"]), "to")
$this->getDateChooser(getReadableDate($event["stop"]-86400), "to")
);
$this->formField(
getMLText("name"),

View File

@ -85,7 +85,7 @@ $(document).ready( function() {
$this->contentContainerStart();
if($document->expires())
$expdate = date('Y-m-d', $document->getExpires());
$expdate = getReadableDate($document->getExpires());
else
$expdate = '';
?>

View File

@ -236,28 +236,13 @@ div.timeline-event-selected {
?>
<form action="../out/out.Timeline.php" class="form form-inline" name="form1" id="form1">
<?php
/*
$html = '
<span class="input-append date" style="display: inline;" id="fromdate" data-date="'.date('Y-m-d', $from).'" data-date-format="yyyy-mm-dd" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
<input type="text" class="input-small" name="fromdate" value="'.date('Y-m-d', $from).'"/>
<span class="add-on"><i class="fa fa-calendar"></i></span>
</span> -
<span class="input-append date" style="display: inline;" id="todate" data-date="'.date('Y-m-d', $to).'" data-date-format="yyyy-mm-dd" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
<input type="text" class="input-small" name="todate" value="'.date('Y-m-d', $to).'"/>
<span class="add-on"><i class="fa fa-calendar"></i></span>
</span>';
$this->formField(
getMLText("date"),
$html
);
*/
$this->formField(
getMLText("from"),
$this->getDateChooser(date('Y-m-d', $from), 'fromdate', $this->params['session']->getLanguage())
$this->getDateChooser(getReadableDate($from), 'fromdate', $this->params['session']->getLanguage())
);
$this->formField(
getMLText("to"),
$this->getDateChooser(date('Y-m-d', $to), 'todate', $this->params['session']->getLanguage())
$this->getDateChooser(getReadableDate($to), 'todate', $this->params['session']->getLanguage())
);
$html = '
<input type="checkbox" name="skip[]" value="add_file" '.(($skip && in_array('add_file', $skip)) ? 'checked' : '').'> '.getMLText('timeline_skip_add_file').'<br />

View File

@ -273,7 +273,7 @@ console.log(element);
);
$this->formField(
getMLText("expires"),
$this->getDateChooser(($expts ? date('Y-m-d', $expts) : ''), "expdate", $this->params['session']->getLanguage())
$this->getDateChooser(($expts ? getReadableDate($expts) : ''), "expdate", $this->params['session']->getLanguage())
);
}
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all));