]> src.bluestatic.org Git - isso.git/blob - PrinterNavigation.php
Updating makepo.sh.php to reflect the new way ScanDir() works
[isso.git] / PrinterNavigation.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 (PrinterNavigation.php)
24 *
25 * @package ISSO
26 */
27
28 /**
29 * Printer: Navigation Generator
30 *
31 * This framework works in conjunction with BSPrinter to generate a page header
32 * and sidebar to be used for navigation. You set the navigation array and then can
33 * specify a given key to highlight elements. Elements are broken into three types:
34 * tabs (top of the page), groups (blocks of link actions), and links
35 *
36 * @author Blue Static
37 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
38 * @version $Revision$
39 * @package ISSO
40 *
41 */
42 class BSPrinterNavigation
43 {
44 /**
45 * Global links that are used for admin home, logout, etc.
46 * @var array
47 */
48 private $toplinks = array();
49
50 /**
51 * Navigational tabs: array(text, url)
52 * @var array
53 */
54 private $tabs = array();
55
56 /**
57 * Sections: text
58 * @var array
59 */
60 private $sections = array();
61
62 /**
63 * Links: array(text, url)
64 * @var array
65 */
66 private $links = array();
67
68 /**
69 * Array of scopes to set focus to key
70 * @var array
71 */
72 private $focus = array('tab' => null, 'link' => null);
73
74 // ###################################################################
75 /**
76 * Adds a global link to the array; these cannot be removed once added
77 *
78 * @param string Link text
79 * @param string HREF of the URL
80 */
81 public function addTopLink($text, $href)
82 {
83 $this->toplinks["$href"] = $text;
84 }
85
86 // ###################################################################
87 /**
88 * Adds to the structure array. The following is the global structure
89 * of the array, but you can specify any entry point. When you add onto
90 * the structure, it will go at the bottom
91 * array(
92 * '<tab>unique_key' => array(
93 * '<section>unique_key' => array(
94 * '<link>unique_key' => array('text', 'url')
95 * )
96 * )
97 * )
98 *
99 * Note that the portion in brackets is called the "scope"
100 *
101 * @param string Scope to add to
102 * @param string Unique key for the scope
103 * @param string Parent key to add to
104 * @param string Text to display (usually localized)
105 * @param string URL to go to when text is clicked
106 */
107 public function addComponent($scope, $key, $parent, $text, $url)
108 {
109 if ($scope == 'tab')
110 {
111 $this->tabs["$key"] = array($text, $url);
112 }
113 else if ($scope == 'section')
114 {
115 $this->sections["$parent"]["$key"] = $text;
116 }
117 else if ($scope == 'link')
118 {
119 $this->links["$parent"]["$key"] = array($text, $url);
120 }
121 }
122
123 // ###################################################################
124 /**
125 * Sets the focus for either a tab or link
126 *
127 * @param string Scope operator
128 * @param string Unique key in scope
129 * @param string Parent operator (links only)
130 */
131 public function setFocus($scope, $key, $parent)
132 {
133 if ($scope == 'tab')
134 {
135 if (isset($this->tabs["$key"]))
136 {
137 $this->focus["$scope"] = $key;
138 }
139 else
140 {
141 trigger_error('Invalid key for scope');
142 }
143 }
144 else if ($scope == 'link')
145 {
146 if (isset($this->links["$parent"]["$key"]))
147 {
148 $this->focus["$scope"] = $key;
149 }
150 else
151 {
152 trigger_error('Invalid key for scope');
153 }
154 }
155 else
156 {
157 trigger_error('BSPrinterNavigation::setFocus() only allows setting of focus for tab and link scopes');
158 }
159 }
160
161 // ###################################################################
162 /**
163 * Generates the header HTML that is called in BSPrinterRootElementPage
164 * to setup the navigation frame
165 *
166 * @return string Generated HTML content
167 */
168 public function constructHeaderHtml()
169 {
170 $output = '<!-- navigation start -->' . "\n\n";
171
172 // -------------------------------------------------------------------
173
174 $output2 = array();
175 foreach ($this->toplinks AS $href => $text)
176 {
177 $output2[] = '<a href="' . $href . '">' . $text . '</a>';
178 }
179
180 $output .= "\n" . '<div id="toplinks">';
181 $output .= "\n\t" . '<div>' . BSRegister::GetApplicaiton . ' ' . BSPrinter::GetRealm() . '</div>';
182 $output .= "\n\t" . '<div id="toplinks-links">' . implode(' &bull; ', $output2) . '</div>';
183 $output .= "\n" . '</div>';
184
185 // -------------------------------------------------------------------
186
187 $output .= "\n\n" . '<div id="wrapper">';
188
189 // -------------------------------------------------------------------
190
191 $output .= "\n" . '<div id="tabbar">';
192 foreach ($this->tabs AS $key => $content)
193 {
194 $link = "\n\t" . '<a href="' . $content[1] . '"';
195 if ($this->focus['tab'] == $key)
196 {
197 $link .= ' id="focustab"';
198 }
199
200 $link .= '><span>' . $content[0] . '</span></a>';
201
202 $output .= $link;
203 }
204 $output .= "\n" . '</div>';
205
206 // -------------------------------------------------------------------
207
208 $output .= "\n\n" . '<table id="contentbody" cellspacing="0" cellpadding="0" border="0">';
209 $output .= "\n" . '<tr>';
210
211 // -------------------------------------------------------------------
212
213 $output .= "\n" . '<td id="menu">';
214 foreach ((array)$this->sections[ $this->focus['tab'] ] AS $key => $text)
215 {
216 $output .= "\n" . '<ul>';
217 $output .= "\n\t" . '<li class="header"><span>' . $text . '</span></li>';
218 foreach ((array)$this->links["$key"] AS $key2 => $content)
219 {
220 $output .= "\n\t" . '<li' . ($this->focus['link'] == $key2 ? ' class="focus"' : '') . '><a href="' . $content[1] . '"><span>' . $content[0] . '</span></a></li>';
221 }
222 $output .= "\n" . '</ul>' . "\n";
223 }
224 $output .= "\n" . '</td>';
225
226 // -------------------------------------------------------------------
227
228 $output .= "\n" . '<td id="mainbody">';
229 $output .= "\n\n" . '<!-- main content body -->' . "\n";
230
231 return $output;
232 }
233
234 // ###################################################################
235 /**
236 * Generates the HTML that is inserted in BSPrinterRootElementPage that
237 * closes all of the navigation HTML stuff
238 *
239 * @return string Generated HTML content
240 */
241 public function constructFooterHtml()
242 {
243 $output = '';
244
245 $output .= "\n" . '<!-- / main content body -->' . "\n";
246
247 $output .= "\n" . '</td>';
248 $output .= "\n" . '</tr>';
249
250 $output .= "\n\n" . '</table>';
251
252 $output .= "\n\n" . '</div>';
253
254 return $output;
255 }
256 }
257
258 /*=====================================================================*\
259 || ###################################################################
260 || # $HeadURL$
261 || # $Id$
262 || ###################################################################
263 \*=====================================================================*/
264 ?>