[TASK] Improve appearance of warnings in object browser
[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 .= '<h3>' . $lang->getLL('currentTemplate', true) . '</h3>';
234 $theOutput .= '<div>';
235 $theOutput .= $content;
236 $theOutput .= '</div>';
237
238 if ($manyTemplatesMenu) {
239 $theOutput .= $manyTemplatesMenu;
240 }
241 $theOutput .= '<div style="padding-top: 10px;"></div>';
242 if ($POST['add_property'] || $POST['update_value'] || $POST['clear_object']) {
243 // add property
244 $line = '';
245 if (is_array($POST['data'])) {
246 $name = key($POST['data']);
247 if ($POST['data'][$name]['name'] !== '') {
248 // 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.
249 unset($POST['update_value']);
250 $POST['add_property'] = 'Add';
251 }
252 if ($POST['add_property']) {
253 $property = trim($POST['data'][$name]['name']);
254 if (preg_replace('/[^a-zA-Z0-9_\\.]*/', '', $property) != $property) {
255 $badPropertyMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noSpaces') . '<br />' . $lang->getLL('nothingUpdated'), $lang->getLL('badProperty'), FlashMessage::ERROR);
256 $this->addFlashMessage($badPropertyMessage);
257 } else {
258 $pline = $name . '.' . $property . ' = ' . trim($POST['data'][$name]['propertyValue']);
259 $propertyAddedMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($pline), $lang->getLL('propertyAdded'));
260 $this->addFlashMessage($propertyAddedMessage);
261 $line .= LF . $pline;
262 }
263 } elseif ($POST['update_value']) {
264 $pline = $name . ' = ' . trim($POST['data'][$name]['value']);
265 $updatedMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($pline), $lang->getLL('valueUpdated'));
266 $this->addFlashMessage($updatedMessage);
267 $line .= LF . $pline;
268 } elseif ($POST['clear_object']) {
269 if ($POST['data'][$name]['clearValue']) {
270 $pline = $name . ' >';
271 $objectClearedMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($pline), $lang->getLL('objectCleared'));
272 $this->addFlashMessage($objectClearedMessage);
273 $line .= LF . $pline;
274 }
275 }
276 }
277 if ($line) {
278 $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
279 // Set the data to be saved
280 $recData = array();
281 $field = $bType == 'setup' ? 'config' : 'constants';
282 $recData['sys_template'][$saveId][$field] = $tplRow[$field] . $line;
283 // Create new tce-object
284 $tce = GeneralUtility::makeInstance(DataHandler::class);
285 $tce->stripslashes_values = false;
286 // Initialize
287 $tce->start($recData, array());
288 // Saved the stuff
289 $tce->process_datamap();
290 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
291 $tce->clear_cacheCmd('all');
292 // re-read the template ...
293 $this->initialize_editor($this->pObj->id, $template_uid);
294 }
295 }
296 }
297 $tsbr = GeneralUtility::_GET('tsbr');
298 $templateService = $this->getExtendedTemplateService();
299 $update = 0;
300 if (is_array($tsbr)) {
301 // If any plus-signs were clicked, it's registred.
302 $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType] = $templateService->ext_depthKeys($tsbr, $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType]);
303 $update = 1;
304 }
305 if ($POST['Submit']) {
306 // If any POST-vars are send, update the condition array
307 $this->pObj->MOD_SETTINGS['tsbrowser_conditions'] = $POST['conditions'];
308 $update = 1;
309 }
310 if ($update) {
311 $this->getBackendUserAuthentication()->pushModuleData($this->pObj->MCONF['name'], $this->pObj->MOD_SETTINGS);
312 }
313 $templateService->matchAlternative = $this->pObj->MOD_SETTINGS['tsbrowser_conditions'];
314 $templateService->matchAlternative[] = 'dummydummydummydummydummydummydummydummydummydummydummy';
315 // 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.
316 $templateService->constantMode = $this->pObj->MOD_SETTINGS['ts_browser_const'];
317 if ($this->pObj->sObj && $templateService->constantMode) {
318 $templateService->constantMode = 'untouched';
319 }
320 $templateService->regexMode = $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'];
321 $templateService->fixedLgd = $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'];
322 $templateService->linkObjects = true;
323 $templateService->ext_regLinenumbers = true;
324 $templateService->ext_regComments = $this->pObj->MOD_SETTINGS['ts_browser_showComments'];
325 $templateService->bType = $bType;
326 if ($this->pObj->MOD_SETTINGS['ts_browser_type'] == 'const') {
327 $templateService->ext_constants_BRP = (int)GeneralUtility::_GP('breakPointLN');
328 } else {
329 $templateService->ext_config_BRP = (int)GeneralUtility::_GP('breakPointLN');
330 }
331 $templateService->generateConfig();
332 if ($bType == 'setup') {
333 $theSetup = $templateService->setup;
334 } else {
335 $theSetup = $templateService->setup_constants;
336 }
337 // EDIT A VALUE:
338 if ($this->pObj->sObj) {
339 list($theSetup, $theSetupValue) = $templateService->ext_getSetup($theSetup, $this->pObj->sObj ? $this->pObj->sObj : '');
340 if ($existTemplate) {
341 // Inline Form Area Begin
342 $theOutput .= '<div class="form-inline form-inline-spaced">';
343 // Value
344 $out = '';
345 $out .= '<div class="form-group">';
346 $out .= ' <label>' . htmlspecialchars($this->pObj->sObj) . ' =' . '</label>';
347 $out .= ' <input class="form-control" type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][value]" value="' . htmlspecialchars($theSetupValue) . '"' . $documentTemplate->formWidth(40) . ' />';
348 $out .= ' <input class="btn btn-default" type="submit" name="update_value" value="' . $lang->getLL('updateButton') . '" />';
349 $out .= '</div>';
350 $theOutput .= '<h3>' . $lang->getLL('editProperty', true) . '</h3>';
351 $theOutput .= $out;
352 // Property
353 $out = '<div class="form-group">';
354 $out .= ' <label>' . htmlspecialchars($this->pObj->sObj) . '.';
355 $out .= ' <input class="form-control" type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][name]"' . $documentTemplate->formWidth(20) . ' /> = ';
356 $out .= ' </label>';
357 $out .= ' <input class="form-control" type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][propertyValue]"' . $documentTemplate->formWidth(40) . ' />';
358 $out .= ' <input class="btn btn-default" type="submit" name="add_property" value="' . $lang->getLL('addButton') . '" />';
359 $out .= '</div>';
360 $theOutput .= '<div style="padding-top: 20px;"></div>';
361 $theOutput .= '<h3>'. $lang->getLL('addProperty', true) . '</h3>';
362 $theOutput .= $out;
363 // clear
364 $out = '<div class="form-group">';
365 $out .= ' <div class="checkbox">';
366 $out .= ' <label>';
367 $out .= ' ' . htmlspecialchars($this->pObj->sObj) . ' ' . $lang->csConvObj->conv_case($lang->charSet, $lang->getLL('clear'), 'toUpper');
368 $out .= ' <input type="checkbox" name="data[' . htmlspecialchars($this->pObj->sObj) . '][clearValue]" value="1" />';
369 $out .= ' </label>';
370 $out .= ' <input class="btn btn-default" type="submit" name="clear_object" value="' . $lang->getLL('clearButton') . '" />';
371 $out .= ' </div>';
372 $out .= '</div>';
373 $theOutput .='<div style="padding-top: 20px;"></div>';
374 $theOutput .= '<h3>' . $lang->getLL('clearObject', true) . '</h3>';
375 $theOutput .= $out;
376 $theOutput .= '<div style="padding-top: 10px;"></div>';
377 // Inline Form Area End
378 $theOutput .= '</div>';
379 } else {
380 $noTemplateMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noCurrentTemplate'), $lang->getLL('edit'), FlashMessage::ERROR);
381 $this->addFlashMessage($noTemplateMessage);
382 $theOutput .= htmlspecialchars($this->pObj->sObj) . ' = <strong>' . htmlspecialchars($theSetupValue) . '</strong>';
383 $theOutput .= '<div style="padding-top: 10px;"></div>';
384 }
385 // Links:
386 $out = '';
387 $urlParameters = array(
388 'id' => $this->pObj->id
389 );
390 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
391 if (!$this->pObj->MOD_SETTINGS[('ts_browser_TLKeys_' . $bType)][$this->pObj->sObj]) {
392 if (!empty($theSetup)) {
393 $out = '<a href="' . htmlspecialchars(($aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=1&SET[ts_browser_toplevel_' . $bType . ']=' . rawurlencode($this->pObj->sObj))) . '">';
394 $out .= sprintf($lang->getLL('addKey'), htmlspecialchars($this->pObj->sObj));
395 }
396 } else {
397 $out = '<a href="' . htmlspecialchars(($aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0')) . '">';
398 $out .= sprintf($lang->getLL('removeKey'), htmlspecialchars($this->pObj->sObj));
399 }
400 if ($out) {
401 $theOutput .= '<div><hr style="margin-top: 5px; margin-bottom: 5px;" />' . $out . '</div>';
402 }
403 // back
404 $out = $lang->getLL('back');
405 $out = '<a href="' . htmlspecialchars($aHref) . '" class="btn btn-default"><strong><i class="fa fa-chevron-left"></i>&nbsp;' . $out . '</strong></a>';
406 $theOutput .= '<div><hr style="margin-top: 5px; margin-bottom: 5px;" />' . $out . '</div>';
407 } else {
408 $templateService->tsbrowser_depthKeys = $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType];
409 if (GeneralUtility::_POST('search') && GeneralUtility::_POST('search_field')) {
410 // If any POST-vars are send, update the condition array
411 $templateService->tsbrowser_depthKeys = $templateService->ext_getSearchKeys($theSetup, '', GeneralUtility::_POST('search_field'), array());
412 }
413 $theOutput .= '
414 <div class="tsob-menu">
415 <div class="form-inline">';
416 if (is_array($this->pObj->MOD_MENU['ts_browser_type']) && count($this->pObj->MOD_MENU['ts_browser_type']) > 1) {
417 $theOutput .= '
418 <div class="form-group">
419 <label class="control-label">' . $lang->getLL('browse') . '</label>'
420 . BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_type]', $bType, $this->pObj->MOD_MENU['ts_browser_type']) . '
421 </div>';
422 }
423 if (is_array($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) > 1) {
424 $theOutput .= '
425 <div class="form-group">
426 <label class="control-label" for="ts_browser_toplevel_' . $bType . '">' . $lang->getLL('objectList') . '</label> '
427 . 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]) . '
428 </div>';
429 }
430
431 $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Tstemplate/TypoScriptObjectBrowser');
432
433 $theOutput .= '
434 <div class="form-group">
435 <label class="control-label" for="search_field">' . $lang->getLL('search') . '</label>
436 <div class="form-group"><input class="form-control" type="search" name="search_field" id="search_field" value="' . htmlspecialchars($POST['search_field']) . '" /></div>
437 </div>
438 <input class="btn btn-default tsob-search-submit" type="submit" name="search" value="' . $lang->sL('LLL:EXT:lang/locallang_common.xlf:search') . '" />
439 </div>
440 <div class="checkbox">
441 <label for="checkTs_browser_regexsearch">
442 ' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_regexsearch]', $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'], '', '', 'id="checkTs_browser_regexsearch"') . $lang->getLL('regExp') . '
443 </label>
444 </div>
445 </div>';
446 $theKey = $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType];
447 if (!$theKey || !str_replace('-', '', $theKey)) {
448 $theKey = '';
449 }
450 list($theSetup, $theSetupValue) = $templateService->ext_getSetup($theSetup, $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] ? $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] : '');
451 $tree = $templateService->ext_getObjTree($theSetup, $theKey, '', '', $theSetupValue, $this->pObj->MOD_SETTINGS['ts_browser_alphaSort']);
452 $tree = $templateService->substituteCMarkers($tree);
453 $urlParameters = array(
454 'id' => $this->pObj->id
455 );
456 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
457 // Parser Errors:
458 $pEkey = $bType == 'setup' ? 'config' : 'constants';
459 if (!empty($templateService->parserErrors[$pEkey])) {
460 $errMsg = array();
461 foreach ($templateService->parserErrors[$pEkey] as $inf) {
462 $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>';
463 $errMsg[] = $lang->getLL('severity.' . $inf[1]) . ':&nbsp;' . $inf[0] . $errorLink;
464 }
465 $theOutput .= '<div style="padding-top: 10px;"></div>';
466
467 $title = $lang->getLL('errorsWarnings');
468 $message = '<p>' . implode($errMsg, '<br />') . '</p>';
469 $view = GeneralUtility::makeInstance(StandaloneView::class);
470 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/InfoBox.html'));
471 $view->assignMultiple(array(
472 'title' => $title,
473 'message' => $message,
474 'state' => InfoboxViewHelper::STATE_WARNING
475 ));
476 $theOutput .= $view->render();
477 }
478
479 if (isset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$theKey])) {
480 $remove = '<a href="' . htmlspecialchars(($aHref . '&addKey[' . $theKey . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0')) . '">' . $lang->getLL('removeKey') . '</a>';
481 } else {
482 $remove = '';
483 }
484
485 $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'));
486
487 $theOutput .= '<div class="panel panel-space panel-default">';
488 $theOutput .= '<div class="panel-heading">';
489 $theOutput .= '<strong>' . $label . ' ' . $remove . '</strong>';
490 $theOutput .= '</div>';
491 $theOutput .= '<div class="panel-body">' . $tree . '</div>';
492 $theOutput .= '</div>';
493
494 // second row options
495 $menu = '<div class="typo3-listOptions">';
496 $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"');
497 $menu .= $lang->getLL('displayComments') . '</label></div>';
498 $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"');
499 $menu .= $lang->getLL('sortAlphabetically') . '</label></div>';
500 $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"');
501 $menu .= $lang->getLL('cropLines') . '</label></div>';
502 if ($bType == 'setup' && !$this->pObj->MOD_SETTINGS['ts_browser_fixedLgd']) {
503 $menu .= '<div class="form"><label>' . $lang->getLL('displayConstants') . '</label>';
504 $menu .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS['ts_browser_const'], $this->pObj->MOD_MENU['ts_browser_const']);
505 $menu .= '</div>';
506 }
507 $menu .= '</div>';
508
509 //start section displayoptions
510 $theOutput .= '<div>';
511 $theOutput .= '<h2>' . $lang->getLL('displayOptions', true) . '</h2>';
512 $theOutput .= $menu;
513 // Conditions:
514 if (is_array($templateService->sections) && !empty($templateService->sections)) {
515 $theOutput .= '<h2>' . $lang->getLL('conditions', true) . '</h2>';
516 $out = '';
517 foreach ($templateService->sections as $key => $val) {
518 $out .= '<div class="checkbox"><label for="check' . $key . '">';
519 $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));
520 $out .= '</label></div>';
521 }
522 $theOutput .= '<div class="typo3-listOptions">' . $out . '</div><input class="btn btn-default" type="submit" name="Submit" value="' . $lang->getLL('setConditions') . '" />';
523 }
524 // Ending section displayoptions
525 $theOutput .= '</div>';
526 }
527 return $theOutput;
528 }
529
530 /**
531 * Add flash message to queue
532 *
533 * @param FlashMessage $flashMessage
534 * @return void
535 */
536 protected function addFlashMessage(FlashMessage $flashMessage)
537 {
538 /** @var $flashMessageService FlashMessageService */
539 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
540 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
541 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
542 $defaultFlashMessageQueue->enqueue($flashMessage);
543 }
544
545 /**
546 * @return ExtendedTemplateService
547 */
548 protected function getExtendedTemplateService()
549 {
550 return $GLOBALS['tmpl'];
551 }
552
553 /**
554 * @return array
555 */
556 protected function getTemplateRow()
557 {
558 return $GLOBALS['tplRow'];
559 }
560 }