XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
breadcrumb.php
Go to the documentation of this file.
1 <?php
2 // $Id: breadcrumb.php 825 2011-12-09 00:06:11Z i.bitcero $
3 // --------------------------------------------------------------
4 // Red México Common Utilities
5 // A framework for Red México Modules
6 // Author: Eduardo Cortés <i.bitcero@gmail.com>
7 // Email: i.bitcero@gmail.com
8 // License: GPL 2.0
9 // --------------------------------------------------------------
10 
17 {
18  private $crumbs = array();
19 
20  public function construct(){
21 
22  }
23 
27  public function get(){
28  static $instance;
29 
30  if (!isset($instance)) {
31  $instance = new RMBreadCrumb();
32  }
33 
34  return $instance;
35 
36  }
37 
50  public function add_crumb($caption, $link='', $icon='', $menu=array()){
51 
52  if(trim($caption)=='') return 0;
53 
54  $this->crumbs[] = array(
55  'caption' => $caption,
56  'link' => $link,
57  'icon' => $icon,
58  'menu' => $menu
59  );
60 
61  end($this->crumbs);
62  return key($this->crumbs);
63 
64  }
65 
73  public function add_menu($id, $caption, $link, $icon=''){
74 
75  if(trim($caption)=='' || trim($link)=='') return 0;
76 
77  if(!isset($this->crumbs[$id])) return 0;
78 
79  $this->crumbs[$id]['menu'] = array(
80  'caption' => $caption,
81  'link' => $link,
82  'icon' => $icon
83  );
84 
85  }
86 
90  public function clear(){
91  $this->crumbs = array();
92  }
93 
99  public function render(){
100 
101  RMTemplate::get()->add_style('breadcrumb.css', 'rmcommon');
102  ob_start();
103 
104  include RMTemplate::get()->get_template('rmc_breadcrumb.php', 'module', 'rmcommon');
105 
106  $ret = ob_get_clean();
107  return $ret;
108 
109  }
110 
111 }