2 namespace TYPO3\CMS\Tstemplate\Controller;
51 parent::init(
$pObj, $conf);
52 $this->pObj->modMenu_dontValidateList .=
',ts_browser_toplevel_setup,ts_browser_toplevel_const,ts_browser_TLKeys_setup,ts_browser_TLKeys_const';
53 $this->pObj->modMenu_setDefaultList .=
',ts_browser_fixedLgd,ts_browser_showComments';
64 $lang->includeLLFile(
'EXT:tstemplate/Resources/Private/Language/locallang_objbrowser.xlf');
66 'ts_browser_type' => array(
67 'const' =>
$lang->getLL(
'constants'),
68 'setup' =>
$lang->getLL(
'setup')
70 'ts_browser_toplevel_setup' => array(
71 '0' =>
$lang->csConvObj->conv_case(
$lang->charSet,
$lang->getLL(
'all'),
'toUpper')
73 'ts_browser_toplevel_const' => array(
74 '0' =>
$lang->csConvObj->conv_case(
$lang->charSet,
$lang->getLL(
'all'),
'toUpper')
76 'ts_browser_const' => array(
77 '0' =>
$lang->getLL(
'plainSubstitution'),
78 'subst' =>
$lang->getLL(
'substitutedGreen'),
79 'const' =>
$lang->getLL(
'unsubstitutedGreen')
81 'ts_browser_regexsearch' =>
'1',
82 'ts_browser_fixedLgd' =>
'1',
83 'ts_browser_showComments' =>
'1',
84 'ts_browser_alphaSort' =>
'1'
86 foreach (array(
'setup',
'const') as $bType) {
89 if (is_array($addKey)) {
91 if (current($addKey)) {
92 $this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType][key($addKey)] = key($addKey);
94 unset($this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType][key($addKey)]);
98 if (!empty($this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType])) {
99 $modMenu[
'ts_browser_toplevel_' . $bType][
'-'] =
'---';
100 $modMenu[
'ts_browser_toplevel_' . $bType] = $modMenu[(
'ts_browser_toplevel_' . $bType)] + $this->pObj->MOD_SETTINGS[(
'ts_browser_TLKeys_' . $bType)];
123 'bodyTag' =>
'string'
139 'current' =>
'boolean'
143 $TSobjDataTypes = array(
144 'COBJ' =>
'TEXT,CONTENT',
149 if (isset($TSobjDataTypes[$parentType]) && (!$TSobjDataTypes[$parentType] || GeneralUtility::inlist($TSobjDataTypes[$parentType], $parentValue))) {
150 $ObjectKind = $parentValue;
157 $ObjectKind = $parentValue;
159 if ($ObjectKind && is_array($TSobjTable[$ObjectKind])) {
161 if (is_array($propertyArray)) {
162 foreach ($propertyArray as $key => $val) {
165 $result[$key] = $TSobjTable[$ObjectKind][
'prop'][
'1,2,3'];
168 $result[$key] = $TSobjTable[$ObjectKind][
'prop'][$key];
190 $GLOBALS[
'tmpl'] = $templateService;
193 $templateService->tt_track =
false;
194 $templateService->init();
198 $rootLine = $sys_page->getRootLine($pageId);
200 $templateService->runThroughTemplates($rootLine, $template_uid);
203 $GLOBALS[
'tplRow'] = $templateService->ext_getFirstTemplate($pageId, $template_uid);
204 return is_array(
$GLOBALS[
'tplRow']);
219 $manyTemplatesMenu = $this->pObj->templateMenu();
221 if ($manyTemplatesMenu) {
222 $template_uid = $this->pObj->MOD_SETTINGS[
'templatesOnPage'];
224 $bType = $this->pObj->MOD_SETTINGS[
'ts_browser_type'];
229 if ($existTemplate) {
231 $content =
' ' . $iconFactory->getIconForRecord(
'sys_template', $tplRow,
Icon::SIZE_SMALL)->render() .
' <strong>'
232 . $this->pObj->linkWrapTemplateTitle($tplRow[
'title'], ($bType ==
'setup' ?
'config' :
'constants')) .
'</strong>'
233 . (trim($tplRow[
'sitetitle']) ? htmlspecialchars(
' (' . $tplRow[
'sitetitle'] .
')') :
'');
234 $theOutput .=
'<h3>' .
$lang->getLL(
'currentTemplate',
true) .
'</h3>';
235 $theOutput .=
'<div>';
236 $theOutput .= $content;
237 $theOutput .=
'</div>';
239 if ($manyTemplatesMenu) {
240 $theOutput .= $manyTemplatesMenu;
242 $theOutput .=
'<div style="padding-top: 10px;"></div>';
243 if ($POST[
'add_property'] || $POST[
'update_value'] || $POST[
'clear_object']) {
246 if (is_array($POST[
'data'])) {
247 $name = key($POST[
'data']);
248 if ($POST[
'data'][$name][
'name'] !==
'') {
250 unset($POST[
'update_value']);
251 $POST[
'add_property'] =
'Add';
253 if ($POST[
'add_property']) {
254 $property = trim($POST[
'data'][$name][
'name']);
255 if (preg_replace(
'/[^a-zA-Z0-9_\\.]*/',
'', $property) != $property) {
257 $this->addFlashMessage($badPropertyMessage);
259 $pline = $name .
'.' . $property .
' = ' . trim($POST[
'data'][$name][
'propertyValue']);
261 $this->addFlashMessage($propertyAddedMessage);
262 $line .= LF . $pline;
264 }
elseif ($POST[
'update_value']) {
265 $pline = $name .
' = ' . trim($POST[
'data'][$name][
'value']);
267 $this->addFlashMessage($updatedMessage);
268 $line .= LF . $pline;
269 }
elseif ($POST[
'clear_object']) {
270 if ($POST[
'data'][$name][
'clearValue']) {
271 $pline = $name .
' >';
273 $this->addFlashMessage($objectClearedMessage);
274 $line .= LF . $pline;
279 $saveId = $tplRow[
'_ORIG_uid'] ? $tplRow[
'_ORIG_uid'] : $tplRow[
'uid'];
282 $field = $bType ==
'setup' ?
'config' :
'constants';
283 $recData[
'sys_template'][$saveId][$field] = $tplRow[$field] . $line;
286 $tce->stripslashes_values =
false;
288 $tce->start($recData, array());
290 $tce->process_datamap();
292 $tce->clear_cacheCmd(
'all');
301 if (is_array($tsbr)) {
303 $this->pObj->MOD_SETTINGS[
'tsbrowser_depthKeys_' . $bType] = $templateService->ext_depthKeys($tsbr, $this->pObj->MOD_SETTINGS[
'tsbrowser_depthKeys_' . $bType]);
306 if ($POST[
'Submit']) {
308 $this->pObj->MOD_SETTINGS[
'tsbrowser_conditions'] = $POST[
'conditions'];
314 $templateService->matchAlternative = $this->pObj->MOD_SETTINGS[
'tsbrowser_conditions'];
315 $templateService->matchAlternative[] =
'dummydummydummydummydummydummydummydummydummydummydummy';
317 $templateService->constantMode = $this->pObj->MOD_SETTINGS[
'ts_browser_const'];
318 if ($this->pObj->sObj && $templateService->constantMode) {
319 $templateService->constantMode =
'untouched';
321 $templateService->regexMode = $this->pObj->MOD_SETTINGS[
'ts_browser_regexsearch'];
322 $templateService->fixedLgd = $this->pObj->MOD_SETTINGS[
'ts_browser_fixedLgd'];
323 $templateService->linkObjects =
true;
324 $templateService->ext_regLinenumbers =
true;
325 $templateService->ext_regComments = $this->pObj->MOD_SETTINGS[
'ts_browser_showComments'];
326 $templateService->bType = $bType;
327 if ($this->pObj->MOD_SETTINGS[
'ts_browser_type'] ==
'const') {
332 $templateService->generateConfig();
333 if ($bType ==
'setup') {
334 $theSetup = $templateService->setup;
336 $theSetup = $templateService->setup_constants;
339 if ($this->pObj->sObj) {
340 list($theSetup, $theSetupValue) = $templateService->ext_getSetup($theSetup, $this->pObj->sObj ? $this->pObj->sObj :
'');
341 if ($existTemplate) {
343 $theOutput .=
'<div class="form-inline form-inline-spaced">';
346 $out .=
'<div class="form-group">';
347 $out .=
' <label>' . htmlspecialchars($this->pObj->sObj) .
' =' .
'</label>';
348 $out .=
' <input class="form-control" type="text" name="data[' . htmlspecialchars($this->pObj->sObj) .
'][value]" value="' . htmlspecialchars($theSetupValue) .
'"' . $documentTemplate->formWidth(40) .
' />';
349 $out .=
' <input class="btn btn-default" type="submit" name="update_value" value="' .
$lang->getLL(
'updateButton') .
'" />';
351 $theOutput .=
'<h3>' .
$lang->getLL(
'editProperty',
true) .
'</h3>';
354 $out =
'<div class="form-group">';
355 $out .=
' <label>' . htmlspecialchars($this->pObj->sObj) .
'.';
356 $out .=
' <input class="form-control" type="text" name="data[' . htmlspecialchars($this->pObj->sObj) .
'][name]"' . $documentTemplate->formWidth(20) .
' /> = ';
358 $out .=
' <input class="form-control" type="text" name="data[' . htmlspecialchars($this->pObj->sObj) .
'][propertyValue]"' . $documentTemplate->formWidth(40) .
' />';
359 $out .=
' <input class="btn btn-default" type="submit" name="add_property" value="' .
$lang->getLL(
'addButton') .
'" />';
361 $theOutput .=
'<div style="padding-top: 20px;"></div>';
362 $theOutput .=
'<h3>'.
$lang->getLL(
'addProperty',
true) .
'</h3>';
365 $out =
'<div class="form-group">';
366 $out .=
' <div class="checkbox">';
368 $out .=
' ' . htmlspecialchars($this->pObj->sObj) .
' ' .
$lang->csConvObj->conv_case(
$lang->charSet,
$lang->getLL(
'clear'),
'toUpper');
369 $out .=
' <input type="checkbox" name="data[' . htmlspecialchars($this->pObj->sObj) .
'][clearValue]" value="1" />';
371 $out .=
' <input class="btn btn-default" type="submit" name="clear_object" value="' .
$lang->getLL(
'clearButton') .
'" />';
374 $theOutput .=
'<div style="padding-top: 20px;"></div>';
375 $theOutput .=
'<h3>' .
$lang->getLL(
'clearObject',
true) .
'</h3>';
377 $theOutput .=
'<div style="padding-top: 10px;"></div>';
379 $theOutput .=
'</div>';
382 $this->addFlashMessage($noTemplateMessage);
383 $theOutput .= htmlspecialchars($this->pObj->sObj) .
' = <strong>' . htmlspecialchars($theSetupValue) .
'</strong>';
384 $theOutput .=
'<div style="padding-top: 10px;"></div>';
388 $urlParameters = array(
389 'id' => $this->pObj->id
391 $aHref = BackendUtility::getModuleUrl(
'web_ts', $urlParameters);
392 if (!$this->pObj->MOD_SETTINGS[(
'ts_browser_TLKeys_' . $bType)][$this->pObj->sObj]) {
393 if (!empty($theSetup)) {
394 $out =
'<a href="' . htmlspecialchars(($aHref .
'&addKey[' . rawurlencode($this->pObj->sObj) .
']=1&SET[ts_browser_toplevel_' . $bType .
']=' . rawurlencode($this->pObj->sObj))) .
'">';
395 $out .= sprintf(
$lang->getLL(
'addKey'), htmlspecialchars($this->pObj->sObj));
398 $out =
'<a href="' . htmlspecialchars(($aHref .
'&addKey[' . rawurlencode($this->pObj->sObj) .
']=0&SET[ts_browser_toplevel_' . $bType .
']=0')) .
'">';
399 $out .= sprintf(
$lang->getLL(
'removeKey'), htmlspecialchars($this->pObj->sObj));
402 $theOutput .=
'<div><hr style="margin-top: 5px; margin-bottom: 5px;" />' . $out .
'</div>';
405 $out =
$lang->getLL(
'back');
406 $out =
'<a href="' . htmlspecialchars($aHref) .
'" class="btn btn-default"><strong><i class="fa fa-chevron-left"></i> ' . $out .
'</strong></a>';
407 $theOutput .=
'<div><hr style="margin-top: 5px; margin-bottom: 5px;" />' . $out .
'</div>';
409 $templateService->tsbrowser_depthKeys = $this->pObj->MOD_SETTINGS[
'tsbrowser_depthKeys_' . $bType];
414 $templateService->tsbrowser_depthKeys =
415 $templateService->ext_getSearchKeys(
422 $this->addFlashMessage(
428 <div class="tsob-menu">
429 <div class="form-inline">';
430 if (is_array($this->pObj->MOD_MENU[
'ts_browser_type']) && count($this->pObj->MOD_MENU[
'ts_browser_type']) > 1) {
432 <div class="form-group">
433 <label class="control-label">' .
$lang->getLL(
'browse') .
'</label>'
437 if (is_array($this->pObj->MOD_MENU[
'ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU[
'ts_browser_toplevel_' . $bType]) > 1) {
439 <div class="form-group">
440 <label class="control-label" for="ts_browser_toplevel_' . $bType .
'">' .
$lang->getLL(
'objectList') .
'</label> '
441 .
BackendUtility::getDropdownMenu($this->pObj->id,
'SET[ts_browser_toplevel_' . $bType .
']', $this->pObj->MOD_SETTINGS[
'ts_browser_toplevel_' . $bType], $this->pObj->MOD_MENU[
'ts_browser_toplevel_' . $bType]) .
'
445 $this->
getPageRenderer()->loadRequireJsModule(
'TYPO3/CMS/Tstemplate/TypoScriptObjectBrowser');
448 <div class="form-group">
449 <label class="control-label" for="search_field">' .
$lang->getLL(
'search') .
'</label>
450 <div class="form-group"><input class="form-control" type="search" name="search_field" id="search_field" value="' . htmlspecialchars($POST[
'search_field']) .
'" /></div>
452 <input class="btn btn-default tsob-search-submit" type="submit" name="search" value="' .
$lang->sL(
'LLL:EXT:lang/locallang_common.xlf:search') .
'" />
454 <div class="checkbox">
455 <label for="checkTs_browser_regexsearch">
456 ' .
BackendUtility::getFuncCheck($this->pObj->id,
'SET[ts_browser_regexsearch]', $this->pObj->MOD_SETTINGS[
'ts_browser_regexsearch'],
'',
'',
'id="checkTs_browser_regexsearch"') .
$lang->getLL(
'regExp') .
'
460 $theKey = $this->pObj->MOD_SETTINGS[
'ts_browser_toplevel_' . $bType];
461 if (!$theKey || !str_replace(
'-',
'', $theKey)) {
464 list($theSetup, $theSetupValue) = $templateService->ext_getSetup($theSetup, $this->pObj->MOD_SETTINGS[
'ts_browser_toplevel_' . $bType] ? $this->pObj->MOD_SETTINGS[
'ts_browser_toplevel_' . $bType] :
'');
465 $tree = $templateService->ext_getObjTree($theSetup, $theKey,
'',
'', $theSetupValue, $this->pObj->MOD_SETTINGS[
'ts_browser_alphaSort']);
466 $tree = $templateService->substituteCMarkers($tree);
467 $urlParameters = array(
468 'id' => $this->pObj->id
470 $aHref = BackendUtility::getModuleUrl(
'web_ts', $urlParameters);
472 $pEkey = $bType ==
'setup' ?
'config' :
'constants';
473 if (!empty($templateService->parserErrors[$pEkey])) {
475 foreach ($templateService->parserErrors[$pEkey] as $inf) {
476 $errorLink =
' <a href="' . htmlspecialchars(($aHref .
'&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TemplateAnalyzerModuleFunctionController&template=all&SET[ts_analyzer_checkLinenum]=1#line-' . $inf[2])) .
'" class="text-warning">' .
$lang->getLL(
'errorShowDetails') .
'</a>';
477 $errMsg[] =
$lang->getLL(
'severity.' . $inf[1]) .
': ' . $inf[0] . $errorLink;
479 $theOutput .=
'<div style="padding-top: 10px;"></div>';
481 $title =
$lang->getLL(
'errorsWarnings');
482 $message =
'<p>' . implode($errMsg,
'<br />') .
'</p>';
485 $view->assignMultiple(array(
487 'message' => $message,
490 $theOutput .= $view->render();
493 if (isset($this->pObj->MOD_SETTINGS[
'ts_browser_TLKeys_' . $bType][$theKey])) {
494 $remove =
'<a href="' . htmlspecialchars(($aHref .
'&addKey[' . $theKey .
']=0&SET[ts_browser_toplevel_' . $bType .
']=0')) .
'">' .
$lang->getLL(
'removeKey') .
'</a>';
499 $label = $theKey ? $theKey : ($bType ==
'setup' ?
$lang->csConvObj->conv_case(
$lang->charSet,
$lang->getLL(
'setupRoot'),
'toUpper') :
$lang->csConvObj->conv_case(
$lang->charSet,
$lang->getLL(
'constantRoot'),
'toUpper'));
501 $theOutput .=
'<div class="panel panel-space panel-default">';
502 $theOutput .=
'<div class="panel-heading">';
503 $theOutput .=
'<strong>' . $label .
' ' . $remove .
'</strong>';
504 $theOutput .=
'</div>';
505 $theOutput .=
'<div class="panel-body">' . $tree .
'</div>';
506 $theOutput .=
'</div>';
509 $menu =
'<div class="typo3-listOptions">';
510 $menu .=
'<div class="checkbox"><label for="checkTs_browser_showComments">' .
BackendUtility::getFuncCheck($this->pObj->id,
'SET[ts_browser_showComments]', $this->pObj->MOD_SETTINGS[
'ts_browser_showComments'],
'',
'',
'id="checkTs_browser_showComments"');
511 $menu .=
$lang->getLL(
'displayComments') .
'</label></div>';
512 $menu .=
'<div class="checkbox"><label for="checkTs_browser_alphaSort">' .
BackendUtility::getFuncCheck($this->pObj->id,
'SET[ts_browser_alphaSort]', $this->pObj->MOD_SETTINGS[
'ts_browser_alphaSort'],
'',
'',
'id="checkTs_browser_alphaSort"');
513 $menu .=
$lang->getLL(
'sortAlphabetically') .
'</label></div>';
514 $menu .=
'<div class="checkbox"><label for="checkTs_browser_fixedLgd">' .
BackendUtility::getFuncCheck($this->pObj->id,
'SET[ts_browser_fixedLgd]', $this->pObj->MOD_SETTINGS[
'ts_browser_fixedLgd'],
'',
'',
'id="checkTs_browser_fixedLgd"');
515 $menu .=
$lang->getLL(
'cropLines') .
'</label></div>';
516 if ($bType ==
'setup' && !$this->pObj->MOD_SETTINGS[
'ts_browser_fixedLgd']) {
517 $menu .=
'<div class="form"><label>' .
$lang->getLL(
'displayConstants') .
'</label>';
518 $menu .=
BackendUtility::getDropdownMenu($this->pObj->id,
'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS[
'ts_browser_const'], $this->pObj->MOD_MENU[
'ts_browser_const']);
524 $theOutput .=
'<div>';
525 $theOutput .=
'<h2>' .
$lang->getLL(
'displayOptions',
true) .
'</h2>';
528 if (is_array($templateService->sections) && !empty($templateService->sections)) {
529 $theOutput .=
'<h2>' .
$lang->getLL(
'conditions',
true) .
'</h2>';
531 foreach ($templateService->sections as $key => $val) {
532 $out .=
'<div class="checkbox"><label for="check' . $key .
'">';
533 $out .=
'<input class="checkbox" type="checkbox" name="conditions[' . $key .
']" id="check' . $key .
'" value="' . htmlspecialchars($val) .
'"' . ($this->pObj->MOD_SETTINGS[
'tsbrowser_conditions'][$key] ?
' checked' :
'') .
' />' . $templateService->substituteCMarkers(htmlspecialchars($val));
534 $out .=
'</label></div>';
536 $theOutput .=
'<div class="typo3-listOptions">' . $out .
'</div><input class="btn btn-default" type="submit" name="Submit" value="' .
$lang->getLL(
'setConditions') .
'" />';
539 $theOutput .=
'</div>';
550 protected function addFlashMessage(
FlashMessage $flashMessage)
555 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
556 $defaultFlashMessageQueue->enqueue($flashMessage);