NavigationController: Implement indexAction()

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-07 15:01:55 +02:00
parent 6a00eaf34d
commit 8e6fc1580e
2 changed files with 57 additions and 1 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Controllers;
use Icinga\Application\Config;
use Icinga\Web\Controller;
/**
@ -15,7 +16,23 @@ class NavigationController extends Controller
*/
public function indexAction()
{
$user = $this->Auth()->getUser();
$userConfig = $user->loadNavigationConfig();
$sharedConfig = Config::app('navigation');
$this->view->items = array_merge(
$sharedConfig->select()->where('owner', $user->getUsername())->fetchAll(),
iterator_to_array($userConfig)
);
$this->getTabs()->add(
'navigation',
array(
'title' => $this->translate('List and configure your own navigation items'),
'label' => $this->translate('Navigation'),
'url' => 'navigation'
)
)->activate('navigation');
}
/**

View File

@ -0,0 +1,39 @@
<?php if (! $this->compact): ?>
<div class="controls">
<?= $this->tabs; ?>
</div>
<?php endif ?>
<div class="content" data-base-target="_next">
<a href="<?= $this->href('navigation/add'); ?>">
<?= $this->icon('plus'); ?> <?= $this->translate('Create A New Navigation Item'); ?>
</a>
<table class="action alternating">
<thead>
<th><?= $this->translate('Navigation'); ?></th>
<th style="width: 5em"><?= $this->translate('Remove'); ?></th>
</thead>
<tbody>
<?php foreach ($items as $name => $item): ?>
<tr>
<td><?= $this->qlink(
$name,
'navigation/edit',
array('name' => $name),
array(
'title' => sprintf($this->translate('Edit navigation item %s'), $name)
)
); ?></td>
<td><?= $this->qlink(
'',
'navigation/remove',
array('name' => $name),
array(
'icon' => 'trash',
'title' => sprintf($this->translate('Remove navigation item %s'), $name)
)
); ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>