Quick Search:

View

Revision:

Diff

Diff from 1670 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/includes/classes/breadcrumb.php

Annotated File View

hpdl
1
1 <?php
2 /*
hpdl
153
3   $Id: breadcrumb.php 1670 2007-07-20 21:11:18Z hpdl $
hpdl
1
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
1670
8   Copyright (c) 2007 osCommerce
hpdl
1
9
hpdl
1497
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License v2 (1991)
12   as published by the Free Software Foundation.
hpdl
1
13 */
14
hpdl
1670
15 /**
16  * The osC_Breadcrumb class handles the breadcrumb navigation path
17  */
hpdl
1
18
hpdl
1670
19   class osC_Breadcrumb {
hpdl
1
20
hpdl
1670
21 /**
22  * An array containing the breadcrumb navigation path
23  *
24  * @var array
25  * @access private
26  */
27
28     private $_path = array();
29
30 /**
31  * Resets the breadcrumb navigation path
32  *
33  * @access public
34  */
35
36     public function reset() {
37       $this->_path = array();
hpdl
1
38     }
39
hpdl
1670
40 /**
41  * Adds an entry to the breadcrumb navigation path
42  *
43  * @param string $title The title of the breadcrumb navigation entry
44  * @param string $link The link of the breadcrumb navigation entry
45  * @access public
46  */
47
48     public function add($title, $link = null) {
49       $this->_path[] = array('title' => $title,
50                              'link' => $link);
hpdl
1
51     }
52
hpdl
1670
53 /**
54  * Returns the breadcrumb navigation path with the entries separated by $separator
55  *
56  * @param string $separator The string value to separate the breadcrumb navigation path entries with
57  * @access public
58  * @return string
59  */
60
61     public function getPath($separator = ' - ') {
hpdl
1
62       $trail_string = '';
63
hpdl
1670
64       $trail_size = sizeof($this->_path);
65       $counter = 0;
66
67       foreach ( $this->_path as $entry ) {
68         $counter++;
69
70         if ( !empty($entry['link']) ) {
71           $trail_string .= osc_link_object($entry['link'], $entry['title']);
hpdl
1
72         } else {
hpdl
1670
73           $trail_string .= $entry['title'];
hpdl
1
74         }
75
hpdl
1670
76         if ( $counter < $trail_size ) {
77           $trail_string .= $separator;
78         }
hpdl
1
79       }
80
81       return $trail_string;
82     }
hpdl
1670
83
84 /**
85  * Returns the breadcrumb navigation path array
86  *
87  * @access public
88  * @return array
89  */
90
91     public function getArray() {
92       return $this->_path;
93     }
hpdl
1
94   }
95 ?>