1 | <?php |
||
13 | class Carbon_Breadcrumb_Trail { |
||
14 | |||
15 | /** |
||
16 | * Breadcrumb items. |
||
17 | * |
||
18 | * @access protected |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $items = array(); |
||
22 | |||
23 | /** |
||
24 | * Breadcrumb trail renderer. |
||
25 | * |
||
26 | * @access protected |
||
27 | * @var Carbon_Breadcrumb_Trail_Renderer |
||
28 | */ |
||
29 | protected $renderer; |
||
30 | |||
31 | /** |
||
32 | * Constructor. |
||
33 | * |
||
34 | * Creates and configures a new breadcrumb trail with the provided settings. |
||
35 | * |
||
36 | * @access public |
||
37 | * |
||
38 | * @param array $settings Configuration options to modify the breadcrumb trail output. |
||
39 | */ |
||
40 | public function __construct( $settings = array() ) { |
||
56 | |||
57 | /** |
||
58 | * Retrieve the renderer object. |
||
59 | * |
||
60 | * @access public |
||
61 | * |
||
62 | * @return Carbon_Breadcrumb_Trail_Renderer $renderer The renderer object. |
||
63 | */ |
||
64 | public function get_renderer() { |
||
67 | |||
68 | /** |
||
69 | * Modify the rendering object. |
||
70 | * |
||
71 | * @access public |
||
72 | * |
||
73 | * @param Carbon_Breadcrumb_Trail_Renderer $renderer The modified rendering object. |
||
74 | */ |
||
75 | public function set_renderer( Carbon_Breadcrumb_Trail_Renderer $renderer ) { |
||
78 | |||
79 | /** |
||
80 | * Populate the breadcrumb items for the current context. |
||
81 | * |
||
82 | * @access public |
||
83 | */ |
||
84 | public function setup() { |
||
96 | |||
97 | /** |
||
98 | * Add a single Carbon_Breadcrumb_Item or an array of them to the trail. |
||
99 | * |
||
100 | * @access public |
||
101 | * |
||
102 | * @param mixed $item The item or array of items to add. |
||
103 | */ |
||
104 | public function add_item( $item ) { |
||
114 | |||
115 | /** |
||
116 | * Add a custom breadcrumb item to the trail. |
||
117 | * |
||
118 | * @access public |
||
119 | * |
||
120 | * @param string $title Breadcrumb item title. |
||
121 | * @param string $link Breadcrumb item link. |
||
122 | * @param int $priority Breadcrumb item priority. |
||
123 | */ |
||
124 | public function add_custom_item( $title, $link = '', $priority = 1000 ) { |
||
131 | |||
132 | /** |
||
133 | * Remove an item from the breadcrumb trail by both title and link. |
||
134 | * |
||
135 | * @access public |
||
136 | * |
||
137 | * @param string $title Title to remove breadcrumb item by. |
||
138 | * @param string $link Link URL to remove breadcrumb item by. |
||
139 | */ |
||
140 | public function remove_item( $title = '', $link = '' ) { |
||
155 | |||
156 | /** |
||
157 | * Remove an item from the breadcrumb trail by a specified method. |
||
158 | * |
||
159 | * @access public |
||
160 | * |
||
161 | * @param string $method Item method to remove breadcrumb item by. |
||
162 | * @param string $data Additional data to pass to the method. |
||
163 | */ |
||
164 | public function remove_item_by_method( $method, $data ) { |
||
180 | |||
181 | /** |
||
182 | * Remove an item from the breadcrumb trail by its title. |
||
183 | * |
||
184 | * @access public |
||
185 | * |
||
186 | * @param string $title Title to remove breadcrumb item by. |
||
187 | */ |
||
188 | public function remove_item_by_title( $title = '' ) { |
||
191 | |||
192 | /** |
||
193 | * Remove an item from the breadcrumb trail by its link. |
||
194 | * |
||
195 | * @access public |
||
196 | * |
||
197 | * @param string $link Link URL to remove breadcrumb item by. |
||
198 | */ |
||
199 | public function remove_item_by_link( $link = '' ) { |
||
202 | |||
203 | /** |
||
204 | * Remove an item from the breadcrumb trail by its priority. |
||
205 | * |
||
206 | * @access public |
||
207 | * |
||
208 | * @param int $priority Priority to remove breadcrumb item by. |
||
209 | */ |
||
210 | public function remove_item_by_priority( $priority = 0 ) { |
||
221 | |||
222 | /** |
||
223 | * Retrieve the breadcrumb items that are currently loaded. |
||
224 | * |
||
225 | * @access public |
||
226 | * |
||
227 | * @return array $items The breadcrumb items, contained in the trail. |
||
228 | */ |
||
229 | public function get_items() { |
||
232 | |||
233 | /** |
||
234 | * Retrieve the breadcrumb items in a flat list. |
||
235 | * |
||
236 | * @access public |
||
237 | * |
||
238 | * @return array $flat_items The breadcrumb items, contained in the trail. |
||
239 | */ |
||
240 | public function get_flat_items() { |
||
249 | |||
250 | /** |
||
251 | * Modify the currently loaded breadcrumb items. |
||
252 | * |
||
253 | * @access public |
||
254 | * |
||
255 | * @param array $items The new set of breadcrumb items. |
||
256 | */ |
||
257 | public function set_items( $items = array() ) { |
||
260 | |||
261 | /** |
||
262 | * Sort the currently loaded breadcrumb items by their priority. |
||
263 | * |
||
264 | * @access public |
||
265 | */ |
||
266 | public function sort_items() { |
||
271 | |||
272 | /** |
||
273 | * Retrieve the total number of breadcrumb items in the trail. |
||
274 | * |
||
275 | * @access public |
||
276 | * |
||
277 | * @return int $total_items Number of items in the breadcrumb trail. |
||
278 | */ |
||
279 | public function get_total_items() { |
||
283 | |||
284 | /** |
||
285 | * Render the breadcrumb trail. |
||
286 | * |
||
287 | * @access public |
||
288 | * |
||
289 | * @param bool $return Whether to return the output. |
||
290 | * @return string|void $output The output HTML if $return is true. |
||
291 | */ |
||
292 | public function render( $return = false ) { |
||
303 | |||
304 | /** |
||
305 | * Build, setup and display a new breadcrumb trail. |
||
306 | * |
||
307 | * @static |
||
308 | * @access public |
||
309 | * |
||
310 | * @param array $args Configuration options to modify the breadcrumb trail output. |
||
311 | */ |
||
312 | public static function output( $args = array() ) { |
||
317 | |||
318 | } |
||
319 |