2015-04-24 14:26:44 +02:00
|
|
|
<?php
|
|
|
|
|
2015-06-30 11:27:32 +02:00
|
|
|
namespace Icinga\Module\Director\Web\Controller;
|
2015-04-24 14:26:44 +02:00
|
|
|
|
|
|
|
use Icinga\Application\Icinga;
|
2015-07-23 16:19:22 +02:00
|
|
|
use Icinga\Data\Paginatable;
|
2015-04-24 14:26:44 +02:00
|
|
|
use Icinga\Module\Director\Db;
|
|
|
|
use Icinga\Module\Director\Web\Form\FormLoader;
|
|
|
|
use Icinga\Module\Director\Web\Table\TableLoader;
|
|
|
|
use Icinga\Web\Controller;
|
|
|
|
use Icinga\Web\Widget;
|
|
|
|
|
|
|
|
abstract class ActionController extends Controller
|
|
|
|
{
|
|
|
|
protected $db;
|
|
|
|
|
2015-07-23 16:19:22 +02:00
|
|
|
protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null)
|
|
|
|
{
|
|
|
|
$limit = $this->params->get('limit', $limit);
|
|
|
|
$page = $this->params->get('page', $offset);
|
|
|
|
|
|
|
|
$paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0);
|
|
|
|
|
|
|
|
return $paginatable;
|
|
|
|
}
|
|
|
|
|
2015-04-24 14:26:44 +02:00
|
|
|
public function loadForm($name)
|
|
|
|
{
|
|
|
|
return FormLoader::load($name, $this->Module());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function loadTable($name)
|
|
|
|
{
|
|
|
|
return TableLoader::load($name, $this->Module());
|
|
|
|
}
|
|
|
|
|
2015-06-29 10:13:39 +02:00
|
|
|
protected function setConfigTabs()
|
|
|
|
{
|
2015-09-30 08:50:59 +02:00
|
|
|
$this->view->tabs = Widget::create('tabs')->add('deploymentlog', array(
|
|
|
|
'label' => $this->translate('Deployments'),
|
|
|
|
'url' => 'director/list/deploymentlog')
|
|
|
|
)->add('generatedconfig', array(
|
2015-06-29 10:13:39 +02:00
|
|
|
'label' => $this->translate('Configs'),
|
|
|
|
'url' => 'director/list/generatedconfig')
|
|
|
|
)->add('activitylog', array(
|
|
|
|
'label' => $this->translate('Activity Log'),
|
|
|
|
'url' => 'director/list/activitylog')
|
2015-07-02 14:13:42 +02:00
|
|
|
)->add('datalist', array(
|
|
|
|
'label' => $this->translate('Data lists'),
|
|
|
|
'url' => 'director/list/datalist')
|
2015-07-03 10:49:47 +02:00
|
|
|
)->add('datafield', array(
|
2015-07-21 15:16:18 +02:00
|
|
|
'label' => $this->translate('Data fields'),
|
|
|
|
'url' => 'director/list/datafield')
|
2015-07-22 10:12:50 +02:00
|
|
|
);
|
|
|
|
return $this->view->tabs;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function setImportTabs()
|
|
|
|
{
|
|
|
|
$this->view->tabs = Widget::create('tabs')->add('importsource', array(
|
2015-07-21 15:16:18 +02:00
|
|
|
'label' => $this->translate('Import source'),
|
|
|
|
'url' => 'director/list/importsource')
|
2015-07-22 10:12:50 +02:00
|
|
|
)->add('importrun', array(
|
2015-09-14 16:53:15 +02:00
|
|
|
'label' => $this->translate('Import history'),
|
2015-07-22 10:12:50 +02:00
|
|
|
'url' => 'director/list/importrun')
|
2015-07-23 16:36:58 +02:00
|
|
|
)->add('syncrule', array(
|
|
|
|
'label' => $this->translate('Sync rule'),
|
|
|
|
'url' => 'director/list/syncrule')
|
2015-07-03 09:01:52 +02:00
|
|
|
);
|
2015-06-29 10:13:39 +02:00
|
|
|
return $this->view->tabs;
|
|
|
|
}
|
|
|
|
|
2015-07-24 09:51:31 +02:00
|
|
|
|
2015-04-24 14:26:44 +02:00
|
|
|
protected function db()
|
|
|
|
{
|
|
|
|
if ($this->db === null) {
|
2015-06-29 16:01:10 +02:00
|
|
|
$resourceName = $this->Config()->get('db', 'resource');
|
|
|
|
if ($resourceName) {
|
|
|
|
$this->db = Db::fromResourceName($resourceName);
|
|
|
|
} else {
|
|
|
|
$this->redirectNow('director/welcome');
|
|
|
|
}
|
2015-04-24 14:26:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->db;
|
|
|
|
}
|
|
|
|
}
|