-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMybreadcrumb.php
More file actions
88 lines (71 loc) · 1.82 KB
/
Mybreadcrumb.php
File metadata and controls
88 lines (71 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class CI_Mybreadcrumb {
private $breadcrumbs = array();
private $tags = "";
function __construct()
{
$this->tags['open'] = "<ol class='breadcrumb'>";
$this->tags['close'] = "</ol>";
$this->tags['itemOpen'] = "<li>";
$this->tags['itemClose'] = "</li>";
}
function add($title, $href){
if (!$title OR !$href) return;
$this->breadcrumbs[] = array('title' => $title, 'href' => $href);
}
function openTag($tags=""){
if(empty($tags)){
return $this->tags['open'];
}else{
$this->tags['open'] = $tags;
}
}
function closeTag($tags=""){
if(empty($tags)){
return $this->tags['close'];
}else{
$this->tags['close'] = $tags;
}
}
function itemOpenTag($tags=""){
if(empty($tags)){
return $this->tags['itemOpen'];
}else{
$this->tags['itemOpen'] = $tags;
}
}
function itemCloseTage($tags=""){
if(empty($tags)){
return $this->tags['itemClose'];
}else{
$this->tags['itemClose'] = $tags;
}
}
function render(){
if(!empty($this->tags['open'])){
$output = $this->tags['open'];
}else{
$output = '<ol class="breadcrumb">';
}
$count = count($this->breadcrumbs)-1;
foreach($this->breadcrumbs as $index => $breadcrumb){
if($index == $count){
$output .= '<li class="active">';
$output .= $breadcrumb['title'];
$output .= '</li>';
}else{
$output .= ($this->tags['itemOpen'])?$this->tags['itemOpen']:'<li>';
$output .= '<a href="'.$breadcrumb['href'].'">';
$output .= $breadcrumb['title'];
$output .= '</a>';
$output .= '</li>';
}
}
if(!empty($this->tags['open'])){
$output .= $this->tags['close'];
}else{
$output .= "</ol>";
}
return $output;
}
}