mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
commit
5202854152
@ -4,21 +4,21 @@
|
|||||||
/**
|
/**
|
||||||
* Icinga 2 Web - Head for multiple monitoring frontends
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
* Copyright (C) 2013 Icinga Development Team
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
* @author Icinga Development Team <info@icinga.org>
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
*/
|
*/
|
||||||
@ -26,32 +26,36 @@
|
|||||||
|
|
||||||
# namespace Icinga\Application\Controllers;
|
# namespace Icinga\Application\Controllers;
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
use \Icinga\Web\Controller\ActionController;
|
||||||
use Icinga\Authentication\Credentials;
|
use \Icinga\Authentication\Credentials;
|
||||||
use Icinga\Authentication\Manager as AuthManager;
|
use \Icinga\Authentication\Manager as AuthManager;
|
||||||
use Icinga\Form\Authentication\LoginForm;
|
use \Icinga\Form\Authentication\LoginForm;
|
||||||
|
use \Icinga\Exception\ConfigurationError;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AuthenticationController
|
* Application wide controller for authentication
|
||||||
* @package Icinga\Application\Controllers
|
|
||||||
*/
|
*/
|
||||||
class AuthenticationController extends ActionController
|
class AuthenticationController extends ActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Flag indicates authentication handling
|
* This controller handles authentication
|
||||||
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $handlesAuthentication = true;
|
protected $handlesAuthentication = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag indicates session modification
|
* This controller modifies the session
|
||||||
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
|
*
|
||||||
|
* @see \Icinga\Web\Controller\ActionController::$modifiesSession
|
||||||
*/
|
*/
|
||||||
protected $modifiesSession = true;
|
protected $modifiesSession = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action to handle login
|
* Log into the application
|
||||||
*/
|
*/
|
||||||
public function loginAction()
|
public function loginAction()
|
||||||
{
|
{
|
||||||
@ -62,7 +66,7 @@ class AuthenticationController extends ActionController
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$auth = AuthManager::getInstance(null, array(
|
$auth = AuthManager::getInstance(null, array(
|
||||||
"writeSession" => true
|
'writeSession' => $this->modifiesSession
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($auth->isAuthenticated()) {
|
if ($auth->isAuthenticated()) {
|
||||||
@ -74,30 +78,28 @@ class AuthenticationController extends ActionController
|
|||||||
$credentials->setPassword($this->view->form->getValue('password'));
|
$credentials->setPassword($this->view->form->getValue('password'));
|
||||||
|
|
||||||
if (!$auth->authenticate($credentials)) {
|
if (!$auth->authenticate($credentials)) {
|
||||||
$this->view->form->getElement('password')->addError(t('Please provide a valid username and password'));
|
$this->view->form->getElement('password')
|
||||||
|
->addError(t('Please provide a valid username and password'));
|
||||||
} else {
|
} else {
|
||||||
$this->redirectNow('index?_render=body');
|
$this->redirectNow('index?_render=body');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Icinga\Exception\ConfigurationError $configError) {
|
} catch (ConfigurationError $configError) {
|
||||||
$this->view->errorInfo = $configError->getMessage();
|
$this->view->errorInfo = $configError->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action handle logout
|
* Log out the current user
|
||||||
*/
|
*/
|
||||||
public function logoutAction()
|
public function logoutAction()
|
||||||
{
|
{
|
||||||
$auth = AuthManager::getInstance(null, array(
|
$auth = AuthManager::getInstance(null, array(
|
||||||
"writeSession" => true
|
'writeSession' => $this->modifiesSession
|
||||||
));
|
));
|
||||||
$this->replaceLayout = true;
|
$this->replaceLayout = true;
|
||||||
$auth->removeAuthorization();
|
$auth->removeAuthorization();
|
||||||
$this->redirect('login');
|
$this->redirect('login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
@ -4,67 +4,66 @@
|
|||||||
/**
|
/**
|
||||||
* Icinga 2 Web - Head for multiple monitoring frontends
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
* Copyright (C) 2013 Icinga Development Team
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
* @author Icinga Development Team <info@icinga.org>
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
*/
|
*/
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
use Icinga\Application\Benchmark;
|
use \Icinga\Application\Benchmark;
|
||||||
use Icinga\Authentication\Manager;
|
use \Icinga\Authentication\Manager;
|
||||||
use Icinga\Web\Controller\BaseConfigController;
|
use \Icinga\Web\Controller\BaseConfigController;
|
||||||
use Icinga\Web\Widget\Tab;
|
use \Icinga\Web\Widget\Tab;
|
||||||
use Icinga\Web\Url;
|
use \Icinga\Web\Url;
|
||||||
use Icinga\Web\Hook\Configuration\ConfigurationTabBuilder;
|
use \Icinga\Web\Hook\Configuration\ConfigurationTabBuilder;
|
||||||
use Icinga\Application\Icinga;
|
use \Icinga\Application\Icinga;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application wide controller for application preferences
|
* Application wide controller for application preferences
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class ConfigController extends BaseConfigController
|
class ConfigController extends BaseConfigController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create tabs for this configuration controller
|
* Create tabs for this configuration controller
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @see BaseConfigController::createProvidedTabs
|
*
|
||||||
|
* @see BaseConfigController::createProvidedTabs()
|
||||||
*/
|
*/
|
||||||
public static function createProvidedTabs()
|
public static function createProvidedTabs()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
"index" => new Tab(
|
'index' => new Tab(
|
||||||
array(
|
array(
|
||||||
"name" => "index",
|
'name' => 'index',
|
||||||
"title" => "Configuration",
|
'title' => 'Configuration',
|
||||||
"iconCls" => "wrench",
|
'iconCls' => 'wrench',
|
||||||
"url" => Url::fromPath("/config")
|
'url' => Url::fromPath('/config')
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
"modules" => new Tab(
|
'modules' => new Tab(
|
||||||
array(
|
array(
|
||||||
"name" => "modules",
|
'name' => 'modules',
|
||||||
"title" => "Modules",
|
'title' => 'Modules',
|
||||||
"iconCls" => "puzzle-piece",
|
'iconCls' => 'puzzle-piece',
|
||||||
"url" => Url::fromPath("/config/moduleoverview")
|
'url' => Url::fromPath('/config/moduleoverview')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +94,6 @@ class ConfigController extends BaseConfigController
|
|||||||
$manager = Icinga::app()->getModuleManager();
|
$manager = Icinga::app()->getModuleManager();
|
||||||
$manager->enableModule($this->_getParam('name'));
|
$manager->enableModule($this->_getParam('name'));
|
||||||
$manager->loadModule($this->_getParam('name'));
|
$manager->loadModule($this->_getParam('name'));
|
||||||
|
|
||||||
$this->redirectNow('config/moduleoverview?_render=body');
|
$this->redirectNow('config/moduleoverview?_render=body');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,4 +107,4 @@ class ConfigController extends BaseConfigController
|
|||||||
$this->redirectNow('config/moduleoverview?_render=body');
|
$this->redirectNow('config/moduleoverview?_render=body');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
@ -27,13 +27,13 @@
|
|||||||
*/
|
*/
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
use \Icinga\Web\Controller\ActionController;
|
||||||
use Icinga\Web\Url;
|
use \Icinga\Web\Url;
|
||||||
use Icinga\Application\Icinga;
|
use \Icinga\Application\Icinga;
|
||||||
use Icinga\Web\Widget\Dashboard;
|
use \Icinga\Web\Widget\Dashboard;
|
||||||
use \Icinga\Application\Config as IcingaConfig;
|
use \Icinga\Application\Config as IcingaConfig;
|
||||||
use Icinga\Form\Dashboard\AddUrlForm;
|
use \Icinga\Form\Dashboard\AddUrlForm;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use \Icinga\Exception\ConfigurationError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle creation, removal and displaying of dashboards, panes and components
|
* Handle creation, removal and displaying of dashboards, panes and components
|
||||||
@ -42,13 +42,12 @@ use Icinga\Exception\ConfigurationError;
|
|||||||
*/
|
*/
|
||||||
class DashboardController extends ActionController
|
class DashboardController extends ActionController
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a dashboard from the provided config
|
* Retrieve a dashboard from the provided config
|
||||||
*
|
*
|
||||||
* @param string $config The config to read the dashboard from, or 'dashboard/dashboard' if none is given
|
* @param string $config The config to read the dashboard from, or 'dashboard/dashboard' if none is given
|
||||||
*
|
*
|
||||||
* @return Dashboard
|
* @return \Icinga\Web\Widget\Dashboard
|
||||||
*/
|
*/
|
||||||
private function getDashboard($config = 'dashboard/dashboard')
|
private function getDashboard($config = 'dashboard/dashboard')
|
||||||
{
|
{
|
||||||
@ -59,7 +58,6 @@ class DashboardController extends ActionController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a component from the pane identified by the 'pane' parameter
|
* Remove a component from the pane identified by the 'pane' parameter
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function removecomponentAction()
|
public function removecomponentAction()
|
||||||
{
|
{
|
||||||
@ -72,24 +70,20 @@ class DashboardController extends ActionController
|
|||||||
)->store();
|
)->store();
|
||||||
$this->redirectNow(Url::fromPath('dashboard', array('pane' => $pane)));
|
$this->redirectNow(Url::fromPath('dashboard', array('pane' => $pane)));
|
||||||
} catch (ConfigurationError $exc ) {
|
} catch (ConfigurationError $exc ) {
|
||||||
|
|
||||||
$this->_helper->viewRenderer('show_configuration');
|
$this->_helper->viewRenderer('show_configuration');
|
||||||
$this->view->exceptionMessage = $exc->getMessage();
|
$this->view->exceptionMessage = $exc->getMessage();
|
||||||
$this->view->iniConfigurationString = $dashboard->toIni();
|
$this->view->iniConfigurationString = $dashboard->toIni();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the form for adding new components or add the new component if submitted
|
* Display the form for adding new components or add the new component if submitted
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function addurlAction()
|
public function addurlAction()
|
||||||
{
|
{
|
||||||
$form = new AddUrlForm();
|
$form = new AddUrlForm();
|
||||||
$form->setRequest($this->_request);
|
$form->setRequest($this->_request);
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
|
|
||||||
if ($form->isSubmittedAndValid()) {
|
if ($form->isSubmittedAndValid()) {
|
||||||
$dashboard = $this->getDashboard();
|
$dashboard = $this->getDashboard();
|
||||||
$dashboard->setComponentUrl(
|
$dashboard->setComponentUrl(
|
||||||
@ -115,12 +109,10 @@ class DashboardController extends ActionController
|
|||||||
*
|
*
|
||||||
* If no pane is submitted or the submitted one doesn't exist, the default pane is
|
* If no pane is submitted or the submitted one doesn't exist, the default pane is
|
||||||
* displayed (normally the first one)
|
* displayed (normally the first one)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
$dashboard = $this->getDashboard();
|
$dashboard = $this->getDashboard();
|
||||||
|
|
||||||
if ($this->_getParam('pane')) {
|
if ($this->_getParam('pane')) {
|
||||||
$pane = $this->_getParam('pane');
|
$pane = $this->_getParam('pane');
|
||||||
$dashboard->activate($pane);
|
$dashboard->activate($pane);
|
||||||
@ -137,5 +129,4 @@ class DashboardController extends ActionController
|
|||||||
$this->view->dashboard = $dashboard;
|
$this->view->dashboard = $dashboard;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
// @codingStandardsIgnoreEnd
|
|
||||||
|
@ -4,21 +4,21 @@
|
|||||||
/**
|
/**
|
||||||
* Icinga 2 Web - Head for multiple monitoring frontends
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
* Copyright (C) 2013 Icinga Development Team
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
* @author Icinga Development Team <info@icinga.org>
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
*/
|
*/
|
||||||
@ -26,21 +26,19 @@
|
|||||||
|
|
||||||
# namespace Icinga\Application\Controllers;
|
# namespace Icinga\Application\Controllers;
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
use \Icinga\Web\Controller\ActionController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ErrorController
|
* Application wide controller for displaying exceptions
|
||||||
* @package Icinga\Application\Controllers
|
|
||||||
*/
|
*/
|
||||||
class ErrorController extends ActionController
|
class ErrorController extends ActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
* Display exception
|
||||||
*/
|
*/
|
||||||
public function errorAction()
|
public function errorAction()
|
||||||
{
|
{
|
||||||
$errors = $this->_getParam('error_handler');
|
$errors = $this->_getParam('error_handler');
|
||||||
|
|
||||||
switch ($errors->type) {
|
switch ($errors->type) {
|
||||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
|
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
|
||||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
||||||
@ -59,9 +57,7 @@ class ErrorController extends ActionController
|
|||||||
if ($this->getInvokeArg('displayExceptions') == true) {
|
if ($this->getInvokeArg('displayExceptions') == true) {
|
||||||
$this->view->exception = $errors->exception;
|
$this->view->exception = $errors->exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->request = $errors->request;
|
$this->view->request = $errors->request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
@ -29,23 +29,16 @@
|
|||||||
|
|
||||||
# namespace Icinga\Application\Controllers;
|
# namespace Icinga\Application\Controllers;
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
use \Icinga\Web\Controller\ActionController;
|
||||||
use Icinga\Application\Icinga;
|
use \Icinga\Application\Icinga;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class IndexController
|
* Application wide index controller
|
||||||
* @package Icinga\Application\Controllers
|
|
||||||
*/
|
*/
|
||||||
class IndexController extends ActionController
|
class IndexController extends ActionController
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* Always authenticate
|
||||||
*/
|
|
||||||
protected $modifiesSession = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function preDispatch()
|
public function preDispatch()
|
||||||
{
|
{
|
||||||
@ -56,11 +49,10 @@ class IndexController extends ActionController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Application's start page
|
||||||
*/
|
*/
|
||||||
public function welcomeAction()
|
public function welcomeAction()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
@ -3,24 +3,24 @@
|
|||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
/**
|
/**
|
||||||
* This file is part of Icinga 2 Web.
|
* This file is part of Icinga 2 Web.
|
||||||
*
|
*
|
||||||
* Icinga 2 Web - Head for multiple monitoring backends.
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
* Copyright (C) 2013 Icinga Development Team
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
* @author Icinga Development Team <info@icinga.org>
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
@ -33,26 +33,25 @@ use \Icinga\Web\Url;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Application wide preference controller for user preferences
|
* Application wide preference controller for user preferences
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class PreferenceController extends BasePreferenceController
|
class PreferenceController extends BasePreferenceController
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create tabs for this preference controller
|
* Create tabs for this preference controller
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @see BasePreferenceController::createProvidedTabs
|
*
|
||||||
|
* @see BasePreferenceController::createProvidedTabs()
|
||||||
*/
|
*/
|
||||||
public static function createProvidedTabs()
|
public static function createProvidedTabs()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
"preference" => new Tab(
|
'preference' => new Tab(
|
||||||
array(
|
array(
|
||||||
"name" => "preferences",
|
'name' => 'preferences',
|
||||||
"iconCls" => "user",
|
'iconCls' => 'user',
|
||||||
"title" => "Preferences",
|
'title' => 'Preferences',
|
||||||
"url" => Url::fromPath("/preference")
|
'url' => Url::fromPath('/preference')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -60,11 +59,10 @@ class PreferenceController extends BasePreferenceController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @TODO: Implement User preferences (feature #5425)
|
* @TODO: Implement User preferences (feature #5425)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
@ -27,13 +27,15 @@
|
|||||||
*/
|
*/
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
use \Zend_Controller_Action_Exception as ActionException;
|
||||||
use Icinga\Application\Icinga,
|
use \Icinga\Web\Controller\ActionController;
|
||||||
Zend_Controller_Action_Exception as ActionException;
|
use \Icinga\Application\Icinga;
|
||||||
|
|
||||||
class StaticController extends ActionController
|
class StaticController extends ActionController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @TODO: Bug #4572
|
||||||
|
*/
|
||||||
protected $handlesAuthentication = true;
|
protected $handlesAuthentication = true;
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
@ -45,11 +47,10 @@ class StaticController extends ActionController
|
|||||||
private function getModuleList()
|
private function getModuleList()
|
||||||
{
|
{
|
||||||
$modules = Icinga::app()->getModuleManager()->getLoadedModules();
|
$modules = Icinga::app()->getModuleManager()->getLoadedModules();
|
||||||
|
|
||||||
// preliminary static definition
|
// preliminary static definition
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach ($modules as $name => $module) {
|
foreach ($modules as $name => $module) {
|
||||||
$hasJs = file_exists($module->getBasedir() . "/public/js/$name.js");
|
$hasJs = file_exists($module->getBasedir() . '/public/js/' . $name . '.js');
|
||||||
$result[] = array(
|
$result[] = array(
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'active' => true,
|
'active' => true,
|
||||||
@ -62,11 +63,10 @@ class StaticController extends ActionController
|
|||||||
|
|
||||||
public function modulelistAction()
|
public function modulelistAction()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
$this->_helper->viewRenderer->setNoRender(true);
|
||||||
$this->_helper->layout()->disableLayout();
|
$this->_helper->layout()->disableLayout();
|
||||||
$this->getResponse()->setHeader("Content-Type","application/json");
|
$this->getResponse()->setHeader('Content-Type', 'application/json');
|
||||||
echo "define(function() { return ".json_encode($this->getModuleList(),true)."; })";
|
echo 'define(function() { return ' . json_encode($this->getModuleList(), true) . '; })';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ class StaticController extends ActionController
|
|||||||
{
|
{
|
||||||
$module = $this->_getParam('module_name');
|
$module = $this->_getParam('module_name');
|
||||||
$file = $this->_getParam('file');
|
$file = $this->_getParam('file');
|
||||||
|
|
||||||
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
||||||
|
|
||||||
$filePath = $basedir . '/public/img/' . $file;
|
$filePath = $basedir . '/public/img/' . $file;
|
||||||
@ -112,14 +112,14 @@ class StaticController extends ActionController
|
|||||||
$file = $this->_getParam('file');
|
$file = $this->_getParam('file');
|
||||||
|
|
||||||
if (!Icinga::app()->getModuleManager()->hasEnabled($module)) {
|
if (!Icinga::app()->getModuleManager()->hasEnabled($module)) {
|
||||||
echo "/** Module not enabled **/";
|
echo '/** Module not enabled **/';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
||||||
|
|
||||||
$filePath = $basedir . '/public/js/' . $file;
|
$filePath = $basedir . '/public/js/' . $file;
|
||||||
if (!file_exists($filePath)) {
|
if (!file_exists($filePath)) {
|
||||||
echo "/** Module has no js files **/";
|
echo '/** Module has no js files **/';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$hash = md5_file($filePath);
|
$hash = md5_file($filePath);
|
||||||
@ -143,10 +143,7 @@ class StaticController extends ActionController
|
|||||||
} else {
|
} else {
|
||||||
readfile($filePath);
|
readfile($filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
@ -1,4 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
namespace Icinga\Form\Dashboard;
|
namespace Icinga\Form\Dashboard;
|
||||||
|
|
||||||
@ -103,6 +129,7 @@ class AddUrlForm extends Form
|
|||||||
protected function create()
|
protected function create()
|
||||||
{
|
{
|
||||||
$dashboard = new Dashboard();
|
$dashboard = new Dashboard();
|
||||||
|
|
||||||
$dashboard->readConfig(IcingaConfig::app('dashboard/dashboard'));
|
$dashboard->readConfig(IcingaConfig::app('dashboard/dashboard'));
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
@ -110,6 +137,7 @@ class AddUrlForm extends Form
|
|||||||
array(
|
array(
|
||||||
'label' => 'Url',
|
'label' => 'Url',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'value' => $this->getRequest()->getParam('url', null)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$elems = $dashboard->getPaneKeyTitleArray();
|
$elems = $dashboard->getPaneKeyTitleArray();
|
||||||
@ -132,5 +160,6 @@ class AddUrlForm extends Form
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->setSubmitLabel("Add to dashboard");
|
$this->setSubmitLabel("Add to dashboard");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
103
doc/widgets.md
Normal file
103
doc/widgets.md
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
# Widgets
|
||||||
|
|
||||||
|
Widgets are reusable UI components that are able to render themselves and return HTML to be included in your template.
|
||||||
|
|
||||||
|
## Basic interface
|
||||||
|
|
||||||
|
The interface needed for implementing widgets can be found under library/Icinga/Web/Widget/Widget.php. This is a rather
|
||||||
|
simple interface, only providing a `render()` method that takes a view and returns HTML:
|
||||||
|
|
||||||
|
interface Widget
|
||||||
|
{
|
||||||
|
public function render(Zend_View_Abstract $view);
|
||||||
|
}
|
||||||
|
|
||||||
|
When implementing own Widgets you just have to make sure that you provide this render method.
|
||||||
|
|
||||||
|
## Using widgets
|
||||||
|
|
||||||
|
Widgets are normally created in the controller and added to the view:
|
||||||
|
|
||||||
|
// in your Controller
|
||||||
|
|
||||||
|
public function myControllerAction()
|
||||||
|
{
|
||||||
|
$this->view->myWidget = new MyWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
The HTML is then rendered in the template using the `render()` method described above. As the '$this' scope in a view is
|
||||||
|
a reference to your current view, you can just pass it to the `render()` method:
|
||||||
|
|
||||||
|
// in your template
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h4>Look at my beautiful widget</h4>
|
||||||
|
<?= $this->myWidget->render($this); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## The 'Tabs' widget
|
||||||
|
|
||||||
|
The Tabs `\Icinga\Web\Widgets\Tabs` widget handles creation of Tab bars and allows you to create and add single tabs to
|
||||||
|
this view. To create an empty Tab bar, you just have to call:
|
||||||
|
|
||||||
|
$tabbar = new Tabs();
|
||||||
|
|
||||||
|
> **Note**: Controllers subclassing `\Icinga\Web\Controller\ActionController` (which all existing controller do so and
|
||||||
|
> yours should too) have already an empty tabs object created under `$this->view->tabs`. This is done in the
|
||||||
|
> `preDispatch` function.
|
||||||
|
|
||||||
|
### Adding tabs
|
||||||
|
|
||||||
|
Afterwards you can add tabs by calling the `add($name, $tab)` function, whereas `$name` is the name of your tab and
|
||||||
|
`$tab` is either an array with tab parameters or an existing Tab object.
|
||||||
|
|
||||||
|
// Add a tab
|
||||||
|
|
||||||
|
$tabbar->add(
|
||||||
|
'myTab',
|
||||||
|
array(
|
||||||
|
'title' => 'My hosts', // Displayed as the tab text
|
||||||
|
'iconCls' => 'myicon', // icon-myicon will be used as an icon in a <i> tag
|
||||||
|
'url' => '/my/url', // The url to use
|
||||||
|
'urlParams' => array('host' => 'localhost') // Will be used as GET parameter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
### Adding tabs to the dropdown list
|
||||||
|
|
||||||
|
Sometimes you want additional actions to be displayed in your tabbar. This can be accomplished with the
|
||||||
|
`addAsDropdown()` method. This one is similar to the `add()` method, but displays your tab in a dropdown list on the
|
||||||
|
right side of the tabbar.
|
||||||
|
|
||||||
|
## Using tabextensions
|
||||||
|
|
||||||
|
Often you find yourself adding the same tabs over and over again. You can write a Tabextension that does this for you
|
||||||
|
and just apply them on your tabs. Tabextensions are located at Icinga/Web/Widgets/Tabextension/ and they use the simple
|
||||||
|
Tabextension interface that just defines `apply(Tabs $tab)`. A simple example is the DashboardAction Tabextender which
|
||||||
|
just adds a new field to the dropdown list:
|
||||||
|
|
||||||
|
class DashboardAction implements Tabextension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @see Tabextension::apply()
|
||||||
|
*/
|
||||||
|
public function apply(Tabs $tabs)
|
||||||
|
{
|
||||||
|
$tabs->addAsDropdown(
|
||||||
|
'dashboard',
|
||||||
|
array(
|
||||||
|
'title' => 'Add to Dashboard',
|
||||||
|
'iconCls' => 'dashboard',
|
||||||
|
'url' => Url::fromPath('dashboard/addurl'),
|
||||||
|
'urlParams' => array(
|
||||||
|
'url' => Url::fromRequest()->getRelativeUrl()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
You can now either extend your Tabs object using the DashboardAction's `apply()` method or by calling the Tabs
|
||||||
|
`extend()` method (which is more fluent):
|
||||||
|
|
||||||
|
$tabs->extend(new DashboardAction());
|
@ -2,29 +2,30 @@
|
|||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
/**
|
/**
|
||||||
* This file is part of Icinga 2 Web.
|
* This file is part of Icinga 2 Web.
|
||||||
*
|
*
|
||||||
* Icinga 2 Web - Head for multiple monitoring backends.
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
* Copyright (C) 2013 Icinga Development Team
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
* @author Icinga Development Team <info@icinga.org>
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
*/
|
*/
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
namespace Icinga\Web\Controller;
|
namespace Icinga\Web\Controller;
|
||||||
|
|
||||||
use \Icinga\Authentication\Manager as AuthManager;
|
use \Icinga\Authentication\Manager as AuthManager;
|
||||||
@ -32,17 +33,13 @@ use \Icinga\Application\Benchmark;
|
|||||||
use \Icinga\Exception;
|
use \Icinga\Exception;
|
||||||
use \Icinga\Application\Config;
|
use \Icinga\Application\Config;
|
||||||
use \Icinga\Web\Notification;
|
use \Icinga\Web\Notification;
|
||||||
|
use \Icinga\Web\Widget\Tabs;
|
||||||
use \Zend_Layout as ZfLayout;
|
use \Zend_Layout as ZfLayout;
|
||||||
use \Zend_Controller_Action as ZfController;
|
use \Zend_Controller_Action as ZfController;
|
||||||
use \Zend_Controller_Request_Abstract as ZfRequest;
|
use \Zend_Controller_Request_Abstract as ZfRequest;
|
||||||
use \Zend_Controller_Response_Abstract as ZfResponse;
|
use \Zend_Controller_Response_Abstract as ZfResponse;
|
||||||
use \Zend_Controller_Action_HelperBroker as ZfActionHelper;
|
use \Zend_Controller_Action_HelperBroker as ZfActionHelper;
|
||||||
|
|
||||||
/*
|
|
||||||
* @TODO(el): There was a note from tg that the following line is temporary. Ask him why.
|
|
||||||
*/
|
|
||||||
use Icinga\File\Pdf;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all core action controllers
|
* Base class for all core action controllers
|
||||||
*
|
*
|
||||||
@ -55,14 +52,39 @@ use Icinga\File\Pdf;
|
|||||||
class ActionController extends ZfController
|
class ActionController extends ZfController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The Icinga Config object is available in all controllers. This is the
|
* True to mark this layout to not render the full layout
|
||||||
* modules config for module action controllers.
|
*
|
||||||
* @var Config
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $config;
|
|
||||||
|
|
||||||
protected $replaceLayout = false;
|
protected $replaceLayout = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, this controller will be shown even when no authentication is available
|
||||||
|
* Needed mainly for the authentication controller
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $handlesAuthentication = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set true when this controller modifies the session
|
||||||
|
*
|
||||||
|
* otherwise the session will be written back to disk and closed before the controller
|
||||||
|
* action is executed, leading to every modification in the session to be lost after
|
||||||
|
* the response is submitted
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $modifiesSession = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if authentication suceeded, otherwise false
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $allowAccess = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current module name. TODO: Find out whether this shall be null for
|
* The current module name. TODO: Find out whether this shall be null for
|
||||||
* non-module actions
|
* non-module actions
|
||||||
@ -85,20 +107,13 @@ class ActionController extends ZfController
|
|||||||
*/
|
*/
|
||||||
protected $action_name;
|
protected $action_name;
|
||||||
|
|
||||||
// @TODO(el): Should be true, is/was disabled for testing purpose
|
|
||||||
protected $handlesAuthentication = false;
|
|
||||||
|
|
||||||
protected $modifiesSession = false;
|
|
||||||
|
|
||||||
private $allowAccess = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor starts benchmarking, loads the configuration and sets
|
* The constructor starts benchmarking, loads the configuration and sets
|
||||||
* other useful controller properties
|
* other useful controller properties
|
||||||
*
|
*
|
||||||
* @param ZfRequest $request
|
* @param ZfRequest $request
|
||||||
* @param ZfResponse $response
|
* @param ZfResponse $response
|
||||||
* @param array $invokeArgs Any additional invocation arguments
|
* @param array $invokeArgs Any additional invocation arguments
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ZfRequest $request,
|
ZfRequest $request,
|
||||||
@ -111,13 +126,12 @@ class ActionController extends ZfController
|
|||||||
$this->controller_name = $request->getControllerName();
|
$this->controller_name = $request->getControllerName();
|
||||||
$this->action_name = $request->getActionName();
|
$this->action_name = $request->getActionName();
|
||||||
|
|
||||||
$this->loadConfig();
|
|
||||||
$this->setRequest($request)
|
$this->setRequest($request)
|
||||||
->setResponse($response)
|
->setResponse($response)
|
||||||
->_setInvokeArgs($invokeArgs);
|
->_setInvokeArgs($invokeArgs);
|
||||||
$this->_helper = new ZfActionHelper($this);
|
$this->_helper = new ZfActionHelper($this);
|
||||||
|
|
||||||
if ($this->handlesAuthentication() ||
|
if ($this->handlesAuthentication ||
|
||||||
AuthManager::getInstance(
|
AuthManager::getInstance(
|
||||||
null,
|
null,
|
||||||
array(
|
array(
|
||||||
@ -126,24 +140,26 @@ class ActionController extends ZfController
|
|||||||
)->isAuthenticated()
|
)->isAuthenticated()
|
||||||
) {
|
) {
|
||||||
$this->allowAccess = true;
|
$this->allowAccess = true;
|
||||||
|
$this->view->tabs = new Tabs();
|
||||||
$this->init();
|
$this->init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is where the configuration is going to be loaded
|
* Return the tabs
|
||||||
*
|
*
|
||||||
* @return void
|
* @return \Icinga\Widget\Web\Tabs
|
||||||
*/
|
*/
|
||||||
protected function loadConfig()
|
public function getTabs()
|
||||||
{
|
{
|
||||||
$this->config = Config::app();
|
return $this->view->tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates the given string with the global translation catalog
|
* Translate the given string with the global translation catalog
|
||||||
*
|
*
|
||||||
* @param string $string The string that should be translated
|
* @param string $string The string that should be translated
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -155,14 +171,11 @@ class ActionController extends ZfController
|
|||||||
/**
|
/**
|
||||||
* Whether the current user has the given permission
|
* Whether the current user has the given permission
|
||||||
*
|
*
|
||||||
* TODO: This has not been implemented yet
|
* TODO: This has not been implemented yet (Feature #4111)
|
||||||
*
|
|
||||||
* @param string $permission Permission name
|
|
||||||
* @param string $object No idea what this should have been :-)
|
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
final protected function hasPermission($uri, $permission = 'read')
|
final protected function hasPermission($uri)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -170,38 +183,25 @@ class ActionController extends ZfController
|
|||||||
/**
|
/**
|
||||||
* Assert the current user has the given permission
|
* Assert the current user has the given permission
|
||||||
*
|
*
|
||||||
* TODO: This has not been implemented yet
|
* TODO: This has not been implemented yet (Feature #4111)
|
||||||
*
|
|
||||||
* @param string $permission Permission name
|
|
||||||
* @param string $object No idea what this should have been :-)
|
|
||||||
*
|
*
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
final protected function assertPermission($permission, $object = null)
|
final protected function assertPermission()
|
||||||
{
|
{
|
||||||
if (! $this->hasPermission($permission, $object)) {
|
|
||||||
// TODO: Log violation, create dedicated Exception class
|
|
||||||
throw new \Exception('Permission denied');
|
|
||||||
}
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function preserve($key, $value = null)
|
private function redirectToLogin()
|
||||||
{
|
{
|
||||||
if ($value === null) {
|
$this->_request->setModuleName('default')
|
||||||
$value = $this->_getParam($key);
|
->setControllerName('authentication')
|
||||||
}
|
->setActionName('login')
|
||||||
if ($value !== null) {
|
->setDispatched(false);
|
||||||
if (! isset($this->view->preserve)) {
|
|
||||||
$this->view->preserve = array();
|
|
||||||
}
|
|
||||||
$this->view->preserve[$key] = $value;
|
|
||||||
}
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our benchmark wants to know when we started our dispatch loop
|
* Prepare action execution by testing for correct permissions and setting shortcuts
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -209,20 +209,13 @@ class ActionController extends ZfController
|
|||||||
{
|
{
|
||||||
Benchmark::measure('Action::preDispatch()');
|
Benchmark::measure('Action::preDispatch()');
|
||||||
if (! $this->allowAccess) {
|
if (! $this->allowAccess) {
|
||||||
$this->_request->setModuleName('default')
|
return $this->redirectToLogin();
|
||||||
->setControllerName('authentication')
|
|
||||||
->setActionName('login')
|
|
||||||
->setDispatched(false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->action_name = $this->action_name;
|
$this->view->action_name = $this->action_name;
|
||||||
$this->view->controller_name = $this->controller_name;
|
$this->view->controller_name = $this->controller_name;
|
||||||
$this->view->module_name = $this->module_name;
|
$this->view->module_name = $this->module_name;
|
||||||
|
|
||||||
// TODO(el): What is this, why do we need that here?
|
|
||||||
$this->view->compact = $this->_request->getParam('view') === 'compact';
|
|
||||||
|
|
||||||
Benchmark::measure(
|
Benchmark::measure(
|
||||||
sprintf(
|
sprintf(
|
||||||
'Action::preDispatched(): %s / %s / %s',
|
'Action::preDispatched(): %s / %s / %s',
|
||||||
@ -231,11 +224,14 @@ class ActionController extends ZfController
|
|||||||
$this->action_name
|
$this->action_name
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
//$this->quickRedirect('/authentication/login?a=e');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function redirectNow($url, array $params = array())
|
/**
|
||||||
|
* Redirect to a specific url, updating the browsers URL field
|
||||||
|
*
|
||||||
|
* @param Url|string $url The target to redirect to
|
||||||
|
**/
|
||||||
|
public function redirectNow($url)
|
||||||
{
|
{
|
||||||
if ($url instanceof Url) {
|
if ($url instanceof Url) {
|
||||||
$url = $url->getRelativeUrl();
|
$url = $url->getRelativeUrl();
|
||||||
@ -243,77 +239,15 @@ class ActionController extends ZfController
|
|||||||
$this->_helper->Redirector->gotoUrlAndExit($url);
|
$this->_helper->Redirector->gotoUrlAndExit($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handlesAuthentication()
|
|
||||||
{
|
|
||||||
return $this->handlesAuthentication;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render our benchmark
|
* Detect whether the current request requires changes in the layout and apply them before rendering
|
||||||
*
|
*
|
||||||
* @return string
|
* @see Zend_Controller_Action::postDispatch()
|
||||||
*/
|
|
||||||
protected function renderBenchmark()
|
|
||||||
{
|
|
||||||
return '<pre class="benchmark">'
|
|
||||||
. Benchmark::renderToHtml()
|
|
||||||
. '</pre>';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* After dispatch happend we are going to do some automagic stuff
|
|
||||||
*
|
|
||||||
* - Benchmark is completed and rendered
|
|
||||||
* - Notifications will be collected here
|
|
||||||
* - Layout is disabled for XHR requests
|
|
||||||
* - TODO: Headers with required JS and other things will be created
|
|
||||||
* for XHR requests
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function postDispatch()
|
public function postDispatch()
|
||||||
{
|
{
|
||||||
Benchmark::measure('Action::postDispatch()');
|
Benchmark::measure('Action::postDispatch()');
|
||||||
|
|
||||||
// TODO: Move this elsewhere, this is just an ugly test:
|
|
||||||
if ($this->_request->getParam('filetype') === 'pdf') {
|
|
||||||
|
|
||||||
// Snippet stolen from less compiler in public/css.php:
|
|
||||||
|
|
||||||
require_once 'vendor/lessphp/lessc.inc.php';
|
|
||||||
$less = new \lessc;
|
|
||||||
$cssdir = dirname(ICINGA_LIBDIR) . '/public/css';
|
|
||||||
// TODO: We need a way to retrieve public dir, even if located elsewhere
|
|
||||||
|
|
||||||
$css = $less->compileFile($cssdir . '/pdfprint.less');
|
|
||||||
$this->render(
|
|
||||||
null,
|
|
||||||
$this->_helper->viewRenderer->getResponseSegment(),
|
|
||||||
$this->_helper->viewRenderer->getNoController()
|
|
||||||
);
|
|
||||||
$html = (string) $this->getResponse();
|
|
||||||
if ($this->module_name !== null) {
|
|
||||||
$html = '<div class="icinga-module module-'
|
|
||||||
. $this->module_name
|
|
||||||
. '">'
|
|
||||||
. "\n"
|
|
||||||
. $html
|
|
||||||
. '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$html = '<style>' . $css . '</style>' . $html;
|
|
||||||
|
|
||||||
$pdf = new Pdf();
|
|
||||||
$pdf->AddPage();
|
|
||||||
$pdf->setFontSubsetting(false);
|
|
||||||
$pdf->writeHTML($html); //0, 0, '', '', $html, 0, 1, 0, true, '', true);
|
|
||||||
|
|
||||||
$pdf->Output('docs.pdf', 'I');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
// END of PDF test
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->_request->isXmlHttpRequest()) {
|
if ($this->_request->isXmlHttpRequest()) {
|
||||||
if ($this->replaceLayout || $this->_getParam('_render') === 'body') {
|
if ($this->replaceLayout || $this->_getParam('_render') === 'body') {
|
||||||
$this->_helper->layout()->setLayout('just-the-body');
|
$this->_helper->layout()->setLayout('just-the-body');
|
||||||
@ -322,22 +256,5 @@ class ActionController extends ZfController
|
|||||||
$this->_helper->layout()->setLayout('inline');
|
$this->_helper->layout()->setLayout('inline');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$notification = Notification::getInstance();
|
|
||||||
if ($notification->hasMessages()) {
|
|
||||||
$nhtml = '<ul class="notification">';
|
|
||||||
foreach ($notification->getMessages() as $msg) {
|
|
||||||
$nhtml .= '<li>['
|
|
||||||
. $msg->type
|
|
||||||
. '] '
|
|
||||||
. htmlspecialchars($msg->message);
|
|
||||||
}
|
|
||||||
$nhtml .= '</ul>';
|
|
||||||
$this->getResponse()->append('notification', $nhtml);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AuthManager::getInstance()->getSession()->get('show_benchmark')) {
|
|
||||||
Benchmark::measure('Response ready');
|
|
||||||
$this->_helper->layout()->benchmark = $this->renderBenchmark();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
/**
|
/**
|
||||||
* Icinga 2 Web - Head for multiple monitoring frontends
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
* Copyright (C) 2013 Icinga Development Team
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
@ -19,7 +21,8 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
* @author Icinga Development Team <info@icinga.org>
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
*/
|
*/
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
@ -28,83 +31,12 @@
|
|||||||
*/
|
*/
|
||||||
namespace Icinga\Web\Controller;
|
namespace Icinga\Web\Controller;
|
||||||
|
|
||||||
use \Icinga\Application\Config as IcingaConfig;
|
|
||||||
use Icinga\Application\Icinga;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all module action controllers
|
* Base class for all module action controllers
|
||||||
*
|
*
|
||||||
* All Icinga Web module controllers should extend this class
|
* @TODO: Only here for compatibility and testing reasons, make ActionController testable and remove this (Bug #4540)
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2013 Icinga-Web Team <info@icinga.org>
|
*/
|
||||||
* @author Icinga-Web Team <info@icinga.org>
|
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
|
||||||
*/
|
|
||||||
class ModuleActionController extends ActionController
|
class ModuleActionController extends ActionController
|
||||||
{
|
{
|
||||||
protected $module;
|
|
||||||
protected $module_dir;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives you this modules base directory
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getModuleDir()
|
|
||||||
{
|
|
||||||
if ($this->module_dir === null) {
|
|
||||||
$this->module_dir = $this->getModule()->getBaseDir();
|
|
||||||
}
|
|
||||||
return $this->module_dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getModule()
|
|
||||||
{
|
|
||||||
if ($this->module === null) {
|
|
||||||
$this->module = Icinga::app()->getModule(
|
|
||||||
$this->module_name
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $this->module;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Translates the given string with the modules translation catalog
|
|
||||||
*
|
|
||||||
* @param string $string The string that should be translated
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function translate($string)
|
|
||||||
{
|
|
||||||
return mt($this->module_name, $string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is where the module configuration is going to be loaded
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function loadConfig()
|
|
||||||
{
|
|
||||||
$this->config = IcingaConfig::module($this->module_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Once dispatched we are going to place each modules output in a div
|
|
||||||
* container having the icinga-module and the icinga-$module-name classes
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function postDispatch()
|
|
||||||
{
|
|
||||||
parent::postDispatch();
|
|
||||||
$this->_helper->layout()->moduleStart =
|
|
||||||
'<div class="icinga-module module-'
|
|
||||||
. $this->module_name
|
|
||||||
. '">'
|
|
||||||
. "\n"
|
|
||||||
;
|
|
||||||
$this->_helper->layout()->moduleEnd = "</div>\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,14 @@ use Icinga\Application\Icinga;
|
|||||||
*/
|
*/
|
||||||
class Url
|
class Url
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Rather dirty hack as the ApplicationBootstrap isn't an interface right now and can't be mocked
|
||||||
|
* overwrite this to use a specific request for all Urls (so only in tests)
|
||||||
|
*
|
||||||
|
* @var null
|
||||||
|
*/
|
||||||
|
public static $overwrittenRequest = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of all parameters stored in this Url
|
* An array of all parameters stored in this Url
|
||||||
*
|
*
|
||||||
@ -59,7 +67,7 @@ class Url
|
|||||||
public static function fromRequest(array $params = array(), $request = null)
|
public static function fromRequest(array $params = array(), $request = null)
|
||||||
{
|
{
|
||||||
if ($request === null) {
|
if ($request === null) {
|
||||||
$request = Icinga::app()->getFrontController()->getRequest();
|
$request = self::getRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
$urlObject = new Url();
|
$urlObject = new Url();
|
||||||
@ -69,6 +77,19 @@ class Url
|
|||||||
return $urlObject;
|
return $urlObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a request object that should be used for determining the URL
|
||||||
|
*
|
||||||
|
* @return Zend_Abstract_Request
|
||||||
|
*/
|
||||||
|
private static function getRequest()
|
||||||
|
{
|
||||||
|
if (self::$overwrittenRequest) {
|
||||||
|
return self::$overwrittenRequest;
|
||||||
|
}
|
||||||
|
return Icinga::app()->getFrontController()->getRequest();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Url class representing the given url
|
* Create a new Url class representing the given url
|
||||||
*
|
*
|
||||||
@ -85,7 +106,7 @@ class Url
|
|||||||
{
|
{
|
||||||
$urlObject = new Url();
|
$urlObject = new Url();
|
||||||
if ($request === null) {
|
if ($request === null) {
|
||||||
$request = Icinga::app()->getFrontController()->getRequest();
|
$request = self::getRequest();
|
||||||
}
|
}
|
||||||
$urlObject->setBaseUrl($request->getBaseUrl());
|
$urlObject->setBaseUrl($request->getBaseUrl());
|
||||||
|
|
||||||
@ -174,15 +195,14 @@ class Url
|
|||||||
public function getAbsoluteUrl()
|
public function getAbsoluteUrl()
|
||||||
{
|
{
|
||||||
$url = $this->getRelativeUrl();
|
$url = $this->getRelativeUrl();
|
||||||
$baseUrl = '/'.ltrim($this->baseUrl, '/');
|
return preg_replace('/\/{2,}/', '/', '/'.$this->baseUrl.'/'.$url);
|
||||||
return $baseUrl.'/'.$url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a set of parameters to the query part if the keys don't exist yet
|
* Add a set of parameters to the query part if the keys don't exist yet
|
||||||
*
|
*
|
||||||
* @param array $params The parameters to add
|
* @param array $params The parameters to add
|
||||||
* @return $this
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function addParams(array $params)
|
public function addParams(array $params)
|
||||||
{
|
{
|
||||||
@ -190,6 +210,18 @@ class Url
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set and overwrite the given params if one if the same key already exists
|
||||||
|
*
|
||||||
|
* @param array $params The parameters to set
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function overwriteParams(array $params)
|
||||||
|
{
|
||||||
|
$this->params = array_merge($this->params, $params);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwrite the parameters used in the query part
|
* Overwrite the parameters used in the query part
|
||||||
*
|
*
|
||||||
@ -318,7 +350,8 @@ class Url
|
|||||||
* Alias for @see Url::getAbsoluteUrl()
|
* Alias for @see Url::getAbsoluteUrl()
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function __toString() {
|
public function __toString()
|
||||||
|
{
|
||||||
return $this->getAbsoluteUrl();
|
return $this->getAbsoluteUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,16 +28,16 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Widget;
|
namespace Icinga\Web\Widget;
|
||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use \Icinga\Application\Icinga;
|
||||||
use \Icinga\Application\Config as IcingaConfig;
|
use \Icinga\Application\Config as IcingaConfig;
|
||||||
use Icinga\Application\Logger;
|
use \Icinga\Application\Logger;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use \Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Web\Widget\Widget;
|
use \Icinga\Web\Widget\Widget;
|
||||||
use Icinga\Web\Widget\Dashboard\Pane;
|
use \Icinga\Web\Widget\Dashboard\Pane;
|
||||||
use Icinga\Web\Widget\Dashboard\Component as DashboardComponent;
|
use \Icinga\Web\Widget\Dashboard\Component as DashboardComponent;
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
use \Icinga\Web\Url;
|
||||||
use Zend_View_Abstract;
|
use \Zend_View_Abstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dashboards display multiple views on a single page
|
* Dashboards display multiple views on a single page
|
||||||
|
@ -207,7 +207,7 @@ EOD;
|
|||||||
$html = str_replace('{URL}', $url->getAbsoluteUrl(), $this->template);
|
$html = str_replace('{URL}', $url->getAbsoluteUrl(), $this->template);
|
||||||
$html = str_replace('{REMOVE_URL}', $removeUrl, $html);
|
$html = str_replace('{REMOVE_URL}', $removeUrl, $html);
|
||||||
$html = str_replace('{DIMENSION}', $this->getBoxSizeAsCSS(), $html);
|
$html = str_replace('{DIMENSION}', $this->getBoxSizeAsCSS(), $html);
|
||||||
$html = str_replace('{TITLE}', $view->escape($this->getTitle()), $html);
|
$html = str_replace('{TITLE}', htmlentities($this->getTitle()), $html);
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Widget;
|
namespace Icinga\Web\Widget;
|
||||||
|
|
||||||
use Icinga\Exception\ProgrammingError;
|
use \Icinga\Web\Url;
|
||||||
use Zend_View_Abstract;
|
use \Zend_View_Abstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single tab, usually used through the tabs widget
|
* A single tab, usually used through the tabs widget
|
||||||
@ -44,9 +44,6 @@ use Zend_View_Abstract;
|
|||||||
* base URL
|
* base URL
|
||||||
* @property string $urlParams Action URL Parameters
|
* @property string $urlParams Action URL Parameters
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2013 Icinga-Web Team <info@icinga.org>
|
|
||||||
* @author Icinga-Web Team <info@icinga.org>
|
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
|
||||||
*/
|
*/
|
||||||
class Tab implements Widget
|
class Tab implements Widget
|
||||||
{
|
{
|
||||||
@ -99,7 +96,6 @@ class Tab implements Widget
|
|||||||
*/
|
*/
|
||||||
private $iconCls = null;
|
private $iconCls = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an icon image for this tab
|
* Sets an icon image for this tab
|
||||||
*
|
*
|
||||||
@ -107,6 +103,9 @@ class Tab implements Widget
|
|||||||
*/
|
*/
|
||||||
public function setIcon($icon)
|
public function setIcon($icon)
|
||||||
{
|
{
|
||||||
|
if (is_string($icon)) {
|
||||||
|
$icon = Url::fromPath($icon);
|
||||||
|
}
|
||||||
$this->icon = $icon;
|
$this->icon = $icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,10 +151,12 @@ class Tab implements Widget
|
|||||||
*/
|
*/
|
||||||
public function setUrl($url)
|
public function setUrl($url)
|
||||||
{
|
{
|
||||||
|
if (is_string($url)) {
|
||||||
|
$url = Url::fromPath($url);
|
||||||
|
}
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the parameters to be set for this tabs Url
|
* Set the parameters to be set for this tabs Url
|
||||||
*
|
*
|
||||||
@ -181,9 +182,6 @@ class Tab implements Widget
|
|||||||
$this->$setter($value);
|
$this->$setter($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->name === null) {
|
|
||||||
throw new ProgrammingError('Cannot create a nameless tab');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -203,6 +201,7 @@ class Tab implements Widget
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Widget::render()
|
* @see Widget::render()
|
||||||
*/
|
*/
|
||||||
@ -210,24 +209,16 @@ class Tab implements Widget
|
|||||||
{
|
{
|
||||||
$class = $this->active ? ' class="active"' : '';
|
$class = $this->active ? ' class="active"' : '';
|
||||||
$caption = $this->title;
|
$caption = $this->title;
|
||||||
|
|
||||||
if ($this->icon !== null) {
|
if ($this->icon !== null) {
|
||||||
$caption = $view->img(
|
$caption = '<img src="' . $this->icon->getAbsoluteUrl()
|
||||||
$this->icon,
|
. '" style="width:16px;height:16px"/> ' . $caption;
|
||||||
array(
|
|
||||||
'width' => 16,
|
|
||||||
'height' => 16
|
|
||||||
)
|
|
||||||
) . ' ' . $caption;
|
|
||||||
} elseif ($this->iconCls !== null) {
|
} elseif ($this->iconCls !== null) {
|
||||||
$caption = '<i class="icon-' . $this->iconCls . '"></i> ' . $caption;
|
$caption = '<i class="icon-' . $this->iconCls . '"></i> ' . $caption;
|
||||||
}
|
}
|
||||||
if ($this->url !== null) {
|
if ($this->url !== null) {
|
||||||
$tab = $view->qlink(
|
$this->url->overwriteParams($this->urlParams);
|
||||||
$caption,
|
$tab = '<a href="' . $this->url->getAbsoluteUrl() . '">' . $caption . '</a>';
|
||||||
$this->url,
|
|
||||||
$this->urlParams,
|
|
||||||
array('quote' => false)
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$tab = $caption;
|
$tab = $caption;
|
||||||
}
|
}
|
||||||
|
62
library/Icinga/Web/Widget/Tabextension/BasketAction.php
Normal file
62
library/Icinga/Web/Widget/Tabextension/BasketAction.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
use \Icinga\Web\Widget\Tabs;
|
||||||
|
use \Icinga\Web\Url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tabextension that adds the basket command
|
||||||
|
*
|
||||||
|
* @TODO: Baskets are not supported in the codebase yet (Feature #4537)
|
||||||
|
*/
|
||||||
|
class BasketAction implements Tabextension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Applies the dashboard actions to the provided tabset
|
||||||
|
*
|
||||||
|
* @param Tabs $tabs The tabs object to extend with
|
||||||
|
*
|
||||||
|
* @see \Icinga\Web\Widget\Tabextension::apply()
|
||||||
|
*/
|
||||||
|
public function apply(Tabs $tabs)
|
||||||
|
{
|
||||||
|
$tabs->addAsDropdown(
|
||||||
|
'basket',
|
||||||
|
array(
|
||||||
|
'title' => 'URL Basket',
|
||||||
|
'icon' => 'img/classic/basket.png',
|
||||||
|
'url' => Url::fromPath('basket/add'),
|
||||||
|
'urlParams' => array(
|
||||||
|
'url' => Url::fromRequest()->getRelativeUrl()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
64
library/Icinga/Web/Widget/Tabextension/DashboardAction.php
Normal file
64
library/Icinga/Web/Widget/Tabextension/DashboardAction.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
use \Icinga\Web\Url;
|
||||||
|
use \Icinga\Config\Config as IcingaConfig;
|
||||||
|
use \Icinga\Web\Widget\Tabs;
|
||||||
|
use \Icinga\Web\Widget\Dashboard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tabextension that allows to add the current URL to a dashboard
|
||||||
|
*
|
||||||
|
* Displayed as a dropdown field in the tabs
|
||||||
|
*/
|
||||||
|
class DashboardAction implements Tabextension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Applies the dashboard actions to the provided tabset
|
||||||
|
*
|
||||||
|
* @param Tabs $tabs The tabs object to extend with
|
||||||
|
*
|
||||||
|
* @see \Icinga\Web\Widget\Tabextension::apply()
|
||||||
|
*/
|
||||||
|
public function apply(Tabs $tabs)
|
||||||
|
{
|
||||||
|
$tabs->addAsDropdown(
|
||||||
|
'dashboard',
|
||||||
|
array(
|
||||||
|
'title' => 'Add to Dashboard',
|
||||||
|
'iconCls' => 'dashboard',
|
||||||
|
'url' => Url::fromPath('dashboard/addurl'),
|
||||||
|
'urlParams' => array(
|
||||||
|
'url' => Url::fromRequest()->getRelativeUrl()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
130
library/Icinga/Web/Widget/Tabextension/OutputFormat.php
Normal file
130
library/Icinga/Web/Widget/Tabextension/OutputFormat.php
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
use \Icinga\Application\Logger;
|
||||||
|
use \Icinga\Web\Widget\Tab;
|
||||||
|
use \Icinga\Web\Widget\Tabs;
|
||||||
|
use \Icinga\Web\Url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tabextension that offers different output formats for the user in the dropdown area
|
||||||
|
*/
|
||||||
|
class OutputFormat implements Tabextension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* PDF output type
|
||||||
|
*/
|
||||||
|
const TYPE_PDF = 'pdf';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON output type
|
||||||
|
*/
|
||||||
|
const TYPE_JSON = 'json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CSV output type
|
||||||
|
*/
|
||||||
|
const TYPE_CSV = 'csv';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array containing the tab definitions for all supported types
|
||||||
|
*
|
||||||
|
* Using array_keys on this array or isset allows to check whether a
|
||||||
|
* requested type is supported
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $supportedTypes = array(
|
||||||
|
self::TYPE_PDF => array(
|
||||||
|
'name' => 'pdf',
|
||||||
|
'title' => 'PDF',
|
||||||
|
'icon' => 'img/classic/application-pdf.png',
|
||||||
|
'urlParams' => array('filetype' => 'pdf')
|
||||||
|
),
|
||||||
|
self::TYPE_CSV => array(
|
||||||
|
'name' => 'csv',
|
||||||
|
'title' => 'CSV',
|
||||||
|
'icon' => 'img/classic/application-csv.png',
|
||||||
|
'urlParams' => array('filetype' => 'csv')
|
||||||
|
),
|
||||||
|
self::TYPE_JSON => array(
|
||||||
|
'name' => 'json',
|
||||||
|
'title' => 'JSON',
|
||||||
|
'icon' => 'img/classic/application-json.png',
|
||||||
|
'urlParams' => array('filetype' => 'json')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of tabs to be added to the dropdown area
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $tabs = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new OutputFormat extender
|
||||||
|
*
|
||||||
|
* In general, it's assumed that all types are supported when an outputFormat extension
|
||||||
|
* is added, so this class offers to remove specific types instead of adding ones
|
||||||
|
*
|
||||||
|
* @param array $disabled An array of output types to <b>not</b> show.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct(array $disabled = array())
|
||||||
|
{
|
||||||
|
foreach ($this->supportedTypes as $type => $values) {
|
||||||
|
if (in_array($type, $disabled)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!isset($this->supportedTypes[$type])) {
|
||||||
|
Logger::error('Tried to add an unsupported output type: %s', $type);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$tabConfig = $this->supportedTypes[$type];
|
||||||
|
$tabConfig["url"] = Url::fromRequest();
|
||||||
|
$this->tabs[] = new Tab($tabConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the format selectio to the provided tabset
|
||||||
|
*
|
||||||
|
* @param Tabs $tabs The tabs object to extend with
|
||||||
|
*
|
||||||
|
* @see Tabextension::apply()
|
||||||
|
*/
|
||||||
|
public function apply(Tabs $tabs)
|
||||||
|
{
|
||||||
|
foreach ($this->tabs as $tab) {
|
||||||
|
$tabs->addAsDropdown($tab->getName(), $tab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
library/Icinga/Web/Widget/Tabextension/Tabextension.php
Normal file
50
library/Icinga/Web/Widget/Tabextension/Tabextension.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
use \Icinga\Web\Widget\Tabs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tabextension interface that allows to extend a tabbar with reusable components
|
||||||
|
*
|
||||||
|
* Tabs can be either extended by creating a `Tabextension` and calling the `apply()` method
|
||||||
|
* or by calling the `\Icinga\Web\Widget\Tabs` `extend()` method and providing
|
||||||
|
* a tab extension
|
||||||
|
*
|
||||||
|
* @see \Icinga\Web\Widget\Tabs::extend()
|
||||||
|
*/
|
||||||
|
interface Tabextension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Apply this tabextension to the provided tabs
|
||||||
|
*
|
||||||
|
* @param Tabs $tabs The tabbar to modify
|
||||||
|
*/
|
||||||
|
public function apply(Tabs $tabs);
|
||||||
|
}
|
@ -28,17 +28,45 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Widget;
|
namespace Icinga\Web\Widget;
|
||||||
|
|
||||||
use Icinga\Exception\ProgrammingError;
|
use \Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Web\Url;
|
use \Icinga\Web\Widget\Tabextension\Tabextension;
|
||||||
|
use \Zend_View_Abstract;
|
||||||
use Countable;
|
use \Countable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigation tab widget
|
* Navigation tab widget
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class Tabs implements Countable, Widget
|
class Tabs implements Countable, Widget
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Template used for the base tabs
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $baseTpl = <<< 'EOT'
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
{TABS}
|
||||||
|
{DROPDOWN}
|
||||||
|
</ul>
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template used for the tabs dropdown
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $dropdownTpl = <<< 'EOT'
|
||||||
|
<li class="dropdown pull-right ">
|
||||||
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||||
|
<i class="icon-list-ul"></i>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
{TABS}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is where single tabs added to this container will be stored
|
* This is where single tabs added to this container will be stored
|
||||||
*
|
*
|
||||||
@ -54,30 +82,23 @@ class Tabs implements Countable, Widget
|
|||||||
private $active;
|
private $active;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class name(s) going to be assigned to the <ul> element
|
* Array of tab names which should be displayed in a dropdown
|
||||||
*
|
*
|
||||||
* @var string
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $tab_class = 'nav-tabs';
|
private $dropdownTabs = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* Array when special actions (dropdown) are enabled
|
|
||||||
* @TODO: Remove special part from tabs (Bug #4512)
|
|
||||||
*
|
|
||||||
* @var bool|array
|
|
||||||
*/
|
|
||||||
private $specialActions = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activate the tab with the given name
|
* Activate the tab with the given name
|
||||||
*
|
*
|
||||||
* If another tab is currently active it will be deactivated
|
* If another tab is currently active it will be deactivated
|
||||||
*
|
*
|
||||||
* @param string $name Name of the tab going to be activated
|
* @param string $name Name of the tab going to be activated
|
||||||
*
|
*
|
||||||
* @throws ProgrammingError if given tab name doesn't exist
|
* @return self
|
||||||
|
*
|
||||||
|
* @throws ProgrammingError When the given tab name doesn't exist
|
||||||
*
|
*
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function activate($name)
|
public function activate($name)
|
||||||
{
|
{
|
||||||
@ -87,18 +108,8 @@ class Tabs implements Countable, Widget
|
|||||||
}
|
}
|
||||||
$this->get($name)->setActive();
|
$this->get($name)->setActive();
|
||||||
$this->active = $name;
|
$this->active = $name;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
return $this;
|
||||||
throw new ProgrammingError(
|
|
||||||
sprintf(
|
|
||||||
"Cannot activate a tab that doesn't exist: %s. Available: %s",
|
|
||||||
$name,
|
|
||||||
empty($this->tabs)
|
|
||||||
? 'none'
|
|
||||||
: implode(', ', array_keys($this->tabs))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,9 +125,9 @@ class Tabs implements Countable, Widget
|
|||||||
/**
|
/**
|
||||||
* Set the CSS class name(s) for the <ul> element
|
* Set the CSS class name(s) for the <ul> element
|
||||||
*
|
*
|
||||||
* @param string $name CSS class name(s)
|
* @param string $name CSS class name(s)
|
||||||
*
|
*
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setClass($name)
|
public function setClass($name)
|
||||||
{
|
{
|
||||||
@ -127,9 +138,9 @@ class Tabs implements Countable, Widget
|
|||||||
/**
|
/**
|
||||||
* Whether the given tab name exists
|
* Whether the given tab name exists
|
||||||
*
|
*
|
||||||
* @param string $name Tab name
|
* @param string $name Tab name
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function has($name)
|
public function has($name)
|
||||||
{
|
{
|
||||||
@ -139,21 +150,16 @@ class Tabs implements Countable, Widget
|
|||||||
/**
|
/**
|
||||||
* Whether the given tab name exists
|
* Whether the given tab name exists
|
||||||
*
|
*
|
||||||
* @param string $name The tab you're interested in
|
* @param string $name The tab you're interested in
|
||||||
*
|
*
|
||||||
* @throws ProgrammingError if given tab name doesn't exist
|
* @return Tab
|
||||||
*
|
*
|
||||||
* @return Tab
|
* @throws ProgrammingError When the given tab name doesn't exist
|
||||||
*/
|
*/
|
||||||
public function get($name)
|
public function get($name)
|
||||||
{
|
{
|
||||||
if (!$this->has($name)) {
|
if (!$this->has($name)) {
|
||||||
throw new ProgrammingError(
|
return null;
|
||||||
sprintf(
|
|
||||||
'There is no such tab: %s',
|
|
||||||
$name
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return $this->tabs[$name];
|
return $this->tabs[$name];
|
||||||
}
|
}
|
||||||
@ -164,12 +170,12 @@ class Tabs implements Countable, Widget
|
|||||||
* A unique tab name is required, the Tab itself can either be an array
|
* A unique tab name is required, the Tab itself can either be an array
|
||||||
* with tab properties or an instance of an existing Tab
|
* with tab properties or an instance of an existing Tab
|
||||||
*
|
*
|
||||||
* @param string $name The new tab name
|
* @param string $name The new tab name
|
||||||
* @param array|Tab The tab itself of it's properties
|
* @param array|Tab $tab The tab itself of it's properties
|
||||||
*
|
*
|
||||||
* @throws ProgrammingError if tab name already exists
|
* @return self
|
||||||
*
|
*
|
||||||
* @return self
|
* @throws ProgrammingError When the tab name already exists
|
||||||
*/
|
*/
|
||||||
public function add($name, $tab)
|
public function add($name, $tab)
|
||||||
{
|
{
|
||||||
@ -191,10 +197,10 @@ class Tabs implements Countable, Widget
|
|||||||
* exists. The tab can either be an array with tab properties or an instance
|
* exists. The tab can either be an array with tab properties or an instance
|
||||||
* of an existing Tab
|
* of an existing Tab
|
||||||
*
|
*
|
||||||
* @param string $name The new tab name
|
* @param string $name The new tab name
|
||||||
* @param array|Tab The tab itself of it's properties
|
* @param array|Tab $tab The tab itself of it's properties
|
||||||
*
|
*
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function set($name, $tab)
|
public function set($name, $tab)
|
||||||
{
|
{
|
||||||
@ -207,93 +213,84 @@ class Tabs implements Countable, Widget
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable special actions (dropdown with format, basket and dashboard)
|
* Add a tab to the dropdown on the right side of the tab-bar.
|
||||||
*
|
*
|
||||||
* @TODO: Remove special part from tabs (Bug #4512)
|
* @param $name
|
||||||
*
|
* @param $tab
|
||||||
* @return $this
|
|
||||||
*/
|
*/
|
||||||
public function enableSpecialActions()
|
public function addAsDropdown($name, $tab)
|
||||||
{
|
{
|
||||||
$this->specialActions = true;
|
$this->set($name, $tab);
|
||||||
return $this;
|
$this->dropdownTabs[] = $name;
|
||||||
|
$this->dropdownTabs = array_unique($this->dropdownTabs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Render the dropdown area with it's tabs and return the resulting HTML
|
||||||
|
*
|
||||||
|
* @param Zend_View_Abstract $view The view used for rendering
|
||||||
|
*
|
||||||
|
* @return mixed|string
|
||||||
|
*/
|
||||||
|
private function renderDropdownTabs(Zend_View_Abstract $view)
|
||||||
|
{
|
||||||
|
if (empty($this->dropdownTabs)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$tabs = '';
|
||||||
|
foreach ($this->dropdownTabs as $tabname) {
|
||||||
|
$tab = $this->get($tabname);
|
||||||
|
if ($tab === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$tabs .= $tab->render($view);
|
||||||
|
}
|
||||||
|
return str_replace('{TABS}', $tabs, $this->dropdownTpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render all tabs, except the ones in dropdown area and return the resulting HTML
|
||||||
|
*
|
||||||
|
* @param Zend_View_Abstract $view The view used for rendering
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function renderTabs(Zend_View_Abstract $view)
|
||||||
|
{
|
||||||
|
$tabs = '';
|
||||||
|
foreach ($this->tabs as $name => $tab) {
|
||||||
|
// ignore tabs added to dropdown
|
||||||
|
if (in_array($name, $this->dropdownTabs)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$tabs .= $tab->render($view);
|
||||||
|
}
|
||||||
|
return $tabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render to HTML
|
||||||
|
*
|
||||||
* @see Widget::render
|
* @see Widget::render
|
||||||
*/
|
*/
|
||||||
public function render(\Zend_View_Abstract $view)
|
public function render(Zend_View_Abstract $view)
|
||||||
{
|
{
|
||||||
if (empty($this->tabs)) {
|
if (empty($this->tabs)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$html = '<ul class="nav ' . $this->tab_class . '">' . PHP_EOL;
|
|
||||||
|
|
||||||
foreach ($this->tabs as $tab) {
|
$html = $this->baseTpl;
|
||||||
$html .= $tab->render($view);
|
$html = str_replace('{TABS}', $this->renderTabs($view), $html);
|
||||||
}
|
$html = str_replace('{DROPDOWN}', $this->renderDropdownTabs($view), $html);
|
||||||
|
|
||||||
// @TODO: Remove special part from tabs (Bug #4512)
|
|
||||||
$special = array();
|
|
||||||
$special[] = $view->qlink(
|
|
||||||
$view->img('img/classic/application-pdf.png') . ' PDF',
|
|
||||||
Url::fromRequest(),
|
|
||||||
array('filetype' => 'pdf'),
|
|
||||||
array('target' => '_blank', 'quote' => false)
|
|
||||||
);
|
|
||||||
$special[] = $view->qlink(
|
|
||||||
$view->img('img/classic/application-csv.png') . ' CSV',
|
|
||||||
Url::fromRequest(),
|
|
||||||
array('format' => 'csv'),
|
|
||||||
array('target' => '_blank', 'quote' => false)
|
|
||||||
);
|
|
||||||
$special[] = $view->qlink(
|
|
||||||
$view->img('img/classic/application-json.png') . ' JSON',
|
|
||||||
Url::fromRequest(),
|
|
||||||
array('format' => 'json', 'quote' => false),
|
|
||||||
array('target' => '_blank', 'quote' => false)
|
|
||||||
);
|
|
||||||
|
|
||||||
$special[] = $view->qlink(
|
|
||||||
$view->img('img/classic/basket.png') . ' URL Basket',
|
|
||||||
Url::fromPath('basket/add'),
|
|
||||||
array('url' => Url::fromRequest()->getRelativeUrl()),
|
|
||||||
array('quote' => false)
|
|
||||||
);
|
|
||||||
|
|
||||||
$special[] = $view->qlink(
|
|
||||||
$view->img('img/classic/dashboard.png') . ' Dashboard',
|
|
||||||
Url::fromPath('dashboard/addurl'),
|
|
||||||
array('url' => Url::fromRequest()->getRelativeUrl()),
|
|
||||||
array('quote' => false)
|
|
||||||
);
|
|
||||||
// $auth = Auth::getInstance();
|
|
||||||
// if ($this->specialActions && ! empty($special) && $auth->isAuthenticated() && $auth->getUsername() === 'admin') {
|
|
||||||
if ($this->specialActions) {
|
|
||||||
$html .= '
|
|
||||||
<li class="dropdown">
|
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><b class="caret"></b></a>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
';
|
|
||||||
|
|
||||||
foreach ($special as $shtml) {
|
|
||||||
$html .= '<li>' . $shtml . "</li>\n";
|
|
||||||
}
|
|
||||||
$html .= ' </ul>
|
|
||||||
</li>
|
|
||||||
';
|
|
||||||
|
|
||||||
}
|
|
||||||
$html .= "</ul>\n";
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of tabs
|
* Return the number of tabs
|
||||||
*
|
*
|
||||||
* @see Countable
|
* @return int
|
||||||
*
|
*
|
||||||
* @return int
|
* @see Countable
|
||||||
*/
|
*/
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
@ -309,4 +306,17 @@ class Tabs implements Countable, Widget
|
|||||||
{
|
{
|
||||||
return $this->tabs;
|
return $this->tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply a Tabextension on this tabs object
|
||||||
|
*
|
||||||
|
* @param Tabextension $tabextension
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function extend(Tabextension $tabextension)
|
||||||
|
{
|
||||||
|
$tabextension->apply($this);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,9 @@ use Icinga\Web\Hook;
|
|||||||
use Icinga\File\Csv;
|
use Icinga\File\Csv;
|
||||||
use Monitoring\Backend;
|
use Monitoring\Backend;
|
||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
use Icinga\Web\Widget\Tabs;
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||||
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
use Icinga\Web\Widget\Tabextension\BasketAction;
|
||||||
|
|
||||||
class Monitoring_ListController extends ModuleActionController
|
class Monitoring_ListController extends ModuleActionController
|
||||||
{
|
{
|
||||||
@ -57,11 +59,9 @@ class Monitoring_ListController extends ModuleActionController
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->view->tabs = $this->getTabs()
|
|
||||||
->activate($this->action_name)
|
|
||||||
->enableSpecialActions();
|
|
||||||
$this->backend = Backend::getInstance($this->_getParam('backend'));
|
$this->backend = Backend::getInstance($this->_getParam('backend'));
|
||||||
$this->view->grapher = Hook::get('grapher');
|
$this->view->grapher = Hook::get('grapher');
|
||||||
|
$this->createTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -275,9 +275,14 @@ class Monitoring_ListController extends ModuleActionController
|
|||||||
*
|
*
|
||||||
* @return Tabs
|
* @return Tabs
|
||||||
*/
|
*/
|
||||||
protected function getTabs()
|
protected function createTabs()
|
||||||
{
|
{
|
||||||
$tabs = new Tabs();
|
|
||||||
|
$tabs = $this->getTabs();
|
||||||
|
$tabs->extend(new OutputFormat())
|
||||||
|
->extend(new DashboardAction())
|
||||||
|
->extend(new BasketAction());
|
||||||
|
|
||||||
$tabs->add('services', array(
|
$tabs->add('services', array(
|
||||||
'title' => 'All services',
|
'title' => 'All services',
|
||||||
'icon' => 'img/classic/service.png',
|
'icon' => 'img/classic/service.png',
|
||||||
@ -290,9 +295,12 @@ class Monitoring_ListController extends ModuleActionController
|
|||||||
));
|
));
|
||||||
$tabs->add('downtimes', array(
|
$tabs->add('downtimes', array(
|
||||||
'title' => 'Downtimes',
|
'title' => 'Downtimes',
|
||||||
|
'usePost' => true,
|
||||||
'icon' => 'img/classic/downtime.gif',
|
'icon' => 'img/classic/downtime.gif',
|
||||||
'url' => 'monitoring/list/downtimes',
|
'url' => 'monitoring/list/downtimes',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$tabs->add('hostgroups', array(
|
$tabs->add('hostgroups', array(
|
||||||
'title' => 'Hostgroups',
|
'title' => 'Hostgroups',
|
||||||
@ -315,7 +323,6 @@ class Monitoring_ListController extends ModuleActionController
|
|||||||
'url' => 'monitoring/list/contactgroups',
|
'url' => 'monitoring/list/contactgroups',
|
||||||
));
|
));
|
||||||
*/
|
*/
|
||||||
return $tabs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,14 +33,16 @@ use Icinga\Web\Hook;
|
|||||||
use Monitoring\Object\Host;
|
use Monitoring\Object\Host;
|
||||||
use Monitoring\Object\Service;
|
use Monitoring\Object\Service;
|
||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
use Icinga\Web\Widget\Tabs;
|
|
||||||
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||||
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
use Icinga\Web\Widget\Tabextension\BasketAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Monitoring_ShowController
|
* Class Monitoring_ShowController
|
||||||
*
|
*
|
||||||
* Actions for show context
|
* Actions for show context
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class Monitoring_ShowController extends ModuleActionController
|
class Monitoring_ShowController extends ModuleActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -82,7 +84,7 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->view->object = $object;
|
$this->view->object = $object;
|
||||||
$this->view->tabs = $this->createTabs();
|
$this->createTabs();
|
||||||
$this->prepareTicketHook();
|
$this->prepareTicketHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +95,6 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
{
|
{
|
||||||
Benchmark::measure('Entered service action');
|
Benchmark::measure('Entered service action');
|
||||||
$this->view->active = 'service';
|
$this->view->active = 'service';
|
||||||
$this->view->tabs->activate('service')->enableSpecialActions();
|
|
||||||
|
|
||||||
if ($grapher = Hook::get('grapher')) {
|
if ($grapher = Hook::get('grapher')) {
|
||||||
if ($grapher->hasGraph(
|
if ($grapher->hasGraph(
|
||||||
@ -209,7 +210,6 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
public function hostAction()
|
public function hostAction()
|
||||||
{
|
{
|
||||||
$this->view->active = 'host';
|
$this->view->active = 'host';
|
||||||
$this->view->tabs->activate('host')->enableSpecialActions();
|
|
||||||
|
|
||||||
if ($grapher = Hook::get('grapher')) {
|
if ($grapher = Hook::get('grapher')) {
|
||||||
if ($grapher->hasGraph($this->view->host->host_name)) {
|
if ($grapher->hasGraph($this->view->host->host_name)) {
|
||||||
@ -302,6 +302,7 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
->where('object_type', 'host')
|
->where('object_type', 'host')
|
||||||
->fetchPairs();
|
->fetchPairs();
|
||||||
$this->view->object->prefetch();
|
$this->view->object->prefetch();
|
||||||
|
$this->prepareTicketHook();
|
||||||
$this->prepareGrapherHook();
|
$this->prepareGrapherHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +427,7 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
protected function createTabs()
|
protected function createTabs()
|
||||||
{
|
{
|
||||||
$object = $this->view->object;
|
$object = $this->view->object;
|
||||||
$tabs = new Tabs();
|
$tabs = $this->getTabs();
|
||||||
if (!$this->view->host) {
|
if (!$this->view->host) {
|
||||||
return $tabs;
|
return $tabs;
|
||||||
}
|
}
|
||||||
@ -493,7 +494,9 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tabs->activate($this->action_name)->enableSpecialActions();
|
$tabs->extend(new OutputFormat())
|
||||||
|
->extend(new DashboardAction())
|
||||||
|
->extend(new BasketAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
$tabs->add('contacts', array(
|
$tabs->add('contacts', array(
|
||||||
@ -501,12 +504,8 @@ class Monitoring_ShowController extends ModuleActionController
|
|||||||
'icon' => 'img/classic/customer.png',
|
'icon' => 'img/classic/customer.png',
|
||||||
'url' => 'monitoring/detail/contacts',
|
'url' => 'monitoring/detail/contacts',
|
||||||
'urlParams' => $params,
|
'urlParams' => $params,
|
||||||
));
|
));**/
|
||||||
*/
|
|
||||||
// TODO: Inventory 'img/classic/facts.gif'
|
|
||||||
// Ticket 'img/classic/ticket.gif'
|
|
||||||
// Customer 'img/classic/customer.png'
|
|
||||||
return $tabs;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
// @codingStandardsIgnoreStart
|
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
|
||||||
|
|
||||||
use \Zend_Soap_Server as ZfSoapServer;
|
|
||||||
use \Zend_Soap_AutoDiscover as ZfSoapAutoDiscover;
|
|
||||||
use \Icinga\Web\Controller\ModuleActionController;
|
|
||||||
use \Icinga\Web\Url;
|
|
||||||
use \Monitoring\Backend;
|
|
||||||
|
|
||||||
|
|
||||||
class Api
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function problems()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$backend = Backend::getInstance('localdb');
|
|
||||||
$result = $backend->select()->from('status', array(
|
|
||||||
'host', 'service', 'host_state', 'service_state', 'service_output'
|
|
||||||
))->where('problems', 1)->fetchAll();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return array('error' => $e->getMessage());
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Monitoring_SoapController extends ModuleActionController
|
|
||||||
{
|
|
||||||
protected $handlesAuthentication = true;
|
|
||||||
|
|
||||||
public function indexAction()
|
|
||||||
{
|
|
||||||
$wsdl = new ZfSoapAutoDiscover();
|
|
||||||
$wsdl->setClass('Api');
|
|
||||||
if (isset($_GET['wsdl'])) {
|
|
||||||
$wsdl->handle();
|
|
||||||
} else {
|
|
||||||
$wsdl->dump('/tmp/test.wsdl');
|
|
||||||
$uri = 'http://itenos-devel.tom.local/' . Url::fromPath('monitoring/soap');
|
|
||||||
$server = new Zend_Soap_Server('/tmp/test.wsdl');
|
|
||||||
$server->setClass('Api');
|
|
||||||
$server->handle();
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// @codingStandardsIgnoreEnd
|
|
@ -28,7 +28,6 @@
|
|||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
use Icinga\Web\Controller\ModuleActionController;
|
use Icinga\Web\Controller\ModuleActionController;
|
||||||
use Icinga\Backend;
|
use Icinga\Backend;
|
||||||
use Icinga\Web\Widget\Tabs;
|
|
||||||
|
|
||||||
class Monitoring_SummaryController extends ModuleActionController
|
class Monitoring_SummaryController extends ModuleActionController
|
||||||
{
|
{
|
||||||
@ -39,13 +38,12 @@ class Monitoring_SummaryController extends ModuleActionController
|
|||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->backend = Backend::getInstance($this->_getParam('backend'));
|
$this->backend = Backend::getInstance($this->_getParam('backend'));
|
||||||
$this->view->compact = $this->_getParam('view') === 'compact';
|
|
||||||
$this->view->tabs = $this->getTabs();
|
$this->view->tabs = $this->getTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTabs()
|
protected function createTabs()
|
||||||
{
|
{
|
||||||
$tabs = new Tabs();
|
$tabs = $this->getTabs();
|
||||||
$tabs->add('hostgroup', array(
|
$tabs->add('hostgroup', array(
|
||||||
'title' => 'Hostgroups',
|
'title' => 'Hostgroups',
|
||||||
'url' => 'monitoring/summary/group',
|
'url' => 'monitoring/summary/group',
|
||||||
@ -92,6 +90,5 @@ class Monitoring_SummaryController extends ModuleActionController
|
|||||||
$this->view->summary = $query->paginate();
|
$this->view->summary = $query->paginate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$client = new SoapClient('http://itenos-devel.tom.local/monitoring/soap?wsdl', array(
|
|
||||||
'login' => 'icingaadmin',
|
|
||||||
'password' => 'tomtom',
|
|
||||||
'trace' => true,
|
|
||||||
'exceptions' => true,
|
|
||||||
'cache_wsdl' => WSDL_CACHE_NONE,
|
|
||||||
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
|
|
||||||
// 'authentication' => SOAP_AUTHENTICATION_BASIC
|
|
||||||
|
|
||||||
));
|
|
||||||
|
|
||||||
// print_r($client->__getFunctions());
|
|
||||||
try {
|
|
||||||
print_r($client->problems());
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo $e->getMessage() . "\n\n";
|
|
||||||
echo $client->__getLastRequest() . "\n\n";
|
|
||||||
echo $client->__getLastResponse() . "\n\n";
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Combo
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class ComboTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Combo::Init()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testInit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testInit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Combo::ListServices()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testListServices()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testListServices is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Ido
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class IdoTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Ido::Init()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testInit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testInit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Ido::GetSummary()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetSummary()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetSummary is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Ido::ListServices()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testListServices()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testListServices is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Livestatus
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class LivestatusTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Livestatus::Init()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testInit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testInit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Livestatus::Summary()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testSummary()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testSummary is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Livestatus::ListServices()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testListServices()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testListServices is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Monitoringobjectlist
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class MonitoringobjectlistTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::Current()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testCurrent()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testCurrent is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::Next()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testNext()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testNext is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::Key()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testKey()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testKey is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::Valid()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testValid()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testValid is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::Rewind()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRewind()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRewind is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for MonitoringObjectList::__isset()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__isset()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__isset is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend\Statusdat;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Servicelistquery
|
|
||||||
* Created Mon, 18 Feb 2013 14:33:21 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class ServicelistqueryTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for ServicelistQuery::Init()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testInit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testInit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Backend;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Statusdat
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class StatusdatTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Statusdat::Init()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testInit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testInit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Statusdat::ListServices()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testListServices()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testListServices is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -87,9 +87,7 @@ var onLinkTagClick = function(ev) {
|
|||||||
'.layout-main-detail * a' : {
|
'.layout-main-detail * a' : {
|
||||||
'click' : onLinkTagClick
|
'click' : onLinkTagClick
|
||||||
},
|
},
|
||||||
/* 'a' : {
|
|
||||||
'click' : onOuterLinkClick
|
|
||||||
},*/
|
|
||||||
'.layout-main-detail .icinga-container#icinga-detail' : {
|
'.layout-main-detail .icinga-container#icinga-detail' : {
|
||||||
'focus' : expandDetailView
|
'focus' : expandDetailView
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Zend_View_Helper_Perfdata
|
|
||||||
* Created Thu, 24 Jan 2013 12:56:08 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Zend_View_Helper_PerfdataTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_Perfdata::Perfdata()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testPerfdata()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testPerfdata is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Zend_View_Helper_Qurl
|
|
||||||
* Created Thu, 24 Jan 2013 12:56:08 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Zend_View_Helper_QurlTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_QUrl::QUrl()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testQUrl()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testQUrl is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
require_once('Zend/View/Helper/Abstract.php');
|
|
||||||
require_once('Zend/View.php');
|
|
||||||
|
|
||||||
require_once('../../application/views/helpers/Qlink.php');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Zend_View_Helper_Qlink
|
|
||||||
* Created Thu, 24 Jan 2013 12:56:08 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Zend_View_Helper_QlinkTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
public function testQlink()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testQlink is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: Url handling has benn moved to `library\Icinga\Web\Url`. Replace following tests.
|
|
||||||
*/
|
|
||||||
// public function testURLPathParameter()
|
|
||||||
// {
|
|
||||||
// $view = new Zend_View();
|
|
||||||
//
|
|
||||||
// $helper = new Zend_View_Helper_Qlink();
|
|
||||||
// $helper->setView($view);
|
|
||||||
// $pathTpl = "/path/%s/to/%s";
|
|
||||||
// $this->assertEquals(
|
|
||||||
// "/path/param1/to/param2",
|
|
||||||
// $helper->getFormattedURL($pathTpl,array('param1','param2'))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public function testUrlGETParameter()
|
|
||||||
// {
|
|
||||||
// $view = new Zend_View();
|
|
||||||
// $helper = new Zend_View_Helper_Qlink();
|
|
||||||
// $helper->setView($view);
|
|
||||||
// $pathTpl = 'path';
|
|
||||||
// $this->assertEquals(
|
|
||||||
// '/path?param1=value1&param2=value2',
|
|
||||||
// $helper->getFormattedURL($pathTpl,array('param1'=>'value1','param2'=>'value2'))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public function testMixedParameters()
|
|
||||||
// {
|
|
||||||
// $view = new Zend_View();
|
|
||||||
// $helper = new Zend_View_Helper_Qlink();
|
|
||||||
// $helper->setView($view);
|
|
||||||
// $pathTpl = 'path/%s/to/%s';
|
|
||||||
// $this->assertEquals(
|
|
||||||
// '/path/path1/to/path2?param1=value1&param2=value2',
|
|
||||||
// $helper->getFormattedURL($pathTpl,array(
|
|
||||||
// 'path1','path2',
|
|
||||||
// 'param1'=>'value1',
|
|
||||||
// 'param2'=>'value2'))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // TODO: Test error case
|
|
||||||
// public function testWrongUrl() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Zend_View_Helper_Renderserviceperfdata
|
|
||||||
* Created Thu, 24 Jan 2013 12:56:08 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Zend_View_Helper_RenderserviceperfdataTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_RenderServicePerfdata::RenderServicePerfdata()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRenderServicePerfdata()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRenderServicePerfdata is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_RenderServicePerfdata::RenderDiskPie()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRenderDiskPie()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRenderDiskPie is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Zend_View_Helper_Timesince
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:14 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Zend_View_Helper_TimesinceTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_TimeSince::TimeSince()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testTimeSince()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testTimeSince is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Zend_View_Helper_TimeSince::ShowHourMin()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testShowHourMin()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testShowHourMin is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Monlib_Gui_Util
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:14 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Monlib_Gui_UtilTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::ShowTimeSince()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testShowTimeSince()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testShowTimeSince is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::ShowHourMin()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testShowHourMin()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testShowHourMin is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::ShowSeconds()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testShowSeconds()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testShowSeconds is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::ShowTime()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testShowTime()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testShowTime is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::GetHostStateClassName()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetHostStateClassName()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetHostStateClassName is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::GetHostStateName()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetHostStateName()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetHostStateName is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Monlib_Gui_Util::GetServiceStateName()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetServiceStateName()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetServiceStateName is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Application;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Bootstrap
|
|
||||||
* Created Thu, 07 Feb 2013 10:07:13 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class BootstrapTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::AddModule()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testAddModule()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testAddModule is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::GetApplicationDir()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetApplicationDir()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetApplicationDir is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::GetModuleDir()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetModuleDir()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetModuleDir is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::HasModule()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasModule()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasModule is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::IsLegacy()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testIsLegacy()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testIsLegacy is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::IsRunningOnCli()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testIsRunningOnCli()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testIsRunningOnCli is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::GetLecacyBasedir()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetLecacyBasedir()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetLecacyBasedir is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::Dispatch()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testDispatch()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testDispatch is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::Cli()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testCli()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testCli is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::ForIcingaWeb1x()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testForIcingaWeb1x()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testForIcingaWeb1x is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::Web()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testWeb()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testWeb is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::Embedded()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testEmbedded()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testEmbedded is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Bootstrap::GetInstance()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetInstance()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetInstance is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Application;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Session
|
|
||||||
* Created Thu, 07 Feb 2013 10:07:13 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class SessionTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Session::GetInstance()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetInstance()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetInstance is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Authentication;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Credentials
|
|
||||||
* Created Mon, 10 Jun 2013 07:54:34 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class CredentialsTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::GetUsername()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetUsername()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetUsername is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::SetUsername()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testSetUsername()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testSetUsername is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::GetPassword()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetPassword()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetPassword is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::SetPassword()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testSetPassword()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testSetPassword is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::GetDomain()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetDomain()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetDomain is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Credentials::SetDomain()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testSetDomain()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testSetDomain is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Authentication;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Userbackend
|
|
||||||
* Created Fri, 07 Jun 2013 10:38:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class UserbackendTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for UserBackend::HasUsername()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasUsername()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasUsername is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for UserBackend::Authenticate()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testAuthenticate()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testAuthenticate is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Backend
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class BackendTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Backend::GetInstance()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetInstance()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetInstance is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Benchmark
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class BenchmarkTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::Measure()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testMeasure()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testMeasure is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::Reset()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testReset()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testReset is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::GetStartTime()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetStartTime()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetStartTime is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::Dump()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testDump()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testDump is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::RenderToText()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRenderToText()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRenderToText is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Benchmark::RenderToHtml()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRenderToHtml()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRenderToHtml is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Format
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class FormatTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Format::Bytes()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testBytes()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testBytes is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Ido;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Db
|
|
||||||
* Created Wed, 16 Jan 2013 15:15:16 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class DbTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Db::Module()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testModule()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testModule is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Db::GetDb()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetDb()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetDb is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Db::GetPrefix()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetPrefix()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetPrefix is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Protocol\Ldap;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Connection
|
|
||||||
* Created Tue, 12 Mar 2013 17:08:12 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class ConnectionTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::GetDN()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::Root()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testRoot()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testRoot is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::Select()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testSelect()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testSelect is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::FetchOne()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testFetchOne()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testFetchOne is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::FetchRow()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testFetchRow()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testFetchRow is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::FetchAll()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testFetchAll()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testFetchAll is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Protocol\Ldap;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Ldaputils
|
|
||||||
* Created Tue, 12 Mar 2013 17:08:12 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class LdaputilsTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for LdapUtils::ExplodeDN()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testExplodeDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testExplodeDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for LdapUtils::ImplodeDN()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testImplodeDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testImplodeDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for LdapUtils::QuoteForDN()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testQuoteForDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testQuoteForDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for LdapUtils::QuoteForSearch()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testQuoteForSearch()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testQuoteForSearch is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Protocol\Ldap;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Node
|
|
||||||
* Created Tue, 12 Mar 2013 17:08:12 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class NodeTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Node::GetRDN()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetRDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetRDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Node::GetDN()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Node::__get()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__get()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__get is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Node::CreateWithRDN()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testCreateWithRDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testCreateWithRDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Protocol\Ldap;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Root
|
|
||||||
* Created Tue, 12 Mar 2013 17:08:12 +0000
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class RootTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::HasParent()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasParent()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasParent is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::GetConnection()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetConnection()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetConnection is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::HasBeenChanged()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasBeenChanged()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasBeenChanged is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::GetRDN()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetRDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetRDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::GetDN()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetDN()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetDN is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::__get()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__get()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__get is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Root::ForConnection()
|
|
||||||
* Note: This method is static!
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testForConnection()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testForConnection is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -18,15 +18,6 @@ require_once('../../library/Icinga/Protocol/Livestatus/Query.php');
|
|||||||
class ConnectionTest extends TestCase
|
class ConnectionTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::HasTable()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasTable()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasTable is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for Connection::Select()
|
* Test for Connection::Select()
|
||||||
*
|
*
|
||||||
@ -39,31 +30,4 @@ class ConnectionTest extends TestCase
|
|||||||
unlink($socket);
|
unlink($socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::FetchAll()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testFetchAll()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testFetchAll is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::Disconnect()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testDisconnect()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testDisconnect is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Connection::__destruct()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__destruct()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__destruct is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,148 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Protocol\Livestatus;
|
|
||||||
|
|
||||||
use Icinga\Protocol\Livestatus\Connection;
|
|
||||||
use Icinga\Protocol\Livestatus\Query;
|
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
|
||||||
|
|
||||||
require_once('../../library/Icinga/Protocol/AbstractQuery.php');
|
|
||||||
require_once('../../library/Icinga/Protocol/Livestatus/Query.php');
|
|
||||||
require_once('../../library/Icinga/Protocol/Livestatus/Connection.php');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Test class for Query
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class QueryTest extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::Compare()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testCompare()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testCompare is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::HasOrder()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasOrder()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasOrder is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::Where()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testWhere()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testWhere is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::Order()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testOrder()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testOrder is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::Limit()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testLimit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testLimit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::HasLimit()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasLimit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasLimit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::HasOffset()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasOffset()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasOffset is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::GetLimit()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetLimit()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetLimit is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::GetOffset()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetOffset()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetOffset is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::From()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testFrom()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testFrom is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::HasColumns()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testHasColumns()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testHasColumns is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::GetColumns()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function testGetColumns()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('testGetColumns is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::__toString()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__toString()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__toString is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for Query::__destruct()
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function test__destruct()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('test__destruct is not implemented yet');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Icinga\Web\Controller\ActionController;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -13,9 +13,18 @@ require_once '../../library/Icinga/Exception/ProgrammingError.php';
|
|||||||
|
|
||||||
use Icinga\Web\Hook\Configuration\ConfigurationTab;
|
use Icinga\Web\Hook\Configuration\ConfigurationTab;
|
||||||
use Icinga\Web\Hook;
|
use Icinga\Web\Hook;
|
||||||
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tabs;
|
use Icinga\Web\Widget\Tabs;
|
||||||
use PHPUnit_Framework_TestResult;
|
use PHPUnit_Framework_TestResult;
|
||||||
|
|
||||||
|
class RequestMock
|
||||||
|
{
|
||||||
|
public function getBaseUrl()
|
||||||
|
{
|
||||||
|
return "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigurationTabBuilderTest extends \PHPUnit_Framework_TestCase
|
class ConfigurationTabBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
@ -23,12 +32,14 @@ class ConfigurationTabBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
Hook::clean();
|
Hook::clean();
|
||||||
|
Url::$overwrittenRequest = new RequestMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
Hook::clean();
|
Hook::clean();
|
||||||
|
Url::$overwrittenRequest = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultTabs()
|
public function testDefaultTabs()
|
||||||
|
89
test/php/library/Icinga/Web/RequestMock.php
Normal file
89
test/php/library/Icinga/Web/RequestMock.php
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Tests\Icinga\Web;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request mock that implements all methods required by the
|
||||||
|
* Url class
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class RequestMock
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The path of the request
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $path = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The baseUrl of the request
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $baseUrl = '/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of query parameters that the request should resemble
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $query = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path set for the request
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPathInfo()
|
||||||
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the baseUrl set for the request
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBaseUrl()
|
||||||
|
{
|
||||||
|
return $this->baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the query set for the request
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getQuery()
|
||||||
|
{
|
||||||
|
return $this->query;
|
||||||
|
}
|
||||||
|
}
|
@ -2,69 +2,10 @@
|
|||||||
|
|
||||||
namespace Tests\Icinga\Web;
|
namespace Tests\Icinga\Web;
|
||||||
require_once('../../library/Icinga/Web/Url.php');
|
require_once('../../library/Icinga/Web/Url.php');
|
||||||
|
require_once('library/Icinga/Web/RequestMock.php');
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
use Tests\Icinga\Web\RequestMock;
|
||||||
|
|
||||||
/**
|
|
||||||
* Request mock that implements all methods required by the
|
|
||||||
* Url class
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class RequestMock
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The path of the request
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $path = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The baseUrl of the request
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $baseUrl = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An array of query parameters that the request should resemble
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $query = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path set for the request
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getPathInfo()
|
|
||||||
{
|
|
||||||
return $this->path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the baseUrl set for the request
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getBaseUrl()
|
|
||||||
{
|
|
||||||
return $this->baseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the query set for the request
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getQuery()
|
|
||||||
{
|
|
||||||
return $this->query;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the Icinga\Web\Url class that provides convenient access to Url manipulation method
|
* Tests for the Icinga\Web\Url class that provides convenient access to Url manipulation method
|
||||||
|
50
test/php/library/Icinga/Web/ViewMock.php
Normal file
50
test/php/library/Icinga/Web/ViewMock.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Tests\Icinga\Web;
|
||||||
|
|
||||||
|
require_once('Zend/View/Abstract.php');
|
||||||
|
use \Zend_View_Abstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ViewMock that does absolutely nothing
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ViewMock extends Zend_View_Abstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* No operation is performed here
|
||||||
|
*/
|
||||||
|
protected function _run()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreEnd
|
164
test/php/library/Icinga/Web/Widget/TabTest.php
Normal file
164
test/php/library/Icinga/Web/Widget/TabTest.php
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Tests\Icinga\Web\Widget;
|
||||||
|
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Widget.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tab.php');
|
||||||
|
require_once('../../library/Icinga/Web/Url.php');
|
||||||
|
require_once('library/Icinga/Web/RequestMock.php');
|
||||||
|
require_once('library/Icinga/Web/ViewMock.php');
|
||||||
|
require_once('Zend/View/Abstract.php');
|
||||||
|
|
||||||
|
use Icinga\Web\View;
|
||||||
|
use Icinga\Web\Widget\Tab;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
use Tests\Icinga\Web\RequestMock;
|
||||||
|
use \Zend_View_Abstract;
|
||||||
|
use \PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
|
use Tests\Icinga\Web\ViewMock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test creation and rendering of tabs
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class TabTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether rendering a tab without URL is done correctly
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testRenderWithoutUrl()
|
||||||
|
{
|
||||||
|
$tab = new Tab(array("name" => "tab", "title" => "Title text"));
|
||||||
|
$html = $tab->render(new ViewMock());
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
preg_match(
|
||||||
|
'/<li *> *Title text *<\/li> */i',
|
||||||
|
$html
|
||||||
|
),
|
||||||
|
"Asserting an tab without url only showing a title, , got " . $html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether rendering an active tab adds the 'class' property
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testActiveTab()
|
||||||
|
{
|
||||||
|
$tab = new Tab(array("name" => "tab", "title" => "Title text"));
|
||||||
|
$tab->setActive(true);
|
||||||
|
|
||||||
|
$html = $tab->render(new ViewMock());
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
preg_match(
|
||||||
|
'/<li *class="active" *> *Title text *<\/li> */i',
|
||||||
|
$html
|
||||||
|
),
|
||||||
|
"Asserting an active tab having the 'active' class provided, got " . $html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether rendering a tab with URL adds a n >a< tag correctly
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testTabWithUrl()
|
||||||
|
{
|
||||||
|
$tab = new Tab(
|
||||||
|
array(
|
||||||
|
"name" => "tab",
|
||||||
|
"title" => "Title text",
|
||||||
|
"url" => Url::fromPath("my/url", array(), new RequestMock())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$html = $tab->render(new ViewMock());
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
preg_match(
|
||||||
|
'/<li *><a href="\/my\/url">Title text<\/a><\/li>/i',
|
||||||
|
$html
|
||||||
|
),
|
||||||
|
'Asserting an url being rendered inside an HTML anchor. got ' . $html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test wheter the 'icon' property adds an img tag
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testTabWithIconImage()
|
||||||
|
{
|
||||||
|
$tab = new Tab(
|
||||||
|
array(
|
||||||
|
"name" => "tab",
|
||||||
|
"title" => "Title text",
|
||||||
|
"icon" => Url::fromPath("my/url", array(), new RequestMock())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$html = $tab->render(new ViewMock());
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
preg_match(
|
||||||
|
'/<li *><img src="\/my\/url" .*?\/> Title text<\/li>/i',
|
||||||
|
$html
|
||||||
|
),
|
||||||
|
'Asserting an url being rendered inside an HTML anchor. got ' . $html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test wheter the iconCls property adds an i tag with the icon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testTabWithIconClass()
|
||||||
|
{
|
||||||
|
$tab = new Tab(
|
||||||
|
array(
|
||||||
|
"name" => "tab",
|
||||||
|
"title" => "Title text",
|
||||||
|
"iconCls" => "myIcon"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$html = $tab->render(new ViewMock());
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
preg_match(
|
||||||
|
'/<li *><i class="icon-myIcon"><\/i> Title text<\/li>/i',
|
||||||
|
$html
|
||||||
|
),
|
||||||
|
'Asserting an url being rendered inside an HTML anchor. got ' . $html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Tests\Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Widget.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tab.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tabs.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tabextension/Tabextension.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tabextension/OutputFormat.php');
|
||||||
|
require_once('../../library/Icinga/Web/Url.php');
|
||||||
|
|
||||||
|
require_once('library/Icinga/Web/RequestMock.php');
|
||||||
|
require_once('library/Icinga/Web/ViewMock.php');
|
||||||
|
|
||||||
|
require_once('Zend/View/Abstract.php');
|
||||||
|
|
||||||
|
use Icinga\Web\View;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
use Icinga\Web\Widget\Tabs;
|
||||||
|
use Tests\Icinga\Web\RequestMock;
|
||||||
|
use Tests\Icinga\Web\ViewMock;
|
||||||
|
use \Zend_View_Abstract;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for the OutputFormat Tabextension
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class OutputFormatTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test if a simple apply adds all tabs from the extender
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testApply()
|
||||||
|
{
|
||||||
|
$tabs = new Tabs();
|
||||||
|
Url::$overwrittenRequest = new RequestMock();
|
||||||
|
$tabs->extend(new OutputFormat());
|
||||||
|
$this->assertEquals(3, $tabs->count(), "Asserting new tabs being available after extending the tab bar");
|
||||||
|
Url::$overwrittenRequest = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if an apply with disabled output formats doesn't add these tabs
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testDisableOutputFormat()
|
||||||
|
{
|
||||||
|
Url::$overwrittenRequest = new RequestMock();
|
||||||
|
$tabs = new Tabs();
|
||||||
|
$tabs->extend(new OutputFormat(array(OutputFormat::TYPE_PDF)));
|
||||||
|
$this->assertEquals(
|
||||||
|
2,
|
||||||
|
$tabs->count(),
|
||||||
|
"Asserting two tabs being available after extending the tab bar and ignoring PDF"
|
||||||
|
);
|
||||||
|
Url::$overwrittenRequest = null;
|
||||||
|
}
|
||||||
|
}
|
111
test/php/library/Icinga/Web/Widget/TabsTest.php
Normal file
111
test/php/library/Icinga/Web/Widget/TabsTest.php
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Tests\Icinga\Web\Widget;
|
||||||
|
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Widget.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tab.php');
|
||||||
|
require_once('../../library/Icinga/Web/Widget/Tabs.php');
|
||||||
|
require_once('../../library/Icinga/Web/Url.php');
|
||||||
|
|
||||||
|
require_once('library/Icinga/Web/ViewMock.php');
|
||||||
|
require_once('Zend/View/Abstract.php');
|
||||||
|
|
||||||
|
use Icinga\Web\View;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
use Icinga\Web\Widget\Tabs;
|
||||||
|
use Tests\Icinga\Web\ViewMock;
|
||||||
|
|
||||||
|
use \Zend_View_Abstract;
|
||||||
|
use \PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test rendering of tabs and corretct tab management
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class TabsTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test adding tabs and asserting for correct count
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testAddTabs()
|
||||||
|
{
|
||||||
|
$tabs = new Tabs();
|
||||||
|
$this->assertEquals(0, $tabs->count(), 'Asserting a tab bar starting with no items');
|
||||||
|
$tabs->add('tab1', array('title' => 'Tab 1'));
|
||||||
|
$tabs->add('tab2', array('title' => 'Tab 2'));
|
||||||
|
$this->assertEquals(2, $tabs->count(), 'Asserting a tab bar containing 2 items after being added');
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
$tabs->has('tab1'),
|
||||||
|
'Asserting the tab bar to determine the existence of added tabs correctly (tab1)'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
$tabs->has('tab2'),
|
||||||
|
'Asserting the tab bar to determine the existence of added tabs correctly (tab2)'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test rendering of tabs when no dropdown is requested
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testRenderTabsWithoutDropdown()
|
||||||
|
{
|
||||||
|
$tabs = new Tabs();
|
||||||
|
|
||||||
|
$tabs->add('tab1', array('title' => 'Tab 1'));
|
||||||
|
$tabs->add('tab2', array('title' => 'Tab 2'));
|
||||||
|
|
||||||
|
$html = $tabs->render(new ViewMock());
|
||||||
|
$this->assertContains('<li >Tab 1</li>', $html, 'Asserting tab 1 being rendered correctly' . $html);
|
||||||
|
$this->assertContains('<li >Tab 2</li>', $html, 'Asserting tab 2 being rendered correctly' . $html);
|
||||||
|
$this->assertNotContains('class="dropdown ', 'Asserting the dropdown to not be rendered' . $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test rendering of tabs when dropdown is requested
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testRenderDropdown()
|
||||||
|
{
|
||||||
|
$tabs = new Tabs();
|
||||||
|
|
||||||
|
$tabs->add('tab1', array('title' => 'Tab 1'));
|
||||||
|
$tabs->addAsDropdown('tab2', array('title' => 'Tab 2'));
|
||||||
|
|
||||||
|
$html = $tabs->render(new ViewMock());
|
||||||
|
$this->assertContains('<li >Tab 1</li>', $html, 'Asserting tab 1 being rendered correctly ' . $html);
|
||||||
|
$this->assertContains('<li >Tab 2</li>', $html, 'Asserting tab 2 being rendered correctly ' . $html);
|
||||||
|
$this->assertContains('class="dropdown ', 'Asserting the dropdown to be rendered, got ' . $html);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user