‪TYPO3CMS  ‪main
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;
24 use TYPO3\CMS\Core\Imaging\IconSize;
27 
46 {
47  public function ‪__construct(
48  protected ‪PageLayoutContext $context,
49  protected readonly ‪Grid $grid,
50  protected readonly array $translationInfo
51  ) {
52  parent::__construct($context);
53  }
54 
55  public function ‪getGrid(): ‪Grid
56  {
57  return $this->grid;
58  }
59 
60  public function ‪getPageIcon(): string
61  {
62  $localizedPageRecord = $this->context->getLocalizedPageRecord() ?? $this->context->getPageRecord();
63  return BackendUtility::wrapClickMenuOnIcon(
64  $this->iconFactory->getIconForRecord('pages', $localizedPageRecord, IconSize::SMALL)->render(),
65  'pages',
66  $localizedPageRecord['uid']
67  );
68  }
69 
70  public function ‪getAllowTranslate(): bool
71  {
72  return $this->context->getDrawingConfiguration()->translateModeForTranslationsAllowed() && !($this->‪getTranslationData()['hasStandAloneContent'] ?? false);
73  }
74 
75  public function ‪getTranslationData(): array
76  {
77  return $this->translationInfo;
78  }
79 
80  public function ‪getAllowTranslateCopy(): bool
81  {
82  return $this->context->getDrawingConfiguration()->copyModeForTranslationsAllowed() && !($this->‪getTranslationData()['hasTranslations'] ?? false);
83  }
84 
85  public function ‪getAllowEditPage(): bool
86  {
87  return $this->‪getBackendUser()->check('tables_modify', 'pages')
88  && $this->‪getBackendUser()->checkLanguageAccess($this->context->getSiteLanguage());
89  }
90 
91  public function ‪getPageEditUrl(): string
92  {
93  $pageRecordUid = $this->context->getLocalizedPageRecord()['uid'] ?? $this->context->getPageRecord()['uid'];
94  $urlParameters = [
95  'edit' => [
96  'pages' => [
97  $pageRecordUid => 'edit',
98  ],
99  ],
100  'returnUrl' => $this->context->getCurrentRequest()->getAttribute('normalizedParams')->getRequestUri(),
101  ];
102  // Disallow manual adjustment of the language field for pages
103  if (($languageField = ‪$GLOBALS['TCA']['pages']['ctrl']['languageField'] ?? '') !== '') {
104  $urlParameters['overrideVals']['pages'][$languageField] = $this->context->getSiteLanguage()->getLanguageId();
105  }
106  return (string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit', $urlParameters);
107  }
108 
109  public function ‪getAllowViewPage(): bool
110  {
111  return VersionState::tryFrom($this->context->getPageRecord()['t3ver_state'] ?? 0) !== VersionState::DELETE_PLACEHOLDER;
112  }
113 
114  public function ‪getPreviewUrlAttributes(): string
115  {
116  $pageId = $this->context->getPageId();
117  $languageId = $this->context->getSiteLanguage()->getLanguageId();
118  return (string)‪PreviewUriBuilder::create($pageId)
119  ->withRootLine(BackendUtility::BEgetRootLine($pageId))
120  ->withLanguage($languageId)
121  ->serializeDispatcherAttributes();
122  }
123 }
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\Grid
Definition: Grid.php:39
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\AbstractGridObject
Definition: AbstractGridObject.php:40
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getAllowViewPage
‪getAllowViewPage()
Definition: LanguageColumn.php:109
‪TYPO3\CMS\Core\Versioning\VersionState
‪VersionState
Definition: VersionState.php:22
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getAllowEditPage
‪getAllowEditPage()
Definition: LanguageColumn.php:85
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getGrid
‪getGrid()
Definition: LanguageColumn.php:55
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getAllowTranslate
‪getAllowTranslate()
Definition: LanguageColumn.php:70
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getTranslationData
‪getTranslationData()
Definition: LanguageColumn.php:75
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\AbstractGridObject\getBackendUser
‪getBackendUser()
Definition: AbstractGridObject.php:58
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:44
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getPageEditUrl
‪getPageEditUrl()
Definition: LanguageColumn.php:91
‪TYPO3\CMS\Backend\Routing\PreviewUriBuilder\create
‪static static create(int $pageId)
Definition: PreviewUriBuilder.php:65
‪TYPO3\CMS\Backend\View\BackendLayout\Grid
Definition: AbstractGridObject.php:18
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getPageIcon
‪getPageIcon()
Definition: LanguageColumn.php:60
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\__construct
‪__construct(protected PageLayoutContext $context, protected readonly Grid $grid, protected readonly array $translationInfo)
Definition: LanguageColumn.php:47
‪TYPO3\CMS\Backend\View\PageLayoutContext
Definition: PageLayoutContext.php:42
‪TYPO3\CMS\Backend\Routing\PreviewUriBuilder
Definition: PreviewUriBuilder.php:44
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn
Definition: LanguageColumn.php:46
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getPreviewUrlAttributes
‪getPreviewUrlAttributes()
Definition: LanguageColumn.php:114
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn\getAllowTranslateCopy
‪getAllowTranslateCopy()
Definition: LanguageColumn.php:80