Commit f704ea81 authored by Carsten  Rose's avatar Carsten Rose
Browse files

FillStoreForm.php, AbstractBuilForm.php, Support.php: replaced 'dateFormat'...

FillStoreForm.php, AbstractBuilForm.php, Support.php: replaced 'dateFormat' with 'FE_DATE_FORMAT' where appropriate.
AbstractBuilForm.php: buildDateJQW in a first version.
parent ac5e87e5
......@@ -1764,7 +1764,7 @@ abstract class AbstractBuildForm {
$value = Support::convertDateTime($value, $formElement[FE_DATE_FORMAT], $formElement[FE_SHOW_ZERO], $showTime, $formElement[FE_SHOW_SECONDS]);
$tmpPattern = $formElement['checkPattern'];
$formElement['checkPattern'] = Support::dateTimeRegexp($formElement[FE_TYPE], $formElement['dateFormat']);
$formElement['checkPattern'] = Support::dateTimeRegexp($formElement[FE_TYPE], $formElement[FE_DATE_FORMAT]);
switch ($formElement['checkType']) {
......@@ -1806,10 +1806,10 @@ abstract class AbstractBuildForm {
$timePattern = ($formElement[FE_SHOW_SECONDS] == 1) ? 'hh:mm:ss' : 'hh:mm';
switch ($formElement[FE_TYPE]) {
case 'date':
$placeholder = $formElement['dateFormat'];
$placeholder = $formElement[FE_DATE_FORMAT];
break;
case 'datetime':
$placeholder = $formElement['dateFormat'] . ' ' . $timePattern;
$placeholder = $formElement[FE_DATE_FORMAT] . ' ' . $timePattern;
break;
case 'time':
$placeholder = $timePattern;
......@@ -1853,88 +1853,73 @@ abstract class AbstractBuildForm {
* @throws UserFormException
*/
public function buildDateJQW(array $formElement, $htmlFormElementId, $value, array &$json) {
$attribute = Support::doAttribute('name', $htmlFormElementId);
$attribute .= Support::doAttribute('class', 'form-control');
$arrMinMax = null;
// if ($formElement['placeholder'] == '') {
// $timePattern = ($formElement[FE_SHOW_SECONDS] == 1) ? 'hh:mm:ss' : 'hh:mm';
// switch ($formElement[FE_TYPE]) {
// case 'date':
// $placeholder = $formElement[FE_DATE_FORMAT];
// break;
// case 'datetime':
// $placeholder = $formElement[FE_DATE_FORMAT] . ' ' . $timePattern;
// break;
// case 'time':
// $placeholder = $timePattern;
// break;
// default:
// throw new UserFormException("Unexpected Formelement type: '" . $formElement[FE_TYPE] . "'", ERROR_FORMELEMENT_TYPE);
// }
// $formElement['placeholder'] = $placeholder;
// }
// switch ($formElement['checkType']) {
//// case SANITIZE_ALLOW_PATTERN:
//// $formElement['checkPattern'] = $tmpPattern;
//// break;
// case SANITIZE_ALLOW_MIN_MAX_DATE:
// $arrMinMax = explode('|', $formElement['checkPattern'], 2);
// if (count($arrMinMax) != 2) {
// throw new UserFormException('Missing min|max definition', ERROR_MISSING_MIN_MAX);
// }
// break;
//// case SANITIZE_ALLOW_ALL:
//// case SANITIZE_ALLOW_ALNUMX:
//// case SANITIZE_ALLOW_ALLBUT:
//// $formElement['checkType'] = SANITIZE_ALLOW_PATTERN;
//// break;
// default:
// throw new UserFormException("Checktype not applicable for date/time: '" . $formElement['checkType'] . "'", ERROR_NOT_APPLICABLE);
// }
$this->adjustMaxLength($formElement);
$showTime = ($formElement[FE_TYPE] == 'time' || $formElement[FE_TYPE] == 'datetime') ? 1 : 0;
$value = Support::convertDateTime($value, $formElement[FE_DATE_FORMAT], $formElement[FE_SHOW_ZERO], $showTime, $formElement[FE_SHOW_SECONDS]);
$tmpPattern = $formElement['checkPattern'];
$formElement['checkPattern'] = Support::dateTimeRegexp($formElement[FE_TYPE], $formElement['dateFormat']);
switch ($formElement['checkType']) {
case SANITIZE_ALLOW_PATTERN:
$formElement['checkPattern'] = $tmpPattern;
break;
case SANITIZE_ALLOW_MIN_MAX_DATE:
$arrMinMax = explode('|', $formElement['checkPattern'], 2);
if (count($arrMinMax) != 2) {
throw new UserFormException('Missing min|max definition', ERROR_MISSING_MIN_MAX);
}
break;
case SANITIZE_ALLOW_ALL:
case SANITIZE_ALLOW_ALNUMX:
case SANITIZE_ALLOW_ALLBUT:
$formElement['checkType'] = SANITIZE_ALLOW_PATTERN;
break;
default:
throw new UserFormException("Checktype not applicable for date/time: '" . $formElement['checkType'] . "'", ERROR_NOT_APPLICABLE);
}
// truncate if necessary
if ($value != '' && $formElement['maxLength'] > 0) {
$value = substr($value, 0, $formElement['maxLength']);
}
// $formElement[FE_DATE_FORMAT]
$type = $formElement[FE_TYPE];
if ($type === 'datetime')
$type = 'datetime-local';
$attribute .= Support::doAttribute('type', $type);
// 'maxLength' needs an upper 'L': naming convention for DB tables!
$attribute .= $this->getAttributeList($formElement, ['size', 'maxLength']);
$attribute .= Support::doAttribute('value', htmlentities($value), false);
if ($formElement['placeholder'] == '') {
$timePattern = ($formElement[FE_SHOW_SECONDS] == 1) ? 'hh:mm:ss' : 'hh:mm';
switch ($formElement[FE_TYPE]) {
case 'date':
$placeholder = $formElement['dateFormat'];
break;
case 'datetime':
$placeholder = $formElement['dateFormat'] . ' ' . $timePattern;
break;
case 'time':
$placeholder = $timePattern;
break;
default:
throw new UserFormException("Unexpected Formelement type: '" . $formElement[FE_TYPE] . "'", ERROR_FORMELEMENT_TYPE);
}
$formElement['placeholder'] = $placeholder;
}
$attribute .= $this->getAttributeList($formElement, ['autocomplete', 'autofocus', 'placeholder']);
$attribute = Support::doAttribute('id', $htmlFormElementId);
$attribute .= Support::doAttribute('class', 'jqw-datetimepicker');
$attribute .= Support::doAttribute('data-control-name', "$htmlFormElementId");
$attribute .= Support::doAttribute('data-format-string', "dd.MM.yyyy HH:mm");
$attribute .= Support::doAttribute('data-show-time-button', "true");
// $attribute .= Support::doAttribute('data-placeholder', $formElement['placeholder']);
$attribute .= Support::doAttribute('data-value', htmlentities($value), false);
// $attribute .= Support::doAttribute('data-autofocus', $formElement['autofocus']);
$attribute .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : '');
$attribute .= Support::doAttribute('title', $formElement['tooltip']);
$attribute .= $this->getInputCheckPattern($formElement['checkType'], $formElement['checkPattern']);
$attribute .= Support::doAttribute('data-title', $formElement['tooltip']);
if (is_array($arrMinMax)) {
$attribute .= Support::doAttribute('min', $arrMinMax[0]);
$attribute .= Support::doAttribute('max', $arrMinMax[1]);
}
// if (is_array($arrMinMax)) {
// $attribute .= Support::doAttribute('data-min', $arrMinMax[0]);
// $attribute .= Support::doAttribute('data-max', $arrMinMax[1]);
// }
$attribute .= $this->getAttributeFeMode($formElement[FE_MODE]);
$json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]);
// $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]);
return "<input $attribute>" . $this->getHelpBlock();
$element = Support::wrapTag("<div $attribute>", '', false);
return $element . $this->getHelpBlock();
}
......
......@@ -462,10 +462,10 @@ class Support {
$timePattern = ($formElement[FE_SHOW_SECONDS] == 1) ? 'hh:mm:ss' : 'hh:mm';
switch ($formElement[FE_TYPE]) {
case 'date':
$placeholder = $formElement['dateFormat'];
$placeholder = $formElement[FE_DATE_FORMAT];
break;
case 'datetime':
$placeholder = $formElement['dateFormat'] . ' ' . $timePattern;
$placeholder = $formElement[FE_DATE_FORMAT] . ' ' . $timePattern;
break;
case 'time':
$placeholder = $timePattern;
......
......@@ -202,14 +202,14 @@ class FillStoreForm {
/**
* Check $value as date/datime/time value and convert it to FORMAT_DATE_INTERNATIONAL.
*
* @param array $formElement - if not set, set $formElement['dateFormat']
* @param array $formElement - if not set, set $formElement[FE_DATE_FORMAT]
* @param string $value - date/datetime/time value in format FORMAT_DATE_INTERNATIONAL or FORMAT_DATE_GERMAN
* @return string - checked datetime string
* @throws UserFormException
*/
private function doDateTime(array &$formElement, $value) {
$regexp = Support::dateTimeRegexp($formElement[FE_TYPE], $formElement['dateFormat']);
$regexp = Support::dateTimeRegexp($formElement[FE_TYPE], $formElement[FE_DATE_FORMAT]);
if (1 !== preg_match('/' . $regexp . '/', $value, $matches)) {
$placeholder = Support::getDateTimePlaceholder($formElement);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment