Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flexslider
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hebotek
flexslider
Commits
3b95717f
Commit
3b95717f
authored
Aug 21, 2012
by
Andy Hausmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented new dynamic LinkViewhelper.
parent
390c2327
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
0 deletions
+122
-0
DynLinkViewHelper.php
Classes/ViewHelpers/DynLinkViewHelper.php
+122
-0
No files found.
Classes/ViewHelpers/DynLinkViewHelper.php
0 → 100644
View file @
3b95717f
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Andy Hausmann <hi@andy-hausmann.de>
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
*
* A view helper for dynamic rendering of links.
*
* @author Andy Hausmann <hi@andy-hausmann.de>
* @package flexslider
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class
Tx_Flexslider_ViewHelpers_DynLinkViewHelper
extends
Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper
{
/**
* @var string
*/
protected
$tagName
=
'a'
;
/**
* @var array
*/
protected
$paramLabels
=
array
();
/**
* Arguments initialization
*
* @return void
*/
public
function
initializeArguments
()
{
$this
->
registerUniversalTagAttributes
();
$this
->
registerArgument
(
'arguments'
,
'array'
,
'Given arguments by Fluid call as an array.'
);
$this
->
registerArgument
(
'href'
,
'string'
,
'Link href.'
);
$this
->
paramLabels
=
array
(
'href'
,
'target'
,
'class'
,
'title'
);
}
/**
* Checks and processes the given link parameters.
*
* @param string $link Output from TYPO3 link wizard.
* @return bool Returns true if it is possible to build a link.
*/
protected
function
processLinkParams
(
$link
)
{
$paramDataArr
=
explode
(
' '
,
$link
);
// Combine labels and values into one array
$paramDataArr
=
Tx_Flexslider_Utility_Div
::
combineArray
(
$this
->
paramLabels
,
$paramDataArr
,
false
);
// Save link data into ViewHelper arguments
$this
->
setArguments
(
$paramDataArr
);
if
(
$this
->
hasArgument
(
'href'
)
&&
!
empty
(
$this
->
arguments
[
'href'
]))
{
$cObj
=
t3lib_div
::
makeInstance
(
'tslib_cObj'
);
$configuration
=
array
(
'parameter'
=>
$this
->
arguments
[
'href'
],
'returnLast'
=>
true
);
$href
=
$cObj
->
typolink
(
''
,
$configuration
);
$this
->
arguments
[
'href'
]
=
$href
;
return
true
;
}
else
{
return
false
;
}
}
/**
* Adds attributes to the tag builder if they're not empty.
*
* @return void
*/
protected
function
addTagAttributes
()
{
foreach
(
$this
->
paramLabels
as
$label
)
{
if
(
$this
->
hasArgument
(
$label
)
&&
!
empty
(
$this
->
arguments
[
$label
]))
{
$this
->
tag
->
addAttribute
(
$label
,
$this
->
arguments
[
$label
]);
}
}
}
/**
* ViewHelper Bootstrap.
*
* @return mixed|void
*/
public
function
render
()
{
if
(
$this
->
processLinkParams
(
$this
->
arguments
[
'arguments'
][
'link'
]))
{
$this
->
tag
->
setContent
(
$this
->
renderChildren
());
$this
->
addTagAttributes
();
return
$this
->
tag
->
render
();
}
else
{
return
$this
->
renderChildren
();
}
}
}
?>
\ No newline at end of file
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