Completed
Push — master ( 3555a5...e61355 )
by Jean-Christophe
03:33
created

HtmlPaginationMenu::setActiveItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Ajax\semantic\html\collections\menus;
4
5
use Ajax\semantic\html\collections\menus\HtmlMenu;
6
use Ajax\JsUtils;
7
8
use Ajax\semantic\html\elements\HtmlIcon;
9
10
class HtmlPaginationMenu extends HtmlMenu{
11
	private $_page;
12
	public function __construct( $identifier, $items=array() ){
13
		parent::__construct( $identifier,$items);
14
	}
15
	/**
16
	 * {@inheritDoc}
17
	 * @see \Ajax\common\html\BaseHtml::compile()
18
	 */
19
	public function compile(JsUtils $js=NULL,&$view=NULL){
20
		$this->insertItem(new HtmlIcon("", "left chevron"))->setProperty("data-page", \max([1,$this->_page-1]));
21
		$this->addItem(new HtmlIcon("", "right chevron"))->setProperty("data-page", \min([\sizeof($this->content)-2,$this->_page+1]));
22
		$this->asPagination();
23
		return parent::compile($js,$view);
24
	}
25
26
	public function setActiveItem($index) {
27
		$result=parent::setActiveItem($index);
28
		$this->_page=$index+1;
29
		return $result;
30
	}
31
32
	public function getPage() {
33
		return $this->_page;
34
	}
35
36
}