45 'pObj' =>
'Using TypoScriptTemplateObjectBrowserModuleFunctionController::$pObj is deprecated and will not be possible anymore in TYPO3 v10.0.',
46 'function_key' =>
'Using TypoScriptTemplateObjectBrowserModuleFunctionController::$function_key is deprecated, property will be removed in TYPO3 v10.0.',
47 'extClassConf' =>
'Using TypoScriptTemplateObjectBrowserModuleFunctionController::$extClassConf is deprecated, property will be removed in TYPO3 v10.0.',
48 'localLangFile' =>
'Using TypoScriptTemplateObjectBrowserModuleFunctionController::$localLangFile is deprecated, property will be removed in TYPO3 v10.0.',
55 'initialize_editor' =>
'Using TypoScriptTemplateObjectBrowserModuleFunctionController::initialize_editor() is deprecated and will not be possible anymore in TYPO3 v10.0.',
56 'modMenu' =>
'Using TypoScriptTemplateObjectBrowserModuleFunctionController::modMenu() is deprecated and will not be possible anymore in TYPO3 v10.0.',
57 'handleExternalFunctionValue' =>
'Using TypoScriptTemplateObjectBrowserModuleFunctionController::handleExternalFunctionValue() is deprecated, method will be removed in TYPO3 v10.0.',
124 if (!empty($this->localLangFile)) {
129 $this->pObj->MOD_MENU = array_merge($this->pObj->MOD_MENU, $this->modMenu());
130 $this->pObj->modMenu_dontValidateList .=
',ts_browser_toplevel_setup,ts_browser_toplevel_const,ts_browser_TLKeys_setup,ts_browser_TLKeys_const';
131 $this->pObj->modMenu_setDefaultList .=
',ts_browser_fixedLgd,ts_browser_showComments';
132 $this->localLanguageFilePath =
'EXT:tstemplate/Resources/Private/Language/locallang_objbrowser.xlf';
133 $this->
id = (int)GeneralUtility::_GP(
'id');
144 $lang->includeLLFile(
'EXT:tstemplate/Resources/Private/Language/locallang_objbrowser.xlf');
146 'ts_browser_type' => [
147 'const' => $lang->getLL(
'constants'),
148 'setup' => $lang->getLL(
'setup')
150 'ts_browser_toplevel_setup' => [
151 '0' => mb_strtolower($lang->getLL(
'all'),
'utf-8')
153 'ts_browser_toplevel_const' => [
154 '0' => mb_strtolower($lang->getLL(
'all'),
'utf-8')
156 'ts_browser_const' => [
157 '0' => $lang->getLL(
'plainSubstitution'),
158 'subst' => $lang->getLL(
'substitutedGreen'),
159 'const' => $lang->getLL(
'unsubstitutedGreen')
161 'ts_browser_regexsearch' =>
'1',
162 'ts_browser_fixedLgd' =>
'1',
163 'ts_browser_showComments' =>
'1',
164 'ts_browser_alphaSort' =>
'1'
166 foreach ([
'setup',
'const'] as $bType) {
167 $addKey = GeneralUtility::_GET(
'addKey');
169 if (is_array($addKey)) {
171 if (current($addKey)) {
172 $this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType][key($addKey)] = key($addKey);
174 unset($this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType][key($addKey)]);
178 if (!empty($this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType])) {
179 $modMenu[
'ts_browser_toplevel_' . $bType][
'-'] =
'---';
180 $modMenu[
'ts_browser_toplevel_' . $bType] = $modMenu[
'ts_browser_toplevel_' . $bType] + $this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType];
198 $this->templateService = GeneralUtility::makeInstance(ExtendedTemplateService::class);
201 $rootlineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $pageId);
202 $rootLine = $rootlineUtility->get();
204 $this->templateService->runThroughTemplates($rootLine, $template_uid);
207 $this->templateRow = $this->templateService->ext_getFirstTemplate($pageId, $template_uid);
208 return is_array($this->templateRow);
216 public function main()
219 $POST = GeneralUtility::_POST();
222 $manyTemplatesMenu = $this->pObj->templateMenu();
224 if ($manyTemplatesMenu) {
225 $template_uid = $this->pObj->MOD_SETTINGS[
'templatesOnPage'];
227 $bType = $this->pObj->MOD_SETTINGS[
'ts_browser_type'];
231 $assigns[
'LLPrefix'] =
'LLL:' . $this->localLanguageFilePath .
':';
232 $assigns[
'existTemplate'] = $existTemplate;
233 $assigns[
'tsBrowserType'] = $this->pObj->MOD_SETTINGS[
'ts_browser_type'];
234 if ($existTemplate) {
236 $assigns[
'linkWrapTemplateTitle'] = $this->pObj->linkWrapTemplateTitle($this->templateRow[
'title'], ($bType ===
'setup' ?
'config' :
'constants'));
237 $assigns[
'manyTemplatesMenu'] = $manyTemplatesMenu;
239 if ($POST[
'add_property'] || $POST[
'update_value'] || $POST[
'clear_object']) {
242 if (is_array($POST[
'data'])) {
243 $name = key($POST[
'data']);
244 if ($POST[
'data'][$name][
'name'] !==
'') {
246 unset($POST[
'update_value']);
247 $POST[
'add_property'] =
'Add';
249 if ($POST[
'add_property']) {
250 $property = trim($POST[
'data'][$name][
'name']);
251 if (preg_replace(
'/[^a-zA-Z0-9_\\.]*/',
'', $property) != $property) {
252 $badPropertyMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL(
'noSpaces') . $lang->getLL(
'nothingUpdated'), $lang->getLL(
'badProperty'),
FlashMessage::ERROR);
255 $pline = $name .
'.' . $property .
' = ' . trim($POST[
'data'][$name][
'propertyValue']);
256 $propertyAddedMessage = GeneralUtility::makeInstance(FlashMessage::class, $pline, $lang->getLL(
'propertyAdded'));
258 $line .= LF . $pline;
260 } elseif ($POST[
'update_value']) {
261 $pline = $name .
' = ' . trim($POST[
'data'][$name][
'value']);
262 $updatedMessage = GeneralUtility::makeInstance(FlashMessage::class, $pline, $lang->getLL(
'valueUpdated'));
264 $line .= LF . $pline;
265 } elseif ($POST[
'clear_object']) {
266 if ($POST[
'data'][$name][
'clearValue']) {
267 $pline = $name .
' >';
268 $objectClearedMessage = GeneralUtility::makeInstance(FlashMessage::class, $pline, $lang->getLL(
'objectCleared'));
270 $line .= LF . $pline;
275 $saveId = $this->templateRow[
'_ORIG_uid'] ?: $this->templateRow[
'uid'];
278 $field = $bType ===
'setup' ?
'config' :
'constants';
279 $recData[
'sys_template'][$saveId][$field] = $this->templateRow[$field] . $line;
281 $tce = GeneralUtility::makeInstance(DataHandler::class);
283 $tce->start($recData, []);
285 $tce->process_datamap();
287 $tce->clear_cacheCmd(
'all');
293 $tsbr = GeneralUtility::_GET(
'tsbr');
295 if (is_array($tsbr)) {
297 $this->pObj->MOD_SETTINGS[
'tsbrowser_depthKeys_' . $bType] = $this->templateService->ext_depthKeys($tsbr, $this->pObj->MOD_SETTINGS[
'tsbrowser_depthKeys_' . $bType]);
300 if ($POST[
'Submit']) {
302 $this->pObj->MOD_SETTINGS[
'tsbrowser_conditions'] = $POST[
'conditions'];
308 $this->templateService->matchAlternative = $this->pObj->MOD_SETTINGS[
'tsbrowser_conditions'];
309 $this->templateService->matchAlternative[] =
'dummydummydummydummydummydummydummydummydummydummydummy';
311 $this->templateService->constantMode = $this->pObj->MOD_SETTINGS[
'ts_browser_const'];
313 $sObj = GeneralUtility::_GP(
'sObj');
314 if (!empty($sObj) && $this->templateService->constantMode) {
315 $this->templateService->constantMode =
'untouched';
317 $this->templateService->regexMode = $this->pObj->MOD_SETTINGS[
'ts_browser_regexsearch'];
318 $this->templateService->fixedLgd = $this->pObj->MOD_SETTINGS[
'ts_browser_fixedLgd'];
319 $this->templateService->linkObjects =
true;
320 $this->templateService->ext_regLinenumbers =
true;
321 $this->templateService->ext_regComments = $this->pObj->MOD_SETTINGS[
'ts_browser_showComments'];
322 $this->templateService->bType = $bType;
323 if ($this->pObj->MOD_SETTINGS[
'ts_browser_type'] ===
'const') {
324 $this->templateService->ext_constants_BRP = (int)GeneralUtility::_GP(
'breakPointLN');
326 $this->templateService->ext_config_BRP = (int)GeneralUtility::_GP(
'breakPointLN');
328 $this->templateService->generateConfig();
329 if ($bType ===
'setup') {
330 $theSetup = $this->templateService->setup;
332 $theSetup = $this->templateService->setup_constants;
335 $assigns[
'typoScriptPath'] = $sObj;
337 list($theSetup, $theSetupValue) = $this->templateService->ext_getSetup($theSetup, $sObj);
338 $assigns[
'theSetupValue'] = $theSetupValue;
339 if ($existTemplate ===
false) {
340 $noTemplateMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL(
'noCurrentTemplate'), $lang->getLL(
'edit'),
FlashMessage::ERROR);
348 $uriBuilder = GeneralUtility::makeInstance(\
TYPO3\CMS\Backend\Routing\UriBuilder::class);
349 $aHref = (string)$uriBuilder->buildUriFromRoute(
'web_ts', $urlParameters);
350 $assigns[
'moduleUrl'] = (string)$uriBuilder->buildUriFromRoute(
'web_ts', $urlParameters);
351 $assigns[
'isNotInTopLevelKeyList'] = !isset($this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType][$sObj]);
352 $assigns[
'hasProperties'] = !empty($theSetup);
353 if (!$this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType][$sObj]) {
354 if (!empty($theSetup)) {
355 $assigns[
'moduleUrlObjectListAction'] = $aHref .
'&addKey[' . rawurlencode($sObj) .
']=1&SET[ts_browser_toplevel_' . $bType .
']=' . rawurlencode($sObj);
358 $assigns[
'moduleUrlObjectListAction'] = $aHref .
'&addKey[' . rawurlencode($sObj) .
']=0&SET[ts_browser_toplevel_' . $bType .
']=0';
361 $this->templateService->tsbrowser_depthKeys = $this->pObj->MOD_SETTINGS[
'tsbrowser_depthKeys_' . $bType];
362 if (GeneralUtility::_POST(
'search') && GeneralUtility::_POST(
'search_field')) {
364 $searchString = GeneralUtility::_POST(
'search_field');
366 $this->templateService->tsbrowser_depthKeys =
367 $this->templateService->ext_getSearchKeys(
373 }
catch (Exception $e) {
375 GeneralUtility::makeInstance(FlashMessage::class, sprintf($lang->getLL(
'error.' . $e->getCode()), $searchString),
'',
FlashMessage::ERROR)
379 $assigns[
'hasTsBrowserTypes'] = is_array($this->pObj->MOD_MENU[
'ts_browser_type']) && count($this->pObj->MOD_MENU[
'ts_browser_type']) > 1;
380 if (is_array($this->pObj->MOD_MENU[
'ts_browser_type']) && count($this->pObj->MOD_MENU[
'ts_browser_type']) > 1) {
381 $assigns[
'browserTypeDropdownMenu'] =
BackendUtility::getDropdownMenu($this->
id,
'SET[ts_browser_type]', $bType, $this->pObj->MOD_MENU[
'ts_browser_type']);
383 $assigns[
'hasTopLevelInObjectList'] = is_array($this->pObj->MOD_MENU[
'ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU[
'ts_browser_toplevel_' . $bType]) > 1;
384 if (is_array($this->pObj->MOD_MENU[
'ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU[
'ts_browser_toplevel_' . $bType]) > 1) {
385 $assigns[
'objectListDropdownMenu'] =
BackendUtility::getDropdownMenu($this->
id,
'SET[ts_browser_toplevel_' . $bType .
']', $this->pObj->MOD_SETTINGS[
'ts_browser_toplevel_' . $bType], $this->pObj->MOD_MENU[
'ts_browser_toplevel_' . $bType]);
388 $assigns[
'regexSearchCheckbox'] =
BackendUtility::getFuncCheck($this->
id,
'SET[ts_browser_regexsearch]', $this->pObj->MOD_SETTINGS[
'ts_browser_regexsearch'],
'',
'',
'id="checkTs_browser_regexsearch"');
389 $assigns[
'postSearchField'] = $POST[
'search_field'];
390 $theKey = $this->pObj->MOD_SETTINGS[
'ts_browser_toplevel_' . $bType];
391 if (!$theKey || !str_replace(
'-',
'', $theKey)) {
394 list($theSetup, $theSetupValue) = $this->templateService->ext_getSetup($theSetup, $this->pObj->MOD_SETTINGS[
'ts_browser_toplevel_' . $bType] ? $this->pObj->MOD_SETTINGS[
'ts_browser_toplevel_' . $bType] :
'');
395 $tree = $this->templateService->ext_getObjTree($theSetup, $theKey,
'',
'', $theSetupValue, $this->pObj->MOD_SETTINGS[
'ts_browser_alphaSort']);
396 $tree = $this->templateService->substituteCMarkers($tree);
401 $uriBuilder = GeneralUtility::makeInstance(\
TYPO3\CMS\Backend\Routing\UriBuilder::class);
402 $aHref = (string)$uriBuilder->buildUriFromRoute(
'web_ts', $urlParameters);
404 $pEkey = $bType ===
'setup' ?
'config' :
'constants';
405 $assigns[
'hasParseErrors'] = !empty($this->templateService->parserErrors[$pEkey]);
406 if (!empty($this->templateService->parserErrors[$pEkey])) {
407 $assigns[
'showErrorDetailsUri'] = $aHref .
'&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TemplateAnalyzerModuleFunctionController&template=all&SET[ts_analyzer_checkLinenum]=1#line-';
408 $assigns[
'parseErrors'] = $this->templateService->parserErrors[$pEkey];
411 if (isset($this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType][$theKey])) {
412 $assigns[
'moduleUrlRemoveFromObjectList'] = $aHref .
'&addKey[' . $theKey .
']=0&SET[ts_browser_toplevel_' . $bType .
']=0';
415 $assigns[
'hasKeySelected'] = $theKey !==
'';
418 $assigns[
'treeLabel'] = $theKey;
420 $assigns[
'rootLLKey'] = $bType ===
'setup' ?
'setupRoot' :
'constantRoot';
422 $assigns[
'tsTree'] = $tree;
425 $assigns[
'isSetupAndCropLinesDisabled'] = $bType ===
'setup' && !$this->pObj->MOD_SETTINGS[
'ts_browser_fixedLgd'];
426 $assigns[
'checkBoxShowComments'] =
BackendUtility::getFuncCheck($this->
id,
'SET[ts_browser_showComments]', $this->pObj->MOD_SETTINGS[
'ts_browser_showComments'],
'',
'',
'id="checkTs_browser_showComments"');
427 $assigns[
'checkBoxAlphaSort'] =
BackendUtility::getFuncCheck($this->
id,
'SET[ts_browser_alphaSort]', $this->pObj->MOD_SETTINGS[
'ts_browser_alphaSort'],
'',
'',
'id="checkTs_browser_alphaSort"');
428 $assigns[
'checkBoxCropLines'] =
BackendUtility::getFuncCheck($this->
id,
'SET[ts_browser_fixedLgd]', $this->pObj->MOD_SETTINGS[
'ts_browser_fixedLgd'],
'',
'',
'id="checkTs_browser_fixedLgd"');
429 if ($bType ===
'setup' && !$this->pObj->MOD_SETTINGS[
'ts_browser_fixedLgd']) {
430 $assigns[
'dropdownDisplayConstants'] =
BackendUtility::getDropdownMenu($this->
id,
'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS[
'ts_browser_const'], $this->pObj->MOD_MENU[
'ts_browser_const']);
434 $assigns[
'hasConditions'] = is_array($this->templateService->sections) && !empty($this->templateService->sections);
435 if (is_array($this->templateService->sections) && !empty($this->templateService->sections)) {
437 foreach ($this->templateService->sections as $key => $val) {
441 'label' => $this->templateService->substituteCMarkers(htmlspecialchars($val)),
442 'isSet' => $this->pObj->MOD_SETTINGS[
'tsbrowser_conditions'][$key] ? true : false
445 $assigns[
'tsConditions'] = $tsConditions;
450 $view = GeneralUtility::makeInstance(StandaloneView::class);
451 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
452 'EXT:tstemplate/Resources/Private/Templates/TemplateObjectBrowserModuleFunction.html'
454 $view->assignMultiple($assigns);
456 return $view->render();
467 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
469 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
470 $defaultFlashMessageQueue->enqueue($flashMessage);
483 if ($this->function_key) {
484 $this->extClassConf = $this->pObj->getExternalItemConfig(
'web_ts', $this->function_key, $this->pObj->MOD_SETTINGS[$this->function_key]);
509 return GeneralUtility::makeInstance(PageRenderer::class);