Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
af38970b
Commit
af38970b
authored
Jun 30, 2019
by
Carsten Rose
Browse files
Merge remote-tracking branch 'origin/master'
parents
72e16b77
6c276cf5
Pipeline
#2068
passed with stages
in 2 minutes and 39 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Documentation/Manual.rst
View file @
af38970b
...
...
@@ -2518,6 +2518,8 @@ Parameter
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| maxFileSize | int | Overwrite default from configuration_ . |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| requiredPosition | int | See requiredPosition_ . |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
* Example:
...
...
@@ -3029,6 +3031,8 @@ See also at specific *FormElement* definitions.
| messageFail | string | |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| dataReference | string | Optional. See `applicationTest`_ |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| requiredPosition | int | See requiredPosition_ . |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
...
...
@@ -3092,6 +3096,21 @@ extraButtonInfo
* For `FormElement` with mode `below`, a `span` element with the given class in `extraButtonInfoClass` (FE, F, configuration_)
will be applied. E.g. this might be `pull-right` to align the `info` button/icon on the right side below the input element.
.. _`requiredPosition`:
Required Position
^^^^^^^^^^^^^^^^^
By default, input elements with `Mode=required` will be displayed with a 'red asterix' right beside the label. The position
of the 'red asterix' can be choosen via the `parameter` field::
requiredPosition = label-left|label-right|input-left|input-right|note-left|note-right
The default is 'label-right'.
The definition can be set per Form (=affects all FormElements) or per FormElement.
.. _`input-checkbox`:
Type: checkbox
...
...
extension/Classes/Core/AbstractBuildForm.php
View file @
af38970b
...
...
@@ -8,19 +8,19 @@
namespace
IMATHUZH\Qfq\Core
;
use
IMATHUZH\Qfq\Core\Helper\Support
;
use
IMATHUZH\Qfq\Core\Store\Sip
;
use
IMATHUZH\Qfq\Core\Store\Store
;
use
IMATHUZH\Qfq\Core\Database\Database
;
use
IMATHUZH\Qfq\Core\Helper\HelperFile
;
use
IMATHUZH\Qfq\Core\Helper\HelperFormElement
;
use
IMATHUZH\Qfq\Core\Helper\
OnArray
;
use
IMATHUZH\Qfq\Core\Helper\
KeyValueStringParser
;
use
IMATHUZH\Qfq\Core\Helper\Ldap
;
use
IMATHUZH\Qfq\Core\Helper\Logger
;
use
IMATHUZH\Qfq\Core\Helper\KeyValueStringParser
;
use
IMATHUZH\Qfq\Core\Report\Link
;
use
IMATHUZH\Qfq\Core\Helper\OnArray
;
use
IMATHUZH\Qfq\Core\Helper\Sanitize
;
use
IMATHUZH\Qfq\Core\Helper\HelperFile
;
use
IMATHUZH\Qfq\Core\Helper\Support
;
use
IMATHUZH\Qfq\Core\Report\Link
;
use
IMATHUZH\Qfq\Core\Report\Report
;
use
IMATHUZH\Qfq\Core\Store\Sip
;
use
IMATHUZH\Qfq\Core\Store\Store
;
/**
* Class AbstractBuildForm
...
...
@@ -958,6 +958,7 @@ abstract class AbstractBuildForm {
* @throws \UserFormException
*/
private
function
getFormElementForJson
(
$htmlFormElementName
,
$value
,
array
$formElement
)
{
$addClassRequired
=
array
();
$json
=
$this
->
getJsonFeMode
(
$formElement
[
FE_MODE
]);
// disabled, required
...
...
@@ -984,14 +985,20 @@ abstract class AbstractBuildForm {
// }
}
if
(
$formElement
[
FE_MODE
]
==
FE_MODE_REQUIRED
||
$formElement
[
FE_MODE
]
==
FE_MODE_SHOW_REQUIRED
)
{
$addClassRequired
=
HelperFormElement
::
getRequiredPositionClass
(
$formElement
[
F_FE_REQUIRED_POSITION
]);
}
if
(
isset
(
$formElement
[
FE_LABEL
]))
{
$key
=
$formElement
[
FE_HTML_ID
]
.
HTML_ID_EXTENSION_LABEL
;
$addClass
=
(
$formElement
[
FE_MODE
]
==
FE_MODE_REQUIRED
||
$formElement
[
FE_MODE
]
==
FE_MODE_SHOW_REQUIRED
)
?
CSS_REQUIRED
:
''
;
$json
[
API_ELEMENT_UPDATE
][
$key
][
API_ELEMENT_CONTENT
]
=
$this
->
buildLabel
(
$htmlFormElementName
,
$formElement
[
FE_LABEL
],
$addClass
);
$json
[
API_ELEMENT_UPDATE
][
$key
][
API_ELEMENT_CONTENT
]
=
$this
->
buildLabel
(
$htmlFormElementName
,
$formElement
[
FE_LABEL
],
$addClassRequired
[
FE_LABEL
]
??
''
);
}
if
(
isset
(
$formElement
[
FE_NOTE
]))
{
$key
=
$formElement
[
FE_HTML_ID
]
.
HTML_ID_EXTENSION_NOTE
;
if
(
!
empty
(
$addClassRequired
[
FE_NOTE
]))
{
$formElement
[
FE_NOTE
]
=
Support
::
wrapTag
(
'<span class="'
.
$addClassRequired
[
FE_NOTE
]
.
'">'
,
$formElement
[
FE_NOTE
]);
}
$json
[
API_ELEMENT_UPDATE
][
$key
][
API_ELEMENT_CONTENT
]
=
$formElement
[
FE_NOTE
];
}
...
...
@@ -1041,6 +1048,10 @@ abstract class AbstractBuildForm {
$class
.
=
' hidden'
;
}
if
(
!
empty
(
$addClassRequired
[
FE_INPUT
]))
{
$class
.
=
' '
.
$addClassRequired
[
FE_INPUT
];
}
$key
=
$formElement
[
FE_HTML_ID
]
.
HTML_ID_EXTENSION_ROW
;
$json
[
API_ELEMENT_UPDATE
][
$key
][
API_ELEMENT_ATTRIBUTE
][
'class'
]
=
$class
;
}
...
...
extension/Classes/Core/BuildFormBootstrap.php
View file @
af38970b
...
...
@@ -8,11 +8,11 @@
namespace
IMATHUZH\Qfq\Core
;
use
IMATHUZH\Qfq\Core\Helper\HelperFormElement
;
use
IMATHUZH\Qfq\Core\Helper\Logger
;
use
IMATHUZH\Qfq\Core\Helper\OnArray
;
use
IMATHUZH\Qfq\Core\Helper\Support
;
use
IMATHUZH\Qfq\Core\Helper\HelperFormElement
;
/**
* Class BuildFormBootstrap
...
...
@@ -728,6 +728,7 @@ EOF;
$htmlLabel
=
''
;
$classHideRow
=
''
;
$classHideElement
=
''
;
$addClassRequired
=
array
();
if
(
$formElement
[
FE_MODE
]
==
FE_MODE_HIDDEN
)
{
if
(
$formElement
[
FE_FLAG_ROW_OPEN_TAG
]
&&
$formElement
[
FE_FLAG_ROW_CLOSE_TAG
])
{
...
...
@@ -737,23 +738,32 @@ EOF;
}
}
if
(
$formElement
[
FE_MODE
]
==
FE_MODE_REQUIRED
||
$formElement
[
FE_MODE
]
==
FE_MODE_SHOW_REQUIRED
)
{
$addClassRequired
=
HelperFormElement
::
getRequiredPositionClass
(
$formElement
[
F_FE_REQUIRED_POSITION
]);
}
// Label
if
(
$formElement
[
FE_BS_LABEL_COLUMNS
]
!=
'0'
)
{
$addClass
=
(
$formElement
[
FE_MODE
]
==
FE_MODE_REQUIRED
||
$formElement
[
FE_MODE
]
==
FE_MODE_SHOW_REQUIRED
)
?
CSS_REQUIRED
:
''
;
$htmlLabel
=
$this
->
buildLabel
(
$htmlFormElementName
,
$formElement
[
FE_LABEL
],
$addClass
);
$htmlLabel
=
$this
->
buildLabel
(
$htmlFormElementName
,
$formElement
[
FE_LABEL
],
$addClassRequired
[
FE_LABEL
]
??
''
);
}
$html
.
=
$this
->
customWrap
(
$formElement
,
$htmlLabel
,
FE_WRAP_LABEL
,
$formElement
[
FE_BS_LABEL_COLUMNS
],
[
$this
->
wrap
[
WRAP_SETUP_LABEL
][
WRAP_SETUP_START
],
$this
->
wrap
[
WRAP_SETUP_LABEL
][
WRAP_SETUP_END
]],
$formElement
[
FE_HTML_ID
]
.
HTML_ID_EXTENSION_LABEL
);
// Input
if
(
!
empty
(
$addClassRequired
[
FE_INPUT
]))
{
$htmlElement
=
Support
::
wrapTag
(
'<span class="'
.
$addClassRequired
[
FE_INPUT
]
.
'">'
,
$htmlElement
);
}
$html
.
=
$this
->
customWrap
(
$formElement
,
$htmlElement
,
FE_WRAP_INPUT
,
$formElement
[
FE_BS_INPUT_COLUMNS
],
[
$this
->
wrap
[
WRAP_SETUP_INPUT
][
WRAP_SETUP_START
],
$this
->
wrap
[
WRAP_SETUP_INPUT
][
WRAP_SETUP_END
]],
$formElement
[
FE_HTML_ID
]
.
HTML_ID_EXTENSION_INPUT
,
$classHideElement
);
if
(
!
empty
(
$addClassRequired
[
FE_NOTE
]))
{
$formElement
[
FE_NOTE
]
=
Support
::
wrapTag
(
'<span class="'
.
$addClassRequired
[
FE_NOTE
]
.
'">'
,
$formElement
[
FE_NOTE
]);
}
// Note
$note
=
$formElement
[
FE_NOTE
];
$html
.
=
$this
->
customWrap
(
$formElement
,
$note
,
FE_WRAP_NOTE
,
$formElement
[
FE_BS_NOTE_COLUMNS
],
$html
.
=
$this
->
customWrap
(
$formElement
,
$formElement
[
FE_NOTE
],
FE_WRAP_NOTE
,
$formElement
[
FE_BS_NOTE_COLUMNS
],
[
$this
->
wrap
[
WRAP_SETUP_NOTE
][
WRAP_SETUP_START
],
$this
->
wrap
[
WRAP_SETUP_NOTE
][
WRAP_SETUP_END
]],
$formElement
[
FE_HTML_ID
]
.
HTML_ID_EXTENSION_NOTE
);
// Row
...
...
extension/Classes/Core/Constants.php
View file @
af38970b
...
...
@@ -674,7 +674,8 @@ const DOWNLOAD_POPUP_REPLACE_TITLE = '#downloadPopupReplaceTitle#';
const
SYSTEM_DRAG_AND_DROP_JS
=
'hasDragAndDropJS'
;
const
SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME
=
'parameterLanguageFieldName'
;
const
CSS_REQUIRED
=
'required-field'
;
const
CSS_REQUIRED_RIGHT
=
'required-right'
;
const
CSS_REQUIRED_LEFT
=
'required-left'
;
// die folgenden Elemente sind vermutlich nicht noetig, wenn Store Klassen globale Vars benutzt.
//const SYSTEM_FORM_DEF = 'formDefinition'; // Type: SANITIZE_ALNUMX / AssocArray. Final form to process. Useful for error reporting.
...
...
@@ -963,6 +964,13 @@ const F_FE_DATA_MATCH_ERROR_DEFAULT = 'Fields do not match'; // Attention: the d
const
F_FE_LABEL_ALIGN
=
SYSTEM_LABEL_ALIGN
;
const
F_FE_LABEL_ALIGN_DEFAULT
=
'default'
;
const
F_FE_REQUIRED_POSITION
=
'requiredPosition'
;
const
F_FE_REQUIRED_POSITION_LABEL_LEFT
=
'label-left'
;
const
F_FE_REQUIRED_POSITION_LABEL_RIGHT
=
'label-right'
;
const
F_FE_REQUIRED_POSITION_INPUT_LEFT
=
'input-left'
;
const
F_FE_REQUIRED_POSITION_INPUT_RIGHT
=
'input-right'
;
const
F_FE_REQUIRED_POSITION_NOTE_LEFT
=
'note-left'
;
const
F_FE_REQUIRED_POSITION_NOTE_RIGHT
=
'note-right'
;
const
F_PARAMETER
=
'parameter'
;
// valid for F_ and FE_
...
...
@@ -1059,6 +1067,7 @@ const FE_VALUE = 'value';
const
FE_CLASS
=
'class'
;
const
FE_LABEL
=
'label'
;
const
FE_NOTE
=
'note'
;
const
FE_INPUT
=
'input'
;
const
FE_BS_LABEL_COLUMNS
=
F_BS_LABEL_COLUMNS
;
const
FE_BS_INPUT_COLUMNS
=
F_BS_INPUT_COLUMNS
;
const
FE_BS_NOTE_COLUMNS
=
F_BS_NOTE_COLUMNS
;
...
...
extension/Classes/Core/Database/Database.php
View file @
af38970b
...
...
@@ -851,7 +851,7 @@ class Database {
$feSpecNative
=
$this
->
sql
(
$sql
,
ROW_REGULAR
,
$param
);
$feSpecNative
=
HelperFormElement
::
formElementSetDefault
(
$feSpecNative
);
$feSpecNative
=
HelperFormElement
::
formElementSetDefault
(
$feSpecNative
,
$formSpec
);
// Explode and Do $FormElement.parameter
HelperFormElement
::
explodeParameterInArrayElements
(
$feSpecNative
,
FE_PARAMETER
);
...
...
extension/Classes/Core/Helper/HelperFormElement.php
View file @
af38970b
...
...
@@ -9,7 +9,7 @@
namespace
IMATHUZH\Qfq\Core\Helper
;
use
IMATHUZH\Qfq\Core\Store\Store
;
/**
* Class HelperFormElement
...
...
@@ -40,16 +40,20 @@ class HelperFormElement {
/**
* Set default values for given FormElement.
* Hint: to copy values from Form, copyAttributesToFormElements() is more appropriate.
*
* @param array $elements
*
* @param array $formSpec
* @return array
*/
public
static
function
formElementSetDefault
(
array
$elements
)
{
public
static
function
formElementSetDefault
(
array
$elements
,
array
$formSpec
)
{
foreach
(
$elements
AS
$key
=>
$element
)
{
$elements
[
$key
][
FE_TG_INDEX
]
=
0
;
unset
(
$elements
[
$key
][
FE_ADMIN_NOTE
]);
// $elements[$key][FE_DATA_REFERENCE] = '';
}
return
$elements
;
...
...
@@ -89,9 +93,11 @@ class HelperFormElement {
// For retype elements: copy the language specific value.
if
(
isset
(
$element
[
FE_RETYPE_SOURCE_NAME
]))
{
if
(
!
empty
(
$element
[
FE_RETYPE_LABEL
]))
{
$element
[
FE_LABEL
]
=
$element
[
FE_RETYPE_LABEL
];
}
if
(
!
empty
(
$element
[
FE_RETYPE_NOTE
]))
{
$element
[
FE_NOTE
]
=
$element
[
FE_RETYPE_NOTE
];
}
...
...
@@ -271,6 +277,7 @@ class HelperFormElement {
if
(
$feSpecNative
[
$key
][
F_FE_LABEL_ALIGN
]
==
F_FE_LABEL_ALIGN_DEFAULT
)
{
$feSpecNative
[
$key
][
F_FE_LABEL_ALIGN
]
=
$formSpec
[
F_FE_LABEL_ALIGN
];
}
Support
::
setIfNotSet
(
$feSpecNative
[
$key
],
F_FE_REQUIRED_POSITION
,
$formSpec
[
F_FE_REQUIRED_POSITION
]);
}
return
$feSpecNative
;
...
...
@@ -464,4 +471,41 @@ EOF;
return
json_encode
(
$rgb
);
}
/**
* Depending on value in $requiredPosition the array $classArr will contain the CSS class to align the required mark.
* @param $requiredPosition
* @return array
* @throws \UserFormException
*/
public
static
function
getRequiredPositionClass
(
$requiredPosition
)
{
$classArr
[
FE_LABEL
]
=
''
;
$classArr
[
FE_TYPE
]
=
''
;
$classArr
[
FE_NOTE
]
=
''
;
switch
(
$requiredPosition
)
{
case
F_FE_REQUIRED_POSITION_LABEL_LEFT
:
$classArr
[
FE_LABEL
]
=
CSS_REQUIRED_LEFT
;
break
;
case
F_FE_REQUIRED_POSITION_LABEL_RIGHT
:
$classArr
[
FE_LABEL
]
=
CSS_REQUIRED_RIGHT
;
break
;
case
F_FE_REQUIRED_POSITION_INPUT_LEFT
:
$classArr
[
FE_INPUT
]
=
CSS_REQUIRED_LEFT
;
break
;
case
F_FE_REQUIRED_POSITION_INPUT_RIGHT
:
$classArr
[
FE_INPUT
]
=
CSS_REQUIRED_RIGHT
;
break
;
case
F_FE_REQUIRED_POSITION_NOTE_LEFT
:
$classArr
[
FE_NOTE
]
=
CSS_REQUIRED_LEFT
;
break
;
case
F_FE_REQUIRED_POSITION_NOTE_RIGHT
:
$classArr
[
FE_NOTE
]
=
CSS_REQUIRED_RIGHT
;
break
;
default
:
throw
new
\
UserFormException
(
'Unkown value for '
.
F_FE_REQUIRED_POSITION
.
': '
.
$requiredPosition
,
ERROR_INVALID_VALUE
);
}
return
$classArr
;
}
}
\ No newline at end of file
extension/Classes/Core/QuickFormQuery.php
View file @
af38970b
...
...
@@ -1144,7 +1144,7 @@ class QuickFormQuery {
$feSpecNative
=
$this
->
dbArray
[
$this
->
dbIndexQfq
]
->
sql
(
$sql
,
ROW_REGULAR
,
$param
);
$feSpecNative
=
HelperFormElement
::
formElementSetDefault
(
$feSpecNative
);
$feSpecNative
=
HelperFormElement
::
formElementSetDefault
(
$feSpecNative
,
$formSpec
);
// Explode and Do $FormElement.parameter
HelperFormElement
::
explodeParameterInArrayElements
(
$feSpecNative
,
FE_PARAMETER
);
...
...
@@ -1403,6 +1403,7 @@ class QuickFormQuery {
Support
::
setIfNotSet
(
$formSpec
,
F_DB_INDEX
,
$this
->
store
->
getVar
(
F_DB_INDEX
,
STORE_SYSTEM
));
Support
::
setIfNotSet
(
$formSpec
,
F_ENTER_AS_SUBMIT
,
$this
->
store
->
getVar
(
SYSTEM_ENTER_AS_SUBMIT
,
STORE_SYSTEM
));
Support
::
setIfNotSet
(
$formSpec
,
F_SESSION_TIMEOUT_SECONDS
,
$this
->
store
->
getVar
(
SYSTEM_SESSION_TIMEOUT_SECONDS
,
STORE_SYSTEM
));
Support
::
setIfNotSet
(
$formSpec
,
F_FE_REQUIRED_POSITION
,
F_FE_REQUIRED_POSITION_LABEL_RIGHT
);
// In case there is no F_MODE defined on the form, check if there is one in STORE_SIP.
if
(
$formSpec
[
F_MODE
]
==
''
)
{
...
...
extension/Classes/Core/Report/Excel.php
View file @
af38970b
...
...
@@ -11,7 +11,6 @@
namespace
IMATHUZH\Qfq\Core\Report
;
use
IMATHUZH\Qfq\Core\Helper\HelperFile
;
require_once
__DIR__
.
'/../../../vendor/autoload.php'
;
use
PhpOffice\PhpSpreadsheet\Spreadsheet
;
use
PhpOffice\PhpSpreadsheet\Writer\Xlsx
;
...
...
extension/Tests/phpunit.md
View file @
af38970b
#
p
hpunit
#
P
hpunit
##
run unit tests from commandline
##
Setup
After running
`make bootstrap`
go to the extension folder and run:
Requirements for running the php unittests:
-
`make bootstrap`
was executed
-
The following files exist at the same location (either
`extension/`
or
`typo3conf/`
):
*
`config.qfq.php`
*
`LocalConfiguration.php`
-
The database credentials in
`config.qfq.php`
are correct
-
The database with the name
`DB_1_NAME`
followed by
`_phpunit`
exists. E.g.
`app_qfq_phpunit`
where
`DB_1_NAME=app_qfq`
In Tests/Unit/ you may find a mockup of
`LocalConfiguration.php`
and a template for
`config.qfq.php`
.
## Run unit tests from commandline
REMARK: Running the unit tests without specifying the configuration file
`phpunit.xml`
will not work. See section "Autoloader" for explanation.
From the extension folder run:
`vendor/bin/phpunit --configuration phpunit.xml`
##
p
hpunit configurations
##
P
hpunit configurations
Phpunit configurations are stored in extension/phpunit.xml
Running the tests without specifying these configurations will not work.
...
...
@@ -14,18 +30,11 @@ Running the tests without specifying these configurations will not work.
## Autoloader
The test classes use the composer autoloader to reference to the source classes.
The autoloader is loaded
in extension/Classes/bootstrap.php which in turn is executed
by phpunit before each test
as specified in phpunit.xml by the line
`<phpunit bootstrap="
Classes/bootstrap
.php">`
The autoloader is loaded by phpunit before each test
as specified in phpunit.xml by the line
`<phpunit bootstrap="
vendor/autoload
.php">`
##
r
un tests
on gitlab runner (i.e.
without typo3 installation)
##
R
un tests without typo3 installation
(e.g. gitlab runner
)
As defined in the phpunit command of projectRoot/Makefile.
The files phpunit_config.qfq.php and phpunit_LocalConfiguration.php are copied outside the extension since
they are necessary for the qfq bootstrap process.
## Database Setup
TODO
Needs existing database:
<name>
_phpunit
\ No newline at end of file
The files phpunit_config.qfq.php and phpunit_LocalConfiguration.php are copied outside the extension folder by the Makefile.
\ No newline at end of file
less/qfq-bs.css.less
View file @
af38970b
...
...
@@ -98,7 +98,7 @@ select.qfq-locked:invalid {
// margin-left: -10px;
//}
.required-
field
:after {
.required-
right
:after {
color: #d00;
content: "*";
//position: absolute;
...
...
@@ -106,6 +106,14 @@ select.qfq-locked:invalid {
//top: 10px;
}
.required-left:before {
color: #d00;
content: "*";
//position: absolute;
margin-right: 3px;
//top: 10px;
}
.qfq-table-50 {
min-width: 50%;
width: auto;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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