mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-24 22:34:24 +02:00
parent
b043317fd4
commit
7fd575080e
@ -14,7 +14,7 @@ use Icinga\Exception\NotFoundError;
|
|||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Forms\ConfigForm;
|
use Icinga\Forms\ConfigForm;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -817,7 +817,7 @@ class NavigationConfigForm extends ConfigForm
|
|||||||
*/
|
*/
|
||||||
protected function getItemForm($type)
|
protected function getItemForm($type)
|
||||||
{
|
{
|
||||||
$className = String::cname($type, '-') . 'Form';
|
$className = StringHelper::cname($type, '-') . 'Form';
|
||||||
|
|
||||||
$form = null;
|
$form = null;
|
||||||
foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) {
|
foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) {
|
||||||
|
@ -9,7 +9,7 @@ use Icinga\Application\Icinga;
|
|||||||
use Icinga\Exception\AlreadyExistsException;
|
use Icinga\Exception\AlreadyExistsException;
|
||||||
use Icinga\Exception\NotFoundError;
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Forms\ConfigForm;
|
use Icinga\Forms\ConfigForm;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for managing roles
|
* Form for managing roles
|
||||||
@ -176,7 +176,7 @@ class RoleForm extends ConfigForm
|
|||||||
}
|
}
|
||||||
$role = $this->config->getSection($name)->toArray();
|
$role = $this->config->getSection($name)->toArray();
|
||||||
$role['permissions'] = ! empty($role['permissions'])
|
$role['permissions'] = ! empty($role['permissions'])
|
||||||
? String::trimSplit($role['permissions'])
|
? StringHelper::trimSplit($role['permissions'])
|
||||||
: null;
|
: null;
|
||||||
$role['name'] = $name;
|
$role['name'] = $name;
|
||||||
$restrictions = array();
|
$restrictions = array();
|
||||||
|
@ -8,7 +8,7 @@ use Icinga\Application\Logger;
|
|||||||
use Icinga\Exception\NotReadableError;
|
use Icinga\Exception\NotReadableError;
|
||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve restrictions and permissions for users
|
* Retrieve restrictions and permissions for users
|
||||||
@ -26,13 +26,13 @@ class AdmissionLoader
|
|||||||
{
|
{
|
||||||
$username = strtolower($username);
|
$username = strtolower($username);
|
||||||
if (! empty($section->users)) {
|
if (! empty($section->users)) {
|
||||||
$users = array_map('strtolower', String::trimSplit($section->users));
|
$users = array_map('strtolower', StringHelper::trimSplit($section->users));
|
||||||
if (in_array($username, $users)) {
|
if (in_array($username, $users)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! empty($section->groups)) {
|
if (! empty($section->groups)) {
|
||||||
$groups = array_map('strtolower', String::trimSplit($section->groups));
|
$groups = array_map('strtolower', StringHelper::trimSplit($section->groups));
|
||||||
foreach ($userGroups as $userGroup) {
|
foreach ($userGroups as $userGroup) {
|
||||||
if (in_array(strtolower($userGroup), $groups)) {
|
if (in_array(strtolower($userGroup), $groups)) {
|
||||||
return true;
|
return true;
|
||||||
@ -69,7 +69,7 @@ class AdmissionLoader
|
|||||||
if ($this->match($username, $userGroups, $role)) {
|
if ($this->match($username, $userGroups, $role)) {
|
||||||
$permissions = array_merge(
|
$permissions = array_merge(
|
||||||
$permissions,
|
$permissions,
|
||||||
array_diff(String::trimSplit($role->permissions), $permissions)
|
array_diff(StringHelper::trimSplit($role->permissions), $permissions)
|
||||||
);
|
);
|
||||||
$restrictionsFromRole = $role->toArray();
|
$restrictionsFromRole = $role->toArray();
|
||||||
unset($restrictionsFromRole['users']);
|
unset($restrictionsFromRole['users']);
|
||||||
|
@ -7,7 +7,7 @@ use Icinga\Exception\StatementException;
|
|||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Repository\IniRepository;
|
use Icinga\Repository\IniRepository;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
class IniUserGroupBackend extends IniRepository implements UserGroupBackendInterface
|
class IniUserGroupBackend extends IniRepository implements UserGroupBackendInterface
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ class IniUserGroupBackend extends IniRepository implements UserGroupBackendInter
|
|||||||
$memberships = array();
|
$memberships = array();
|
||||||
foreach ($result as $group) {
|
foreach ($result as $group) {
|
||||||
if ($group->users && !in_array($group->group_name, $memberships)) {
|
if ($group->users && !in_array($group->group_name, $memberships)) {
|
||||||
$users = array_map('strtolower', String::trimSplit($group->users));
|
$users = array_map('strtolower', StringHelper::trimSplit($group->users));
|
||||||
if (in_array($username, $users)) {
|
if (in_array($username, $users)) {
|
||||||
$memberships[] = $group->group_name;
|
$memberships[] = $group->group_name;
|
||||||
$parent = $groups[$group->group_name];
|
$parent = $groups[$group->group_name];
|
||||||
|
@ -13,7 +13,7 @@ use Icinga\Data\Updatable;
|
|||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Exception\StatementException;
|
use Icinga\Exception\StatementException;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for concrete database repository implementations
|
* Abstract base class for concrete database repository implementations
|
||||||
@ -904,7 +904,7 @@ abstract class DbRepository extends Repository implements Extensible, Updatable,
|
|||||||
return $column;
|
return $column;
|
||||||
}
|
}
|
||||||
|
|
||||||
$joinMethod = 'join' . String::cname($tableName);
|
$joinMethod = 'join' . StringHelper::cname($tableName);
|
||||||
if (! method_exists($this, $joinMethod)) {
|
if (! method_exists($this, $joinMethod)) {
|
||||||
throw new ProgrammingError(
|
throw new ProgrammingError(
|
||||||
'Unable to join table "%s" into "%s". Method "%s" not found',
|
'Unable to join table "%s" into "%s". Method "%s" not found',
|
||||||
|
@ -11,7 +11,7 @@ use Icinga\Data\Selectable;
|
|||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Exception\QueryException;
|
use Icinga\Exception\QueryException;
|
||||||
use Icinga\Exception\StatementException;
|
use Icinga\Exception\StatementException;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for concrete repository implementations
|
* Abstract base class for concrete repository implementations
|
||||||
@ -789,7 +789,7 @@ abstract class Repository implements Selectable
|
|||||||
protected function retrieveCommaSeparatedString($value)
|
protected function retrieveCommaSeparatedString($value)
|
||||||
{
|
{
|
||||||
if ($value && is_string($value)) {
|
if ($value && is_string($value)) {
|
||||||
$value = String::trimSplit($value);
|
$value = StringHelper::trimSplit($value);
|
||||||
} elseif ($value !== null) {
|
} elseif ($value !== null) {
|
||||||
throw new ProgrammingError('Cannot retrieve value "%s" as array. It\'s not a string', $value);
|
throw new ProgrammingError('Cannot retrieve value "%s" as array. It\'s not a string', $value);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ class DirectoryIterator implements Iterator
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->extension && ! String::endsWith($file, $this->extension)) {
|
if ($this->extension && ! StringHelper::endsWith($file, $this->extension)) {
|
||||||
$skip = true;
|
$skip = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ namespace Icinga\Util;
|
|||||||
/**
|
/**
|
||||||
* Common string functions
|
* Common string functions
|
||||||
*/
|
*/
|
||||||
class String
|
class StringHelper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Split string into an array and trim spaces
|
* Split string into an array and trim spaces
|
@ -4,7 +4,7 @@
|
|||||||
namespace Icinga\Web\Controller;
|
namespace Icinga\Web\Controller;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
use Zend_Controller_Action;
|
use Zend_Controller_Action;
|
||||||
use Zend_Controller_Action_Interface;
|
use Zend_Controller_Action_Interface;
|
||||||
use Zend_Controller_Dispatcher_Exception;
|
use Zend_Controller_Dispatcher_Exception;
|
||||||
@ -44,7 +44,7 @@ class Dispatcher extends Zend_Controller_Dispatcher_Standard
|
|||||||
parent::dispatch($request, $response);
|
parent::dispatch($request, $response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$controllerName = String::cname($controllerName, '-') . 'Controller';
|
$controllerName = StringHelper::cname($controllerName, '-') . 'Controller';
|
||||||
$moduleName = $request->getModuleName();
|
$moduleName = $request->getModuleName();
|
||||||
if ($moduleName === null || $moduleName === $this->_defaultModule) {
|
if ($moduleName === null || $moduleName === $this->_defaultModule) {
|
||||||
$controllerClass = 'Icinga\\' . self::CONTROLLER_NAMESPACE . '\\' . $controllerName;
|
$controllerClass = 'Icinga\\' . self::CONTROLLER_NAMESPACE . '\\' . $controllerName;
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
namespace Icinga\Web\Form\Validator;
|
namespace Icinga\Web\Form\Validator;
|
||||||
|
|
||||||
use Zend_Validate_InArray;
|
use Zend_Validate_InArray;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
class InArray extends Zend_Validate_InArray
|
class InArray extends Zend_Validate_InArray
|
||||||
{
|
{
|
||||||
protected function _error($messageKey, $value = null)
|
protected function _error($messageKey, $value = null)
|
||||||
{
|
{
|
||||||
if ($messageKey === static::NOT_IN_ARRAY) {
|
if ($messageKey === static::NOT_IN_ARRAY) {
|
||||||
$matches = String::findSimilar($this->_value, $this->_haystack);
|
$matches = StringHelper::findSimilar($this->_value, $this->_haystack);
|
||||||
if (empty($matches)) {
|
if (empty($matches)) {
|
||||||
$this->_messages[$messageKey] = sprintf(t('"%s" is not in the list of allowed values.'), $this->_value);
|
$this->_messages[$messageKey] = sprintf(t('"%s" is not in the list of allowed values.'), $this->_value);
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,7 +17,7 @@ use Icinga\Data\ConfigObject;
|
|||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
use Icinga\Web\Navigation\Renderer\RecursiveNavigationRenderer;
|
use Icinga\Web\Navigation\Renderer\RecursiveNavigationRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,7 +134,7 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
|
|||||||
throw new InvalidArgumentException('Argument $properties must be of type array or ConfigObject');
|
throw new InvalidArgumentException('Argument $properties must be of type array or ConfigObject');
|
||||||
}
|
}
|
||||||
|
|
||||||
$itemType = isset($properties['type']) ? String::cname($properties['type'], '-') : 'NavigationItem';
|
$itemType = isset($properties['type']) ? StringHelper::cname($properties['type'], '-') : 'NavigationItem';
|
||||||
if (! empty(static::$types) && isset(static::$types[$itemType])) {
|
if (! empty(static::$types) && isset(static::$types[$itemType])) {
|
||||||
return new static::$types[$itemType]($name, $properties);
|
return new static::$types[$itemType]($name, $properties);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ namespace Icinga\Web\Navigation\Renderer;
|
|||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
use Icinga\Web\Navigation\NavigationItem;
|
use Icinga\Web\Navigation\NavigationItem;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\View;
|
use Icinga\Web\View;
|
||||||
@ -76,7 +76,7 @@ class NavigationItemRenderer
|
|||||||
public function setOptions(array $options)
|
public function setOptions(array $options)
|
||||||
{
|
{
|
||||||
foreach ($options as $name => $value) {
|
foreach ($options as $name => $value) {
|
||||||
$setter = 'set' . String::cname($name);
|
$setter = 'set' . StringHelper::cname($name);
|
||||||
if (method_exists($this, $setter)) {
|
if (method_exists($this, $setter)) {
|
||||||
$this->$setter($value);
|
$this->$setter($value);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Icinga\Web\View;
|
namespace Icinga\Web\View;
|
||||||
|
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
$this->addHelperFunction('ellipsis', function ($string, $maxLength, $ellipsis = '...') {
|
$this->addHelperFunction('ellipsis', function ($string, $maxLength, $ellipsis = '...') {
|
||||||
return String::ellipsis($string, $maxLength, $ellipsis);
|
return StringHelper::ellipsis($string, $maxLength, $ellipsis);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->addHelperFunction('nl2br', function ($string) {
|
$this->addHelperFunction('nl2br', function ($string) {
|
||||||
|
@ -5,7 +5,7 @@ namespace Icinga\Web\Widget\Chart;
|
|||||||
|
|
||||||
use Icinga\Chart\PieChart;
|
use Icinga\Chart\PieChart;
|
||||||
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
|
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
use Icinga\Web\Widget\AbstractWidget;
|
use Icinga\Web\Widget\AbstractWidget;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Util\Format;
|
use Icinga\Util\Format;
|
||||||
@ -277,7 +277,7 @@ EOD;
|
|||||||
{
|
{
|
||||||
$handledUnhandledStates = array();
|
$handledUnhandledStates = array();
|
||||||
foreach ($states as $key => $value) {
|
foreach ($states as $key => $value) {
|
||||||
if (String::endsWith($key, '_handled') || String::endsWith($key, '_unhandled')) {
|
if (StringHelper::endsWith($key, '_handled') || StringHelper::endsWith($key, '_unhandled')) {
|
||||||
$handledUnhandledStates[$key] = $value;
|
$handledUnhandledStates[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
use Icinga\Module\Monitoring\Plugin\Perfdata;
|
use Icinga\Module\Monitoring\Plugin\Perfdata;
|
||||||
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
|
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||||
{
|
{
|
||||||
@ -81,7 +81,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
|||||||
$data []= sprintf(
|
$data []= sprintf(
|
||||||
'<span title="%s">%s</span>',
|
'<span title="%s">%s</span>',
|
||||||
$text,
|
$text,
|
||||||
String::ellipsisCenter($text, 24)
|
StringHelper::ellipsisCenter($text, 24)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ namespace Icinga\Module\Monitoring\Object;
|
|||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Traversable;
|
use Traversable;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acknowledgement of a host or service incident
|
* Acknowledgement of a host or service incident
|
||||||
@ -205,7 +205,7 @@ class Acknowledgement
|
|||||||
throw new InvalidArgumentException('Properties must be either an array or an instance of Traversable');
|
throw new InvalidArgumentException('Properties must be either an array or an instance of Traversable');
|
||||||
}
|
}
|
||||||
foreach ($properties as $name => $value) {
|
foreach ($properties as $name => $value) {
|
||||||
$setter = 'set' . ucfirst(String::cname($name));
|
$setter = 'set' . ucfirst(StringHelper::cname($name));
|
||||||
if (method_exists($this, $setter)) {
|
if (method_exists($this, $setter)) {
|
||||||
$this->$setter($value);
|
$this->$setter($value);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use Icinga\Data\DataArray\ArrayDatasource;
|
|||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Data\Filter\FilterOr;
|
use Icinga\Data\Filter\FilterOr;
|
||||||
use Icinga\Data\SimpleQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A host list
|
* A host list
|
||||||
@ -61,7 +61,7 @@ class HostList extends ObjectList
|
|||||||
*/
|
*/
|
||||||
public static function getHostStatesSummaryEmpty()
|
public static function getHostStatesSummaryEmpty()
|
||||||
{
|
{
|
||||||
return String::cartesianProduct(
|
return StringHelper::cartesianProduct(
|
||||||
array(
|
array(
|
||||||
array('hosts'),
|
array('hosts'),
|
||||||
array(
|
array(
|
||||||
|
@ -7,7 +7,7 @@ use Icinga\Data\DataArray\ArrayDatasource;
|
|||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Data\Filter\FilterOr;
|
use Icinga\Data\Filter\FilterOr;
|
||||||
use Icinga\Data\SimpleQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A service list
|
* A service list
|
||||||
@ -106,7 +106,7 @@ class ServiceList extends ObjectList
|
|||||||
*/
|
*/
|
||||||
public static function getServiceStatesSummaryEmpty()
|
public static function getServiceStatesSummaryEmpty()
|
||||||
{
|
{
|
||||||
return String::cartesianProduct(
|
return StringHelper::cartesianProduct(
|
||||||
array(
|
array(
|
||||||
array('services'),
|
array('services'),
|
||||||
array(
|
array(
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
namespace Tests\Icinga\Util;
|
namespace Tests\Icinga\Util;
|
||||||
|
|
||||||
use Icinga\Test\BaseTestCase;
|
use Icinga\Test\BaseTestCase;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\StringHelper;
|
||||||
|
|
||||||
class StringTest extends BaseTestCase
|
class StringTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
@ -12,7 +12,7 @@ class StringTest extends BaseTestCase
|
|||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('one', 'two', 'three'),
|
array('one', 'two', 'three'),
|
||||||
String::trimSplit(' one ,two , three'),
|
StringHelper::trimSplit(' one ,two , three'),
|
||||||
'String::trimSplit does not properly split a string and/or trim its elements'
|
'String::trimSplit does not properly split a string and/or trim its elements'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ class StringTest extends BaseTestCase
|
|||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('one', 'two', 'three'),
|
array('one', 'two', 'three'),
|
||||||
String::trimSplit('one.two.three', '.'),
|
StringHelper::trimSplit('one.two.three', '.'),
|
||||||
'String::trimSplit does not split a string by the given delimiter'
|
'String::trimSplit does not split a string by the given delimiter'
|
||||||
);
|
);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user