Skip to content
GitLab
Menu
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
6d8d731e
Commit
6d8d731e
authored
Sep 15, 2017
by
Carsten Rose
Browse files
Feature #4511 / Form: URL Forward - mode dynamic computed - more generic implementation.
parent
64c46a59
Changes
2
Hide whitespace changes
Inline
Side-by-side
extension/Documentation/Manual.rst
View file @
6d8d731e
...
...
@@ -1753,41 +1753,58 @@ Display or hide the button `new`, `delete`, `close`, `save`.
Forward: Save / Close
^^^^^^^^^^^^^^^^^^^^^
Forward
'''''''
Forward
(=forwardMode)
'''''''
'''''''''''''''
After the user presses *Save*, *Close*, *Delete* or *New*, different actions are possible where the browser redirects to.
* `client` (default) - the QFQ Javascript logic,
inside the browser,
decides to stay on the page or to force a redirection
* `client` (default) - the QFQ
browser
Javascript logic, decides to stay on the page or to force a redirection
to a previous page.
* *Close* closes the current page and goes back to the previous page.
* *Close* closes the current page and goes back to the previous page. Note: if a new tab is opened and the user presses
QFQ close (in any way) - in that new browser tab there is no previous page! QFQ won't close the tab, instead a message
is shown
* *Save* stays on the current page.
* `no` - no change, the browser remains on the current side. Close does not close the page. It just triggers a save if
there are modified data.
* `url` - the browser redirects to the
named
URL or T3 page. Independent if the user presses `save` or `close`.
* `url` - the browser redirects to the URL or T3 page
named in `Forward URL / Page`
. Independent if the user presses `save` or `close`.
* `url-skip-history` - same as `url`, but the current location won't saved in the browser history.
Only with `Forward` == `url` | `url-skip-history`, the definition of `Forward URL / Page` becomes active.
Forward URL / Page
''''''''''''''''''
Forward URL / Page
(=forwardPage)
''''''''''''''''''
'''''''''''''''
Type: dynamic URL/Page
^^^^^^^^^^^^^^^^^^^^^^
Format: [<url>] or [<mode>|<url>]
* `forwardPage=http://john-doe.com` - fix URL.
* `forwardPage=?thanks` - fix Typo3 alias or page id, inside current Typo3 installation.
* `forwardPage=?id=thanks` - same as above, but more complete notation.
* `forwardPage={{SELECT ... }}` - dynamically calculated, after all processing is done. This is very usefull, to redirect to different
targets, depending on user input or other dependency/ies.
* `<url>`:
Type: dynamic Mode
^^^^^^^^^^^^^^^^^^
* `http://www.example.com/index.html?a=123#bottom`
* `website.html?a=123#bottom`
* `?<T3 Alias pageid>&a=123#bottom, ?id=<T3 page id>&a=123#bottom`
* `{{SELECT ...}}`
* `<mode>|<url>`
* `<mode>` - Valid keywords are as above: `no|client|url|url-skip-history`
Specifying the mode in `forwardPage` overwrites `formMode` (but only if `formMode` is `url...`).
Also regular QFQ statements like {{var}} or {{SELECT ...}} are possible in `forwardPage`. This is useful to dynamically
redirect to different targets, depending on user input or any other dependencies.
If a forwardMode 'url...' is specified and there is no `forwardPage`, QFQ falls down to `client` mode.
On a form, the user might click 'save' or 'save,close' or 'close' (with modified data this leads to 'save,close').
The CLIENT `submit_reason` shows the user action:
* `{{submit_reason:CE:alnumx}}`='save' or 'save,close'
Example forwardPage
^^^^^^^^^^^^^^^^^^^
*
Specify in `forwardPage` any of the forward modes: `forwardPage=no | client | url | url-skip-history`,
*
Or vua an SQL statement: `forwardPage={{SELECT IF('{{formModeGlobal:S
:anumx
)
}}'='
requiredOff', 'no', 'client')
}}`
*
`{{SELECT IF('{{formModeGlobal:S:anumx}}'='requiredOff', 'no', 'client') }}`
*
`{{SELECT IF('{{submit_reason:CE
:a
l
numx}}'='
save', 'no', 'url'), '|http://example.com'
}}`
Type: combined dynamic mode & URL/page
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
...
extension/qfq/qfq/QuickFormQuery.php
View file @
6d8d731e
...
...
@@ -168,21 +168,7 @@ class QuickFormQuery {
*/
public
function
getForwardMode
()
{
$forwardPage
=
$this
->
eval
->
parse
(
$this
->
formSpec
[
F_FORWARD_PAGE
]);
// Format: [mode/url][|url]
$forwardArray
=
explode
(
'|'
,
$forwardPage
,
2
);
switch
(
$forwardArray
[
0
])
{
case
F_FORWARD_MODE_CLIENT
:
case
F_FORWARD_MODE_NO
:
case
F_FORWARD_MODE_URL
:
case
F_FORWARD_MODE_URL_SKIP_HISTORY
:
case
F_FORWARD_MODE_URL_SIP
:
$this
->
formSpec
[
F_FORWARD_MODE
]
=
$forwardArray
[
0
];
if
(
isset
(
$forwardArray
[
1
]))
{
$forwardPage
=
$forwardArray
[
1
];
}
}
$forwardPage
=
$this
->
formSpec
[
F_FORWARD_PAGE
];
if
(
$this
->
formSpec
[
F_FORWARD_MODE
]
==
F_FORWARD_MODE_URL_SIP
)
{
$forwardPage
=
store
::
getSipInstance
()
->
queryStringToSip
(
$forwardPage
,
RETURN_URL
);
...
...
@@ -409,23 +395,25 @@ class QuickFormQuery {
$formAction
->
elements
(
$rc
,
$this
->
feSpecAction
,
FE_TYPE_SENDMAIL
);
$getJson
=
true
;
// Retrieve current STORE_SIP.
$sipArray
=
$this
->
store
->
getStore
(
STORE_SIP
);
if
(
$sipArray
[
SIP_RECORD_ID
]
==
0
&&
API_SUBMIT_REASON_SAVE
==
$this
->
store
->
getVar
(
API_SUBMIT_REASON
,
STORE_CLIENT
.
STORE_EMPTY
,
SANITIZE_ALLOW_ALNUMX
))
{
if
(
$this
->
formSpec
[
F_FORWARD_MODE
]
!==
F_FORWARD_MODE_URL
&&
$this
->
formSpec
[
F_FORWARD_MODE
]
!==
F_FORWARD_MODE_URL_SKIP_HISTORY
&&
$this
->
formSpec
[
F_FORWARD_MODE
]
!==
F_FORWARD_MODE_URL_SIP
)
{
$this
->
formSpec
=
$this
->
buildNSetReloadUrl
(
$this
->
formSpec
,
$rc
);
}
$customForward
=
$this
->
setForwardModePage
();
// Logic: If a) r=0 and
// b) User presses only 'save' (not save & close) and
// c) there is no forwardMode=='url...'
// then the client should reload the current page with the newly created record. A new SIP is necessary!
if
(
0
==
$this
->
store
->
getVar
(
SIP_RECORD_ID
,
STORE_SIP
)
&&
API_SUBMIT_REASON_SAVE
==
$this
->
store
->
getVar
(
API_SUBMIT_REASON
,
STORE_CLIENT
.
STORE_EMPTY
,
SANITIZE_ALLOW_ALNUMX
)
&&
$customForward
==
false
)
{
$this
->
formSpec
=
$this
->
buildNSetReloadUrl
(
$this
->
formSpec
,
$rc
);
$getJson
=
false
;
}
if
(
$getJson
)
{
// Retrieve FE Values as JSON
// $data['form-update']=...
//
$data = $build->process($formMode, $htmlElementNameIdZero);
//
$data = $build->process($formMode, $htmlElementNameIdZero);
$data
=
$build
->
process
(
$formMode
);
}
break
;
...
...
@@ -442,6 +430,72 @@ class QuickFormQuery {
return
$data
;
}
/**
* Check if forwardMode='url...'.
* yes: process 'forwardPage' and fill $this->formSpec[F_FORWARD_MODE] and $this->formSpec[F_FORWARD_PAGE]
* no: do nothing
*
* '$this->formSpec[F_FORWARD_PAGE]' might give a new forwardMode. If so, set $this->formSpec[F_FORWARD_MODE] to
* it.
*
* '$this->formSpec[F_FORWARD_PAGE]':
* a) url http://www.nzz.ch/index.html?a=123#bottom, website.html?a=123#bottom,
* ?<T3 Alias pageid>&a=123#bottom, ?id=<T3 page id>&a=123#bottom
* b) mode no|client|url|...
* c) mode|url combination of above
*
* @return bool TRUE if F_FORWARD_MODE = 'url..', else FALSE
*
* @throws UserFormException
*/
private
function
setForwardModePage
()
{
if
(
'url'
!=
substr
(
$this
->
formSpec
[
F_FORWARD_MODE
],
0
,
3
))
{
return
false
;
}
$forwardPageTmp
=
$this
->
eval
->
parse
(
$this
->
formSpec
[
F_FORWARD_PAGE
]);
// Format: [mode/url][|url]
$forwardArray
=
explode
(
'|'
,
$forwardPageTmp
,
2
);
$forward
=
trim
(
$forwardArray
[
0
]);
switch
(
$forward
)
{
case
F_FORWARD_MODE_CLIENT
:
case
F_FORWARD_MODE_NO
:
case
F_FORWARD_MODE_URL
:
case
F_FORWARD_MODE_URL_SKIP_HISTORY
:
case
F_FORWARD_MODE_URL_SIP
:
$this
->
formSpec
[
F_FORWARD_MODE
]
=
$forward
;
if
(
isset
(
$forwardArray
[
1
]))
{
$this
->
formSpec
[
F_FORWARD_PAGE
]
=
trim
(
$forwardArray
[
1
]);
}
else
{
$this
->
formSpec
[
F_FORWARD_PAGE
]
=
''
;
}
break
;
default
:
$this
->
formSpec
[
F_FORWARD_PAGE
]
=
$forward
;
break
;
}
if
(
'url'
==
substr
(
$this
->
formSpec
[
F_FORWARD_MODE
],
0
,
3
))
{
if
(
$this
->
formSpec
[
F_FORWARD_PAGE
]
==
''
)
{
$this
->
formSpec
[
F_FORWARD_MODE
]
=
F_FORWARD_MODE_CLIENT
;
$customForward
=
false
;
}
else
{
$customForward
=
true
;
}
}
else
{
$customForward
=
false
;
}
return
$customForward
;
}
/**
* Iterate over all Clipboard source records and fire for each all FE.type=paste records.
*
...
...
Write
Preview
Supports
Markdown
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