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