Skip to content

Commit 8362e6d

Browse files
committed
Add support for W3.CSS framework
1 parent 343c67f commit 8362e6d

File tree

6 files changed

+95
-0
lines changed

6 files changed

+95
-0
lines changed

.phpstorm.meta.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
'tailwind-short',
4343
'tailwind3',
4444
'tailwind3-short',
45+
'w3',
46+
'w3-short',
47+
'w34',
48+
'w34-short',
4549
);
4650
expectedArguments(
4751
\Framework\Pagination\Pager::getView(),

guide/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ The Aplus Framework Pagination Library works with the following front-end framew
166166
- `Primer <https://primer.style/>`_
167167
- `Semantic UI <https://semantic-ui.com/>`_
168168
- `Tailwind <https://tailwindcss.com/>`_
169+
- `W3.CSS <https://www.w3schools.com/w3css/default.asp/>`_
169170

170171
Note that it is necessary to load links from CSS files.
171172

src/Pager.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class Pager implements JsonSerializable
7878
'tailwind-short' => __DIR__ . '/Views/tailwind-short.php',
7979
'tailwind3' => __DIR__ . '/Views/tailwind.php',
8080
'tailwind3-short' => __DIR__ . '/Views/tailwind-short.php',
81+
// W3.CSS 4
82+
'w3' => __DIR__ . '/Views/w3.php',
83+
'w3-short' => __DIR__ . '/Views/w3-short.php',
84+
'w34' => __DIR__ . '/Views/w3.php',
85+
'w34-short' => __DIR__ . '/Views/w3-short.php',
8186
];
8287
protected string $defaultView = 'pagination';
8388
protected URL $url;

src/Views/w3-short.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/*
3+
* This file is part of Aplus Framework Pagination Library.
4+
*
5+
* (c) Natan Felles <natanfelles@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
/**
11+
* @var Framework\Pagination\Pager $pager
12+
*/
13+
$language = $pager->getLanguage();
14+
?>
15+
<div class="w3-center">
16+
<div class="w3-bar">
17+
<?php if ($pager->getPreviousPage()) : ?>
18+
<a rel="prev" href="<?= $pager->getPreviousPageUrl() ?>" class="w3-button">
19+
<?= $language->render('pagination', 'previous') ?>
20+
</a>
21+
<?php endif ?>
22+
23+
<?php if ($pager->getNextPage()) : ?>
24+
<a rel="next" href="<?= $pager->getNextPageUrl() ?>" class="w3-button">
25+
<?= $language->render('pagination', 'next') ?>
26+
</a>
27+
<?php endif ?>
28+
</div>
29+
</div>

src/Views/w3.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/*
3+
* This file is part of Aplus Framework Pagination Library.
4+
*
5+
* (c) Natan Felles <natanfelles@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
/**
11+
* @var Framework\Pagination\Pager $pager
12+
*/
13+
$language = $pager->getLanguage();
14+
?>
15+
<div class="w3-center">
16+
<div class="w3-bar">
17+
<?php if ($pager->getCurrentPage() - $pager->getSurround() > 1) : ?>
18+
<a class="w3-button" href="<?= $pager->getFirstPageUrl() ?>"><?= $pager->getLanguage()
19+
->render('pagination', 'first') ?></a>
20+
<?php endif ?>
21+
22+
<?php if ($pager->getPreviousPage()) : ?>
23+
<a class="w3-button" rel="prev" href="<?= $pager->getPreviousPageUrl() ?>" title="<?=
24+
$language->render('pagination', 'previous') ?>">&laquo;</a>
25+
<?php endif ?>
26+
27+
<?php foreach ($pager->getPreviousPagesUrls() as $p => $url) : ?>
28+
<a href="<?= $url ?>" class="w3-button"><?= $p ?></a>
29+
<?php endforeach ?>
30+
31+
<a href="<?= $pager->getCurrentPageUrl() ?>" rel="canonical" class="w3-button w3-blue w3-hover-blue">
32+
<?= $pager->getCurrentPage() ?>
33+
</a>
34+
35+
<?php foreach ($pager->getNextPagesUrls() as $p => $url) : ?>
36+
<a href="<?= $url ?>" class="w3-button"><?= $p ?></a>
37+
<?php endforeach ?>
38+
39+
<?php if ($pager->getNextPage() && $pager->getNextPage() < $pager->getLastPage() + 1) : ?>
40+
<a class="w3-button" rel="next" href="<?= $pager->getNextPageUrl() ?>" title="<?=
41+
$language->render('pagination', 'next') ?>">&raquo;</a>
42+
<?php endif ?>
43+
44+
<?php if ($pager->getLastPage()
45+
&& $pager->getCurrentPage() + $pager->getSurround() < $pager->getLastPage()
46+
) : ?>
47+
<a class="w3-button" href="<?= $pager->getLastPageUrl() ?>"><?= $pager->getLanguage()
48+
->render('pagination', 'last') ?></a>
49+
<?php endif ?>
50+
</div>
51+
</div>

tests/PagerTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ public function testViews() : void
201201
'tailwind-short' => \realpath(__DIR__ . '/../src/Views/tailwind-short.php'),
202202
'tailwind3' => \realpath(__DIR__ . '/../src/Views/tailwind.php'),
203203
'tailwind3-short' => \realpath(__DIR__ . '/../src/Views/tailwind-short.php'),
204+
'w3' => \realpath(__DIR__ . '/../src/Views/w3.php'),
205+
'w3-short' => \realpath(__DIR__ . '/../src/Views/w3-short.php'),
206+
'w34' => \realpath(__DIR__ . '/../src/Views/w3.php'),
207+
'w34-short' => \realpath(__DIR__ . '/../src/Views/w3-short.php'),
204208
];
205209
self::assertSame($views, $this->pager->getViews());
206210
$this->pager->setView('foo', __FILE__);
@@ -304,6 +308,7 @@ public function viewsProvider() : array
304308
['primer'],
305309
['semantic-ui'],
306310
['tailwind'],
311+
['w3'],
307312
];
308313
}
309314

0 commit comments

Comments
 (0)