icingaweb2/modules/monitoring/application/views/helpers/ResolveComments.php

32 lines
983 B
PHP

<?php
// TODO: Throw away as soon as our backends are handling things better
class Zend_View_Helper_ResolveComments extends Zend_View_Helper_Abstract
{
public function resolveComments($infos)
{
$ret = array();
if (is_array($infos)) {
foreach ($infos as $info) {
if (! is_array($info) || empty($info)) continue;
if (is_int(key($info))) {
// livestatus
$ret[] = '[' . $info[1] . '] ' . $info[2];
} else {
// statusdat - doesn't seem to work?!
$ret[] = '[' . $info['author'] . '] '
. (isset($info['comment'])
? $info['comment']
: $info['comment_data']
);
}
}
} else {
// ido
$ret = preg_split('~\|~', $infos);
}
return $ret;
}
}