‪TYPO3CMS  11.5
LanguageColumn.php
Go to the documentation of this file.
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 
19 
22 use TYPO3\CMS\Backend\Utility\BackendUtility;
27 
46 {
50  protected ‪$localizationConfiguration = [];
51 
55  protected ‪$grid;
56 
60  protected ‪$translationInfo = [
61  'hasStandaloneContent' => false,
62  'hasTranslations' => false,
63  'untranslatedRecordUids' => [],
64  ];
65 
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  {
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  {
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  && $this->‪getBackendUser()->checkLanguageAccess($this->context->getSiteLanguage()->getLanguageId());
113  }
114 
115  public function ‪getPageEditTitle(): string
116  {
117  return $this->‪getLanguageService()->getLL('edit');
118  }
119 
120  public function ‪getPageEditUrl(): string
121  {
122  $pageRecordUid = $this->context->getLocalizedPageRecord()['uid'] ?? $this->context->getPageRecord()['uid'];
123  $urlParameters = [
124  'edit' => [
125  'pages' => [
126  $pageRecordUid => 'edit',
127  ],
128  ],
129  // Disallow manual adjustment of the language field for pages
130  'overrideVals' => [
131  'pages' => [
132  'sys_language_uid' => $this->context->getSiteLanguage()->getLanguageId(),
133  ],
134  ],
135  'returnUrl' => ‪$GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri(),
136  ];
137  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
138  return (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
139  }
140 
141  public function ‪getAllowViewPage(): bool
142  {
143  return !‪VersionState::cast($this->context->getPageRecord()['t3ver_state'])->equals(‪VersionState::DELETE_PLACEHOLDER);
144  }
145 
146  public function ‪getViewPageLinkTitle(): string
147  {
148  return $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage');
149  }
150 
151  public function ‪getPreviewUrlAttributes(): string
152  {
153  $pageId = $this->context->getPageId();
154  $languageId = $this->context->getSiteLanguage()->getLanguageId();
155  return (string)‪PreviewUriBuilder::create($pageId)
156  ->withRootLine(BackendUtility::BEgetRootLine($pageId))
157  ->withAdditionalQueryParameters('&L=' . $languageId)
158  ->serializeDispatcherAttributes();
159  }
160 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\Grid
Definition: Grid.php:39
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\AbstractGridObject
Definition: AbstractGridObject.php:41
‪TYPO3\CMS\Backend\Routing\PreviewUriBuilder\create
‪static static create(int $pageId, string $alternativeUri=null)
Definition: PreviewUriBuilder.php:75
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getAllowViewPage
‪getAllowViewPage()
Definition: LanguageColumn.php:138
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getAllowEditPage
‪getAllowEditPage()
Definition: LanguageColumn.php:106
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getGrid
‪getGrid()
Definition: LanguageColumn.php:71
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\$localizationConfiguration
‪array $localizationConfiguration
Definition: LanguageColumn.php:49
‪TYPO3\CMS\Core\Versioning\VersionState\DELETE_PLACEHOLDER
‪const DELETE_PLACEHOLDER
Definition: VersionState.php:61
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\AbstractGridObject\$context
‪PageLayoutContext $context
Definition: AbstractGridObject.php:44
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getTranslatePageTitle
‪getTranslatePageTitle()
Definition: LanguageColumn.php:101
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getViewPageLinkTitle
‪getViewPageLinkTitle()
Definition: LanguageColumn.php:143
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\$translationInfo
‪array $translationInfo
Definition: LanguageColumn.php:57
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getAllowTranslate
‪getAllowTranslate()
Definition: LanguageColumn.php:86
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getPageEditTitle
‪getPageEditTitle()
Definition: LanguageColumn.php:112
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getTranslationData
‪getTranslationData()
Definition: LanguageColumn.php:91
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\AbstractGridObject\getBackendUser
‪getBackendUser()
Definition: AbstractGridObject.php:71
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:40
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getPageEditUrl
‪getPageEditUrl()
Definition: LanguageColumn.php:117
‪TYPO3\CMS\Backend\View\BackendLayout\Grid
Definition: AbstractGridObject.php:18
‪TYPO3\CMS\Core\Versioning\VersionState
Definition: VersionState.php:24
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\__construct
‪__construct(PageLayoutContext $context, Grid $grid, array $translationInfo)
Definition: LanguageColumn.php:63
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getPageIcon
‪getPageIcon()
Definition: LanguageColumn.php:76
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\View\PageLayoutContext
Definition: PageLayoutContext.php:43
‪TYPO3\CMS\Backend\View\PageLayoutContext\getPageId
‪getPageId()
Definition: PageLayoutContext.php:164
‪TYPO3\CMS\Backend\Routing\PreviewUriBuilder
Definition: PreviewUriBuilder.php:32
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn
Definition: LanguageColumn.php:46
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getPreviewUrlAttributes
‪getPreviewUrlAttributes()
Definition: LanguageColumn.php:148
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\AbstractGridObject\getLanguageService
‪getLanguageService()
Definition: AbstractGridObject.php:66
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getAllowTranslateCopy
‪getAllowTranslateCopy()
Definition: LanguageColumn.php:96
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\$grid
‪Grid null $grid
Definition: LanguageColumn.php:53