044f971e19524d1fc78e887f9a6fd2e7baff5550
[Packages/TYPO3.CMS.git] / typo3 / sysext / tstemplate / Classes / Controller / TypoScriptTemplateObjectBrowserModuleFunctionController.php
1 <?php
2 namespace TYPO3\CMS\Tstemplate\Controller;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Module\AbstractFunctionModule;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Core\DataHandling\DataHandler;
20 use TYPO3\CMS\Core\Imaging\Icon;
21 use TYPO3\CMS\Core\Imaging\IconFactory;
22 use TYPO3\CMS\Core\Messaging\FlashMessage;
23 use TYPO3\CMS\Core\Messaging\FlashMessageService;
24 use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
25 use TYPO3\CMS\Core\Utility\GeneralUtility;
26 use TYPO3\CMS\Core\Utility\MathUtility;
27 use TYPO3\CMS\Fluid\View\StandaloneView;
28 use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper;
29 use TYPO3\CMS\Frontend\Page\PageRepository;
30
31 /**
32 * This class displays the submodule "TypoScript Object Browser" inside the Web > Template module
33 */
34 class TypoScriptTemplateObjectBrowserModuleFunctionController extends AbstractFunctionModule
35 {
36 /**
37 * @var TypoScriptTemplateModuleController
38 */
39 public $pObj;
40
41 /**
42 * Init
43 *
44 * @param TypoScriptTemplateModuleController $pObj
45 * @param array $conf
46 * @return void
47 */
48 public function init(&$pObj, $conf)
49 {
50 parent::init($pObj, $conf);
51 $this->pObj->modMenu_dontValidateList .= ',ts_browser_toplevel_setup,ts_browser_toplevel_const,ts_browser_TLKeys_setup,ts_browser_TLKeys_const';
52 $this->pObj->modMenu_setDefaultList .= ',ts_browser_fixedLgd,ts_browser_showComments';
53 }
54
55 /**
56 * Mod menu
57 *
58 * @return array
59 */
60 public function modMenu()
61 {
62 $lang = $this->getLanguageService();
63 $lang->includeLLFile('EXT:tstemplate/Resources/Private/Language/locallang_objbrowser.xlf');
64 $modMenu = array(
65 'ts_browser_type' => array(
66 'const' => $lang->getLL('constants'),
67 'setup' => $lang->getLL('setup')
68 ),
69 'ts_browser_toplevel_setup' => array(
70 '0' => $lang->csConvObj->conv_case($lang->charSet, $lang->getLL('all'), 'toUpper')
71 ),
72 'ts_browser_toplevel_const' => array(
73 '0' => $lang->csConvObj->conv_case($lang->charSet, $lang->getLL('all'), 'toUpper')
74 ),
75 'ts_browser_const' => array(
76 '0' => $lang->getLL('plainSubstitution'),
77 'subst' => $lang->getLL('substitutedGreen'),
78 'const' => $lang->getLL('unsubstitutedGreen')
79 ),
80 'ts_browser_regexsearch' => '1',
81 'ts_browser_fixedLgd' => '1',
82 'ts_browser_showComments' => '1',
83 'ts_browser_alphaSort' => '1'
84 );
85 foreach (array('setup', 'const') as $bType) {
86 $addKey = GeneralUtility::_GET('addKey');
87 // If any plus-signs were clicked, it's registered.
88 if (is_array($addKey)) {
89 reset($addKey);
90 if (current($addKey)) {
91 $this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][key($addKey)] = key($addKey);
92 } else {
93 unset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][key($addKey)]);
94 }
95 $this->getBackendUserAuthentication()->pushModuleData($this->pObj->MCONF['name'], $this->pObj->MOD_SETTINGS);
96 }
97 if (!empty($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType])) {
98 $modMenu['ts_browser_toplevel_' . $bType]['-'] = '---';
99 $modMenu['ts_browser_toplevel_' . $bType] = $modMenu[('ts_browser_toplevel_' . $bType)] + $this->pObj->MOD_SETTINGS[('ts_browser_TLKeys_' . $bType)];
100 }
101 }
102 return $modMenu;
103 }
104
105 /**
106 * Verify TS objects
107 *
108 * @param array $propertyArray
109 * @param string $parentType
110 * @param string $parentValue
111 * @return array|NULL
112 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
113 */
114 public function verify_TSobjects($propertyArray, $parentType, $parentValue)
115 {
116 GeneralUtility::logDeprecatedFunction();
117 $TSobjTable = array(
118 'PAGE' => array(
119 'prop' => array(
120 'typeNum' => 'int',
121 '1,2,3' => 'COBJ',
122 'bodyTag' => 'string'
123 )
124 ),
125 'TEXT' => array(
126 'prop' => array(
127 'value' => 'string'
128 )
129 ),
130 'HTML' => array(
131 'prop' => array(
132 'value' => 'stdWrap'
133 )
134 ),
135 'stdWrap' => array(
136 'prop' => array(
137 'field' => 'string',
138 'current' => 'boolean'
139 )
140 )
141 );
142 $TSobjDataTypes = array(
143 'COBJ' => 'TEXT,CONTENT',
144 'PAGE' => 'PAGE',
145 'stdWrap' => ''
146 );
147 if ($parentType) {
148 if (isset($TSobjDataTypes[$parentType]) && (!$TSobjDataTypes[$parentType] || GeneralUtility::inlist($TSobjDataTypes[$parentType], $parentValue))) {
149 $ObjectKind = $parentValue;
150 } else {
151 // Object kind is "" if it should be known.
152 $ObjectKind = '';
153 }
154 } else {
155 // If parentType is not given, then it can be anything. Free.
156 $ObjectKind = $parentValue;
157 }
158 if ($ObjectKind && is_array($TSobjTable[$ObjectKind])) {
159 $result = array();
160 if (is_array($propertyArray)) {
161 foreach ($propertyArray as $key => $val) {
162 if (MathUtility::canBeInterpretedAsInteger($key)) {
163 // If num-arrays
164 $result[$key] = $TSobjTable[$ObjectKind]['prop']['1,2,3'];
165 } else {
166 // standard
167 $result[$key] = $TSobjTable[$ObjectKind]['prop'][$key];
168 }
169 }
170 }
171 return $result;
172 }
173 return null;
174 }
175
176 /**
177 * Initialize editor
178 *
179 * Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
180 *
181 * @param int $pageId
182 * @param int $template_uid
183 * @return int
184 */
185 public function initialize_editor($pageId, $template_uid = 0)
186 {
187 // Defined global here!
188 $templateService = GeneralUtility::makeInstance(ExtendedTemplateService::class);
189 $GLOBALS['tmpl'] = $templateService;
190
191 // Do not log time-performance information
192 $templateService->tt_track = false;
193 $templateService->init();
194
195 // Gets the rootLine
196 $sys_page = GeneralUtility::makeInstance(PageRepository::class);
197 $rootLine = $sys_page->getRootLine($pageId);
198 // This generates the constants/config + hierarchy info for the template.
199 $templateService->runThroughTemplates($rootLine, $template_uid);
200
201 // Get the row of the first VISIBLE template of the page. whereclause like the frontend.
202 $GLOBALS['tplRow'] = $templateService->ext_getFirstTemplate($pageId, $template_uid);
203 return is_array($GLOBALS['tplRow']);
204 }
205
206 /**
207 * Main
208 *
209 * @return string
210 */
211 public function main()
212 {
213 $lang = $this->getLanguageService();
214 $POST = GeneralUtility::_POST();
215 $documentTemplate = $this->getDocumentTemplate();
216
217 // Checking for more than one template an if, set a menu...
218 $manyTemplatesMenu = $this->pObj->templateMenu();
219 $template_uid = 0;
220 if ($manyTemplatesMenu) {
221 $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
222 }
223 $bType = $this->pObj->MOD_SETTINGS['ts_browser_type'];
224 $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
225 $tplRow = $this->getTemplateRow();
226 // initialize
227 $theOutput = '';
228 if ($existTemplate) {
229 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
230 $content = ' ' . $iconFactory->getIconForRecord('sys_template', $tplRow, Icon::SIZE_SMALL)->render() . ' <strong>'
231 . $this->pObj->linkWrapTemplateTitle($tplRow['title'], ($bType == 'setup' ? 'config' : 'constants')) . '</strong>'
232 . (trim($tplRow['sitetitle']) ? htmlspecialchars(' (' . $tplRow['sitetitle'] . ')') : '');
233 $theOutput .= $this->pObj->doc->section($lang->getLL('currentTemplate'), $content);
234 if ($manyTemplatesMenu) {
235 $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
236 }
237 $theOutput .= $this->pObj->doc->spacer(10);
238 if ($POST['add_property'] || $POST['update_value'] || $POST['clear_object']) {
239 // add property
240 $line = '';
241 if (is_array($POST['data'])) {
242 $name = key($POST['data']);
243 if ($POST['data'][$name]['name'] !== '') {
244 // Workaround for this special case: User adds a key and submits by pressing the return key. The form however will use "add_property" which is the name of the first submit button in this form.
245 unset($POST['update_value']);
246 $POST['add_property'] = 'Add';
247 }
248 if ($POST['add_property']) {
249 $property = trim($POST['data'][$name]['name']);
250 if (preg_replace('/[^a-zA-Z0-9_\\.]*/', '', $property) != $property) {
251 $badPropertyMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noSpaces') . '<br />' . $lang->getLL('nothingUpdated'), $lang->getLL('badProperty'), FlashMessage::ERROR);
252 $this->addFlashMessage($badPropertyMessage);
253 } else {
254 $pline = $name . '.' . $property . ' = ' . trim($POST['data'][$name]['propertyValue']);
255 $propertyAddedMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($pline), $lang->getLL('propertyAdded'));
256 $this->addFlashMessage($propertyAddedMessage);
257 $line .= LF . $pline;
258 }
259 } elseif ($POST['update_value']) {
260 $pline = $name . ' = ' . trim($POST['data'][$name]['value']);
261 $updatedMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($pline), $lang->getLL('valueUpdated'));
262 $this->addFlashMessage($updatedMessage);
263 $line .= LF . $pline;
264 } elseif ($POST['clear_object']) {
265 if ($POST['data'][$name]['clearValue']) {
266 $pline = $name . ' >';
267 $objectClearedMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($pline), $lang->getLL('objectCleared'));
268 $this->addFlashMessage($objectClearedMessage);
269 $line .= LF . $pline;
270 }
271 }
272 }
273 if ($line) {
274 $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
275 // Set the data to be saved
276 $recData = array();
277 $field = $bType == 'setup' ? 'config' : 'constants';
278 $recData['sys_template'][$saveId][$field] = $tplRow[$field] . $line;
279 // Create new tce-object
280 $tce = GeneralUtility::makeInstance(DataHandler::class);
281 $tce->stripslashes_values = false;
282 // Initialize
283 $tce->start($recData, array());
284 // Saved the stuff
285 $tce->process_datamap();
286 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
287 $tce->clear_cacheCmd('all');
288 // re-read the template ...
289 $this->initialize_editor($this->pObj->id, $template_uid);
290 }
291 }
292 }
293 $tsbr = GeneralUtility::_GET('tsbr');
294 $templateService = $this->getExtendedTemplateService();
295 $update = 0;
296 if (is_array($tsbr)) {
297 // If any plus-signs were clicked, it's registred.
298 $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType] = $templateService->ext_depthKeys($tsbr, $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType]);
299 $update = 1;
300 }
301 if ($POST['Submit']) {
302 // If any POST-vars are send, update the condition array
303 $this->pObj->MOD_SETTINGS['tsbrowser_conditions'] = $POST['conditions'];
304 $update = 1;
305 }
306 if ($update) {
307 $this->getBackendUserAuthentication()->pushModuleData($this->pObj->MCONF['name'], $this->pObj->MOD_SETTINGS);
308 }
309 $templateService->matchAlternative = $this->pObj->MOD_SETTINGS['tsbrowser_conditions'];
310 $templateService->matchAlternative[] = 'dummydummydummydummydummydummydummydummydummydummydummy';
311 // This is just here to make sure that at least one element is in the array so that the tsparser actually uses this array to match.
312 $templateService->constantMode = $this->pObj->MOD_SETTINGS['ts_browser_const'];
313 if ($this->pObj->sObj && $templateService->constantMode) {
314 $templateService->constantMode = 'untouched';
315 }
316 $templateService->regexMode = $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'];
317 $templateService->fixedLgd = $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'];
318 $templateService->linkObjects = true;
319 $templateService->ext_regLinenumbers = true;
320 $templateService->ext_regComments = $this->pObj->MOD_SETTINGS['ts_browser_showComments'];
321 $templateService->bType = $bType;
322 if ($this->pObj->MOD_SETTINGS['ts_browser_type'] == 'const') {
323 $templateService->ext_constants_BRP = (int)GeneralUtility::_GP('breakPointLN');
324 } else {
325 $templateService->ext_config_BRP = (int)GeneralUtility::_GP('breakPointLN');
326 }
327 $templateService->generateConfig();
328 if ($bType == 'setup') {
329 $theSetup = $templateService->setup;
330 } else {
331 $theSetup = $templateService->setup_constants;
332 }
333 // EDIT A VALUE:
334 if ($this->pObj->sObj) {
335 list($theSetup, $theSetupValue) = $templateService->ext_getSetup($theSetup, $this->pObj->sObj ? $this->pObj->sObj : '');
336 if ($existTemplate) {
337 // Inline Form Area Begin
338 $theOutput .= '<div class="form-inline form-inline-spaced">';
339 // Value
340 $out = '';
341 $out .= '<div class="form-group">';
342 $out .= ' <label>' . htmlspecialchars($this->pObj->sObj) . ' =' . '</label>';
343 $out .= ' <input class="form-control" type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][value]" value="' . htmlspecialchars($theSetupValue) . '"' . $documentTemplate->formWidth(40) . ' />';
344 $out .= ' <input class="btn btn-default" type="submit" name="update_value" value="' . $lang->getLL('updateButton') . '" />';
345 $out .= '</div>';
346 $theOutput .= $this->pObj->doc->section($lang->getLL('editProperty'), $out, 0, 0);
347 // Property
348 $out = '<div class="form-group">';
349 $out .= ' <label>' . htmlspecialchars($this->pObj->sObj) . '.';
350 $out .= ' <input class="form-control" type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][name]"' . $documentTemplate->formWidth(20) . ' /> = ';
351 $out .= ' </label>';
352 $out .= ' <input class="form-control" type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][propertyValue]"' . $documentTemplate->formWidth(40) . ' />';
353 $out .= ' <input class="btn btn-default" type="submit" name="add_property" value="' . $lang->getLL('addButton') . '" />';
354 $out .= '</div>';
355 $theOutput .= $this->pObj->doc->spacer(20);
356 $theOutput .= $this->pObj->doc->section($lang->getLL('addProperty'), $out, 0, 0);
357 // clear
358 $out = '<div class="form-group">';
359 $out .= ' <div class="checkbox">';
360 $out .= ' <label>';
361 $out .= ' ' . htmlspecialchars($this->pObj->sObj) . ' ' . $lang->csConvObj->conv_case($lang->charSet, $lang->getLL('clear'), 'toUpper');
362 $out .= ' <input type="checkbox" name="data[' . htmlspecialchars($this->pObj->sObj) . '][clearValue]" value="1" />';
363 $out .= ' </label>';
364 $out .= ' <input class="btn btn-default" type="submit" name="clear_object" value="' . $lang->getLL('clearButton') . '" />';
365 $out .= ' </div>';
366 $out .= '</div>';
367 $theOutput .= $this->pObj->doc->spacer(20);
368 $theOutput .= $this->pObj->doc->section($lang->getLL('clearObject'), $out, 0, 0);
369 $theOutput .= $this->pObj->doc->spacer(10);
370 // Inline Form Area End
371 $theOutput .= '</div>';
372 } else {
373 $noTemplateMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noCurrentTemplate'), $lang->getLL('edit'), FlashMessage::ERROR);
374 $this->addFlashMessage($noTemplateMessage);
375 $theOutput .= htmlspecialchars($this->pObj->sObj) . ' = <strong>' . htmlspecialchars($theSetupValue) . '</strong>';
376 $theOutput .= $this->pObj->doc->spacer(10);
377 }
378 // Links:
379 $out = '';
380 $urlParameters = array(
381 'id' => $this->pObj->id
382 );
383 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
384 if (!$this->pObj->MOD_SETTINGS[('ts_browser_TLKeys_' . $bType)][$this->pObj->sObj]) {
385 if (!empty($theSetup)) {
386 $out = '<a href="' . htmlspecialchars(($aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=1&SET[ts_browser_toplevel_' . $bType . ']=' . rawurlencode($this->pObj->sObj))) . '">';
387 $out .= sprintf($lang->getLL('addKey'), htmlspecialchars($this->pObj->sObj));
388 }
389 } else {
390 $out = '<a href="' . htmlspecialchars(($aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0')) . '">';
391 $out .= sprintf($lang->getLL('removeKey'), htmlspecialchars($this->pObj->sObj));
392 }
393 if ($out) {
394 $theOutput .= $this->pObj->doc->divider(5);
395 $theOutput .= $this->pObj->doc->section('', $out);
396 }
397 // back
398 $out = $lang->getLL('back');
399 $out = '<a href="' . htmlspecialchars($aHref) . '" class="btn btn-default"><strong><i class="fa fa-chevron-left"></i>&nbsp;' . $out . '</strong></a>';
400 $theOutput .= $this->pObj->doc->divider(5);
401 $theOutput .= $this->pObj->doc->section('', $out);
402 } else {
403 $templateService->tsbrowser_depthKeys = $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType];
404 if (GeneralUtility::_POST('search') && GeneralUtility::_POST('search_field')) {
405 // If any POST-vars are send, update the condition array
406 $templateService->tsbrowser_depthKeys = $templateService->ext_getSearchKeys($theSetup, '', GeneralUtility::_POST('search_field'), array());
407 }
408 $theOutput .= '
409 <div class="tsob-menu">
410 <div class="form-inline">';
411 if (is_array($this->pObj->MOD_MENU['ts_browser_type']) && count($this->pObj->MOD_MENU['ts_browser_type']) > 1) {
412 $theOutput .= '
413 <div class="form-group">
414 <label class="control-label">' . $lang->getLL('browse') . '</label>'
415 . BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_type]', $bType, $this->pObj->MOD_MENU['ts_browser_type']) . '
416 </div>';
417 }
418 if (is_array($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) > 1) {
419 $theOutput .= '
420 <div class="form-group">
421 <label class="control-label" for="ts_browser_toplevel_' . $bType . '">' . $lang->getLL('objectList') . '</label> '
422 . 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]) . '
423 </div>';
424 }
425
426 $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Tstemplate/TypoScriptObjectBrowser');
427
428 $theOutput .= '
429 <div class="form-group">
430 <label class="control-label" for="search_field">' . $lang->getLL('search') . '</label>
431 <div class="form-group"><input class="form-control" type="search" name="search_field" id="search_field" value="' . htmlspecialchars($POST['search_field']) . '" /></div>
432 </div>
433 <input class="btn btn-default tsob-search-submit" type="submit" name="search" value="' . $lang->sL('LLL:EXT:lang/locallang_common.xlf:search') . '" />
434 </div>
435 <div class="checkbox">
436 <label for="checkTs_browser_regexsearch">
437 ' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_regexsearch]', $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'], '', '', 'id="checkTs_browser_regexsearch"') . $lang->getLL('regExp') . '
438 </label>
439 </div>
440 </div>';
441 $theKey = $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType];
442 if (!$theKey || !str_replace('-', '', $theKey)) {
443 $theKey = '';
444 }
445 list($theSetup, $theSetupValue) = $templateService->ext_getSetup($theSetup, $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] ? $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] : '');
446 $tree = $templateService->ext_getObjTree($theSetup, $theKey, '', '', $theSetupValue, $this->pObj->MOD_SETTINGS['ts_browser_alphaSort']);
447 $tree = $templateService->substituteCMarkers($tree);
448 $urlParameters = array(
449 'id' => $this->pObj->id
450 );
451 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
452 // Parser Errors:
453 $pEkey = $bType == 'setup' ? 'config' : 'constants';
454 if (!empty($templateService->parserErrors[$pEkey])) {
455 $errMsg = array();
456 foreach ($templateService->parserErrors[$pEkey] as $inf) {
457 $errorLink = ' <a href="' . htmlspecialchars(($aHref . '&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TemplateAnalyzerModuleFunctionController&template=all&SET[ts_analyzer_checkLinenum]=1#line-' . $inf[2])) . '">' . $lang->getLL('errorShowDetails') . '</a>';
458 $errMsg[] = $inf[1] . ': &nbsp; &nbsp;' . $inf[0] . $errorLink;
459 }
460 $theOutput .= $this->pObj->doc->spacer(10);
461
462 $title = $lang->getLL('errorsWarnings');
463 $message = '<p>' . implode($errMsg, '<br />') . '</p>';
464 $view = GeneralUtility::makeInstance(StandaloneView::class);
465 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/InfoBox.html'));
466 $view->assignMultiple(array(
467 'title' => $title,
468 'message' => $message,
469 'state' => InfoboxViewHelper::STATE_WARNING
470 ));
471 $theOutput .= $view->render();
472 }
473
474 if (isset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$theKey])) {
475 $remove = '<a href="' . htmlspecialchars(($aHref . '&addKey[' . $theKey . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0')) . '">' . $lang->getLL('removeKey') . '</a>';
476 } else {
477 $remove = '';
478 }
479
480 $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'));
481 $theOutput .= $this->pObj->doc->sectionEnd();
482
483 $theOutput .= '<div class="panel panel-space panel-default">';
484 $theOutput .= '<div class="panel-heading">';
485 $theOutput .= '<strong>' . $label . ' ' . $remove . '</strong>';
486 $theOutput .= '</div>';
487 $theOutput .= '<div class="panel-body">' . $tree . '</div>';
488 $theOutput .= '</div>';
489
490 // second row options
491 $menu = '<div class="typo3-listOptions">';
492 $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"');
493 $menu .= $lang->getLL('displayComments') . '</label></div>';
494 $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"');
495 $menu .= $lang->getLL('sortAlphabetically') . '</label></div>';
496 $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"');
497 $menu .= $lang->getLL('cropLines') . '</label></div>';
498 if ($bType == 'setup' && !$this->pObj->MOD_SETTINGS['ts_browser_fixedLgd']) {
499 $menu .= '<div class="form"><label>' . $lang->getLL('displayConstants') . '</label>';
500 $menu .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS['ts_browser_const'], $this->pObj->MOD_MENU['ts_browser_const']);
501 $menu .= '</div>';
502 }
503 $menu .= '</div>';
504 $theOutput .= $this->pObj->doc->section($lang->getLL('displayOptions'), $menu, 0, 1);
505 // Conditions:
506 if (is_array($templateService->sections) && !empty($templateService->sections)) {
507 $theOutput .= $this->pObj->doc->section($lang->getLL('conditions'), '', 0, 1);
508 $out = '';
509 foreach ($templateService->sections as $key => $val) {
510 $out .= '<div class="checkbox"><label for="check' . $key . '">';
511 $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));
512 $out .= '</label></div>';
513 }
514 $theOutput .= '<div class="typo3-listOptions">' . $out . '</div><input class="btn btn-default" type="submit" name="Submit" value="' . $lang->getLL('setConditions') . '" />';
515 }
516 // Ending section:
517 $theOutput .= $this->pObj->doc->sectionEnd();
518 }
519 return $theOutput;
520 }
521
522 /**
523 * Add flash message to queue
524 *
525 * @param FlashMessage $flashMessage
526 * @return void
527 */
528 protected function addFlashMessage(FlashMessage $flashMessage)
529 {
530 /** @var $flashMessageService FlashMessageService */
531 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
532 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
533 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
534 $defaultFlashMessageQueue->enqueue($flashMessage);
535 }
536
537 /**
538 * @return ExtendedTemplateService
539 */
540 protected function getExtendedTemplateService()
541 {
542 return $GLOBALS['tmpl'];
543 }
544
545 /**
546 * @return array
547 */
548 protected function getTemplateRow()
549 {
550 return $GLOBALS['tplRow'];
551 }
552 }