Removed the tree filter toggle
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_topmenubase.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Base class for scripts delivering content to the top menu bar/icon panel.
29 *
30 * $Id$
31 *
32 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 */
38
39
40
41
42 /**
43 * Base class for scripts delivering content to the top menu bar/icon panel.
44 *
45 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
46 * @package TYPO3
47 * @subpackage core
48 */
49 class t3lib_topmenubase {
50
51 function menuItems($menuItems) {
52 $output = '';
53
54 // Traverse items:
55 foreach($menuItems as $item) {
56
57 // Divider has no other options:
58 if ($item['title']=='--div--') {
59 $output.= '<div class="menuLayerItem_divider" onmouseover="menuOpenSub(this);"></div>';
60 } else {
61
62 $itemCode = '';
63 $onClick = '';
64
65 // Render subitems if any:
66 if (is_array($item['subitems'])) {
67 $itemCode.= $this->menuLayer($item['subitems'],$item['id']);
68 }
69
70 // Render state icon if any:
71 switch ($item['state']) {
72 case 'checked';
73 $itemCode.= '<img src="gfx/x_state_checked.png" width="16" class="menulayerItemIcon">';
74 break;
75 default:
76 $itemCode.= '<img src="gfx/clear.gif" width="16" class="menulayerItemIcon">';
77 break;
78 }
79
80 // Render icon if any:
81 if ($item['icon']) {
82 if (is_array($item['icon'])) {
83 $itemCode.= '<img '.t3lib_iconWorks::skinImg('',$item['icon'][0],$item['icon'][1]).' class="menulayerItemIcon" alt="" />';
84 } else {
85 $itemCode.= $item['icon'];
86 }
87 }
88
89 // Title:
90 $itemCode.= htmlspecialchars($item['title']).'&nbsp;&nbsp;';
91
92 // if subitems, show arrow pointing right:
93 $itemCode.= is_array($item['subitems']) ? '<img src="gfx/x_thereismore.png" class="menulayerItemIcon" style="padding-left:40px;">' : '';
94
95 // Set onclick handlers:
96 $onClick.= $item['xurl'] ? "if (Event.element(event)==this){openUrlInWindow('".$item['xurl']."','aWindow');}" : '';
97 $onClick.= $item['url'] ? "if (Event.element(event)==this){content.document.location='".$item['url']."';}" : '';
98 $onClick.= $item['onclick'] ? $item['onclick'] : $item['onclick'];
99
100 // Wrap it all up:
101 $output.= '<div '.($item['id'] ? 'id="'.htmlspecialchars($item['id']).'"' : '').'class="menuLayerItem" onmouseover="menuOpenSub(this);"'.($onClick ? ' onclick="'.htmlspecialchars($onClick).'"' : '').'>'.$itemCode.'</div>';
102 $output.= $item['html'];
103 }
104 }
105
106 return $output;
107 }
108 /**
109 *
110 */
111 function menuLayer($menuItems,$baseid='') {
112 $output = $this->menuItems($menuItems);
113
114 // Encapsulate in menu layer:
115 return $this->simpleLayer($output,$baseid?$baseid.'-layer':'');
116 }
117
118 function simpleLayer($output,$id='',$class='menulayer') {
119 return '<div class="'.$class.'" style="display: none;"'.($id?' id="'.htmlspecialchars($id).'"':'').'>'.$output.'</div>';
120 }
121
122 function menuItemLayer($id,$content,$onclick='') {
123 return '<div id="'.$id.'" class="menuItems menu-normal" style="float: left;" onclick="menuToggleState(\''.$id.'\');'.$onclick.'" onmouseover="menuMouseOver(\''.$id.'\');" onmouseout="menuMouseOut(\''.$id.'\');">'.$content.'</div>';
124 }
125 function menuItemObject($id,$functionContent) {
126 return '
127 <script>
128 menuItemObjects[\''.$id.'\'] = {
129 '.$functionContent.'
130 }
131 </script>
132 ';
133 }
134 }
135
136 ?>