1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* The Carbon Pagination item class. |
4
|
|
|
* Corresponds to a particular item of the pagination. |
5
|
|
|
*/ |
6
|
|
|
class Carbon_Pagination_Item { |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @var Carbon_Pagination_Collection |
10
|
|
|
* |
11
|
|
|
* The pagination collection object this item belongs to. |
12
|
|
|
*/ |
13
|
|
|
protected $collection; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var Carbon_Pagination_Collection|bool |
17
|
|
|
* |
18
|
|
|
* The subitems collection. |
19
|
|
|
* Contains the sub items that this item consists of. |
20
|
|
|
* Can be false if this item is a standalone single item. |
21
|
|
|
*/ |
22
|
|
|
protected $subitems_collection = false; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var array |
26
|
|
|
* |
27
|
|
|
* Tokens that can be auto replaced in the HTML of an item. |
28
|
|
|
* |
29
|
|
|
* Tokens should be passed in the array in the following way: |
30
|
|
|
* array( 'TOKENNAME' => 'tokenvalue' ) |
31
|
|
|
* |
32
|
|
|
* Tokens should be used in the string in the following way: |
33
|
|
|
* 'lorem {TOKENNAME} ipsum' |
34
|
|
|
*/ |
35
|
|
|
protected $tokens = array(); |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Constructor. |
39
|
|
|
* Creates and configures a new pagination item. |
40
|
|
|
* |
41
|
|
|
* @param Carbon_Pagination_Collection $collection Pagination collection object. |
42
|
|
|
*/ |
43
|
1 |
|
public function __construct( Carbon_Pagination_Collection $collection ) { |
44
|
1 |
|
$this->set_collection( $collection ); |
45
|
|
|
|
46
|
1 |
|
$this->init(); |
47
|
1 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Retrieve the collection object. |
51
|
|
|
* |
52
|
|
|
* @return Carbon_Pagination_Collection $collection The collection object. |
53
|
|
|
*/ |
54
|
1 |
|
public function get_collection() { |
55
|
1 |
|
return $this->collection; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Modify the collection object. |
60
|
|
|
* |
61
|
|
|
* @param Carbon_Pagination_Collection $collection The new collection object. |
62
|
|
|
*/ |
63
|
1 |
|
public function set_collection( Carbon_Pagination_Collection $collection ) { |
64
|
1 |
|
$this->collection = $collection; |
65
|
1 |
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Retrieve the item subitems collection. |
69
|
|
|
* |
70
|
|
|
* @return Carbon_Pagination_Collection $subitems_collection The item subitems collection. |
71
|
|
|
*/ |
72
|
1 |
|
public function get_subitems_collection() { |
73
|
1 |
|
return $this->subitems_collection; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Modify the item subitems collection. |
78
|
|
|
* |
79
|
|
|
* @param Carbon_Pagination_Collection $subitems_collection The new item subitems collection. |
80
|
|
|
*/ |
81
|
1 |
|
public function set_subitems_collection( Carbon_Pagination_Collection $subitems_collection ) { |
82
|
1 |
|
$this->subitems_collection = $subitems_collection; |
83
|
1 |
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Retrieve the item HTML replaceable tokens. |
87
|
|
|
* |
88
|
|
|
* @return array $tokens The item HTML replaceable tokens. |
89
|
|
|
*/ |
90
|
1 |
|
public function get_tokens() { |
91
|
1 |
|
return $this->tokens; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Modify the item HTML replaceable tokens. |
96
|
|
|
* |
97
|
|
|
* @param array $tokens The new item HTML replaceable tokens. |
98
|
|
|
*/ |
99
|
1 |
|
public function set_tokens( $tokens ) { |
100
|
1 |
|
$this->tokens = $tokens; |
101
|
1 |
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Render the item. |
105
|
|
|
* |
106
|
|
|
* @return string $html The HTML of the item. |
107
|
|
|
*/ |
108
|
1 |
|
public function render() { |
109
|
1 |
|
return ''; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Initialize the item. |
114
|
|
|
*/ |
115
|
|
|
public function init() {} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Setup the item before rendering. |
119
|
|
|
*/ |
120
|
|
|
public function setup() {} |
121
|
|
|
|
122
|
|
|
} |