[icinga-checkins] icinga.org: icinga-web/jmosshammer/default: * Fixed context awareness bug in AppKitXIncludeConfigHandler

git at icinga.org git at icinga.org
Thu Aug 18 16:57:01 CEST 2011


Module: icinga-web
Branch: jmosshammer/default
Commit: 237841ae9c793aad5b9edbd618ae19b26e102022
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=237841ae9c793aad5b9edbd618ae19b26e102022

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Thu Aug 18 16:56:23 2011 +0200

* Fixed context awareness bug in AppKitXIncludeConfigHandler

---

 app/config/config_handlers.xml                     |    2 +-
 app/config/routing.xml                             |    2 +-
 .../config/AppKitXIncludeConfigHandler.class.php   |   21 ++++++++++++-------
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/app/config/config_handlers.xml b/app/config/config_handlers.xml
index fd8e9e9..afd5a09 100755
--- a/app/config/config_handlers.xml
+++ b/app/config/config_handlers.xml
@@ -10,7 +10,7 @@
 	                	You can use __CONTEXT__ to expand the current context
 	                -->
                     <ae:parameter name="query"><![CDATA[//ae:configurations/ae:configuration[@context='__CONTEXT__']/routing:routes/routing:route[@name='modules']]]></ae:parameter>
-                    <ae:parameter name="pointer"><![CDATA[xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(r=http://icinga.org/appkit/config/parts/routing/1.0) xpointer(//ae:configurations/ae:configuration/r:routes/node())]]></ae:parameter>
+                    <ae:parameter name="pointer"><![CDATA[xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(r=http://icinga.org/appkit/config/parts/routing/1.0) xpointer(//ae:configurations/ae:configuration[@context='__CONTEXT__']/r:routes/node())]]></ae:parameter>
                     <ae:parameter name="includeNS">routing</ae:parameter>
                     <!--
                     	Handler is needed here, because we do not use the default
diff --git a/app/config/routing.xml b/app/config/routing.xml
index b6a7447..e569715 100755
--- a/app/config/routing.xml
+++ b/app/config/routing.xml
@@ -63,7 +63,7 @@
 	
 	<ae:configuration context="console">
 		<routes>
-			<route name="modules" pattern="^/modules">	
+			<route name="modules" pattern="">	
 				<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="routing.modules.xml" xpointer="xmlns(r=http://icinga.org/appkit/config/parts/routing/1.0) xpointer(//r:module_routes/r:configuration[@context='console']/node())">
 						<xi:fallback></xi:fallback>
 				</xi:include>
diff --git a/app/modules/AppKit/lib/config/AppKitXIncludeConfigHandler.class.php b/app/modules/AppKit/lib/config/AppKitXIncludeConfigHandler.class.php
index fa15fcc..b923fac 100644
--- a/app/modules/AppKit/lib/config/AppKitXIncludeConfigHandler.class.php
+++ b/app/modules/AppKit/lib/config/AppKitXIncludeConfigHandler.class.php
@@ -22,7 +22,7 @@ class AppKitXIncludeConfigHandler extends AgaviXmlConfigHandler {
      * @see AgaviIXmlConfigHandler::execute()
      */
     public function execute(AgaviXmlConfigDomDocument $document) {
-
+        
         $config = basename($document->baseURI, '.xml');
 
         $refClass = $this->getConfigHandlerClass($config);
@@ -50,7 +50,7 @@ class AppKitXIncludeConfigHandler extends AgaviXmlConfigHandler {
         $query = $this->getQuery();
 
         $pointers = $this->getPointers();
-
+        
         foreach($modules as $module) {
             $includes = AgaviConfig::get(
                             sprintf(
@@ -59,13 +59,13 @@ class AppKitXIncludeConfigHandler extends AgaviXmlConfigHandler {
                                 $this->getParameter('includeNS', $config)
                             ),
                             false
-                        );
+                       );
             
             if ($includes) {
                 
                 if(isset($includes["folder"]))
                     $includes = $this->resolveFolder($includes); 
-                
+              
                 foreach($pointers as $pointer) {
                     AppKitXmlUtil::includeXmlFilesToTarget(
                         $document,
@@ -73,16 +73,17 @@ class AppKitXIncludeConfigHandler extends AgaviXmlConfigHandler {
                         $pointer,
                         $includes
                     );
-
+             
                     try {
                         $document->xinclude();
                     } catch (Exception $e) {
-
+                        
                     }
+                   
                 }
             }
         }
-
+      
         // The confighandler behind this included definition
         return $configHandler->execute($document);
     }
@@ -177,7 +178,11 @@ class AppKitXIncludeConfigHandler extends AgaviXmlConfigHandler {
         if (!is_array($pointers)) {
             $pointers = array($pointers);
         }
-
+        foreach($pointers as &$pointer) {
+            if (strpos($pointer, '__CONTEXT__') !== false) {
+                $pointer = str_replace('__CONTEXT__', AgaviConfig::get('core.default_context', 'web'), $pointer);
+            }
+        }
         return $pointers;
     }
 





More information about the icinga-checkins mailing list