2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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
37 * @author Iris Studios, Inc.
38 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
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
167 function set_focus($scope, $key)
173 else if ($scope == 'link')
179 trigger_error('Printer_Navigation::set_focus() only allows setting of focus for tab and link scopes', E_USER_ERROR
);
182 if (isset($this->{$array}["$key"]))
184 $this->focus
["$scope"] = $key;
188 // ###################################################################
190 * Generates the header HTML that is called in ISSO.Printer->page_start()
191 * to setup the navigation frame
195 * @return string Generated HTML content
197 function generate_header_html()
199 $output = '<!-- navigation start -->' . "\n\n";
202 foreach ($this->toplinks
AS $href => $text)
204 $output2[] = '<a href="' . $href . '" class="nav_toplink">' . $text . '</a>';
207 $output .= implode(' • ', $output2);
209 $output .= '<div><strong>Tabs:</strong><ul>';
210 foreach ($this->tabs
AS $key => $content)
212 $link = '<li><a href="' . $content[1] . '" class="tab">' . $content[0] . '</a></li>';
213 if ($this->focus
['tab'] == $key)
215 $output .= "<em>$link</em>";
222 $output .= '</ul></div>';
224 $output .= '<div><ul>';
225 foreach ((array)$this->sections
[ $this->focus
['tab'] ] AS $key => $text)
227 $output .= '<li><strong>' . $text . '</strong><ul>';
228 foreach ((array)$this->links
["$key"] AS $key2 => $content)
230 $link = '<li><a href="' . $content[1] . '" class="link">' . $content[0] . '</a></li>';
231 if ($this->focus
['link'] == $key)
233 $output .= "<em>$link</em>";
242 $output .= '</ul></div>';
248 /*=====================================================================*\
249 || ###################################################################
252 || ###################################################################
253 \*=====================================================================*/