[icinga-checkins] icinga.org: icinga-web/r1.2: * Total view is now also available as XML

git at icinga.org git at icinga.org
Mon Sep 27 11:32:32 CEST 2010


Module: icinga-web
Branch: r1.2
Commit: eab9210876154c9305e5e0823201a1e093587ea7
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=eab9210876154c9305e5e0823201a1e093587ea7

Author: jmosshammer <jmosshammer at ws-jmosshammer.(none)>
Date:   Thu Sep 23 12:43:52 2010 +0200

* Total view is now also available as XML

---

 .../views/Icinga/ApiSearchSuccessView.class.php    |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/app/modules/Web/views/Icinga/ApiSearchSuccessView.class.php b/app/modules/Web/views/Icinga/ApiSearchSuccessView.class.php
index 7015bee..019a85d 100755
--- a/app/modules/Web/views/Icinga/ApiSearchSuccessView.class.php
+++ b/app/modules/Web/views/Icinga/ApiSearchSuccessView.class.php
@@ -10,8 +10,9 @@ class Web_Icinga_ApiSearchSuccessView extends IcingaWebBaseView
 	
 	public function executeJson(AgaviRequestDataHolder $rd) 
 	{
+		$count = $rd->getParameter("searchCount");
 		// just return the entities
-		if(!$rd->getParameter("withMeta",false))
+		if(!$rd->getParameter("withMeta",false) && !$count)
 			return json_encode($rd->getParameter("searchResult",null));
 		
 		// provide meta data for ExtJs stores
@@ -53,6 +54,7 @@ class Web_Icinga_ApiSearchSuccessView extends IcingaWebBaseView
 	public function executeXml(AgaviRequestDataHolder $rd) 
 	{
 		$results = $rd->getParameter("searchResult",null);
+		$count = $rd->getParameter("searchCount");
 		$DOM = new DOMDocument("1.0","UTF-8");
 		$root = $DOM->createElement("results");
 		$DOM->appendChild($root);
@@ -69,6 +71,12 @@ class Web_Icinga_ApiSearchSuccessView extends IcingaWebBaseView
 				$resultNode->appendChild($node);
 			}				
 		}
+		if($count) {
+			$count = array_values($count[0]);
+			$node = $DOM->createElement("total");
+			$node->nodeValue = $count[0];
+			$root->appendChild($node);
+		}
 		return $DOM->saveXML();
 	}
 





More information about the icinga-checkins mailing list