1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* handler to create the labels. |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace HDNET\Autoloader\Hooks; |
7
|
|
|
|
8
|
|
|
use HDNET\Autoloader\Localization\LanguageHandler; |
9
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* handler to create the labels. |
13
|
|
|
* |
14
|
|
|
* @hook TYPO3_CONF_VARS|EXTCONF|autoloader|assureLabel |
15
|
|
|
*/ |
16
|
|
|
class Localization |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Take care that the label exists. |
20
|
|
|
* |
21
|
|
|
* @param string $key key in the localization file |
22
|
|
|
* @param string $extensionName |
23
|
|
|
* @param string $default default value of the label |
24
|
|
|
* @param array $arguments arguments are being passed over to vsprintf |
25
|
|
|
* @param string $tableName The tablename of the given table (null, in non table context) |
26
|
|
|
*/ |
27
|
|
|
public function assureLabel($key, $extensionName, &$default, $arguments, $tableName) |
28
|
|
|
{ |
29
|
|
|
$overrideBaseName = null; |
30
|
|
|
if($this->useTableNameFileBase()) { |
31
|
|
|
$overrideBaseName = $tableName; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** @var LanguageHandler $languageHandler */ |
35
|
|
|
$languageHandler = GeneralUtility::makeInstance(LanguageHandler::class); |
36
|
|
|
$default = $languageHandler->handle($key, $extensionName, $default, $arguments, $overrideBaseName); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Check if table name file base is used |
41
|
|
|
* |
42
|
|
|
* @return bool |
43
|
|
|
*/ |
44
|
|
|
protected function useTableNameFileBase() |
45
|
|
|
{ |
46
|
|
|
$configuration = unserialize((string)$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['autoloader']); |
47
|
|
|
return isset($configuration['enableLanguageFileOnTableBase']) ? (bool)$configuration['enableLanguageFileOnTableBase'] : false; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|