]>
src.bluestatic.org Git - isso.git/blob - printer_navigation.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©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 ©2002 - [#]year[#], Blue Static
43 class Printer_Navigation
46 * Framework registry object
49 private $registry = null;
52 * Global links that are used for admin home, logout, etc.
55 private $toplinks = array();
58 * Navigational tabs: array(text, url)
61 private $tabs = array();
67 private $sections = array();
70 * Links: array(text, url)
73 private $links = array();
76 * Array of scopes to set focus to key
79 private $focus = array('tab' => null, 'link' => null);
81 // ###################################################################
85 public function __construct(&$registry)
87 $this->registry
=& $registry;
90 // ###################################################################
92 * Adds a global link to the array; these cannot be removed once added
94 * @param string Link text
95 * @param string HREF of the URL
97 public function add_top_link($text, $href)
99 $this->toplinks
["$href"] = $text;
102 // ###################################################################
104 * Adds to the structure array. The following is the global structure
105 * of the array, but you can specify any entry point. When you add onto
106 * the structure, it will go at the bottom
108 * '<tab>unique_key' => array(
109 * '<section>unique_key' => array(
110 * '<link>unique_key' => array('text', 'url')
115 * Note that the portion in brackets is called the "scope
"
117 * @param string Scope to add to
118 * @param string Unique key for the scope
119 * @param string Parent key to add to
120 * @param string Text to display (usually localized)
121 * @param string URL to go to when text is clicked
123 public function add_component($scope, $key, $parent, $text, $url)
127 $this->tabs["$key"] = array($text, $url);
129 else if ($scope == 'section')
131 $this->sections
["$parent"]["$key"] = $text;
133 else if ($scope == 'link')
135 $this->links
["$parent"]["$key"] = array($text, $url);
139 // ###################################################################
141 * Sets the focus for either a tab or link
143 * @param string Scope operator
144 * @param string Unique key in scope
145 * @param string Parent operator (links only)
147 public function set_focus($scope, $key, $parent)
151 if (isset($this->tabs
["$key"]))
153 $this->focus["$scope"] = $key;
157 trigger_error('Invalid key for scope', E_USER_WARNING
);
160 else if ($scope == 'link')
162 if (isset($this->links
["$parent"]["$key"]))
164 $this->focus
["$scope"] = $key;
168 trigger_error('Invalid key for scope', E_USER_WARNING);
173 trigger_error('Printer_Navigation::set_focus() only allows setting of focus for tab and link scopes', E_USER_ERROR);
177 // ###################################################################
179 * Generates the header HTML that is called in ISSO.Printer->page_start()
180 * to setup the navigation frame
182 * @return string Generated HTML content
184 public function generate_header_html()
186 $output = '<!-- navigation start -->' . "\n\n
";
188 // -------------------------------------------------------------------
191 foreach ($this->toplinks AS $href => $text)
193 $output2[] = '<a href="' . $href . '">' . $text . '</a>';
196 $output .= "\n
" . '<div id="toplinks
">';
197 $output .= "\n\t
" . '<div>' . $this->registry->get('application') . ' ' . $this->registry->modules['printer']->get('realm') . '</div>';
198 $output .= "\n\t
" . '<div id="toplinks
-links
">' . implode(' • ', $output2) . '</div>';
199 $output .= "\n
" . '</div>';
201 // -------------------------------------------------------------------
203 $output .= "\n\n
" . '<div id="wrapper
">';
205 // -------------------------------------------------------------------
207 $output .= "\n
" . '<div id="tabbar
">';
208 foreach ($this->tabs AS $key => $content)
210 $link = "\n\t
" . '<a href="' . $content[1] . '"';
211 if ($this->focus['tab'] == $key)
213 $link .= ' id="focustab
"';
216 $link .= '><span>' . $content[0] . '</span></a>';
220 $output .= "\n
" . '</div>';
222 // -------------------------------------------------------------------
224 $output .= "\n\n
" . '<table id="contentbody
" cellspacing="0" cellpadding="0" border="0">';
225 $output .= "\n
" . '<tr>';
227 // -------------------------------------------------------------------
229 $output .= "\n
" . '<td id="menu
">';
230 foreach ((array)$this->sections[ $this->focus['tab'] ] AS $key => $text)
232 $output .= "\n
" . '<ul>';
233 $output .= "\n\t
" . '<li class="header
"><span>' . $text . '</span></li>';
234 foreach ((array)$this->links["$key"] AS $key2 => $content)
236 $output .= "\n\t" . '<li' . ($this->focus
['link'] == $key2 ? ' class="focus"' : '') . '><a href="' . $content[1] . '"><span>' . $content[0] . '</span></a></li>';
238 $output .= "\n" . '</ul>' . "\n";
240 $output .= "\n" . '</td>';
242 // -------------------------------------------------------------------
244 $output .= "\n" . '<td id="mainbody">';
245 $output .= "\n\n" . '<!-- main content body -->' . "\n";
250 // ###################################################################
252 * Generates the HTML that is inserted in ISSO.Printer->page_end() that
253 * closes all of the navigation HTML stuff
255 * @return string Generated HTML content
257 public function generate_footer_html()
261 $output .= "\n" . '<!-- / main content body -->' . "\n";
263 $output .= "\n" . '</td>';
264 $output .= "\n" . '</tr>';
266 $output .= "\n\n" . '</table>';
268 $output .= "\n\n" . '</div>';
274 /*=====================================================================*\
275 || ###################################################################
278 || ###################################################################
279 \*=====================================================================*/