-
Notifications
You must be signed in to change notification settings - Fork 646
/
PageLayoutView.php
4401 lines (4137 loc) · 188 KB
/
PageLayoutView.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
namespace TYPO3\CMS\Backend\View;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Doctrine\DBAL\Driver\Statement;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Backend\Controller\Page\LocalizationController;
use TYPO3\CMS\Backend\Controller\PageLayoutController;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Tree\View\PageTreeView;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\ReferenceIndex;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Routing\SiteMatcher;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
use TYPO3\CMS\Core\Versioning\VersionState;
use TYPO3\CMS\Fluid\View\StandaloneView;
/**
* Child class for the Web > Page module
* @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API.
*/
class PageLayoutView implements LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* If TRUE, users/groups are shown in the page info box.
*
* @var bool
*/
public $pI_showUser = false;
/**
* The number of successive records to edit when showing content elements.
*
* @var int
*/
public $nextThree = 3;
/**
* If TRUE, disables the edit-column icon for tt_content elements
*
* @var bool
*/
public $pages_noEditColumns = false;
/**
* If TRUE, new-wizards are linked to rather than the regular new-element list.
*
* @var bool
*/
public $option_newWizard = true;
/**
* If set to "1", will link a big button to content element wizard.
*
* @var int
*/
public $ext_function = 0;
/**
* If TRUE, elements will have edit icons (probably this is whether the user has permission to edit the page content). Set externally.
*
* @var bool
*/
public $doEdit = true;
/**
* Age prefixes for displaying times. May be set externally to localized values.
*
* @var string
*/
public $agePrefixes = ' min| hrs| days| yrs| min| hour| day| year';
/**
* Array of tables to be listed by the Web > Page module in addition to the default tables.
*
* @var array
*/
public $externalTables = [];
/**
* "Pseudo" Description -table name
*
* @var string
*/
public $descrTable;
/**
* If set TRUE, the language mode of tt_content elements will be rendered with hard binding between
* default language content elements and their translations!
*
* @var bool
*/
public $defLangBinding = false;
/**
* External, static: Configuration of tt_content element display:
*
* @var array
*/
public $tt_contentConfig = [
// Boolean: Display info-marks or not
'showInfo' => 1,
// Boolean: Display up/down arrows and edit icons for tt_content records
'showCommands' => 1,
'languageCols' => 0,
'languageMode' => 0,
'languageColsPointer' => 0,
'showHidden' => 1,
// Displays hidden records as well
'sys_language_uid' => 0,
// Which language
'cols' => '1,0,2,3',
'activeCols' => '1,0,2,3'
// Which columns can be accessed by current BE user
];
/**
* Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function )
*
* @var array
*/
public $activeTables = [];
/**
* @var array
*/
public $tt_contentData = [
'nextThree' => [],
'prev' => [],
'next' => []
];
/**
* Used to store labels for CTypes for tt_content elements
*
* @var array
*/
public $CType_labels = [];
/**
* Used to store labels for the various fields in tt_content elements
*
* @var array
*/
public $itemLabels = [];
/**
* Indicates if all available fields for a user should be selected or not.
*
* @var int
*/
public $allFields = 0;
/**
* Number of records to show
*
* @var int
*/
public $showLimit = 0;
/**
* Shared module configuration, used by localization features
*
* @var array
*/
public $modSharedTSconfig = [];
/**
* Tables which should not get listed
*
* @var string
*/
public $hideTables = '';
/**
* Containing which fields to display in extended mode
*
* @var string[]
*/
public $displayFields;
/**
* Tables which should not list their translations
*
* @var string
*/
public $hideTranslations = '';
/**
* If set, csvList is outputted.
*
* @var bool
*/
public $csvOutput = false;
/**
* Cache for record path
*
* @var mixed[]
*/
public $recPath_cache = [];
/**
* Field, to sort list by
*
* @var string
*/
public $sortField;
/**
* default Max items shown per table in "multi-table mode", may be overridden by tables.php
*
* @var int
*/
public $itemsLimitPerTable = 20;
/**
* Page select permissions
*
* @var string
*/
public $perms_clause = '';
/**
* Page id
*
* @var int
*/
public $id;
/**
* Return URL
*
* @var string
*/
public $returnUrl = '';
/**
* Tablename if single-table mode
*
* @var string
*/
public $table = '';
/**
* Some permissions...
*
* @var int
*/
public $calcPerms = 0;
/**
* Mode for what happens when a user clicks the title of a record.
*
* @var string
*/
public $clickTitleMode = '';
/**
* Levels to search down.
*
* @var int
*/
public $searchLevels = '';
/**
* "LIMIT " in SQL...
*
* @var int
*/
public $iLimit = 0;
/**
* Set to the total number of items for a table when selecting.
*
* @var string
*/
public $totalItems = '';
/**
* TSconfig which overwrites TCA-Settings
*
* @var mixed[][]
*/
public $tableTSconfigOverTCA = [];
/**
* Loaded with page record with version overlay if any.
*
* @var string[]
*/
public $pageRecord = [];
/**
* Used for tracking duplicate values of fields
*
* @var string[]
*/
public $duplicateStack = [];
/**
* Fields to display for the current table
*
* @var string[]
*/
public $setFields = [];
/**
* Current script name
*
* @var string
*/
public $script = 'index.php';
/**
* If TRUE, records are listed only if a specific table is selected.
*
* @var bool
*/
public $listOnlyInSingleTableMode = false;
/**
* JavaScript code accumulation
*
* @var string
*/
public $JScode = '';
/**
* Pointer for browsing list
*
* @var int
*/
public $firstElementNumber = 0;
/**
* Counting the elements no matter what...
*
* @var int
*/
public $eCounter = 0;
/**
* Search string
*
* @var string
*/
public $searchString = '';
/**
* default Max items shown per table in "single-table mode", may be overridden by tables.php
*
* @var int
*/
public $itemsLimitSingleTable = 100;
/**
* Field, indicating to sort in reverse order.
*
* @var bool
*/
public $sortRev;
/**
* String, can contain the field name from a table which must have duplicate values marked.
*
* @var string
*/
public $duplicateField;
/**
* Specify a list of tables which are the only ones allowed to be displayed.
*
* @var string
*/
public $tableList = '';
/**
* Array of collapsed / uncollapsed tables in multi table view
*
* @var int[][]
*/
public $tablesCollapsed = [];
/**
* @var array[] Module configuration
*/
public $modTSconfig;
/**
* HTML output
*
* @var string
*/
public $HTMLcode = '';
/**
* Thumbnails on records containing files (pictures)
*
* @var bool
*/
public $thumbs = 0;
/**
* Used for tracking next/prev uids
*
* @var int[][]
*/
public $currentTable = [];
/**
* OBSOLETE - NOT USED ANYMORE. leftMargin
*
* @var int
*/
public $leftMargin = 0;
/**
* Decides the columns shown. Filled with values that refers to the keys of the data-array. $this->fieldArray[0] is the title column.
*
* @var array
*/
public $fieldArray = [];
/**
* Set to zero, if you don't want a left-margin with addElement function
*
* @var int
*/
public $setLMargin = 1;
/**
* Contains page translation languages
*
* @var array
*/
public $pageOverlays = [];
/**
* Counter increased for each element. Used to index elements for the JavaScript-code that transfers to the clipboard
*
* @var int
*/
public $counter = 0;
/**
* Contains site languages for this page ID
*
* @var SiteLanguage[]
*/
protected $siteLanguages = [];
/**
* Script URL
*
* @var string
*/
public $thisScript = '';
/**
* If set this is <td> CSS-classname for odd columns in addElement. Used with db_layout / pages section
*
* @var string
*/
public $oddColumnsCssClass = '';
/**
* Not used in this class - but maybe extension classes...
* Max length of strings
*
* @var int
*/
public $fixedL = 30;
/**
* Keys are fieldnames and values are td-parameters to add in addElement(), please use $addElement_tdCSSClass for CSS-classes;
*
* @var array
*/
public $addElement_tdParams = [];
/**
* @var int
*/
public $no_noWrap = 0;
/**
* @var int
*/
public $showIcon = 1;
/**
* Keys are fieldnames and values are td-css-classes to add in addElement();
*
* @var array
*/
public $addElement_tdCssClass = [];
/**
* @var \TYPO3\CMS\Backend\Clipboard\Clipboard
*/
protected $clipboard;
/**
* User permissions
*
* @var int
*/
public $ext_CALC_PERMS;
/**
* Current ids page record
*
* @var array
*/
protected $pageinfo;
/**
* Caches the available languages in a colPos
*
* @var array
*/
protected $languagesInColumnCache = [];
/**
* Caches the amount of content elements as a matrix
*
* @var array
* @internal
*/
protected $contentElementCache = [];
/**
* @var IconFactory
*/
protected $iconFactory;
/**
* Stores whether a certain language has translations in it
*
* @var array
*/
protected $languageHasTranslationsCache = [];
/**
* @var LocalizationController
*/
protected $localizationController;
/**
* Override the page ids taken into account by getPageIdConstraint()
*
* @var array
*/
protected $overridePageIdList = [];
/**
* Override/add urlparameters in listUrl() method
*
* @var string[]
*/
protected $overrideUrlParameters = [];
/**
* Array with before/after setting for tables
* Structure:
* 'tableName' => [
* 'before' => ['A', ...]
* 'after' => []
* ]
* @var array[]
*/
protected $tableDisplayOrder = [];
/**
* Cache the number of references to a record
*
* @var array
*/
protected $referenceCount = [];
/**
* Construct to initialize class variables.
*/
public function __construct()
{
if (isset($GLOBALS['BE_USER']->uc['titleLen']) && $GLOBALS['BE_USER']->uc['titleLen'] > 0) {
$this->fixedL = $GLOBALS['BE_USER']->uc['titleLen'];
}
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$this->determineScriptUrl();
$this->localizationController = GeneralUtility::makeInstance(LocalizationController::class);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Localization');
}
/*****************************************
*
* Renderings
*
*****************************************/
/**
* Adds the code of a single table
*
* @param string $table Table name
* @param int $id Current page id
* @param string $fields
* @return string HTML for listing.
*/
public function getTable($table, $id, $fields = '')
{
if (isset($this->externalTables[$table])) {
return $this->getExternalTables($id, $table);
}
// Branch out based on table name:
switch ($table) {
case 'pages':
return $this->getTable_pages($id);
case 'tt_content':
return $this->getTable_tt_content($id);
default:
return '';
}
}
/**
* Renders an external table from page id
*
* @param int $id Page id
* @param string $table Name of the table
* @return string HTML for the listing
*/
public function getExternalTables($id, $table)
{
$this->pageinfo = BackendUtility::readPageAccess($id, '');
$type = $this->getPageLayoutController()->MOD_SETTINGS[$table];
if (!isset($type)) {
$type = 0;
}
// eg. "name;title;email;company,image"
$fList = $this->externalTables[$table][$type]['fList'];
// The columns are separeted by comma ','.
// Values separated by semicolon ';' are shown in the same column.
$icon = $this->externalTables[$table][$type]['icon'];
$addWhere = $this->externalTables[$table][$type]['addWhere'];
// Create listing
$out = $this->makeOrdinaryList($table, $id, $fList, $icon, $addWhere);
return $out;
}
/**
* Renders records from the pages table from page id
* (Used to get information about the page tree content by "Web>Info"!)
*
* @param int $id Page id
* @return string HTML for the listing
*/
public function getTable_pages($id)
{
// Initializing:
$out = '';
$lang = $this->getLanguageService();
// Select current page:
if (!$id) {
// The root has a pseudo record in pageinfo...
$row = $this->getPageLayoutController()->pageinfo;
} else {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$row = $queryBuilder
->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)),
$this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)
)
->execute()
->fetch();
BackendUtility::workspaceOL('pages', $row);
}
// If there was found a page:
if (is_array($row)) {
// Getting select-depth:
$depth = (int)$this->getPageLayoutController()->MOD_SETTINGS['pages_levels'];
// Overriding a few things:
$this->no_noWrap = 0;
// Items
$this->eCounter = $this->firstElementNumber;
// Creating elements:
list($flag, $code) = $this->fwd_rwd_nav();
$out .= $code;
$editUids = [];
if ($flag) {
// Getting children:
$theRows = $this->getPageRecordsRecursive($row['uid'], $depth);
if ($this->getBackendUser()->doesUserHaveAccess($row, 2) && $row['uid'] > 0) {
$editUids[] = $row['uid'];
}
$out .= $this->pages_drawItem($row, $this->fieldArray);
// Traverse all pages selected:
foreach ($theRows as $sRow) {
if ($this->getBackendUser()->doesUserHaveAccess($sRow, 2)) {
$editUids[] = $sRow['uid'];
}
$out .= $this->pages_drawItem($sRow, $this->fieldArray);
}
$this->eCounter++;
}
// Header line is drawn
$theData = [];
$editIdList = implode(',', $editUids);
// Traverse fields (as set above) in order to create header values:
foreach ($this->fieldArray as $field) {
if ($editIdList
&& isset($GLOBALS['TCA']['pages']['columns'][$field])
&& $field !== 'uid'
&& !$this->pages_noEditColumns
) {
$iTitle = sprintf(
$lang->getLL('editThisColumn'),
rtrim(trim($lang->sL(BackendUtility::getItemLabel('pages', $field))), ':')
);
$urlParameters = [
'edit' => [
'pages' => [
$editIdList => 'edit'
]
],
'columnsOnly' => $field,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$eI = '<a class="btn btn-default" href="' . htmlspecialchars($url)
. '" title="' . htmlspecialchars($iTitle) . '">'
. $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
} else {
$eI = '';
}
switch ($field) {
case 'title':
$theData[$field] = $eI . ' <strong>'
. $lang->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'])
. '</strong>';
break;
case 'uid':
$theData[$field] = '';
break;
default:
if (strpos($field, 'table_') === 0) {
$f2 = substr($field, 6);
if ($GLOBALS['TCA'][$f2]) {
$theData[$field] = ' ' .
'<span title="' .
htmlspecialchars($lang->sL($GLOBALS['TCA'][$f2]['ctrl']['title'])) .
'">' .
$this->iconFactory->getIconForRecord($f2, [], Icon::SIZE_SMALL)->render() .
'</span>';
}
} else {
$theData[$field] = $eI . ' <strong>'
. htmlspecialchars($lang->sL($GLOBALS['TCA']['pages']['columns'][$field]['label']))
. '</strong>';
}
}
}
$out = '<div class="table-fit">'
. '<table class="table table-striped table-hover typo3-page-pages">'
. '<thead>'
. $this->addElement(1, '', $theData)
. '</thead>'
. '<tbody>'
. $out
. '</tbody>'
. '</table>'
. '</div>';
}
return $out;
}
/**
* Renders Content Elements from the tt_content table from page id
*
* @param int $id Page id
* @return string HTML for the listing
*/
public function getTable_tt_content($id)
{
$expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tt_content')
->getExpressionBuilder();
$this->pageinfo = BackendUtility::readPageAccess($this->id, '');
$this->initializeLanguages();
$this->initializeClipboard();
$pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(BackendUtility::getRecordTitle('pages', BackendUtility::getRecordWSOL('pages', $id), true));
/** @var PageRenderer $pageRenderer */
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/DragDrop');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/Paste');
if ($this->isPageEditable()) {
$languageOverlayId = 0;
$pageLocalizationRecord = BackendUtility::getRecordLocalization('pages', $this->id, (int)$this->tt_contentConfig['sys_language_uid']);
if (is_array($pageLocalizationRecord)) {
$pageLocalizationRecord = reset($pageLocalizationRecord);
}
if (!empty($pageLocalizationRecord['uid'])) {
$languageOverlayId = $pageLocalizationRecord['uid'];
}
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', 'function(PageActions) {
PageActions.setPageId(' . (int)$this->id . ');
PageActions.setLanguageOverlayId(' . $languageOverlayId . ');
}');
}
// Get labels for CTypes and tt_content element fields in general:
$this->CType_labels = [];
foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
$this->CType_labels[$val[1]] = $this->getLanguageService()->sL($val[0]);
}
$this->itemLabels = [];
foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
$this->itemLabels[$name] = $this->getLanguageService()->sL($val['label']);
}
$languageColumn = [];
$out = '';
// Setting language list:
$langList = $this->tt_contentConfig['sys_language_uid'];
if ($this->tt_contentConfig['languageMode']) {
if ($this->tt_contentConfig['languageColsPointer']) {
$langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
} else {
$langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
}
$languageColumn = [];
}
$langListArr = GeneralUtility::intExplode(',', $langList);
$defaultLanguageElementsByColumn = [];
$defLangBinding = [];
// For each languages... :
// If not languageMode, then we'll only be through this once.
foreach ($langListArr as $lP) {
$lP = (int)$lP;
if (!isset($this->contentElementCache[$lP])) {
$this->contentElementCache[$lP] = [];
}
if (count($langListArr) === 1 || $lP === 0) {
$showLanguage = $expressionBuilder->in('sys_language_uid', [$lP, -1]);
} else {
$showLanguage = $expressionBuilder->eq('sys_language_uid', $lP);
}
$content = [];
$head = [];
$backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($this->id);
$columns = $backendLayout['__colPosList'];
// Select content records per column
$contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, $columns, $showLanguage);
$cList = array_keys($contentRecordsPerColumn);
// For each column, render the content into a variable:
foreach ($cList as $columnId) {
if (!isset($this->contentElementCache[$lP])) {
$this->contentElementCache[$lP] = [];
}
if (!$lP) {
$defaultLanguageElementsByColumn[$columnId] = [];
}
// Start wrapping div
$content[$columnId] .= '<div data-colpos="' . $columnId . '" data-language-uid="' . $lP . '" class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $lP . ' t3-page-ce-wrapper';
if (empty($contentRecordsPerColumn[$columnId])) {
$content[$columnId] .= ' t3-page-ce-empty';
}
$content[$columnId] .= '">';
// Add new content at the top most position
$link = '';
if ($this->isContentEditable()
&& (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
) {
if ($this->option_newWizard) {
$urlParameters = [
'id' => $id,
'sys_language_uid' => $lP,
'colPos' => $columnId,
'uid_pid' => $id,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
];
$routeName = BackendUtility::getPagesTSconfig($id)['mod.']['newContentElementWizard.']['override']
?? 'new_content_element_wizard';
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
} else {
$urlParameters = [
'edit' => [
'tt_content' => [
$id => 'new'
]
],
'defVals' => [
'tt_content' => [
'colPos' => $columnId,
'sys_language_uid' => $lP
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
}
$title = htmlspecialchars($this->getLanguageService()->getLL('newContentElement'));
$link = '<a href="#" data-url="' . htmlspecialchars($url) . '" '
. 'title="' . $title . '"'
. 'data-title="' . $title . '"'
. 'class="btn btn-default btn-sm t3js-toggle-new-content-element-wizard">'
. $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render()
. ' '
. htmlspecialchars($this->getLanguageService()->getLL('content')) . '</a>';
}
if ($this->getBackendUser()->checkLanguageAccess($lP) && $columnId !== 'unused') {
$content[$columnId] .= '
<div class="t3-page-ce t3js-page-ce" data-page="' . (int)$id . '" id="' . StringUtility::getUniqueId() . '">
<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $columnId . '-' . 'page-' . $id . '-' . StringUtility::getUniqueId() . '">'
. $link
. '</div>
<div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
</div>
';
}
$editUidList = '';
if (!isset($contentRecordsPerColumn[$columnId]) || !is_array($contentRecordsPerColumn[$columnId])) {
$message = GeneralUtility::makeInstance(
FlashMessage::class,
$this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:error.invalidBackendLayout'),
'',
FlashMessage::WARNING
);
$service = GeneralUtility::makeInstance(FlashMessageService::class);
$queue = $service->getMessageQueueByIdentifier();
$queue->addMessage($message);
} else {
$rowArr = $contentRecordsPerColumn[$columnId];
$this->generateTtContentDataArray($rowArr);
foreach ((array)$rowArr as $rKey => $row) {
$this->contentElementCache[$lP][$columnId][$row['uid']] = $row;
if ($this->tt_contentConfig['languageMode']) {
$languageColumn[$columnId][$lP] = $head[$columnId] . $content[$columnId];
}
if (is_array($row) && !VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
$singleElementHTML = '<div class="t3-page-ce-dragitem" id="' . StringUtility::getUniqueId() . '">';
if (!$lP && ($this->defLangBinding || $row['sys_language_uid'] != -1)) {
$defaultLanguageElementsByColumn[$columnId][] = ($row['_ORIG_uid'] ?? $row['uid']);
}