From 58518868773dc5c393ada2ab86e342c8948fc210 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 12 Nov 2014 11:30:06 +0100 Subject: [PATCH 01/11] Widget\Tab: no underlined space after icon --- library/Icinga/Web/Widget/Tab.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Tab.php b/library/Icinga/Web/Widget/Tab.php index 92a1a9954..28c04e6ab 100644 --- a/library/Icinga/Web/Widget/Tab.php +++ b/library/Icinga/Web/Widget/Tab.php @@ -201,7 +201,7 @@ class Tab extends AbstractWidget $caption = $view->escape($this->title); if ($this->icon !== null) { - $caption = $view->img($this->icon, array('class' => 'icon')) . ' ' . $caption; + $caption = $view->img($this->icon, array('class' => 'icon')) . $caption; } if ($this->url !== null) { $this->url->overwriteParams($this->urlParams); From f0ca81d7af6d7cb0b777877e786f26e637b60821 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 12 Nov 2014 11:47:42 +0100 Subject: [PATCH 02/11] Data\Filter: SORT_NATURAL only for PHP >= 5.4 --- library/Icinga/Data/Filter/Filter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Data/Filter/Filter.php b/library/Icinga/Data/Filter/Filter.php index 64607a4a0..99b0290f1 100644 --- a/library/Icinga/Data/Filter/Filter.php +++ b/library/Icinga/Data/Filter/Filter.php @@ -79,7 +79,7 @@ abstract class Filter } } - krsort($operators, SORT_NATURAL); + krsort($operators, version_compare(PHP_VERSION, '5.4.0') >= 0 ? SORT_NATURAL : SORT_REGULAR); foreach ($operators as $id => $operator) { $f = $filter->getById($id); if ($f->getOperatorName() !== $operator) { From 877e9101f363f4275adffb48a083983fd87c770a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 11 Nov 2014 15:00:59 +0100 Subject: [PATCH 03/11] Do not define the constant ICINGAWEB_LIBDIR This constant should not be needed anywhere. --- library/Icinga/Application/ApplicationBootstrap.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 00c600609..52d0e77d2 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -102,10 +102,6 @@ abstract class ApplicationBootstrap { $this->libDir = realpath(__DIR__ . '/../..'); - if (!defined('ICINGA_LIBDIR')) { - define('ICINGA_LIBDIR', $this->libDir); - } - if (defined('ICINGAWEB_APPDIR')) { $this->appDir = ICINGAWEB_APPDIR; } elseif (array_key_exists('ICINGAWEB_APPDIR', $_SERVER)) { From 32d483f69f4675bea1462a4a5c65c0ec2ad8586b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 11 Nov 2014 15:22:21 +0100 Subject: [PATCH 04/11] Level up index.php This is the preparation for having the Icinga library in PHP's include path. --- public/index.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/index.php b/public/index.php index 171581155..92cd0a499 100644 --- a/public/index.php +++ b/public/index.php @@ -2,4 +2,12 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -require_once dirname(__DIR__). '/library/Icinga/Application/webrouter.php'; +define('ICINGAWEB_BASEDIR', dirname(__DIR__)); +// ICINGAWEB_BASEDIR is the parent folder for at least application, bin, modules and public + + +if (! @include_once ICINGAWEB_BASEDIR . '/library/Icinga/Application/webrouter.php') { + // If the Icinga library wasn't found under ICINGAWEB_BASEDIR, require that the Icinga library is found in PHP's + // include path which is the case if Icinga Web 2 is installed via packages + require_once 'Icinga/Application/webrouter.php'; +} From 8c9465ffbd5565dde988e889cc13676485768d99 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 11 Nov 2014 15:30:11 +0100 Subject: [PATCH 05/11] Fix ICINGAWEB_APPDIR location if the Icinga library is in PHP's include path --- .../Icinga/Application/ApplicationBootstrap.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 52d0e77d2..29e545cf8 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -6,6 +6,7 @@ namespace Icinga\Application; use ErrorException; use Exception; +use LogicException; use Icinga\Application\Modules\Manager as ModuleManager; use Icinga\Data\ResourceFactory; use Icinga\Exception\ConfigurationError; @@ -104,13 +105,15 @@ abstract class ApplicationBootstrap if (defined('ICINGAWEB_APPDIR')) { $this->appDir = ICINGAWEB_APPDIR; - } elseif (array_key_exists('ICINGAWEB_APPDIR', $_SERVER)) { - $this->appDir = $_SERVER['ICINGAWEB_APPDIR']; } else { - $this->appDir = realpath($this->libDir. '/../application'); - } - - if (!defined('ICINGAWEB_APPDIR')) { + if (array_key_exists('ICINGAWEB_APPDIR', $_SERVER)) { + $this->appDIr = $_SERVER['ICINGAWEB_APPDIR']; + } else { + if (! defined('ICINGAWEB_BASEDIR')) { + throw new LogicException('\'ICINGAWEB_BASEDIR\' is not defined'); + } + $this->appDir = ICINGAWEB_BASEDIR . '/application'; + } define('ICINGAWEB_APPDIR', $this->appDir); } @@ -394,7 +397,7 @@ abstract class ApplicationBootstrap */ protected function setupLogger() { - if (($loggingConfig = $this->config->get('logging')) !== null) { + if (($loggingConfig = $this->config->logging) !== null) { try { Logger::create($loggingConfig); } catch (ConfigurationError $e) { From 921f324d3e10cbcbe9ca661b6cc53f1de2e4e3f2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 12 Nov 2014 13:13:39 +0100 Subject: [PATCH 06/11] Prepare icingacli for having the Icinga library in PHP's include path --- bin/icingacli | 19 +++++++++++++++---- public/index.php | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bin/icingacli b/bin/icingacli index 1a0781222..5bd5086d2 100755 --- a/bin/icingacli +++ b/bin/icingacli @@ -1,6 +1,17 @@ #!/usr/bin/php -dispatch(); +dispatch(); diff --git a/public/index.php b/public/index.php index 92cd0a499..881c1318e 100644 --- a/public/index.php +++ b/public/index.php @@ -3,7 +3,7 @@ // {{{ICINGA_LICENSE_HEADER}}} define('ICINGAWEB_BASEDIR', dirname(__DIR__)); -// ICINGAWEB_BASEDIR is the parent folder for at least application, bin, modules and public +// ICINGAWEB_BASEDIR is the parent folder for at least application, bin, modules, library/vendor and public if (! @include_once ICINGAWEB_BASEDIR . '/library/Icinga/Application/webrouter.php') { From 11e13582e246305281a5fe8cc7addb07449db528 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 12 Nov 2014 13:17:18 +0100 Subject: [PATCH 07/11] Define the ICINGAWEB_VENDORS contant --- library/Icinga/Application/ApplicationBootstrap.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 29e545cf8..08bab4aba 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -103,15 +103,17 @@ abstract class ApplicationBootstrap { $this->libDir = realpath(__DIR__ . '/../..'); + if (! defined('ICINGAWEB_BASEDIR')) { + throw new LogicException('\'ICINGAWEB_BASEDIR\' is not defined'); + } + define('ICINGAWEB_VENDORS', ICINGAWEB_BASEDIR . '/library/vendor'); + if (defined('ICINGAWEB_APPDIR')) { $this->appDir = ICINGAWEB_APPDIR; } else { if (array_key_exists('ICINGAWEB_APPDIR', $_SERVER)) { - $this->appDIr = $_SERVER['ICINGAWEB_APPDIR']; + $this->appDir = $_SERVER['ICINGAWEB_APPDIR']; } else { - if (! defined('ICINGAWEB_BASEDIR')) { - throw new LogicException('\'ICINGAWEB_BASEDIR\' is not defined'); - } $this->appDir = ICINGAWEB_BASEDIR . '/application'; } define('ICINGAWEB_APPDIR', $this->appDir); From 277765ac72dc5b8cbcbc08cee74fc2381ffd9fee Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 12 Nov 2014 13:18:05 +0100 Subject: [PATCH 08/11] No longer make ICINGAWEB_APPDIR configureable --- library/Icinga/Application/ApplicationBootstrap.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 08bab4aba..0c3721294 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -107,17 +107,7 @@ abstract class ApplicationBootstrap throw new LogicException('\'ICINGAWEB_BASEDIR\' is not defined'); } define('ICINGAWEB_VENDORS', ICINGAWEB_BASEDIR . '/library/vendor'); - - if (defined('ICINGAWEB_APPDIR')) { - $this->appDir = ICINGAWEB_APPDIR; - } else { - if (array_key_exists('ICINGAWEB_APPDIR', $_SERVER)) { - $this->appDir = $_SERVER['ICINGAWEB_APPDIR']; - } else { - $this->appDir = ICINGAWEB_BASEDIR . '/application'; - } - define('ICINGAWEB_APPDIR', $this->appDir); - } + define('ICINGAWEB_APPDIR', ICINGAWEB_BASEDIR . '/application'); if ($configDir === null) { if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) { From 826cfbeceb488fa8d7bb0d0c80d09e2d94f6d872 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 12 Nov 2014 13:48:26 +0100 Subject: [PATCH 09/11] Fix include path to the Cli in icingacli --- bin/icingacli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/icingacli b/bin/icingacli index 5bd5086d2..3f3cc47f1 100755 --- a/bin/icingacli +++ b/bin/icingacli @@ -8,7 +8,7 @@ define('ICINGAWEB_BASEDIR', dirname(__DIR__)); // ICINGAWEB_BASEDIR is the parent folder for at least application, bin, modules, library/vendor and public -if (! @include_once ICINGAWEB_BASEDIR . 'Icinga/Application/Cli.php') { +if (! @include_once ICINGAWEB_BASEDIR . '/library/Icinga/Application/Cli.php') { // If the Icinga library wasn't found under ICINGAWEB_BASEDIR, require that the Icinga library is found in PHP's // include path which is the case if Icinga Web 2 is installed via packages require_once 'Icinga/Application/Cli.php'; From 6089372c424b4b1f3de1bea255aacb51a7fdf45a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 12 Nov 2014 14:39:45 +0100 Subject: [PATCH 10/11] Do not define ICINGAWEB_BASEDIR in index.php There's SCRIPT_FILENAME. The constants will be removed shortly. --- library/Icinga/Application/ApplicationBootstrap.php | 9 ++++----- public/index.php | 6 +----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 0c3721294..fc124b61d 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -101,14 +101,13 @@ abstract class ApplicationBootstrap */ protected function __construct($configDir = null) { - $this->libDir = realpath(__DIR__ . '/../..'); - - if (! defined('ICINGAWEB_BASEDIR')) { - throw new LogicException('\'ICINGAWEB_BASEDIR\' is not defined'); - } + define('ICINGAWEB_BASEDIR', dirname($this->getBootstrapDirecory())); define('ICINGAWEB_VENDORS', ICINGAWEB_BASEDIR . '/library/vendor'); define('ICINGAWEB_APPDIR', ICINGAWEB_BASEDIR . '/application'); + $this->appDir = ICINGAWEB_APPDIR; + $this->libDir = realpath(__DIR__ . '/../..'); + if ($configDir === null) { if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) { $configDir = $_SERVER['ICINGAWEB_CONFIGDIR']; diff --git a/public/index.php b/public/index.php index 881c1318e..085f73747 100644 --- a/public/index.php +++ b/public/index.php @@ -2,11 +2,7 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -define('ICINGAWEB_BASEDIR', dirname(__DIR__)); -// ICINGAWEB_BASEDIR is the parent folder for at least application, bin, modules, library/vendor and public - - -if (! @include_once ICINGAWEB_BASEDIR . '/library/Icinga/Application/webrouter.php') { +if (! @include_once dirname(__DIR__) . '/library/Icinga/Application/webrouter.php') { // If the Icinga library wasn't found under ICINGAWEB_BASEDIR, require that the Icinga library is found in PHP's // include path which is the case if Icinga Web 2 is installed via packages require_once 'Icinga/Application/webrouter.php'; From a081db08a40ee137fb53af081bbc256c1869e5d4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 12 Nov 2014 14:43:58 +0100 Subject: [PATCH 11/11] icingacli: Fix "Notice: Constant ICINGAWEB_BASEDIR already defined" --- library/Icinga/Application/ApplicationBootstrap.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index fc124b61d..90e420d7e 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -101,7 +101,9 @@ abstract class ApplicationBootstrap */ protected function __construct($configDir = null) { - define('ICINGAWEB_BASEDIR', dirname($this->getBootstrapDirecory())); + if (! defined('ICINGAWEB_BASEDIR')) { + define('ICINGAWEB_BASEDIR', dirname($this->getBootstrapDirecory())); + } define('ICINGAWEB_VENDORS', ICINGAWEB_BASEDIR . '/library/vendor'); define('ICINGAWEB_APPDIR', ICINGAWEB_BASEDIR . '/application');