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