1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace hiqdev\themes\hyde\widgets; |
4
|
|
|
|
5
|
|
|
use yii\helpers\ArrayHelper; |
6
|
|
|
use yii\helpers\Html; |
7
|
|
|
|
8
|
|
|
class LinkPager extends \yii\widgets\LinkPager |
9
|
|
|
{ |
10
|
|
|
/** @inheritdoc */ |
11
|
|
|
public $prevPageCssClass = 'pagination-item newer'; |
12
|
|
|
|
13
|
|
|
/** @inheritdoc */ |
14
|
|
|
public $nextPageCssClass = 'pagination-item older'; |
15
|
|
|
|
16
|
|
|
/** @inheritdoc */ |
17
|
|
|
public function renderPageButtons() |
18
|
|
|
{ |
19
|
|
|
$pageCount = $this->pagination->getPageCount(); |
20
|
|
|
if ($pageCount < 2 && $this->hideOnSinglePage) { |
21
|
|
|
return ''; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
$buttons = []; |
25
|
|
|
$currentPage = $this->pagination->getPage(); |
26
|
|
|
|
27
|
|
|
// prev page |
28
|
|
|
if ($this->prevPageLabel !== false) { |
29
|
|
|
if (($page = $currentPage - 1) < 0) { |
30
|
|
|
$page = 0; |
31
|
|
|
} |
32
|
|
|
$buttons[] = $this->renderPageButton($this->prevPageLabel, $page, $this->prevPageCssClass, $currentPage <= 0, false); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
// next page |
36
|
|
|
if ($this->nextPageLabel !== false) { |
37
|
|
|
if (($page = $currentPage + 1) >= $pageCount - 1) { |
38
|
|
|
$page = $pageCount - 1; |
39
|
|
|
} |
40
|
|
|
$buttons[] = $this->renderPageButton($this->nextPageLabel, $page, $this->nextPageCssClass, $currentPage >= $pageCount - 1, false); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
return Html::tag('div', implode("\n", $buttons), $this->options); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** @inheritdoc */ |
47
|
|
|
protected function renderPageButton($label, $page, $class, $disabled, $active) |
48
|
|
|
{ |
49
|
|
|
$options = ['class' => empty($class) ? $this->pageCssClass : $class]; |
50
|
|
|
if ($active) { |
51
|
|
|
Html::addCssClass($options, $this->activePageCssClass); |
52
|
|
|
} |
53
|
|
|
if ($disabled) { |
54
|
|
|
Html::addCssClass($options, $this->disabledPageCssClass); |
55
|
|
|
$tag = ArrayHelper::remove($this->disabledListItemSubTagOptions, 'tag', 'span'); |
|
|
|
|
56
|
|
|
|
57
|
|
|
return Html::tag($tag, $label, $options); |
58
|
|
|
} |
59
|
|
|
$linkOptions = $this->linkOptions; |
60
|
|
|
$linkOptions['data-page'] = $page; |
61
|
|
|
|
62
|
|
|
return Html::a($label, $this->pagination->createUrl($page), $options); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.