]>
src.bluestatic.org Git - bugdar.git/blob - framework/printer_navigation.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2002-[#]year[#] Blue Static
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.
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
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 \*=====================================================================*/
23 * Printer - Navigation Generator
24 * printer_navigation.php
30 * Printer - Navigation Generator
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
38 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
43 class Printer_Navigation
46 * Framework registry object
53 * Global links that are used for admin home, logout, etc.
57 var $toplinks = array();
60 * Navigational tabs: array(text, url)
71 var $sections = array();
74 * Links: array(text, url)
81 * Array of scopes to set focus to key
85 var $focus = array('tab' => null, 'link' => null);
87 // ###################################################################
91 function __construct(&$registry)
93 $this->registry
=& $registry;
96 // ###################################################################
100 function Printer_Navigation(&$registry)
102 $this->__construct($registry);
105 // ###################################################################
107 * Adds a global link to the array; these cannot be removed once added
111 * @param string Link text
112 * @param string HREF of the URL
114 function add_top_link($text, $href)
116 $this->toplinks
["$href"] = $text;
119 // ###################################################################
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
125 * '<tab>unique_key' => array(
126 * '<section>unique_key' => array(
127 * '<link>unique_key' => array('text', 'url')
132 * Note that the portion in brackets is called the "scope
"
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
142 function add_component($scope, $key, $parent, $text, $url)
146 $this->tabs["$key"] = array($text, $url);
148 else if ($scope == 'section')
150 $this->sections
["$parent"]["$key"] = $text;
152 else if ($scope == 'link')
154 $this->links
["$parent"]["$key"] = array($text, $url);
158 // ###################################################################
160 * Sets the focus for either a tab or link
164 * @param string Scope operator
165 * @param string Unique key in scope
166 * @param string Parent operator (links only)
168 function set_focus($scope, $key, $parent)
172 if (isset($this->tabs
["$key"]))
174 $this->focus["$scope"] = $key;
178 trigger_error('Invalid key for scope', E_USER_WARNING
);
181 else if ($scope == 'link')
183 if (isset($this->links
["$parent"]["$key"]))
185 $this->focus
["$scope"] = $key;
189 trigger_error('Invalid key for scope', E_USER_WARNING);
194 trigger_error('Printer_Navigation::set_focus() only allows setting of focus for tab and link scopes', E_USER_ERROR);
198 // ###################################################################
200 * Generates the header HTML that is called in ISSO.Printer->page_start()
201 * to setup the navigation frame
205 * @return string Generated HTML content
207 function generate_header_html()
209 $output = '<!-- navigation start -->' . "\n\n
";
211 // -------------------------------------------------------------------
214 foreach ($this->toplinks AS $href => $text)
216 $output2[] = '<a href="' . $href . '">' . $text . '</a>';
219 $language = $this->registry->modules['printer']->getLanguageInformation();
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(' • ', $output2) . '</div>';
224 $output .= "\n
" . '</div>';
226 // -------------------------------------------------------------------
228 $output .= "\n\n
" . '<div id="wrapper
">';
230 // -------------------------------------------------------------------
232 $output .= "\n
" . '<div id="tabbar
">';
233 foreach ($this->tabs AS $key => $content)
235 $link = "\n\t
" . '<a href="' . $content[1] . '"';
236 if ($this->focus['tab'] == $key)
238 $link .= ' id="focustab
"';
241 $link .= '><span>' . $content[0] . '</span></a>';
245 $output .= "\n
" . '</div>';
247 // -------------------------------------------------------------------
249 $output .= "\n\n
" . '<table id="contentbody
" cellspacing="0" cellpadding="0" border="0">';
250 $output .= "\n
" . '<tr>';
252 // -------------------------------------------------------------------
254 $output .= "\n
" . '<td id="menu
">';
255 foreach ((array)$this->sections[ $this->focus['tab'] ] AS $key => $text)
257 $output .= "\n
" . '<ul>';
258 $output .= "\n\t
" . '<li class="header
"><span>' . $text . '</span></li>';
259 foreach ((array)$this->links["$key"] AS $key2 => $content)
261 $output .= "\n\t" . '<li' . ($this->focus
['link'] == $key2 ? ' class="focus"' : '') . '><a href="' . $content[1] . '"><span>' . $content[0] . '</span></a></li>';
263 $output .= "\n" . '</ul>' . "\n";
265 $output .= "\n" . '</td>';
267 // -------------------------------------------------------------------
269 $output .= "\n" . '<td id="mainbody">';
270 $output .= "\n\n" . '<!-- main content body -->' . "\n";
275 // ###################################################################
277 * Generates the HTML that is inserted in ISSO.Printer->page_end() that
278 * closes all of the navigation HTML stuff
282 * @return string Generated HTML content
284 function generate_footer_html()
288 $output .= "\n" . '<!-- / main content body -->' . "\n";
290 $output .= "\n" . '</td>';
291 $output .= "\n" . '</tr>';
293 $output .= "\n\n" . '</table>';
295 $output .= "\n\n" . '</div>';