protected function _renderNode (ISC_SITEMAP_NODE $node) { $childHtml = ''; foreach ($node->getChildren() as $child) { $childHtml .= $this->_renderNode($child); } // html attributes are being generated here in php because front end templates have no conditionals yet and // I don't want to output blank class="" id="" etc. for 99% of nodes // @todo change this behaviour when the front end uses Twig or whatever $GLOBALS['FlyoutChildHtml'] = ''; if ($childHtml) { $attributes = array(); if ($node instanceof ISC_SITEMAP_ROOT) { if ($this->getRootClasses()) { $attributes['class'] = $this->getRootClasses(); } } $GLOBALS['FlyoutAttributes'] = ''; foreach ($attributes as $key => $value) { // don't ltrim me! see usage in FlyoutTree and FlyoutNode.html $GLOBALS['FlyoutAttributes'] .= ' ' . isc_html_escape($key) . '="' . isc_html_escape($value) . '"'; } $GLOBALS['FlyoutChildHtml'] = $childHtml; $GLOBALS['FlyoutChildHtml'] = $this->getTemplateEngine()->GetSnippet($this->getTreeTemplate()); unset($GLOBALS['FlyoutAttributes'], $attributes, $key, $value); } unset($childHtml); if ($node instanceof ISC_SITEMAP_ROOT) { // sitemap root does not have any node info of its own to show, just return child info $childHtml = $GLOBALS['FlyoutChildHtml']; unset($GLOBALS['FlyoutChildHtml']); return $childHtml; } $GLOBALS['FlyoutNodeLabel'] = isc_html_escape($node->getLabel()); $GLOBALS['FlyoutNodeUrl'] = isc_html_escape($node->getUrl()); $html = $this->getTemplateEngine()->GetSnippet($this->getNodeTemplate()); unset($GLOBALS['FlyoutNodeLabel'], $GLOBALS['FlyoutNodeUrl'], $GLOBALS['FlyoutChildHtml']); return $html; }
/** * * @param ISC_SITEMAP_NODE $node */ public function appendChild(ISC_SITEMAP_NODE $node) { $this->_childNodes[] = $node; $node->setParent($this); }