mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
parent
88315db1eb
commit
5bf89da6d7
@ -5,34 +5,44 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
|
|||||||
{
|
{
|
||||||
protected static $purifier;
|
protected static $purifier;
|
||||||
|
|
||||||
|
protected static $txtPatterns = array(
|
||||||
|
'~\\\n~',
|
||||||
|
'~\\\t~',
|
||||||
|
'~\\\n\\\n~',
|
||||||
|
'~(\[|\()OK(\]|\))~',
|
||||||
|
'~(\[|\()WARNING(\]|\))~',
|
||||||
|
'~(\[|\()CRITICAL(\]|\))~',
|
||||||
|
'~(\[|\()UNKNOWN(\]|\))~',
|
||||||
|
'~\@{6,}~'
|
||||||
|
);
|
||||||
|
|
||||||
|
protected static $txtReplacements = array(
|
||||||
|
"\n",
|
||||||
|
"\t",
|
||||||
|
"\n",
|
||||||
|
'<span class="state ok">$1OK$2</span>',
|
||||||
|
'<span class="state warning">$1WARNING$2</span>',
|
||||||
|
'<span class="state critical">$1CRITICAL$2</span>',
|
||||||
|
'<span class="state error">$1UNKNOWN$2</span>',
|
||||||
|
'@@@@@@',
|
||||||
|
);
|
||||||
|
|
||||||
public function pluginOutput($output)
|
public function pluginOutput($output)
|
||||||
{
|
{
|
||||||
if (empty($output)) {
|
if (empty($output)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$output = preg_replace('~<br[^>]+>~', "\n", $output);
|
$output = preg_replace('~<br[^>]+>~', "\n", $output);
|
||||||
if (preg_match('~<\w+[^>]*>~', $output)) {
|
if (preg_match('~<\w+[^>^\\\]{,60}>~', $output)) {
|
||||||
// HTML
|
// HTML
|
||||||
$output = preg_replace('~<table~', '<table style="font-size: 0.75em"',
|
$output = preg_replace('~<table~', '<table style="font-size: 0.75em"',
|
||||||
$this->getPurifier()->purify($output)
|
$this->getPurifier()->purify($output)
|
||||||
);
|
);
|
||||||
} elseif (preg_match('~\\\n~', $output)) {
|
|
||||||
// Plaintext
|
|
||||||
$output = '<pre class="pluginoutput">'
|
|
||||||
. preg_replace(
|
|
||||||
'~\\\n~', "\n", preg_replace(
|
|
||||||
'~\\\n\\\n~', "\n",
|
|
||||||
preg_replace('~\[OK\]~', '<span class="ok">[OK]</span>',
|
|
||||||
preg_replace('~\[WARNING\]~', '<span class="warning">[WARNING]</span>',
|
|
||||||
preg_replace('~\[CRITICAL\]~', '<span class="error">[CRITICAL]</span>',
|
|
||||||
preg_replace('~\@{6,}~', '@@@@@@',
|
|
||||||
$this->view->escape($output)
|
|
||||||
))))
|
|
||||||
)
|
|
||||||
) . '</pre>';
|
|
||||||
} else {
|
} else {
|
||||||
$output = '<pre class="pluginoutput">'
|
// Plaintext
|
||||||
. preg_replace('~\@{6,}~', '@@@@@@',
|
$output = '<pre class="pluginoutput">' . preg_replace(
|
||||||
|
self::$txtPatterns,
|
||||||
|
self::$txtReplacements,
|
||||||
$this->view->escape($output)
|
$this->view->escape($output)
|
||||||
) . '</pre>';
|
) . '</pre>';
|
||||||
}
|
}
|
||||||
@ -55,7 +65,7 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
|
|||||||
parse_str($m[1], $params);
|
parse_str($m[1], $params);
|
||||||
if (isset($params['host'])) {
|
if (isset($params['host'])) {
|
||||||
$tag->setAttribute('href', $this->view->baseUrl(
|
$tag->setAttribute('href', $this->view->baseUrl(
|
||||||
'/monitoring/detail/show?host=' . urlencode($params['host']
|
'/monitoring/host/show?host=' . urlencode($params['host']
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user