-
Notifications
You must be signed in to change notification settings - Fork 452
/
ConcreteBootstrap3PagerTemplate.php
82 lines (67 loc) · 2.06 KB
/
ConcreteBootstrap3PagerTemplate.php
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace Concrete\Core\Search\Pagination\View;
use Pagerfanta\View\Template\Template;
use Pagerfanta\View\Template\TwitterBootstrap3Template;
class ConcreteBootstrap3PagerTemplate extends Template
{
static protected $defaultOptions = array(
'css_container_class' => 'pagination',
);
public function container()
{
return sprintf('<div class="ccm-pagination-wrapper"><ul class="%s">%%pages%%</ul></div>',
$this->option('css_container_class')
);
}
public function page($page)
{
return null;
}
public function pageWithText($page, $text)
{
return null;
}
public function previousDisabled()
{
return '<li class="disabled pull-left"><a href="#" disabled="disabled" onclick="return false">' . t('Previous') . '</a></li>';
}
public function previousEnabled($page)
{
$href = $this->generateRoute($page);
return '<li class="pull-left"><a href="' . $href . '">' . t('Previous') . '</a></li>';
}
public function nextDisabled()
{
return '<li class="disabled pull-right"><a href="#" disabled="disabled" onclick="return false">' . t('Next') . '</a></li> ';
}
public function nextEnabled($page)
{
$href = $this->generateRoute($page);
return '<li class="pull-right"><a href="' . $href . '">' . t('Next'). '</a></li> ';
}
public function last($page)
{
return null;
}
public function separator()
{
return null;
}
public function current($page)
{
$href = $this->generateRoute($page);
$pageNumber = 1;
$pageResult = '/ccm_cursor=([\d\|]+)/';
if (preg_match_all($pageResult, $href, $pageResultMatches)) {
$page = '/(\d+)/';
if (preg_match_all($page, $pageResultMatches[1][0], $pageMatches)) {
$pageNumber = count($pageMatches[1]) + 1;
}
}
return '<li class="active"><span>' . $pageNumber . '</span></li>';
}
public function first()
{
return null;
}
}