[icinga-checkins] icinga.org: icinga-web/cdoebler/default: * static content: added use of singleton methods for post processing
git at icinga.org
git at icinga.org
Fri Jan 22 10:27:53 CET 2010
Module: icinga-web
Branch: cdoebler/default
Commit: 28f61e161d560aea03f4b81b761fbb416234a95d
URL: https://git.icinga.org/?p=icinga-web.git;a=commit;h=28f61e161d560aea03f4b81b761fbb416234a95d
Author: Christian Doebler <christian.doebler at netways.de>
Date: Fri Jan 22 10:27:08 2010 +0100
* static content: added use of singleton methods for post processing
---
.../models/System/StaticContentModel.class.php | 14 ++++++++++++--
res/xml/icinga-tactical-overview-template.xml | 4 ++--
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/app/modules/Cronks/models/System/StaticContentModel.class.php b/app/modules/Cronks/models/System/StaticContentModel.class.php
index d6ed153..7e9bc90 100644
--- a/app/modules/Cronks/models/System/StaticContentModel.class.php
+++ b/app/modules/Cronks/models/System/StaticContentModel.class.php
@@ -264,7 +264,7 @@ class Cronks_System_StaticContentModel extends ICINGACronksBaseModel
$content = $this->substituteRepeatingTemplateVariables($content, $templateVariables);
// fetch remaining variables from template and call substitution routine
- $variablePattern = '/\${([A-Za-z0-9_\-]+):([A-Z_]+)}/s';
+ $variablePattern = '/\${([A-Za-z0-9_\-]+):([A-Z_]+)(:.*)?}/s';
preg_match_all($variablePattern, $content, $templateVariables);
$content = $this->substituteTemplateVariables($content, $templateVariables);
@@ -297,7 +297,7 @@ class Cronks_System_StaticContentModel extends ICINGACronksBaseModel
for ($y = 0; $y < $numSubTemplates; $y++) {
$subContentTemplate = $templateSubVariables[1][$y];
- $variablePattern = '/\${([A-Za-z0-9_\-]+):([A-Z_]+)}/s';
+ $variablePattern = '/\${([A-Za-z0-9_\-]+):([A-Z_]+)(:.*)?}/s';
preg_match_all($variablePattern, $subContentTemplate, $subTemplateSubVariables);
$numSubTemplateSubVariables = count($subTemplateSubVariables[0]);
@@ -336,6 +336,7 @@ class Cronks_System_StaticContentModel extends ICINGACronksBaseModel
for ($x = 0; $x < $numMatches; $x++) {
$id = $templateVariables[1][$x];
$column = $templateVariables[2][$x];
+ $outputWrapperFunction = $templateVariables[3][$x];
// determine template values and set them
$substitution = null;
@@ -352,6 +353,15 @@ class Cronks_System_StaticContentModel extends ICINGACronksBaseModel
);
}
+ // apply output wrapper
+ if (!empty($outputWrapperFunction)) {
+ $funcDef = explode(':', $outputWrapperFunction);
+ eval("\$funcInstance = $funcDef[1]::getInstance();");
+
+ $funcCall = str_replace('__VALUE__', $substitution, $funcDef[2]);
+ eval("\$substitution = \$funcInstance->$funcCall;");
+ }
+
$content = str_replace(
$templateVariables[0][$x],
$substitution,
diff --git a/res/xml/icinga-tactical-overview-template.xml b/res/xml/icinga-tactical-overview-template.xml
index 511a0bf..a894043 100644
--- a/res/xml/icinga-tactical-overview-template.xml
+++ b/res/xml/icinga-tactical-overview-template.xml
@@ -119,7 +119,7 @@
<id>HOST_NAMES</id>
<source_type>IcingaApi</source_type>
<target>IcingaApi::TARGET_HOST</target>
- <columns>HOST_NAME</columns>
+ <columns>HOST_NAME,HOST_STATE</columns>
</datasource>
</datasources>
@@ -166,7 +166,7 @@
<!--
${HOST_NAMES:repeat}
<br/>
- ${HOST_NAMES:HOST_NAME} |
+ ${HOST_NAMES:HOST_NAME} | ${HOST_NAMES:HOST_STATE:IcingaTemplateDisplayMonitoring:hostStatus(__VALUE__,new AgaviParameterHolder(),new AgaviParameterHolder())}
<br/>
${HOST_NAMES:repeat_end}
-->
More information about the icinga-checkins
mailing list