1 | <?php |
||
6 | class Carbon_Pagination_Renderer { |
||
7 | |||
8 | /** |
||
9 | * @var Carbon_Pagination_Collection |
||
10 | * |
||
11 | * The pagination collection object. |
||
12 | */ |
||
13 | protected $collection; |
||
14 | |||
15 | /** |
||
16 | * Constructor. |
||
17 | * Creates and configures a new pagination renderer for the provided pagination collection. |
||
18 | * |
||
19 | * @param Carbon_Pagination_Collection $collection Pagination collection object. |
||
20 | */ |
||
21 | 1 | public function __construct( Carbon_Pagination_Collection $collection ) { |
|
24 | |||
25 | /** |
||
26 | * Retrieve the collection object. |
||
27 | * |
||
28 | * @return Carbon_Pagination_Collection $collection The collection object. |
||
29 | */ |
||
30 | 1 | public function get_collection() { |
|
33 | |||
34 | /** |
||
35 | * Modify the collection object. |
||
36 | * |
||
37 | * @param Carbon_Pagination_Collection $collection The new collection object. |
||
38 | */ |
||
39 | 1 | public function set_collection( Carbon_Pagination_Collection $collection ) { |
|
42 | |||
43 | /** |
||
44 | * Parse all tokens within a string. |
||
45 | * |
||
46 | * Tokens should be passed in the array in the following way: |
||
47 | * array( 'TOKENNAME' => 'tokenvalue' ) |
||
48 | * |
||
49 | * Tokens should be used in the string in the following way: |
||
50 | * 'lorem {TOKENNAME} ipsum' |
||
51 | * |
||
52 | * @param string $string The unparsed string. |
||
53 | * @param array $tokens An array of tokens and their values. |
||
54 | * @return string $string The parsed string. |
||
55 | */ |
||
56 | 9 | public function parse_tokens( $string, $tokens = array() ) { |
|
63 | |||
64 | /** |
||
65 | * Prepare the items for rendering. |
||
66 | * If no items are specified, fetches the ones from the collection. |
||
67 | * Filters out incorrect items. |
||
68 | * |
||
69 | * @return array $ready_items The prepared items. |
||
70 | */ |
||
71 | 4 | public function prepare_items( $items = array() ) { |
|
88 | |||
89 | /** |
||
90 | * Render the current collection items. |
||
91 | * Each item can have sub items, which are rendered recursively. |
||
92 | * |
||
93 | * @param array $items Items to render. If not specified, will render the collection items. |
||
94 | * @param bool $echo Whether to display or return the output. True will display, false will return. |
||
95 | */ |
||
96 | 6 | public function render( $items = array(), $echo = true ) { |
|
113 | |||
114 | /** |
||
115 | * Render a set of pagination items, recursively. |
||
116 | * |
||
117 | * @param array $items Items to render. |
||
118 | * @return string $output The HTML output of all items. |
||
119 | */ |
||
120 | 4 | public function render_items( $items ) { |
|
137 | |||
138 | /** |
||
139 | * Setup, parse tokens & render a specific item. |
||
140 | * |
||
141 | * @param Carbon_Pagination_Item $item Item to render. |
||
142 | * @return string $output The HTML of the item. |
||
143 | */ |
||
144 | 4 | public function render_item( Carbon_Pagination_Item $item ) { |
|
162 | |||
163 | } |