1
|
|
|
<?php |
2
|
|
|
namespace DERHANSEN\SfBanners\ViewHelpers\Flash; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the TYPO3 CMS project. |
6
|
|
|
* |
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
9
|
|
|
* of the License, or any later version. |
10
|
|
|
* |
11
|
|
|
* For the full copyright and license information, please read the |
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
13
|
|
|
* |
14
|
|
|
* The TYPO3 project - inspiring people to share! |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Flash params viewhelper |
21
|
|
|
* |
22
|
|
|
* @author Torben Hansen <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class ParamsViewHelper extends AbstractViewHelper |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface |
28
|
|
|
* @inject |
29
|
|
|
*/ |
30
|
|
|
protected $configurationManager; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Returns TypoSript settings for the extension |
34
|
|
|
* |
35
|
|
|
* @return array |
36
|
|
|
*/ |
37
|
|
|
public function getSettings() |
38
|
|
|
{ |
39
|
|
|
$typoScript = $this->configurationManager->getConfiguration( |
40
|
|
|
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, |
41
|
|
|
'SfBanners', |
42
|
|
|
'Pi1' |
43
|
|
|
); |
44
|
|
|
return $typoScript; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Returns the requested flash variable depending on the setting in the banner. |
49
|
|
|
* If no value is set in the banner object, the default value from TS setting |
50
|
|
|
* is returned |
51
|
|
|
* |
52
|
|
|
* @param \DERHANSEN\SfBanners\Domain\Model\Banner $banner The banner |
53
|
|
|
* @param string $flashSetting Flash settings |
54
|
|
|
* @return string |
55
|
|
|
*/ |
56
|
|
|
public function render($banner = null, $flashSetting = '') |
57
|
|
|
{ |
58
|
|
|
$settings = $this->getSettings(); |
59
|
|
|
$retVal = ''; |
60
|
|
|
switch ($flashSetting) { |
61
|
|
|
case 'wmode': |
62
|
|
|
if ($banner->getFlashWmode() != '') { |
63
|
|
|
$retVal = $banner->getFlashWmode(); |
|
|
|
|
64
|
|
|
} else { |
65
|
|
|
$retVal = $settings['defaultFlashVars']['wmode']; |
66
|
|
|
} |
67
|
|
|
break; |
68
|
|
|
case 'allowScriptAccess': |
69
|
|
|
if ($banner->getFlashAllowScriptAccess() != '') { |
70
|
|
|
$retVal = $banner->getFlashAllowScriptAccess(); |
71
|
|
|
} else { |
72
|
|
|
$retVal = $settings['defaultFlashVars']['allowScriptAccess']; |
73
|
|
|
} |
74
|
|
|
break; |
75
|
|
|
default: |
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
} |
78
|
|
|
return $retVal; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: