Passed
Branch master (6c65a4)
by Christian
16:31
created

main()   F

Complexity

Conditions 54
Paths > 20000

Size

Total Lines 240
Code Lines 170

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 54
eloc 170
nc 193493760
nop 0
dl 0
loc 240
rs 2
c 1
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\Exception;
21
use TYPO3\CMS\Core\Messaging\FlashMessage;
22
use TYPO3\CMS\Core\Messaging\FlashMessageService;
23
use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
24
use TYPO3\CMS\Core\Utility\GeneralUtility;
25
use TYPO3\CMS\Core\Utility\RootlineUtility;
26
use TYPO3\CMS\Fluid\View\StandaloneView;
27
28
/**
29
 * This class displays the submodule "TypoScript Object Browser" inside the Web > Template module
30
 */
31
class TypoScriptTemplateObjectBrowserModuleFunctionController extends AbstractFunctionModule
32
{
33
    /**
34
     * @var string
35
     */
36
    protected $localLanguageFilePath;
37
38
    /**
39
     * @var TypoScriptTemplateModuleController
40
     */
41
    public $pObj;
42
43
    /**
44
     * The currently selected sys_template record
45
     * @var array
46
     */
47
    protected $templateRow;
48
49
    /**
50
     * @var ExtendedTemplateService
51
     */
52
    protected $templateService;
53
54
    /**
55
     * Init
56
     *
57
     * @param TypoScriptTemplateModuleController $pObj
58
     * @param array $conf
59
     */
60
    public function init(&$pObj, $conf)
61
    {
62
        parent::init($pObj, $conf);
63
        $this->pObj->modMenu_dontValidateList .= ',ts_browser_toplevel_setup,ts_browser_toplevel_const,ts_browser_TLKeys_setup,ts_browser_TLKeys_const';
64
        $this->pObj->modMenu_setDefaultList .= ',ts_browser_fixedLgd,ts_browser_showComments';
65
        $this->localLanguageFilePath = 'EXT:tstemplate/Resources/Private/Language/locallang_objbrowser.xlf';
66
    }
67
68
    /**
69
     * Mod menu
70
     *
71
     * @return array
72
     */
73
    public function modMenu()
74
    {
75
        $lang = $this->getLanguageService();
76
        $lang->includeLLFile('EXT:tstemplate/Resources/Private/Language/locallang_objbrowser.xlf');
77
        $modMenu = [
78
            'ts_browser_type' => [
79
                'const' => $lang->getLL('constants'),
80
                'setup' => $lang->getLL('setup')
81
            ],
82
            'ts_browser_toplevel_setup' => [
83
                '0' => mb_strtolower($lang->getLL('all'), 'utf-8')
84
            ],
85
            'ts_browser_toplevel_const' => [
86
                '0' => mb_strtolower($lang->getLL('all'), 'utf-8')
87
            ],
88
            'ts_browser_const' => [
89
                '0' => $lang->getLL('plainSubstitution'),
90
                'subst' => $lang->getLL('substitutedGreen'),
91
                'const' => $lang->getLL('unsubstitutedGreen')
92
            ],
93
            'ts_browser_regexsearch' => '1',
94
            'ts_browser_fixedLgd' => '1',
95
            'ts_browser_showComments' => '1',
96
            'ts_browser_alphaSort' => '1'
97
        ];
98
        foreach (['setup', 'const'] as $bType) {
99
            $addKey = GeneralUtility::_GET('addKey');
100
            // If any plus-signs were clicked, it's registered.
101
            if (is_array($addKey)) {
102
                reset($addKey);
103
                if (current($addKey)) {
104
                    $this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][key($addKey)] = key($addKey);
105
                } else {
106
                    unset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][key($addKey)]);
107
                }
108
                $this->getBackendUserAuthentication()->pushModuleData($this->pObj->MCONF['name'], $this->pObj->MOD_SETTINGS);
109
            }
110
            if (!empty($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType])) {
111
                $modMenu['ts_browser_toplevel_' . $bType]['-'] = '---';
112
                $modMenu['ts_browser_toplevel_' . $bType] = $modMenu['ts_browser_toplevel_' . $bType] + $this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType];
113
            }
114
        }
115
        return $modMenu;
116
    }
117
118
    /**
119
     * Initialize editor
120
     *
121
     * Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
122
     *
123
     * @param int $pageId
124
     * @param int $template_uid
125
     * @return bool
126
     */
127
    public function initialize_editor($pageId, $template_uid = 0)
128
    {
129
        // Defined global here!
130
        $this->templateService = GeneralUtility::makeInstance(ExtendedTemplateService::class);
131
        $this->templateService->init();
132
133
        // Gets the rootLine
134
        $rootlineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $pageId);
0 ignored issues
show
Bug introduced by
$pageId of type integer is incompatible with the type array<integer,mixed> expected by parameter $constructorArguments of TYPO3\CMS\Core\Utility\G...Utility::makeInstance(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

134
        $rootlineUtility = GeneralUtility::makeInstance(RootlineUtility::class, /** @scrutinizer ignore-type */ $pageId);
Loading history...
135
        $rootLine = $rootlineUtility->get();
136
        // This generates the constants/config + hierarchy info for the template.
137
        $this->templateService->runThroughTemplates($rootLine, $template_uid);
138
139
        // Get the row of the first VISIBLE template of the page. whereclause like the frontend.
140
        $this->templateRow = $this->templateService->ext_getFirstTemplate($pageId, $template_uid);
141
        return is_array($this->templateRow);
142
    }
143
144
    /**
145
     * Main
146
     *
147
     * @return string
148
     */
149
    public function main()
150
    {
151
        $lang = $this->getLanguageService();
152
        $POST = GeneralUtility::_POST();
153
154
        // Checking for more than one template an if, set a menu...
155
        $manyTemplatesMenu = $this->pObj->templateMenu();
156
        $template_uid = 0;
157
        if ($manyTemplatesMenu) {
158
            $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
159
        }
160
        $bType = $this->pObj->MOD_SETTINGS['ts_browser_type'];
161
        $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
162
        // initialize
163
        $assigns = [];
164
        $assigns['LLPrefix'] = 'LLL:' . $this->localLanguageFilePath . ':';
165
        $assigns['existTemplate'] = $existTemplate;
166
        $assigns['tsBrowserType'] = $this->pObj->MOD_SETTINGS['ts_browser_type'];
167
        if ($existTemplate) {
168
            $assigns['templateRecord'] = $this->templateRow;
169
            $assigns['linkWrapTemplateTitle'] = $this->pObj->linkWrapTemplateTitle($this->templateRow['title'], ($bType === 'setup' ? 'config' : 'constants'));
170
            $assigns['manyTemplatesMenu'] = $manyTemplatesMenu;
171
172
            if ($POST['add_property'] || $POST['update_value'] || $POST['clear_object']) {
173
                // add property
174
                $line = '';
175
                if (is_array($POST['data'])) {
176
                    $name = key($POST['data']);
177
                    if ($POST['data'][$name]['name'] !== '') {
178
                        // 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.
179
                        unset($POST['update_value']);
180
                        $POST['add_property'] = 'Add';
181
                    }
182
                    if ($POST['add_property']) {
183
                        $property = trim($POST['data'][$name]['name']);
184
                        if (preg_replace('/[^a-zA-Z0-9_\\.]*/', '', $property) != $property) {
185
                            $badPropertyMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noSpaces') . $lang->getLL('nothingUpdated'), $lang->getLL('badProperty'), FlashMessage::ERROR);
0 ignored issues
show
Bug introduced by
$lang->getLL('noSpaces')...getLL('nothingUpdated') of type string is incompatible with the type array<integer,mixed> expected by parameter $constructorArguments of TYPO3\CMS\Core\Utility\G...Utility::makeInstance(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

185
                            $badPropertyMessage = GeneralUtility::makeInstance(FlashMessage::class, /** @scrutinizer ignore-type */ $lang->getLL('noSpaces') . $lang->getLL('nothingUpdated'), $lang->getLL('badProperty'), FlashMessage::ERROR);
Loading history...
Bug introduced by
TYPO3\CMS\Core\Messaging\FlashMessage::ERROR of type integer is incompatible with the type array<integer,mixed> expected by parameter $constructorArguments of TYPO3\CMS\Core\Utility\G...Utility::makeInstance(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

185
                            $badPropertyMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noSpaces') . $lang->getLL('nothingUpdated'), $lang->getLL('badProperty'), /** @scrutinizer ignore-type */ FlashMessage::ERROR);
Loading history...
186
                            $this->addFlashMessage($badPropertyMessage);
187
                        } else {
188
                            $pline = $name . '.' . $property . ' = ' . trim($POST['data'][$name]['propertyValue']);
189
                            $propertyAddedMessage = GeneralUtility::makeInstance(FlashMessage::class, $pline, $lang->getLL('propertyAdded'));
190
                            $this->addFlashMessage($propertyAddedMessage);
191
                            $line .= LF . $pline;
0 ignored issues
show
Bug introduced by
Are you sure $pline of type array can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

191
                            $line .= LF . /** @scrutinizer ignore-type */ $pline;
Loading history...
192
                        }
193
                    } elseif ($POST['update_value']) {
194
                        $pline = $name . ' = ' . trim($POST['data'][$name]['value']);
195
                        $updatedMessage = GeneralUtility::makeInstance(FlashMessage::class, $pline, $lang->getLL('valueUpdated'));
196
                        $this->addFlashMessage($updatedMessage);
197
                        $line .= LF . $pline;
198
                    } elseif ($POST['clear_object']) {
199
                        if ($POST['data'][$name]['clearValue']) {
200
                            $pline = $name . ' >';
201
                            $objectClearedMessage = GeneralUtility::makeInstance(FlashMessage::class, $pline, $lang->getLL('objectCleared'));
202
                            $this->addFlashMessage($objectClearedMessage);
203
                            $line .= LF . $pline;
204
                        }
205
                    }
206
                }
207
                if ($line) {
208
                    $saveId = $this->templateRow['_ORIG_uid'] ?: $this->templateRow['uid'];
209
                    // Set the data to be saved
210
                    $recData = [];
211
                    $field = $bType === 'setup' ? 'config' : 'constants';
212
                    $recData['sys_template'][$saveId][$field] = $this->templateRow[$field] . $line;
213
                    // Create new  tce-object
214
                    $tce = GeneralUtility::makeInstance(DataHandler::class);
215
                    // Initialize
216
                    $tce->start($recData, []);
217
                    // Saved the stuff
218
                    $tce->process_datamap();
219
                    // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
220
                    $tce->clear_cacheCmd('all');
221
                    // re-read the template ...
222
                    $this->initialize_editor($this->pObj->id, $template_uid);
223
                }
224
            }
225
        }
226
        $tsbr = GeneralUtility::_GET('tsbr');
227
        $update = 0;
228
        if (is_array($tsbr)) {
229
            // If any plus-signs were clicked, it's registred.
230
            $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType] = $this->templateService->ext_depthKeys($tsbr, $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType]);
231
            $update = 1;
232
        }
233
        if ($POST['Submit']) {
234
            // If any POST-vars are send, update the condition array
235
            $this->pObj->MOD_SETTINGS['tsbrowser_conditions'] = $POST['conditions'];
236
            $update = 1;
237
        }
238
        if ($update) {
239
            $this->getBackendUserAuthentication()->pushModuleData($this->pObj->MCONF['name'], $this->pObj->MOD_SETTINGS);
240
        }
241
        $this->templateService->matchAlternative = $this->pObj->MOD_SETTINGS['tsbrowser_conditions'];
242
        $this->templateService->matchAlternative[] = 'dummydummydummydummydummydummydummydummydummydummydummy';
243
        // 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.
244
        $this->templateService->constantMode = $this->pObj->MOD_SETTINGS['ts_browser_const'];
245
        if ($this->pObj->sObj && $this->templateService->constantMode) {
246
            $this->templateService->constantMode = 'untouched';
247
        }
248
        $this->templateService->regexMode = $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'];
249
        $this->templateService->fixedLgd = $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'];
250
        $this->templateService->linkObjects = true;
251
        $this->templateService->ext_regLinenumbers = true;
252
        $this->templateService->ext_regComments = $this->pObj->MOD_SETTINGS['ts_browser_showComments'];
253
        $this->templateService->bType = $bType;
254
        if ($this->pObj->MOD_SETTINGS['ts_browser_type'] === 'const') {
255
            $this->templateService->ext_constants_BRP = (int)GeneralUtility::_GP('breakPointLN');
256
        } else {
257
            $this->templateService->ext_config_BRP = (int)GeneralUtility::_GP('breakPointLN');
258
        }
259
        $this->templateService->generateConfig();
260
        if ($bType === 'setup') {
261
            $theSetup = $this->templateService->setup;
262
        } else {
263
            $theSetup = $this->templateService->setup_constants;
264
        }
265
        // EDIT A VALUE:
266
        $assigns['typoScriptPath'] = $this->pObj->sObj;
267
        if ($this->pObj->sObj) {
268
            list($theSetup, $theSetupValue) = $this->templateService->ext_getSetup($theSetup, $this->pObj->sObj ? $this->pObj->sObj : '');
269
            $assigns['theSetupValue'] = $theSetupValue;
270
            if ($existTemplate === false) {
271
                $noTemplateMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noCurrentTemplate'), $lang->getLL('edit'), FlashMessage::ERROR);
272
                $this->addFlashMessage($noTemplateMessage);
273
            }
274
            // Links:
275
            $urlParameters = [
276
                'id' => $this->pObj->id
277
            ];
278
            /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
279
            $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
280
            $aHref = (string)$uriBuilder->buildUriFromRoute('web_ts', $urlParameters);
281
            $assigns['moduleUrl'] = (string)$uriBuilder->buildUriFromRoute('web_ts', $urlParameters);
282
            $assigns['isNotInTopLevelKeyList'] = !isset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$this->pObj->sObj]);
283
            $assigns['hasProperties'] = !empty($theSetup);
284
            if (!$this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$this->pObj->sObj]) {
285
                if (!empty($theSetup)) {
286
                    $assigns['moduleUrlObjectListAction'] = $aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=1&SET[ts_browser_toplevel_' . $bType . ']=' . rawurlencode($this->pObj->sObj);
287
                }
288
            } else {
289
                $assigns['moduleUrlObjectListAction'] = $aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0';
290
            }
291
        } else {
292
            $this->templateService->tsbrowser_depthKeys = $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType];
293
            if (GeneralUtility::_POST('search') && GeneralUtility::_POST('search_field')) {
0 ignored issues
show
Bug Best Practice introduced by
The expression TYPO3\CMS\Core\Utility\G...::_POST('search_field') of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
Bug Best Practice introduced by
The expression TYPO3\CMS\Core\Utility\G...tility::_POST('search') of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
294
                // If any POST-vars are send, update the condition array
295
                $searchString = GeneralUtility::_POST('search_field');
296
                try {
297
                    $this->templateService->tsbrowser_depthKeys =
298
                        $this->templateService->ext_getSearchKeys(
299
                            $theSetup,
300
                            '',
301
                            $searchString,
302
                            []
303
                        );
304
                } catch (Exception $e) {
305
                    $this->addFlashMessage(
306
                        GeneralUtility::makeInstance(FlashMessage::class, sprintf($lang->getLL('error.' . $e->getCode()), $searchString), '', FlashMessage::ERROR)
307
                    );
308
                }
309
            }
310
            $assigns['hasTsBrowserTypes'] = is_array($this->pObj->MOD_MENU['ts_browser_type']) && count($this->pObj->MOD_MENU['ts_browser_type']) > 1;
311
            if (is_array($this->pObj->MOD_MENU['ts_browser_type']) && count($this->pObj->MOD_MENU['ts_browser_type']) > 1) {
312
                $assigns['browserTypeDropdownMenu'] = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_type]', $bType, $this->pObj->MOD_MENU['ts_browser_type']);
313
            }
314
            $assigns['hasTopLevelInObjectList'] = is_array($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) > 1;
315
            if (is_array($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) > 1) {
316
                $assigns['objectListDropdownMenu'] = 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]);
317
            }
318
319
            $assigns['regexSearchCheckbox'] = BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_regexsearch]', $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'], '', '', 'id="checkTs_browser_regexsearch"');
320
            $assigns['postSearchField'] = $POST['search_field'];
321
            $theKey = $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType];
322
            if (!$theKey || !str_replace('-', '', $theKey)) {
323
                $theKey = '';
324
            }
325
            list($theSetup, $theSetupValue) = $this->templateService->ext_getSetup($theSetup, $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] ? $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] : '');
326
            $tree = $this->templateService->ext_getObjTree($theSetup, $theKey, '', '', $theSetupValue, $this->pObj->MOD_SETTINGS['ts_browser_alphaSort']);
327
            $tree = $this->templateService->substituteCMarkers($tree);
328
            $urlParameters = [
329
                'id' => $this->pObj->id
330
            ];
331
            /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
332
            $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
333
            $aHref = (string)$uriBuilder->buildUriFromRoute('web_ts', $urlParameters);
334
            // Parser Errors:
335
            $pEkey = $bType === 'setup' ? 'config' : 'constants';
336
            $assigns['hasParseErrors'] = !empty($this->templateService->parserErrors[$pEkey]);
337
            if (!empty($this->templateService->parserErrors[$pEkey])) {
338
                $assigns['showErrorDetailsUri'] = $aHref . '&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TemplateAnalyzerModuleFunctionController&template=all&SET[ts_analyzer_checkLinenum]=1#line-';
339
                $assigns['parseErrors'] = $this->templateService->parserErrors[$pEkey];
340
            }
341
342
            if (isset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$theKey])) {
343
                $assigns['moduleUrlRemoveFromObjectList'] = $aHref . '&addKey[' . $theKey . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0';
344
            }
345
346
            $assigns['hasKeySelected'] = $theKey !== '';
347
348
            if ($theKey) {
349
                $assigns['treeLabel'] = $theKey;
350
            } else {
351
                $assigns['rootLLKey'] = $bType === 'setup' ? 'setupRoot' : 'constantRoot';
352
            }
353
            $assigns['tsTree'] = $tree;
354
355
            // second row options
356
            $assigns['isSetupAndCropLinesDisabled'] = $bType === 'setup' && !$this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'];
357
            $assigns['checkBoxShowComments'] = BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_showComments]', $this->pObj->MOD_SETTINGS['ts_browser_showComments'], '', '', 'id="checkTs_browser_showComments"');
358
            $assigns['checkBoxAlphaSort'] = BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_alphaSort]', $this->pObj->MOD_SETTINGS['ts_browser_alphaSort'], '', '', 'id="checkTs_browser_alphaSort"');
359
            $assigns['checkBoxCropLines'] = BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_fixedLgd]', $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'], '', '', 'id="checkTs_browser_fixedLgd"');
360
            if ($bType === 'setup' && !$this->pObj->MOD_SETTINGS['ts_browser_fixedLgd']) {
361
                $assigns['dropdownDisplayConstants'] = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS['ts_browser_const'], $this->pObj->MOD_MENU['ts_browser_const']);
362
            }
363
364
            // Conditions:
365
            $assigns['hasConditions'] = is_array($this->templateService->sections) && !empty($this->templateService->sections);
366
            if (is_array($this->templateService->sections) && !empty($this->templateService->sections)) {
367
                $tsConditions = [];
368
                foreach ($this->templateService->sections as $key => $val) {
369
                    $tsConditions[] = [
370
                        'key' => $key,
371
                        'value' => $val,
372
                        'label' => $this->templateService->substituteCMarkers(htmlspecialchars($val)),
373
                        'isSet' => $this->pObj->MOD_SETTINGS['tsbrowser_conditions'][$key] ? true : false
374
                    ];
375
                }
376
                $assigns['tsConditions'] = $tsConditions;
377
            }
378
            // Ending section displayoptions
379
        }
380
        $this->getPageRenderer();
381
        $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
382
        $view = GeneralUtility::makeInstance(StandaloneView::class);
383
        $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
384
            'EXT:tstemplate/Resources/Private/Templates/TemplateObjectBrowserModuleFunction.html'
385
        ));
386
        $view->assignMultiple($assigns);
387
388
        return $view->render();
389
    }
390
391
    /**
392
     * Add flash message to queue
393
     *
394
     * @param FlashMessage $flashMessage
395
     */
396
    protected function addFlashMessage(FlashMessage $flashMessage)
397
    {
398
        /** @var $flashMessageService FlashMessageService */
399
        $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
400
        /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
401
        $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
402
        $defaultFlashMessageQueue->enqueue($flashMessage);
403
    }
404
}
405