2015-07-03 13:17:05 +02:00
|
|
|
<?php
|
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
namespace Icinga\Module\Director\Controllers;
|
|
|
|
|
2017-07-11 15:28:04 +02:00
|
|
|
use Icinga\Module\Director\Forms\DirectorDatafieldForm;
|
2015-07-03 13:17:05 +02:00
|
|
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
class DatafieldController extends ActionController
|
2015-07-03 13:17:05 +02:00
|
|
|
{
|
2015-07-03 14:20:47 +02:00
|
|
|
public function addAction()
|
|
|
|
{
|
2015-07-29 20:13:06 +02:00
|
|
|
$this->indexAction();
|
2015-07-03 14:20:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function editAction()
|
|
|
|
{
|
2015-07-29 20:13:06 +02:00
|
|
|
$this->indexAction();
|
2015-07-03 14:20:47 +02:00
|
|
|
}
|
|
|
|
|
2015-07-03 13:17:05 +02:00
|
|
|
public function indexAction()
|
|
|
|
{
|
2017-07-11 15:28:04 +02:00
|
|
|
$form = DirectorDatafieldForm::load()
|
2015-07-03 13:17:05 +02:00
|
|
|
->setDb($this->db());
|
|
|
|
|
2021-10-05 22:57:09 +02:00
|
|
|
if ($id = $this->params->get('id')) {
|
|
|
|
$form->loadObject((int) $id);
|
2017-07-11 15:28:04 +02:00
|
|
|
$this->addTitle(
|
2016-10-17 19:48:04 +02:00
|
|
|
$this->translate('Modify %s'),
|
|
|
|
$form->getObject()->varname
|
|
|
|
);
|
2017-07-20 15:10:12 +02:00
|
|
|
$this->addSingleTab($this->translate('Edit a Field'));
|
2016-10-17 19:48:04 +02:00
|
|
|
} else {
|
2017-07-11 15:28:04 +02:00
|
|
|
$this->addTitle($this->translate('Add a new Data Field'));
|
2017-07-20 15:10:12 +02:00
|
|
|
$this->addSingleTab($this->translate('New Field'));
|
2015-07-03 13:17:05 +02:00
|
|
|
}
|
2015-07-03 14:20:47 +02:00
|
|
|
|
2015-07-03 13:17:05 +02:00
|
|
|
$form->handleRequest();
|
2017-07-11 15:28:04 +02:00
|
|
|
$this->content()->add($form);
|
2015-07-03 13:17:05 +02:00
|
|
|
}
|
|
|
|
}
|