diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:47:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:47:21 +0000 |
commit | 1ac4a2050c8076eb96e07e83721ebc9db864db94 (patch) | |
tree | da9b32212bf99154450a7668f61a75f65617a9fa /application/controllers/EditController.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-toplevelview-1ac4a2050c8076eb96e07e83721ebc9db864db94.tar.xz icingaweb2-module-toplevelview-1ac4a2050c8076eb96e07e83721ebc9db864db94.zip |
Adding upstream version 0.3.3.upstream/0.3.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/controllers/EditController.php')
-rw-r--r-- | application/controllers/EditController.php | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/application/controllers/EditController.php b/application/controllers/EditController.php new file mode 100644 index 0000000..b91255c --- /dev/null +++ b/application/controllers/EditController.php @@ -0,0 +1,92 @@ +<?php +/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */ + +namespace Icinga\Module\Toplevelview\Controllers; + +use Icinga\Module\Toplevelview\Forms\EditForm; +use Icinga\Module\Toplevelview\ViewConfig; +use Icinga\Module\Toplevelview\Web\Controller; +use Icinga\Web\Url; + +class EditController extends Controller +{ + public function init() + { + $this->assertPermission('toplevelview/edit'); + + $tabs = $this->getTabs(); + + if ($name = $this->getParam('name')) { + $tabs->add( + 'tiles', + array( + 'title' => $this->translate('Tiles'), + 'url' => Url::fromPath('toplevelview/show', array( + 'name' => $name + )) + ) + ); + + $tabs->add( + 'index', + array( + 'title' => $this->translate('Edit'), + 'url' => Url::fromPath('toplevelview/edit', array( + 'name' => $name + )) + ) + ); + } + + + $action = $this->getRequest()->getActionName(); + if ($tab = $tabs->get($action)) { + $tab->setActive(); + } + } + + public function indexAction() + { + $action = $this->getRequest()->getActionName(); + if ($action === 'add') { + $this->view->title = sprintf( + '%s Top Level View', + $this->translate('Add') + ); + $view = new ViewConfig(); + $view->setConfigDir(); + } elseif ($action === 'clone') { + $name = $this->params->getRequired('name'); + $this->view->title = sprintf( + '%s Top Level View', + $this->translate('Clone') + ); + $view = clone ViewConfig::loadByName($name); + } else { + $this->view->name = $name = $this->params->getRequired('name'); + $this->view->title = sprintf( + '%s Top Level View: %s', + $this->translate('Edit'), + $this->params->getRequired('name') + ); + $view = ViewConfig::loadByName($name); + } + + $this->view->form = $form = new EditForm(); + $view->setFormat(ViewConfig::FORMAT_YAML); + $form->setViewConfig($view); + $form->handleRequest(); + + $this->setViewScript('edit/index'); + } + + public function addAction() + { + $this->indexAction(); + } + + public function cloneAction() + { + $this->indexAction(); + } +} |