Perfdata and PluginOutput helpers, output slightly changed

This commit is contained in:
Thomas Gelf 2014-03-04 12:54:23 +00:00
parent b09ea7c690
commit 0e50547a01
2 changed files with 17 additions and 11 deletions

View File

@ -1,6 +1,6 @@
<?php
use \Icinga\Module\Monitoring\Plugin\PerfdataSet;
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
{
@ -67,11 +67,11 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
. implode(',', array($green, $orange, $red, $gray))
. '</div>';
} else {
$result .= '<tr><td><div class="inlinepie" title="' . htmlspecialchars($name) . '">'
$result .= '<tr><th><div class="inlinepie" title="' . htmlspecialchars($name) . '" style="float: left; margin: 0.2em 0.5em 0.2em 0;">'
. implode(',', array($green, $orange, $red, $gray))
. '</div></td><td>'
. '</div>'
. htmlspecialchars($name)
. '</td><td>'
. '</th><td>'
. htmlspecialchars($ps[$name]->getFormattedValue() /* $val*/)
//. htmlspecialchars($unit)
. '</td></tr>';
@ -81,7 +81,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
$result = $perfdata;
}
if (! $compact && $result !== '') {
$result = '<table style="width: 100%; border: none;">' . $result . '</table>';
$result = '<table class="perfdata">' . $result . '</table>';
}
return $result;

View File

@ -6,14 +6,18 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
public function pluginOutput($output)
{
if (empty($output)) {
return '';
}
$output = preg_replace('~<br[^>]+>~', "\n", $output);
if (preg_match('~<\w+[^>]*>~', $output)) {
// HTML
$output = preg_replace('~<table~', '<table style="font-size: 0.65em"',
$output = preg_replace('~<table~', '<table style="font-size: 0.75em"',
$this->getPurifier()->purify($output)
);
} elseif (preg_match('~\\\n~', $output)) {
// Plaintext
$output = '<pre style="font-family: monospace; font-size: 0.95em;'
$output = '<pre style="font-family: monospace; font-size: 1em;'
. ' width: 90%; overflow: auto;">'
. preg_replace(
'~\\\n~', "\n", preg_replace(
@ -22,14 +26,16 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
preg_replace('~\[WARNING\]~', '<span class="warning">[WARNING]</span>',
preg_replace('~\[CRITICAL\]~', '<span class="error">[CRITICAL]</span>',
preg_replace('~\@{6,}~', '@@@@@@',
$this->view->escape(wordwrap($output, 72, ' ', true))
$this->view->escape(wordwrap($output, 80, "\n", true))
))))
)
) . '</pre>';
} else {
$output = preg_replace('~\@{6,}~', '@@@@@@',
$this->view->escape(wordwrap($output, 72, ' ', true))
);
$output = '<pre style="font-family: monospace; font-size: 1em;'
. ' width: 90%; overflow: auto;">'
. preg_replace('~\@{6,}~', '@@@@@@',
$this->view->escape(wordwrap($output, 80, "\n", true))
) . '</pre>';
}
$output = $this->fixLinks($output);
return $output;