1 | <?php |
||
13 | class Carbon_Breadcrumb_Trail_Renderer { |
||
14 | |||
15 | /** |
||
16 | * String used between the breadcrumb items when displaying the breadcrumbs. |
||
17 | * |
||
18 | * @access protected |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $glue = ' > '; |
||
22 | |||
23 | /** |
||
24 | * String before the opening link tag. |
||
25 | * |
||
26 | * @access protected |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $link_before = ''; |
||
30 | |||
31 | /** |
||
32 | * String after the closing link tag. |
||
33 | * |
||
34 | * @access protected |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $link_after = ''; |
||
38 | |||
39 | /** |
||
40 | * String before all breadcrumb items. |
||
41 | * |
||
42 | * @access protected |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $wrapper_before = ''; |
||
46 | |||
47 | /** |
||
48 | * String after all breadcrumb items. |
||
49 | * |
||
50 | * @access protected |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $wrapper_after = ''; |
||
54 | |||
55 | /** |
||
56 | * String before the title of a breadcrumb item. |
||
57 | * |
||
58 | * @access protected |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $title_before = ''; |
||
62 | |||
63 | /** |
||
64 | * String before the title of a breadcrumb item. |
||
65 | * |
||
66 | * @access protected |
||
67 | * @var string |
||
68 | */ |
||
69 | protected $title_after = ''; |
||
70 | |||
71 | /** |
||
72 | * Minimum items necessary to display the breadcrumb trail. |
||
73 | * |
||
74 | * @access protected |
||
75 | * @var int |
||
76 | */ |
||
77 | protected $min_items = 2; |
||
78 | |||
79 | /** |
||
80 | * Whether to display the last item as link. |
||
81 | * |
||
82 | * @access protected |
||
83 | * @var bool |
||
84 | */ |
||
85 | protected $last_item_link = true; |
||
86 | |||
87 | /** |
||
88 | * Whether to display the home item. |
||
89 | * |
||
90 | * @access protected |
||
91 | * @var bool |
||
92 | */ |
||
93 | protected $display_home_item = true; |
||
94 | |||
95 | /** |
||
96 | * The title of the home item. |
||
97 | * |
||
98 | * @access protected |
||
99 | * @var string |
||
100 | */ |
||
101 | protected $home_item_title = ''; |
||
102 | |||
103 | /** |
||
104 | * Constructor. |
||
105 | * |
||
106 | * Creates and configures a new breadcrumb trail with the provided settings. |
||
107 | * |
||
108 | * @access public |
||
109 | * |
||
110 | * @param array $args Configuration options to modify the breadcrumb trail output. |
||
111 | */ |
||
112 | public function __construct( $args = array() ) { |
||
134 | |||
135 | /** |
||
136 | * Retrieve the string, used for concatenating the breadcrumb items. |
||
137 | * |
||
138 | * @access public |
||
139 | * |
||
140 | * @return string $glue String, used for concatenating the breadcrumb items. |
||
141 | */ |
||
142 | public function get_glue() { |
||
145 | |||
146 | /** |
||
147 | * Modify the string, used for concatenating the breadcrumb items. |
||
148 | * |
||
149 | * @access public |
||
150 | * |
||
151 | * @param string $glue String, used for concatenating the breadcrumb items. |
||
152 | */ |
||
153 | public function set_glue( $glue = '' ) { |
||
156 | |||
157 | /** |
||
158 | * Retrieve the string before the opening link tag of a breadcrumb item. |
||
159 | * |
||
160 | * @access public |
||
161 | * |
||
162 | * @return string $link_before String before the opening link tag of a breadcrumb item. |
||
163 | */ |
||
164 | public function get_link_before() { |
||
167 | |||
168 | /** |
||
169 | * Modify the string before the opening link tag of a breadcrumb item. |
||
170 | * |
||
171 | * @access public |
||
172 | * |
||
173 | * @param string $link_before String before the opening link tag of a breadcrumb item. |
||
174 | */ |
||
175 | public function set_link_before( $link_before = '' ) { |
||
178 | |||
179 | /** |
||
180 | * Retrieve the string after the closing link tag of a breadcrumb item. |
||
181 | * |
||
182 | * @access public |
||
183 | * |
||
184 | * @return string $link_after String after the closing link tag of a breadcrumb item. |
||
185 | */ |
||
186 | public function get_link_after() { |
||
189 | |||
190 | /** |
||
191 | * Modify the string after the closing link tag of a breadcrumb item. |
||
192 | * |
||
193 | * @access public |
||
194 | * |
||
195 | * @param string $link_after String after the closing link tag of a breadcrumb item. |
||
196 | */ |
||
197 | public function set_link_after( $link_after = '' ) { |
||
200 | |||
201 | /** |
||
202 | * Retrieve the string before the breadcrumb items. |
||
203 | * |
||
204 | * @access public |
||
205 | * |
||
206 | * @return string $wrapper_before String before the breadcrumb items. |
||
207 | */ |
||
208 | public function get_wrapper_before() { |
||
211 | |||
212 | /** |
||
213 | * Modify the string before the breadcrumb items. |
||
214 | * |
||
215 | * @access public |
||
216 | * |
||
217 | * @param string $wrapper_before String before the breadcrumb items. |
||
218 | */ |
||
219 | public function set_wrapper_before( $wrapper_before = '' ) { |
||
222 | |||
223 | /** |
||
224 | * Retrieve the string after the breadcrumb items. |
||
225 | * |
||
226 | * @access public |
||
227 | * |
||
228 | * @return string $wrapper_after String after the breadcrumb items. |
||
229 | */ |
||
230 | public function get_wrapper_after() { |
||
233 | |||
234 | /** |
||
235 | * Modify the string after the breadcrumb items. |
||
236 | * |
||
237 | * @access public |
||
238 | * |
||
239 | * @param string $wrapper_after String after the breadcrumb items. |
||
240 | */ |
||
241 | public function set_wrapper_after( $wrapper_after = '' ) { |
||
244 | |||
245 | /** |
||
246 | * Retrieve the string before the title of a breadcrumb item. |
||
247 | * |
||
248 | * @access public |
||
249 | * |
||
250 | * @return string $title_before String before the title of a breadcrumb item. |
||
251 | */ |
||
252 | public function get_title_before() { |
||
255 | |||
256 | /** |
||
257 | * Modify the string before the title of a breadcrumb item. |
||
258 | * |
||
259 | * @access public |
||
260 | * |
||
261 | * @param string $title_before String before the title of a breadcrumb item. |
||
262 | */ |
||
263 | public function set_title_before( $title_before = '' ) { |
||
266 | |||
267 | /** |
||
268 | * Retrieve the string after the title of a breadcrumb item. |
||
269 | * |
||
270 | * @access public |
||
271 | * |
||
272 | * @return string $title_after String after the title of a breadcrumb item. |
||
273 | */ |
||
274 | public function get_title_after() { |
||
277 | |||
278 | /** |
||
279 | * Modify the string after the title of a breadcrumb item. |
||
280 | * |
||
281 | * @access public |
||
282 | * |
||
283 | * @param string $title_after String after the title of a breadcrumb item. |
||
284 | */ |
||
285 | public function set_title_after( $title_after = '' ) { |
||
288 | |||
289 | /** |
||
290 | * Retrieve the minimum number of items, necessary to display the trail. |
||
291 | * |
||
292 | * @access public |
||
293 | * |
||
294 | * @return int $min_items Minimum number of items, necessary to display the trail |
||
295 | */ |
||
296 | public function get_min_items() { |
||
299 | |||
300 | /** |
||
301 | * Modify the minimum number of items, necessary to display the trail. |
||
302 | * |
||
303 | * @access public |
||
304 | * |
||
305 | * @param int $min_items Minimum number of items, necessary to display the trail. |
||
306 | */ |
||
307 | public function set_min_items( $min_items ) { |
||
310 | |||
311 | /** |
||
312 | * Whether the last item will be displayed as a link. |
||
313 | * |
||
314 | * @access public |
||
315 | * |
||
316 | * @return bool $last_item_link Whether the last item will be displayed as a link. |
||
317 | */ |
||
318 | public function get_last_item_link() { |
||
321 | |||
322 | /** |
||
323 | * Change whether the last item will be displayed as a link. |
||
324 | * |
||
325 | * @access public |
||
326 | * |
||
327 | * @param bool $last_item_link Whether the last item will be displayed as a link. |
||
328 | */ |
||
329 | public function set_last_item_link( $last_item_link ) { |
||
332 | |||
333 | /** |
||
334 | * Whether the home item will be displayed. |
||
335 | * |
||
336 | * @access public |
||
337 | * |
||
338 | * @return bool $display_home_item Whether the home item will be displayed. |
||
339 | */ |
||
340 | public function get_display_home_item() { |
||
343 | |||
344 | /** |
||
345 | * Change whether the home item will be displayed. |
||
346 | * |
||
347 | * @access public |
||
348 | * |
||
349 | * @param bool $display_home_item Whether the home item will be displayed. |
||
350 | */ |
||
351 | public function set_display_home_item( $display_home_item ) { |
||
354 | |||
355 | /** |
||
356 | * Retrieve the title of the home item. |
||
357 | * |
||
358 | * @access public |
||
359 | * |
||
360 | * @return string $home_item_title The title of the home item. |
||
361 | */ |
||
362 | public function get_home_item_title() { |
||
365 | |||
366 | /** |
||
367 | * Modify the title of the home item. |
||
368 | * |
||
369 | * @access public |
||
370 | * |
||
371 | * @param string $home_item_title The title of the home item. |
||
372 | */ |
||
373 | public function set_home_item_title( $home_item_title = '' ) { |
||
376 | |||
377 | /** |
||
378 | * Prepare for rendering. |
||
379 | * Allows renderer to be modified in the last second. |
||
380 | * Also autosorts the trail items, if autosorting is enabled. |
||
381 | * |
||
382 | * @access public |
||
383 | * |
||
384 | * @param Carbon_Breadcrumb_Trail $trail Trail object. |
||
385 | */ |
||
386 | public function prepare_for_rendering( $trail ) { |
||
396 | |||
397 | /** |
||
398 | * Render the given breadcrumb trail. |
||
399 | * |
||
400 | * @access public |
||
401 | * |
||
402 | * @param Carbon_Breadcrumb_Trail $trail The trail object. |
||
403 | * @param bool $return Whether to return the output. |
||
404 | * @return string|void $output The output HTML if $return is true. |
||
405 | */ |
||
406 | public function render( Carbon_Breadcrumb_Trail $trail, $return = false ) { |
||
429 | |||
430 | /** |
||
431 | * Render the breadcrumb trail items. |
||
432 | * |
||
433 | * @access public |
||
434 | * |
||
435 | * @param Carbon_Breadcrumb_Trail $trail The trail object. |
||
436 | * @return array $output The output elements. |
||
437 | */ |
||
438 | public function render_items( $trail ) { |
||
460 | |||
461 | } |
||
462 |