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
4899392a
Commit
4899392a
authored
Jan 15, 2019
by
Carsten Rose
Browse files
Fixes: #7647. Implement new token 'A' to add any custom attribute to '... AS _link'
parent
e3d5ae88
Pipeline
#1338
passed with stage
in 2 minutes and 3 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
extension/Documentation/Manual.rst
View file @
4899392a
...
...
@@ -5460,6 +5460,8 @@ Column: _link
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Class |c:[n|
<text>
] |c:text-muted |CSS class for link. n:no class attribute,
<text>
: explicit named |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Attribute |A:
<key>
="
<value
"
>
|A:data-selenium="person" |Custom attributes and a corresponding value. Might be used by Selenium tests. |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Target |g:
<text>
|g:_blank |target=_blank,_self,_parent,
<custom>
. Default: no target |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Question |q:
<text>
|q:please confirm |See: `question`_. Link will be executed only if user clicks ok/cancel, default: 'Please confirm' |
...
...
@@ -7517,11 +7519,23 @@ AutoCron / website: HTTPS protocol
Selenium
Test
=============
With
https
://
www
.seleniumhq.org
/
it
's possible to play automate test cases.
With
https
://
www
.seleniumhq.org
/
it
's possible to play and verify automate test cases. To simplify the process of automatically
identifying HTML elements, a tag might be assigned to elements which have to interact with the test framework.
Form
----
By default every FormElement contains an attribute '
data-selenium
=<
value
>
', whereas the '
<
value
>
' is either the name
of the FormElement or a custom value, defined via '
FormElement
.parameter.dataSelenium
=<
value
>
'.
Report
------
Any HTML output can be extended by a tag. For QFQ generated links, an attribute like '
data-selenium
' might be injected
via token '
A
' (attribute). ::
SELECT '
p
:personedit
&
form
=
person
&
r
=
1
|
b
|
s
|
A
:data-selenium
=
"person-edit"
|
t
:Edit
person
'
AS
_link
..
_help
:
...
...
extension/Source/core/Constants.php
View file @
4899392a
...
...
@@ -1527,6 +1527,7 @@ const TOKEN_RIGHT = 'R';
const
TOKEN_FILE
=
'F'
;
const
TOKEN_FILE_DEPRECATED
=
'f'
;
// since 5.12.17
const
TOKEN_DOWNLOAD_MODE
=
'M'
;
const
TOKEN_ATTRIBUTE
=
'A'
;
const
TOKEN_THUMBNAIL
=
'T'
;
const
TOKEN_THUMBNAIL_DIMENSION
=
'W'
;
...
...
extension/Source/core/report/Link.php
View file @
4899392a
...
...
@@ -34,6 +34,7 @@ require_once(__DIR__ . '/Thumbnail.php');
/*
* a:AltText
* A:Attribute
* b:bootstrap [0|1|<button>]
* B:bullet
* c:class [n|i|e|<class>]
...
...
@@ -103,6 +104,7 @@ const NAME_THUMBNAIL = 'thumbnail';
const
NAME_THUMBNAIL_DIMENSION
=
'thumbnailDimension'
;
const
NAME_COPY_TO_CLIPBOARD
=
'copyToClipBoard'
;
const
NAME_MONITOR
=
'monitor'
;
const
NAME_ATTRIBUTE
=
'attribute'
;
const
FINAL_HREF
=
'finalHref'
;
const
FINAL_ANCHOR
=
'finalAnchor'
;
...
...
@@ -221,6 +223,7 @@ class Link {
TOKEN_THUMBNAIL
=>
NAME_THUMBNAIL
,
TOKEN_THUMBNAIL_DIMENSION
=>
NAME_THUMBNAIL_DIMENSION
,
TOKEN_COPY_TO_CLIPBOARD
=>
NAME_COPY_TO_CLIPBOARD
,
TOKEN_ATTRIBUTE
=>
NAME_ATTRIBUTE
,
TOKEN_MONITOR
=>
NAME_MONITOR
,
// The following don't need a renaming: already 'long'
...
...
@@ -351,11 +354,14 @@ class Link {
private
function
wrapLinkTextOnly
(
array
$vars
,
$keyName
)
{
$text
=
$vars
[
$keyName
];
if
(
$vars
[
NAME_BOOTSTRAP_BUTTON
]
==
''
&&
$vars
[
FINAL_TOOL_TIP
]
==
''
)
{
if
(
$vars
[
NAME_BOOTSTRAP_BUTTON
]
==
''
&&
$vars
[
FINAL_TOOL_TIP
]
==
''
&&
$vars
[
NAME_ATTRIBUTE
]
==
''
)
{
return
$text
;
}
$attributes
=
Support
::
doAttribute
(
'title'
,
$vars
[
FINAL_TOOL_TIP
]);
if
(
$vars
[
NAME_ATTRIBUTE
]
!=
''
)
{
$attributes
.
=
$vars
[
NAME_ATTRIBUTE
]
.
' '
;
}
if
(
$vars
[
NAME_BOOTSTRAP_BUTTON
]
!=
''
)
{
$attributes
.
=
Support
::
doAttribute
(
'class'
,
[
$vars
[
NAME_BOOTSTRAP_BUTTON
],
'disabled'
]);
...
...
@@ -1128,6 +1134,9 @@ EOF;
$attributes
.
=
Support
::
doAttribute
(
'class'
,
$vars
[
FINAL_CLASS
]);
$attributes
.
=
Support
::
doAttribute
(
'target'
,
$vars
[
NAME_TARGET
]);
$attributes
.
=
Support
::
doAttribute
(
'title'
,
$vars
[
FINAL_TOOL_TIP
]);
if
(
$vars
[
NAME_ATTRIBUTE
]
!=
''
)
{
$attributes
.
=
$vars
[
NAME_ATTRIBUTE
]
.
' '
;
}
$attributes
.
=
$vars
[
FINAL_QUESTION
];
$anchor
=
'<a '
.
$attributes
.
'>'
;
...
...
@@ -1460,7 +1469,7 @@ EOF;
if
(
$vars
[
NAME_COPY_TO_CLIPBOARD
]
!==
''
)
{
$jsAction
=
'onClick'
;
// Take care that ' and " are properly escaped
$source
=
json_encode
([
"text"
=>
$vars
[
NAME_COPY_TO_CLIPBOARD
]],
JSON_HEX_QUOT
|
JSON_HEX_APOS
);
$source
=
json_encode
([
"text"
=>
$vars
[
NAME_COPY_TO_CLIPBOARD
]],
JSON_HEX_QUOT
|
JSON_HEX_APOS
);
}
elseif
(
isset
(
$vars
[
NAME_COLLECT_ELEMENTS
][
0
]))
{
$jsAction
=
'onmousedown'
;
...
...
@@ -1476,7 +1485,7 @@ EOF;
$vars
[
NAME_TOOL_TIP
]
.
=
PHP_EOL
.
PHP_EOL
.
$this
->
sip
->
debugSip
(
$paramArray
);
}
$source
=
json_encode
([
'uri'
=>
API_DIR
.
'/'
.
API_DOWNLOAD_PHP
.
'?s='
.
$paramArray
[
SIP_SIP
]
]);
$source
=
json_encode
([
'uri'
=>
API_DIR
.
'/'
.
API_DOWNLOAD_PHP
.
'?s='
.
$paramArray
[
SIP_SIP
]]);
}
else
{
throw
new
UserReportException
(
"Missing content for 'copy to clipboard'"
,
ERROR_MISSING_CONTENT
);
}
...
...
extension/Tests/unit/core/report/LinkTest.php
View file @
4899392a
...
...
@@ -983,7 +983,6 @@ class LinkTest extends TestCase {
}
/**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
...
...
@@ -1006,6 +1005,28 @@ class LinkTest extends TestCase {
}
/**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public
function
testAttribute
()
{
$link
=
new
Link
(
$this
->
sip
,
DB_INDEX_DEFAULT
,
true
);
// Standard
$result
=
$link
->
renderLink
(
'p:editperson|A:data-selenium="editperson"'
);
$this
->
assertEquals
(
'<a href="?id=editperson" data-selenium="editperson" >?id=editperson</a>'
,
$result
);
// BS Button & SIP
$result
=
$link
->
renderLink
(
'p:editperson|A:data-selenium="editperson"|b|s'
);
$this
->
assertEquals
(
'<a href="index.php?id=editperson&s=badcaffee1234" class="btn btn-default" data-selenium="editperson" >index.php?id=editperson&s=badcaffee1234</a>'
,
$result
);
// Render mode 3 (disabled)
$result
=
$link
->
renderLink
(
'p:editperson|A:data-selenium="editperson"|r:3'
);
$this
->
assertEquals
(
'<span data-selenium="editperson" >?id=editperson</span>'
,
$result
);
}
/**
*
* @throws CodeException
...
...
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