Ulf Gebhardt 6fe5fd6d7e Add 'community_server/' from commit 'b6544b9e69fb85d4da100934675323c3e8c8ef67'
git-subtree-dir: community_server
git-subtree-mainline: ff11f6efe35bba180260fe84077bcd94298895c1
git-subtree-split: b6544b9e69fb85d4da100934675323c3e8c8ef67
2021-03-17 00:39:06 +01:00

89 lines
2.7 KiB
PHP

<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Model\Navigation;
class NaviEntry extends NaviEntryBase {
private $controller = '';
private $action = '';
private $active = '';
private $param = null;
private $iconClass = '';
private $iconColor = '';
private $bgColorClass = '';
public function __construct($title, $iconClass, $controller, $action, $active = null, $param = null) {
$this->controller = $controller;
$this->action = $action;
$this->param = $param;
$this->iconClass = $iconClass;
if($active != null) {
$this->active = $active;
} else {
$this->active = ($GLOBALS["side"] == $controller &&
$GLOBALS["subside"] == $action &&
$GLOBALS["passed"] == $param);
}
$this->title = $title;
return $this;
}
public function setIconColor($iconColorClass) {
$this->iconColor = $iconColorClass;
return $this;
}
public function setBGColor($bgColorClass) {
$this->bgColorClass = $bgColorClass;
return $this;
}
private function isActive() {
return $this->active;
}
private function link() {
$self = $GLOBALS["self"];
if($this->hasChilds()) {
return $self->Html->link(
$this->title.'<span class="caret"></span>',
['controller' => $this->controller, "action" => $this->action, $this->param],
['escape' => false]
);
} else {
return $self->Html->Link(
'<i class="material-icons-outlined nav-icon ' . $this->iconColor
.'" title="' . $this->title . '">'. $this->iconClass .'</i>'
.'<span class="link-title">' . $this->title . '</span>',
['controller' => $this->controller, 'action' => $this->action, $this->param],
['class' => $this->bgColorClass, 'escape' => false]);
}
}
public function __toString() {
$str = "";
$str .= "<li";
$class = "";
if($this->hasChilds()) { $class .= "dropdown";}
if($this->isActive()) { $class .= " selected"; }
if(strlen($class) > 0 ) $str .= " class='$class'";
$str .= ">";
$str .= $this->link();
if($this->hasChilds()) {
$str .= "<ul class='subnav'>";
foreach($this->childs as $child) {
$str .= $child;
}
$str .= "</ul>";
}
$str .= "</li>";
return $str;
}
}