• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / Yoast-SEO-for-TYPO3 / 13327579701

14 Feb 2025 10:43AM UTC coverage: 1.276%. First build
13327579701

push

github

web-flow
Merge pull request #597 from Yoast/feature/v11

[FEATURE] Release 11.0.0

21 of 894 new or added lines in 76 files covered. (2.35%)

35 of 2744 relevant lines covered (1.28%)

0.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Classes/Service/Overview/Pagination/Pagination.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace YoastSeoForTypo3\YoastSeo\Service\Overview\Pagination;
6

7
use TYPO3\CMS\Core\Pagination\ArrayPaginator;
8

9
/**
10
 * Class Pagination
11
 *
12
 * Functionality ported from the old fluid widget paginate, to support huge overviews
13
 * (prevent long lists of numbered links)
14
 * TODO: Can be removed once CMS11 support is dropped
15
 */
16
class Pagination
17
{
18
    protected ArrayPaginator $paginator;
19

20
    protected int $maximumNumberOfLinks = 15;
21
    protected float $displayRangeStart = 0;
22
    protected float $displayRangeEnd = 0;
23

24
    public function __construct(ArrayPaginator $paginator)
25
    {
26
        $this->paginator = $paginator;
×
27
        $this->calculateDisplayRange();
×
28
    }
29

30
    public function getPreviousPageNumber(): ?int
31
    {
32
        $previousPage = $this->paginator->getCurrentPageNumber() - 1;
×
33

34
        if ($previousPage > $this->paginator->getNumberOfPages()) {
×
35
            return null;
×
36
        }
37

38
        return $previousPage >= $this->getFirstPageNumber()
×
39
            ? $previousPage
×
40
            : null
×
NEW
41
        ;
×
42
    }
43

44
    public function getNextPageNumber(): ?int
45
    {
46
        $nextPage = $this->paginator->getCurrentPageNumber() + 1;
×
47

48
        return $nextPage <= $this->paginator->getNumberOfPages()
×
49
            ? $nextPage
×
50
            : null
×
NEW
51
        ;
×
52
    }
53

54
    public function getFirstPageNumber(): int
55
    {
56
        return 1;
×
57
    }
58

59
    public function getLastPageNumber(): int
60
    {
61
        return $this->paginator->getNumberOfPages();
×
62
    }
63

64
    /**
65
     * @return array<int, float>
66
     */
67
    public function getAllPageNumbers(): array
68
    {
69
        return range($this->displayRangeStart, $this->displayRangeEnd);
×
70
    }
71

72
    public function getHasLessPages(): bool
73
    {
74
        return $this->displayRangeStart > 2;
×
75
    }
76

77
    public function getHasMorePages(): bool
78
    {
79
        return $this->displayRangeEnd + 1 < $this->paginator->getNumberOfPages();
×
80
    }
81

82
    protected function calculateDisplayRange(): void
83
    {
84
        $maximumNumberOfLinks = $this->maximumNumberOfLinks;
×
85
        $numberOfPages = $this->paginator->getNumberOfPages();
×
86
        $currentPage = $this->paginator->getCurrentPageNumber();
×
87
        if ($maximumNumberOfLinks > $numberOfPages) {
×
88
            $maximumNumberOfLinks = $numberOfPages;
×
89
        }
90
        $delta = floor($maximumNumberOfLinks / 2);
×
91
        $this->displayRangeStart = $currentPage - $delta;
×
92
        $this->displayRangeEnd = $currentPage + $delta - ($maximumNumberOfLinks % 2 === 0 ? 1 : 0);
×
93
        if ($this->displayRangeStart < 1) {
×
94
            $this->displayRangeEnd -= $this->displayRangeStart - 1;
×
95
        }
96
        if ($this->displayRangeEnd > $numberOfPages) {
×
97
            $this->displayRangeStart -= $this->displayRangeEnd - $numberOfPages;
×
98
        }
99
        $this->displayRangeStart = (int)max($this->displayRangeStart, 1);
×
100
        $this->displayRangeEnd = (int)min($this->displayRangeEnd, $numberOfPages);
×
101
    }
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc