hpdl
|
1
|
1
|
<?php
|
|
2
|
/*
|
mattice
|
151
|
3
|
$Id: breadcrumb.php 1861 2009-03-06 23:26:28Z hpdl $
|
hpdl
|
1
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
hpdl
|
1860
|
8
|
Copyright (c) 2007 osCommerce
|
hpdl
|
1
|
9
|
|
hpdl
|
1498
|
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
|
1860
|
15
|
/**
|
|
16
|
* The osC_Breadcrumb class handles the breadcrumb navigation path
|
|
17
|
*/
|
hpdl
|
1
|
18
|
|
hpdl
|
1861
|
19
|
class osC_Breadcrumb implements iterator {
|
hpdl
|
1
|
20
|
|
hpdl
|
1860
|
21
|
/**
|
|
22
|
* An array containing the breadcrumb navigation path
|
|
23
|
*
|
|
24
|
* @var array
|
|
25
|
* @access private
|
|
26
|
*/
|
|
27
|
|
|
28
|
private $_path = array();
|
|
29
|
|
|
30
|
/**
|
hpdl
|
1861
|
31
|
* The string to separate the breadcrumb entries with
|
|
32
|
*
|
|
33
|
* @var string
|
|
34
|
* @access private
|
|
35
|
*/
|
|
36
|
|
|
37
|
private $_separator = ' » ';
|
|
38
|
|
|
39
|
/**
|
hpdl
|
1860
|
40
|
* Resets the breadcrumb navigation path
|
|
41
|
*
|
|
42
|
* @access public
|
|
43
|
*/
|
|
44
|
|
|
45
|
public function reset() {
|
|
46
|
$this->_path = array();
|
hpdl
|
1
|
47
|
}
|
|
48
|
|
hpdl
|
1860
|
49
|
/**
|
|
50
|
* Adds an entry to the breadcrumb navigation path
|
|
51
|
*
|
|
52
|
* @param string $title The title of the breadcrumb navigation entry
|
|
53
|
* @param string $link The link of the breadcrumb navigation entry
|
|
54
|
* @access public
|
|
55
|
*/
|
|
56
|
|
|
57
|
public function add($title, $link = null) {
|
hpdl
|
1861
|
58
|
if ( !empty($link) ) {
|
|
59
|
$title = osc_link_object($link, $title);
|
|
60
|
}
|
|
61
|
|
|
62
|
$this->_path[] = $title;
|
hpdl
|
1
|
63
|
}
|
|
64
|
|
hpdl
|
1860
|
65
|
/**
|
|
66
|
* Returns the breadcrumb navigation path with the entries separated by $separator
|
|
67
|
*
|
|
68
|
* @param string $separator The string value to separate the breadcrumb navigation path entries with
|
|
69
|
* @access public
|
|
70
|
* @return string
|
|
71
|
*/
|
|
72
|
|
hpdl
|
1861
|
73
|
public function getPath($separator = null) {
|
|
74
|
if ( is_null($separator) ) {
|
|
75
|
$separator = $this->_separator;
|
hpdl
|
1
|
76
|
}
|
|
77
|
|
hpdl
|
1861
|
78
|
return implode($separator, $this->_path);
|
hpdl
|
1
|
79
|
}
|
hpdl
|
1860
|
80
|
|
|
81
|
/**
|
|
82
|
* Returns the breadcrumb navigation path array
|
|
83
|
*
|
|
84
|
* @access public
|
|
85
|
* @return array
|
|
86
|
*/
|
|
87
|
|
|
88
|
public function getArray() {
|
|
89
|
return $this->_path;
|
|
90
|
}
|
hpdl
|
1861
|
91
|
|
|
92
|
/**
|
|
93
|
* Returns the breadcrumb separator
|
|
94
|
*
|
|
95
|
* @access public
|
|
96
|
* @return string
|
|
97
|
*/
|
|
98
|
|
|
99
|
public function getSeparator() {
|
|
100
|
return $this->_separator;
|
|
101
|
}
|
|
102
|
|
|
103
|
/**
|
|
104
|
* Sets the breadcrumb string separator
|
|
105
|
*
|
|
106
|
* @param string $separator The string to separator breadcrumb entries with
|
|
107
|
* @access public
|
|
108
|
* @return string
|
|
109
|
*/
|
|
110
|
|
|
111
|
public function setSeparator($separator) {
|
|
112
|
$this->_separator = $separator;
|
|
113
|
}
|
|
114
|
|
|
115
|
/**
|
|
116
|
* Overloaded rewind iterator function
|
|
117
|
*
|
|
118
|
* @access public
|
|
119
|
*/
|
|
120
|
|
|
121
|
public function rewind() {
|
|
122
|
return reset($this->_path);
|
|
123
|
}
|
|
124
|
|
|
125
|
/**
|
|
126
|
* Overloaded current iterator function
|
|
127
|
*
|
|
128
|
* @access public
|
|
129
|
*/
|
|
130
|
|
|
131
|
public function current() {
|
|
132
|
return current($this->_path);
|
|
133
|
}
|
|
134
|
|
|
135
|
/**
|
|
136
|
* Overloaded key iterator function
|
|
137
|
*
|
|
138
|
* @access public
|
|
139
|
*/
|
|
140
|
|
|
141
|
public function key() {
|
|
142
|
return key($this->_path);
|
|
143
|
}
|
|
144
|
|
|
145
|
/**
|
|
146
|
* Overloaded next iterator function
|
|
147
|
*
|
|
148
|
* @access public
|
|
149
|
*/
|
|
150
|
|
|
151
|
public function next() {
|
|
152
|
return next($this->_path);
|
|
153
|
}
|
|
154
|
|
|
155
|
/**
|
|
156
|
* Overloaded valid iterator function
|
|
157
|
*
|
|
158
|
* @access public
|
|
159
|
*/
|
|
160
|
|
|
161
|
public function valid() {
|
|
162
|
return ( current($this->_path) !== false );
|
|
163
|
}
|
hpdl
|
1
|
164
|
}
|
|
165
|
?>
|