XOOPS  2.6.0
menu.php
Go to the documentation of this file.
1 <?php
2 /*
3  * You may not change or alter any portion of this comment or credits
4  * of supporting developers from this source code or any supporting source code
5  * which is considered copyrighted (c) material of the original comment or credit authors.
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9  */
10 
23 {
28  private $_menutop = array();
29  private $_menutabs = array();
30  private $_obj;
31  private $_header;
32  private $_subheader;
33 
37  public function __construct()
38  {
40  $this->_obj = $xoops->module;
41  }
42 
43  public function getAddon($addon)
44  {
45  $this->_obj = $addon;
46  }
47 
51  public function addMenuTop($link, $name = "")
52  {
53  $this->_menutop[] = array('link' => $link, 'name' => $name);
54  }
55 
56  public function addMenuTopArray($options, $multi = true)
57  {
58  if (is_array($options)) {
59  if ($multi == true) {
60  foreach ($options as $k => $v) {
61  $this->addOptionTop($k, $v);
62  }
63  } else {
64  foreach ($options as $k) {
65  $this->addOptiontop($k, $k);
66  }
67  }
68  }
69  }
70 
74  public function addMenuTabs($link, $name = "")
75  {
76  $this->_menutabs[] = array('link' => $link, 'name' => $name, 'current' => 0);
77  }
78 
79  public function addMenuTabsArray($options, $multi = true)
80  {
81  if (is_array($options)) {
82  if ($multi == true) {
83  foreach ($options as $k => $v) {
84  $this->addMenuTabsTop($k, $v);
85  }
86  } else {
87  foreach ($options as $k) {
88  $this->addMenuTabsTop($k, $k);
89  }
90  }
91  }
92  }
93 
94  public function addHeader($value)
95  {
96  $this->_header = $value;
97  }
98 
99  public function addSubHeader($value)
100  {
101  $this->_subheader = $value;
102  }
103 
104  public function breadcrumb_nav($basename = "Home")
105  {
106  global $bc_site, $bc_label;
107  $site = $bc_site;
108  $return_str = "<a href=\"/\">$basename</a>";
109  $str = substr(dirname(Xoops::getInstance()->getEnv('PHP_SELF')), 1);
110 
111  $arr = split('/', $str);
112  $num = count($arr);
113 
114  if ($num > 1) {
115  foreach ($arr as $val) {
116  $return_str .= ' &gt; <a href="' . $site . $val . '/">' . $bc_label[$val] . '</a>';
117  $site .= $val . '/';
118  }
119  } else {
120  if ($num == 1) {
121  $arr = $str;
122  $return_str .= ' &gt; <a href="' . $bc_site . $arr . '/">' . $bc_label[$arr] . '</a>';
123  }
124  }
125 
126  return $return_str;
127  }
128 
129  public function render($currentoption = 1, $display = true)
130  {
132  $xoops->tpl()->assign('xo_module_menu_top', $this->_menutop);
133  $this->_menutabs[$currentoption]['current'] = 1;
134  $xoops->tpl()->assign('xo_module_menu_tab', $this->_menutabs);
135  //$xoops->tpl()->assign('xo_admin_help', $this->_help);
136  //if ($xoops->tpl()_name == '') {
137  // $xoops->tpl()->display('admin:system/admin_tabs.tpl');
138  //}
139  return;
140 
141  global $modversion;
142  $_dirname = $this->_obj->getVar('dirname');
143  $i = 0;
144 
148  foreach ($this->_menutabs as $k => $menus) {
149  $menuItems[] = $menus;
150  }
151  $breadcrumb = $menuItems[$currentoption];
152  $menuItems[$currentoption] = 'current';
153  //Not the best method of adding CSS but the only method available at the moment since xoops is shitty with the backend
154  //$menu = "<style type=\"text/css\" media=\"screen\">@import \"" . \XoopsBaseConfig::get('url') . "/modules/" . $this->_obj->getVar('dirname') . "/css/menu.css\";</style>";
155  $menu = "<div id='buttontop_mod'>";
156  $menu .= "<table style='width: 100%; padding: 0;' cellspacing='0'>\n<tr>";
157  $menu .= "<td style='font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;'>";
158  foreach ($this->_menutop as $k => $v) {
159  $menu .= " <a href=\"$k\">$v</a> |";
160  }
161  $menu = substr($menu, 0, -1);
162 
163  $menu .= "</td>";
164  $menu .= "<td style='text-align: right;'><strong>" . $this->_obj->getVar('name') . "</strong> : " . $breadcrumb . "</td>";
165  $menu .= "</tr>\n</table>\n";
166  $menu .= "</div>\n";
167  $menu .= "<div id='buttonbar_mod'><ul>";
168  foreach ($this->_menutabs as $k => $v) {
169  $menu .= "<li id='" . $menuItems[$i] . "'><a href='" . \XoopsBaseConfig::get('url') . "/modules/" . $this->_obj->getVar('dirname') . "/" . $k . "'><span>$v</span></a></li>\n";
170  ++$i;
171  }
172  $menu .= "</ul>\n</div>\n";
173  if ($this->_header) {
174  $menu .= "<h4 class='admin_header'>";
175  if (isset($modversion['name'])) {
176  if ($modversion['image'] && $this->_obj->getVar('mid') == 1) {
177  $system_image = \XoopsBaseConfig::get('url') . '/modules/system/images/system/' . $modversion['image'];
178  } else {
179  $system_image = \XoopsBaseConfig::get('url') . '/modules/' . $_dirname . '/images/' . $modversion['image'];
180  }
181  $menu .= "<img src='$system_image' align='middle' height='32' width='32' alt='' />";
182  $menu .= " " . $modversion['name'] . "</h4>\n";
183  } else {
184  $menu .= " " . $this->_header . "</h4>\n";
185  }
186  }
187  if ($this->_subheader) {
188  $menu .= "<div class='admin_subheader'>" . $this->_subheader . "</div>\n";
189  }
190  $menu .= '<div class="clear">&nbsp;</div>';
191  unset($this->_obj);
192  if ($display == true) {
193  echo $menu;
194  } else {
195  return $menu;
196  }
197  }
198 }
breadcrumb_nav($basename="Home")
Definition: menu.php:104
static getInstance()
Definition: Xoops.php:160
$options['editor']
addMenuTabs($link, $name="")
Definition: menu.php:74
$link
Definition: userinfo.php:84
$menu
static get($name)
$i
Definition: menu.php:24
addSubHeader($value)
Definition: menu.php:99
$modversion
addHeader($value)
Definition: menu.php:94
$xoops
Definition: menu.php:23
addMenuTabsArray($options, $multi=true)
Definition: menu.php:79
getAddon($addon)
Definition: menu.php:43
addMenuTopArray($options, $multi=true)
Definition: menu.php:56
addMenuTop($link, $name="")
Definition: menu.php:51
$breadcrumb
render($currentoption=1, $display=true)
Definition: menu.php:129