1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the TYPO3 CMS project. |
5
|
|
|
* |
6
|
|
|
* It is free software; you can redistribute it and/or modify it under |
7
|
|
|
* the terms of the GNU General Public License, either version 2 |
8
|
|
|
* of the License, or any later version. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please read the |
11
|
|
|
* LICENSE.txt file that was distributed with this source code. |
12
|
|
|
* |
13
|
|
|
* The TYPO3 project - inspiring people to share! |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace TYPO3\CMS\Info\Controller; |
17
|
|
|
|
18
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
19
|
|
|
use TYPO3\CMS\Backend\Routing\PreviewUriBuilder; |
20
|
|
|
use TYPO3\CMS\Backend\Routing\UriBuilder; |
21
|
|
|
use TYPO3\CMS\Backend\Tree\View\PageTreeView; |
22
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
23
|
|
|
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; |
24
|
|
|
use TYPO3\CMS\Core\Database\ConnectionPool; |
25
|
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; |
26
|
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction; |
27
|
|
|
use TYPO3\CMS\Core\Imaging\Icon; |
28
|
|
|
use TYPO3\CMS\Core\Imaging\IconFactory; |
29
|
|
|
use TYPO3\CMS\Core\Localization\LanguageService; |
30
|
|
|
use TYPO3\CMS\Core\Page\PageRenderer; |
31
|
|
|
use TYPO3\CMS\Core\Site\Entity\SiteInterface; |
32
|
|
|
use TYPO3\CMS\Core\Site\Entity\SiteLanguage; |
33
|
|
|
use TYPO3\CMS\Core\Type\Bitmask\PageTranslationVisibility; |
34
|
|
|
use TYPO3\CMS\Core\Type\Bitmask\Permission; |
35
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Class for displaying translation status of pages in the tree in Web -> Info |
39
|
|
|
* @internal This class is a specific Backend controller implementation and is not part of the TYPO3's Core API. |
40
|
|
|
*/ |
41
|
|
|
class TranslationStatusController |
42
|
|
|
{ |
43
|
|
|
protected IconFactory $iconFactory; |
44
|
|
|
protected UriBuilder $uriBuilder; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var SiteLanguage[] |
48
|
|
|
*/ |
49
|
|
|
protected $siteLanguages; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var InfoModuleController Contains a reference to the parent calling object |
53
|
|
|
*/ |
54
|
|
|
protected $pObj; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var int Value of the GET/POST var 'id' |
58
|
|
|
*/ |
59
|
|
|
protected $id; |
60
|
|
|
|
61
|
|
|
public function __construct(IconFactory $iconFactory, UriBuilder $uriBuilder) |
62
|
|
|
{ |
63
|
|
|
$this->iconFactory = $iconFactory; |
64
|
|
|
$this->uriBuilder = $uriBuilder; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Init, called from parent object |
69
|
|
|
* |
70
|
|
|
* @param InfoModuleController $pObj A reference to the parent (calling) object |
71
|
|
|
*/ |
72
|
|
|
public function init(InfoModuleController $pObj, ServerRequestInterface $request) |
73
|
|
|
{ |
74
|
|
|
$this->id = (int)($request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0); |
75
|
|
|
$this->initializeSiteLanguages($request); |
76
|
|
|
$this->pObj = $pObj; |
77
|
|
|
|
78
|
|
|
// Setting MOD_MENU items as we need them for logging: |
79
|
|
|
$this->pObj->MOD_MENU = array_merge($this->pObj->MOD_MENU, $this->modMenu()); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Main, called from parent object |
84
|
|
|
* |
85
|
|
|
* @return string Output HTML for the module. |
86
|
|
|
*/ |
87
|
|
|
public function main(ServerRequestInterface $request) |
88
|
|
|
{ |
89
|
|
|
$theOutput = '<h1>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_title')) . '</h1>'; |
90
|
|
|
if ($this->id) { |
91
|
|
|
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Info/TranslationStatus'); |
92
|
|
|
|
93
|
|
|
// Settings: Depth and language selectors |
94
|
|
|
$theOutput .= ' |
95
|
|
|
<div class="row row-cols-auto mb-3 g-3 align-items-center"> |
96
|
|
|
<div class="col-auto">' . BackendUtility::getDropdownMenu($this->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']) . '</div> |
97
|
|
|
<div class="col-auto">' . BackendUtility::getDropdownMenu($this->id, 'SET[lang]', $this->pObj->MOD_SETTINGS['lang'], $this->pObj->MOD_MENU['lang']) . '</div> |
98
|
|
|
' . BackendUtility::cshItem('_MOD_web_info', 'lang', '', '<div class="col-auto"><span class="btn btn-default btn-sm">|</span></div>') . ' |
99
|
|
|
</div>'; |
100
|
|
|
// Showing the tree |
101
|
|
|
$tree = $this->getTree(); |
102
|
|
|
// Render information table |
103
|
|
|
$theOutput .= $this->renderL10nTable($tree, $request); |
104
|
|
|
} |
105
|
|
|
return $theOutput; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
protected function getTree(): PageTreeView |
109
|
|
|
{ |
110
|
|
|
// Initialize starting point of page tree |
111
|
|
|
$treeStartingPoint = $this->id; |
112
|
|
|
$treeStartingRecord = BackendUtility::getRecordWSOL('pages', $treeStartingPoint); |
113
|
|
|
$depth = (int)$this->pObj->MOD_SETTINGS['depth']; |
114
|
|
|
$tree = GeneralUtility::makeInstance(PageTreeView::class); |
115
|
|
|
$tree->init('AND ' . $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)); |
116
|
|
|
$tree->addField('l18n_cfg'); |
117
|
|
|
$tree->tree[] = [ |
118
|
|
|
'row' => $treeStartingRecord, |
119
|
|
|
// Creating top icon; the current page |
120
|
|
|
'HTML' => $this->iconFactory->getIconForRecord('pages', $treeStartingRecord, Icon::SIZE_SMALL)->render() |
121
|
|
|
]; |
122
|
|
|
// Create the tree from starting point |
123
|
|
|
if ($depth) { |
124
|
|
|
$tree->getTree($treeStartingPoint, $depth); |
125
|
|
|
} |
126
|
|
|
return $tree; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Returns the menu array |
131
|
|
|
* |
132
|
|
|
* @return array |
133
|
|
|
*/ |
134
|
|
|
protected function modMenu() |
135
|
|
|
{ |
136
|
|
|
$lang = $this->getLanguageService(); |
137
|
|
|
$menuArray = [ |
138
|
|
|
'depth' => [ |
139
|
|
|
0 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0'), |
140
|
|
|
1 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1'), |
141
|
|
|
2 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2'), |
142
|
|
|
3 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3'), |
143
|
|
|
4 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4'), |
144
|
|
|
999 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi') |
145
|
|
|
] |
146
|
|
|
]; |
147
|
|
|
// Languages: |
148
|
|
|
$menuArray['lang'] = []; |
149
|
|
|
foreach ($this->siteLanguages as $language) { |
150
|
|
|
if ($language->getLanguageId() === 0) { |
151
|
|
|
$menuArray['lang'][0] = '[All]'; |
152
|
|
|
} else { |
153
|
|
|
$menuArray['lang'][$language->getLanguageId()] = $language->getTitle(); |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
return $menuArray; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Rendering the localization information table. |
161
|
|
|
* |
162
|
|
|
* @param PageTreeView $tree The Page tree data |
163
|
|
|
* @param ServerRequestInterface $request |
164
|
|
|
* @return string HTML for the localization information table. |
165
|
|
|
*/ |
166
|
|
|
protected function renderL10nTable(PageTreeView $tree, ServerRequestInterface $request) |
167
|
|
|
{ |
168
|
|
|
$lang = $this->getLanguageService(); |
169
|
|
|
// Title length: |
170
|
|
|
$titleLen = $this->getBackendUser()->uc['titleLen']; |
171
|
|
|
// Put together the TREE: |
172
|
|
|
$output = ''; |
173
|
|
|
$newOL_js = []; |
174
|
|
|
$langRecUids = []; |
175
|
|
|
|
176
|
|
|
$userTsConfig = $this->getBackendUser()->getTSConfig(); |
177
|
|
|
$showPageId = !empty($userTsConfig['options.']['pageTree.']['showPageIdWithTitle']); |
178
|
|
|
|
179
|
|
|
foreach ($tree->tree as $data) { |
180
|
|
|
$tCells = []; |
181
|
|
|
$langRecUids[0][] = $data['row']['uid']; |
182
|
|
|
$pageTitle = ($showPageId ? '[' . (int)$data['row']['uid'] . '] ' : '') . GeneralUtility::fixed_lgd_cs($data['row']['title'], $titleLen); |
183
|
|
|
// Page icons / titles etc. |
184
|
|
|
$tCells[] = '<td' . ($data['row']['_CSSCLASS'] ? ' class="' . $data['row']['_CSSCLASS'] . '"' : '') . '>' . |
185
|
|
|
($data['depthData'] ?: '') . |
186
|
|
|
BackendUtility::wrapClickMenuOnIcon($data['HTML'], 'pages', $data['row']['uid']) . |
187
|
|
|
'<a href="#" onclick="' . htmlspecialchars( |
188
|
|
|
'top.loadEditId(' . (int)$data['row']['uid'] . ',"&SET[language]=0"); return false;' |
189
|
|
|
) . '" title="' . $lang->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editPage') . '">' . |
190
|
|
|
htmlspecialchars($pageTitle) . |
191
|
|
|
'</a>' . |
192
|
|
|
((string)$data['row']['nav_title'] !== '' ? ' [Nav: <em>' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($data['row']['nav_title'], $titleLen)) . '</em>]' : '') . |
193
|
|
|
'</td>'; |
194
|
|
|
$previewUriBuilder = PreviewUriBuilder::create((int)$data['row']['uid']); |
195
|
|
|
// DEFAULT language: |
196
|
|
|
// "View page" link is created: |
197
|
|
|
$viewPageLink = '<a href="#" ' . $previewUriBuilder |
198
|
|
|
->withAdditionalQueryParameters('&L=###LANG_UID###') |
199
|
|
|
->serializeDispatcherAttributes() |
200
|
|
|
. ' class="btn btn-default" title="' . $lang->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_viewPage') . '">' . |
201
|
|
|
$this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render() . '</a>'; |
202
|
|
|
$pageTranslationVisibility = new PageTranslationVisibility((int)($data['row']['l18n_cfg'] ?? 0)); |
203
|
|
|
$status = $pageTranslationVisibility->shouldBeHiddenInDefaultLanguage() ? 'danger' : 'success'; |
204
|
|
|
// Create links: |
205
|
|
|
$editUrl = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [ |
206
|
|
|
'edit' => [ |
207
|
|
|
'pages' => [ |
208
|
|
|
$data['row']['uid'] => 'edit' |
209
|
|
|
] |
210
|
|
|
], |
211
|
|
|
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri() |
212
|
|
|
]); |
213
|
|
|
$info = '<a href="#" ' . $previewUriBuilder->serializeDispatcherAttributes() |
214
|
|
|
. ' class="btn btn-default" title="' . $lang->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_viewPage') . '">' . |
215
|
|
|
$this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render() . '</a>'; |
216
|
|
|
$info .= '<a href="' . htmlspecialchars($editUrl) |
217
|
|
|
. '" class="btn btn-default" title="' . $lang->sL( |
218
|
|
|
'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editDefaultLanguagePage' |
219
|
|
|
) . '">' . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render() . '</a>'; |
220
|
|
|
$info .= ' '; |
221
|
|
|
$info .= $pageTranslationVisibility->shouldBeHiddenInDefaultLanguage() ? '<span title="' . htmlspecialchars($lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.1')) . '">D</span>' : ' '; |
222
|
|
|
$info .= $pageTranslationVisibility->shouldHideTranslationIfNoTranslatedRecordExists() ? '<span title="' . htmlspecialchars($lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.2')) . '">N</span>' : ' '; |
223
|
|
|
// Put into cell: |
224
|
|
|
$tCells[] = '<td class="' . $status . ' col-border-left"><div class="btn-group">' . $info . '</div></td>'; |
225
|
|
|
$tCells[] = '<td class="' . $status . '" title="' . $lang->sL( |
226
|
|
|
'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_CEcount' |
227
|
|
|
) . '" align="center">' . $this->getContentElementCount($data['row']['uid'], 0) . '</td>'; |
228
|
|
|
// Traverse system languages: |
229
|
|
|
foreach ($this->siteLanguages as $siteLanguage) { |
230
|
|
|
$languageId = $siteLanguage->getLanguageId(); |
231
|
|
|
if ($languageId === 0) { |
232
|
|
|
continue; |
233
|
|
|
} |
234
|
|
|
if ($this->pObj->MOD_SETTINGS['lang'] == 0 || (int)$this->pObj->MOD_SETTINGS['lang'] === $languageId) { |
235
|
|
|
$row = $this->getLangStatus($data['row']['uid'], $languageId); |
236
|
|
|
if ($pageTranslationVisibility->shouldBeHiddenInDefaultLanguage() || $pageTranslationVisibility->shouldHideTranslationIfNoTranslatedRecordExists()) { |
237
|
|
|
$status = 'danger'; |
238
|
|
|
} else { |
239
|
|
|
$status = ''; |
240
|
|
|
} |
241
|
|
|
if (is_array($row)) { |
242
|
|
|
$langRecUids[$languageId][] = $row['uid']; |
243
|
|
|
if (!$row['_HIDDEN']) { |
244
|
|
|
$status = 'success'; |
245
|
|
|
} |
246
|
|
|
$info = ($showPageId ? ' [' . (int)$row['uid'] . ']' : '') . ' ' . htmlspecialchars( |
247
|
|
|
GeneralUtility::fixed_lgd_cs($row['title'], $titleLen) |
248
|
|
|
) . ((string)$row['nav_title'] !== '' ? ' [Nav: <em>' . htmlspecialchars( |
249
|
|
|
GeneralUtility::fixed_lgd_cs($row['nav_title'], $titleLen) |
250
|
|
|
) . '</em>]' : '') . ($row['_COUNT'] > 1 ? '<div>' . $lang->sL( |
251
|
|
|
'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_badThingThereAre' |
252
|
|
|
) . '</div>' : ''); |
253
|
|
|
$tCells[] = '<td class="' . $status . ' col-border-left">' . |
254
|
|
|
BackendUtility::wrapClickMenuOnIcon($tree->getIcon($row), 'pages', (int)$row['uid']) . |
255
|
|
|
'<a href="#" onclick="' . htmlspecialchars( |
256
|
|
|
'top.loadEditId(' . (int)$data['row']['uid'] . ',"&SET[language]=' . $languageId . '"); return false;' |
257
|
|
|
) . '" title="' . $lang->sL( |
258
|
|
|
'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editPageLang' |
259
|
|
|
) . '">' . $info . '</a></td>'; |
260
|
|
|
// Edit whole record: |
261
|
|
|
// Create links: |
262
|
|
|
$editUrl = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [ |
263
|
|
|
'edit' => [ |
264
|
|
|
'pages' => [ |
265
|
|
|
$row['uid'] => 'edit' |
266
|
|
|
] |
267
|
|
|
], |
268
|
|
|
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri() |
269
|
|
|
]); |
270
|
|
|
$info = str_replace('###LANG_UID###', (string)$languageId, $viewPageLink); |
271
|
|
|
$info .= '<a href="' . htmlspecialchars($editUrl) |
272
|
|
|
. '" class="btn btn-default" title="' . $lang->sL( |
273
|
|
|
'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editLanguageOverlayRecord' |
274
|
|
|
) . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>'; |
275
|
|
|
$tCells[] = '<td class="' . $status . '"><div class="btn-group">' . $info . '</div></td>'; |
276
|
|
|
$tCells[] = '<td class="' . $status . '" title="' . $lang->sL( |
277
|
|
|
'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_CEcount' |
278
|
|
|
) . '" align="center">' . $this->getContentElementCount($data['row']['uid'], $languageId) . '</td>'; |
279
|
|
|
} else { |
280
|
|
|
$info = '<div class="btn-group"><label class="btn btn-default btn-checkbox">'; |
281
|
|
|
$info .= '<input type="checkbox" data-lang="' . $languageId . '" data-uid="' . (int)$data['row']['uid'] . '" name="newOL[' . $languageId . '][' . $data['row']['uid'] . ']" value="1" />'; |
282
|
|
|
$info .= '<span class="t3-icon fa"></span></label></div>'; |
283
|
|
|
$newOL_js[$languageId] .= |
284
|
|
|
' +(document.webinfoForm[' |
285
|
|
|
. GeneralUtility::quoteJSvalue('newOL[' . $languageId . '][' . $data['row']['uid'] . ']') |
286
|
|
|
. '].checked ? ' |
287
|
|
|
. GeneralUtility::quoteJSvalue('&edit[pages][' . $data['row']['uid'] . ']=new') |
288
|
|
|
. ' : \'\')' |
289
|
|
|
; |
290
|
|
|
$tCells[] = '<td class="' . $status . ' col-border-left"> </td>'; |
291
|
|
|
$tCells[] = '<td class="' . $status . '"> </td>'; |
292
|
|
|
$tCells[] = '<td class="' . $status . '">' . $info . '</td>'; |
293
|
|
|
} |
294
|
|
|
} |
295
|
|
|
} |
296
|
|
|
$output .= ' |
297
|
|
|
<tr> |
298
|
|
|
' . implode(' |
299
|
|
|
', $tCells) . ' |
300
|
|
|
</tr>'; |
301
|
|
|
} |
302
|
|
|
// Put together HEADER: |
303
|
|
|
$headerCells = []; |
304
|
|
|
$headerCells[] = '<th>' . $lang->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_page') . '</th>'; |
305
|
|
|
if (is_array($langRecUids[0])) { |
306
|
|
|
$editUrl = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [ |
307
|
|
|
'edit' => [ |
308
|
|
|
'pages' => [ |
309
|
|
|
implode(',', $langRecUids[0]) => 'edit' |
310
|
|
|
] |
311
|
|
|
], |
312
|
|
|
'columnsOnly' => 'title,nav_title,l18n_cfg,hidden', |
313
|
|
|
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri() |
314
|
|
|
]); |
315
|
|
|
$editIco = '<a href="' . htmlspecialchars($editUrl) |
316
|
|
|
. '" class="btn btn-default" title="' . $lang->sL( |
317
|
|
|
'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editPageProperties' |
318
|
|
|
) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>'; |
319
|
|
|
} else { |
320
|
|
|
$editIco = ''; |
321
|
|
|
} |
322
|
|
|
$headerCells[] = '<th class="col-border-left" colspan="2">' . $lang->sL( |
323
|
|
|
'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_default' |
324
|
|
|
) . ' ' . $editIco . '</th>'; |
325
|
|
|
foreach ($this->siteLanguages as $siteLanguage) { |
326
|
|
|
$languageId = $siteLanguage->getLanguageId(); |
327
|
|
|
if ($languageId === 0) { |
328
|
|
|
continue; |
329
|
|
|
} |
330
|
|
|
if ($this->pObj->MOD_SETTINGS['lang'] == 0 || (int)$this->pObj->MOD_SETTINGS['lang'] === $languageId) { |
331
|
|
|
// Title: |
332
|
|
|
$headerCells[] = '<th class="col-border-left">' . htmlspecialchars($siteLanguage->getTitle()) . '</th>'; |
333
|
|
|
// Edit language overlay records: |
334
|
|
|
if (is_array($langRecUids[$languageId])) { |
335
|
|
|
$editUrl = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [ |
336
|
|
|
'edit' => [ |
337
|
|
|
'pages' => [ |
338
|
|
|
implode(',', $langRecUids[$languageId]) => 'edit' |
339
|
|
|
] |
340
|
|
|
], |
341
|
|
|
'columnsOnly' => 'title,nav_title,hidden', |
342
|
|
|
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri() |
343
|
|
|
]); |
344
|
|
|
$editButton = '<a href="' . htmlspecialchars($editUrl) |
345
|
|
|
. '" class="btn btn-default" title="' . $lang->sL( |
346
|
|
|
'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editLangOverlays' |
347
|
|
|
) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>'; |
348
|
|
|
} else { |
349
|
|
|
$editButton = ''; |
350
|
|
|
} |
351
|
|
|
// Create new overlay records: |
352
|
|
|
$createLink = (string)$this->uriBuilder->buildUriFromRoute('tce_db', [ |
353
|
|
|
'redirect' => $request->getAttribute('normalizedParams')->getRequestUri() |
354
|
|
|
]); |
355
|
|
|
$newButton = '<a href="' . htmlspecialchars($createLink) . '" data-edit-url="' . htmlspecialchars($createLink) . '" class="btn btn-default disabled t3js-language-new-' . $languageId . '" title="' . $lang->sL( |
356
|
|
|
'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_getlangsta_createNewTranslationHeaders' |
357
|
|
|
) . '">' . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render() . '</a>'; |
358
|
|
|
|
359
|
|
|
$headerCells[] = '<th class="btn-group">' . $editButton . $newButton . '</th>'; |
360
|
|
|
$headerCells[] = '<th> </th>'; |
361
|
|
|
} |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
$output = |
365
|
|
|
'<div class="table-fit">' . |
366
|
|
|
'<table class="table table-striped table-hover" id="langTable">' . |
367
|
|
|
'<thead>' . |
368
|
|
|
'<tr>' . |
369
|
|
|
implode('', $headerCells) . |
370
|
|
|
'</tr>' . |
371
|
|
|
'</thead>' . |
372
|
|
|
'<tbody>' . |
373
|
|
|
$output . |
374
|
|
|
'</tbody>' . |
375
|
|
|
'</table>' . |
376
|
|
|
'</div>'; |
377
|
|
|
return $output; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* Get an alternative language record for a specific page / language |
382
|
|
|
* |
383
|
|
|
* @param int $pageId Page ID to look up for. |
384
|
|
|
* @param int $langId Language UID to select for. |
385
|
|
|
* @return array translated pages record |
386
|
|
|
*/ |
387
|
|
|
protected function getLangStatus($pageId, $langId) |
388
|
|
|
{ |
389
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
390
|
|
|
->getQueryBuilderForTable('pages'); |
391
|
|
|
$queryBuilder |
392
|
|
|
->getRestrictions() |
393
|
|
|
->removeAll() |
394
|
|
|
->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, (int)$this->getBackendUser()->workspace)) |
395
|
|
|
->add(GeneralUtility::makeInstance(DeletedRestriction::class)); |
396
|
|
|
$result = $queryBuilder |
397
|
|
|
->select('*') |
398
|
|
|
->from('pages') |
399
|
|
|
->where( |
400
|
|
|
$queryBuilder->expr()->eq( |
401
|
|
|
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'], |
402
|
|
|
$queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT) |
403
|
|
|
) |
404
|
|
|
) |
405
|
|
|
->andWhere( |
406
|
|
|
$queryBuilder->expr()->eq( |
407
|
|
|
$GLOBALS['TCA']['pages']['ctrl']['languageField'], |
408
|
|
|
$queryBuilder->createNamedParameter($langId, \PDO::PARAM_INT) |
409
|
|
|
) |
410
|
|
|
) |
411
|
|
|
->execute(); |
412
|
|
|
|
413
|
|
|
$row = $result->fetch(); |
414
|
|
|
BackendUtility::workspaceOL('pages', $row); |
415
|
|
|
if (is_array($row)) { |
416
|
|
|
$row['_COUNT'] = $queryBuilder->count('uid')->execute()->fetchColumn(0); |
417
|
|
|
$row['_HIDDEN'] = $row['hidden'] || (int)$row['endtime'] > 0 && (int)$row['endtime'] < $GLOBALS['EXEC_TIME'] || $GLOBALS['EXEC_TIME'] < (int)$row['starttime']; |
418
|
|
|
} |
419
|
|
|
$result->closeCursor(); |
420
|
|
|
return $row; |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
/** |
424
|
|
|
* Counting content elements for a single language on a page. |
425
|
|
|
* |
426
|
|
|
* @param int $pageId Page id to select for. |
427
|
|
|
* @param int $sysLang Sys language uid |
428
|
|
|
* @return int Number of content elements from the PID where the language is set to a certain value. |
429
|
|
|
*/ |
430
|
|
|
protected function getContentElementCount($pageId, $sysLang) |
431
|
|
|
{ |
432
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
433
|
|
|
->getQueryBuilderForTable('tt_content'); |
434
|
|
|
$queryBuilder->getRestrictions() |
435
|
|
|
->removeAll() |
436
|
|
|
->add(GeneralUtility::makeInstance(DeletedRestriction::class)) |
437
|
|
|
->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, (int)$this->getBackendUser()->workspace)); |
438
|
|
|
$count = $queryBuilder |
439
|
|
|
->count('uid') |
440
|
|
|
->from('tt_content') |
441
|
|
|
->where( |
442
|
|
|
$queryBuilder->expr()->eq( |
443
|
|
|
'pid', |
444
|
|
|
$queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT) |
445
|
|
|
) |
446
|
|
|
) |
447
|
|
|
->andWhere( |
448
|
|
|
$queryBuilder->expr()->eq( |
449
|
|
|
'sys_language_uid', |
450
|
|
|
$queryBuilder->createNamedParameter($sysLang, \PDO::PARAM_INT) |
451
|
|
|
) |
452
|
|
|
) |
453
|
|
|
->execute() |
454
|
|
|
->fetchColumn(0); |
455
|
|
|
return $count ?: '-'; |
|
|
|
|
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
/** |
459
|
|
|
* Since the controller does not access the current request yet, we'll do it "old school" |
460
|
|
|
* to fetch the Site based on the current ID. |
461
|
|
|
*/ |
462
|
|
|
protected function initializeSiteLanguages(ServerRequestInterface $request) |
463
|
|
|
{ |
464
|
|
|
/** @var SiteInterface $currentSite */ |
465
|
|
|
$currentSite = $request->getAttribute('site'); |
466
|
|
|
$this->siteLanguages = $currentSite->getAvailableLanguages($this->getBackendUser(), false, (int)$this->id); |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* @return LanguageService |
471
|
|
|
*/ |
472
|
|
|
protected function getLanguageService(): LanguageService |
473
|
|
|
{ |
474
|
|
|
return $GLOBALS['LANG']; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* Returns the current BE user. |
479
|
|
|
* |
480
|
|
|
* @return BackendUserAuthentication |
481
|
|
|
*/ |
482
|
|
|
protected function getBackendUser(): BackendUserAuthentication |
483
|
|
|
{ |
484
|
|
|
return $GLOBALS['BE_USER']; |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* @return PageRenderer |
489
|
|
|
*/ |
490
|
|
|
protected function getPageRenderer(): PageRenderer |
491
|
|
|
{ |
492
|
|
|
return GeneralUtility::makeInstance(PageRenderer::class); |
493
|
|
|
} |
494
|
|
|
} |
495
|
|
|
|