[BUGFIX] Recordlist: Removed call to deprecated method render()
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Classes / RecordList.php
1 <?php
2 namespace TYPO3\CMS\Recordlist;
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 Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
19 use TYPO3\CMS\Backend\Clipboard\Clipboard;
20 use TYPO3\CMS\Backend\Module\AbstractModule;
21 use TYPO3\CMS\Backend\Template\Components\ButtonBar;
22 use TYPO3\CMS\Backend\Template\DocumentTemplate;
23 use TYPO3\CMS\Backend\Template\ModuleTemplate;
24 use TYPO3\CMS\Backend\Utility\BackendUtility;
25 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
26 use TYPO3\CMS\Core\DataHandling\DataHandler;
27 use TYPO3\CMS\Core\Imaging\Icon;
28 use TYPO3\CMS\Core\Imaging\IconFactory;
29 use TYPO3\CMS\Core\Messaging\FlashMessage;
30 use TYPO3\CMS\Core\Messaging\FlashMessageService;
31 use TYPO3\CMS\Core\Page\PageRenderer;
32 use TYPO3\CMS\Core\Type\Bitmask\Permission;
33 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
34 use TYPO3\CMS\Core\Utility\GeneralUtility;
35 use TYPO3\CMS\Extbase\Service\TypoScriptService;
36 use TYPO3\CMS\Lang\LanguageService;
37
38 /**
39 * Script Class for the Web > List module; rendering the listing of records on a page
40 */
41 class RecordList extends AbstractModule
42 {
43 /**
44 * Page Id for which to make the listing
45 *
46 * @var int
47 */
48 public $id;
49
50 /**
51 * Pointer - for browsing list of records.
52 *
53 * @var int
54 */
55 public $pointer;
56
57 /**
58 * Thumbnails or not
59 *
60 * @var string
61 */
62 public $imagemode;
63
64 /**
65 * Which table to make extended listing for
66 *
67 * @var string
68 */
69 public $table;
70
71 /**
72 * Search-fields
73 *
74 * @var string
75 */
76 public $search_field;
77
78 /**
79 * Search-levels
80 *
81 * @var int
82 */
83 public $search_levels;
84
85 /**
86 * Show-limit
87 *
88 * @var int
89 */
90 public $showLimit;
91
92 /**
93 * Return URL
94 *
95 * @var string
96 */
97 public $returnUrl;
98
99 /**
100 * Clear-cache flag - if set, clears page cache for current id.
101 *
102 * @var bool
103 */
104 public $clear_cache;
105
106 /**
107 * Command: Eg. "delete" or "setCB" (for TCEmain / clipboard operations)
108 *
109 * @var string
110 */
111 public $cmd;
112
113 /**
114 * Table on which the cmd-action is performed.
115 *
116 * @var string
117 */
118 public $cmd_table;
119
120 /**
121 * Page select perms clause
122 *
123 * @var int
124 */
125 public $perms_clause;
126
127 /**
128 * Module TSconfig
129 *
130 * @var array
131 */
132 public $modTSconfig;
133
134 /**
135 * Current ids page record
136 *
137 * @var mixed[]|bool
138 */
139 public $pageinfo;
140
141 /**
142 * Document template object
143 *
144 * @var DocumentTemplate
145 */
146 public $doc;
147
148 /**
149 * Module configuration
150 *
151 * @var array
152 * @deprecated since TYPO3 CMS 7, will be removed in CMS 8.
153 */
154 public $MCONF = array();
155
156 /**
157 * Menu configuration
158 *
159 * @var string[]
160 */
161 public $MOD_MENU = array();
162
163 /**
164 * Module settings (session variable)
165 *
166 * @var string[]
167 */
168 public $MOD_SETTINGS = array();
169
170 /**
171 * Module output accumulation
172 *
173 * @var string
174 */
175 public $content;
176
177 /**
178 * The name of the module
179 *
180 * @var string
181 */
182 protected $moduleName = 'web_list';
183
184 /**
185 * @var string
186 */
187 public $body = '';
188
189 /**
190 * @var PageRenderer
191 */
192 protected $pageRenderer = null;
193
194 /**
195 * @var IconFactory
196 */
197 protected $iconFactory;
198
199 /**
200 * Constructor
201 */
202 public function __construct()
203 {
204 parent::__construct();
205 $this->getLanguageService()->includeLLFile('EXT:lang/locallang_mod_web_list.xlf');
206 $this->moduleTemplate->getPageRenderer()->loadJquery();
207 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/FieldSelectBox');
208 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/Recordlist');
209 }
210
211 /**
212 * Initializing the module
213 *
214 * @return void
215 */
216 public function init()
217 {
218 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
219 $backendUser = $this->getBackendUserAuthentication();
220 $this->perms_clause = $backendUser->getPagePermsClause(1);
221 // Get session data
222 $sessionData = $backendUser->getSessionData(__CLASS__);
223 $this->search_field = !empty($sessionData['search_field']) ? $sessionData['search_field'] : '';
224 // GPvars:
225 $this->id = (int)GeneralUtility::_GP('id');
226 $this->pointer = GeneralUtility::_GP('pointer');
227 $this->imagemode = GeneralUtility::_GP('imagemode');
228 $this->table = GeneralUtility::_GP('table');
229 $this->search_field = GeneralUtility::_GP('search_field');
230 $this->search_levels = (int)GeneralUtility::_GP('search_levels');
231 $this->showLimit = GeneralUtility::_GP('showLimit');
232 $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
233 $this->clear_cache = GeneralUtility::_GP('clear_cache');
234 $this->cmd = GeneralUtility::_GP('cmd');
235 $this->cmd_table = GeneralUtility::_GP('cmd_table');
236 $sessionData['search_field'] = $this->search_field;
237 // Initialize menu
238 $this->menuConfig();
239 // Store session data
240 $backendUser->setAndSaveSessionData(RecordList::class, $sessionData);
241 $this->getPageRenderer()->addInlineLanguageLabelFile('EXT:lang/locallang_mod_web_list.xlf');
242 }
243
244 /**
245 * Initialize function menu array
246 *
247 * @return void
248 */
249 public function menuConfig()
250 {
251 // MENU-ITEMS:
252 $this->MOD_MENU = array(
253 'bigControlPanel' => '',
254 'clipBoard' => '',
255 'localization' => ''
256 );
257 // Loading module configuration:
258 $this->modTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.' . $this->moduleName);
259 // Clean up settings:
260 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName);
261 }
262
263 /**
264 * Clears page cache for the current id, $this->id
265 *
266 * @return void
267 */
268 public function clearCache()
269 {
270 if ($this->clear_cache) {
271 $tce = GeneralUtility::makeInstance(DataHandler::class);
272 $tce->stripslashes_values = 0;
273 $tce->start(array(), array());
274 $tce->clear_cacheCmd($this->id);
275 }
276 }
277
278 /**
279 * Main function, starting the rendering of the list.
280 *
281 * @return void
282 */
283 public function main()
284 {
285 $backendUser = $this->getBackendUserAuthentication();
286 $lang = $this->getLanguageService();
287 // Loading current page record and checking access:
288 $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
289 $access = is_array($this->pageinfo) ? 1 : 0;
290 // Start document template object:
291 // We need to keep this due to deeply nested dependencies
292 $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
293
294 $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/AjaxDataHandler');
295 $calcPerms = $backendUser->calcPerms($this->pageinfo);
296 $userCanEditPage = $calcPerms & Permission::PAGE_EDIT && !empty($this->id) && ($backendUser->isAdmin() || (int)$this->pageinfo['editlock'] === 0);
297 if ($userCanEditPage) {
298 $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', 'function(PageActions) {
299 PageActions.setPageId(' . (int)$this->id . ');
300 PageActions.initializePageTitleRenaming();
301 }');
302 }
303 $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/Tooltip');
304 // Apply predefined values for hidden checkboxes
305 // Set predefined value for DisplayBigControlPanel:
306 if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'activated') {
307 $this->MOD_SETTINGS['bigControlPanel'] = true;
308 } elseif ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'deactivated') {
309 $this->MOD_SETTINGS['bigControlPanel'] = false;
310 }
311 // Set predefined value for Clipboard:
312 if ($this->modTSconfig['properties']['enableClipBoard'] === 'activated') {
313 $this->MOD_SETTINGS['clipBoard'] = true;
314 } elseif ($this->modTSconfig['properties']['enableClipBoard'] === 'deactivated') {
315 $this->MOD_SETTINGS['clipBoard'] = false;
316 } else {
317 if ($this->MOD_SETTINGS['clipBoard'] === null) {
318 $this->MOD_SETTINGS['clipBoard'] = true;
319 }
320 }
321 // Set predefined value for LocalizationView:
322 if ($this->modTSconfig['properties']['enableLocalizationView'] === 'activated') {
323 $this->MOD_SETTINGS['localization'] = true;
324 } elseif ($this->modTSconfig['properties']['enableLocalizationView'] === 'deactivated') {
325 $this->MOD_SETTINGS['localization'] = false;
326 }
327
328 // Initialize the dblist object:
329 /** @var $dblist RecordList\DatabaseRecordList */
330 $dblist = GeneralUtility::makeInstance(RecordList\DatabaseRecordList::class);
331 $dblist->script = BackendUtility::getModuleUrl('web_list');
332 $dblist->calcPerms = $calcPerms;
333 $dblist->thumbs = $backendUser->uc['thumbnailsByDefault'];
334 $dblist->returnUrl = $this->returnUrl;
335 $dblist->allFields = $this->MOD_SETTINGS['bigControlPanel'] || $this->table ? 1 : 0;
336 $dblist->localizationView = $this->MOD_SETTINGS['localization'];
337 $dblist->showClipboard = 1;
338 $dblist->disableSingleTableView = $this->modTSconfig['properties']['disableSingleTableView'];
339 $dblist->listOnlyInSingleTableMode = $this->modTSconfig['properties']['listOnlyInSingleTableView'];
340 $dblist->hideTables = $this->modTSconfig['properties']['hideTables'];
341 $dblist->hideTranslations = $this->modTSconfig['properties']['hideTranslations'];
342 $dblist->tableTSconfigOverTCA = $this->modTSconfig['properties']['table.'];
343 $dblist->allowedNewTables = GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], true);
344 $dblist->deniedNewTables = GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], true);
345 $dblist->newWizards = $this->modTSconfig['properties']['newWizards'] ? 1 : 0;
346 $dblist->pageRow = $this->pageinfo;
347 $dblist->counter++;
348 $dblist->MOD_MENU = array('bigControlPanel' => '', 'clipBoard' => '', 'localization' => '');
349 $dblist->modTSconfig = $this->modTSconfig;
350 $clickTitleMode = trim($this->modTSconfig['properties']['clickTitleMode']);
351 $dblist->clickTitleMode = $clickTitleMode === '' ? 'edit' : $clickTitleMode;
352 if (isset($this->modTSconfig['properties']['tableDisplayOrder.'])) {
353 $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
354 $dblist->setTableDisplayOrder($typoScriptService->convertTypoScriptArrayToPlainArray($this->modTSconfig['properties']['tableDisplayOrder.']));
355 }
356 // Clipboard is initialized:
357 // Start clipboard
358 $dblist->clipObj = GeneralUtility::makeInstance(Clipboard::class);
359 // Initialize - reads the clipboard content from the user session
360 $dblist->clipObj->initializeClipboard();
361 // Clipboard actions are handled:
362 // CB is the clipboard command array
363 $CB = GeneralUtility::_GET('CB');
364 if ($this->cmd == 'setCB') {
365 // CBH is all the fields selected for the clipboard, CBC is the checkbox fields which were checked.
366 // By merging we get a full array of checked/unchecked elements
367 // This is set to the 'el' array of the CB after being parsed so only the table in question is registered.
368 $CB['el'] = $dblist->clipObj->cleanUpCBC(array_merge(GeneralUtility::_POST('CBH'), (array)GeneralUtility::_POST('CBC')), $this->cmd_table);
369 }
370 if (!$this->MOD_SETTINGS['clipBoard']) {
371 // If the clipboard is NOT shown, set the pad to 'normal'.
372 $CB['setP'] = 'normal';
373 }
374 // Execute commands.
375 $dblist->clipObj->setCmd($CB);
376 // Clean up pad
377 $dblist->clipObj->cleanCurrent();
378 // Save the clipboard content
379 $dblist->clipObj->endClipboard();
380 // This flag will prevent the clipboard panel in being shown.
381 // It is set, if the clickmenu-layer is active AND the extended view is not enabled.
382 $dblist->dontShowClipControlPanels = ($dblist->clipObj->current == 'normal' && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers']);
383 // If there is access to the page or root page is used for searching, then render the list contents and set up the document template object:
384 if ($access || ($this->id === 0 && $this->search_levels > 0 && $this->search_field !== '')) {
385 // Deleting records...:
386 // Has not to do with the clipboard but is simply the delete action. The clipboard object is used to clean up the submitted entries to only the selected table.
387 if ($this->cmd == 'delete') {
388 $items = $dblist->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), $this->cmd_table, 1);
389 if (!empty($items)) {
390 $cmd = array();
391 foreach ($items as $iK => $value) {
392 $iKParts = explode('|', $iK);
393 $cmd[$iKParts[0]][$iKParts[1]]['delete'] = 1;
394 }
395 $tce = GeneralUtility::makeInstance(DataHandler::class);
396 $tce->stripslashes_values = 0;
397 $tce->start(array(), $cmd);
398 $tce->process_cmdmap();
399 if (isset($cmd['pages'])) {
400 BackendUtility::setUpdateSignal('updatePageTree');
401 }
402 $tce->printLogErrorMessages(GeneralUtility::getIndpEnv('REQUEST_URI'));
403 }
404 }
405 // Initialize the listing object, dblist, for rendering the list:
406 $this->pointer = max(0, (int)$this->pointer);
407 $dblist->start($this->id, $this->table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
408 $dblist->setDispFields();
409 // Render versioning selector:
410 if (ExtensionManagementUtility::isLoaded('version')) {
411 $dblist->HTMLcode .= $this->moduleTemplate->getVersionSelector($this->id);
412 }
413 // Render the list of tables:
414 $dblist->generateList();
415 $listUrl = $dblist->listURL();
416 // Add JavaScript functions to the page:
417
418 $this->moduleTemplate->addJavaScriptCode(
419 'RecordListInlineJS',
420 '
421 function jumpExt(URL,anchor) { //
422 var anc = anchor?anchor:"";
423 window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc;
424 return false;
425 }
426 function jumpSelf(URL) { //
427 window.location.href = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:"");
428 return false;
429 }
430 function jumpToUrl(URL) {
431 window.location.href = URL;
432 return false;
433 }
434
435 function setHighlight(id) { //
436 top.fsMod.recentIds["web"]=id;
437 top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_"+top.fsMod.currentBank; // For highlighting
438
439 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
440 top.content.nav_frame.refresh_nav();
441 }
442 }
443 ' . $this->moduleTemplate->redirectUrls($listUrl) . '
444 ' . $dblist->CBfunctions() . '
445 function editRecords(table,idList,addParams,CBflag) { //
446 window.location.href="' . BackendUtility::getModuleUrl('record_edit', array('returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'))) . '&edit["+table+"]["+idList+"]=edit"+addParams;
447 }
448 function editList(table,idList) { //
449 var list="";
450
451 // Checking how many is checked, how many is not
452 var pointer=0;
453 var pos = idList.indexOf(",");
454 while (pos!=-1) {
455 if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) {
456 list+=idList.substr(pointer,pos-pointer)+",";
457 }
458 pointer=pos+1;
459 pos = idList.indexOf(",",pointer);
460 }
461 if (cbValue(table+"|"+idList.substr(pointer))) {
462 list+=idList.substr(pointer)+",";
463 }
464
465 return list ? list : idList;
466 }
467
468 if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
469 '
470 );
471
472 // Setting up the context sensitive menu:
473 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu');
474 }
475 // access
476 // Begin to compile the whole page, starting out with page header:
477 if (!$this->id) {
478 $this->body = $this->moduleTemplate->header($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
479 } else {
480 $this->body = $this->moduleTemplate->header($this->pageinfo['title']);
481 }
482
483 if (!empty($dblist->HTMLcode)) {
484 $output = $dblist->HTMLcode;
485 } else {
486 $output = '';
487 $flashMessage = GeneralUtility::makeInstance(
488 FlashMessage::class,
489 $lang->getLL('noRecordsOnThisPage'),
490 '',
491 FlashMessage::INFO
492 );
493 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
494 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
495 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
496 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
497 $defaultFlashMessageQueue->enqueue($flashMessage);
498 }
499
500 $this->body .= '<form action="' . htmlspecialchars($dblist->listURL()) . '" method="post" name="dblistForm">';
501 $this->body .= $output;
502 $this->body .= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>';
503 // If a listing was produced, create the page footer with search form etc:
504 if ($dblist->HTMLcode) {
505 // Making field select box (when extended view for a single table is enabled):
506 if ($dblist->table) {
507 $this->body .= $dblist->fieldSelectBox($dblist->table);
508 }
509 // Adding checkbox options for extended listing and clipboard display:
510 $this->body .= '
511
512 <!--
513 Listing options for extended view, clipboard and localization view
514 -->
515 <div class="typo3-listOptions">
516 <form action="" method="post">';
517
518 // Add "display bigControlPanel" checkbox:
519 if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'selectable') {
520 $this->body .= '<div class="checkbox">' .
521 '<label for="checkLargeControl">' .
522 BackendUtility::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLargeControl"') .
523 BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $lang->getLL('largeControl', true)) .
524 '</label>' .
525 '</div>';
526 }
527
528 // Add "clipboard" checkbox:
529 if ($this->modTSconfig['properties']['enableClipBoard'] === 'selectable') {
530 if ($dblist->showClipboard) {
531 $this->body .= '<div class="checkbox">' .
532 '<label for="checkShowClipBoard">' .
533 BackendUtility::getFuncCheck($this->id, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], '', $this->table ? '&table=' . $this->table : '', 'id="checkShowClipBoard"') .
534 BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $lang->getLL('showClipBoard', true)) .
535 '</label>' .
536 '</div>';
537 }
538 }
539
540 // Add "localization view" checkbox:
541 if ($this->modTSconfig['properties']['enableLocalizationView'] === 'selectable') {
542 $this->body .= '<div class="checkbox">' .
543 '<label for="checkLocalization">' .
544 BackendUtility::getFuncCheck($this->id, 'SET[localization]', $this->MOD_SETTINGS['localization'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLocalization"') .
545 BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $lang->getLL('localization', true)) .
546 '</label>' .
547 '</div>';
548 }
549
550 $this->body .= '
551 </form>
552 </div>';
553 }
554 // Printing clipboard if enabled
555 if ($this->MOD_SETTINGS['clipBoard'] && $dblist->showClipboard && ($dblist->HTMLcode || $dblist->clipObj->hasElements())) {
556 $this->body .= '<div class="db_list-dashboard">' . $dblist->clipObj->printClipboard() . '</div>';
557 }
558 // Additional footer content
559 $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['recordlist/Modules/Recordlist/index.php']['drawFooterHook'];
560 if (is_array($footerContentHook)) {
561 foreach ($footerContentHook as $hook) {
562 $params = array();
563 $this->body .= GeneralUtility::callUserFunction($hook, $params, $this);
564 }
565 }
566 // Setting up the buttons for docheader
567 $dblist->getDocHeaderButtons($this->moduleTemplate);
568 // searchbox toolbar
569 if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dblist->HTMLcode || !empty($dblist->searchString))) {
570 $this->content = $dblist->getSearchBox();
571 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox');
572
573 $searchButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeLinkButton();
574 $searchButton
575 ->setHref('#')
576 ->setClasses('t3js-toggle-search-toolbox')
577 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon'))
578 ->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL));
579 $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($searchButton,
580 ButtonBar::BUTTON_POSITION_LEFT, 90);
581 }
582
583 if ($this->pageinfo) {
584 $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
585 }
586
587 // Build the <body> for the module
588 $this->content .= $this->body;
589 }
590
591 /**
592 * Injects the request object for the current request or subrequest
593 * Simply calls main() and init() and outputs the content
594 *
595 * @param ServerRequestInterface $request the current request
596 * @param ResponseInterface $response
597 * @return ResponseInterface the response with the content
598 */
599 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
600 {
601 BackendUtility::lockRecords();
602 $GLOBALS['SOBE'] = $this;
603 $this->init();
604 $this->clearCache();
605 $this->main();
606 $this->moduleTemplate->setContent($this->content);
607 $response->getBody()->write($this->moduleTemplate->renderContent());
608 return $response;
609 }
610
611 /**
612 * Outputting the accumulated content to screen
613 *
614 * @return void
615 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
616 */
617 public function printContent()
618 {
619 GeneralUtility::logDeprecatedFunction();
620 echo $this->content;
621 }
622
623 /**
624 * @return ModuleTemplate
625 */
626 public function getModuleTemplate()
627 {
628 return $this->moduleTemplate;
629 }
630
631 /**
632 * @return BackendUserAuthentication
633 */
634 protected function getBackendUserAuthentication()
635 {
636 return $GLOBALS['BE_USER'];
637 }
638
639 /**
640 * @return LanguageService
641 */
642 protected function getLanguageService()
643 {
644 return $GLOBALS['LANG'];
645 }
646
647 /**
648 * @return PageRenderer
649 */
650 protected function getPageRenderer()
651 {
652 if ($this->pageRenderer === null) {
653 $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
654 }
655
656 return $this->pageRenderer;
657 }
658 }