1
|
|
|
<?php |
2
|
|
|
namespace Qbus\Qbtools\Utility; |
3
|
|
|
|
4
|
|
|
use TYPO3\CMS\Core\TypoScript\TemplateService; |
5
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* TypoScriptManagementUtility |
9
|
|
|
* |
10
|
|
|
* @author Benjamin Franzke <[email protected]> |
11
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later |
12
|
|
|
*/ |
13
|
|
|
class TypoScriptManagementUtility |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var array |
17
|
|
|
*/ |
18
|
|
|
private static $staticTypoScript = array(); |
19
|
|
|
|
20
|
|
|
/* |
21
|
|
|
* @var bool |
22
|
|
|
*/ |
23
|
|
|
private static $includeStaticTemplateFilesBeforeAllStaticTemplates = false; |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param string $path |
28
|
|
|
* @return void |
29
|
|
|
*/ |
30
|
|
|
public static function addStaticTypoScript($path) |
31
|
|
|
{ |
32
|
|
|
if (!in_array($path, self::$staticTypoScript)) { |
33
|
|
|
array_push(self::$staticTypoScript, $path); |
34
|
|
|
} |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param array $paths |
39
|
|
|
* @return void |
40
|
|
|
*/ |
41
|
|
|
public static function addStaticTypoScripts($paths) |
42
|
|
|
{ |
43
|
|
|
foreach ($paths as $path) { |
44
|
|
|
self::addStaticTypoScript($path); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param bool $enable |
50
|
|
|
*/ |
51
|
|
|
public static function forceStaticTSFilesBeforeAllTSTemplates($enable = true) |
52
|
|
|
{ |
53
|
|
|
self::$includeStaticTemplateFilesBeforeAllStaticTemplates = $enable; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Includes static template from extensions |
58
|
|
|
* |
59
|
|
|
* @param array $params |
60
|
|
|
* @param TemplateService $pObj |
61
|
|
|
* @return void |
62
|
|
|
*/ |
63
|
|
|
public function preprocessIncludeStaticTypoScriptSources(array &$params, TemplateService $pObj) |
|
|
|
|
64
|
|
|
{ |
65
|
|
|
if (isset($params['row']['root']) && $params['row']['root']) { |
66
|
|
|
$existing = GeneralUtility::trimExplode(',', $params['row']['include_static_file']); |
67
|
|
|
$staticTemplates = array_merge($existing, self::$staticTypoScript); |
68
|
|
|
$params['row']['include_static_file'] = implode(',', array_unique($staticTemplates)); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
if (self::$includeStaticTemplateFilesBeforeAllStaticTemplates) { |
72
|
|
|
/* Enfore "Static Template Files from TYPO3 Extensions:" to be |
73
|
|
|
* "Include before all static templates if root flag is set". |
74
|
|
|
* So that our typoscript can override typoscript from other extensions "ext_typoscript_setup.txt" */ |
75
|
|
|
$params['row']['static_file_mode'] = 3; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.