In mail.php, we don't want to double encode fields so in send() create local variable...
[isso.git] / printer_navigation.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 /**
23 * Printer - Navigation Generator
24 * printer_navigation.php
25 *
26 * @package ISSO
27 */
28
29 /**
30 * Printer - Navigation Generator
31 *
32 * This framework works in conjunction with ISSO.Printer to generate a page header
33 * and sidebar to be used for navigation. You set the navigation array and then can
34 * specify a given key to highlight elements. Elements are broken into three types:
35 * tabs (top of the page), groups (blocks of link actions), and links
36 *
37 * @author Blue Static
38 * @copyright Copyright ©2002 - [#]year[#], Blue Static
39 * @version $Revision$
40 * @package ISSO
41 *
42 */
43 class Printer_Navigation
44 {
45 /**
46 * Framework registry object
47 * @var object
48 * @access private
49 */
50 var $registry = null;
51
52 /**
53 * Global links that are used for admin home, logout, etc.
54 * @var array
55 * @access private
56 */
57 var $toplinks = array();
58
59 /**
60 * Navigational tabs: array(text, url)
61 * @var array
62 * @access private
63 */
64 var $tabs = array();
65
66 /**
67 * Sections: text
68 * @var array
69 * @access private
70 */
71 var $sections = array();
72
73 /**
74 * Links: array(text, url)
75 * @var array
76 * @access private
77 */
78 var $links = array();
79
80 /**
81 * Array of scopes to set focus to key
82 * @var array
83 * @access private
84 */
85 var $focus = array('tab' => null, 'link' => null);
86
87 // ###################################################################
88 /**
89 * Constructor
90 */
91 function __construct(&$registry)
92 {
93 $this->registry =& $registry;
94 }
95
96 // ###################################################################
97 /**
98 * (PHP 4) Constructor
99 */
100 function Printer_Navigation(&$registry)
101 {
102 $this->__construct($registry);
103 }
104
105 // ###################################################################
106 /**
107 * Adds a global link to the array; these cannot be removed once added
108 *
109 * @access public
110 *
111 * @param string Link text
112 * @param string HREF of the URL
113 */
114 function add_top_link($text, $href)
115 {
116 $this->toplinks["$href"] = $text;
117 }
118
119 // ###################################################################
120 /**
121 * Adds to the structure array. The following is the global structure
122 * of the array, but you can specify any entry point. When you add onto
123 * the structure, it will go at the bottom
124 * array(
125 * '<tab>unique_key' => array(
126 * '<section>unique_key' => array(
127 * '<link>unique_key' => array('text', 'url')
128 * )
129 * )
130 * )
131 *
132 * Note that the portion in brackets is called the "scope"
133 *
134 * @access public
135 *
136 * @param string Scope to add to
137 * @param string Unique key for the scope
138 * @param string Parent key to add to
139 * @param string Text to display (usually localized)
140 * @param string URL to go to when text is clicked
141 */
142 function add_component($scope, $key, $parent, $text, $url)
143 {
144 if ($scope == 'tab')
145 {
146 $this->tabs["$key"] = array($text, $url);
147 }
148 else if ($scope == 'section')
149 {
150 $this->sections["$parent"]["$key"] = $text;
151 }
152 else if ($scope == 'link')
153 {
154 $this->links["$parent"]["$key"] = array($text, $url);
155 }
156 }
157
158 // ###################################################################
159 /**
160 * Sets the focus for either a tab or link
161 *
162 * @access public
163 *
164 * @param string Scope operator
165 * @param string Unique key in scope
166 * @param string Parent operator (links only)
167 */
168 function set_focus($scope, $key, $parent)
169 {
170 if ($scope == 'tab')
171 {
172 if (isset($this->tabs["$key"]))
173 {
174 $this->focus["$scope"] = $key;
175 }
176 else
177 {
178 trigger_error('Invalid key for scope', E_USER_WARNING);
179 }
180 }
181 else if ($scope == 'link')
182 {
183 if (isset($this->links["$parent"]["$key"]))
184 {
185 $this->focus["$scope"] = $key;
186 }
187 else
188 {
189 trigger_error('Invalid key for scope', E_USER_WARNING);
190 }
191 }
192 else
193 {
194 trigger_error('Printer_Navigation::set_focus() only allows setting of focus for tab and link scopes', E_USER_ERROR);
195 }
196 }
197
198 // ###################################################################
199 /**
200 * Generates the header HTML that is called in ISSO.Printer->page_start()
201 * to setup the navigation frame
202 *
203 * @access public
204 *
205 * @return string Generated HTML content
206 */
207 function generate_header_html()
208 {
209 $output = '<!-- navigation start -->' . "\n\n";
210
211 // -------------------------------------------------------------------
212
213 $output2 = array();
214 foreach ($this->toplinks AS $href => $text)
215 {
216 $output2[] = '<a href="' . $href . '">' . $text . '</a>';
217 }
218
219 $language = $this->registry->modules['printer']->getLanguageInformation();
220
221 $output .= "\n" . '<div id="toplinks" style="float: ' . ($language['direction'] == 'rtl' ? 'left' : 'right') . '">';
222 $output .= "\n\t" . '<div>' . $this->registry->getApplication() . ' ' . $this->registry->modules['printer']->getRealm() . '</div>';
223 $output .= "\n\t" . '<div id="toplinks-links">' . implode(' &bull; ', $output2) . '</div>';
224 $output .= "\n" . '</div>';
225
226 // -------------------------------------------------------------------
227
228 $output .= "\n\n" . '<div id="wrapper">';
229
230 // -------------------------------------------------------------------
231
232 $output .= "\n" . '<div id="tabbar">';
233 foreach ($this->tabs AS $key => $content)
234 {
235 $link = "\n\t" . '<a href="' . $content[1] . '"';
236 if ($this->focus['tab'] == $key)
237 {
238 $link .= ' id="focustab"';
239 }
240
241 $link .= '><span>' . $content[0] . '</span></a>';
242
243 $output .= $link;
244 }
245 $output .= "\n" . '</div>';
246
247 // -------------------------------------------------------------------
248
249 $output .= "\n\n" . '<table id="contentbody" cellspacing="0" cellpadding="0" border="0">';
250 $output .= "\n" . '<tr>';
251
252 // -------------------------------------------------------------------
253
254 $output .= "\n" . '<td id="menu">';
255 foreach ((array)$this->sections[ $this->focus['tab'] ] AS $key => $text)
256 {
257 $output .= "\n" . '<ul>';
258 $output .= "\n\t" . '<li class="header"><span>' . $text . '</span></li>';
259 foreach ((array)$this->links["$key"] AS $key2 => $content)
260 {
261 $output .= "\n\t" . '<li' . ($this->focus['link'] == $key2 ? ' class="focus"' : '') . '><a href="' . $content[1] . '"><span>' . $content[0] . '</span></a></li>';
262 }
263 $output .= "\n" . '</ul>' . "\n";
264 }
265 $output .= "\n" . '</td>';
266
267 // -------------------------------------------------------------------
268
269 $output .= "\n" . '<td id="mainbody">';
270 $output .= "\n\n" . '<!-- main content body -->' . "\n";
271
272 return $output;
273 }
274
275 // ###################################################################
276 /**
277 * Generates the HTML that is inserted in ISSO.Printer->page_end() that
278 * closes all of the navigation HTML stuff
279 *
280 * @access public
281 *
282 * @return string Generated HTML content
283 */
284 function generate_footer_html()
285 {
286 $output = '';
287
288 $output .= "\n" . '<!-- / main content body -->' . "\n";
289
290 $output .= "\n" . '</td>';
291 $output .= "\n" . '</tr>';
292
293 $output .= "\n\n" . '</table>';
294
295 $output .= "\n\n" . '</div>';
296
297 return $output;
298 }
299 }
300
301 /*=====================================================================*\
302 || ###################################################################
303 || # $HeadURL$
304 || # $Id$
305 || ###################################################################
306 \*=====================================================================*/
307 ?>