forked from Gernott/mask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ext_localconf.php
executable file
·179 lines (162 loc) · 7.58 KB
/
ext_localconf.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
// initialize mask utility for various things
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Domain\\Repository\\StorageRepository');
$fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper');
$typoScriptCodeGenerator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\CodeGenerator\\TyposcriptCodeGenerator');
$settingsService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Domain\\Service\\SettingsService');
$configuration = $storageRepository->load();
$settings = $settingsService->get();
// Register Plugin to render content in the frontend
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'MASK.' . $_EXTKEY, 'ContentRenderer', array('Frontend' => 'contentelement'), array('Frontend' => '')
);
// Register Icons needed in the backend module
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("TYPO3\CMS\Core\Imaging\IconRegistry");
$maskIcons = array("Check", "Date", "Datetime", "File", "Float", "Inline", "Integer", "Link", "Radio", "Richtext", "Select", "String", "Tab", "Text", "Content");
foreach ($maskIcons as $maskIcon) {
$iconRegistry->registerIcon(
'mask-fieldtype-' . $maskIcon, 'TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider', array(
'source' => 'EXT:mask/Resources/Public/Icons/Fieldtypes/' . $maskIcon . '.svg'
)
);
}
// Add all the typoscript we need in the correct files
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:mask/Configuration/TypoScript/page.txt">');
$tsConfig = $typoScriptCodeGenerator->generateTsConfig($configuration);
$pageTs = $typoScriptCodeGenerator->generatePageTyposcript($configuration);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig($tsConfig);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig($pageTs);
$setupTs = $typoScriptCodeGenerator->generateSetupTyposcript($configuration, $settings);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup($setupTs);
// for conditions on tt_content
if (!function_exists('user_mask_contentType')) {
function user_mask_contentType($param = "")
{
if (isset($_REQUEST["edit"]["tt_content"]) && is_array($_REQUEST["edit"]["tt_content"])) {
$field = explode("|", $param);
$request = $_REQUEST;
$first = array_shift($request["edit"]["tt_content"]);
if ($first == "new") { // if new element
if ($_REQUEST["defVals"]["tt_content"]["CType"] == $field[1]) {
return true;
} else {
return false;
}
} else { // if element exists
$uid = intval(key($_REQUEST["edit"]["tt_content"]));
$sql = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
$field[0], "tt_content", "uid = " . $uid
);
$data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($sql);
if ($data[$field[0]] == $field[1]) {
return true;
} else {
return false;
}
}
} else {
// if content element is loaded by ajax, then it's ok
if (is_array($_REQUEST["ajax"])) {
return true;
} else {
return false;
}
}
}
}
// for conditions on the backend-layouts
if (!function_exists('user_mask_beLayout')) {
function user_mask_beLayout($layout = null)
{
// get current page uid:
if (is_array($_REQUEST["data"]["pages"])) { // after saving page
$uid = intval(key($_REQUEST["data"]["pages"]));
} elseif (is_array($_REQUEST["data"]["pages_language_overlay"])) {
$po_uid = key($_REQUEST["data"]["pages_language_overlay"]);
if ($_REQUEST["data"]["pages_language_overlay"][$po_uid]["pid"]) { // after saving a new pages_language_overlay
$uid = $_REQUEST["data"]["pages_language_overlay"][$po_uid]["pid"];
} else { // after saving an existing pages_language_overlay
$po_uid = intval($po_uid);
$sql = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
"pid", "pages_language_overlay", "uid = " . $po_uid
);
$data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($sql);
$uid = $data["pid"];
}
} elseif ($GLOBALS["SOBE"]->editconf["pages"]) { // after opening pages
$uid = intval(key($GLOBALS["SOBE"]->editconf["pages"]));
} elseif ($GLOBALS["SOBE"]->viewId) { // after opening or creating pages_language_overlay
$uid = $GLOBALS["SOBE"]->viewId;
} else {
if ($GLOBALS["_SERVER"]["HTTP_REFERER"] != "") {
$url = $GLOBALS["_SERVER"]["HTTP_REFERER"];
$queryString = parse_url($url, PHP_URL_QUERY);
$result = array();
parse_str($queryString, $result);
if ($result["id"]) {
$uid = (int) $result["id"];
}
}
}
if ($uid) {
$sql = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
"backend_layout, backend_layout_next_level", "pages", "uid = " . $uid
);
$data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($sql);
$backend_layout = $data["backend_layout"];
$backend_layout_next_level = $data["backend_layout_next_level"];
if ($backend_layout !== "") { // If backend_layout is set on current page
if (in_array($backend_layout, [$layout, "pagets__" . $layout])) { // Check backend_layout of current page
return true;
} else {
return false;
}
} elseif ($backend_layout_next_level !== "") { // If backend_layout_next_level is set on current page
if (in_array($backend_layout_next_level, [$layout, "pagets__" . $layout])) { // Check backend_layout_next_level of current page
return true;
} else {
return false;
}
} else { // If backend_layout and backend_layout_next_level is not set on current page, check backend_layout_next_level on rootline
$sysPage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$rootline = $sysPage->getRootLine($uid, '', TRUE);
foreach ($rootline as $page) {
if (in_array($page["backend_layout_next_level"], [$layout, "pagets__" . $layout])) {
return true;
}
}
return false;
}
} else {
return false;
}
}
}
// set rootlinefields and pageoverlayfields
if ($json['pages']['tca']) {
$rootlineFields = explode(",", $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields']);
$pageOverlayFields = explode(",", $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']);
foreach ($json['pages']['tca'] as $fieldKey => $value) {
$formType = $fieldHelper->getFormType($fieldKey, "", "pages");
if ($formType !== "Tab") {
// Add addRootLineFields and pageOverlayFields for all pagefields
$rootlineFields[] = $fieldKey;
$pageOverlayFields[] = $fieldKey;
}
}
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] = implode(",", $rootlineFields);
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = implode(",", $pageOverlayFields);
}
// SQL inject:
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
$signalSlotDispatcher->connect('TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService', 'tablesDefinitionIsBeingBuilt', 'MASK\\Mask\\CodeGenerator\\SqlCodeGenerator', 'addDatabaseTablesDefinition');
// Enhance Fluid Output with overridden FluidTemplateContentObject
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Frontend\\ContentObject\\FluidTemplateContentObject'] = array(
'className' => 'MASK\\Mask\\Fluid\\FluidTemplateContentObject'
);
// Hook to override tt_content backend_preview
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][$_EXTKEY] = 'EXT:' . $_EXTKEY . '/Classes/Hooks/PageLayoutViewDrawItem.php:MASK\Mask\Hooks\PageLayoutViewDrawItem';