<html
    xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
    xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
    xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
    data-namespace-typo3-fluid="true"
>

<div class="t3-grid-container{f:if(condition: context.backendLayout.identifierCleaned, then: ' t3-grid-container-{context.backendLayout.identifierCleaned}')}" data-multi-languages="{f:if(condition: context.multiLanguages, then: '1', else: '0')}">
    <div class="t3-grid-container-inner">
        <table class="t3-page-columns t3-grid-table t3js-page-columns">
            <tr>
                <f:for each="{languageColumns}" as="languageColumn">
                    <td valign="top"
                        class="t3-page-column t3-page-column-lang-name"
                        data-language-uid="{languageColumn.context.siteLanguage.languageId}"
                        data-language-title="{languageColumn.context.siteLanguage.title}"
                        data-flag-identifier="{languageColumn.context.siteLanguage.flagIdentifier}"
                    >
                        <typo3-backend-editable-page-title
                            pageTitle="{languageColumn.context.localizedPageTitle}"
                            pageId="{context.pageId}"
                            localizedPageId="{languageColumn.pageRecordUid}"
                            {languageColumn.allowEditPage ? 'editable' : ''}
                        >
                            {languageColumn.context.localizedPageTitle}
                        </typo3-backend-editable-page-title>
                        <div>
                            <core:iconForRecord table="pages" row="{languageColumn.pageRecord}" />
                            <core:icon identifier="{languageColumn.context.siteLanguage.flagIdentifier}" />
                            {languageColumn.context.siteLanguage.title}
                            <f:if condition="{languageColumn.context.languageMode}">
                                <span class="badge badge-{languageColumn.context.languageModeLabelClass}">{languageColumn.context.languageMode}</span>
                            </f:if>
                            <f:if condition="{languageColumn.translationData.hasElementsWithWorkspaceDeletePlaceholders}">
                                <span class="badge badge-warning"
                                    data-bs-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:languageContainsWorkspaceDeletePlaceholderRecords')}"
                                    data-bs-toggle="popover"
                                    data-bs-placement="auto"
                                    data-bs-trigger="hover focus"
                                >
                                    !
                                </span>
                            </f:if>
                        </div>
                        <div class="mt-2">
                            <f:if condition="{languageColumn.allowViewPage}">
                                <button class="btn btn-default btn-sm" {f:if(condition: languageColumn.previewUrlAttributes, then: '{languageColumn.previewUrlAttributes -> f:format.raw()}', else: 'disabled="true"')} title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')}">
                                    <core:icon identifier="actions-view" />
                                    <f:translate key="LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage" />
                                </button>
                            </f:if>
                            <f:if condition="{languageColumn.allowEditPage}">
                                <typo3-backend-contextual-record-edit-trigger
                                    url="{languageColumn.pageEditUrl}"
                                    edit-url="{languageColumn.fullPageEditUrl}"
                                    class="btn btn-default btn-sm"
                                    title="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:editPageProperties')}"
                                >
                                    <core:icon identifier="actions-open" />
                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:editPageProperties" />
                                </typo3-backend-contextual-record-edit-trigger>
                            </f:if>
                            <f:if condition="{allowEditContent} && {languageColumn.context.siteLanguage.languageId} && {languageColumn.translationData.untranslatedRecordUids}">
                                <typo3-backend-localization-button
                                    class="btn btn-default btn-sm"
                                    title="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:newPageContent_translate')}"
                                    record-type="pages"
                                    record-uid="{context.pageId}"
                                    target-language="{languageColumn.context.siteLanguage.languageId}"
                                >
                                    <core:icon identifier="actions-localize" />
                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:localize.wizard.button.translate" />
                                </typo3-backend-localization-button>
                            </f:if>
                        </div>
                    </td>
                </f:for>
            </tr>
            <f:if condition="{context.multiLanguages}">
                <f:then>
                    <f:variable name="grid" value="{languageColumns.0.grid}" />
                    <f:for each="{context.drawingConfiguration.activeColumns}" as="columnNumber">
                        <tr>
                            <f:for each="{languageColumns}" as="languageColumn">
                                <f:variable name="column" value="{be:languageColumn(languageColumn: languageColumn, columnNumber: columnNumber)}" />
                                <td valign="top"
                                    data-colpos="{column.columnNumber}" data-language-uid="{column.context.siteLanguage.languageId}"
                                    class="t3-grid-cell t3-page-column t3js-page-column {f:if(condition: column.identifierCleaned, then: 't3-grid-cell-{column.identifierCleaned}')}">
                                    <f:alias map="{columnHeaderLevel: 3}">
                                        <f:render partial="PageLayout/Grid/ColumnHeader" arguments="{_all}" />
                                    </f:alias>
                                </td>
                            </f:for>
                        </tr>
                        <f:variable name="column" value="{be:languageColumn(languageColumn: languageColumns.0, columnNumber: columnNumber)}" />
                        <f:for each="{column.items}" as="gridItem" iteration="itemIterator">
                            <tr>
                                <td class="t3-grid-cell t3js-page-column {f:if(condition: column.identifierCleaned, then: 't3-grid-cell-{column.identifierCleaned}')}" valign="top" data-colpos="{column.columnNumber}">
                                    <f:variable name="column" value="{be:languageColumn(languageColumn: languageColumns.0, columnNumber: columnNumber)}" />
                                    <f:variable name="item" value="{gridItem}" />
                                    <f:render partial="PageLayout/Record" arguments="{_all}" />
                                </td>
                                <f:for each="{languageColumns}" as="languageColumn">
                                    <f:if condition="{languageColumn.context.siteLanguage.languageId} > 0">
                                        <f:variable name="column" value="{be:languageColumn(languageColumn: languageColumn, columnNumber: columnNumber)}" />
                                        <td class="t3-grid-cell t3js-page-column {f:if(condition: column.identifierCleaned, then: 't3-grid-cell-{column.identifierCleaned}')}" valign="top" data-colpos="{column.columnNumber}">
                                            <f:variable name="languageId" value="{languageColumn.context.siteLanguage.languageId}" />
                                            <f:if condition="{languageColumn.translationData.mode} == 'connected'">
                                                <f:then>
                                                    <f:if condition="{gridItem.translations.{languageId}}">
                                                        <f:variable name="item" value="{gridItem.translations.{languageId}}" />
                                                        <f:render partial="PageLayout/Record" arguments="{_all}" />
                                                    </f:if>
                                                </f:then>
                                                <f:else>
                                                    <f:if condition="{itemIterator.isFirst}">
                                                        <f:variable name="languageColumnNonConnected">{languageColumns.{languageId}}</f:variable>
                                                        <f:variable name="column" value="{be:languageColumn(languageColumn: languageColumnNonConnected, columnNumber: columnNumber)}" />
                                                        <f:for each="{column.items}" as="item">
                                                            <f:render partial="PageLayout/Record" arguments="{_all}" />
                                                        </f:for>
                                                    </f:if>
                                                </f:else>
                                            </f:if>
                                        </td>
                                    </f:if>
                                </f:for>
                            </tr>
                        </f:for>
                    </f:for>
                </f:then>
                <f:else>
                    <f:for each="{context.drawingConfiguration.activeColumns}" as="columnNumber">
                        <tr>
                            <f:for each="{languageColumns}" as="languageColumn">
                                <f:if condition="{languageColumn.grid.columns}">
                                    <f:variable name="grid" value="{languageColumn.grid}" />
                                    <f:variable name="column" value="{be:languageColumn(languageColumn: languageColumn, columnNumber: columnNumber)}" />
                                    <f:render partial="PageLayout/Grid/Column" arguments="{_all}" />
                                </f:if>
                            </f:for>
                        </tr>
                    </f:for>
                </f:else>
            </f:if>
        </table>
    </div>
</div>
</html>
