[CLEANUP] Replace count with empty in EXT:backend
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / EditDocumentController.php
1 <?php
2 namespace TYPO3\CMS\Backend\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\Form\FormEngine;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Backend\Utility\IconUtility;
20 use TYPO3\CMS\Core\Html\HtmlParser;
21 use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
22 use TYPO3\CMS\Core\Type\Bitmask\Permission;
23 use TYPO3\CMS\Core\Utility\GeneralUtility;
24 use TYPO3\CMS\Core\Utility\HttpUtility;
25 use TYPO3\CMS\Core\Utility\MathUtility;
26 use TYPO3\CMS\Frontend\Page\PageRepository;
27 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
28 use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
29 use TYPO3\CMS\Core\DataHandling\DataHandler;
30 use TYPO3\CMS\Backend\Form\DataPreprocessor;
31 use TYPO3\CMS\Core\Messaging\FlashMessage;
32 use TYPO3\CMS\Core\Messaging\FlashMessageService;
33
34 /**
35 * Script Class: Drawing the editing form for editing records in TYPO3.
36 * Notice: It does NOT use tce_db.php to submit data to, rather it handles submissions itself
37 *
38 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
39 */
40 class EditDocumentController {
41
42 /**
43 * GPvar "edit": Is an array looking approx like [tablename][list-of-ids]=command, eg.
44 * "&edit[pages][123]=edit". See \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick(). Value can be seen modified
45 * internally (converting NEW keyword to id, workspace/versioning etc).
46 *
47 * @var array
48 */
49 public $editconf;
50
51 /**
52 * Commalist of fieldnames to edit. The point is IF you specify this list, only those
53 * fields will be rendered in the form. Otherwise all (available) fields in the record
54 * is shown according to the types configuration in $GLOBALS['TCA']
55 *
56 * @var bool
57 */
58 public $columnsOnly;
59
60 /**
61 * Default values for fields (array with tablenames, fields etc. as keys).
62 * Can be seen modified internally.
63 *
64 * @var array
65 */
66 public $defVals;
67
68 /**
69 * Array of values to force being set (as hidden fields). Will be set as $this->defVals
70 * IF defVals does not exist.
71 *
72 * @var array
73 */
74 public $overrideVals;
75
76 /**
77 * If set, this value will be set in $this->retUrl (which is used quite many places
78 * as the return URL). If not set, "dummy.php" will be set in $this->retUrl
79 *
80 * @var string
81 */
82 public $returnUrl;
83
84 /**
85 * Close-document command. Not really sure of all options...
86 *
87 * @var int
88 */
89 public $closeDoc;
90
91 /**
92 * Quite simply, if this variable is set, then the processing of incoming data will be performed
93 * as if a save-button is pressed. Used in the forms as a hidden field which can be set through
94 * JavaScript if the form is somehow submitted by JavaScript).
95 *
96 * @var bool
97 */
98 public $doSave;
99
100 /**
101 * The data array from which the data comes...
102 *
103 * @var array
104 */
105 public $data;
106
107 /**
108 * @var string
109 */
110 public $cmd;
111
112 /**
113 * @var array
114 */
115 public $mirror;
116
117 /**
118 * Clear-cache cmd.
119 *
120 * @var string
121 */
122 public $cacheCmd;
123
124 /**
125 * Redirect (not used???)
126 *
127 * @var string
128 */
129 public $redirect;
130
131 /**
132 * Boolean: If set, then the GET var "&id=" will be added to the
133 * retUrl string so that the NEW id of something is returned to the script calling the form.
134 *
135 * @var bool
136 */
137 public $returnNewPageId;
138
139 /**
140 * @var string
141 */
142 public $vC;
143
144 /**
145 * update BE_USER->uc
146 *
147 * @var array
148 */
149 public $uc;
150
151 /**
152 * ID for displaying the page in the frontend (used for SAVE/VIEW operations)
153 *
154 * @var int
155 */
156 public $popViewId;
157
158 /**
159 * Additional GET vars for the link, eg. "&L=xxx"
160 *
161 * @var string
162 */
163 public $popViewId_addParams;
164
165 /**
166 * Alternative URL for viewing the frontend pages.
167 *
168 * @var string
169 */
170 public $viewUrl;
171
172 /**
173 * If this is pointing to a page id it will automatically load all content elements
174 * (NORMAL column/default language) from that page into the form!
175 *
176 * @var int
177 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8
178 */
179 public $editRegularContentFromId;
180
181 /**
182 * Alternative title for the document handler.
183 *
184 * @var string
185 */
186 public $recTitle;
187
188 /**
189 * If set, then no SAVE/VIEW button is printed
190 *
191 * @var bool
192 */
193 public $noView;
194
195 /**
196 * @var string
197 */
198 public $perms_clause;
199
200 /**
201 * If set, the $this->editconf array is returned to the calling script
202 * (used by wizard_add.php for instance)
203 *
204 * @var bool
205 */
206 public $returnEditConf;
207
208 /**
209 * localization mode for TCEforms (eg. "text")
210 *
211 * @var string
212 */
213 public $localizationMode;
214
215 /**
216 * Workspace used for the editing action.
217 *
218 * @var NULL|integer
219 */
220 protected $workspace;
221
222 /**
223 * document template object
224 *
225 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
226 */
227 public $doc;
228
229 /**
230 * a static HTML template, usually in templates/alt_doc.html
231 *
232 * @var string
233 */
234 public $template;
235
236 /**
237 * Content accumulation
238 *
239 * @var string
240 */
241 public $content;
242
243 /**
244 * Return URL script, processed. This contains the script (if any) that we should
245 * RETURN TO from the FormEngine script IF we press the close button. Thus this
246 * variable is normally passed along from the calling script so we can properly return if needed.
247 *
248 * @var string
249 */
250 public $retUrl;
251
252 /**
253 * Contains the parts of the REQUEST_URI (current url). By parts we mean the result of resolving
254 * REQUEST_URI (current url) by the parse_url() function. The result is an array where eg. "path"
255 * is the script path and "query" is the parameters...
256 *
257 * @var array
258 */
259 public $R_URL_parts;
260
261 /**
262 * Contains the current GET vars array; More specifically this array is the foundation for creating
263 * the R_URI internal var (which becomes the "url of this script" to which we submit the forms etc.)
264 *
265 * @var array
266 */
267 public $R_URL_getvars;
268
269 /**
270 * Set to the URL of this script including variables which is needed to re-display the form. See main()
271 *
272 * @var string
273 */
274 public $R_URI;
275
276 /**
277 * @var array
278 */
279 public $MCONF;
280
281 /**
282 * @var array
283 */
284 public $pageinfo;
285
286 /**
287 * Is loaded with the "title" of the currently "open document" - this is used in the
288 * Document Selector box. (see makeDocSel())
289 *
290 * @var string
291 */
292 public $storeTitle;
293
294 /**
295 * Contains an array with key/value pairs of GET parameters needed to reach the
296 * current document displayed - used in the Document Selector box. (see compileStoreDat())
297 *
298 * @var array
299 */
300 public $storeArray;
301
302 /**
303 * Contains storeArray, but imploded into a GET parameter string (see compileStoreDat())
304 *
305 * @var string
306 */
307 public $storeUrl;
308
309 /**
310 * Hashed value of storeURL (see compileStoreDat())
311 *
312 * @var string
313 */
314 public $storeUrlMd5;
315
316 /**
317 * Module session data
318 *
319 * @var array
320 */
321 public $docDat;
322
323 /**
324 * An array of the "open documents" - keys are md5 hashes (see $storeUrlMd5) identifying
325 * the various documents on the GET parameter list needed to open it. The values are
326 * arrays with 0,1,2 keys with information about the document (see compileStoreDat()).
327 * The docHandler variable is stored in the $docDat session data, key "0".
328 *
329 * @var array
330 */
331 public $docHandler;
332
333 /**
334 * Array of the elements to create edit forms for.
335 *
336 * @var array
337 */
338 public $elementsData;
339
340 /**
341 * Pointer to the first element in $elementsData
342 *
343 * @var array
344 */
345 public $firstEl;
346
347 /**
348 * Counter, used to count the number of errors (when users do not have edit permissions)
349 *
350 * @var int
351 */
352 public $errorC;
353
354 /**
355 * Counter, used to count the number of new record forms displayed
356 *
357 * @var int
358 */
359 public $newC;
360
361 /**
362 * Is set to the pid value of the last shown record - thus indicating which page to
363 * show when clicking the SAVE/VIEW button
364 *
365 * @var int
366 */
367 public $viewId;
368
369 /**
370 * Is set to additional parameters (like "&L=xxx") if the record supports it.
371 *
372 * @var string
373 */
374 public $viewId_addParams;
375
376 /**
377 * Module TSconfig, loaded from main() based on the page id value of viewId
378 *
379 * @var array
380 */
381 public $modTSconfig;
382
383 /**
384 * instance of TCEforms class
385 *
386 * @var \TYPO3\CMS\Backend\Form\FormEngine
387 */
388 public $tceforms;
389
390 /**
391 * Contains the root-line path of the currently edited record(s) - for display.
392 *
393 * @var string
394 */
395 public $generalPathOfForm;
396
397 /**
398 * Used internally to disable the storage of the document reference (eg. new records)
399 *
400 * @var bool
401 */
402 public $dontStoreDocumentRef;
403
404 /**
405 * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
406 */
407 protected $signalSlotDispatcher;
408
409 /**
410 * Stores information needed to preview the currently saved record
411 *
412 * @var array
413 */
414 protected $previewData = [];
415
416 /**
417 * Constructor
418 */
419 public function __construct() {
420 $GLOBALS['SOBE'] = $this;
421 $this->getLanguageService()->includeLLFile('EXT:lang/locallang_alt_doc.xml');
422 }
423
424 /**
425 * Get the SignalSlot dispatcher
426 *
427 * @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
428 */
429 protected function getSignalSlotDispatcher() {
430 if (!isset($this->signalSlotDispatcher)) {
431 $this->signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
432 }
433 return $this->signalSlotDispatcher;
434 }
435
436 /**
437 * Emits a signal after a function was executed
438 *
439 * @param string $signalName
440 */
441 protected function emitFunctionAfterSignal($signalName) {
442 $this->getSignalSlotDispatcher()->dispatch(__CLASS__, $signalName . 'After', array($this));
443 }
444
445 /**
446 * First initialization.
447 *
448 * @return void
449 */
450 public function preInit() {
451 if (GeneralUtility::_GP('justLocalized')) {
452 $this->localizationRedirect(GeneralUtility::_GP('justLocalized'));
453 }
454 // Setting GPvars:
455 $this->editconf = GeneralUtility::_GP('edit');
456 $this->defVals = GeneralUtility::_GP('defVals');
457 $this->overrideVals = GeneralUtility::_GP('overrideVals');
458 $this->columnsOnly = GeneralUtility::_GP('columnsOnly');
459 $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
460 $this->closeDoc = GeneralUtility::_GP('closeDoc');
461 $this->doSave = GeneralUtility::_GP('doSave');
462 $this->returnEditConf = GeneralUtility::_GP('returnEditConf');
463 $this->localizationMode = GeneralUtility::_GP('localizationMode');
464 $this->workspace = GeneralUtility::_GP('workspace');
465 $this->uc = GeneralUtility::_GP('uc');
466 // Setting override values as default if defVals does not exist.
467 if (!is_array($this->defVals) && is_array($this->overrideVals)) {
468 $this->defVals = $this->overrideVals;
469 }
470 // Setting return URL
471 $this->retUrl = $this->returnUrl ?: BackendUtility::getModuleUrl('dummy');
472 // Fix $this->editconf if versioning applies to any of the records
473 $this->fixWSversioningInEditConf();
474 // Make R_URL (request url) based on input GETvars:
475 $this->R_URL_parts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
476 $this->R_URL_getvars = GeneralUtility::_GET();
477 $this->R_URL_getvars['edit'] = $this->editconf;
478 // MAKE url for storing
479 $this->compileStoreDat();
480 // Initialize more variables.
481 $this->dontStoreDocumentRef = 0;
482 $this->storeTitle = '';
483 // Get session data for the module:
484 $this->docDat = $this->getBackendUser()->getModuleData('FormEngine', 'ses');
485 $this->docHandler = $this->docDat[0];
486 // If a request for closing the document has been sent, act accordingly:
487 if ($this->closeDoc > 0) {
488 $this->closeDocument($this->closeDoc);
489 }
490 // If NO vars are sent to the script, try to read first document:
491 // Added !is_array($this->editconf) because editConf must not be set either.
492 // Anyways I can't figure out when this situation here will apply...
493 if (is_array($this->R_URL_getvars) && count($this->R_URL_getvars) < 2 && !is_array($this->editconf)) {
494 $this->setDocument($this->docDat[1]);
495 }
496
497 // Sets a temporary workspace, this request is based on
498 if ($this->workspace !== NULL) {
499 $this->getBackendUser()->setTemporaryWorkspace($this->workspace);
500 }
501
502 $this->emitFunctionAfterSignal(__FUNCTION__);
503 }
504
505 /**
506 * Detects, if a save command has been triggered.
507 *
508 * @return bool TRUE, then save the document (data submitted)
509 */
510 public function doProcessData() {
511 $out = $this->doSave || isset($_POST['_savedok_x']) || isset($_POST['_saveandclosedok_x']) || isset($_POST['_savedokview_x']) || isset($_POST['_savedoknew_x']) || isset($_POST['_translation_savedok_x']) || isset($_POST['_translation_savedokclear_x']);
512 return $out;
513 }
514
515 /**
516 * Do processing of data, submitting it to TCEmain.
517 *
518 * @return void
519 */
520 public function processData() {
521 $beUser = $this->getBackendUser();
522 // GPvars specifically for processing:
523 $control = GeneralUtility::_GP('control');
524 $this->data = GeneralUtility::_GP('data');
525 $this->cmd = GeneralUtility::_GP('cmd');
526 $this->mirror = GeneralUtility::_GP('mirror');
527 $this->cacheCmd = GeneralUtility::_GP('cacheCmd');
528 $this->redirect = GeneralUtility::_GP('redirect');
529 $this->returnNewPageId = GeneralUtility::_GP('returnNewPageId');
530 $this->vC = GeneralUtility::_GP('vC');
531 // See tce_db.php for relevate options here:
532 // Only options related to $this->data submission are included here.
533 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
534 $tce = GeneralUtility::makeInstance(DataHandler::class);
535 $tce->stripslashes_values = FALSE;
536
537 if (!empty($control)) {
538 $tce->setControl($control);
539 }
540 if (isset($_POST['_translation_savedok_x'])) {
541 $tce->updateModeL10NdiffData = 'FORCE_FFUPD';
542 }
543 if (isset($_POST['_translation_savedokclear_x'])) {
544 $tce->updateModeL10NdiffData = 'FORCE_FFUPD';
545 $tce->updateModeL10NdiffDataClear = TRUE;
546 }
547 // Setting default values specific for the user:
548 $TCAdefaultOverride = $beUser->getTSConfigProp('TCAdefaults');
549 if (is_array($TCAdefaultOverride)) {
550 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
551 }
552 // Setting internal vars:
553 if ($beUser->uc['neverHideAtCopy']) {
554 $tce->neverHideAtCopy = 1;
555 }
556 // Loading TCEmain with data:
557 $tce->start($this->data, $this->cmd);
558 if (is_array($this->mirror)) {
559 $tce->setMirror($this->mirror);
560 }
561 // Checking referer / executing
562 $refInfo = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER'));
563 $httpHost = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
564 if ($httpHost != $refInfo['host'] && $this->vC != $beUser->veriCode() && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) {
565 $tce->log('', 0, 0, 0, 1, 'Referer host \'%s\' and server host \'%s\' did not match and veriCode was not valid either!', 1, array($refInfo['host'], $httpHost));
566 debug('Error: Referer host did not match with server host.');
567 } else {
568 // Perform the saving operation with TCEmain:
569 $tce->process_uploads($_FILES);
570 $tce->process_datamap();
571 $tce->process_cmdmap();
572 // If pages are being edited, we set an instruction about updating the page tree after this operation.
573 if ($tce->pagetreeNeedsRefresh && (isset($this->data['pages']) || $beUser->workspace != 0 && !empty($this->data))) {
574 BackendUtility::setUpdateSignal('updatePageTree');
575 }
576 // If there was saved any new items, load them:
577 if (!empty($tce->substNEWwithIDs_table)) {
578 // save the expanded/collapsed states for new inline records, if any
579 FormEngineUtility::updateInlineView($this->uc, $tce);
580 $newEditConf = array();
581 foreach ($this->editconf as $tableName => $tableCmds) {
582 $keys = array_keys($tce->substNEWwithIDs_table, $tableName);
583 if (!empty($keys)) {
584 foreach ($keys as $key) {
585 $editId = $tce->substNEWwithIDs[$key];
586 // Check if the $editId isn't a child record of an IRRE action
587 if (!(is_array($tce->newRelatedIDs[$tableName]) && in_array($editId, $tce->newRelatedIDs[$tableName]))) {
588 // Translate new id to the workspace version:
589 if ($versionRec = BackendUtility::getWorkspaceVersionOfRecord($beUser->workspace, $tableName, $editId, 'uid')) {
590 $editId = $versionRec['uid'];
591 }
592 $newEditConf[$tableName][$editId] = 'edit';
593 }
594 // Traverse all new records and forge the content of ->editconf so we can continue to EDIT these records!
595 if ($tableName == 'pages' && $this->retUrl != BackendUtility::getModuleUrl('dummy') && $this->returnNewPageId) {
596 $this->retUrl .= '&id=' . $tce->substNEWwithIDs[$key];
597 }
598 }
599 } else {
600 $newEditConf[$tableName] = $tableCmds;
601 }
602 }
603 // Resetting editconf if newEditConf has values:
604 if (!empty($newEditConf)) {
605 $this->editconf = $newEditConf;
606 }
607 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
608 $this->R_URL_getvars['edit'] = $this->editconf;
609 // Unsetting default values since we don't need them anymore.
610 unset($this->R_URL_getvars['defVals']);
611 // Re-compile the store* values since editconf changed...
612 $this->compileStoreDat();
613 }
614 // See if any records was auto-created as new versions?
615 if (!empty($tce->autoVersionIdMap)) {
616 $this->fixWSversioningInEditConf($tce->autoVersionIdMap);
617 }
618 // If a document is saved and a new one is created right after.
619 if (isset($_POST['_savedoknew_x']) && is_array($this->editconf)) {
620 // Finding the current table:
621 reset($this->editconf);
622 $nTable = key($this->editconf);
623 // Finding the first id, getting the records pid+uid
624 reset($this->editconf[$nTable]);
625 $nUid = key($this->editconf[$nTable]);
626 $nRec = BackendUtility::getRecord($nTable, $nUid, 'pid,uid');
627 // Setting a blank editconf array for a new record:
628 $this->editconf = array();
629 if ($this->getNewIconMode($nTable) == 'top') {
630 $this->editconf[$nTable][$nRec['pid']] = 'new';
631 } else {
632 $this->editconf[$nTable][-$nRec['uid']] = 'new';
633 }
634 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
635 $this->R_URL_getvars['edit'] = $this->editconf;
636 // Re-compile the store* values since editconf changed...
637 $this->compileStoreDat();
638 }
639 // If a preview is requested
640 if (isset($_POST['_savedokview_x'])) {
641 // Get the first table and id of the data array from DataHandler
642 $table = reset(array_keys($this->data));
643 $id = reset(array_keys($this->data[$table]));
644 if (!MathUtility::canBeInterpretedAsInteger($id)) {
645 $id = $tce->substNEWwithIDs[$id];
646 }
647 // Store this information for later use
648 $this->previewData['table'] = $table;
649 $this->previewData['id'] = $id;
650 }
651 $tce->printLogErrorMessages(isset($_POST['_saveandclosedok_x']) || isset($_POST['_translation_savedok_x']) ? $this->retUrl : $this->R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $this->R_URL_getvars));
652 }
653 // || count($tce->substNEWwithIDs)... If any new items has been save, the document is CLOSED
654 // because if not, we just get that element re-listed as new. And we don't want that!
655 if (isset($_POST['_saveandclosedok_x']) || isset($_POST['_translation_savedok_x']) || $this->closeDoc < 0) {
656 $this->closeDocument(abs($this->closeDoc));
657 }
658 }
659
660 /**
661 * Initialize the normal module operation
662 *
663 * @return void
664 */
665 public function init() {
666 $beUser = $this->getBackendUser();
667 // Setting more GPvars:
668 $this->popViewId = GeneralUtility::_GP('popViewId');
669 $this->popViewId_addParams = GeneralUtility::_GP('popViewId_addParams');
670 $this->viewUrl = GeneralUtility::_GP('viewUrl');
671 $this->editRegularContentFromId = GeneralUtility::_GP('editRegularContentFromId');
672 $this->recTitle = GeneralUtility::_GP('recTitle');
673 $this->noView = GeneralUtility::_GP('noView');
674 $this->perms_clause = $beUser->getPagePermsClause(1);
675 // Set other internal variables:
676 $this->R_URL_getvars['returnUrl'] = $this->retUrl;
677 $this->R_URI = $this->R_URL_parts['path'] . '?' . ltrim(GeneralUtility::implodeArrayForUrl('', $this->R_URL_getvars), '&');
678 // Setting virtual document name
679 $this->MCONF['name'] = 'xMOD_alt_doc.php';
680 // Create an instance of the document template object
681 $this->doc = $GLOBALS['TBE_TEMPLATE'];
682 $this->doc->getPageRenderer()->addInlineLanguageLabelFile('EXT:lang/locallang_alt_doc.xml');
683 $this->doc->backPath = $GLOBALS['BACK_PATH'];
684 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/alt_doc.html');
685 $this->doc->form = '<form action="' . htmlspecialchars($this->R_URI) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editform" onsubmit="document.editform._scrollPosition.value=(document.documentElement.scrollTop || document.body.scrollTop); return TBE_EDITOR.checkSubmit(1);">';
686 $this->doc->getPageRenderer()->loadPrototype();
687 // override the default jumpToUrl
688 $this->doc->JScodeArray['jumpToUrl'] = '
689 function jumpToUrl(URL,formEl) {
690 if (!TBE_EDITOR.isFormChanged()) {
691 window.location.href = URL;
692 } else if (formEl && formEl.type=="checkbox") {
693 formEl.checked = formEl.checked ? 0 : 1;
694 }
695 }
696 ';
697 // define the window size of the element browser
698 $popupWindowWidth = 700;
699 $popupWindowHeight = 750;
700 $popupWindowSize = trim($beUser->getTSConfigVal('options.popupWindowSize'));
701 if (!empty($popupWindowSize)) {
702 list($popupWindowWidth, $popupWindowHeight) = GeneralUtility::intExplode('x', $popupWindowSize);
703 }
704 $t3Configuration = array(
705 'PopupWindow' => array(
706 'width' => $popupWindowWidth,
707 'height' => $popupWindowHeight
708 ),
709 );
710 $javascript = '
711 TYPO3.configuration = ' . json_encode($t3Configuration) . ';
712 // Object: TS:
713 // passwordDummy and decimalSign are used by tbe_editor.js and have to be declared here as
714 // TS object overwrites the object declared in tbe_editor.js
715 function typoSetup() { //
716 this.uniqueID = "";
717 this.passwordDummy = "********";
718 this.PATH_typo3 = "";
719 this.decimalSign = ".";
720 }
721 var TS = new typoSetup();
722
723 // Info view:
724 function launchView(table,uid,bP) { //
725 var backPath= bP ? bP : "";
726 var thePreviewWindow="";
727 thePreviewWindow = window.open(backPath+' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('show_item', array(), '') . '&table=') . '+encodeURIComponent(table)+"&uid="+encodeURIComponent(uid),"ShowItem"+TS.uniqueID,"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
728 if (thePreviewWindow && thePreviewWindow.focus) {
729 thePreviewWindow.focus();
730 }
731 }
732 function deleteRecord(table,id,url) { //
733 if (
734 ' . ($beUser->jsConfirmation(JsConfirmation::DELETE) ? 'confirm(' . GeneralUtility::quoteJSvalue($this->getLanguageService()->getLL('deleteWarning')) . ')' : '1==1') . '
735 ) {
736 window.location.href = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&cmd[') . '+table+"]["+id+"][delete]=1' . BackendUtility::getUrlToken('tceAction') . '&redirect="+escape(url)+"&vC=' . $beUser->veriCode() . '&prErr=1&uPT=1";
737 }
738 return false;
739 }
740 ';
741
742 $previewCode = isset($_POST['_savedokview_x']) && $this->popViewId ? $this->generatePreviewCode() : '';
743
744 $this->doc->JScode = $this->doc->wrapScriptTags($javascript . $previewCode);
745 // Setting up the context sensitive menu:
746 $this->doc->getContextMenuCode();
747 $this->doc->bodyTagAdditions = 'onload="window.scrollTo(0,' . MathUtility::forceIntegerInRange(GeneralUtility::_GP('_scrollPosition'), 0, 10000) . ');"';
748
749 $this->emitFunctionAfterSignal(__FUNCTION__);
750 }
751
752 /**
753 * @return string
754 */
755 protected function generatePreviewCode() {
756 $currentPageId = MathUtility::convertToPositiveInteger($this->popViewId);
757 $table = $this->previewData['table'];
758 $recordId = $this->previewData['id'];
759
760 $pageTsConfig = BackendUtility::getPagesTSconfig($currentPageId);
761 $previewConfiguration = isset($pageTsConfig['TCEMAIN.']['preview.'][$table . '.'])
762 ? $pageTsConfig['TCEMAIN.']['preview.'][$table . '.']
763 : array();
764
765 $recordArray = BackendUtility::getRecord($table, $recordId);
766
767 // find the right preview page id
768 $previewPageId = 0;
769 if (isset($previewConfiguration['previewPageId'])) {
770 $previewPageId = $previewConfiguration['previewPageId'];
771 }
772 // if no preview page was configured
773 if (!$previewPageId) {
774 $rootPageData = NULL;
775 $rootLine = BackendUtility::BEgetRootLine($currentPageId);
776 $currentPage = reset($rootLine);
777 if ((int)$currentPage['doktype'] === PageRepository::DOKTYPE_DEFAULT) {
778 // try the current page
779 $previewPageId = $currentPageId;
780 } else {
781 // or search for the root page
782 foreach ($rootLine as $page) {
783 if ($page['is_siteroot']) {
784 $rootPageData = $page;
785 break;
786 }
787 }
788 $previewPageId = isset($rootPageData)
789 ? (int)$rootPageData['uid']
790 : $currentPageId;
791 }
792 }
793
794 $linkParameters = [
795 'no_cache' => 1,
796 ];
797
798 // language handling
799 $languageField = isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
800 ? $GLOBALS['TCA'][$table]['ctrl']['languageField']
801 : '';
802 if ($languageField && !empty($recordArray[$languageField])) {
803 $l18nPointer = isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
804 ? $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
805 : '';
806 if (
807 $l18nPointer && !empty($recordArray[$l18nPointer])
808 && isset($previewConfiguration['useDefaultLanguageRecord'])
809 && !$previewConfiguration['useDefaultLanguageRecord']
810 ) {
811 // use parent record
812 $recordId = $recordArray[$l18nPointer];
813 }
814 $linkParameters['L'] = $recordArray[$languageField];
815 }
816
817 // map record data to GET parameters
818 if (isset($previewConfiguration['fieldToParameterMap.'])) {
819 foreach ($previewConfiguration['fieldToParameterMap.'] as $field => $parameterName) {
820 $value = $recordArray[$field];
821 if ($field === 'uid') {
822 $value = $recordId;
823 }
824 $linkParameters[$parameterName] = $value;
825 }
826 }
827
828 // add/override parameters by configuration
829 if (isset($previewConfiguration['additionalGetParameters.'])) {
830 $linkParameters = array_replace($linkParameters, $previewConfiguration['additionalGetParameters.']);
831 }
832
833 $this->popViewId = $previewPageId;
834 $this->popViewId_addParams = GeneralUtility::implodeArrayForUrl('', $linkParameters, '', FALSE, TRUE);
835
836 $previewPageRootline = BackendUtility::BEgetRootLine($this->popViewId);
837 return '
838 if (window.opener) {
839 '
840 . BackendUtility::viewOnClick($this->popViewId, '', $previewPageRootline, '', $this->viewUrl, $this->popViewId_addParams, FALSE)
841 . '
842 } else {
843 '
844 . BackendUtility::viewOnClick($this->popViewId, '', $previewPageRootline, '', $this->viewUrl, $this->popViewId_addParams)
845 . '
846 }';
847 }
848
849 /**
850 * Main module operation
851 *
852 * @return void
853 */
854 public function main() {
855 $body = '';
856 // Begin edit:
857 if (is_array($this->editconf)) {
858 // Initialize TCEforms (rendering the forms)
859 $this->tceforms = GeneralUtility::makeInstance(FormEngine::class);
860 $this->tceforms->doSaveFieldName = 'doSave';
861 $this->tceforms->localizationMode = GeneralUtility::inList('text,media', $this->localizationMode) ? $this->localizationMode : '';
862 // text,media is keywords defined in TYPO3 Core API..., see "l10n_cat"
863 $this->tceforms->returnUrl = $this->R_URI;
864 if ($this->editRegularContentFromId) {
865 $this->editRegularContentFromId();
866 }
867 // Creating the editing form, wrap it with buttons, document selector etc.
868 $editForm = $this->makeEditForm();
869 if ($editForm) {
870 $this->firstEl = reset($this->elementsData);
871 // Checking if the currently open document is stored in the list of "open documents" - if not, then add it:
872 if (($this->docDat[1] !== $this->storeUrlMd5 || !isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef) {
873 $this->docHandler[$this->storeUrlMd5] = array($this->storeTitle, $this->storeArray, $this->storeUrl, $this->firstEl);
874 $this->getBackendUser()->pushModuleData('FormEngine', array($this->docHandler, $this->storeUrlMd5));
875 BackendUtility::setUpdateSignal('OpendocsController::updateNumber', count($this->docHandler));
876 }
877 // Module configuration
878 $this->modTSconfig = $this->viewId ? BackendUtility::getModTSconfig($this->viewId, 'mod.xMOD_alt_doc') : array();
879 $body = $this->tceforms->printNeededJSFunctions_top();
880 $body .= $this->compileForm($editForm);
881 $body .= $this->tceforms->printNeededJSFunctions();
882 }
883 }
884 // Access check...
885 // The page will show only if there is a valid page and if this page may be viewed by the user
886 $this->pageinfo = BackendUtility::readPageAccess($this->viewId, $this->perms_clause);
887 // Setting up the buttons and markers for docheader
888 $docHeaderButtons = $this->getButtons();
889 $markers = array(
890 'LANGSELECTOR' => $this->langSelector(),
891 'EXTRAHEADER' => $this->extraFormHeaders(),
892 'CSH' => $docHeaderButtons['csh'],
893 'CONTENT' => $body
894 );
895 // Build the <body> for the module
896 $this->content = $this->doc->startPage('TYPO3 Edit Document');
897 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
898 $this->content .= $this->doc->endPage();
899 $this->content = $this->doc->insertStylesAndJS($this->content);
900 }
901
902 /**
903 * Outputting the accumulated content to screen
904 *
905 * @return void
906 */
907 public function printContent() {
908 echo $this->content;
909 }
910
911 /***************************
912 *
913 * Sub-content functions, rendering specific parts of the module content.
914 *
915 ***************************/
916 /**
917 * Creates the editing form with TCEforms, based on the input from GPvars.
918 *
919 * @return string HTML form elements wrapped in tables
920 */
921 public function makeEditForm() {
922 // Initialize variables:
923 $this->elementsData = array();
924 $this->errorC = 0;
925 $this->newC = 0;
926 $thePrevUid = '';
927 $editForm = '';
928 $trData = NULL;
929 $beUser = $this->getBackendUser();
930 // Traverse the GPvar edit array
931 // Tables:
932 foreach ($this->editconf as $table => $conf) {
933 if (is_array($conf) && $GLOBALS['TCA'][$table] && $beUser->check('tables_modify', $table)) {
934 // Traverse the keys/comments of each table (keys can be a commalist of uids)
935 foreach ($conf as $cKey => $cmd) {
936 if ($cmd == 'edit' || $cmd == 'new') {
937 // Get the ids:
938 $ids = GeneralUtility::trimExplode(',', $cKey, TRUE);
939 // Traverse the ids:
940 foreach ($ids as $theUid) {
941 // Checking if the user has permissions? (Only working as a precaution,
942 // because the final permission check is always down in TCE. But it's
943 // good to notify the user on beforehand...)
944 // First, resetting flags.
945 $hasAccess = 1;
946 $deniedAccessReason = '';
947 $deleteAccess = 0;
948 $this->viewId = 0;
949 // If the command is to create a NEW record...:
950 if ($cmd == 'new') {
951 // NOTICE: the id values in this case points to the page uid onto which the
952 // record should be create OR (if the id is negativ) to a record from the
953 // same table AFTER which to create the record.
954 if ((int)$theUid) {
955 // Find parent page on which the new record reside
956 // Less than zero - find parent page
957 if ($theUid < 0) {
958 $calcPRec = BackendUtility::getRecord($table, abs($theUid));
959 $calcPRec = BackendUtility::getRecord('pages', $calcPRec['pid']);
960 } else {
961 // always a page
962 $calcPRec = BackendUtility::getRecord('pages', abs($theUid));
963 }
964 // Now, calculate whether the user has access to creating new records on this position:
965 if (is_array($calcPRec)) {
966 // Permissions for the parent page
967 $CALC_PERMS = $beUser->calcPerms($calcPRec);
968 if ($table == 'pages') {
969 // If pages:
970 $hasAccess = $CALC_PERMS & Permission::PAGE_NEW ? 1 : 0;
971 $this->viewId = 0;
972 } else {
973 $hasAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
974 $this->viewId = $calcPRec['uid'];
975 }
976 }
977 }
978 // Don't save this document title in the document selector if the document is new.
979 $this->dontStoreDocumentRef = 1;
980 } else {
981 // Edit:
982 $calcPRec = BackendUtility::getRecord($table, $theUid);
983 BackendUtility::fixVersioningPid($table, $calcPRec);
984 if (is_array($calcPRec)) {
985 if ($table == 'pages') { // If pages:
986 $CALC_PERMS = $beUser->calcPerms($calcPRec);
987 $hasAccess = $CALC_PERMS & Permission::PAGE_EDIT ? 1 : 0;
988 $deleteAccess = $CALC_PERMS & Permission::PAGE_DELETE ? 1 : 0;
989 $this->viewId = $calcPRec['uid'];
990 } else {
991 // Fetching pid-record first
992 $CALC_PERMS = $beUser->calcPerms(BackendUtility::getRecord('pages', $calcPRec['pid']));
993 $hasAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
994 $deleteAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
995 $this->viewId = $calcPRec['pid'];
996 // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
997 if ($GLOBALS['TCA'][$table]['ctrl']['languageField'] && $calcPRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
998 $this->viewId_addParams = '&L=' . $calcPRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']];
999 }
1000 }
1001 // Check internals regarding access:
1002 $isRootLevelRestrictionIgnored = BackendUtility::isRootLevelRestrictionIgnored($table);
1003 if ($hasAccess || (int)$calcPRec['pid'] === 0 && $isRootLevelRestrictionIgnored) {
1004 $hasAccess = $beUser->recordEditAccessInternals($table, $calcPRec);
1005 $deniedAccessReason = $beUser->errorMsg;
1006 }
1007 } else {
1008 $hasAccess = 0;
1009 }
1010 }
1011 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['makeEditForm_accessCheck'])) {
1012 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['makeEditForm_accessCheck'] as $_funcRef) {
1013 $_params = array(
1014 'table' => $table,
1015 'uid' => $theUid,
1016 'cmd' => $cmd,
1017 'hasAccess' => $hasAccess
1018 );
1019 $hasAccess = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1020 }
1021 }
1022 // AT THIS POINT we have checked the access status of the editing/creation of
1023 // records and we can now proceed with creating the form elements:
1024 if ($hasAccess) {
1025 /** @var DataPreprocessor $trData */
1026 $prevPageID = is_object($trData) ? $trData->prevPageID : '';
1027 $trData = GeneralUtility::makeInstance(DataPreprocessor::class);
1028 $trData->addRawData = TRUE;
1029 $trData->defVals = $this->defVals;
1030 $trData->lockRecords = 1;
1031 $trData->prevPageID = $prevPageID;
1032 // 'new'
1033 $trData->fetchRecord($table, $theUid, $cmd == 'new' ? 'new' : '');
1034 $rec = reset($trData->regTableItems_data);
1035 $rec['uid'] = $cmd == 'new' ? uniqid('NEW', TRUE) : $theUid;
1036 if ($cmd == 'new') {
1037 $rec['pid'] = $theUid == 'prev' ? $thePrevUid : $theUid;
1038 }
1039 $this->elementsData[] = array(
1040 'table' => $table,
1041 'uid' => $rec['uid'],
1042 'pid' => $rec['pid'],
1043 'cmd' => $cmd,
1044 'deleteAccess' => $deleteAccess
1045 );
1046 // Now, render the form:
1047 if (is_array($rec)) {
1048 // Setting visual path / title of form:
1049 $this->generalPathOfForm = $this->tceforms->getRecordPath($table, $rec);
1050 if (!$this->storeTitle) {
1051 $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : BackendUtility::getRecordTitle($table, $rec, TRUE);
1052 }
1053 // Setting variables in TCEforms object:
1054 if (is_array($this->overrideVals) && is_array($this->overrideVals[$table])) {
1055 $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]);
1056 }
1057 // Create form for the record (either specific list of fields or the whole record):
1058 $panel = '';
1059 if ($this->columnsOnly) {
1060 if (is_array($this->columnsOnly)) {
1061 $panel .= $this->tceforms->getListedFields($table, $rec, $this->columnsOnly[$table]);
1062 } else {
1063 $panel .= $this->tceforms->getListedFields($table, $rec, $this->columnsOnly);
1064 }
1065 } else {
1066 $panel .= $this->tceforms->getMainFields($table, $rec);
1067 }
1068 $panel = $this->tceforms->wrapTotal($panel, $rec, $table);
1069 // Setting the pid value for new records:
1070 if ($cmd == 'new') {
1071 $panel .= '<input type="hidden" name="data[' . $table . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
1072 $this->newC++;
1073 }
1074 // Display "is-locked" message:
1075 if ($lockInfo = BackendUtility::isRecordLocked($table, $rec['uid'])) {
1076 /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
1077 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($lockInfo['msg']), '', FlashMessage::WARNING);
1078 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
1079 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
1080 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
1081 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1082 $defaultFlashMessageQueue->enqueue($flashMessage);
1083 }
1084 // Combine it all:
1085 $editForm .= $panel;
1086 }
1087 $thePrevUid = $rec['uid'];
1088 } else {
1089 $this->errorC++;
1090 $editForm .= $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noEditPermission', TRUE) . '<br /><br />' . ($deniedAccessReason ? 'Reason: ' . htmlspecialchars($deniedAccessReason) . '<br /><br />' : '');
1091 }
1092 }
1093 }
1094 }
1095 }
1096 }
1097 return $editForm;
1098 }
1099
1100 /**
1101 * Create the panel of buttons for submitting the form or otherwise perform operations.
1102 *
1103 * @return array All available buttons as an assoc. array
1104 */
1105 protected function getButtons() {
1106 $lang = $this->getLanguageService();
1107 $buttons = array(
1108 'save' => '',
1109 'save_view' => '',
1110 'save_new' => '',
1111 'save_close' => '',
1112 'close' => '',
1113 'delete' => '',
1114 'undo' => '',
1115 'history' => '',
1116 'columns_only' => '',
1117 'csh' => '',
1118 'translation_save' => '',
1119 'translation_saveclear' => ''
1120 );
1121 // Render SAVE type buttons:
1122 // The action of each button is decided by its name attribute. (See doProcessData())
1123 if (!$this->errorC && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly']) {
1124 // SAVE button:
1125 $buttons['save'] = IconUtility::getSpriteIcon('actions-document-save', array('html' => '<input type="image" name="_savedok" class="c-inputButton" src="clear.gif" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" />'));
1126 // SAVE / VIEW button:
1127 if ($this->viewId && !$this->noView && $this->getNewIconMode($this->firstEl['table'], 'saveDocView')) {
1128 $buttons['save_view'] = IconUtility::getSpriteIcon('actions-document-save-view', array('html' => '<input onclick="window.open(\'\', \'newTYPO3frontendWindow\');" type="image" class="c-inputButton" name="_savedokview" src="clear.gif" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDocShow', TRUE) . '" />'));
1129 }
1130 // SAVE / NEW button:
1131 if (count($this->elementsData) === 1 && $this->getNewIconMode($this->firstEl['table'])) {
1132 $buttons['save_new'] = IconUtility::getSpriteIcon('actions-document-save-new', array('html' => '<input type="image" class="c-inputButton" name="_savedoknew" src="clear.gif" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveNewDoc', TRUE) . '" />'));
1133 }
1134 // SAVE / CLOSE
1135 $buttons['save_close'] = IconUtility::getSpriteIcon('actions-document-save-close', array('html' => '<input type="image" class="c-inputButton" name="_saveandclosedok" src="clear.gif" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '" />'));
1136 // FINISH TRANSLATION / SAVE / CLOSE
1137 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['explicitConfirmationOfTranslation']) {
1138 $buttons['translation_save'] = '<input type="image" class="c-inputButton" name="_translation_savedok" src="' . IconUtility::skinImg($this->doc->backPath, 'sysext/t3skin/images/icons/actions/document-save-translation.png', '', 1) . '" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.translationSaveDoc', TRUE) . '" /> ';
1139 $buttons['translation_saveclear'] = '<input type="image" class="c-inputButton" name="_translation_savedokclear" src="' . IconUtility::skinImg($this->doc->backPath, 'sysext/t3skin/images/icons/actions/document-save-cleartranslationcache.png', '', 1) . '" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.translationSaveDocClear', TRUE) . '" />';
1140 }
1141 }
1142 // CLOSE button:
1143 $buttons['close'] = '<a href="#" class="t3js-editform-close" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-close') . '</a>';
1144 // DELETE + UNDO buttons:
1145 if (!$this->errorC && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData) === 1) {
1146 if ($this->firstEl['cmd'] != 'new' && MathUtility::canBeInterpretedAsInteger($this->firstEl['uid'])) {
1147 // Delete:
1148 if ($this->firstEl['deleteAccess'] && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'], 'disableDelete')) {
1149 $aOnClick = 'return deleteRecord(' . GeneralUtility::quoteJSvalue($this->firstEl['table']) . ',' . GeneralUtility::quoteJSvalue($this->firstEl['uid']) . ', ' . GeneralUtility::quoteJSvalue($this->retUrl) . ');';
1150 $buttons['delete'] = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '" title="' . $lang->getLL('deleteItem', TRUE) . '">' . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
1151 }
1152 // Undo:
1153 $undoRes = $this->getDatabaseConnection()->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $this->getDatabaseConnection()->fullQuoteStr($this->firstEl['table'], 'sys_history') . ' AND recuid=' . (int)$this->firstEl['uid'], '', 'tstamp DESC', '1');
1154 if ($undoButtonR = $this->getDatabaseConnection()->sql_fetch_assoc($undoRes)) {
1155 $aOnClick = 'window.location.href=' .
1156 GeneralUtility::quoteJSvalue(
1157 BackendUtility::getModuleUrl(
1158 'record_history',
1159 array(
1160 'element' => $this->firstEl['table'] . ':' . $this->firstEl['uid'],
1161 'revert' => 'ALL_FIELDS',
1162 'sumUp' => -1,
1163 'returnUrl' => $this->R_URI,
1164 )
1165 )
1166 ) . '; return false;';
1167 $buttons['undo'] = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '"' . ' title="' . htmlspecialchars(sprintf($lang->getLL('undoLastChange'), BackendUtility::calcAge(($GLOBALS['EXEC_TIME'] - $undoButtonR['tstamp']), $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears')))) . '">' . IconUtility::getSpriteIcon('actions-edit-undo') . '</a>';
1168 }
1169 if ($this->getNewIconMode($this->firstEl['table'], 'showHistory')) {
1170 $aOnClick = 'window.location.href=' .
1171 GeneralUtility::quoteJSvalue(
1172 BackendUtility::getModuleUrl(
1173 'record_history',
1174 array(
1175 'element' => $this->firstEl['table'] . ':' . $this->firstEl['uid'],
1176 'returnUrl' => $this->R_URI,
1177 )
1178 )
1179 ) . '; return false;';
1180 $buttons['history'] = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . IconUtility::getSpriteIcon('actions-document-history-open') . '</a>';
1181 }
1182 // If only SOME fields are shown in the form, this will link the user to the FULL form:
1183 if ($this->columnsOnly) {
1184 $buttons['columns_only'] = '<a href="' . htmlspecialchars(($this->R_URI . '&columnsOnly=')) . '" title="' . $lang->getLL('editWholeRecord', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
1185 }
1186 }
1187 }
1188 // add the CSH icon
1189 $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'TCEforms');
1190 $buttons['shortcut'] = $this->shortCutLink();
1191 $buttons['open_in_new_window'] = $this->openInNewWindowLink();
1192 return $buttons;
1193 }
1194
1195 /**
1196 * Returns the language switch/selector for editing,
1197 * show only when a single record is edited
1198 * - multiple records are too confusing
1199 *
1200 * @return string The HTML
1201 */
1202 public function langSelector() {
1203 $langSelector = '';
1204 if (count($this->elementsData) === 1) {
1205 $langSelector = $this->languageSwitch($this->firstEl['table'], $this->firstEl['uid'], $this->firstEl['pid']);
1206 }
1207 return $langSelector;
1208 }
1209
1210 /**
1211 * Compiles the extra form headers if the tceforms
1212 *
1213 * @return string The HTML
1214 */
1215 public function extraFormHeaders() {
1216 $extraTemplate = '';
1217 if (is_array($this->tceforms->extraFormHeaders)) {
1218 $extraTemplate = HtmlParser::getSubpart($this->doc->moduleTemplate, '###DOCHEADER_EXTRAHEADER###');
1219 $extraTemplate = HtmlParser::substituteMarker($extraTemplate, '###EXTRAHEADER###', implode(LF, $this->tceforms->extraFormHeaders));
1220 }
1221 return $extraTemplate;
1222 }
1223
1224 /**
1225 * Put together the various elements (buttons, selectors, form) into a table
1226 *
1227 * @param string $editForm HTML form.
1228 * @return string Composite HTML
1229 */
1230 public function compileForm($editForm) {
1231 $formContent = '
1232 <!-- EDITING FORM -->
1233 ' . $editForm . '
1234
1235 <input type="hidden" name="returnUrl" value="' . htmlspecialchars($this->retUrl) . '" />
1236 <input type="hidden" name="viewUrl" value="' . htmlspecialchars($this->viewUrl) . '" />';
1237 if ($this->returnNewPageId) {
1238 $formContent .= '<input type="hidden" name="returnNewPageId" value="1" />';
1239 }
1240 $formContent .= '<input type="hidden" name="popViewId" value="' . htmlspecialchars($this->viewId) . '" />';
1241 if ($this->viewId_addParams) {
1242 $formContent .= '<input type="hidden" name="popViewId_addParams" value="' . htmlspecialchars($this->viewId_addParams) . '" />';
1243 }
1244 $formContent .= '
1245 <input type="hidden" name="closeDoc" value="0" />
1246 <input type="hidden" name="doSave" value="0" />
1247 <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
1248 <input type="hidden" name="_scrollPosition" value="" />' . FormEngine::getHiddenTokenField('editRecord');
1249 return $formContent;
1250 }
1251
1252 /**
1253 * Create shortcut icon
1254 *
1255 * @return string
1256 */
1257 public function shortCutLink() {
1258 if ($this->returnUrl == 'close.html' || !$this->getBackendUser()->mayMakeShortcut()) {
1259 return '';
1260 }
1261 return $this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,noView', '', $this->MCONF['name'], 1);
1262 }
1263
1264 /**
1265 * Creates open-in-window link
1266 *
1267 * @return string
1268 */
1269 public function openInNewWindowLink() {
1270 if ($this->returnUrl == 'close.html') {
1271 return '';
1272 }
1273 $aOnClick = 'vHWin=window.open(' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript(array('returnUrl' => 'close.html'))) . ',' . GeneralUtility::quoteJSvalue(md5($this->R_URI)) . ',\'width=670,height=500,status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;';
1274 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.openInNewWindow', TRUE) . '">' . IconUtility::getSpriteIcon('actions-window-open') . '</a>';
1275 }
1276
1277 /***************************
1278 *
1279 * Localization stuff
1280 *
1281 ***************************/
1282 /**
1283 * Make selector box for creating new translation for a record or switching to edit the record in an existing language.
1284 * Displays only languages which are available for the current page.
1285 *
1286 * @param string $table Table name
1287 * @param int $uid Uid for which to create a new language
1288 * @param int $pid Pid of the record
1289 * @return string <select> HTML element (if there were items for the box anyways...)
1290 */
1291 public function languageSwitch($table, $uid, $pid = NULL) {
1292 $content = '';
1293 $languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
1294 $transOrigPointerField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
1295 // Table editable and activated for languages?
1296 if ($this->getBackendUser()->check('tables_modify', $table) && $languageField && $transOrigPointerField && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable']) {
1297 if (is_null($pid)) {
1298 $row = BackendUtility::getRecord($table, $uid, 'pid');
1299 $pid = $row['pid'];
1300 }
1301 // Get all avalibale languages for the page
1302 $langRows = $this->getLanguages($pid);
1303 // Page available in other languages than default language?
1304 if (is_array($langRows) && count($langRows) > 1) {
1305 $rowsByLang = array();
1306 $fetchFields = 'uid,' . $languageField . ',' . $transOrigPointerField;
1307 // Get record in current language
1308 $rowCurrent = BackendUtility::getLiveVersionOfRecord($table, $uid, $fetchFields);
1309 if (!is_array($rowCurrent)) {
1310 $rowCurrent = BackendUtility::getRecord($table, $uid, $fetchFields);
1311 }
1312 $currentLanguage = $rowCurrent[$languageField];
1313 // Disabled for records with [all] language!
1314 if ($currentLanguage > -1) {
1315 // Get record in default language if needed
1316 if ($currentLanguage && $rowCurrent[$transOrigPointerField]) {
1317 $rowsByLang[0] = BackendUtility::getLiveVersionOfRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
1318 if (!is_array($rowsByLang[0])) {
1319 $rowsByLang[0] = BackendUtility::getRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
1320 }
1321 } else {
1322 $rowsByLang[$rowCurrent[$languageField]] = $rowCurrent;
1323 }
1324 if ($rowCurrent[$transOrigPointerField] || $currentLanguage === '0') {
1325 // Get record in other languages to see what's already available
1326 $translations = $this->getDatabaseConnection()->exec_SELECTgetRows($fetchFields, $table, 'pid=' . (int)$pid . ' AND ' . $languageField . '>0' . ' AND ' . $transOrigPointerField . '=' . (int)$rowsByLang[0]['uid'] . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table));
1327 foreach ($translations as $row) {
1328 $rowsByLang[$row[$languageField]] = $row;
1329 }
1330 }
1331 $langSelItems = array();
1332 foreach ($langRows as $lang) {
1333 if ($this->getBackendUser()->checkLanguageAccess($lang['uid'])) {
1334 $newTranslation = isset($rowsByLang[$lang['uid']]) ? '' : ' [' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.new', TRUE) . ']';
1335 // Create url for creating a localized record
1336 if ($newTranslation) {
1337 $redirectUrl = BackendUtility::getModuleUrl('record_edit', array(
1338 'justLocalized' => $table . ':' . $rowsByLang[0]['uid'] . ':' . $lang['uid'],
1339 'returnUrl' => $this->retUrl
1340 )) . BackendUtility::getUrlToken('editRecord');
1341 $href = $this->doc->issueCommand('&cmd[' . $table . '][' . $rowsByLang[0]['uid'] . '][localize]=' . $lang['uid'], $redirectUrl);
1342 } else {
1343 $href = BackendUtility::getModuleUrl('record_edit', array(
1344 'edit[' . $table . '][' . $rowsByLang[$lang['uid']]['uid'] . ']' => 'edit',
1345 'returnUrl' => $this->retUrl
1346 )) . BackendUtility::getUrlToken('editRecord');
1347 }
1348 $langSelItems[$lang['uid']] = '
1349 <option value="' . htmlspecialchars($href) . '"' . ($currentLanguage == $lang['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars(($lang['title'] . $newTranslation)) . '</option>';
1350 }
1351 }
1352 // If any languages are left, make selector:
1353 if (count($langSelItems) > 1) {
1354 $onChange = 'if(this.options[this.selectedIndex].value){window.location.href=(this.options[this.selectedIndex].value);}';
1355 $content = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_general.xlf:LGL.language', TRUE) . ' <select name="_langSelector" onchange="' . htmlspecialchars($onChange) . '">
1356 ' . implode('', $langSelItems) . '
1357 </select>';
1358 }
1359 }
1360 }
1361 }
1362 return $content;
1363 }
1364
1365 /**
1366 * Redirects to FormEngine with new parameters to edit a just created localized record
1367 *
1368 * @param string $justLocalized String passed by GET &justLocalized=
1369 * @return void
1370 */
1371 public function localizationRedirect($justLocalized) {
1372 list($table, $orig_uid, $language) = explode(':', $justLocalized);
1373 if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) {
1374 $localizedRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid', $table, $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . (int)$language . ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . (int)$orig_uid . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table));
1375 if (is_array($localizedRecord)) {
1376 // Create parameters and finally run the classic page module for creating a new page translation
1377 $location = BackendUtility::getModuleUrl('record_edit', array(
1378 'edit[' . $table . '][' . $localizedRecord['uid'] . ']' => 'edit',
1379 'returnUrl' => GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'))
1380 ));
1381 HttpUtility::redirect($location . BackendUtility::getUrlToken('editRecord'));
1382 }
1383 }
1384 }
1385
1386 /**
1387 * Returns sys_language records available for record translations on given page.
1388 *
1389 * @param int $id Page id: If zero, the query will select all sys_language records from root level which are NOT hidden. If set to another value, the query will select all sys_language records that has a pages_language_overlay record on that page (and is not hidden, unless you are admin user)
1390 * @return array Language records including faked record for default language
1391 */
1392 public function getLanguages($id) {
1393 $modSharedTSconfig = BackendUtility::getModTSconfig($id, 'mod.SHARED');
1394 // Fallback non sprite-configuration
1395 if (preg_match('/\\.gif$/', $modSharedTSconfig['properties']['defaultLanguageFlag'])) {
1396 $modSharedTSconfig['properties']['defaultLanguageFlag'] = str_replace('.gif', '', $modSharedTSconfig['properties']['defaultLanguageFlag']);
1397 }
1398 $languages = array(
1399 0 => array(
1400 'uid' => 0,
1401 'pid' => 0,
1402 'hidden' => 0,
1403 'title' => $modSharedTSconfig['properties']['defaultLanguageLabel'] !== ''
1404 ? $modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $this->getLanguageService()->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage') . ')'
1405 : $this->getLanguageService()->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage'),
1406 'flag' => $modSharedTSconfig['properties']['defaultLanguageFlag']
1407 )
1408 );
1409 $exQ = $this->getBackendUser()->isAdmin() ? '' : ' AND sys_language.hidden=0';
1410 if ($id) {
1411 $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('sys_language.*', 'pages_language_overlay,sys_language', 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid=' . (int)$id . BackendUtility::deleteClause('pages_language_overlay') . $exQ, 'pages_language_overlay.sys_language_uid,sys_language.uid,sys_language.pid,sys_language.tstamp,sys_language.hidden,sys_language.title,sys_language.language_isocode,sys_language.static_lang_isocode,sys_language.flag', 'sys_language.title');
1412 } else {
1413 $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('sys_language.*', 'sys_language', 'sys_language.hidden=0', '', 'sys_language.title');
1414 }
1415 if ($rows) {
1416 foreach ($rows as $row) {
1417 $languages[$row['uid']] = $row;
1418 }
1419 }
1420 return $languages;
1421 }
1422
1423 /***************************
1424 *
1425 * Other functions
1426 *
1427 ***************************/
1428 /**
1429 * Fix $this->editconf if versioning applies to any of the records
1430 *
1431 * @param array|bool $mapArray Mapping between old and new ids if auto-versioning has been performed.
1432 * @return void
1433 */
1434 public function fixWSversioningInEditConf($mapArray = FALSE) {
1435 // Traverse the editConf array
1436 if (is_array($this->editconf)) {
1437 // Tables:
1438 foreach ($this->editconf as $table => $conf) {
1439 if (is_array($conf) && $GLOBALS['TCA'][$table]) {
1440 // Traverse the keys/comments of each table (keys can be a commalist of uids)
1441 $newConf = array();
1442 foreach ($conf as $cKey => $cmd) {
1443 if ($cmd == 'edit') {
1444 // Traverse the ids:
1445 $ids = GeneralUtility::trimExplode(',', $cKey, TRUE);
1446 foreach ($ids as $idKey => $theUid) {
1447 if (is_array($mapArray)) {
1448 if ($mapArray[$table][$theUid]) {
1449 $ids[$idKey] = $mapArray[$table][$theUid];
1450 }
1451 } else {
1452 // Default, look for versions in workspace for record:
1453 $calcPRec = $this->getRecordForEdit($table, $theUid);
1454 if (is_array($calcPRec)) {
1455 // Setting UID again if it had changed, eg. due to workspace versioning.
1456 $ids[$idKey] = $calcPRec['uid'];
1457 }
1458 }
1459 }
1460 // Add the possibly manipulated IDs to the new-build newConf array:
1461 $newConf[implode(',', $ids)] = $cmd;
1462 } else {
1463 $newConf[$cKey] = $cmd;
1464 }
1465 }
1466 // Store the new conf array:
1467 $this->editconf[$table] = $newConf;
1468 }
1469 }
1470 }
1471 }
1472
1473 /**
1474 * Get record for editing.
1475 *
1476 * @param string $table Table name
1477 * @param int $theUid Record UID
1478 * @return array Returns record to edit, FALSE if none
1479 */
1480 public function getRecordForEdit($table, $theUid) {
1481 // Fetch requested record:
1482 $reqRecord = BackendUtility::getRecord($table, $theUid, 'uid,pid');
1483 if (is_array($reqRecord)) {
1484 // If workspace is OFFLINE:
1485 if ($this->getBackendUser()->workspace != 0) {
1486 // Check for versioning support of the table:
1487 if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
1488 // If the record is already a version of "something" pass it by.
1489 if ($reqRecord['pid'] == -1) {
1490 // (If it turns out not to be a version of the current workspace there will be trouble, but that is handled inside TCEmain then and in the interface it would clearly be an error of links if the user accesses such a scenario)
1491 return $reqRecord;
1492 } else {
1493 // The input record was online and an offline version must be found or made:
1494 // Look for version of this workspace:
1495 $versionRec = BackendUtility::getWorkspaceVersionOfRecord($this->getBackendUser()->workspace, $table, $reqRecord['uid'], 'uid,pid,t3ver_oid');
1496 return is_array($versionRec) ? $versionRec : $reqRecord;
1497 }
1498 } else {
1499 // This means that editing cannot occur on this record because it was not supporting versioning which is required inside an offline workspace.
1500 return FALSE;
1501 }
1502 } else {
1503 // In ONLINE workspace, just return the originally requested record:
1504 return $reqRecord;
1505 }
1506 } else {
1507 // Return FALSE because the table/uid was not found anyway.
1508 return FALSE;
1509 }
1510 }
1511
1512 /**
1513 * Function, which populates the internal editconf array with editing commands for all tt_content elements from the normal column in normal language from the page pointed to by $this->editRegularContentFromId
1514 *
1515 * @return void
1516 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8
1517 */
1518 public function editRegularContentFromId() {
1519 GeneralUtility::logDeprecatedFunction();
1520 $dbConnection = $this->getDatabaseConnection();
1521 $res = $dbConnection->exec_SELECTquery('uid', 'tt_content', 'pid=' . (int)$this->editRegularContentFromId . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content') . ' AND colPos=0 AND sys_language_uid=0', '', 'sorting');
1522 if ($dbConnection->sql_num_rows($res)) {
1523 $ecUids = array();
1524 while ($ecRec = $dbConnection->sql_fetch_assoc($res)) {
1525 $ecUids[] = $ecRec['uid'];
1526 }
1527 $this->editconf['tt_content'][implode(',', $ecUids)] = 'edit';
1528 }
1529 $dbConnection->sql_free_result($res);
1530 }
1531
1532 /**
1533 * Populates the variables $this->storeArray, $this->storeUrl, $this->storeUrlMd5
1534 *
1535 * @return void
1536 * @see makeDocSel()
1537 */
1538 public function compileStoreDat() {
1539 $this->storeArray = GeneralUtility::compileSelectedGetVarsFromArray('edit,defVals,overrideVals,columnsOnly,noView,editRegularContentFromId,workspace', $this->R_URL_getvars);
1540 $this->storeUrl = GeneralUtility::implodeArrayForUrl('', $this->storeArray);
1541 $this->storeUrlMd5 = md5($this->storeUrl);
1542 }
1543
1544 /**
1545 * Function used to look for configuration of buttons in the form: Fx. disabling buttons or showing them at various positions.
1546 *
1547 * @param string $table The table for which the configuration may be specific
1548 * @param string $key The option for look for. Default is checking if the saveDocNew button should be displayed.
1549 * @return string Return value fetched from USER TSconfig
1550 */
1551 public function getNewIconMode($table, $key = 'saveDocNew') {
1552 $TSconfig = $this->getBackendUser()->getTSConfig('options.' . $key);
1553 $output = trim(isset($TSconfig['properties'][$table]) ? $TSconfig['properties'][$table] : $TSconfig['value']);
1554 return $output;
1555 }
1556
1557 /**
1558 * Handling the closing of a document
1559 *
1560 * @param int $code Close code: 0/1 will redirect to $this->retUrl, 3 will clear the docHandler (thus closing all documents) and other values will call setDocument with ->retUrl
1561 * @return void
1562 */
1563 public function closeDocument($code = 0) {
1564 // If current document is found in docHandler,
1565 // then unset it, possibly unset it ALL and finally, write it to the session data
1566 if (isset($this->docHandler[$this->storeUrlMd5])) {
1567 // add the closing document to the recent documents
1568 $recentDocs = $this->getBackendUser()->getModuleData('opendocs::recent');
1569 if (!is_array($recentDocs)) {
1570 $recentDocs = array();
1571 }
1572 $closedDoc = $this->docHandler[$this->storeUrlMd5];
1573 $recentDocs = array_merge(array($this->storeUrlMd5 => $closedDoc), $recentDocs);
1574 if (count($recentDocs) > 8) {
1575 $recentDocs = array_slice($recentDocs, 0, 8);
1576 }
1577 // remove it from the list of the open documents
1578 unset($this->docHandler[$this->storeUrlMd5]);
1579 if ($code == '3') {
1580 $recentDocs = array_merge($this->docHandler, $recentDocs);
1581 $this->docHandler = array();
1582 }
1583 $this->getBackendUser()->pushModuleData('opendocs::recent', $recentDocs);
1584 $this->getBackendUser()->pushModuleData('FormEngine', array($this->docHandler, $this->docDat[1]));
1585 BackendUtility::setUpdateSignal('OpendocsController::updateNumber', count($this->docHandler));
1586 }
1587 // If ->returnEditConf is set, then add the current content of editconf to the ->retUrl variable: (used by other scripts, like wizard_add, to know which records was created or so...)
1588 if ($this->returnEditConf && $this->retUrl != BackendUtility::getModuleUrl('dummy')) {
1589 $this->retUrl .= '&returnEditConf=' . rawurlencode(json_encode($this->editconf));
1590 }
1591 // If code is NOT set OR set to 1, then make a header location redirect to $this->retUrl
1592 if (!$code || $code == 1) {
1593 HttpUtility::redirect($this->retUrl);
1594 } else {
1595 $this->setDocument('', $this->retUrl);
1596 }
1597 }
1598
1599 /**
1600 * Redirects to the document pointed to by $currentDocFromHandlerMD5 OR $retUrl (depending on some internal calculations).
1601 * Most likely you will get a header-location redirect from this function.
1602 *
1603 * @param string $currentDocFromHandlerMD5 Pointer to the document in the docHandler array
1604 * @param string $retUrl Alternative/Default retUrl
1605 * @return void
1606 */
1607 public function setDocument($currentDocFromHandlerMD5 = '', $retUrl = '') {
1608 if ($retUrl === '') {
1609 return;
1610 }
1611 if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && !empty($this->docHandler)) {
1612 if (isset($this->docHandler[$currentDocFromHandlerMD5])) {
1613 $setupArr = $this->docHandler[$currentDocFromHandlerMD5];
1614 } else {
1615 $setupArr = reset($this->docHandler);
1616 }
1617 if ($setupArr[2]) {
1618 $sParts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
1619 $retUrl = $sParts['path'] . '?' . $setupArr[2] . '&returnUrl=' . rawurlencode($retUrl);
1620 }
1621 }
1622 HttpUtility::redirect($retUrl);
1623 }
1624
1625 /**
1626 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
1627 */
1628 protected function getBackendUser() {
1629 return $GLOBALS['BE_USER'];
1630 }
1631
1632 /**
1633 * Returns LanguageService
1634 *
1635 * @return \TYPO3\CMS\Lang\LanguageService
1636 */
1637 protected function getLanguageService() {
1638 return $GLOBALS['LANG'];
1639 }
1640
1641 /**
1642 * Returns the database connection
1643 *
1644 * @return \TYPO3\CMS\Core\Database\DatabaseConnection
1645 */
1646 protected function getDatabaseConnection() {
1647 return $GLOBALS['TYPO3_DB'];
1648 }
1649
1650 }