[icinga-checkins] icinga.org: icinga-web/mhein/testing: * Fixed AppKitResourceConfigHandler using values of directory iterator' s array instead of keys

git at icinga.org git at icinga.org
Tue Aug 2 10:58:52 CEST 2011


Module: icinga-web
Branch: mhein/testing
Commit: ededf0ecb72e978e79845931e98a85fe66977936
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=ededf0ecb72e978e79845931e98a85fe66977936

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Tue Jul 26 14:18:46 2011 +0200

* Fixed AppKitResourceConfigHandler using values of directory iterator's array instead of keys
* Added try catch to missing xincludes
* Allowed array syntax for pointer definition of AppKitXIncludeConfigHandler since Agavi is not capable of multiple config handlers for one file (which I assumed)
* Dropped second css.xml handler and updated the remaining one

refs #1548

---

 app/config/config_handlers.xml                     |   17 +++---------
 .../config/AppKitResourceConfigHandler.class.php   |    4 +-
 .../config/AppKitXIncludeConfigHandler.class.php   |   27 ++++++++++++++------
 3 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/app/config/config_handlers.xml b/app/config/config_handlers.xml
index adf5b30..6d3e471 100755
--- a/app/config/config_handlers.xml
+++ b/app/config/config_handlers.xml
@@ -49,25 +49,16 @@
              <handler pattern="%core.config_dir%/css.xml" class="AppKitXIncludeConfigHandler">
                 <ae:parameters>
                     <ae:parameter name="query"><![CDATA[//ae:configurations/ae:configuration]]></ae:parameter>
-                    <ae:parameter name="pointer"><![CDATA[xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(r=http://icinga.org/icinga/config/global/resource/1.0) xpointer(//ae:configurations/ae:configuration/r:css)]]></ae:parameter>
+                    <ae:parameter name="pointer">
+                        <ae:parameter><![CDATA[xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(r=http://icinga.org/icinga/config/global/resource/1.0) xpointer(//ae:configurations/ae:configuration/r:css_import)]]></ae:parameter>
+                        <ae:parameter><![CDATA[xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(r=http://icinga.org/icinga/config/global/resource/1.0) xpointer(//ae:configurations/ae:configuration/r:css)]]></ae:parameter>
+                    </ae:parameter>
                     <ae:parameter name="handler">AppKitResourceConfigHandler</ae:parameter>
                 </ae:parameters>
 
                 <validation>%core.module_dir%/AppKit/lib/config/xsd/resource.xsd</validation>
                 <transformation>%core.module_dir%/AppKit/lib/config/xsl/resource.xsl</transformation>
             </handler>
-            
-             <handler pattern="%core.config_dir%/css.xml" class="AppKitXIncludeConfigHandler">
-                <ae:parameters>
-                    <ae:parameter name="query"><![CDATA[//ae:configurations/ae:configuration]]></ae:parameter>
-                    <ae:parameter name="pointer"><![CDATA[xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(r=http://icinga.org/icinga/config/global/resource/1.0) xpointer(//ae:configurations/ae:configuration/r:css_import)]]></ae:parameter>
-                    <ae:parameter name="handler">AppKitResourceConfigHandler</ae:parameter>
-                    <ae:parameter name="includeNS">css</ae:parameter>
-                </ae:parameters>
-
-                <validation>%core.module_dir%/AppKit/lib/config/xsd/resource.xsd</validation>
-                <transformation>%core.module_dir%/AppKit/lib/config/xsl/resource.xsl</transformation>
-            </handler>
         </handlers>
     </ae:configuration>
 </ae:configurations>
diff --git a/app/modules/AppKit/lib/config/AppKitResourceConfigHandler.class.php b/app/modules/AppKit/lib/config/AppKitResourceConfigHandler.class.php
index f22d632..1a3754c 100644
--- a/app/modules/AppKit/lib/config/AppKitResourceConfigHandler.class.php
+++ b/app/modules/AppKit/lib/config/AppKitResourceConfigHandler.class.php
@@ -41,12 +41,12 @@ class AppKitResourceConfigHandler extends AgaviXmlConfigHandler {
                 if(is_dir($r)) {
                     $_resources = array_merge(
                         $_resources,
-                        iterator_to_array(
+                        array_keys(iterator_to_array(
                             AppKitIteratorUtil::RegexRecursiveDirectoryIterator(
                                 $r,
                                 sprintf('/\%s/i', $sfx)
                             )
-                        )
+                        ))
                     );
                 } else {
                     $_resources[] = $r;
diff --git a/app/modules/AppKit/lib/config/AppKitXIncludeConfigHandler.class.php b/app/modules/AppKit/lib/config/AppKitXIncludeConfigHandler.class.php
index 4182ca7..0cca50c 100644
--- a/app/modules/AppKit/lib/config/AppKitXIncludeConfigHandler.class.php
+++ b/app/modules/AppKit/lib/config/AppKitXIncludeConfigHandler.class.php
@@ -68,17 +68,28 @@ class AppKitXIncludeConfigHandler extends AgaviXmlConfigHandler {
             );
 
             if($includes) {
-                AppKitXmlUtil::includeXmlFilesToTarget(
-                    $document,
-                    $this->getParameter('query'),
-                    $this->getParameter('pointer'),
-                    $includes
-                );
+                $pointers = $this->getParameter('pointer');
+                if(!is_array($pointers)) {
+                    $pointers = array($pointers);
+                }
+
+                foreach($pointers as $pointer) {
+                    AppKitXmlUtil::includeXmlFilesToTarget(
+                        $document,
+                        $this->getParameter('query'),
+                        $pointer,
+                        $includes
+                    );
+
+                    try {
+                        $document->xinclude();
+                    } catch(Exception $e) {
+
+                    }
+                }
             }
         }
 
-        $document->xinclude();
-
         return $configHandler->execute($document);
     }
 





More information about the icinga-checkins mailing list