Adding structure-creation functions
[isso.git] / printer_navigation.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
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.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 /**
23 * Printer - Navigation Generator
24 * printer_navigation.php
25 *
26 * @package ISSO
27 */
28
29 /**
30 * Printer - Navigation Generator
31 *
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
36 *
37 * @author Iris Studios, Inc.
38 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
39 * @version $Revision$
40 * @package ISSO
41 *
42 */
43 class Printer_Navigation
44 {
45 /**
46 * Framework registry object
47 * @var object
48 * @access private
49 */
50 var $registry = null;
51
52 /**
53 * Global links that are used for admin home, logout, etc.
54 * @var array
55 * @access private
56 */
57 var $toplinks = array();
58
59 /**
60 * Navigational tabs: array(text, url)
61 * @var array
62 * @access private
63 */
64 var $tabs = array();
65
66 /**
67 * Sections: text
68 * @var array
69 * @access private
70 */
71 var $sections = array();
72
73 /**
74 * Links: array(text, url)
75 * @var array
76 * @access private
77 */
78 var $links = array();
79
80 // ###################################################################
81 /**
82 * Constructor
83 */
84 function __construct(&$registry)
85 {
86 $this->registry =& $registry;
87 }
88
89 // ###################################################################
90 /**
91 * (PHP 4) Constructor
92 */
93 function Printer_Navigation(&$registry)
94 {
95 $this->__construct($registry);
96 }
97
98 // ###################################################################
99 /**
100 * Adds a global link to the array; these cannot be removed once added
101 *
102 * @access public
103 *
104 * @param string Link text
105 * @param string HREF of the URL
106 */
107 function add_top_link($text, $href)
108 {
109 $this->toplinks["$href"] = $text;
110 }
111
112 // ###################################################################
113 /**
114 * Adds to the structure array. The following is the global structure
115 * of the array, but you can specify any entry point. When you add onto
116 * the structure, it will go at the bottom
117 * array(
118 * '<tab_>unique_key' => array(
119 * '<section_>unique_key' => array(
120 * '<link_>unique_key' => array('text', 'url')
121 * )
122 * )
123 * )
124 *
125 * Note that the portion in brackets is automatically added to the key
126 * when using the set_focus() method and is called the "scope"
127 *
128 * @access public
129 *
130 * @param string Scope to add to
131 * @param string Unique key for the scope
132 * @param string Parent key to add to
133 * @param string Text to display (usually localized)
134 * @param string URL to go to when text is clicked
135 */
136 function add_component($scope, $key, $parent, $text, $url)
137 {
138 if ($scope == 'tab')
139 {
140 $this->tabs["$key"] = array($text, $url);
141 }
142 else if ($scope == 'section')
143 {
144 $this->sections["$parent"]["$key"] = $text;
145 }
146 else if ($scope == 'link')
147 {
148 $this->links["$parent"]["$key"] = array($text, $url);
149 }
150 }
151
152 // ###################################################################
153 /**
154 * Generates the header HTML that is called in ISSO.Printer->page_start()
155 * to setup the navigation frame
156 *
157 * @access public
158 *
159 * @return string Generated HTML content
160 */
161 function generate_header_html()
162 {
163 $output = '<!-- navigation start -->' . "\n\n";
164
165 $output2 = array();
166 foreach ($this->toplinks AS $href => $text)
167 {
168 $output2[] = '<a href="' . $href . '" class="nav_toplink">' . $text . '</a>';
169 }
170
171 $output .= implode(' &bull; ', $output2);
172
173 return $output;
174 }
175 }
176
177 /*=====================================================================*\
178 || ###################################################################
179 || # $HeadURL$
180 || # $Id$
181 || ###################################################################
182 \*=====================================================================*/
183 ?>