-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from CPS-IT/feature/pagination
[FEATURE] Add pagination to backend module
- Loading branch information
Showing
8 changed files
with
248 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS extension "mailqueue". | ||
* | ||
* Copyright (C) 2024 Elias Häußler <elias@haeussler.dev> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace CPSIT\Typo3Mailqueue\Configuration; | ||
|
||
use CPSIT\Typo3Mailqueue\Extension; | ||
use TYPO3\CMS\Core; | ||
|
||
/** | ||
* ExtensionConfiguration | ||
* | ||
* @author Elias Häußler <e.haeussler@familie-redlich.de> | ||
* @license GPL-2.0-or-later | ||
*/ | ||
final class ExtensionConfiguration | ||
{ | ||
private const DEFAULT_ITEMS_PER_PAGE = 20; | ||
|
||
public function __construct( | ||
private readonly Core\Configuration\ExtensionConfiguration $configuration, | ||
) {} | ||
|
||
public function getItemsPerPage(): int | ||
{ | ||
try { | ||
$itemsPerPage = $this->configuration->get(Extension::KEY, 'pagination/itemsPerPage'); | ||
} catch (Core\Exception) { | ||
return self::DEFAULT_ITEMS_PER_PAGE; | ||
} | ||
|
||
if (!is_scalar($itemsPerPage)) { | ||
return self::DEFAULT_ITEMS_PER_PAGE; | ||
} | ||
|
||
return max(1, (int)$itemsPerPage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" | ||
xmlns:c="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers" | ||
data-namespace-typo3-fluid="true"> | ||
|
||
<f:if condition="{paginator.numberOfPages} > 1"> | ||
<tr> | ||
<td colspan="6"> | ||
<nav class="mb-2 mt-2"> | ||
<span class="page-item ps-2 pe-2"> | ||
<f:translate key="pagination.paginatedItems" extensionName="Mailqueue" arguments="{ | ||
0: '{paginator.keyOfFirstPaginatedItem + 1}', | ||
1: '{paginator.keyOfLastPaginatedItem + 1}' | ||
}" /> | ||
<span class="visually-hidden">, | ||
<f:translate key="pagination.pageRange" extensionName="Mailqueue" arguments="{ | ||
0: paginator.currentPageNumber, | ||
1: pagination.lastPageNumber | ||
}" /> | ||
</span> | ||
</span> | ||
|
||
<ul class="pagination d-inline-flex"> | ||
<f:comment><!-- First/Previous page --></f:comment> | ||
<f:if condition="{pagination.previousPageNumber}"> | ||
<f:then> | ||
<li class="page-item ps-2"> | ||
<f:be.link route="system_mailqueue" | ||
parameters="{page: pagination.firstPageNumber}" | ||
title="{f:translate(key: 'aria.first', extensionName: 'Mailqueue')}" | ||
aria="{label: '{f:translate(key: \'aria.first\', extensionName: \'Mailqueue\')}'}" | ||
>{c:icon(identifier: 'actions-view-paging-first')}</f:be.link> | ||
</li> | ||
<li class="page-item ps-2"> | ||
<f:be.link route="system_mailqueue" | ||
parameters="{page: pagination.previousPageNumber}" | ||
title="{f:translate(key: 'aria.previous', extensionName: 'Mailqueue')}" | ||
aria="{label: '{f:translate(key: \'aria.previous\', extensionName: \'Mailqueue\')}'}" | ||
>{c:icon(identifier: 'actions-view-paging-previous')}</f:be.link> | ||
</li> | ||
</f:then> | ||
<f:else> | ||
<li class="page-item ps-2" aria-hidden="true"> | ||
{c:icon(identifier: 'actions-view-paging-first')} | ||
</li> | ||
<li class="page-item ps-2" aria-hidden="true"> | ||
{c:icon(identifier: 'actions-view-paging-previous')} | ||
</li> | ||
</f:else> | ||
</f:if> | ||
|
||
<f:comment><!-- Page selector --></f:comment> | ||
<li class="page-item ps-2"> | ||
<form action="{f:be.uri(route: 'system_mailqueue')}" method="post"> | ||
<label> | ||
{f:translate(key: 'pagination.pageRange.start', extensionName: 'Mailqueue')} | ||
|
||
<input type="number" | ||
autocomplete="off" | ||
name="page" | ||
min="{pagination.firstPageNumber}" | ||
max="{pagination.lastPageNumber}" | ||
value="{paginator.currentPageNumber}" | ||
size="3" | ||
class="form-control form-control-sm paginator-input" | ||
> | ||
</label> | ||
<span aria-hidden="true"> | ||
<f:translate key="pagination.pageRange.end" extensionName="Mailqueue" arguments="{ | ||
0: pagination.lastPageNumber | ||
}" /> | ||
</span> | ||
</form> | ||
</li> | ||
|
||
<f:comment><!-- Next/Last page --></f:comment> | ||
<f:if condition="{pagination.nextPageNumber}"> | ||
<f:then> | ||
<li class="page-item ps-2"> | ||
<f:be.link route="system_mailqueue" | ||
parameters="{page: pagination.nextPageNumber}" | ||
title="{f:translate(key: 'aria.next', extensionName: 'Mailqueue')}" | ||
aria="{label: '{f:translate(key: \'aria.next\', extensionName: \'Mailqueue\')}'}" | ||
>{c:icon(identifier: 'actions-view-paging-next')}</f:be.link> | ||
</li> | ||
<li class="page-item ps-2"> | ||
<f:be.link route="system_mailqueue" | ||
parameters="{page: pagination.lastPageNumber}" | ||
title="{f:translate(key: 'aria.last', extensionName: 'Mailqueue')}" | ||
aria="{label: '{f:translate(key: \'aria.last\', extensionName: \'Mailqueue\')}'}" | ||
>{c:icon(identifier: 'actions-view-paging-last')}</f:be.link> | ||
</li> | ||
</f:then> | ||
<f:else> | ||
<li class="page-item ps-2" aria-hidden="true"> | ||
{c:icon(identifier: 'actions-view-paging-next')} | ||
</li> | ||
<li class="page-item ps-2" aria-hidden="true"> | ||
{c:icon(identifier: 'actions-view-paging-last')} | ||
</li> | ||
</f:else> | ||
</f:if> | ||
|
||
<f:comment><!-- Reload --></f:comment> | ||
<li class="page-item ps-2"> | ||
<f:be.link route="system_mailqueue" | ||
parameters="{page: paginator.currentPageNumber}" | ||
title="{f:translate(key: 'aria.reload', extensionName: 'Mailqueue')}" | ||
aria="{label: '{f:translate(key: \'aria.reload\', extensionName: \'Mailqueue\')}'}" | ||
>{c:icon(identifier: 'actions-refresh')}</f:be.link> | ||
</li> | ||
</ul> | ||
</nav> | ||
</td> | ||
</tr> | ||
</f:if> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# cat=pagination//10; type=int+; label=Number of mails to display on a single page in backend module list pagination | ||
pagination.itemsPerPage = 20 |