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
5b82041d
Commit
5b82041d
authored
May 19, 2019
by
Carsten Rose
Browse files
Refs #8348 - first implementation for Bootstrap dropdown menu's - fully SIP supported.
parent
98fe89cb
Pipeline
#1856
passed with stage
in 2 minutes and 30 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
extension/Source/core/Constants.php
View file @
5b82041d
...
@@ -1595,6 +1595,7 @@ const TOKEN_PAGE = 'p';
...
@@ -1595,6 +1595,7 @@ const TOKEN_PAGE = 'p';
const
TOKEN_UID
=
'uid'
;
const
TOKEN_UID
=
'uid'
;
const
TOKEN_DOWNLOAD
=
'd'
;
const
TOKEN_DOWNLOAD
=
'd'
;
const
TOKEN_COPY_TO_CLIPBOARD
=
'y'
;
const
TOKEN_COPY_TO_CLIPBOARD
=
'y'
;
const
TOKEN_DROPDOWN
=
'z'
;
const
TOKEN_TEXT
=
't'
;
const
TOKEN_TEXT
=
't'
;
const
TOKEN_ALT_TEXT
=
'a'
;
const
TOKEN_ALT_TEXT
=
'a'
;
...
...
extension/Source/core/report/Link.php
View file @
5b82041d
...
@@ -43,19 +43,30 @@ require_once(__DIR__ . '/Thumbnail.php');
...
@@ -43,19 +43,30 @@ require_once(__DIR__ . '/Thumbnail.php');
* D:delete
* D:delete
* e:encryption 0|1
* e:encryption 0|1
* E:edit
* E:edit
* f:
* F:File
* F:File
* g:target
* g:target
* G:Glyph
* G:Glyph
* h:
* H:Help
* H:Help
* i:
* I:information
* I:information
* j:
* J:
* k:
* K:
* l:
* L:
* m:mailto
* m:mailto
* M:Mode
* M:Mode
* n:
* N:new
* N:new
* o:ToolTip
* o:ToolTip
* O:Monitor
* O:Monitor
* p:page
* p:page
* P:picture [file]
* P:picture [file]
* q:question <text>
* q:question <text>
* Q:
* r:render
* r:render
* R:right
* R:right
* s:sip
* s:sip
...
@@ -64,18 +75,25 @@ require_once(__DIR__ . '/Thumbnail.php');
...
@@ -64,18 +75,25 @@ require_once(__DIR__ . '/Thumbnail.php');
* T:Thumbnail
* T:Thumbnail
* u:url
* u:url
* U:URL Param
* U:URL Param
* v:
* V:
* w:
* W:Dimension
* W:Dimension
* x:Delete
* x:Delete
* X:
* y:Copy to clipboard
* y:Copy to clipboard
* Y:
* z:DropDown Menu
* Z:
*
*
*/
*/
const
NAME_URL
=
'url'
;
const
NAME_URL
=
'url'
;
const
NAME_MAIL
=
'mail'
;
const
NAME_MAIL
=
'mail'
;
const
NAME_PAGE
=
'page'
;
const
NAME_PAGE
=
'page'
;
const
NAME_UID
=
'uid'
;
const
NAME_UID
=
'uid'
;
const
NAME_TEXT
=
'text'
;
const
NAME_TEXT
=
'text'
;
const
NAME_DROPDOWN
=
'dropdown'
;
const
NAME_DOWNLOAD
=
DOWNLOAD_EXPORT_FILENAME
;
const
NAME_DOWNLOAD
=
DOWNLOAD_EXPORT_FILENAME
;
const
NAME_COLLECT_ELEMENTS
=
'downloadElements'
;
// array with element sources
const
NAME_COLLECT_ELEMENTS
=
'downloadElements'
;
// array with element sources
const
NAME_DOWNLOAD_MODE
=
'mode'
;
const
NAME_DOWNLOAD_MODE
=
'mode'
;
...
@@ -171,6 +189,7 @@ class Link {
...
@@ -171,6 +189,7 @@ class Link {
TOKEN_PAGE
=>
'buildPage'
,
TOKEN_PAGE
=>
'buildPage'
,
TOKEN_COPY_TO_CLIPBOARD
=>
'buildCopyToClipboard'
,
TOKEN_COPY_TO_CLIPBOARD
=>
'buildCopyToClipboard'
,
TOKEN_DOWNLOAD
=>
'buildDownload'
,
TOKEN_DOWNLOAD
=>
'buildDownload'
,
TOKEN_DROPDOWN
=>
'buildDropdown'
,
TOKEN_TOOL_TIP
=>
'buildToolTip'
,
TOKEN_TOOL_TIP
=>
'buildToolTip'
,
TOKEN_PICTURE
=>
'buildPicture'
,
TOKEN_PICTURE
=>
'buildPicture'
,
TOKEN_BULLET
=>
'buildBullet'
,
TOKEN_BULLET
=>
'buildBullet'
,
...
@@ -193,6 +212,7 @@ class Link {
...
@@ -193,6 +212,7 @@ class Link {
TOKEN_MAIL
=>
NAME_MAIL
,
TOKEN_MAIL
=>
NAME_MAIL
,
TOKEN_PAGE
=>
NAME_PAGE
,
TOKEN_PAGE
=>
NAME_PAGE
,
TOKEN_UID
=>
NAME_UID
,
TOKEN_UID
=>
NAME_UID
,
TOKEN_DROPDOWN
=>
NAME_DROPDOWN
,
TOKEN_DOWNLOAD
=>
NAME_DOWNLOAD
,
TOKEN_DOWNLOAD
=>
NAME_DOWNLOAD
,
TOKEN_DOWNLOAD_MODE
=>
NAME_DOWNLOAD_MODE
,
TOKEN_DOWNLOAD_MODE
=>
NAME_DOWNLOAD_MODE
,
TOKEN_TEXT
=>
NAME_TEXT
,
TOKEN_TEXT
=>
NAME_TEXT
,
...
@@ -371,6 +391,101 @@ class Link {
...
@@ -371,6 +391,101 @@ class Link {
}
}
/**
* @param string $str
*
* @return string
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
private
function
processDropdown
(
$str
)
{
$menuHtml
=
''
;
$menuEntryStrArr
=
array
();
$menuEntryLinkArr
=
array
();
$tokenCollect
=
array
();
$dropdownStr
=
null
;
$paramArr
=
KeyValueStringParser
::
explodeEscape
(
PARAM_DELIMITER
,
$str
);
// Iterate over token. Find delimiter to separate dropdown definition and all menu entries.
foreach
(
$paramArr
as
$tokenStr
)
{
$tokenArr
=
explode
(
PARAM_TOKEN_DELIMITER
,
$tokenStr
,
2
);
switch
(
$tokenArr
[
0
]
??
''
)
{
// No further need: skip
case
TOKEN_DROPDOWN
:
break
;
// Indicator to start menu entry: force a flush of existing token and start a new round.
case
TOKEN_URL
:
case
TOKEN_MAIL
:
case
TOKEN_PAGE
:
case
TOKEN_DOWNLOAD
:
case
TOKEN_COPY_TO_CLIPBOARD
:
case
''
:
// New menu entry
$menuEntryStrArr
[]
=
implode
(
PARAM_DELIMITER
,
$tokenCollect
);
$tokenCollect
=
array
();
$tokenCollect
[]
=
$tokenStr
;
break
;
default
:
$tokenCollect
[]
=
$tokenStr
;
}
}
// Flush remaining element
$menuEntryStrArr
[]
=
implode
(
PARAM_DELIMITER
,
$tokenCollect
);
$dropdownStr
=
array_shift
(
$menuEntryStrArr
);
// For each menu entry get the link
foreach
(
$menuEntryStrArr
as
$str
)
{
$menuEntryLinkArr
[]
=
$this
->
renderLink
(
$str
);
}
return
$this
->
renderDropdown
(
$dropdownStr
,
$menuEntryLinkArr
);
}
/**
* Start
* <span class="dropdown">
* <span class="glyphicon glyphicon-option-vertical dropdown-toggle" id="dropdownMenu11" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
* </span>
* <ul class="dropdown-menu" aria-labelledby="dropdownMenu11">
* <li><a href="#">Action</a></li>
* <li><a href="#">Another action</a></li>
* <li><a href="#">Something else here</a></li>
* <li role="separator" class="divider"></li>
* <li><a href="#">Separated link</a></li>
* </ul>
* </span>
* End
*
* @param $dropdownStr
* @param $menuEntryLinkArr
* @return string
*/
private
function
renderDropdown
(
$dropdownStr
,
$menuEntryLinkArr
)
{
static
$count
=
0
;
$time
=
microtime
(
false
);
if
(
defined
(
'PHPUNIT_QFQ'
))
{
$time
=
'0.123 1234'
;
}
$htmlId
=
$time
.
$count
++
;
$tmp
=
''
;
foreach
(
$menuEntryLinkArr
as
$link
)
{
$tmp
.
=
'<li>'
.
$link
.
'</li>'
;
}
$ul
=
Support
::
wrapTag
(
'<ul class="dropdown-menu" aria-labelledby="'
.
$htmlId
.
'">'
,
$tmp
);
$symbol
=
'<span class="glyphicon glyphicon-option-vertical dropdown-toggle" id="'
.
$htmlId
.
'" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"></span>'
;
return
Support
::
wrapTag
(
'<span class="dropdown">'
,
$symbol
.
$ul
);
}
/**
/**
* Build the whole link.
* Build the whole link.
*
*
...
@@ -391,6 +506,11 @@ class Link {
...
@@ -391,6 +506,11 @@ class Link {
return
''
;
return
''
;
}
}
// Check for dropdown menu
if
((
$str
[
0
]
??
''
)
==
TOKEN_DROPDOWN
)
{
return
$this
->
processDropdown
(
$str
);
}
$vars
=
$this
->
fillParameter
(
$str
,
$tokenGiven
);
$vars
=
$this
->
fillParameter
(
$str
,
$tokenGiven
);
$vars
=
$this
->
processParameter
(
$vars
,
$tokenGiven
);
$vars
=
$this
->
processParameter
(
$vars
,
$tokenGiven
);
$mode
=
$this
->
getModeRender
(
$vars
,
$tokenGiven
);
$mode
=
$this
->
getModeRender
(
$vars
,
$tokenGiven
);
...
@@ -489,10 +609,10 @@ class Link {
...
@@ -489,10 +609,10 @@ class Link {
$key
=
substr
(
$value
,
0
,
2
);
$key
=
substr
(
$value
,
0
,
2
);
if
(
strlen
(
$key
)
==
1
)
{
if
(
strlen
(
$key
)
==
1
)
{
$key
.
=
':'
;
$key
.
=
PARAM_TOKEN_DELIMITER
;
}
}
if
(
$key
==
TOKEN_DOWNLOAD
.
':'
)
{
if
(
$key
==
TOKEN_DOWNLOAD
.
PARAM_TOKEN_DELIMITER
)
{
$prio
[]
=
$value
;
$prio
[]
=
$value
;
}
else
{
}
else
{
$regular
[]
=
$value
;
$regular
[]
=
$value
;
...
@@ -1094,7 +1214,7 @@ class Link {
...
@@ -1094,7 +1214,7 @@ class Link {
$level
=
(
$arr
[
QUESTION_INDEX_LEVEL
]
===
''
)
?
DEFAULT_QUESTION_LEVEL
:
$arr
[
QUESTION_INDEX_LEVEL
];
$level
=
(
$arr
[
QUESTION_INDEX_LEVEL
]
===
''
)
?
DEFAULT_QUESTION_LEVEL
:
$arr
[
QUESTION_INDEX_LEVEL
];
$ok
=
(
$arr
[
QUESTION_INDEX_BUTTON_OK
]
===
''
)
?
'Ok'
:
$arr
[
QUESTION_INDEX_BUTTON_OK
];
$ok
=
(
$arr
[
QUESTION_INDEX_BUTTON_OK
]
===
''
)
?
'Ok'
:
$arr
[
QUESTION_INDEX_BUTTON_OK
];
$cancel
=
(
$arr
[
QUESTION_INDEX_BUTTON_FALSE
]
===
''
)
?
'Cancel'
:
$arr
[
QUESTION_INDEX_BUTTON_FALSE
];
$cancel
=
(
$arr
[
QUESTION_INDEX_BUTTON_FALSE
]
===
''
)
?
'Cancel'
:
$arr
[
QUESTION_INDEX_BUTTON_FALSE
];
$cancel
=
(
$cancel
==
'-'
)
?
''
:
", { label: '
$cancel
',eventName: 'cancel'}"
;
$cancel
=
(
$cancel
==
'-'
)
?
''
:
", { label: '
$cancel
',eventName: 'cancel'}"
;
$timeout
=
(
$arr
[
QUESTION_INDEX_TIMEOUT
]
===
''
)
?
'0'
:
$arr
[
QUESTION_INDEX_TIMEOUT
]
*
1000
;
$timeout
=
(
$arr
[
QUESTION_INDEX_TIMEOUT
]
===
''
)
?
'0'
:
$arr
[
QUESTION_INDEX_TIMEOUT
]
*
1000
;
$flagModalStatus
=
(
$arr
[
QUESTION_INDEX_FLAG_MODAL
]
===
''
)
?
'1'
:
$arr
[
QUESTION_INDEX_FLAG_MODAL
];
$flagModalStatus
=
(
$arr
[
QUESTION_INDEX_FLAG_MODAL
]
===
''
)
?
'1'
:
$arr
[
QUESTION_INDEX_FLAG_MODAL
];
...
@@ -1137,7 +1257,7 @@ EOF;
...
@@ -1137,7 +1257,7 @@ EOF;
$attributes
.
=
Support
::
doAttribute
(
'class'
,
$vars
[
FINAL_CLASS
]);
$attributes
.
=
Support
::
doAttribute
(
'class'
,
$vars
[
FINAL_CLASS
]);
$attributes
.
=
Support
::
doAttribute
(
'target'
,
$vars
[
NAME_TARGET
]);
$attributes
.
=
Support
::
doAttribute
(
'target'
,
$vars
[
NAME_TARGET
]);
$attributes
.
=
Support
::
doAttribute
(
'title'
,
$vars
[
FINAL_TOOL_TIP
]);
$attributes
.
=
Support
::
doAttribute
(
'title'
,
$vars
[
FINAL_TOOL_TIP
]);
if
(
$vars
[
NAME_ATTRIBUTE
]
!=
''
)
{
if
(
$vars
[
NAME_ATTRIBUTE
]
!=
''
)
{
$attributes
.
=
$vars
[
NAME_ATTRIBUTE
]
.
' '
;
$attributes
.
=
$vars
[
NAME_ATTRIBUTE
]
.
' '
;
}
}
$attributes
.
=
$vars
[
FINAL_QUESTION
];
$attributes
.
=
$vars
[
FINAL_QUESTION
];
...
...
extension/Tests/unit/core/report/LinkTest.php
View file @
5b82041d
...
@@ -1458,7 +1458,35 @@ EOF;
...
@@ -1458,7 +1458,35 @@ EOF;
$this
->
assertEquals
(
''
,
$result
);
$this
->
assertEquals
(
''
,
$result
);
}
}
/**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public
function
testLinkDropdown
()
{
$link
=
new
Link
(
$this
->
sip
,
DB_INDEX_DEFAULT
,
true
);
$expect
=
'<span class="dropdown"><span class="glyphicon glyphicon-option-vertical dropdown-toggle" id="0.123 12340" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"></span><ul class="dropdown-menu" aria-labelledby="0.123 12340"></ul></span>'
;
$result
=
$link
->
renderLink
(
'z'
);
$this
->
assertEquals
(
$expect
,
$result
);
$expect
=
'<span class="dropdown"><span class="glyphicon glyphicon-option-vertical dropdown-toggle" id="0.123 12341" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"></span><ul class="dropdown-menu" aria-labelledby="0.123 12341"></ul></span>'
;
$result
=
$link
->
renderLink
(
'z:'
);
$this
->
assertEquals
(
$expect
,
$result
);
$expect
=
'<span class="dropdown"><span class="glyphicon glyphicon-option-vertical dropdown-toggle" id="0.123 12342" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"></span><ul class="dropdown-menu" aria-labelledby="0.123 12342"></ul></span>'
;
$result
=
$link
->
renderLink
(
'z|t:Menu|G:glyph-icon-left|o:Open menu'
);
$this
->
assertEquals
(
$expect
,
$result
);
$expect
=
'<span class="dropdown"><span class="glyphicon glyphicon-option-vertical dropdown-toggle" id="0.123 12343" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"></span><ul class="dropdown-menu" aria-labelledby="0.123 12343"><li><a href="?id=home" >Home</a></li></ul></span>'
;
$result
=
$link
->
renderLink
(
'z|t:Menu|G:glyph-icon-left|o:Open menu|p:home|t:Home'
);
$this
->
assertEquals
(
$expect
,
$result
);
$expect
=
'<span class="dropdown"><span class="glyphicon glyphicon-option-vertical dropdown-toggle" id="0.123 12344" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"></span><ul class="dropdown-menu" aria-labelledby="0.123 12344"><li><a href="index.php?id=home&s=badcaffee1234" >Home</a></li><li><a href="?id=back" title="Navigate back" >Back</a></li></ul></span>'
;
$result
=
$link
->
renderLink
(
'z|t:Menu|G:glyph-icon-left|o:Open menu|p:home|t:Home|s|p:back|t:Back|o:Navigate back'
);
$this
->
assertEquals
(
$expect
,
$result
);
}
/**
/**
* @expectedException \qfq\UserReportException
* @expectedException \qfq\UserReportException
*
*
...
...
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