From f0475c240792ed1ee0dc5c54d40a73db2a3fd63d Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 25 Nov 2015 12:52:57 +0100 Subject: [PATCH] IcingaHost: beautify enumProperties --- library/Director/Objects/IcingaHost.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/library/Director/Objects/IcingaHost.php b/library/Director/Objects/IcingaHost.php index 3a175e59..5c9a2f3a 100644 --- a/library/Director/Objects/IcingaHost.php +++ b/library/Director/Objects/IcingaHost.php @@ -50,19 +50,26 @@ class IcingaHost extends IcingaObject public static function enumProperties(DbConnection $connection = null) { $properties = static::create()->listProperties(); - $properties = array_combine($properties, $properties); + $props = mt('director', 'Properties'); + $vars = mt('director', 'Custom variables'); + $properties = array( + $props => array_combine($properties, $properties), + $vars => array() + ); + if ($connection !== null) { foreach ($connection->fetchDistinctHostVars() as $var) { if ($var->datatype) { - $properties['vars.' . $var->varname] = $var->caption; + $properties[$vars]['vars.' . $var->varname] = sprintf('%s (%s)', $var->varname, $var->caption); } else { - $properties['vars.' . $var->varname] = 'vars.' . $var->varname; + $properties[$vars]['vars.' . $var->varname] = $var->varname; } } } - $properties['vars.*'] = 'Other custom variable'; - + //$properties['vars.*'] = 'Other custom variable'; + ksort($properties[$vars]); + ksort($properties[$props]); return $properties; }