Skip to content

Commit f7670f3

Browse files
authored
Merge pull request #5 from punktDe/AddPageTranslationsSupport
[TASK] Add support for translated pages, update version
2 parents 6e443f8 + 3ccb0ba commit f7670f3

File tree

4 files changed

+60
-7
lines changed

4 files changed

+60
-7
lines changed

Classes/Backend/PageLayoutHeader.php

+52-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PageLayoutHeader
2626
protected $backendUser;
2727

2828
/**
29-
* @var integer
29+
* @var int
3030
*/
3131
protected $pageUid;
3232

@@ -35,13 +35,41 @@ class PageLayoutHeader
3535
*/
3636
protected $pageRecord;
3737

38+
/**
39+
* @var int
40+
*/
41+
protected $language;
42+
3843

3944

4045
public function __construct()
4146
{
4247
$this->backendUser = $GLOBALS['BE_USER'];
4348
$this->pageUid = (int)GeneralUtility::_GET('id');
4449
$this->pageRecord = BackendUtility::getRecord('pages', $this->pageUid);
50+
$this->language = (int)BackendUtility::getModuleData(['language'], [], 'web_layout')['language'];
51+
52+
$this->updatePageRecordIfOverlay();
53+
}
54+
55+
56+
57+
/**
58+
*
59+
*/
60+
protected function updatePageRecordIfOverlay(): void
61+
{
62+
if ($this->language > 0) {
63+
$overlayRecords = BackendUtility::getRecordLocalization(
64+
'pages',
65+
$this->pageUid,
66+
$this->language
67+
);
68+
69+
if (is_array($overlayRecords) && array_key_exists(0, $overlayRecords) && is_array($overlayRecords[0])) {
70+
$this->pageRecord = $overlayRecords[0];
71+
}
72+
}
4573
}
4674

4775

@@ -60,7 +88,7 @@ public function render(): string
6088
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Quickedit/Quickedit');
6189

6290
$standaloneView = $this->initializeStandaloneView();
63-
$standaloneView->assign('pageId', $this->pageUid);
91+
$standaloneView->assign('pageId', $this->pageRecord['uid']);
6492
$standaloneView->assign('config', $this->getFieldConfigForPage());
6593
$standaloneView->assign('isVisible', $this->isVisible());
6694

@@ -198,7 +226,8 @@ protected function prepareFieldsList(string $fields): string
198226
$fieldsArray = array_map('trim', $fieldsArray);
199227

200228
foreach ($fieldsArray as $index => $field) {
201-
if ($this->userHasAccessToField($field) === false) {
229+
if ($this->userHasAccessToField($field) === false
230+
|| $this->fieldIsAvailableForLanguage($field) === false) {
202231
unset($fieldsArray[$index]);
203232
}
204233
}
@@ -222,6 +251,24 @@ protected function userHasAccessToField(string $field): bool
222251

223252

224253

254+
/**
255+
* @param string $field
256+
* @return bool
257+
*/
258+
protected function fieldIsAvailableForLanguage(string $field): bool
259+
{
260+
if ($this->language > 0) {
261+
return $field !== '' && (
262+
!array_key_exists('l10n_mode', $GLOBALS['TCA']['pages']['columns'][$field]) ||
263+
$GLOBALS['TCA']['pages']['columns'][$field]['l10n_mode'] !== 'exclude'
264+
);
265+
}
266+
267+
return true;
268+
}
269+
270+
271+
225272
/**
226273
* Checks set previewFields and get the corresponding field labels and values for display in backend.
227274
*
@@ -284,8 +331,8 @@ protected function isVisible(): bool
284331

285332
if (array_key_exists('quickedit', $this->backendUser->uc) &&
286333
array_key_exists('visible', $this->backendUser->uc['quickedit']) &&
287-
array_key_exists($this->pageUid, $this->backendUser->uc['quickedit']['visible'])) {
288-
$isVisible = (bool)$this->backendUser->uc['quickedit']['visible'][$this->pageUid];
334+
array_key_exists($this->pageRecord['uid'], $this->backendUser->uc['quickedit']['visible'])) {
335+
$isVisible = (bool)$this->backendUser->uc['quickedit']['visible'][$this->pageRecord['uid']];
289336
}
290337

291338
return $isVisible;

Documentation/Changelog/Index.rst

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
Change log
77
==========
88

9+
Version 0.2.0
10+
-------------
11+
12+
- Add extension key to composer.json file
13+
- Add support for using toolbar with page translations
14+
915
Version 0.1.1
1016
-------------
1117

Documentation/Settings.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ project = Quickedit
2525
# ... (recommended) version, displayed next to title (desktop) and in <meta name="book-version"
2626
# .................................................................................
2727

28-
release = 0.1.1
28+
release = 0.2.0
2929

3030
# .................................................................................
3131
# ... (recommended) displayed in footer

ext_emconf.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$EM_CONF[$_EXTKEY] = [
33
'title' => 'Toolbar for editing page properties',
44
'description' => 'This extension provides a configurable toolbar for editing page properties.',
5-
'version' => '0.1.1',
5+
'version' => '0.2.0',
66
'category' => 'be',
77
'constraints' => [
88
'depends' => [

0 commit comments

Comments
 (0)