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