<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"
>

<f:layout name="Module" />

<f:section name="Content">

    <f:be.pageRenderer
        includeJavaScriptModules="{
            0:'@typo3/backend/context-menu.js',
            1:'@typo3/backend/modal.js',
            2:'@typo3/backend/tooltip.js'
        }"
    />

    <h1>
        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:title" />
    </h1>

    <f:if condition="{isInWorkspace}">
        <f:then>
            <f:be.infobox
                title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:notAvailableInWorkspace.title')}"
                message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:notAvailableInWorkspace.message')}"
                state="-1"
            />
        </f:then>
        <f:else>
            <f:if condition="{subPages}">
                <f:then>
                    <f:if condition="{hasInvisiblePage}">
                        <f:be.infobox
                            title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:hasInvisiblePage.title')}"
                            message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:hasInvisiblePage.message')}"
                            state="-1"
                        />
                    </f:if>

                    <h2>
                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:currentPageOrder" />
                    </h2>

                    <div class="table-fit">
                        <table class="table table-striped table-hover">
                            <thead>
                                <tr>
                                    <th>
                                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldTitle" />
                                    </th>
                                    <th>
                                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldSubtitle" />
                                    </th>
                                    <th>
                                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldNavTitle" />
                                    </th>
                                    <th>
                                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldTstamp" />
                                    </th>
                                    <th>
                                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldCrdate" />
                                    </th>
                                </tr>
                            </thead>

                            <f:for each="{subPages}" as="page">
                                <tr>
                                    <td class="text-nowrap">
                                        <core:iconForRecord table="pages" row="{page.record}" />
                                        <f:if condition="!{page.canEdit}">
                                            <span
                                                data-bs-toggle="tooltip"
                                                title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:noEditPermissions')}"
                                            >
                                                <core:icon identifier="status-status-permission-denied" />
                                            </span>
                                        </f:if>
                                        {page.record.title -> f:format.crop(maxCharacters: maxTitleLength)}
                                    </td>
                                    <td class="text-nowrap">
                                        {page.record.subtitle -> f:format.crop(maxCharacters: maxTitleLength)}
                                    </td>
                                    <td class="text-nowrap">
                                        {page.record.nav_title -> f:format.crop(maxCharacters: maxTitleLength)}
                                    </td>
                                    <td class="text-nowrap">
                                        <f:format.date format="{dateFormat} {timeFormat}">{page.record.tstamp}</f:format.date>
                                    </td>
                                    <td class="text-nowrap">
                                        <f:format.date format="{dateFormat} {timeFormat}">{page.record.crdate}</f:format.date>
                                    </td>
                                </tr>
                            </f:for>
                        </table>
                    </div>

                    <h2>
                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrder"/>
                    </h2>
                    <a class="btn btn-default t3js-modal-trigger"
                        href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'title\'}')}"
                        data-severity="warning"
                        data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                        data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                        data-bs-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                    >
                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByTitle" />
                    </a>
                    <a class="btn btn-default t3js-modal-trigger"
                        href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'subtitle\'}')}"
                        data-severity="warning"
                        data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                        data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                        data-bs-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                    >
                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderBySubtitle" />
                    </a>
                    <a class="btn btn-default t3js-modal-trigger"
                        href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'nav_title\'}')}"
                        data-severity="warning"
                        data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                        data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                        data-bs-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                    >
                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByNavtitle" />
                    </a>
                    <a class="btn btn-default t3js-modal-trigger"
                        href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'tstamp\'}')}"
                        data-severity="warning"
                        data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                        data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                        data-bs-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                    >
                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByTstamp" />
                    </a>
                    <a class="btn btn-default t3js-modal-trigger"
                        href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'create\'}')}"
                        data-severity="warning"
                        data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                        data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                        data-bs-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                    >
                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByCreate" />
                    </a>
                    <a class="btn btn-default t3js-modal-trigger"
                        href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'reverseCurrentSorting\'}')}"
                        data-severity="warning"
                        data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                        data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                        data-bs-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                    >
                        <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderReverse" />
                    </a>
                </f:then>
                <f:else>
                    <f:be.infobox
                        title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:noSubpages.title')}"
                        message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:noSubpages.message')}"
                        state="-1"
                    />
                </f:else>
            </f:if>
        </f:else>
    </f:if>

</f:section>

</html>
