UrlWindowPresenterTrait.php
1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace Illuminate\Pagination;
trait UrlWindowPresenterTrait
{
/**
* Render the actual link slider.
*
* @return string
*/
protected function getLinks()
{
$html = '';
if (is_array($this->window['first'])) {
$html .= $this->getUrlLinks($this->window['first']);
}
if (is_array($this->window['slider'])) {
$html .= $this->getDots();
$html .= $this->getUrlLinks($this->window['slider']);
}
if (is_array($this->window['last'])) {
$html .= $this->getDots();
$html .= $this->getUrlLinks($this->window['last']);
}
return $html;
}
/**
* Get the links for the URLs in the given array.
*
* @param array $urls
* @return string
*/
protected function getUrlLinks(array $urls)
{
$html = '';
foreach ($urls as $page => $url) {
$html .= $this->getPageLinkWrapper($url, $page);
}
return $html;
}
/**
* Get HTML wrapper for a page link.
*
* @param string $url
* @param int $page
* @param string|null $rel
* @return string
*/
protected function getPageLinkWrapper($url, $page, $rel = null)
{
if ($page == $this->paginator->currentPage()) {
return $this->getActivePageWrapper($page);
}
return $this->getAvailablePageWrapper($url, $page, $rel);
}
}