[icinga-checkins] icinga.org: icinga-web/master: * modlarized schedules xml, created SubSettingConfigHandler that allows to create own setting-xmls

git at icinga.org git at icinga.org
Sat Aug 20 12:53:39 CEST 2011


Module: icinga-web
Branch: master
Commit: 04041d094703affe486eba09cb061639889fc03e
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=04041d094703affe486eba09cb061639889fc03e

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Thu Aug 18 13:08:47 2011 +0200

* modlarized schedules xml, created SubSettingConfigHandler that allows to create own setting-xmls

---

 app/config/config_handlers.xml                     |   15 +++++-
 app/config/icinga.xml.in                           |    6 ---
 app/config/schedules.xml                           |    9 +++-
 app/modules/AppKit/config/autoload.xml             |    7 ++-
 .../config/AppKitSubSettingConfigHandler.class.php |   46 ++++++++++++++++++++
 5 files changed, 68 insertions(+), 15 deletions(-)

diff --git a/app/config/config_handlers.xml b/app/config/config_handlers.xml
index fcd4065..fd8e9e9 100755
--- a/app/config/config_handlers.xml
+++ b/app/config/config_handlers.xml
@@ -87,11 +87,20 @@
                 </ae:parameters>
 
 				<ae:parameter name="handler">AppKitMenuConfigHandler</ae:parameter>
-                <validation>%core.module_dir%/AppKit/lib/xml/xsd/menu.xsd</validation>
-           
+                <validation>%core.module_dir%/AppKit/lib/xml/xsd/menu.xsd</validation>           
             </handler>
+            
+            <handler pattern="%core.config_dir%/schedules.xml" class="AppKitXIncludeConfigHandler">
+                 
+                    <ae:parameter name="query"><![CDATA[//settings:settings]]></ae:parameter>
+                    <ae:parameter name="pointer"><![CDATA[xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(c=http://agavi.org/agavi/config/parts/settings/1.0) xpointer(//ae:configurations/ae:configuration/c:settings/node())]]></ae:parameter>
+            	    
+                
 
-           
+				<ae:parameter name="handler">AppKitSubSettingConfigHandler</ae:parameter>
+    
+            </handler>
+          
         </handlers>
     </ae:configuration>
 </ae:configurations>
diff --git a/app/config/icinga.xml.in b/app/config/icinga.xml.in
index 117e58a..a9061ee 100755
--- a/app/config/icinga.xml.in
+++ b/app/config/icinga.xml.in
@@ -53,10 +53,4 @@
 	<setting name="version.releasedate"><![CDATA[@RELEASE_DATE@]]></setting>
 	<setting name="version.name">icinga-web</setting>
 
-	<!--
-		Early initialize modules
-		* This controls which agavi modules are initialized at start
-		* needed for classes, javascript, ...
-	-->
-	<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="schedules.xml"/>
 </settings>
diff --git a/app/config/schedules.xml b/app/config/schedules.xml
index 37973ab..c541773 100755
--- a/app/config/schedules.xml
+++ b/app/config/schedules.xml
@@ -1,4 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<setting xmlns="http://agavi.org/agavi/1.0/config" name="schedules">
-  
-</setting>
+<ae:configurations xmlns:ae="http://agavi.org/agavi/config/global/envelope/1.0" xmlns="http://agavi.org/agavi/config/parts/settings/1.0" >
+    <ae:configuration>
+        <settings prefix="org.icinga.">
+        </settings>
+    </ae:configuration>
+</ae:configurations>
diff --git a/app/modules/AppKit/config/autoload.xml b/app/modules/AppKit/config/autoload.xml
index c9e5f6a..3c83167 100755
--- a/app/modules/AppKit/config/autoload.xml
+++ b/app/modules/AppKit/config/autoload.xml
@@ -59,9 +59,10 @@
 		<autoload name="AppKitUriValidator">%core.module_dir%/AppKit/lib/validator/AppKitUriValidator.class.php</autoload>
 		
 		<autoload name="AppKitXmlUtil">%core.module_dir%/AppKit/lib/util/AppKitXmlUtil.class.php</autoload>
-	        <autoload name="AppKitXIncludeConfigHandler">%core.module_dir%/AppKit/lib/config/AppKitXIncludeConfigHandler.class.php</autoload>
-	        <autoload name="AppKitResourceConfigHandler">%core.module_dir%/AppKit/lib/config/AppKitResourceConfigHandler.class.php</autoload>
-	        <autoload name="AppKitIteratorUtil">%core.module_dir%/AppKit/lib/util/AppKitIteratorUtil.class.php</autoload>
+	    <autoload name="AppKitXIncludeConfigHandler">%core.module_dir%/AppKit/lib/config/AppKitXIncludeConfigHandler.class.php</autoload> 
+	    <autoload name="AppKitSubSettingConfigHandler">%core.module_dir%/AppKit/lib/config/AppKitSubSettingConfigHandler.class.php</autoload>
+	    <autoload name="AppKitResourceConfigHandler">%core.module_dir%/AppKit/lib/config/AppKitResourceConfigHandler.class.php</autoload>
+	    <autoload name="AppKitIteratorUtil">%core.module_dir%/AppKit/lib/util/AppKitIteratorUtil.class.php</autoload>
 	
 		<!-- Agavi config file handler -->
 		<autoload name="AppKitRoutingConfigHandler">%core.module_dir%/AppKit/lib/config/AppKitRoutingConfigHandler.class.php</autoload>
diff --git a/app/modules/AppKit/lib/config/AppKitSubSettingConfigHandler.class.php b/app/modules/AppKit/lib/config/AppKitSubSettingConfigHandler.class.php
new file mode 100644
index 0000000..f397138
--- /dev/null
+++ b/app/modules/AppKit/lib/config/AppKitSubSettingConfigHandler.class.php
@@ -0,0 +1,46 @@
+<?php
+/**
+* Allows to import configurations in the same structure like the settings.xml
+* Config settigns will be available through the AgaviConfig class
+*
+* @author Jannis Moßhammer <jannis.mosshammer at netways.de> 
+**/
+class AppKitSubSettingConfigHandler extends AgaviXmlConfigHandler
+{
+	const XML_NAMESPACE = 'http://agavi.org/agavi/config/parts/settings/1.0';
+	
+    public function execute(AgaviXmlConfigDomDocument $document)
+	{
+        $data = array();
+        $prefix = "org.icinga.";
+       
+		$document->setDefaultNamespace(self::XML_NAMESPACE, 'settings');
+       
+		foreach($document->getConfigurationElements() as $cfg) {
+         
+            foreach($cfg->get('settings') as $setting) {
+                $localPrefix = $prefix;
+                 
+                // let's see if this buddy has a <settings> parent with valuable information
+                if($setting->parentNode->localName == 'settings') {
+                    if($setting->parentNode->hasAttribute('prefix')) {
+                        $localPrefix = $setting->parentNode->getAttribute('prefix');
+                    }
+                }
+                    
+                $settingName = $localPrefix . $setting->getAttribute('name');
+
+                if($setting->hasAgaviParameters()) {
+
+                    $data[$settingName] = $setting->getAgaviParameters();
+                } else {
+                    $data[$settingName] = AgaviToolkit::literalize($setting->getValue());
+                }
+            }
+          
+        }
+		$code = 'AgaviConfig::fromArray(' . var_export($data, true) . ');';
+        return $this->generate($code, $document->documentURI);
+
+    }
+}





More information about the icinga-checkins mailing list