structure = new SimpleXMLElement($xml); } /** * Adds focus to a given key * * @param string Key */ public function addFocus($key) { if (sizeof($this->structure->xpath('//*[@key="' . $key . '"]')) != 1) { throw new Exception('The key passed to BSPrinterNavigation::addFocus() is either too vague or nonexistent'); } $this->focusKeys[] = $key; } /** * Adds a section to display. The order in which sections are added is the order * in which they are painted * * @param string Key */ public function addSection($key) { if (sizeof($this->structure->xpath('//*[@key="' . $key . '"]')) != 1) { throw new Exception('The key passed to BSPrinterNavigation::addSection() is either too vague or nonexistent'); } $this->displaySections[] = $key; } /** * Generates the header HTML that is called in BSPrinterRootPage * to setup the navigation frame * * @return string Generated HTML content */ public function constructHeaderHtml() { $output = '' . "\n\n"; // ------------------------------------------------------------------- if (isset($this->structure->links)) { $links = array(); foreach ($this->structure->links->link as $link) { $attrs = $link->attributes(); $links[] = '' . $link . ''; } } $output .= "\n" . '
';
foreach ($this->structure->sections->section as $section)
{
if (!in_array($section['key'], $this->displaySections))
{
continue;
}
// handle inherited sections
$links = array();
if ($section['inherits'])
{
$keys = explode(',', $section['inherits']);
foreach ($keys as $parKey)
{
$parLinks = $this->structure->xpath('/navigation/sections/section[@key="' . $parKey . '"]/link');
$links = array_merge($links, $parLinks);
}
// add the links from the hybrid section
if (is_array($section->link))
{
$links = array_merge($links, $section->link);
}
else
{
$links[] = $section->link;
}
}
// no inheritance, so the links are straight from the section
else
{
$links = $section->link;
}
$output .= "\n" . '
| ';
// -------------------------------------------------------------------
$output .= "\n" . ''; $output .= "\n\n" . '' . "\n"; return $output; } /** * Generates the HTML that is inserted in BSPrinterRootPage that * closes all of the navigation HTML stuff * * @return string Generated HTML content */ public function constructFooterHtml() { $output = ''; $output .= "\n" . '' . "\n"; $output .= "\n" . ' | '; $output .= "\n" . '