implement navigation actions

This commit is contained in:
Dennis Eichhorn 2019-12-21 10:34:30 +01:00
parent bbbec7e50b
commit a3ddb0a782
5 changed files with 11 additions and 2 deletions

View File

@ -46,6 +46,12 @@
"default": null,
"null": true
},
"nav_action": {
"name": "nav_action",
"type": "text",
"default": null,
"null": true
},
"nav_from": {
"name": "nav_from",
"type": "VARCHAR(255)",

View File

@ -91,6 +91,7 @@ class Installer extends InstallerAbstract
$navElement->icon = $data['icon'] ?? null;
$navElement->uri = $data['uri'] ?? null;
$navElement->target = (string) ($data['target'] ?? 'self');
$navElement->action = $data['action'] ?? null;
$navElement->from = (string) ($data['from'] ?? '0');
$navElement->order = (int) ($data['order'] ?? 1);
$navElement->parent = (int) ($data['parent'] ?? 0);

View File

@ -32,6 +32,7 @@ class NavElement
public $icon = null;
public $uri = null;
public $target = 'self';
public $action = null;
public $from = '0';
public $order = 1;
public $parent = 0;

View File

@ -41,6 +41,7 @@ final class NavElementMapper extends DataMapperAbstract
'nav_icon' => ['name' => 'nav_icon', 'type' => 'string', 'internal' => 'icon'],
'nav_uri' => ['name' => 'nav_uri', 'type' => 'string', 'internal' => 'uri'],
'nav_target' => ['name' => 'nav_target', 'type' => 'string', 'internal' => 'target'],
'nav_action' => ['name' => 'nav_action', 'type' => 'string', 'internal' => 'action'],
'nav_from' => ['name' => 'nav_from', 'type' => 'string', 'internal' => 'from'],
'nav_order' => ['name' => 'nav_order', 'type' => 'int', 'internal' => 'order'],
'nav_parent' => ['name' => 'nav_parent', 'type' => 'int', 'internal' => 'parent'],

View File

@ -22,8 +22,8 @@ if (isset($this->nav[NavigationType::TOP])): ?>
<ul id="t-nav" role="navigation">
<?php $unread = $this->getData('unread');
foreach ($this->nav[NavigationType::TOP] as $key => $parent) :
foreach ($parent as $link) : ?>
<li><a href="<?= \phpOMS\Uri\UriFactory::build($link['nav_uri']); ?>">
foreach ($parent as $id => $link) : ?>
<li><a id="link-<?= $id; ?>" target="<?= $link['nav_target'] ?>" href="<?= \phpOMS\Uri\UriFactory::build($link['nav_uri']); ?>"<?= $link['nav_action'] !== null ? ' data-action=\'' . $link['nav_action'] . '\'' : ''; ?>>
<?php if (isset($link['nav_icon'])) : ?>
<i class="<?= $this->printHtml($link['nav_icon']); ?> infoIcon"><?php if (isset($unread[$link['nav_from']]) && $unread[$link['nav_from']] > 0) : ?><span class="badge"><?= $this->printHtml($unread[$link['nav_from']]); ?></span><?php endif; ?></i>