Change the documentation a wee bit for add_component()
[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 called the "scope"
126 *
127 * @access public
128 *
129 * @param string Scope to add to
130 * @param string Unique key for the scope
131 * @param string Parent key to add to
132 * @param string Text to display (usually localized)
133 * @param string URL to go to when text is clicked
134 */
135 function add_component($scope, $key, $parent, $text, $url)
136 {
137 if ($scope == 'tab')
138 {
139 $this->tabs["$key"] = array($text, $url);
140 }
141 else if ($scope == 'section')
142 {
143 $this->sections["$parent"]["$key"] = $text;
144 }
145 else if ($scope == 'link')
146 {
147 $this->links["$parent"]["$key"] = array($text, $url);
148 }
149 }
150
151 // ###################################################################
152 /**
153 * Generates the header HTML that is called in ISSO.Printer->page_start()
154 * to setup the navigation frame
155 *
156 * @access public
157 *
158 * @return string Generated HTML content
159 */
160 function generate_header_html()
161 {
162 $output = '<!-- navigation start -->' . "\n\n";
163
164 $output2 = array();
165 foreach ($this->toplinks AS $href => $text)
166 {
167 $output2[] = '<a href="' . $href . '" class="nav_toplink">' . $text . '</a>';
168 }
169
170 $output .= implode(' &bull; ', $output2);
171
172 return $output;
173 }
174 }
175
176 /*=====================================================================*\
177 || ###################################################################
178 || # $HeadURL$
179 || # $Id$
180 || ###################################################################
181 \*=====================================================================*/
182 ?>