adding missing files

This commit is contained in:
Dario Rekowski on RockPI 2019-11-29 15:00:03 +00:00
parent 68a9c42d8b
commit c63e41fd49
7 changed files with 347 additions and 0 deletions

View File

@ -0,0 +1,16 @@
<?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 NaviBreakLine {
public function __toString() {
return "<li><hr></li>";
}
}

View File

@ -0,0 +1,87 @@
<?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() {
//global $self;
//echo "<i>self: </i>"; var_dump($GLOBALS("self"));
$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($this->title, ['controller' => $this->controller, "action" => $this->action, $this->param]);
return $self->Html->Link(
'<span class="link-title">' . $this->title . '</span>'
.'<i class="mdi '. $this->iconClass .' link-icon ' . $this->iconColor .'"></i>',
['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 .= " active"; }
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;
}
}

View File

@ -0,0 +1,85 @@
<?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;
use Cake\Routing\Router;
class NaviEntryAbsoluteLink extends NaviEntryBase {
private $link = '';
private $active = '';
private $iconClass = '';
private $iconColor = '';
private $bgColorClass = '';
public function __construct($title, $iconClass, $link, $active = null) {
$this->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 "<i>self: </i>"; var_dump($GLOBALS("self"));
$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($this->title, ['controller' => $this->controller, "action" => $this->action, $this->param]);
return '<a href="' . Router::url('./', true). $this->link.'" class="' .$this->bgColorClass .'" >'
. '<span class="link-title">' . $this->title . '</span>'
. '<i class="mdi '. $this->iconClass .' link-icon ' . $this->iconColor .'"></i>'
. '</a>';
}
}
public function __toString() {
$str = "";
$str .= "<li";
$class = "";
if($this->hasChilds()) { $class .= "dropdown";}
if($this->isActive()) { $class .= " active"; }
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;
}
}

View File

@ -0,0 +1,31 @@
<?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 NaviEntryBase {
protected $title = "";
protected $childs = [];
protected $isChild = false;
public function setTitle($title) {
$this->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;
}
}

View File

@ -0,0 +1,37 @@
<?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 TitleOnly extends NaviEntryBase {
public function __construct($title) {
$this->title = $title;
}
public function __toString() {
$str = "";
$str .= "<li";
$class = "";
if($this->hasChilds()) { $class .= " dropdown";}
if(strlen($class) > 0 ) $str .= " class='$class'";
$str .= ">";
$hNumber = 1;
if($this->isChild) $hNumber = 3;
$str .= "<h$hNumber><span class='block-btn'>" . $this->title . "</span></h$hNumber>";
if($this->hasChilds()) {
$str .= "<ul class='subnav'>";
foreach($this->childs as $child) {
$str .= $child;
}
$str .= "</ul>";
}
$str .= "</li>";
return $str;
}
}

View File

@ -0,0 +1,46 @@
<?php
use Model\Navigation\NaviEntry;
use Model\Navigation\NaviEntryAbsoluteLink;
$session = $this->getRequest()->getSession();
$transactionPendings = $session->read('Transactions.pending');
$errorCount = intval($session->read('StateUser.errorCount'));
$balance = $session->read('StateUser.balance');
//echo "balance: $balance<br>";
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") . '&nbsp;(' . intval($transactionPendings) . ')',
'mdi-signature-freehand', 'account/checkTransactions'
));*/
} else {
array_push($navi, new NaviEntryAbsoluteLink(__('Abmelden'), 'mdi-logout', 'account/logout'));
}
?>
<ul class="navigation-menu">
<?php foreach($navi as $n) echo $n; ?>
</ul>

View File

@ -0,0 +1,45 @@
<?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.
*/
use Cake\Routing\Router;
$session = $this->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
}
*/
?>
<ul class="nav ml-auto">
<?php if($errorCount > 0) : ?>
<li class="nav-item">
<?= $this->Html->link(
'<i class="mdi mdi-alert-outline grd-alert-color mdi-1x"></i>'
. '<span class="notification-indicator notification-indicator-warning notification-indicator-ripple"></span>',
['controller' => 'StateErrors', 'action' => 'ShowForUser'],
['class' => 'nav-link', 'escape' => false, 'title' => "($errorCount) " . __('Fehler')]) ?>
</li>
<?php endif; ?>
<?php if($transactionPendings > 0) : ?>
<li class="nav-item">
<a class="nav-link" title="<?= "($transactionPendings) " . __('Transaktionen sind noch zu unterzeichnen')?>" href="<?= Router::url('./', true) ?>account/checkTransactions">
<i class="mdi mdi-signature-freehand mdi-1x"></i>
<!--(<?= $transactionPendings ?>)-->
<span class="notification-indicator notification-indicator-primary notification-indicator-ripple"></span>
</a>
</li>
<?php endif; ?>
</ul>