hpdl
|
1
|
1
|
<?php
|
|
2
|
/*
|
mattice
|
151
|
3
|
$Id: breadcrumb.php 1860 2009-03-06 23:25:01Z 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
|
1860
|
19
|
class osC_Breadcrumb {
|
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
|
/**
|
|
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
|
1860
|
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
|
1860
|
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
|
1860
|
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
|
1860
|
73
|
$trail_string .= $entry['title'];
|
hpdl
|
1
|
74
|
}
|
|
75
|
|
hpdl
|
1860
|
76
|
if ( $counter < $trail_size ) {
|
|
77
|
$trail_string .= $separator;
|
|
78
|
}
|
hpdl
|
1
|
79
|
}
|
|
80
|
|
|
81
|
return $trail_string;
|
|
82
|
}
|
hpdl
|
1860
|
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
|
?>
|