diff --git a/library/Icinga/Web/Navigation/NavigationRenderer.php b/library/Icinga/Web/Navigation/NavigationRenderer.php deleted file mode 100644 index 60cfcf900..000000000 --- a/library/Icinga/Web/Navigation/NavigationRenderer.php +++ /dev/null @@ -1,340 +0,0 @@ -iterator = $navigation->getIterator(); - $this->navigation = $navigation; - $this->flags = $flags; - } - - /** - * {@inheritdoc} - */ - public function getChildren() - { - return new static($this->current()->getChildren(), $this->flags & static::NAV_DISABLE); - } - - /** - * {@inheritdoc} - */ - public function hasChildren() - { - return $this->current()->hasChildren(); - } - - /** - * {@inheritdoc} - * @return \Icinga\Web\Navigation\NavigationItem - */ - public function current() - { - return $this->iterator->current(); - } - - /** - * {@inheritdoc} - */ - public function key() - { - return $this->iterator->key(); - } - - /** - * {@inheritdoc} - */ - public function next() - { - $this->iterator->next(); - } - - /** - * {@inheritdoc} - */ - public function rewind() - { - $this->iterator->rewind(); - if (! (bool) ($this->flags & static::NAV_DISABLE) && ! $this->inIteration) { - $this->content[] = $this->beginMarkup(); - $this->inIteration = true; - } - } - - /** - * {@inheritdoc} - */ - public function valid() - { - $valid = $this->iterator->valid(); - if (! (bool) ($this->flags & static::NAV_DISABLE) && ! $valid && $this->inIteration) { - $this->content[] = $this->endMarkup(); - $this->inIteration = false; - } - return $valid; - } - - /** - * Begin navigation markup - * - * @return string - */ - public function beginMarkup() - { - $content = array(); - if ($this->flags & static::NAV_MAJOR) { - $el = 'nav'; - } else { - $el = 'div'; - } - if (($elCssClass = $this->getCssClass()) !== null) { - $elCss = ' class="' . $elCssClass . '"'; - } else { - $elCss = ''; - } - $content[] = sprintf( - '<%s%s role="navigation">', - $el, - $elCss - ); - $content[] = sprintf( - '%2$s', - static::HEADING_RANK, - $this->getView()->escape($this->getHeading()) - ); - $content[] = $this->beginChildrenMarkup(); - return implode("\n", $content); - } - - /** - * End navigation markup - * - * @return string - */ - public function endMarkup() - { - $content = array(); - $content[] = $this->endChildrenMarkup(); - if ($this->flags & static::NAV_MAJOR) { - $content[] = ''; - } else { - $content[] = ''; - } - return implode("\n", $content); - } - - /** - * Begin children markup - * - * @return string - */ - public function beginChildrenMarkup() - { - $ulCssClass = static::CSS_CLASS_NAV; - if ($this->navigation->getLayout() & Navigation::LAYOUT_TABS) { - $ulCssClass .= ' ' . static::CSS_CLASS_NAV_TABS; - } - if ($this->navigation->getLayout() & Navigation::LAYOUT_DROPDOWN) { - $ulCssClass .= ' ' . static::CSS_CLASS_NAV_DROPDOWN; - } - return ''; - } - - /** - * Begin item markup - * - * @param NavigationItem $item - * - * @return string - */ - public function beginItemMarkup(NavigationItem $item) - { - $cssClass = array(); - if ($item->getActive()) { - $cssClass[] = static::CSS_CLASS_ACTIVE; - } - if ($item->hasChildren() - && $item->getChildren()->getLayout() === Navigation::LAYOUT_DROPDOWN - ) { - $cssClass[] = static::CSS_CLASS_DROPDOWN; - $item - ->setAttribute('class', static::CSS_CLASS_DROPDOWN_TOGGLE) - ->setIcon(static::DROPDOWN_TOGGLE_ICON) - ->setUrl('#'); - } - if (! empty($cssClass)) { - $content = sprintf('
  • ', implode(' ', $cssClass)); - } else { - $content = '
  • '; - } - return $content; - } - - /** - * End item markup - * - * @return string - */ - public function endItemMarkup() - { - return '
  • '; - } - - /** - * {@inheritdoc} - */ - public function getCssClass() - { - return $this->cssClass; - } - - /** - * {@inheritdoc} - */ - public function setCssClass($class) - { - $this->cssClass = trim((string) $class); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getHeading() - { - return $this->heading; - } - - /** - * {@inheritdoc} - */ - public function setHeading($heading) - { - $this->heading = (string) $heading; - return $this; - } - - /** - * Get the view - * - * @return View - */ - public function getView() - { - if ($this->view === null) { - $this->view = Icinga::app()->getViewRenderer()->view; - } - return $this->view; - } - - /** - * Set the view - * - * @param View $view - * - * @return $this - */ - public function setView(View $view) - { - $this->view = $view; - return $this; - } - - /** - * {@inheritdoc} - */ - public function render() - { - foreach ($this as $navigationItem) { - /** @var \Icinga\Web\Navigation\NavigationItem $navigationItem */ - $this->content[] = $this->beginItemMarkup($navigationItem); - $this->content[] = $navigationItem->render(); - $this->content[] = $this->endItemMarkup(); - } - return implode("\n", $this->content); - } -} diff --git a/library/Icinga/Web/Navigation/NavigationRendererInterface.php b/library/Icinga/Web/Navigation/NavigationRendererInterface.php deleted file mode 100644 index c3e014f44..000000000 --- a/library/Icinga/Web/Navigation/NavigationRendererInterface.php +++ /dev/null @@ -1,122 +0,0 @@ -content[] = $this->getInnerIterator()->beginMarkup(); - } - - /** - * {@inheritdoc} - */ - public function endIteration() - { - $this->content[] = $this->getInnerIterator()->endMarkup(); - } - - /** - * {@inheritdoc} - */ - public function beginChildren() - { - $this->content[] = $this->getInnerIterator()->beginChildrenMarkup(); - } - - /** - * {@inheritdoc} - */ - public function endChildren() - { - $this->content[] = $this->getInnerIterator()->endChildrenMarkup(); - } - - /** - * {@inheritdoc} - */ - public function getCssClass() - { - return $this->getInnerIterator()->getCssClass(); - } - - /** - * {@inheritdoc} - */ - public function setCssClass($class) - { - $this->getInnerIterator()->setCssClass($class); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getHeading() - { - return $this->getInnerIterator()->getHeading(); - } - - /** - * {@inheritdoc} - */ - public function setHeading($heading) - { - $this->getInnerIterator()->setHeading($heading); - return $this; - } - - /** - * {@inheritdoc} - */ - public function render() - { - foreach ($this as $navigationItem) { - /** @var \Icinga\Web\Navigation\NavigationItem $navigationItem */ - $this->content[] = $this->getInnerIterator()->beginItemMarkup($navigationItem); - $this->content[] = $navigationItem->render(); - if (! $navigationItem->hasChildren()) { - $this->content[] = $this->getInnerIterator()->endItemMarkup(); - } - } - return implode("\n", $this->content); - } -}