NavigationController: Implement sharedAction()

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-07 15:04:31 +02:00
parent 8e6fc1580e
commit 04a14a46b6
2 changed files with 61 additions and 0 deletions

View File

@ -5,6 +5,8 @@ namespace Icinga\Controllers;
use Icinga\Application\Config;
use Icinga\Web\Controller;
use Icinga\Web\Form;
use Icinga\Web\Url;
/**
* Navigation configuration
@ -41,6 +43,37 @@ class NavigationController extends Controller
public function sharedAction()
{
$this->assertPermission('config/application/navigation');
$this->view->items = Config::app('navigation');
$removeForm = new Form();
$removeForm->setUidDisabled();
$removeForm->setAction(Url::fromPath('navigation/unshare'));
$removeForm->addElement('hidden', 'name', array(
'decorators' => array('ViewHelper')
));
$removeForm->addElement('hidden', 'redirect', array(
'value' => Url::fromPath('navigation/shared'),
'decorators' => array('ViewHelper')
));
$removeForm->addElement('button', 'btn_submit', array(
'escape' => false,
'type' => 'submit',
'class' => 'link-like spinner',
'value' => 'btn_submit',
'decorators' => array('ViewHelper'),
'label' => $this->view->icon('trash'),
'title' => $this->translate('Unshare this navigation item')
));
$this->view->removeForm = $removeForm;
$this->getTabs()->add(
'navigation/shared',
array(
'title' => $this->translate('List and configure shared navigation items'),
'label' => $this->translate('Shared Navigation'),
'url' => 'navigation/shared'
)
)->activate('navigation/shared');
}
/**

View File

@ -0,0 +1,28 @@
<?php if (! $this->compact): ?>
<div class="controls">
<?= $this->tabs; ?>
</div>
<?php endif ?>
<div class="content" data-base-target="_next">
<table class="action alternating">
<thead>
<th><?= $this->translate('Shared 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 shared navigation item %s'), $name)
)
); ?></td>
<td><?= $removeForm->setDefault('name', $name); ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>