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
4b6bd660
Commit
4b6bd660
authored
Nov 24, 2019
by
Carsten Rose
Browse files
Add param 'L' & 'type' automatically to form save
parent
0bb8694b
Pipeline
#2761
passed with stages
in 4 minutes and 30 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/Classes/Api/save.php
View file @
4b6bd660
...
...
@@ -12,7 +12,8 @@ require_once(__DIR__ . '/../../vendor/autoload.php');
use
IMATHUZH\Qfq\Core\QuickFormQuery
;
use
IMATHUZH\Qfq\Core\Store\Store
;
use
IMATHUZH\Qfq\Core\Helper\Support
;
/**
...
...
@@ -64,7 +65,7 @@ try {
$arr
=
$qfq
->
getForwardMode
();
$answer
[
API_REDIRECT
]
=
$arr
[
API_REDIRECT
];
$answer
[
API_REDIRECT_URL
]
=
$arr
[
API_REDIRECT_URL
];
$answer
[
API_REDIRECT_URL
]
=
Support
::
appendTypo3ParameterToUrl
(
$arr
[
API_REDIRECT_URL
]
)
;
$answer
[
API_STATUS
]
=
API_ANSWER_STATUS_SUCCESS
;
$answer
[
API_MESSAGE
]
=
'Saved'
;
...
...
extension/Classes/Core/Helper/Support.php
View file @
4b6bd660
...
...
@@ -8,7 +8,7 @@
namespace
IMATHUZH\Qfq\Core\Helper
;
use
IMATHUZH\Qfq\Core\Store\Store
;
const
LONG_CURLY_OPEN
=
'#/+open+/#'
;
...
...
@@ -55,6 +55,44 @@ class Support {
}
}
/**
* Check $uri if 'type' and/or 'L' is missing. If yes, append it.
*
* Do nothing if $uri is empty.
* Do nothing if $uri is absolute (=starts with http)
*
* @param $uri
* @return string
* @throws \CodeException
* @throws \UserFormException
*/
public
static
function
appendTypo3ParameterToUrl
(
$uri
)
{
if
(
$uri
==
''
)
{
return
''
;
}
// Full URL: no processing
$protocol
=
explode
(
':'
,
$uri
,
2
);
if
(
$protocol
[
0
]
==
'http'
||
$protocol
[
0
]
==
'https'
)
{
return
$uri
;
}
$arr
=
KeyValueStringParser
::
parse
(
$uri
,
'='
,
'&'
);
$type
=
self
::
$store
->
getVar
(
TYPO3_PAGE_TYPE
,
STORE_TYPO3
);
$language
=
self
::
$store
->
getVar
(
TYPO3_PAGE_LANGUAGE
,
STORE_TYPO3
);
if
(
$type
!=
0
&&
$type
!==
false
&&
!
isset
(
$arr
[
'type'
]))
{
$uri
.
=
'&type='
.
$type
;
}
if
(
$language
!=
0
&&
$language
!==
false
&&
!
isset
(
$arr
[
'L'
]))
{
$uri
.
=
'&L='
.
$language
;
}
return
$uri
;
}
/**
* Build the form log filename. Depending on $formLog=FORM_LOG_ALL one file for all BE_USER, or $formLog=FORM_LOG_SESSION one file per BE_USER.
*
...
...
extension/Tests/Unit/Core/Helper/SupportTest.php
View file @
4b6bd660
...
...
@@ -67,6 +67,48 @@ class SupportTest extends TestCase {
}
/**
* @throws \CodeException
* @throws \UserFormException
* @throws \UserReportException
*/
public
function
testappendTypo3ParameterUrl
()
{
$this
->
assertEquals
(
''
,
Support
::
appendTypo3ParameterToUrl
(
''
));
$this
->
assertEquals
(
'http://example.com'
,
Support
::
appendTypo3ParameterToUrl
(
'http://example.com'
));
$this
->
assertEquals
(
'https://example.com'
,
Support
::
appendTypo3ParameterToUrl
(
'https://example.com'
));
$this
->
store
->
setVar
(
TYPO3_PAGE_ID
,
1
,
STORE_TYPO3
,
true
);
$this
->
store
->
setVar
(
TYPO3_PAGE_TYPE
,
0
,
STORE_TYPO3
,
true
);
$this
->
store
->
setVar
(
TYPO3_PAGE_LANGUAGE
,
0
,
STORE_TYPO3
,
true
);
// Kein type, L
$url
=
'?id=1'
;
$this
->
assertEquals
(
$url
,
Support
::
appendTypo3ParameterToUrl
(
$url
));
$url
=
'?id=1&type=0'
;
$this
->
assertEquals
(
$url
,
Support
::
appendTypo3ParameterToUrl
(
$url
));
$url
=
'?id=1&type=1'
;
$this
->
assertEquals
(
$url
,
Support
::
appendTypo3ParameterToUrl
(
$url
));
$url
=
'?id=1&L=0'
;
$this
->
assertEquals
(
$url
,
Support
::
appendTypo3ParameterToUrl
(
$url
));
$url
=
'?id=1&L=1'
;
$this
->
assertEquals
(
$url
,
Support
::
appendTypo3ParameterToUrl
(
$url
));
// type und L given
$this
->
store
->
setVar
(
TYPO3_PAGE_TYPE
,
2
,
STORE_TYPO3
,
true
);
$this
->
store
->
setVar
(
TYPO3_PAGE_LANGUAGE
,
3
,
STORE_TYPO3
,
true
);
$url
=
'?id=1'
;
$this
->
assertEquals
(
$url
.
'&type=2&L=3'
,
Support
::
appendTypo3ParameterToUrl
(
$url
));
$url
=
'?id=1&type=2'
;
$this
->
assertEquals
(
$url
.
'&L=3'
,
Support
::
appendTypo3ParameterToUrl
(
$url
));
$url
=
'?id=1&L=3'
;
$this
->
assertEquals
(
$url
.
'&type=2'
,
Support
::
appendTypo3ParameterToUrl
(
$url
));
}
public
function
testGetFormLogFileName
()
{
// TBD
$this
->
assertEquals
(
1
,
1
);
...
...
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