]>
src.bluestatic.org Git - isso.git/blob - PrinterNavigation.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
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 (PrinterNavigation.php)
29 * Printer: Navigation Generator
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
37 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
42 class BSPrinterNavigation
45 * Global links that are used for admin home, logout, etc.
48 private $toplinks = array();
51 * Navigational tabs: array(text, url)
54 private $tabs = array();
60 private $sections = array();
63 * Links: array(text, url)
66 private $links = array();
69 * Array of scopes to set focus to key
72 private $focus = array('tab' => null, 'link' => null);
74 // ###################################################################
76 * Adds a global link to the array; these cannot be removed once added
78 * @param string Link text
79 * @param string HREF of the URL
81 public function addTopLink($text, $href)
83 $this->toplinks
["$href"] = $text;
86 // ###################################################################
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
92 * '<tab>unique_key' => array(
93 * '<section>unique_key' => array(
94 * '<link>unique_key' => array('text', 'url')
99 * Note that the portion in brackets is called the "scope
"
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
107 public function addComponent($scope, $key, $parent, $text, $url)
111 $this->tabs["$key"] = array($text, $url);
113 else if ($scope == 'section')
115 $this->sections
["$parent"]["$key"] = $text;
117 else if ($scope == 'link')
119 $this->links
["$parent"]["$key"] = array($text, $url);
123 // ###################################################################
125 * Sets the focus for either a tab or link
127 * @param string Scope operator
128 * @param string Unique key in scope
129 * @param string Parent operator (links only)
131 public function setFocus($scope, $key, $parent)
135 if (isset($this->tabs
["$key"]))
137 $this->focus["$scope"] = $key;
141 trigger_error('Invalid key for scope');
144 else if ($scope == 'link')
146 if (isset($this->links
["$parent"]["$key"]))
148 $this->focus
["$scope"] = $key;
152 trigger_error('Invalid key for scope');
157 trigger_error('BSPrinterNavigation::setFocus() only allows setting of focus for tab and link scopes');
161 // ###################################################################
163 * Generates the header HTML that is called in BSPrinterRootElementPage
164 * to setup the navigation frame
166 * @return string Generated HTML content
168 public function constructHeaderHtml()
170 $output = '<!-- navigation start -->' . "\n\n
";
172 // -------------------------------------------------------------------
175 foreach ($this->toplinks AS $href => $text)
177 $output2[] = '<a href="' . $href . '">' . $text . '</a>';
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(' • ', $output2) . '</div>';
183 $output .= "\n
" . '</div>';
185 // -------------------------------------------------------------------
187 $output .= "\n\n
" . '<div id="wrapper
">';
189 // -------------------------------------------------------------------
191 $output .= "\n
" . '<div id="tabbar
">';
192 foreach ($this->tabs AS $key => $content)
194 $link = "\n\t
" . '<a href="' . $content[1] . '"';
195 if ($this->focus['tab'] == $key)
197 $link .= ' id="focustab
"';
200 $link .= '><span>' . $content[0] . '</span></a>';
204 $output .= "\n
" . '</div>';
206 // -------------------------------------------------------------------
208 $output .= "\n\n
" . '<table id="contentbody
" cellspacing="0" cellpadding="0" border="0">';
209 $output .= "\n
" . '<tr>';
211 // -------------------------------------------------------------------
213 $output .= "\n
" . '<td id="menu
">';
214 foreach ((array)$this->sections[ $this->focus['tab'] ] AS $key => $text)
216 $output .= "\n
" . '<ul>';
217 $output .= "\n\t
" . '<li class="header
"><span>' . $text . '</span></li>';
218 foreach ((array)$this->links["$key"] AS $key2 => $content)
220 $output .= "\n\t" . '<li' . ($this->focus
['link'] == $key2 ? ' class="focus"' : '') . '><a href="' . $content[1] . '"><span>' . $content[0] . '</span></a></li>';
222 $output .= "\n" . '</ul>' . "\n";
224 $output .= "\n" . '</td>';
226 // -------------------------------------------------------------------
228 $output .= "\n" . '<td id="mainbody">';
229 $output .= "\n\n" . '<!-- main content body -->' . "\n";
234 // ###################################################################
236 * Generates the HTML that is inserted in BSPrinterRootElementPage that
237 * closes all of the navigation HTML stuff
239 * @return string Generated HTML content
241 public function constructFooterHtml()
245 $output .= "\n" . '<!-- / main content body -->' . "\n";
247 $output .= "\n" . '</td>';
248 $output .= "\n" . '</tr>';
250 $output .= "\n\n" . '</table>';
252 $output .= "\n\n" . '</div>';
258 /*=====================================================================*\
259 || ###################################################################
262 || ###################################################################
263 \*=====================================================================*/