Skip to content
This repository was archived by the owner on Jun 9, 2024. It is now read-only.

Commit c75f309

Browse files
committed
make simplePaginate() ready. create PaginationHTML class.
1 parent 7c4da7e commit c75f309

6 files changed

+200
-99
lines changed

src/Pagination.php

+4-99
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Pagination\UrlWindow;
66
use Illuminate\Pagination\UrlWindowPresenterTrait;
77

8-
class Pagination implements PresenterContract {
8+
class Pagination extends PaginationHTML implements PresenterContract {
99

1010
use UrlWindowPresenterTrait;
1111

@@ -23,48 +23,6 @@ class Pagination implements PresenterContract {
2323
*/
2424
protected $window;
2525

26-
/**
27-
* Pagination wrapper HTML.
28-
*
29-
* @var string
30-
*/
31-
protected $paginationWrapper = '<ul class="pagination">%s %s %s</ul>';
32-
33-
/**
34-
* Available page wrapper HTML.
35-
*
36-
* @var string
37-
*/
38-
protected $availablePageWrapper = '<li><a href="%s">%s</a></li>';
39-
40-
/**
41-
* Get active page wrapper HTML.
42-
*
43-
* @var string
44-
*/
45-
protected $activePageWrapper = '<li class="active"><span>%s</span></li>';
46-
47-
/**
48-
* Get disabled page wrapper HTML.
49-
*
50-
* @var string
51-
*/
52-
protected $disabledPageWrapper = '<li class="disabled"><span>%s</span></li>';
53-
54-
/**
55-
* Previous button text.
56-
*
57-
* @var string
58-
*/
59-
protected $previousButtonText = '&laquo;';
60-
61-
/**
62-
* Next button text.
63-
*
64-
* @var string
65-
*/
66-
protected $nextButtonText = '&raquo;';
67-
6826
/**
6927
* Create a new Pagination presenter instance.
7028
*
@@ -87,60 +45,6 @@ public function hasPages()
8745
return $this->paginator->hasPages();
8846
}
8947

90-
/**
91-
* Get pagination wrapper HTML.
92-
*
93-
* @return string
94-
*/
95-
protected function getPaginationWrapperHTML() {
96-
return $this->paginationWrapper;
97-
}
98-
99-
/**
100-
* Get available page wrapper HTML.
101-
*
102-
* @return string
103-
*/
104-
protected function getAvailablePageWrapperHTML() {
105-
return $this->availablePageWrapper;
106-
}
107-
108-
/**
109-
* Get active page wrapper HTML.
110-
*
111-
* @return string
112-
*/
113-
protected function getActivePageWrapperHTML() {
114-
return $this->activePageWrapper;
115-
}
116-
117-
/**
118-
* Get disabled page wrapper HTML.
119-
*
120-
* @return string
121-
*/
122-
protected function getDisabledPageWrapperHTML() {
123-
return $this->disabledPageWrapper;
124-
}
125-
126-
/**
127-
* Get previous button text.
128-
*
129-
* @return string
130-
*/
131-
protected function getPreviousButtonText() {
132-
return $this->previousButtonText;
133-
}
134-
135-
/**
136-
* Get next button text.
137-
*
138-
* @return string
139-
*/
140-
protected function getNextButtonText() {
141-
return $this->nextButtonText;
142-
}
143-
14448
/**
14549
* Convert the URL window into Pagination HTML.
14650
*
@@ -202,7 +106,7 @@ protected function getActivePageWrapper($text)
202106
*/
203107
protected function getDots()
204108
{
205-
return $this->getDisabledTextWrapper("...");
109+
return $this->getDisabledTextWrapper($this->getDotsText());
206110
}
207111

208112
/**
@@ -244,8 +148,8 @@ protected function getPageLinkWrapper($url, $page)
244148

245149
/**
246150
* Get the previous page pagination element.
151+
*
247152
* @return string
248-
* @internal param string $text
249153
*/
250154
protected function getPreviousButton()
251155
{
@@ -265,6 +169,7 @@ protected function getPreviousButton()
265169

266170
/**
267171
* Get the next page pagination element.
172+
*
268173
* @return string
269174
*/
270175
protected function getNextButton()

src/PaginationHTML.php

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php namespace Landish\Pagination;
2+
3+
class PaginationHTML {
4+
5+
/**
6+
* Pagination wrapper HTML.
7+
*
8+
* @var string
9+
*/
10+
protected $paginationWrapper = '<ul class="pagination">%s %s %s</ul>';
11+
12+
/**
13+
* Available page wrapper HTML.
14+
*
15+
* @var string
16+
*/
17+
protected $availablePageWrapper = '<li><a href="%s">%s</a></li>';
18+
19+
/**
20+
* Get active page wrapper HTML.
21+
*
22+
* @var string
23+
*/
24+
protected $activePageWrapper = '<li class="active"><span>%s</span></li>';
25+
26+
/**
27+
* Get disabled page wrapper HTML.
28+
*
29+
* @var string
30+
*/
31+
protected $disabledPageWrapper = '<li class="disabled"><span>%s</span></li>';
32+
33+
/**
34+
* Previous button text.
35+
*
36+
* @var string
37+
*/
38+
protected $previousButtonText = '&laquo;';
39+
40+
/**
41+
* Next button text.
42+
*
43+
* @var string
44+
*/
45+
protected $nextButtonText = '&raquo;';
46+
47+
/***
48+
* "Dots" text.
49+
*
50+
* @var string
51+
*/
52+
protected $dotsText = '...';
53+
54+
/**
55+
* Get pagination wrapper HTML.
56+
*
57+
* @return string
58+
*/
59+
protected function getPaginationWrapperHTML() {
60+
return $this->paginationWrapper;
61+
}
62+
63+
/**
64+
* Get available page wrapper HTML.
65+
*
66+
* @return string
67+
*/
68+
protected function getAvailablePageWrapperHTML() {
69+
return $this->availablePageWrapper;
70+
}
71+
72+
/**
73+
* Get active page wrapper HTML.
74+
*
75+
* @return string
76+
*/
77+
protected function getActivePageWrapperHTML() {
78+
return $this->activePageWrapper;
79+
}
80+
81+
/**
82+
* Get disabled page wrapper HTML.
83+
*
84+
* @return string
85+
*/
86+
protected function getDisabledPageWrapperHTML() {
87+
return $this->disabledPageWrapper;
88+
}
89+
90+
/**
91+
* Get previous button text.
92+
*
93+
* @return string
94+
*/
95+
protected function getPreviousButtonText() {
96+
return $this->previousButtonText;
97+
}
98+
99+
/**
100+
* Get next button text.
101+
*
102+
* @return string
103+
*/
104+
protected function getNextButtonText() {
105+
return $this->nextButtonText;
106+
}
107+
108+
/***
109+
* Get "dots" text.
110+
*
111+
* @return string
112+
*/
113+
protected function getDotsText() {
114+
return $this->dotsText;
115+
}
116+
117+
}

src/Simple/Pagination.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php namespace Landish\Pagination\Simple;
2+
3+
use Illuminate\Contracts\Pagination\Paginator as PaginatorContract;
4+
use Landish\Pagination\Pagination as PaginationPresenter;
5+
6+
class Pagination extends PaginationPresenter {
7+
8+
/**
9+
* Pagination wrapper HTML.
10+
*
11+
* @var string
12+
*/
13+
protected $paginationWrapper = '<ul class="pager">%s %s %s</ul>';
14+
15+
/**
16+
* Create a simple Pagination presenter.
17+
*
18+
* @param \Illuminate\Contracts\Pagination\Paginator $paginator
19+
*/
20+
public function __construct(PaginatorContract $paginator)
21+
{
22+
$this->paginator = $paginator;
23+
}
24+
25+
}

src/Simple/SemanticUI.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php namespace Landish\Pagination\Simple;
2+
3+
use Illuminate\Contracts\Pagination\Paginator as PaginatorContract;
4+
use Landish\Pagination\SemanticUI as SemanticUIPresenter;
5+
6+
class SemanticUI extends SemanticUIPresenter {
7+
8+
/**
9+
* Create a simple Pagination presenter.
10+
*
11+
* @param \Illuminate\Contracts\Pagination\Paginator $paginator
12+
*/
13+
public function __construct(PaginatorContract $paginator)
14+
{
15+
$this->paginator = $paginator;
16+
}
17+
18+
}

src/Simple/UIKit.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php namespace Landish\Pagination\Simple;
2+
3+
use Illuminate\Contracts\Pagination\Paginator as PaginatorContract;
4+
use Landish\Pagination\UIKit as UIKitPresenter;
5+
6+
class UIKit extends UIKitPresenter {
7+
8+
/**
9+
* Create a simple Pagination presenter.
10+
*
11+
* @param \Illuminate\Contracts\Pagination\Paginator $paginator
12+
*/
13+
public function __construct(PaginatorContract $paginator)
14+
{
15+
$this->paginator = $paginator;
16+
}
17+
18+
}

src/Simple/ZurbFoundation.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php namespace Landish\Pagination\Simple;
2+
3+
use Illuminate\Contracts\Pagination\Paginator as PaginatorContract;
4+
use Landish\Pagination\ZurbFoundation as ZurbFoundationPresenter;
5+
6+
class ZurbFoundation extends ZurbFoundationPresenter {
7+
8+
/**
9+
* Create a simple Pagination presenter.
10+
*
11+
* @param \Illuminate\Contracts\Pagination\Paginator $paginator
12+
*/
13+
public function __construct(PaginatorContract $paginator)
14+
{
15+
$this->paginator = $paginator;
16+
}
17+
18+
}

0 commit comments

Comments
 (0)