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