|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the TYPO3 CMS project. |
|
7
|
|
|
* |
|
8
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
9
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
10
|
|
|
* of the License, or any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* For the full copyright and license information, please read the |
|
13
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
14
|
|
|
* |
|
15
|
|
|
* The TYPO3 project - inspiring people to share! |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace TYPO3\CMS\Backend\View\BackendLayout\Grid; |
|
19
|
|
|
|
|
20
|
|
|
use TYPO3\CMS\Backend\Routing\PreviewUriBuilder; |
|
21
|
|
|
use TYPO3\CMS\Backend\Routing\UriBuilder; |
|
22
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
|
23
|
|
|
use TYPO3\CMS\Backend\View\PageLayoutContext; |
|
24
|
|
|
use TYPO3\CMS\Core\Imaging\Icon; |
|
25
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
26
|
|
|
use TYPO3\CMS\Core\Versioning\VersionState; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Language Column |
|
30
|
|
|
* |
|
31
|
|
|
* Object representation of a site language selected in the "page" module |
|
32
|
|
|
* to show translations of content elements. |
|
33
|
|
|
* |
|
34
|
|
|
* Contains getter methods to return various values associated with a single |
|
35
|
|
|
* language, e.g. localized page title, associated SiteLanguage instance, |
|
36
|
|
|
* edit URLs and link titles and so on. |
|
37
|
|
|
* |
|
38
|
|
|
* Stores a duplicated Grid object associated with the SiteLanguage. |
|
39
|
|
|
* |
|
40
|
|
|
* Accessed from Fluid templates - generated from within BackendLayout when |
|
41
|
|
|
* "page" module is in "languages" mode. |
|
42
|
|
|
* |
|
43
|
|
|
* @internal this is experimental and subject to change in TYPO3 v10 / v11 |
|
44
|
|
|
*/ |
|
45
|
|
|
class LanguageColumn extends AbstractGridObject |
|
46
|
|
|
{ |
|
47
|
|
|
/** |
|
48
|
|
|
* @var array |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $localizationConfiguration = []; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var Grid|null |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $grid; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var array |
|
59
|
|
|
*/ |
|
60
|
|
|
protected $translationInfo = [ |
|
61
|
|
|
'hasStandaloneContent' => false, |
|
62
|
|
|
'hasTranslations' => false, |
|
63
|
|
|
'untranslatedRecordUids' => [], |
|
64
|
|
|
]; |
|
65
|
|
|
|
|
66
|
|
|
public function __construct(PageLayoutContext $context, Grid $grid, array $translationInfo) |
|
67
|
|
|
{ |
|
68
|
|
|
parent::__construct($context); |
|
69
|
|
|
$this->localizationConfiguration = BackendUtility::getPagesTSconfig($context->getPageId())['mod.']['web_layout.']['localization.'] ?? []; |
|
70
|
|
|
$this->grid = $grid; |
|
71
|
|
|
$this->translationInfo = $translationInfo; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function getGrid(): ?Grid |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->grid; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function getPageIcon(): string |
|
80
|
|
|
{ |
|
81
|
|
|
$localizedPageRecord = $this->context->getLocalizedPageRecord() ?? $this->context->getPageRecord(); |
|
82
|
|
|
return BackendUtility::wrapClickMenuOnIcon( |
|
83
|
|
|
$this->iconFactory->getIconForRecord('pages', $localizedPageRecord, Icon::SIZE_SMALL)->render(), |
|
84
|
|
|
'pages', |
|
85
|
|
|
$localizedPageRecord['uid'] |
|
86
|
|
|
); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function getAllowTranslate(): bool |
|
90
|
|
|
{ |
|
91
|
|
|
return ($this->localizationConfiguration['enableTranslate'] ?? true) && !($this->getTranslationData()['hasStandAloneContent'] ?? false); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function getTranslationData(): array |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->translationInfo; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function getAllowTranslateCopy(): bool |
|
100
|
|
|
{ |
|
101
|
|
|
return ($this->localizationConfiguration['enableCopy'] ?? true) && !($this->getTranslationData()['hasTranslations'] ?? false); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function getTranslatePageTitle(): string |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->getLanguageService()->getLL('newPageContent_translate'); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function getAllowEditPage(): bool |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->getBackendUser()->check('tables_modify', 'pages'); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function getPageEditTitle(): string |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->getLanguageService()->getLL('edit'); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function getPageEditUrl(): string |
|
120
|
|
|
{ |
|
121
|
|
|
$pageRecordUid = $this->context->getLocalizedPageRecord()['uid'] ?? $this->context->getPageRecord()['uid']; |
|
122
|
|
|
$urlParameters = [ |
|
123
|
|
|
'edit' => [ |
|
124
|
|
|
'pages' => [ |
|
125
|
|
|
$pageRecordUid => 'edit' |
|
126
|
|
|
] |
|
127
|
|
|
], |
|
128
|
|
|
// Disallow manual adjustment of the language field for pages |
|
129
|
|
|
'overrideVals' => [ |
|
130
|
|
|
'pages' => [ |
|
131
|
|
|
'sys_language_uid' => $this->context->getSiteLanguage()->getLanguageId() |
|
132
|
|
|
] |
|
133
|
|
|
], |
|
134
|
|
|
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') |
|
135
|
|
|
]; |
|
136
|
|
|
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); |
|
137
|
|
|
return (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
public function getAllowViewPage(): bool |
|
141
|
|
|
{ |
|
142
|
|
|
return !VersionState::cast($this->context->getPageRecord()['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
public function getViewPageLinkTitle(): string |
|
146
|
|
|
{ |
|
147
|
|
|
return $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage'); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
public function getPreviewUrlAttributes(): string |
|
151
|
|
|
{ |
|
152
|
|
|
$pageId = $this->context->getPageId(); |
|
153
|
|
|
$languageId = $this->context->getSiteLanguage()->getLanguageId(); |
|
154
|
|
|
return PreviewUriBuilder::create($pageId) |
|
|
|
|
|
|
155
|
|
|
->withRootLine(BackendUtility::BEgetRootLine($pageId)) |
|
156
|
|
|
->withAdditionalQueryParameters('&L=' . $languageId) |
|
157
|
|
|
->serializeDispatcherAttributes(); |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
|