[TASK] TS path next to error msg in obj-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\Utility\BackendUtility;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * This class displays the submodule "TypoScript Object Browser" inside the Web > Template module
22 *
23 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
24 */
25 class TypoScriptTemplateObjectBrowserModuleFunctionController extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
26
27 /**
28 * Init
29 *
30 * @param object $pObj
31 * @param array $conf
32 * @return void
33 * @todo Define visibility
34 */
35 public function init(&$pObj, $conf) {
36 parent::init($pObj, $conf);
37 $this->pObj->modMenu_dontValidateList .= ',ts_browser_toplevel_setup,ts_browser_toplevel_const,ts_browser_TLKeys_setup,ts_browser_TLKeys_const';
38 $this->pObj->modMenu_setDefaultList .= ',ts_browser_fixedLgd,ts_browser_showComments';
39 }
40
41 /**
42 * Mod menu
43 *
44 * @return array
45 * @todo Define visibility
46 */
47 public function modMenu() {
48 $GLOBALS['LANG']->includeLLFile('EXT:tstemplate/Resources/Private/Language/locallang_objbrowser.xlf');
49 $modMenu = array(
50 'ts_browser_type' => array(
51 'const' => $GLOBALS['LANG']->getLL('constants'),
52 'setup' => $GLOBALS['LANG']->getLL('setup')
53 ),
54 'ts_browser_toplevel_setup' => array(
55 '0' => $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('all'), 'toUpper')
56 ),
57 'ts_browser_toplevel_const' => array(
58 '0' => $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('all'), 'toUpper')
59 ),
60 'ts_browser_const' => array(
61 '0' => $GLOBALS['LANG']->getLL('plainSubstitution'),
62 'subst' => $GLOBALS['LANG']->getLL('substitutedGreen'),
63 'const' => $GLOBALS['LANG']->getLL('unsubstitutedGreen')
64 ),
65 'ts_browser_regexsearch' => '1',
66 'ts_browser_fixedLgd' => '1',
67 'ts_browser_showComments' => '1',
68 'ts_browser_alphaSort' => '1'
69 );
70 foreach (array('setup', 'const') as $bType) {
71 $addKey = GeneralUtility::_GET('addKey');
72 // If any plus-signs were clicked, it's registred.
73 if (is_array($addKey)) {
74 reset($addKey);
75 if (current($addKey)) {
76 $this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][key($addKey)] = key($addKey);
77 } else {
78 unset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][key($addKey)]);
79 }
80 $GLOBALS['BE_USER']->pushModuleData($this->pObj->MCONF['name'], $this->pObj->MOD_SETTINGS);
81 }
82 if (count($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType])) {
83 $modMenu['ts_browser_toplevel_' . $bType]['-'] = '---';
84 $modMenu['ts_browser_toplevel_' . $bType] = $modMenu[('ts_browser_toplevel_' . $bType)] + $this->pObj->MOD_SETTINGS[('ts_browser_TLKeys_' . $bType)];
85 }
86 }
87 return $modMenu;
88 }
89
90 /**
91 * Verify TS objects
92 *
93 * @param array $propertyArray
94 * @param string $parentType
95 * @param string $parentValue
96 * @return array
97 * @todo Define visibility
98 */
99 public function verify_TSobjects($propertyArray, $parentType, $parentValue) {
100 $TSobjTable = array(
101 'PAGE' => array(
102 'prop' => array(
103 'typeNum' => 'int',
104 '1,2,3' => 'COBJ',
105 'bodyTag' => 'string'
106 )
107 ),
108 'TEXT' => array(
109 'prop' => array(
110 'value' => 'string'
111 )
112 ),
113 'HTML' => array(
114 'prop' => array(
115 'value' => 'stdWrap'
116 )
117 ),
118 'stdWrap' => array(
119 'prop' => array(
120 'field' => 'string',
121 'current' => 'boolean'
122 )
123 )
124 );
125 $TSobjDataTypes = array(
126 'COBJ' => 'TEXT,CONTENT',
127 'PAGE' => 'PAGE',
128 'stdWrap' => ''
129 );
130 if ($parentType) {
131 if (isset($TSobjDataTypes[$parentType]) && (!$TSobjDataTypes[$parentType] || GeneralUtility::inlist($TSobjDataTypes[$parentType], $parentValue))) {
132 $ObjectKind = $parentValue;
133 } else {
134 // Object kind is "" if it should be known.
135 $ObjectKind = '';
136 }
137 } else {
138 // If parentType is not given, then it can be anything. Free.
139 $ObjectKind = $parentValue;
140 }
141 if ($ObjectKind && is_array($TSobjTable[$ObjectKind])) {
142 $result = array();
143 if (is_array($propertyArray)) {
144 foreach ($propertyArray as $key => $val) {
145 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($key)) {
146 // If num-arrays
147 $result[$key] = $TSobjTable[$ObjectKind]['prop']['1,2,3'];
148 } else {
149 // standard
150 $result[$key] = $TSobjTable[$ObjectKind]['prop'][$key];
151 }
152 }
153 }
154 return $result;
155 }
156 }
157
158 /**
159 * Initialize editor
160 *
161 * @param integer $pageId
162 * @param integer $template_uid
163 * @return integer
164 * @todo Define visibility
165 */
166 public function initialize_editor($pageId, $template_uid = 0) {
167 // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
168 global $tmpl, $tplRow, $theConstants;
169 // Defined global here!
170 $tmpl = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
171 // Do not log time-performance information
172 $tmpl->tt_track = 0;
173 $tmpl->init();
174 // Gets the rootLine
175 $sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
176 $rootLine = $sys_page->getRootLine($pageId);
177 // This generates the constants/config + hierarchy info for the template.
178 $tmpl->runThroughTemplates($rootLine, $template_uid);
179 // Get the row of the first VISIBLE template of the page. whereclause like the frontend.
180 $tplRow = $tmpl->ext_getFirstTemplate($pageId, $template_uid);
181 // IF there was a template...
182 if (is_array($tplRow)) {
183 return 1;
184 }
185 }
186
187 /**
188 * Main
189 *
190 * @return string
191 * @todo Define visibility
192 */
193 public function main() {
194 global $BACK_PATH;
195 global $tmpl, $tplRow, $theConstants;
196 $POST = GeneralUtility::_POST();
197 // Checking for more than one template an if, set a menu...
198 $manyTemplatesMenu = $this->pObj->templateMenu();
199 $template_uid = 0;
200 if ($manyTemplatesMenu) {
201 $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
202 }
203 // BUGBUG: Should we check if the user may at all read and write template-records???
204 $bType = $this->pObj->MOD_SETTINGS['ts_browser_type'];
205 $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
206 // initialize
207 if ($existTemplate) {
208 $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('currentTemplate'), ' <img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], \TYPO3\CMS\Backend\Utility\IconUtility::getIcon('sys_template', $tplRow)) . ' align="top" /> <strong>' . $this->pObj->linkWrapTemplateTitle($tplRow['title'], ($bType == 'setup' ? 'config' : 'constants')) . '</strong>' . htmlspecialchars((trim($tplRow['sitetitle']) ? ' (' . $tplRow['sitetitle'] . ')' : '')));
209 if ($manyTemplatesMenu) {
210 $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
211 }
212 $theOutput .= $this->pObj->doc->spacer(10);
213 if ($POST['add_property'] || $POST['update_value'] || $POST['clear_object']) {
214 // add property
215 $line = '';
216 if (is_array($POST['data'])) {
217 $name = key($POST['data']);
218 if ($POST['data'][$name]['name'] !== '') {
219 // 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.
220 unset($POST['update_value']);
221 $POST['add_property'] = 'Add';
222 }
223 if ($POST['add_property']) {
224 $property = trim($POST['data'][$name]['name']);
225 if (preg_replace('/[^a-zA-Z0-9_\\.]*/', '', $property) != $property) {
226 $badPropertyMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('noSpaces') . '<br />' . $GLOBALS['LANG']->getLL('nothingUpdated'), $GLOBALS['LANG']->getLL('badProperty'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
227 $this->addFlashMessage($badPropertyMessage);
228 } else {
229 $pline = $name . '.' . $property . ' = ' . trim($POST['data'][$name]['propertyValue']);
230 $propertyAddedMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($pline), $GLOBALS['LANG']->getLL('propertyAdded'));
231 $this->addFlashMessage($propertyAddedMessage);
232 $line .= LF . $pline;
233 }
234 } elseif ($POST['update_value']) {
235 $pline = $name . ' = ' . trim($POST['data'][$name]['value']);
236 $updatedMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($pline), $GLOBALS['LANG']->getLL('valueUpdated'));
237 $this->addFlashMessage($updatedMessage);
238 $line .= LF . $pline;
239 } elseif ($POST['clear_object']) {
240 if ($POST['data'][$name]['clearValue']) {
241 $pline = $name . ' >';
242 $objectClearedMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($pline), $GLOBALS['LANG']->getLL('objectCleared'));
243 $this->addFlashMessage($objectClearedMessage);
244 $line .= LF . $pline;
245 }
246 }
247 }
248 if ($line) {
249 $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
250 // Set the data to be saved
251 $recData = array();
252 $field = $bType == 'setup' ? 'config' : 'constants';
253 $recData['sys_template'][$saveId][$field] = $tplRow[$field] . $line;
254 // Create new tce-object
255 $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
256 $tce->stripslashes_values = 0;
257 // Initialize
258 $tce->start($recData, array());
259 // Saved the stuff
260 $tce->process_datamap();
261 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
262 $tce->clear_cacheCmd('all');
263 // re-read the template ...
264 $this->initialize_editor($this->pObj->id, $template_uid);
265 }
266 }
267 }
268 $tsbr = GeneralUtility::_GET('tsbr');
269 $update = 0;
270 if (is_array($tsbr)) {
271 // If any plus-signs were clicked, it's registred.
272 $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType] = $tmpl->ext_depthKeys($tsbr, $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType]);
273 $update = 1;
274 }
275 if ($POST['Submit']) {
276 // If any POST-vars are send, update the condition array
277 $this->pObj->MOD_SETTINGS['tsbrowser_conditions'] = $POST['conditions'];
278 $update = 1;
279 }
280 if ($update) {
281 $GLOBALS['BE_USER']->pushModuleData($this->pObj->MCONF['name'], $this->pObj->MOD_SETTINGS);
282 }
283 $tmpl->matchAlternative = $this->pObj->MOD_SETTINGS['tsbrowser_conditions'];
284 $tmpl->matchAlternative[] = 'dummydummydummydummydummydummydummydummydummydummydummy';
285 // 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.
286 $tmpl->constantMode = $this->pObj->MOD_SETTINGS['ts_browser_const'];
287 if ($this->pObj->sObj && $tmpl->constantMode) {
288 $tmpl->constantMode = 'untouched';
289 }
290 $tmpl->regexMode = $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'];
291 $tmpl->fixedLgd = $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'];
292 $tmpl->linkObjects = TRUE;
293 $tmpl->ext_regLinenumbers = TRUE;
294 $tmpl->ext_regComments = $this->pObj->MOD_SETTINGS['ts_browser_showComments'];
295 $tmpl->bType = $bType;
296 $tmpl->resourceCheck = 1;
297 $tmpl->removeFromGetFilePath = PATH_site;
298 if ($this->pObj->MOD_SETTINGS['ts_browser_type'] == 'const') {
299 $tmpl->ext_constants_BRP = (int)GeneralUtility::_GP('breakPointLN');
300 } else {
301 $tmpl->ext_config_BRP = (int)GeneralUtility::_GP('breakPointLN');
302 }
303 $tmpl->generateConfig();
304 if ($bType == 'setup') {
305 $theSetup = $tmpl->setup;
306 } else {
307 $theSetup = $tmpl->setup_constants;
308 }
309 // EDIT A VALUE:
310 if ($this->pObj->sObj) {
311 list($theSetup, $theSetupValue) = $tmpl->ext_getSetup($theSetup, $this->pObj->sObj ? $this->pObj->sObj : '');
312 if ($existTemplate) {
313 // Value
314 $out = '';
315 $out .= htmlspecialchars($this->pObj->sObj) . ' =<br />';
316 $out .= '<input type="Text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][value]" value="' . htmlspecialchars($theSetupValue) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(40) . ' />';
317 $out .= '<input type="Submit" name="update_value" value="' . $GLOBALS['LANG']->getLL('updateButton') . '" />';
318 $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editProperty'), $out, 0, 0);
319 // Property
320 $out = '';
321 $out = '<nobr>' . htmlspecialchars($this->pObj->sObj) . '.';
322 $out .= '<input type="Text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][name]"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' /> = </nobr><br />';
323 $out .= '<input type="Text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][propertyValue]"' . $GLOBALS['TBE_TEMPLATE']->formWidth(40) . ' />';
324 $out .= '<input type="Submit" name="add_property" value="' . $GLOBALS['LANG']->getLL('addButton') . '" />';
325 $theOutput .= $this->pObj->doc->spacer(20);
326 $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('addProperty'), $out, 0, 0);
327 // clear
328 $out = '';
329 $out = htmlspecialchars($this->pObj->sObj) . ' <strong>' . $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('clear'), 'toUpper') . '</strong> &nbsp;&nbsp;';
330 $out .= '<input type="Checkbox" name="data[' . htmlspecialchars($this->pObj->sObj) . '][clearValue]" value="1" />';
331 $out .= '<input type="Submit" name="clear_object" value="' . $GLOBALS['LANG']->getLL('clearButton') . '" />';
332 $theOutput .= $this->pObj->doc->spacer(20);
333 $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('clearObject'), $out, 0, 0);
334 $theOutput .= $this->pObj->doc->spacer(10);
335 } else {
336 $noTemplateMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('noCurrentTemplate'), $GLOBALS['LANG']->getLL('edit'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
337 $this->addFlashMessage($noTemplateMessage);
338 $theOutput .= htmlspecialchars($this->pObj->sObj) . ' = <strong>' . htmlspecialchars($theSetupValue) . '</strong>';
339 $theOutput .= $this->pObj->doc->spacer(10);
340 }
341 // Links:
342 $out = '';
343 $urlParameters = array(
344 'id' => $this->pObj->id
345 );
346 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
347 if (!$this->pObj->MOD_SETTINGS[('ts_browser_TLKeys_' . $bType)][$this->pObj->sObj]) {
348 if (count($theSetup)) {
349 $out = '<a href="' . htmlspecialchars(($aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=1&SET[ts_browser_toplevel_' . $bType . ']=' . rawurlencode($this->pObj->sObj))) . '">';
350 $out .= sprintf($GLOBALS['LANG']->getLL('addKey'), htmlspecialchars($this->pObj->sObj));
351 }
352 } else {
353 $out = '<a href="' . htmlspecialchars(($aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0')) . '">';
354 $out .= sprintf($GLOBALS['LANG']->getLL('removeKey'), htmlspecialchars($this->pObj->sObj));
355 }
356 if ($out) {
357 $theOutput .= $this->pObj->doc->divider(5);
358 $theOutput .= $this->pObj->doc->section('', $out);
359 }
360 // back
361 $out = $GLOBALS['LANG']->getLL('back');
362 $out = '<a href="' . htmlspecialchars($aHref) . '"><strong>' . $out . '</strong></a>';
363 $theOutput .= $this->pObj->doc->divider(5);
364 $theOutput .= $this->pObj->doc->section('', $out);
365 } else {
366 $tmpl->tsbrowser_depthKeys = $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType];
367 if (GeneralUtility::_POST('search') && GeneralUtility::_POST('search_field')) {
368 // If any POST-vars are send, update the condition array
369 $tmpl->tsbrowser_depthKeys = $tmpl->ext_getSearchKeys($theSetup, '', GeneralUtility::_POST('search_field'), array());
370 }
371 $menu = '<div class="tsob-menu"><label>' . $GLOBALS['LANG']->getLL('browse') . '</label>';
372 $menu .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_type]', $bType, $this->pObj->MOD_MENU['ts_browser_type']);
373 $menu .= '<label for="ts_browser_toplevel_' . $bType . '">' . $GLOBALS['LANG']->getLL('objectList') . '</label>';
374 $menu .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_toplevel_' . $bType . ']', $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType], $this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]);
375 //search
376 $menu .= '<label for="search_field">' . $GLOBALS['LANG']->getLL('search') . '</label>';
377 $menu .= '<input type="Text" name="search_field" id="search_field" value="' . htmlspecialchars($POST['search_field']) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . '/>';
378 $menu .= '<input type="Submit" name="search" class="tsob-search-submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:search') . '" />';
379 $menu .= BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_regexsearch]', $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'], '', '', 'id="checkTs_browser_regexsearch"');
380 $menu .= '<label for="checkTs_browser_regexsearch">' . $GLOBALS['LANG']->getLL('regExp') . '</label>';
381 $menu .= '</div>';
382 $theOutput .= $this->pObj->doc->section('', '<nobr>' . $menu . '</nobr>');
383 $theKey = $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType];
384 if (!$theKey || !str_replace('-', '', $theKey)) {
385 $theKey = '';
386 }
387 list($theSetup, $theSetupValue) = $tmpl->ext_getSetup($theSetup, $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] ? $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] : '');
388 $tree = $tmpl->ext_getObjTree($theSetup, $theKey, '', '', $theSetupValue, $this->pObj->MOD_SETTINGS['ts_browser_alphaSort']);
389 $tree = $tmpl->substituteCMarkers($tree);
390 $urlParameters = array(
391 'id' => $this->pObj->id
392 );
393 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
394 // Parser Errors:
395 $pEkey = $bType == 'setup' ? 'config' : 'constants';
396 if (count($tmpl->parserErrors[$pEkey])) {
397 $errMsg = array();
398 $templateAnalyzerInstalled = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('tstemplate');
399 foreach ($tmpl->parserErrors[$pEkey] as $inf) {
400 $errorLink = '';
401 if ($templateAnalyzerInstalled) {
402 $errorLink = ' <a href="' . htmlspecialchars(($aHref . '&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TemplateAnalyzerModuleFunctionController&template=all&SET[ts_analyzer_checkLinenum]=1#line-' . $inf[2])) . '">' . $GLOBALS['LANG']->getLL('errorShowDetails') . '</a>';
403 }
404 $errMsg[] = $inf[1] . ': &nbsp; &nbsp;' . $inf[0] . $errorLink;
405 }
406 $theOutput .= $this->pObj->doc->spacer(10);
407 $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', implode($errMsg, '<br />'), $GLOBALS['LANG']->getLL('errorsWarnings'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
408 $theOutput .= $flashMessage->render();
409 }
410 if (isset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$theKey])) {
411 $remove = '<th><a href="' . htmlspecialchars(($aHref . '&addKey[' . $theKey . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0')) . '">' . $GLOBALS['LANG']->getLL('removeKey') . '</a></th>';
412 } else {
413 $remove = '';
414 }
415 $label = $theKey ? $theKey : ($bType == 'setup' ? $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('setupRoot'), 'toUpper') : $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('constantRoot'), 'toUpper'));
416 $theOutput .= $this->pObj->doc->spacer(15);
417 $theOutput .= $this->pObj->doc->sectionEnd();
418 $theOutput .= '<table class="t3-table" id="typo3-objectBrowser">
419 <thead>
420 <tr>
421 <th>' . $label . '</th>' .
422 $remove .
423 '</tr>
424 </thead>
425 <tbody>
426 <tr>
427 <td>' . $tree . '</td>' .
428 ($remove ? '<td></td>' : '') . '
429 </tr>
430 </tbody>
431 </table>';
432 // second row options
433 $menu = '<div class="tsob-menu-row2">';
434 $menu .= BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_showComments]', $this->pObj->MOD_SETTINGS['ts_browser_showComments'], '', '', 'id="checkTs_browser_showComments"');
435 $menu .= '<label for="checkTs_browser_showComments">' . $GLOBALS['LANG']->getLL('displayComments') . '</label>';
436 $menu .= BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_alphaSort]', $this->pObj->MOD_SETTINGS['ts_browser_alphaSort'], '', '', 'id="checkTs_browser_alphaSort"');
437 $menu .= '<label for="checkTs_browser_alphaSort">' . $GLOBALS['LANG']->getLL('sortAlphabetically') . '</label>';
438 $menu .= BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_fixedLgd]', $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'], '', '', 'id="checkTs_browser_fixedLgd"');
439 $menu .= '<label for="checkTs_browser_fixedLgd">' . $GLOBALS['LANG']->getLL('cropLines') . '</label>';
440 if ($bType == 'setup' && !$this->pObj->MOD_SETTINGS['ts_browser_fixedLgd']) {
441 $menu .= '<br /><br /><label>' . $GLOBALS['LANG']->getLL('displayConstants') . '</label>';
442 $menu .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS['ts_browser_const'], $this->pObj->MOD_MENU['ts_browser_const']);
443 }
444 $menu .= '</div>';
445 $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('displayOptions'), '<nobr>' . $menu . '</nobr>', 0, 1);
446 // Conditions:
447 if (is_array($tmpl->sections)) {
448 $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('conditions'), '', 0, 1);
449 $out = '';
450 foreach ($tmpl->sections as $key => $val) {
451 $out .= '<div class="tsob-conditions"><input class="checkbox" type="checkbox" name="conditions[' . $key . ']" id="check' . $key . '" value="' . htmlspecialchars($val) . '"' . ($this->pObj->MOD_SETTINGS['tsbrowser_conditions'][$key] ? ' checked' : '') . ' />';
452 $out .= '<label for="check' . $key . '">' . $tmpl->substituteCMarkers(htmlspecialchars($val)) . '</label></div>';
453 }
454 $theOutput .= '<div class="tsob-menu-row2">' . $out . '</div><input type="Submit" name="Submit" value="' . $GLOBALS['LANG']->getLL('setConditions') . '" />';
455 }
456 // Ending section:
457 $theOutput .= $this->pObj->doc->sectionEnd();
458 }
459 return $theOutput;
460 }
461
462 /**
463 * Add flash message to queue
464 *
465 * @param \TYPO3\CMS\Core\Messaging\FlashMessage $flasgMessage
466 * @return void
467 */
468 protected function addFlashMessage(\TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage) {
469 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
470 $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
471 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
472 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
473 $defaultFlashMessageQueue->enqueue($flashMessage);
474 }
475
476 }