2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2005-2008 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)2005 - 2008, Blue Static
41 class BSPrinterNavigation
44 * XML document structure
45 * @var SimpleXMLElement
50 * Keys to set focus on
53 private $focusKeys = array();
59 private $displaySections = array();
64 * @param string Navigation XML data
66 public function __construct($xml)
68 $this->structure
= new SimpleXMLElement($xml);
72 * Adds focus to a given key
76 public function addFocus($key)
78 $this->focusKeys
[] = $key;
82 * Adds a section to display. The order in which sections are added is the order
83 * in which they are painted
87 public function addSection($key)
89 $this->displaySections
[] = $key;
93 * Generates the header HTML that is called in BSPrinterRootElementPage
94 * to setup the navigation frame
96 * @return string Generated HTML content
98 public function constructHeaderHtml()
100 $output = '<!-- navigation start -->' . "\n\n";
102 // -------------------------------------------------------------------
105 foreach ($this->structure
->links
->link
as $link)
107 $attrs = $link->attributes();
108 $output2[] = '<a href="' . $attrs->target
. '">' . $link . '</a>';
111 $output .= "\n" . '<div id="toplinks">';
112 $output .= "\n\t" . '<div>' . BSPrinter
::get_realm() . '</div>';
113 $output .= "\n\t" . '<div id="toplinks-links">' . implode(' • ', $output2) . '</div>';
114 $output .= "\n" . '</div>';
116 // -------------------------------------------------------------------
118 $output .= "\n\n" . '<div id="wrapper">';
120 // -------------------------------------------------------------------
122 $output .= "\n" . '<div id="tabbar">';
123 foreach ($this->structure
->tabs
->tab
as $tab)
125 $link = "\n\t" . '<a href="' . $tab['target'] . '"';
126 if (in_array($tab['key'], $this->focusKeys
))
128 $link .= ' id="focustab"';
131 $link .= '><span>' . $tab . '</span></a>';
135 $output .= "\n" . '</div>';
137 // -------------------------------------------------------------------
139 $output .= "\n\n" . '<table id="contentbody" cellspacing="0" cellpadding="0" border="0">';
140 $output .= "\n" . '<tr>';
142 // -------------------------------------------------------------------
144 $output .= "\n" . '<td id="menu">';
145 foreach ($this->structure
->sections
->section
as $section)
147 if (!in_array($section['key'], $this->displaySections
))
152 // handle inherited sections
154 if ($section['inherits'])
156 $keys = explode(',', $section['inherits']);
158 foreach ($keys as $parKey)
160 $parLinks = $this->structure
->xpath('/navigation/sections/section[@key="' . $parKey . '"]/link');
161 $links = array_merge($links, $parLinks);
164 // add the links from the hybrid section
165 if (is_array($section->link
))
167 $links = array_merge($links, $section->link
);
171 $links[] = $section->link
;
174 // no inheritance, so the links are straight from the section
177 $links = $section->link
;
180 $output .= "\n" . '<ul>';
181 $output .= "\n\t" . '<li class="header"><span>' . $section['name'] . '</span></li>';
182 foreach ($links as $link)
184 $output .= "\n\t" . '<li' . (in_array($link['key'], $this->focusKeys
) ?
' class="focus"' : '') . '><a href="' . $link['target'] . '"><span>' . $link . '</span></a></li>';
186 $output .= "\n" . '</ul>' . "\n";
188 $output .= "\n" . '</td>';
190 // -------------------------------------------------------------------
192 $output .= "\n" . '<td id="mainbody">';
193 $output .= "\n\n" . '<!-- main content body -->' . "\n";
199 * Generates the HTML that is inserted in BSPrinterRootElementPage that
200 * closes all of the navigation HTML stuff
202 * @return string Generated HTML content
204 public function constructFooterHtml()
208 $output .= "\n" . '<!-- / main content body -->' . "\n";
210 $output .= "\n" . '</td>';
211 $output .= "\n" . '</tr>';
213 $output .= "\n\n" . '</table>';
215 $output .= "\n\n" . '</div>';