]>
src.bluestatic.org Git - isso.git/blob - PrinterNavigation.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2002-2007 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 2 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 - 2007, Blue Static
41 class BSPrinterNavigation
44 * Global links that are used for admin home, logout, etc.
47 private $toplinks = array();
50 * Navigational tabs: array(text, url)
53 private $tabs = array();
59 private $sections = array();
62 * Links: array(text, url)
65 private $links = array();
68 * Array of scopes to set focus to key
71 private $focus = array('tab' => null, 'link' => null);
73 // ###################################################################
75 * Adds a global link to the array; these cannot be removed once added
77 * @param string Link text
78 * @param string HREF of the URL
80 public function addTopLink($text, $href)
82 $this->toplinks
["$href"] = $text;
85 // ###################################################################
87 * Adds to the structure array. The following is the global structure
88 * of the array, but you can specify any entry point. When you add onto
89 * the structure, it will go at the bottom
91 * '<tab>unique_key' => array(
92 * '<section>unique_key' => array(
93 * '<link>unique_key' => array('text', 'url')
98 * Note that the portion in brackets is called the "scope
"
100 * @param string Scope to add to
101 * @param string Unique key for the scope
102 * @param string Parent key to add to
103 * @param string Text to display (usually localized)
104 * @param string URL to go to when text is clicked
106 public function addComponent($scope, $key, $parent, $text, $url)
110 $this->tabs["$key"] = array($text, $url);
112 else if ($scope == 'section')
114 $this->sections
["$parent"]["$key"] = $text;
116 else if ($scope == 'link')
118 $this->links
["$parent"]["$key"] = array($text, $url);
122 // ###################################################################
124 * Sets the focus for either a tab or link
126 * @param string Scope operator
127 * @param string Unique key in scope
128 * @param string Parent operator (links only)
130 public function setFocus($scope, $key, $parent)
134 if (isset($this->tabs
["$key"]))
136 $this->focus["$scope"] = $key;
140 trigger_error('Invalid key for scope');
143 else if ($scope == 'link')
145 if (isset($this->links
["$parent"]["$key"]))
147 $this->focus
["$scope"] = $key;
151 trigger_error('Invalid key for scope');
156 trigger_error('BSPrinterNavigation::setFocus() only allows setting of focus for tab and link scopes');
160 // ###################################################################
162 * Generates the header HTML that is called in BSPrinterRootElementPage
163 * to setup the navigation frame
165 * @return string Generated HTML content
167 public function constructHeaderHtml()
169 $output = '<!-- navigation start -->' . "\n\n
";
171 // -------------------------------------------------------------------
174 foreach ($this->toplinks AS $href => $text)
176 $output2[] = '<a href="' . $href . '">' . $text . '</a>';
179 $output .= "\n
" . '<div id="toplinks
">';
180 $output .= "\n\t
" . '<div>' . BSApp::GetApplicaiton . ' ' . BSPrinter::GetRealm() . '</div>';
181 $output .= "\n\t
" . '<div id="toplinks
-links
">' . implode(' • ', $output2) . '</div>';
182 $output .= "\n
" . '</div>';
184 // -------------------------------------------------------------------
186 $output .= "\n\n
" . '<div id="wrapper
">';
188 // -------------------------------------------------------------------
190 $output .= "\n
" . '<div id="tabbar
">';
191 foreach ($this->tabs AS $key => $content)
193 $link = "\n\t
" . '<a href="' . $content[1] . '"';
194 if ($this->focus['tab'] == $key)
196 $link .= ' id="focustab
"';
199 $link .= '><span>' . $content[0] . '</span></a>';
203 $output .= "\n
" . '</div>';
205 // -------------------------------------------------------------------
207 $output .= "\n\n
" . '<table id="contentbody
" cellspacing="0" cellpadding="0" border="0">';
208 $output .= "\n
" . '<tr>';
210 // -------------------------------------------------------------------
212 $output .= "\n
" . '<td id="menu
">';
213 foreach ((array)$this->sections[ $this->focus['tab'] ] AS $key => $text)
215 $output .= "\n
" . '<ul>';
216 $output .= "\n\t
" . '<li class="header
"><span>' . $text . '</span></li>';
217 foreach ((array)$this->links["$key"] AS $key2 => $content)
219 $output .= "\n\t" . '<li' . ($this->focus
['link'] == $key2 ? ' class="focus"' : '') . '><a href="' . $content[1] . '"><span>' . $content[0] . '</span></a></li>';
221 $output .= "\n" . '</ul>' . "\n";
223 $output .= "\n" . '</td>';
225 // -------------------------------------------------------------------
227 $output .= "\n" . '<td id="mainbody">';
228 $output .= "\n\n" . '<!-- main content body -->' . "\n";
233 // ###################################################################
235 * Generates the HTML that is inserted in BSPrinterRootElementPage that
236 * closes all of the navigation HTML stuff
238 * @return string Generated HTML content
240 public function constructFooterHtml()
244 $output .= "\n" . '<!-- / main content body -->' . "\n";
246 $output .= "\n" . '</td>';
247 $output .= "\n" . '</tr>';
249 $output .= "\n\n" . '</table>';
251 $output .= "\n\n" . '</div>';