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

Input Field date / datetime / time implemented.

AdministratorManual/index.rst, UsersManual/index.rst: Configuration & Documentation.
Sanitize.php: code rewrote to use Support::dateTime2mysql().
Support.php: add dateTimeTegexp()
FillStoreForm.php: use of Support::setFeDefaults($formElement). Format date/datetime/time values
Store.php: redefined various functions to be 'static'
AbstractBuildForm.php, Constants.php: added date/datetime/time to tables. Various new functions.
Save.php: FE die nicht uebertragen wurden (typsicherweise weil leer) werden neu mit eimem leer String gesschrieben - sonst ist es nicht moeglich  Eingaben wieder zu loeschen.
formEditor.sql: Felder date/datetime/time neun implementiert.
parent 810b81b6
......@@ -101,6 +101,8 @@ Setup a *report* to manage all *forms*: Create a Typo3 page and insert a content
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| CSS_LINK_CLASS_EXTERNAL| CSS_LINK_CLASS_EXTERNAL=external | CSS class name of links which points to internal tagets |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| DATE_FORMAT | DATE_FORMAT= yyyy-mm-dd | Possible options: yyyy-mm-dd, dd.mm.yyyy |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
Example: *<ext_dir>/config.ini*
......
......@@ -507,9 +507,10 @@ Class: Native
|class | enum('native', 'action', | Details below. |
| | 'container') | |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|type | enum('checkbox', 'dateJQW', 'datetimeJQW', 'gridJQW', 'hidden', 'text', 'note', 'password', 'radio', 'select', 'subrecord', |
| | 'textarea', 'timeJQW', 'upload', 'fieldset', 'pill', 'before_load', 'before_save', 'before_insert', 'before_update', |
| | 'before_delete', 'after_load', 'after_save', 'after_insert', 'after_update', 'after_delete', 'feGroup', 'sendmail') |
|type | enum('checkbox', 'date', 'time', 'datetime', 'dateJQW', 'datetimeJQW', 'gridJQW', 'hidden', 'text', 'note', 'password', |
| | 'radio', 'select', 'subrecord', 'textarea', 'timeJQW', 'upload', 'fieldset', 'pill', 'before_load', 'before_save', |
| | 'before_insert', 'before_update', 'before_delete', 'after_load', 'after_save', 'after_insert', 'after_update', 'after_delete', |
| | 'feGroup', 'sendmail') |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|checkType | enum('min|max', 'pattern', | |
| | 'number', 'email') | |
......@@ -685,9 +686,19 @@ Checkboxes can be rendered in mode:
Type: date
^^^^^^^^^^
* Range datetime: '1000-01-01' to '9999-12-31' or '0000-00-00'. (http://dev.mysql.com/doc/refman/5.5/en/datetime.html)
* Optional:
* *dateFormat*: ; yyyy-mm-dd | dd.mm.yyyy
Type: datetime
^^^^^^^^^^^^^^
* Range datetime: '1000-01-01 00:00:00' to '9999-12-31 23:59:59' or '0000-00-00 00:00:00'. (http://dev.mysql.com/doc/refman/5.5/en/datetime.html)
* Optional:
* *dateFormat*: ; yyyy-mm-dd | dd.mm.yyyy
* *showSeconds*: 0|1 - shows the seconds. Independent if the user specifies seconds, they are displayed '1' or not '0'.
* *showZero*: 0|1 - For an empty timestamp, With '0' nothing is displayed. With '1' the string '0000-00-00 00:00:00' is displayed.
Type: hidden
^^^^^^^^^^^^
......@@ -807,6 +818,11 @@ Typically not used. Useful if user wishes an explicit 'Submit' Button.
Type: time
^^^^^^^^^^
* Range time: '00:00:00' to '23:59:59' or '00:00:00'. (http://dev.mysql.com/doc/refman/5.5/en/datetime.html)
* Optional:
* *showSeconds*: 0|1 - shows the seconds. Independent if the user specifies seconds, they are displayed '1' or not '0'.
* *showZero*: 0|1 - For an empty timestamp, With '0' nothing is displayed. With '1' the string '00:00[:00]' is displayed.
Type: upload
^^^^^^^^^^^^
......
......@@ -20,3 +20,6 @@ CSS_LINK_CLASS_EXTERNAL = external
; QFQ with own Bootstrap: 'container'. QFQ already nested in Bootstrap of mainpage: <empty>
CSS_CLASS_QFQ_CONTAINER =
; yyyy-mm-dd, dd.mm.yyyy
DATE_FORMAT = yyyy-mm-dd
......@@ -9,8 +9,8 @@ namespace qfq;
use qfq;
use qfq\Store;
use qfq\UserFormException;
use qfq\OnArray;
use qfq\UserFormException;
require_once(__DIR__ . '/../qfq/store/Store.php');
require_once(__DIR__ . '/../qfq/Constants.php');
......@@ -66,12 +66,15 @@ abstract class AbstractBuildForm {
$this->buildElementFunctionName = [
'checkbox' => 'Checkbox',
'date' => 'DateTime',
'datetime' => 'DateTime',
'dateJQW' => 'DateJQW',
'datetimeJQW' => 'DateJQW',
'email' => 'Input',
'gridJQW' => 'GridJQW',
'hidden' => 'Hidden',
'text' => 'Input',
'time' => 'DateTime',
'note' => 'Note',
'password' => 'Input',
'radio' => 'Radio',
......@@ -84,12 +87,15 @@ abstract class AbstractBuildForm {
$this->buildRowName = [
'checkbox' => 'Native',
'date' => 'Native',
'datetime' => 'Native',
'dateJQW' => 'Native',
'datetimeJQW' => 'Native',
'email' => 'Native',
'gridJQW' => 'Native',
'hidden' => 'Native',
'text' => 'Native',
'time' => 'Native',
'note' => 'Native',
'password' => 'Native',
'radio' => 'Native',
......@@ -124,7 +130,14 @@ abstract class AbstractBuildForm {
$htmlSubrecords = '';
$htmlElements = '';
$json = array();
$modeCollectFe = ($mode === FORM_SAVE) ? FLAG_ALL : FLAG_DYNAMIC_UPDATE;
$modeCollectFe = FLAG_DYNAMIC_UPDATE;
$storeUse = STORE_USE_DEFAULT;
if ($mode === FORM_SAVE) {
$modeCollectFe = FLAG_ALL;
$storeUse = STORE_RECORD . STORE_TABLE_DEFAULT;
}
// <form>
if ($mode === FORM_LOAD) {
......@@ -145,7 +158,7 @@ abstract class AbstractBuildForm {
$json[] = $jsonTmp;
}
} else {
$htmlElements = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), $filter, 0, $json, $modeCollectFe, $htmlElementNameIdZero);
$htmlElements = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), $filter, 0, $json, $modeCollectFe, $htmlElementNameIdZero, $storeUse);
}
$htmlSip = $this->buildHiddenSip($json);
......@@ -303,7 +316,7 @@ abstract class AbstractBuildForm {
* @throws \qfq\UserFormException
*/
public function elements($recordId, $filter = FORM_ELEMENTS_NATIVE, $feIdContainer = 0, &$json,
$modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false) {
$modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false, $storeUse = STORE_USE_DEFAULT) {
$html = '';
// get current data record
......@@ -330,8 +343,11 @@ abstract class AbstractBuildForm {
$evaluate = new Evaluate($this->store, $this->db);
$formElement = $evaluate->parseArray($fe, $debugStack);
// Some Defaults
$formElement = Support::setFeDefaults($formElement);
// Get default value
$value = ($formElement['value'] === '') ? $this->store->getVar($formElement['name'], STORE_USE_DEFAULT,
$value = ($formElement['value'] === '') ? $this->store->getVar($formElement['name'], $storeUse,
$formElement['checkType']) : $formElement['value'];
// Typically: $htmlElementNameIdZero = true
......@@ -544,6 +560,27 @@ abstract class AbstractBuildForm {
// MIN( $formElement['maxLength'], tabledefinition)
$maxLength = $this->getColumnSize($formElement['name']);
switch ($formElement['type']) {
case 'date':
$feMaxLength = 10;
break;
case 'datetime':
$feMaxLength = 19;
break;
case 'time':
$feMaxLength = 8;
break;
default:
$feMaxLength = false;
break;
}
// In case the underlying tablecolumn is not of type date/time, the $maxLength might be to high: correct
if ($feMaxLength !== false && $maxLength !== false && $feMaxLength < $maxLength) {
$maxLength = $feMaxLength;
}
// date/datetime
if ($maxLength !== false) {
if (is_numeric($formElement['maxLength'])) {
if ($formElement['maxLength'] > $maxLength) {
......@@ -559,14 +596,25 @@ abstract class AbstractBuildForm {
* Get column spec from tabledefinition and parse size of it. If nothing defined, return false.
*
* @param $column
* @return bool|int
* @return bool|int a) 'false' if there is no length definition, b) length definition, c) date|time|datetime|timestamp use hardcoded length
*/
private function getColumnSize($column) {
$matches = array();
$typeSpec = $this->store->getVar($column, STORE_TABLE_COLUMN_TYPES);
switch ($typeSpec) {
case 'date': // yyyy-mm-dd
return 10;
case 'datetime': // yyyy-mm-dd hh:mm:ss
case 'timestamp': // yyyy-mm-dd hh:mm:ss
return 19;
case 'time': // hh:mm:ss
return 8;
default:
break;
}
// e.g.: string(64), enum('yes','no')
// e.g.: string(64) >> 64, enum('yes','no') >> false
if (1 === preg_match('/\((.+)\)/', $typeSpec, $matches)) {
if (is_numeric($matches[1]))
return $matches[1];
......@@ -1456,16 +1504,153 @@ abstract class AbstractBuildForm {
}
/**
* Build Date JQW element.
* Builds HTML 'input' element.
* Format: <input name="$htmlFormElementId" <type="email|input|password|url" [autocomplete="autocomplete"] [autofocus="autofocus"]
* [maxlength="$maxLength"] [placeholder="$placeholder"] [size="$size"] [min="$min"] [max="$max"]
* [pattern="$pattern"] [readonly="readonly"] [required="required"] [disabled="disabled"] value="$value">
*
*
* @param array $formElement
* @param $htmlFormElementId
* @param $value
* @return string
* @throws UserFormException
*/
public function buildDateJQW(array $formElement, $htmlFormElementId, $value) {
// TODO: implement
throw new UserFormException("Not implemented yet: buildDateJQW()", ERROR_NOT_IMPLEMENTED);
public function builddateJQW(array $formElement, $htmlFormElementId, $value, &$json) {
$textarea = '';
$attribute = Support::doAttribute('name', $htmlFormElementId);
$htmlTag = '<input';
$this->adjustMaxLength($formElement);
// Get date format
if (!isset($formElement['dateFormat'])) {
$formElement['dateFormat'] = $this->store->getVar(SYSTEM_DATE_FORMAT, STORE_SYSTEM);
}
// Format date
$value = Support::convertDateTime($value, $formElement[FE_DATE_FORMAT], $formElement[FE_SHOW_ZERO], 0, $formElement[FE_SHOW_SECONDS]);
// <input>
if ($formElement['maxLength'] > 0) {
// crop string only if it's not empty (substr returns false on empty strings)
if ($value !== '')
$value = substr($value, 0, $formElement['maxLength']);
// 'maxLength' needs an upper 'L': naming convention for DB tables!
$attribute .= $this->getAttributeList($formElement, ['type', 'size', 'maxLength']);
$attribute .= Support::doAttribute('value', htmlentities($value), false);
}
$attribute .= $this->getAttributeList($formElement, ['autocomplete', 'autofocus', 'placeholder']);
$attribute .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : '');
$attribute .= Support::doAttribute('title', $formElement['tooltip']);
$attribute .= $this->getInputCheckPattern($formElement['checkType'], $formElement['checkPattern']);
$attribute .= $this->getAttributeMode($formElement);
$json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']);
return "$htmlTag $attribute>$textarea";
}
/**
* Builds HTML 'input' element.
* Format: <input name="$htmlFormElementId" <type="date" [autocomplete="autocomplete"] [autofocus="autofocus"]
* [maxlength="$maxLength"] [placeholder="$placeholder"] [size="$size"] [min="$min"] [max="$max"]
* [pattern="$pattern"] [readonly="readonly"] [required="required"] [disabled="disabled"] value="$value">
*
*
* @param array $formElement
* @param $htmlFormElementId
* @param $value
* @param $json
* @return string
* @throws UserFormException
*/
public function buildDateTime(array $formElement, $htmlFormElementId, $value, &$json) {
$attribute = Support::doAttribute('name', $htmlFormElementId);
$arrMinMax = null;
$this->adjustMaxLength($formElement);
$showTime = ($formElement['type'] == 'time' || $formElement['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['type'], $formElement['dateFormat']);
switch ($formElement['checkType']) {
case 'pattern':
$formElement['checkPattern'] = $tmpPattern;
break;
case '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 'all':
case 'alnumx':
$formElement['checkType'] = 'pattern';
break;
default:
throw new UserFormException("Checktype not applicable for date/time: '" . $formElement['checkType'] . "'", ERROR_NOT_APPLICABLE);
}
// truncate if necessary
if ($value != '') {
$value = substr($value, 0, $formElement['maxLength']);
}
$type = $formElement['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['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['type'] . "'", ERROR_FORMELEMENT_TYPE);
}
$formElement['placeholder'] = $placeholder;
}
$attribute .= $this->getAttributeList($formElement, ['autocomplete', 'autofocus', 'placeholder']);
$attribute .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : '');
$attribute .= Support::doAttribute('title', $formElement['tooltip']);
$attribute .= $this->getInputCheckPattern($formElement['checkType'], $formElement['checkPattern']);
if (is_array($arrMinMax)) {
$attribute .= Support::doAttribute('min', $arrMinMax[0]);
$attribute .= Support::doAttribute('max', $arrMinMax[1]);
}
$attribute .= $this->getAttributeMode($formElement);
$json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']);
return "<input $attribute>";
}
/**
......
......@@ -130,6 +130,9 @@ const ERROR_FORM_NOT_FOUND = 1052;
const ERROR_DATE_TIME_FORMAT_NOT_RECOGNISED = 1053;
const ERROR_SANATIZE_INVALID_VALUE = 1054;
const ERROR_REQUIRED_VALUE_EMPTY = 1055;
const ERROR_DATE_UNEXPECTED_FORMAT = 1056;
const ERROR_NOT_APPLICABLE = 1057;
const ERROR_FORMELEMENT_TYPE = 1058;
// Store
const ERROR_STORE_VALUE_ALREADY_CODPIED = 1100;
......@@ -236,6 +239,7 @@ const SYSTEM_DB_NAME_TEST = 'DB_NAME_TEST';
const SYSTEM_SESSION_NAME = 'SESSION_NAME';
const SYSTEM_SQL_LOG = 'SQL_LOG'; // Logging to file
const SYSTEM_SQL_LOG_MODE = 'SQL_LOG_MODE'; // Mode, which statements to log.
const SYSTEM_DATE_FORMAT = 'DATE_FORMAT';
const SYSTEM_SHOW_DEBUG_INFO = 'SHOW_DEBUG_INFO';
const SYSTEM_CSS_LINK_CLASS_INTERNAL = 'CSS_LINK_CLASS_INTERNAL';
......@@ -341,6 +345,14 @@ const FE_MODE_REQUIRED = 'required';
const FE_MODE_LOCK = 'lock';
const FE_MODE_DISABLED = 'disabled';
// FormElement columns: real
const FE_TYPE = 'type';
// FormElement columns: via parameter field
const FE_DATE_FORMAT = 'dateFormat'; // value: FORMAT_DATE_INTERNATIONAL | FORMAT_DATE_GERMAN
const FE_SHOW_SECONDS = 'showSeconds'; // value: 0|1
const FE_SHOW_ZERO = 'showZero'; // value: 0|1
// SUPPORT
const PARAM_T3_ALL = 't3 all';
const PARAM_T3_NO_ID = "t3 no id";
......@@ -354,6 +366,11 @@ const QUERY_TYPE_INSERT = 'type: insert';
const QUERY_TYPE_UPDATE = 'type: update,replace,delete';
//Regexp
const REGEXP_DATE_INT = '^\d{4}-\d{2}-\d{2}$';
const REGEXP_DATE_GER = '^\d{1,2}\.\d{1,2}\.\d{2}(\d{2})?$';
const REGEXP_TIME = '^\d{1,2}:\d{1,2}(:\d{1,2})?$';
\ No newline at end of file
//const REGEXP_DATE_INT = '^\d{4}-\d{2}-\d{2}$';
//const REGEXP_DATE_GER = '^\d{1,2}\.\d{1,2}\.\d{2}(\d{2})?$';
//const REGEXP_TIME = '^\d{1,2}:\d{1,2}(:\d{1,2})?$';
// Date/ DateTime formats
const FORMAT_DATE_INTERNATIONAL = 'yyyy-mm-dd';
const FORMAT_DATE_GERMAN = 'dd.mm.yyyy';
......@@ -98,6 +98,8 @@ class Save {
if (isset($formValues[$column])) {
$newValues[$column] = $formValues[$column];
} else {
$newValues[$column] = '';
}
}
......
......@@ -60,14 +60,14 @@ class Sanitize {
// a) der Value verletzt die Datumsgrenzen
// b) die Definition der Grenzen ist buggy
// try {
$valueCompare = Support::dateTime2mysql($value);
$valueCompare = Support::dateTimeGermanToInternational($value);
// } catch (UserFormException $e) {
// throw new UserFormException("Date or time not recognized '" . $value . "' - " . $e->formatMessage(), ERROR_SANATIZE_INVALID_VALUE);
// }
// try {
$minMax[0] = Support::dateTime2mysql($minMax[0]);
$minMax[1] = Support::dateTime2mysql($minMax[1]);
$minMax[0] = Support::dateTimeGermanToInternational($minMax[0]);
$minMax[1] = Support::dateTimeGermanToInternational($minMax[1]);
// } catch (UserFormException $e) {
// throw new UserFormException("Date or time of min|max definition not recognized '" . $patternOrRange . "' - " . $e->formatMessage(), ERROR_SANATIZE_INVALID_VALUE);
// }
......
......@@ -130,7 +130,7 @@ class Support {
}
/**
* Converts a dateTime String to the english format:
* Converts a dateTime String to the international format:
* 1.2.79 > 1979-02-01 00:00:00
* 01.02.13 3:24 > 1979-02-01 03:24:00
* 1.2.1979 14:21:5 > 1979-02-01 14:21:05
......@@ -139,7 +139,7 @@ class Support {
* @return string
* @throws UserFormException
*/
public static function dateTime2mysql($dateTimeString) {
public static function dateTimeGermanToInternational($dateTimeString) {
$dateRaw = '';
$timeRaw = '';
......@@ -175,11 +175,12 @@ class Support {
$date = '0000-00-00';
} else {
// International format: YYYY-MM-DD
if (preg_match("/" . REGEXP_DATE_INT . "/", $dateRaw) === 1) {
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $dateRaw) === 1) {
$date = $dateRaw;
// German format: 1.1.01 - 11.12.1234
} elseif (preg_match("/" . REGEXP_DATE_GER . "/", $dateRaw) === 1) {
} elseif (preg_match('/^\d{1,2}\.\d{1,2}\.\d{2}(\d{2})?$/', $dateRaw) === 1) {
$tmpArr = explode('.', $dateRaw);
if ($tmpArr[2] < 70) {
......@@ -197,7 +198,7 @@ class Support {
if ($timeRaw === '') {
$time = '00:00:00';
} else {
if (preg_match("/" . REGEXP_TIME . "/", $timeRaw) !== 1) {
if (preg_match('/^\d{1,2}:\d{1,2}(:\d{1,2})?$/', $timeRaw) !== 1) {
throw new UserFormException('Date/time format not recognised.', ERROR_DATE_TIME_FORMAT_NOT_RECOGNISED);
}
......@@ -218,13 +219,238 @@ class Support {
return $date . ' ' . $time;
}
/**
* @param string $type date | datetime | time
* @param string $format FORMAT_DATE_INTERNATIONAL | FORMAT_DATE_GERMAN
* @param $showSeconds
* @return string
* @throws UserFormException
*/
public static function dateTimeRegexp($type, $format) {
if ($format === FORMAT_DATE_GERMAN) {
// yyyy-mm-dd | 0000-00-00
$date = '(([1-9]|0[1-9]|1[0-9]|2[0-9]|3[01])\.([1-9]|0[1-9]|1[012])\.([1-9][0-9]{3}|[0-9]{2})|00\.00\.(00){1,2})';
} else {
// FORMAT_DATE_INTERNATIONAL: [d]d.[m]m.[yy]yy | 00.00.0000
$date = '([1-9][0-9]{3}-([1-9]|0[1-9]|1[012])-([1-9]|0[1-9]|1[0-9]|2[0-9]|3[01])|0000-00-00)';
}
// hh:mm[:ss]
$time = '(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){1,2}';
switch ($type) {
case 'date':
$pattern = $date;
break;
case 'datetime':
$pattern = $date . ' ' . $time;
break;
case 'time':
$pattern = $time;
break;
default:
throw new UserFormException("Unknown mode: '$type'", ERROR_UNKNOWN_MODE);
}
return '^' . $pattern . '$';
}
/**
* Parses $dateTimeString. If a date is given, detect international or german format automatically.
* Convert to $dateFormat. 'yy' and 'd' will be converted to 'yyyy' and 'dd'
* Returned value will be 'date only', 'datetime' oder 'time only', depending on the input value.
*
* @param string $dateTimeString
* @param $dateFormat
* @param $showZero
* @param $showTime
* @param $showSeconds
* @return string
* @throws UserFormException
*/
public static function convertDateTime($dateTimeString, $dateFormat, $showZero, $showTime, $showSeconds) {
$givenDate = '';
$givenTime = '';
$newDate = '';
$newTime = '';
$delim = '';
$dateTimeString = trim($dateTimeString);
switch ($dateTimeString) {
case '':
case '0':
case '0000-00-00 00:00:00':
case '0000-00-00':
case '00:00:00':
return (self::dateTimeZero($dateFormat, $showZero, $showTime, $showSeconds));
break;
default:
break;
}
// Main convert
$arr = explode(' ', $dateTimeString);
switch (count($arr)) {
case 1:
if (strpos($dateTimeString, ':') === false) {
$givenDate = $dateTimeString;
} else {
$givenTime = $dateTimeString;
}
break;
case 2:
$givenDate = $arr[0];
$givenTime = $arr[1];
default:
}
// Date
if ($givenDate != '') {
if ($givenDate == '0')
$givenDate = '0000-00-00';
$arr = self::splitDateToArray($givenDate);
switch ($dateFormat) {
case FORMAT_DATE_INTERNATIONAL:
$newDate = sprintf("%04d-%02d-%02d", $arr[0], $arr[1], $arr[2]);
break;
case FORMAT_DATE_GERMAN:
$newDate = sprintf("%02d.%02d.%04d", $arr[2], $arr[1], $arr[0]);
default:
}
}
// Time
if ($givenTime != '') {
if ($givenTime == '0')
$givenTime = '0:0:0';
$arr = explode(':', $givenTime);
if (count($arr) < 3) {
$arr[2] = 0;
}
if ($showSeconds == 1) {
$newTime = sprintf("%02d:%02d:%02d", $arr[0], $arr[1], $arr[2]);
} else