-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtx_contagged_userfunction.php
63 lines (55 loc) · 2.1 KB
/
tx_contagged_userfunction.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
function user_addTermTypes(&$params, &$pObj) {
$template = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\TypoScript\TemplateService');
$template->tt_track = 0;
$template->init();
$sysPage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\Page\PageRepository');
$rootline = $sysPage->getRootLine(getCurrentPageId());
$rootlineIndex = 0;
foreach ($rootline as $index => $rootlinePart) {
if ($rootlinePart['is_siteroot'] == 1) {
$rootlineIndex = $index;
break;
}
}
$template->runThroughTemplates($rootline, $rootlineIndex);
$template->generateConfig();
$conf = $template->setup['plugin.']['tx_contagged.'];
// make localized labels
$LOCAL_LANG_ARRAY = array();
if (!empty($conf['types.'])) {
foreach ($conf['types.'] as $typeName => $typeConfigArray) {
unset($LOCAL_LANG_ARRAY);
if (!$typeConfigArray['hideSelection'] > 0 && !$typeConfigArray['dataSource']) {
if (is_array($typeConfigArray['label.'])) {
foreach ($typeConfigArray['label.'] as $langKey => $labelText) {
$LOCAL_LANG_ARRAY[$langKey]['label'] = $labelText;
}
}
$LOCAL_LANG_ARRAY['default']['label'] = $typeConfigArray['label'] ? $typeConfigArray['label'] : $typeConfigArray['label.']['default'];
$params['items'][] = array($GLOBALS['LANG']->getLLL('label', $LOCAL_LANG_ARRAY), substr($typeName, 0, -1));
}
}
}
}
function getCurrentPageId() {
$pageId = (integer)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
if ($pageId > 0) {
return $pageId;
}
preg_match('/(?<=id=)[0-9]a/', urldecode(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('returnUrl')), $matches);
if (count($matches) > 0) {
return $matches[0];
}
$rootTemplates = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('pid', 'sys_template', 'deleted=0 AND hidden=0 AND root=1', '', '', '1');
if (count($rootTemplates) > 0) {
return $rootTemplates[0]['pid'];
}
$rootPages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'pages', 'deleted=0 AND hidden=0 AND is_siteroot=1', '', '', '1');
if (count($rootPages) > 0) {
return $rootPages[0]['uid'];
}
// take pid 1 as fallback
return 1;
}
?>