From c63e41fd49fa4bcb4367971312eb22f42dd5a247 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Fri, 29 Nov 2019 15:00:03 +0000 Subject: [PATCH] adding missing files --- src/Model/Navigation/NaviBreakLine.php | 16 ++++ src/Model/Navigation/NaviEntry.php | 87 +++++++++++++++++++ .../Navigation/NaviEntryAbsoluteLink.php | 85 ++++++++++++++++++ src/Model/Navigation/NaviEntryBase.php | 31 +++++++ src/Model/Navigation/TitleOnly.php | 37 ++++++++ src/Template/Element/navi.ctp | 46 ++++++++++ src/Template/Element/navi_header.ctp | 45 ++++++++++ 7 files changed, 347 insertions(+) create mode 100644 src/Model/Navigation/NaviBreakLine.php create mode 100644 src/Model/Navigation/NaviEntry.php create mode 100644 src/Model/Navigation/NaviEntryAbsoluteLink.php create mode 100644 src/Model/Navigation/NaviEntryBase.php create mode 100644 src/Model/Navigation/TitleOnly.php create mode 100644 src/Template/Element/navi.ctp create mode 100644 src/Template/Element/navi_header.ctp diff --git a/src/Model/Navigation/NaviBreakLine.php b/src/Model/Navigation/NaviBreakLine.php new file mode 100644 index 000000000..79917db8c --- /dev/null +++ b/src/Model/Navigation/NaviBreakLine.php @@ -0,0 +1,16 @@ +
"; + } +} \ No newline at end of file diff --git a/src/Model/Navigation/NaviEntry.php b/src/Model/Navigation/NaviEntry.php new file mode 100644 index 000000000..500e4e658 --- /dev/null +++ b/src/Model/Navigation/NaviEntry.php @@ -0,0 +1,87 @@ +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() { + //global $self; + //echo "self: "; var_dump($GLOBALS("self")); + $self = $GLOBALS["self"]; + if($this->hasChilds()) { + return $self->Html->link($this->title.'', ['controller' => $this->controller, "action" => $this->action, $this->param], ['escape' => false]); + } else { + //return $self->Html->link($this->title, ['controller' => $this->controller, "action" => $this->action, $this->param]); + return $self->Html->Link( + '' . $this->title . '' + .'', + ['controller' => $this->controller, 'action' => $this->action, $this->param], + ['class' => $this->bgColorClass, 'escape' => false]); + } + } + + public function __toString() { + $str = ""; + $str .= "hasChilds()) { $class .= "dropdown";} + if($this->isActive()) { $class .= " active"; } + if(strlen($class) > 0 ) $str .= " class='$class'"; + $str .= ">"; + + $str .= $this->link(); + if($this->hasChilds()) { + $str .= ""; + } + $str .= ""; + return $str; + } +} \ No newline at end of file diff --git a/src/Model/Navigation/NaviEntryAbsoluteLink.php b/src/Model/Navigation/NaviEntryAbsoluteLink.php new file mode 100644 index 000000000..17dcf4af6 --- /dev/null +++ b/src/Model/Navigation/NaviEntryAbsoluteLink.php @@ -0,0 +1,85 @@ +link = $link; + $this->iconClass = $iconClass; + if($active != null) { + $this->active = $active; + } + $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() { + //global $self; + //echo "self: "; var_dump($GLOBALS("self")); + $self = $GLOBALS["self"]; + if($this->hasChilds()) { + return $self->Html->link($this->title.'', ['controller' => $this->controller, "action" => $this->action, $this->param], ['escape' => false]); + } else { + //return $self->Html->link($this->title, ['controller' => $this->controller, "action" => $this->action, $this->param]); + + return '' + . '' . $this->title . '' + . '' + . ''; + } + } + + public function __toString() { + $str = ""; + $str .= "hasChilds()) { $class .= "dropdown";} + if($this->isActive()) { $class .= " active"; } + if(strlen($class) > 0 ) $str .= " class='$class'"; + $str .= ">"; + + $str .= $this->link(); + if($this->hasChilds()) { + $str .= ""; + } + $str .= ""; + return $str; + } + +} \ No newline at end of file diff --git a/src/Model/Navigation/NaviEntryBase.php b/src/Model/Navigation/NaviEntryBase.php new file mode 100644 index 000000000..ebb4e122f --- /dev/null +++ b/src/Model/Navigation/NaviEntryBase.php @@ -0,0 +1,31 @@ +title = $title; + return $this; + } + + public function add($child) { + $child->isChild = true; + array_push($this->childs, $child); + return $this; + } + + protected function hasChilds() { + return count($this->childs) > 0; + } + +} diff --git a/src/Model/Navigation/TitleOnly.php b/src/Model/Navigation/TitleOnly.php new file mode 100644 index 000000000..39d7ac616 --- /dev/null +++ b/src/Model/Navigation/TitleOnly.php @@ -0,0 +1,37 @@ +title = $title; + } + + public function __toString() { + $str = ""; + $str .= "hasChilds()) { $class .= " dropdown";} + if(strlen($class) > 0 ) $str .= " class='$class'"; + $str .= ">"; + $hNumber = 1; + if($this->isChild) $hNumber = 3; + $str .= "" . $this->title . ""; + if($this->hasChilds()) { + $str .= ""; + } + $str .= ""; + return $str; + } +} diff --git a/src/Template/Element/navi.ctp b/src/Template/Element/navi.ctp new file mode 100644 index 000000000..8bc8eb7e5 --- /dev/null +++ b/src/Template/Element/navi.ctp @@ -0,0 +1,46 @@ +getRequest()->getSession(); +$transactionPendings = $session->read('Transactions.pending'); +$errorCount = intval($session->read('StateUser.errorCount')); +$balance = $session->read('StateUser.balance'); +//echo "balance: $balance
"; +if(!isset($balance)) { + $balance = 0; +} + + + +$navi = []; +/*if($errorCount > 0) { + $errorNaviEntry = new NaviEntry(__('Fehler '). "($errorCount)", 'mdi-alert-outline', 'StateErrors', 'showForUser'); + $errorNaviEntry->setBGColor('bg-inverse-danger') + ->setIconColor('grd-alert-color'); + array_push($navi, $errorNaviEntry); +}*/ +$balanceNaviEntry = new NaviEntry($this->element('printGradido', ['number' => $balance]), 'mdi-wallet-outline', 'StateBalances', 'overview'); +if($balance < 0 ) { + //$balanceNaviEntry->setIconColor('grd-alert-color'); +} else if($balance > 0) { + //$balanceNaviEntry->setIconColor('grd-success-color'); +} +array_push($navi, $balanceNaviEntry); +array_push($navi, new NaviEntry(__('Startseite'), 'mdi-gauge', 'Dashboard', 'index')); +array_push($navi, new NaviEntry(__('Überweisung'), 'mdi-bank-transfer-out', 'TransactionSendCoins', 'create')); + +if(intval($transactionPendings) > 0) { +/* array_push($navi, new NaviEntryAbsoluteLink( + __("Transaktionen unterzeichnen") . ' (' . intval($transactionPendings) . ')', + 'mdi-signature-freehand', 'account/checkTransactions' + ));*/ +} else { + array_push($navi, new NaviEntryAbsoluteLink(__('Abmelden'), 'mdi-logout', 'account/logout')); +} + + +?> + \ No newline at end of file diff --git a/src/Template/Element/navi_header.ctp b/src/Template/Element/navi_header.ctp new file mode 100644 index 000000000..b3b8d4129 --- /dev/null +++ b/src/Template/Element/navi_header.ctp @@ -0,0 +1,45 @@ +getRequest()->getSession(); +$errorCount = intval($session->read('StateUser.errorCount')); +$transactionPendings = $session->read('Transactions.pending'); + +/* +class NavHeaderEntry +{ + public function __construct($icon_name, $controller, $action, $title) { + ; + } + + public function +} +*/ +?> + \ No newline at end of file