$definition */ public function __construct( protected readonly PageLayoutContext $context, protected readonly array $definition, protected readonly string $table = 'tt_content' ) { $this->columnNumber = isset($definition['colPos']) ? (int)$definition['colPos'] : null; $this->columnName = (string)($definition['name'] ?? 'default'); $this->icon = (string)($definition['icon'] ?? ''); $this->colSpan = (int)($definition['colspan'] ?? 1); $this->rowSpan = (int)($definition['rowspan'] ?? 1); $this->identifier = isset($definition['identifier']) ? (string)$definition['identifier'] : null; $this->slideMode = ContentSlideMode::tryFrom($definition['slideMode'] ?? null); } public function getContext(): PageLayoutContext { return $this->context; } /** * @return array */ public function getDefinition(): array { return $this->definition; } public function isActive(): bool { return $this->columnNumber !== null && in_array($this->columnNumber, $this->context->getDrawingConfiguration()->getActiveColumns()); } public function addItem(GridColumnItem $item): void { $this->items[] = $item; } /** * @return GridColumnItem[] */ public function getItems(): iterable { return $this->items; } public function getColumnNumber(): ?int { return $this->columnNumber; } public function getColumnName(): string { return $this->columnName; } public function getIcon(): string { return $this->icon; } public function getColSpan(): int { if ($this->context->getDrawingConfiguration()->isLanguageComparisonMode()) { return 1; } return $this->colSpan; } public function getRowSpan(): int { if ($this->context->getDrawingConfiguration()->isLanguageComparisonMode()) { return 1; } return $this->rowSpan; } public function getIdentifier(): ?string { return $this->identifier; } public function getIdentifierCleaned(): string { return strtolower((string)preg_replace('/[^a-zA-Z0-9_-]/', '', (string)$this->identifier)); } public function getSlideMode(): ContentSlideMode { return $this->slideMode; } /** * @return int[] */ public function getAllContainedItemUids(): array { $uids = []; foreach ($this->items as $columnItem) { $uids[] = $columnItem->getRecord()->getUid(); } return $uids; } public function getEditUrl(): ?string { if (empty($this->items)) { return null; } $pageRecord = $this->context->getPageRecord(); if (!$this->getBackendUser()->doesUserHaveAccess($pageRecord, Permission::CONTENT_EDIT) || !$this->getBackendUser()->checkLanguageAccess($this->context->getSiteLanguage())) { return null; } $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); return (string)$uriBuilder->buildUriFromRoute('record_edit', [ 'edit' => [ $this->table => [ implode(',', $this->getAllContainedItemUids()) => 'edit', ], ], 'module' => 'web_layout', 'returnUrl' => $this->context->getReturnUrl(), ]); } public function getNewContentUrl(): string { $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $pageId = $this->context->getPageId(); return (string)$uriBuilder->buildUriFromRoute('new_content_element_wizard', [ 'id' => $pageId, 'sys_language_uid' => $this->context->getSiteLanguage()->getLanguageId(), 'colPos' => $this->getColumnNumber(), 'uid_pid' => $pageId, 'returnUrl' => $this->context->getReturnUrl(), ]); } public function getTitle(): string { $columnNumber = $this->getColumnNumber(); $colTitle = ''; foreach ($this->context->getBackendLayout()->getUsedColumns() as $colPos => $title) { if ($colPos === $columnNumber) { $colTitle = $this->getLanguageService()->sL($title); } } return $colTitle; } public function getTitleInaccessible(): string { return $this->getLanguageService()->sL($this->columnName) . ' (' . $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:noAccess') . ')'; } public function getTitleUnassigned(): string { return $this->getLanguageService()->sL($this->columnName) . ' (' . $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:notAssigned') . ')'; } public function isUnassigned(): bool { return $this->columnName !== 'unused' && $this->columnNumber === null; } public function isUnused(): bool { return $this->columnName === 'unused' && $this->columnNumber === null; } public function isContentEditable(): bool { if ($this->columnName === 'unused' || $this->columnNumber === null) { return false; } if ($this->getBackendUser()->isAdmin()) { return true; } $pageRecord = $this->context->getPageRecord(); return $this->getBackendUser()->doesUserHaveAccess($pageRecord, Permission::CONTENT_EDIT) && $this->getBackendUser()->checkLanguageAccess($this->context->getSiteLanguage()) && ( !($pagesSchema = GeneralUtility::makeInstance(TcaSchemaFactory::class)->get('pages'))->hasCapability(TcaSchemaCapability::EditLock) || !($pageRecord[$pagesSchema->getCapability(TcaSchemaCapability::EditLock)->getFieldName()] ?? false) ); } protected function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } protected function getBackendUser(): BackendUserAuthentication { return $GLOBALS['BE_USER']; } }