1
|
|
|
<?php |
2
|
|
|
namespace TYPO3\CMS\Backend\Tree\View; |
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\Routing\UriBuilder; |
18
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
19
|
|
|
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; |
20
|
|
|
use TYPO3\CMS\Core\Database\ConnectionPool; |
21
|
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction; |
22
|
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction; |
23
|
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; |
24
|
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction; |
25
|
|
|
use TYPO3\CMS\Core\Imaging\Icon; |
26
|
|
|
use TYPO3\CMS\Core\Imaging\IconFactory; |
27
|
|
|
use TYPO3\CMS\Core\Localization\LanguageService; |
28
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Position map class - generating a page tree / content element list which links for inserting (copy/move) of records. |
32
|
|
|
* Used for pages / tt_content element wizards of various kinds. |
33
|
|
|
*/ |
34
|
|
|
class PagePositionMap |
35
|
|
|
{ |
36
|
|
|
// EXTERNAL, static: |
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
public $moveOrCopy = 'move'; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var int |
44
|
|
|
*/ |
45
|
|
|
public $dontPrintPageInsertIcons = 0; |
46
|
|
|
|
47
|
|
|
// How deep the position page tree will go. |
48
|
|
|
/** |
49
|
|
|
* @var int |
50
|
|
|
*/ |
51
|
|
|
public $depth = 2; |
52
|
|
|
|
53
|
|
|
// Can be set to the sys_language uid to select content elements for. |
54
|
|
|
/** |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
public $cur_sys_language; |
58
|
|
|
|
59
|
|
|
// INTERNAL, dynamic: |
60
|
|
|
// Request uri |
61
|
|
|
/** |
62
|
|
|
* @var string |
63
|
|
|
*/ |
64
|
|
|
public $R_URI = ''; |
65
|
|
|
|
66
|
|
|
// Element id. |
67
|
|
|
/** |
68
|
|
|
* @var string |
69
|
|
|
*/ |
70
|
|
|
public $elUid = ''; |
71
|
|
|
|
72
|
|
|
// tt_content element uid to move. |
73
|
|
|
/** |
74
|
|
|
* @var string |
75
|
|
|
*/ |
76
|
|
|
public $moveUid = ''; |
77
|
|
|
|
78
|
|
|
// Caching arrays: |
79
|
|
|
/** |
80
|
|
|
* @var array |
81
|
|
|
*/ |
82
|
|
|
public $getModConfigCache = []; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @var array |
86
|
|
|
*/ |
87
|
|
|
public $checkNewPageCache = []; |
88
|
|
|
|
89
|
|
|
// Label keys: |
90
|
|
|
/** |
91
|
|
|
* @var string |
92
|
|
|
*/ |
93
|
|
|
public $l_insertNewPageHere = 'insertNewPageHere'; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @var string |
97
|
|
|
*/ |
98
|
|
|
public $l_insertNewRecordHere = 'insertNewRecordHere'; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @var string |
102
|
|
|
*/ |
103
|
|
|
public $modConfigStr = 'mod.web_list.newPageWiz'; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Page tree implementation class name |
107
|
|
|
* |
108
|
|
|
* @var string |
109
|
|
|
*/ |
110
|
|
|
protected $pageTreeClassName = ElementBrowserPageTreeView::class; |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @var IconFactory |
114
|
|
|
*/ |
115
|
|
|
protected $iconFactory; |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Constructor allowing to set pageTreeImplementation |
119
|
|
|
* |
120
|
|
|
* @param string $pageTreeClassName |
121
|
|
|
*/ |
122
|
|
|
public function __construct($pageTreeClassName = null) |
123
|
|
|
{ |
124
|
|
|
if ($pageTreeClassName !== null) { |
125
|
|
|
$this->pageTreeClassName = $pageTreeClassName; |
126
|
|
|
} |
127
|
|
|
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/************************************* |
131
|
|
|
* |
132
|
|
|
* Page position map: |
133
|
|
|
* |
134
|
|
|
**************************************/ |
135
|
|
|
/** |
136
|
|
|
* Creates a "position tree" based on the page tree. |
137
|
|
|
* |
138
|
|
|
* @param int $id Current page id |
139
|
|
|
* @param array $pageinfo Current page record. |
140
|
|
|
* @param string $perms_clause Page selection permission clause. |
141
|
|
|
* @param string $R_URI Current REQUEST_URI |
142
|
|
|
* @return string HTML code for the tree. |
143
|
|
|
*/ |
144
|
|
|
public function positionTree($id, $pageinfo, $perms_clause, $R_URI) |
145
|
|
|
{ |
146
|
|
|
// Make page tree object: |
147
|
|
|
/** @var \TYPO3\CMS\Backend\Tree\View\PageTreeView $pageTree */ |
148
|
|
|
$pageTree = GeneralUtility::makeInstance($this->pageTreeClassName); |
149
|
|
|
$pageTree->init(' AND ' . $perms_clause); |
150
|
|
|
$pageTree->addField('pid'); |
151
|
|
|
// Initialize variables: |
152
|
|
|
$this->R_URI = $R_URI; |
153
|
|
|
$this->elUid = $id; |
154
|
|
|
// Create page tree, in $this->depth levels. |
155
|
|
|
$pageTree->getTree($pageinfo['pid'], $this->depth); |
156
|
|
|
// Initialize variables: |
157
|
|
|
$saveLatestUid = []; |
158
|
|
|
$latestInvDepth = $this->depth; |
159
|
|
|
// Traverse the tree: |
160
|
|
|
$lines = []; |
161
|
|
|
foreach ($pageTree->tree as $cc => $dat) { |
162
|
|
|
if ($latestInvDepth > $dat['invertedDepth']) { |
163
|
|
|
$margin = 'style="margin-left: ' . ($dat['invertedDepth'] * 16 + 9) . 'px;"'; |
164
|
|
|
$lines[] = '<ul class="list-tree" ' . $margin . '>'; |
165
|
|
|
} |
166
|
|
|
// Make link + parameters. |
167
|
|
|
$latestInvDepth = $dat['invertedDepth']; |
168
|
|
|
$saveLatestUid[$latestInvDepth] = $dat; |
169
|
|
|
if (isset($pageTree->tree[$cc - 1])) { |
170
|
|
|
$prev_dat = $pageTree->tree[$cc - 1]; |
171
|
|
|
// If current page, subpage? |
172
|
|
|
if ($prev_dat['row']['uid'] == $id) { |
173
|
|
|
// 1) It must be allowed to create a new page and 2) If there are subpages there is no need to render a subpage icon here - it'll be done over the subpages... |
174
|
|
|
if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id) && !($prev_dat['invertedDepth'] > $pageTree->tree[$cc]['invertedDepth'])) { |
175
|
|
|
end($lines); |
176
|
|
|
$margin = 'style="margin-left: ' . (($dat['invertedDepth'] - 1) * 16 + 9) . 'px;"'; |
177
|
|
|
$lines[] = '<ul class="list-tree" ' . $margin . '><li><span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($id, $id)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li></ul>'; |
178
|
|
|
} |
179
|
|
|
} |
180
|
|
|
// If going down |
181
|
|
|
if ($prev_dat['invertedDepth'] > $pageTree->tree[$cc]['invertedDepth']) { |
182
|
|
|
$prevPid = $pageTree->tree[$cc]['row']['pid']; |
183
|
|
|
} elseif ($prev_dat['invertedDepth'] < $pageTree->tree[$cc]['invertedDepth']) { |
184
|
|
|
// If going up |
185
|
|
|
// First of all the previous level should have an icon: |
186
|
|
View Code Duplication |
if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($prev_dat['row']['pid'])) { |
187
|
|
|
$prevPid = -$prev_dat['row']['uid']; |
188
|
|
|
end($lines); |
189
|
|
|
$lines[] = '<li><span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $prev_dat['row']['pid'])) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li>'; |
190
|
|
|
} |
191
|
|
|
// Then set the current prevPid |
192
|
|
|
$prevPid = -$prev_dat['row']['pid']; |
193
|
|
|
if ($prevPid !== $dat['row']['pid']) { |
194
|
|
|
$lines[] = '</ul>'; |
195
|
|
|
} |
196
|
|
|
} else { |
197
|
|
|
// In on the same level |
198
|
|
|
$prevPid = -$prev_dat['row']['uid']; |
199
|
|
|
} |
200
|
|
|
} else { |
201
|
|
|
// First in the tree |
202
|
|
|
$prevPid = $dat['row']['pid']; |
203
|
|
|
} |
204
|
|
|
// print arrow on the same level |
205
|
|
|
if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid'])) { |
206
|
|
|
$lines[] = '<span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $dat['row']['pid'])) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span>'; |
207
|
|
|
} |
208
|
|
|
// The line with the icon and title: |
209
|
|
|
$toolTip = BackendUtility::getRecordToolTip($dat['row'], 'pages'); |
210
|
|
|
$icon = '<span ' . $toolTip . '>' . $this->iconFactory->getIconForRecord('pages', $dat['row'], Icon::SIZE_SMALL)->render() . '</span>'; |
211
|
|
|
|
212
|
|
|
$lines[] = '<span class="text-nowrap">' . $icon . $this->linkPageTitle($this->boldTitle(htmlspecialchars(GeneralUtility::fixed_lgd_cs($dat['row']['title'], $this->getBackendUser()->uc['titleLen'])), $dat, $id), $dat['row']) . '</span>'; |
213
|
|
|
} |
214
|
|
|
// If the current page was the last in the tree: |
215
|
|
|
$prev_dat = end($pageTree->tree); |
216
|
|
|
if ($prev_dat['row']['uid'] == $id) { |
217
|
|
|
if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id)) { |
218
|
|
|
$lines[] = '<ul class="list-tree" style="margin-left: 25px"><li><span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($id, $id)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li></ul>'; |
219
|
|
|
} |
220
|
|
|
} |
221
|
|
|
for ($a = $latestInvDepth; $a <= $this->depth; $a++) { |
222
|
|
|
$dat = $saveLatestUid[$a]; |
223
|
|
|
$prevPid = -$dat['row']['uid']; |
224
|
|
View Code Duplication |
if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid'])) { |
225
|
|
|
if ($latestInvDepth < $dat['invertedDepth']) { |
226
|
|
|
$lines[] = '</ul>'; |
227
|
|
|
} |
228
|
|
|
$lines[] = '<span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $dat['row']['pid'])) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span>'; |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
$code = '<ul class="list-tree">'; |
233
|
|
|
|
234
|
|
|
foreach ($lines as $line) { |
235
|
|
|
if ((substr($line, 0, 3) === '<ul') || (substr($line, 0, 4) === '</ul')) { |
236
|
|
|
$code .= $line; |
237
|
|
|
} else { |
238
|
|
|
$code .= '<li>' . $line . '</li>'; |
239
|
|
|
} |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
$code .= '</ul>'; |
243
|
|
|
return $code; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Wrap $t_code in bold IF the $dat uid matches $id |
248
|
|
|
* |
249
|
|
|
* @param string $t_code Title string |
250
|
|
|
* @param array $dat Information array with record array inside. |
251
|
|
|
* @param int $id The current id. |
252
|
|
|
* @return string The title string. |
253
|
|
|
*/ |
254
|
|
|
public function boldTitle($t_code, $dat, $id) |
255
|
|
|
{ |
256
|
|
|
if ($dat['row']['uid'] == $id) { |
257
|
|
|
$t_code = '<strong>' . $t_code . '</strong>'; |
258
|
|
|
} |
259
|
|
|
return $t_code; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Creates the onclick event for the insert-icons. |
264
|
|
|
* |
265
|
|
|
* TSconfig mod.newPageWizard.override may contain an alternative module / route which can be |
266
|
|
|
* used instead of the normal create new page wizard. |
267
|
|
|
* |
268
|
|
|
* @param int $pid The pid. |
269
|
|
|
* @param int $newPagePID New page id. |
270
|
|
|
* @return string Onclick attribute content |
271
|
|
|
*/ |
272
|
|
|
public function onClickEvent($pid, $newPagePID) |
273
|
|
|
{ |
274
|
|
|
$TSconfig = BackendUtility::getModTSconfig($newPagePID, 'mod.newPageWizard'); |
275
|
|
|
$TSconfig = $TSconfig['properties']; |
276
|
|
|
if (isset($TSconfig['override']) && !empty($TSconfig['override'])) { |
277
|
|
|
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); |
278
|
|
|
$url = $uriBuilder->buildUriFromRoute( |
279
|
|
|
$TSconfig['override'], |
280
|
|
|
[ |
281
|
|
|
'positionPid' => $pid, |
282
|
|
|
'newPageId' => $newPagePID, |
283
|
|
|
'cmd' => 'crPage', |
284
|
|
|
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') |
285
|
|
|
] |
286
|
|
|
); |
287
|
|
|
return 'list_frame.location.href=' . GeneralUtility::quoteJSvalue((string)$url) . ';'; |
288
|
|
|
} |
289
|
|
|
$params = '&edit[pages][' . $pid . ']=new&returnNewPageId=1'; |
290
|
|
|
return BackendUtility::editOnClick($params, '', $this->R_URI); |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* Get label, htmlspecialchars()'ed |
295
|
|
|
* |
296
|
|
|
* @return string The localized label for "insert new page here |
297
|
|
|
*/ |
298
|
|
|
public function insertlabel() |
299
|
|
|
{ |
300
|
|
|
return htmlspecialchars($this->getLanguageService()->getLL($this->l_insertNewPageHere)); |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* Wrapping page title. |
305
|
|
|
* |
306
|
|
|
* @param string $str Page title. |
307
|
|
|
* @param array $rec Page record (?) |
308
|
|
|
* @return string Wrapped title. |
309
|
|
|
*/ |
310
|
|
|
public function linkPageTitle($str, $rec) |
|
|
|
|
311
|
|
|
{ |
312
|
|
|
return $str; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* Checks if the user has permission to created pages inside of the $pid page. |
317
|
|
|
* Uses caching so only one regular lookup is made - hence you can call the function multiple times without worrying about performance. |
318
|
|
|
* |
319
|
|
|
* @param int $pid Page id for which to test. |
320
|
|
|
* @return bool |
321
|
|
|
*/ |
322
|
|
|
public function checkNewPageInPid($pid) |
323
|
|
|
{ |
324
|
|
|
if (!isset($this->checkNewPageCache[$pid])) { |
325
|
|
|
$pidInfo = BackendUtility::getRecord('pages', $pid); |
326
|
|
|
$this->checkNewPageCache[$pid] = $this->getBackendUser()->isAdmin() || $this->getBackendUser()->doesUserHaveAccess($pidInfo, 8); |
327
|
|
|
} |
328
|
|
|
return $this->checkNewPageCache[$pid]; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* Returns module configuration for a pid. |
333
|
|
|
* |
334
|
|
|
* @param int $pid Page id for which to get the module configuration. |
335
|
|
|
* @return array The properties of the module configuration for the page id. |
336
|
|
|
* @see onClickEvent() |
337
|
|
|
*/ |
338
|
|
|
public function getModConfig($pid) |
339
|
|
|
{ |
340
|
|
|
if (!isset($this->getModConfigCache[$pid])) { |
341
|
|
|
// Acquiring TSconfig for this PID: |
342
|
|
|
$this->getModConfigCache[$pid] = BackendUtility::getModTSconfig($pid, $this->modConfigStr); |
343
|
|
|
} |
344
|
|
|
return $this->getModConfigCache[$pid]['properties']; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/************************************* |
348
|
|
|
* |
349
|
|
|
* Content element positioning: |
350
|
|
|
* |
351
|
|
|
**************************************/ |
352
|
|
|
/** |
353
|
|
|
* Creates HTML for inserting/moving content elements. |
354
|
|
|
* |
355
|
|
|
* @param int $pid page id onto which to insert content element. |
356
|
|
|
* @param int $moveUid Move-uid (tt_content element uid?) |
357
|
|
|
* @param string $colPosList List of columns to show |
358
|
|
|
* @param bool $showHidden If not set, then hidden/starttime/endtime records are filtered out. |
359
|
|
|
* @param string $R_URI Request URI |
360
|
|
|
* @return string HTML |
361
|
|
|
*/ |
362
|
|
|
public function printContentElementColumns($pid, $moveUid, $colPosList, $showHidden, $R_URI) |
363
|
|
|
{ |
364
|
|
|
$this->R_URI = $R_URI; |
365
|
|
|
$this->moveUid = $moveUid; |
366
|
|
|
$colPosArray = GeneralUtility::trimExplode(',', $colPosList, true); |
367
|
|
|
$lines = []; |
368
|
|
|
foreach ($colPosArray as $kk => $vv) { |
369
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); |
370
|
|
|
$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class)); |
371
|
|
|
if ($showHidden) { |
372
|
|
|
$queryBuilder->getRestrictions() |
373
|
|
|
->removeByType(HiddenRestriction::class) |
374
|
|
|
->removeByType(StartTimeRestriction::class) |
375
|
|
|
->removeByType(EndTimeRestriction::class); |
376
|
|
|
} |
377
|
|
|
$queryBuilder |
378
|
|
|
->select('*') |
379
|
|
|
->from('tt_content') |
380
|
|
|
->where( |
381
|
|
|
$queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)), |
382
|
|
|
$queryBuilder->expr()->eq('colPos', $queryBuilder->createNamedParameter($vv, \PDO::PARAM_INT)) |
383
|
|
|
) |
384
|
|
|
->orderBy('sorting'); |
385
|
|
|
|
386
|
|
|
if ((string)$this->cur_sys_language !== '') { |
387
|
|
|
$queryBuilder->andWhere( |
388
|
|
|
$queryBuilder->expr()->eq( |
389
|
|
|
'sys_language_uid', |
390
|
|
|
$queryBuilder->createNamedParameter($this->cur_sys_language, \PDO::PARAM_INT) |
391
|
|
|
) |
392
|
|
|
); |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
$res = $queryBuilder->execute(); |
396
|
|
|
$lines[$vv] = []; |
397
|
|
|
$lines[$vv][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid); |
398
|
|
|
|
399
|
|
|
while ($row = $res->fetch()) { |
400
|
|
|
BackendUtility::workspaceOL('tt_content', $row); |
401
|
|
|
if (is_array($row)) { |
402
|
|
|
$lines[$vv][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row); |
|
|
|
|
403
|
|
|
$lines[$vv][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid); |
404
|
|
|
} |
405
|
|
|
} |
406
|
|
|
} |
407
|
|
|
return $this->printRecordMap($lines, $colPosArray, $pid); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
/** |
411
|
|
|
* Creates the table with the content columns |
412
|
|
|
* |
413
|
|
|
* @param array $lines Array with arrays of lines for each column |
414
|
|
|
* @param array $colPosArray Column position array |
415
|
|
|
* @param int $pid The id of the page |
416
|
|
|
* @return string HTML |
417
|
|
|
*/ |
418
|
|
|
public function printRecordMap($lines, $colPosArray, $pid = 0) |
419
|
|
|
{ |
420
|
|
|
$count = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(count($colPosArray), 1); |
421
|
|
|
$backendLayout = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getSelectedBackendLayout', $pid, $this); |
422
|
|
|
if (isset($backendLayout['__config']['backend_layout.'])) { |
423
|
|
|
$this->getLanguageService()->includeLLFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf'); |
424
|
|
|
$table = '<div class="table-fit"><table class="table table-condensed table-bordered table-vertical-top">'; |
425
|
|
|
$colCount = (int)$backendLayout['__config']['backend_layout.']['colCount']; |
426
|
|
|
$rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount']; |
427
|
|
|
$table .= '<colgroup>'; |
428
|
|
|
for ($i = 0; $i < $colCount; $i++) { |
429
|
|
|
$table .= '<col style="width:' . 100 / $colCount . '%"></col>'; |
430
|
|
|
} |
431
|
|
|
$table .= '</colgroup>'; |
432
|
|
|
$table .= '<tbody>'; |
433
|
|
|
$tcaItems = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $pid, $this); |
434
|
|
|
// Cycle through rows |
435
|
|
|
for ($row = 1; $row <= $rowCount; $row++) { |
436
|
|
|
$rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.']; |
437
|
|
|
if (!isset($rowConfig)) { |
438
|
|
|
continue; |
439
|
|
|
} |
440
|
|
|
$table .= '<tr>'; |
441
|
|
|
for ($col = 1; $col <= $colCount; $col++) { |
442
|
|
|
$columnConfig = $rowConfig['columns.'][$col . '.']; |
443
|
|
|
if (!isset($columnConfig)) { |
444
|
|
|
continue; |
445
|
|
|
} |
446
|
|
|
// Which tt_content colPos should be displayed inside this cell |
447
|
|
|
$columnKey = (int)$columnConfig['colPos']; |
448
|
|
|
$head = ''; |
449
|
|
|
foreach ($tcaItems as $item) { |
450
|
|
|
if ($item[1] == $columnKey) { |
451
|
|
|
$head = htmlspecialchars($this->getLanguageService()->sL($item[0])); |
452
|
|
|
} |
453
|
|
|
} |
454
|
|
|
// Render the grid cell |
455
|
|
|
$table .= '<td' |
456
|
|
|
. (isset($columnConfig['colspan']) ? ' colspan="' . $columnConfig['colspan'] . '"' : '') |
457
|
|
|
. (isset($columnConfig['rowspan']) ? ' rowspan="' . $columnConfig['rowspan'] . '"' : '') |
458
|
|
|
. ' class="col-nowrap col-min' |
459
|
|
|
. (!isset($columnConfig['colPos']) ? ' warning' : '') |
460
|
|
|
. (isset($columnConfig['colPos']) && !$head ? ' danger' : '') . '">'; |
461
|
|
|
// Render header |
462
|
|
|
$table .= '<p>'; |
463
|
|
|
if (isset($columnConfig['colPos']) && $head) { |
464
|
|
|
$table .= '<strong>' . $this->wrapColumnHeader($head, '', '') . '</strong>'; |
|
|
|
|
465
|
|
|
} elseif ($columnConfig['colPos']) { |
466
|
|
|
$table .= '<em>' . $this->wrapColumnHeader($this->getLanguageService()->getLL('noAccess'), '', '') . '</em>'; |
467
|
|
|
} else { |
468
|
|
|
$table .= '<em>' . $this->wrapColumnHeader(($this->getLanguageService()->sL($columnConfig['name']) ?: '') . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')', '', '') . '</em>'; |
469
|
|
|
} |
470
|
|
|
$table .= '</p>'; |
471
|
|
|
// Render lines |
472
|
|
|
if (isset($columnConfig['colPos']) && $head && !empty($lines[$columnKey])) { |
473
|
|
|
$table .= '<ul class="list-unstyled">'; |
474
|
|
|
foreach ($lines[$columnKey] as $line) { |
475
|
|
|
$table .= '<li>' . $line . '</li>'; |
476
|
|
|
} |
477
|
|
|
$table .= '</ul>'; |
478
|
|
|
} |
479
|
|
|
$table .= '</td>'; |
480
|
|
|
} |
481
|
|
|
$table .= '</tr>'; |
482
|
|
|
} |
483
|
|
|
$table .= '</tbody>'; |
484
|
|
|
$table .= '</table></div>'; |
485
|
|
|
} else { |
486
|
|
|
// Traverse the columns here: |
487
|
|
|
$row = ''; |
488
|
|
|
foreach ($colPosArray as $kk => $vv) { |
489
|
|
|
$row .= '<td class="col-nowrap col-min" width="' . round(100 / $count) . '%">'; |
490
|
|
|
$row .= '<p><strong>' . $this->wrapColumnHeader(htmlspecialchars($this->getLanguageService()->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $vv))), $vv) . '</strong></p>'; |
491
|
|
|
if (!empty($lines[$vv])) { |
492
|
|
|
$row .= '<ul class="list-unstyled">'; |
493
|
|
|
foreach ($lines[$vv] as $line) { |
494
|
|
|
$row .= '<li>' . $line . '</li>'; |
495
|
|
|
} |
496
|
|
|
$row .= '</ul>'; |
497
|
|
|
} |
498
|
|
|
$row .= '</td>'; |
499
|
|
|
} |
500
|
|
|
$table = ' |
501
|
|
|
|
502
|
|
|
<!-- |
503
|
|
|
Map of records in columns: |
504
|
|
|
--> |
505
|
|
|
<div class="table-fit"> |
506
|
|
|
<table class="table table-condensed table-bordered table-vertical-top"> |
507
|
|
|
<tr>' . $row . '</tr> |
508
|
|
|
</table> |
509
|
|
|
</div> |
510
|
|
|
|
511
|
|
|
'; |
512
|
|
|
} |
513
|
|
|
return $table; |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
/** |
517
|
|
|
* Wrapping the column header |
518
|
|
|
* |
519
|
|
|
* @param string $str Header value |
520
|
|
|
* @param string $vv Column info. |
521
|
|
|
* @return string |
522
|
|
|
* @see printRecordMap() |
523
|
|
|
*/ |
524
|
|
|
public function wrapColumnHeader($str, $vv) |
525
|
|
|
{ |
526
|
|
|
return $str; |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
/** |
530
|
|
|
* Creates a linked position icon. |
531
|
|
|
* |
532
|
|
|
* @param mixed $row Element row. If this is an array the link will cause an insert after this content element, otherwise |
533
|
|
|
* the link will insert at the first position in the column |
534
|
|
|
* @param string $vv Column position value. |
535
|
|
|
* @param int $kk Column key. |
536
|
|
|
* @param int $moveUid Move uid |
537
|
|
|
* @param int $pid PID value. |
538
|
|
|
* @return string |
539
|
|
|
*/ |
540
|
|
|
public function insertPositionIcon($row, $vv, $kk, $moveUid, $pid) |
541
|
|
|
{ |
542
|
|
View Code Duplication |
if (is_array($row) && !empty($row['uid'])) { |
543
|
|
|
// Use record uid for the hash when inserting after this content element |
544
|
|
|
$uid = $row['uid']; |
545
|
|
|
} else { |
546
|
|
|
// No uid means insert at first position in the column |
547
|
|
|
$uid = ''; |
548
|
|
|
} |
549
|
|
|
$cc = hexdec(substr(md5($uid . '-' . $vv . '-' . $kk), 0, 4)); |
|
|
|
|
550
|
|
|
return '<a href="#" onclick="' . htmlspecialchars($this->onClickInsertRecord($row, $vv, $moveUid, $pid, $this->cur_sys_language)) . '" data-dismiss="modal">' . '<i class="t3-icon fa fa-long-arrow-left" name="mImgEnd' . $cc . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($this->l_insertNewRecordHere)) . '"></i></a>'; |
|
|
|
|
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
/** |
554
|
|
|
* Create on-click event value. |
555
|
|
|
* |
556
|
|
|
* @param mixed $row The record. If this is not an array with the record data the insert will be for the first position |
557
|
|
|
* in the column |
558
|
|
|
* @param string $vv Column position value. |
559
|
|
|
* @param int $moveUid Move uid |
560
|
|
|
* @param int $pid PID value. |
561
|
|
|
* @param int $sys_lang System language (not used currently) |
562
|
|
|
* @return string |
563
|
|
|
*/ |
564
|
|
|
public function onClickInsertRecord($row, $vv, $moveUid, $pid, $sys_lang = 0) |
|
|
|
|
565
|
|
|
{ |
566
|
|
|
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); |
567
|
|
|
if (is_array($row)) { |
568
|
|
|
$location = $uriBuilder->buildUriFromRoute('tce_db', [ |
569
|
|
|
'cmd[tt_content][' . $moveUid . '][' . $this->moveOrCopy . ']' => '-' . $row['uid'], |
570
|
|
|
'redirect' => rawurlencode($this->R_URI) |
571
|
|
|
]); |
572
|
|
|
} else { |
573
|
|
|
$location = $uriBuilder->buildUriFromRoute('tce_db', [ |
574
|
|
|
'cmd[tt_content][' . $moveUid . '][' . $this->moveOrCopy . ']' => $pid, |
575
|
|
|
'data[tt_content][' . $moveUid . '][colPos]' => $vv, |
576
|
|
|
'redirect' => rawurlencode($this->R_URI) |
577
|
|
|
]); |
578
|
|
|
} |
579
|
|
|
// returns to prev. page |
580
|
|
|
return 'list_frame.location.href=' . GeneralUtility::quoteJSvalue((string)$location) . ';return false;'; |
581
|
|
|
} |
582
|
|
|
|
583
|
|
|
/** |
584
|
|
|
* Wrapping the record header (from getRecordHeader()) |
585
|
|
|
* |
586
|
|
|
* @param string $str HTML content |
587
|
|
|
* @param string $row Record array. |
588
|
|
|
* @return string HTML content |
589
|
|
|
*/ |
590
|
|
|
public function wrapRecordHeader($str, $row) |
591
|
|
|
{ |
592
|
|
|
return $str; |
593
|
|
|
} |
594
|
|
|
|
595
|
|
|
/** |
596
|
|
|
* Create record header (includes the record icon, record title etc.) |
597
|
|
|
* |
598
|
|
|
* @param array $row Record row. |
599
|
|
|
* @return string HTML |
600
|
|
|
*/ |
601
|
|
|
public function getRecordHeader($row) |
602
|
|
|
{ |
603
|
|
|
$iconFactory = GeneralUtility::makeInstance(IconFactory::class); |
604
|
|
|
$toolTip = BackendUtility::getRecordToolTip($row, 'tt_content'); |
605
|
|
|
$line = '<span ' . $toolTip . ' title="' . BackendUtility::getRecordIconAltText($row, 'tt_content') . '">' . $iconFactory->getIconForRecord('tt_content', $row, Icon::SIZE_SMALL)->render() . '</span>'; |
606
|
|
|
$line .= BackendUtility::getRecordTitle('tt_content', $row, true); |
607
|
|
|
return $this->wrapRecordTitle($line, $row); |
608
|
|
|
} |
609
|
|
|
|
610
|
|
|
/** |
611
|
|
|
* Wrapping the title of the record. |
612
|
|
|
* |
613
|
|
|
* @param string $str The title value. |
614
|
|
|
* @param array $row The record row. |
615
|
|
|
* @return string Wrapped title string. |
616
|
|
|
*/ |
617
|
|
|
public function wrapRecordTitle($str, $row) |
618
|
|
|
{ |
619
|
|
|
return '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(['uid' => (int)$row['uid'], 'moveUid' => ''])) . '">' . $str . '</a>'; |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
/** |
623
|
|
|
* Returns the BackendUser |
624
|
|
|
* |
625
|
|
|
* @return BackendUserAuthentication |
626
|
|
|
*/ |
627
|
|
|
protected function getBackendUser() |
628
|
|
|
{ |
629
|
|
|
return $GLOBALS['BE_USER']; |
630
|
|
|
} |
631
|
|
|
|
632
|
|
|
/** |
633
|
|
|
* Returns the LanguageService |
634
|
|
|
* |
635
|
|
|
* @return LanguageService |
636
|
|
|
*/ |
637
|
|
|
protected function getLanguageService() |
638
|
|
|
{ |
639
|
|
|
return $GLOBALS['LANG']; |
640
|
|
|
} |
641
|
|
|
} |
642
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.