1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20:
21:
22: class SystemBreadcrumb
23: {
24: 25: 26:
27: private $_directory = '';
28:
29: 30: 31:
32: private $_bread = array();
33:
34: var $_help;
35:
36: var $_tips;
37:
38: 39: 40: 41: 42:
43: private function __construct($fct)
44: {
45: if ($fct != '') {
46: $this->_directory = $fct;
47: }
48: }
49:
50: 51: 52: 53: 54: 55: 56: 57:
58: static public function getInstance($fct = '')
59: {
60: static $instance;
61: if (!isset($instance)) {
62: $class = __CLASS__;
63: $instance = new $class($fct);
64: }
65: return $instance;
66: }
67:
68: public function setDirectory($fct)
69: {
70: $this->_directory = $fct;
71: }
72:
73: 74: 75: 76:
77: function addLink($title = '', $link = '', $home = false)
78: {
79: $this->_bread[] = array(
80: 'link' => $link, 'title' => $title, 'home' => $home
81: );
82: }
83:
84: 85: 86: 87:
88: function addHelp($link = '')
89: {
90: $this->_help = $link;
91: }
92:
93: 94: 95: 96:
97: function addTips($value)
98: {
99: $this->_tips = $value;
100: }
101:
102: 103: 104: 105:
106: function render()
107: {
108: $xoops = Xoops::getInstance();
109: if ($xoops->tpl()) {
110: $xoops->tpl()->assign('xo_sys_breadcrumb', $this->_bread);
111: $xoops->tpl()->assign('xo_sys_help', $this->_help);
112: if ($this->_tips) {
113: if ($xoops->getModuleConfig('usetips', 'system')) {
114: $xoops->tpl()->assign('xo_sys_tips', $this->_tips);
115: }
116: }
117:
118: if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/system/language/' . $xoops->getConfig('language') . '/help/' . $this->_directory . '.html')) {
119: $xoops->tpl()
120: ->assign('help_content', \XoopsBaseConfig::get('root-path') . '/modules/system/language/' . $xoops->getConfig('language') . '/help/' . $this->_directory . '.html');
121: } else {
122: if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/system/language/english/help/' . $this->_directory . '.html')) {
123: $xoops->tpl()
124: ->assign('help_content', \XoopsBaseConfig::get('root-path') . '/modules/system/language/english/help/' . $this->_directory . '.html');
125: } else {
126: $xoops->tpl()->assign('load_error', 1);
127: }
128: }
129: } else {
130: $out = $menu = '<style type="text/css" media="screen">@import ' . \XoopsBaseConfig::get('url') . '/modules/system/css/menu.css;</style>';
131: $out .= '<ul id="xo-breadcrumb">';
132: foreach ($this->_bread as $menu) {
133: if ($menu['home']) {
134: $out .= '<li><a href="' . $menu['link'] . '" title="' . $menu['title'] . '"><img src="images/home.png" alt="' . $menu['title'] . '" class="home" /></a></li>';
135: } else {
136: if ($menu['link'] != '') {
137: $out .= '<li><a href="' . $menu['link'] . '" title="' . $menu['title'] . '">' . $menu['title'] . '</a></li>';
138: } else {
139: $out .= '<li>' . $menu['title'] . '</li>';
140: }
141: }
142: }
143: $out .= '</ul>';
144: if ($this->_tips) {
145: $out .= '<div class="tips">' . $this->_tips . '</div>';
146: }
147: echo $out;
148: }
149: }
150: }
151: