Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
7215931f
Commit
7215931f
authored
Feb 08, 2018
by
Carsten Rose
Browse files
Merge branch '5308-timeIsOptional-parameter' into 'master'
5308 time is optional parameter See merge request
!35
parents
7365bbcd
c30f49bd
Changes
6
Show whitespace changes
Inline
Side-by-side
extension/Documentation/Manual.rst
View file @
7215931f
...
...
@@ -2453,6 +2453,9 @@ See also at specific *FormElement* definitions.
+
------------------------
+
--------
+
----------------------------------------------------------------------------------------------------------
+
|
showSeconds
|
string
|
0|1
-
Shows
the
seconds
on
form
load.
Default:
0
|
+
------------------------
+
--------
+
----------------------------------------------------------------------------------------------------------
+
|
timeIsOptional
|
string
|
0|1
-
Used
for
datetime
input.
0
(
default
)
:
Time
is
required
-
1
:
Entering
a
time
is
optional
|
|
|
|
(
defaults
to
00
:00:00
if
none
entered
).
|
+
------------------------
+
--------
+
----------------------------------------------------------------------------------------------------------
+
|
showZero
|
string
|
0|1
-
Empty
timestamp:
'0'(
default
)
-
nothing
shown
,
'1'
-
the
string
'0000
-00-00
00
:00:00
'
is
displayed
|
+
------------------------
+
--------
+
----------------------------------------------------------------------------------------------------------
+
|
retype
|
string
|
See
`
input-text
`
_
|
...
...
extension/qfq/qfq/AbstractBuildForm.php
View file @
7215931f
...
...
@@ -3144,8 +3144,7 @@ abstract class AbstractBuildForm {
$value
=
Support
::
convertDateTime
(
$value
,
$formElement
[
FE_DATE_FORMAT
],
$formElement
[
FE_SHOW_ZERO
],
$showTime
,
$formElement
[
FE_SHOW_SECONDS
]);
$tmpPattern
=
$formElement
[
FE_CHECK_PATTERN
];
$formElement
[
FE_CHECK_PATTERN
]
=
Support
::
dateTimeRegexp
(
$formElement
[
FE_TYPE
],
$formElement
[
FE_DATE_FORMAT
]);
$formElement
[
FE_CHECK_PATTERN
]
=
Support
::
dateTimeRegexp
(
$formElement
[
FE_TYPE
],
$formElement
[
FE_DATE_FORMAT
],
$formElement
[
FE_TIME_IS_OPTIONAL
]);
switch
(
$formElement
[
FE_CHECK_TYPE
])
{
case
SANITIZE_ALLOW_PATTERN
:
...
...
@@ -3187,6 +3186,7 @@ abstract class AbstractBuildForm {
$placeholder
=
$formElement
[
FE_DATE_FORMAT
];
break
;
case
'datetime'
:
if
(
$formElement
[
FE_TIME_IS_OPTIONAL
]
==
1
)
$timePattern
=
"[
$timePattern
]"
;
$placeholder
=
$formElement
[
FE_DATE_FORMAT
]
.
' '
.
$timePattern
;
break
;
case
'time'
:
...
...
extension/qfq/qfq/Constants.php
View file @
7215931f
...
...
@@ -860,6 +860,7 @@ const FE_PLACEHOLDER = 'placeholder';
const
FE_DATE_FORMAT
=
'dateFormat'
;
// value: FORMAT_DATE_INTERNATIONAL | FORMAT_DATE_GERMAN
const
FE_DECIMAL_FORMAT
=
'decimalFormat'
;
// value: 10,2
const
FE_SHOW_SECONDS
=
'showSeconds'
;
// value: 0|1
const
FE_TIME_IS_OPTIONAL
=
'timeIsOptional'
;
// value: 0|1
const
FE_SHOW_ZERO
=
'showZero'
;
// 0|1 - Used for 'date/datime/time': in case of fe.value='0' shows corresponding '00-00-0000'|'00:00:00'
const
FE_HIDE_ZERO
=
'hideZero'
;
// 0|1 - In case of fe.value=0|'0', an empty string is shown.
const
FE_FILE_DESTINATION
=
'fileDestination'
;
// Target pathFilename for an uploaded file.
...
...
extension/qfq/qfq/helper/Sanitize.php
View file @
7215931f
extension/qfq/qfq/helper/Support.php
View file @
7215931f
...
...
@@ -258,9 +258,9 @@ class Support {
}
/**
* Search for the parameter $needle in $haystack. The arguments has to be sep
e
rated by ','.
* Search for the parameter $needle in $haystack. The arguments has to be sep
a
rated by ','.
*
* Returns false if not found or index of found place. Be careful
l
: use unary operator to compare for 'false'
* Returns false if not found or index of found place. Be careful: use unary operator to compare for 'false'
*
* @param string $needle
* @param string $haystack
...
...
@@ -367,11 +367,12 @@ class Support {
/**
* @param string $type date | datetime | time
* @param string $format FORMAT_DATE_INTERNATIONAL | FORMAT_DATE_GERMAN
* @param string $timeIsOptional
*
* @return string
* @throws UserFormException
*/
public
static
function
dateTimeRegexp
(
$type
,
$format
)
{
public
static
function
dateTimeRegexp
(
$type
,
$format
,
$timeIsOptional
=
'0'
)
{
if
(
$format
===
FORMAT_DATE_GERMAN
)
{
// yyyy-mm-dd | 0000-00-00
...
...
@@ -389,6 +390,9 @@ class Support {
$pattern
=
$date
;
break
;
case
'datetime'
:
if
(
$timeIsOptional
==
'1'
)
$pattern
=
$date
.
'( '
.
$time
.
')?'
;
else
$pattern
=
$date
.
' '
.
$time
;
break
;
case
'time'
:
...
...
@@ -721,6 +725,7 @@ class Support {
// Some Defaults
self
::
setIfNotSet
(
$formElement
,
FE_SHOW_SECONDS
,
'0'
);
self
::
setIfNotSet
(
$formElement
,
FE_TIME_IS_OPTIONAL
,
'0'
);
self
::
setIfNotSet
(
$formElement
,
FE_SHOW_ZERO
,
'0'
);
self
::
setIfNotSet
(
$formElement
,
FE_HIDE_ZERO
,
'0'
);
self
::
setIfNotSet
(
$formElement
,
FE_DATE_FORMAT
,
$store
->
getVar
(
SYSTEM_DATE_FORMAT
,
STORE_SYSTEM
));
...
...
extension/qfq/qfq/store/FillStoreForm.php
View file @
7215931f
...
...
@@ -312,7 +312,7 @@ class FillStoreForm {
*/
public
function
doDateTime
(
array
&
$formElement
,
$value
)
{
$regexp
=
Support
::
dateTimeRegexp
(
$formElement
[
FE_TYPE
],
$formElement
[
FE_DATE_FORMAT
]);
$regexp
=
Support
::
dateTimeRegexp
(
$formElement
[
FE_TYPE
],
$formElement
[
FE_DATE_FORMAT
]
,
$formElement
[
FE_TIME_IS_OPTIONAL
]
);
if
(
1
!==
preg_match
(
'/'
.
$regexp
.
'/'
,
$value
,
$matches
))
{
$placeholder
=
Support
::
getDateTimePlaceholder
(
$formElement
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment