[icinga-checkins] icinga.org: icinga-web/jmosshammer/default: Changes for console-context compatibility

git at icinga.org git at icinga.org
Tue Apr 6 13:03:51 CEST 2010


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

Author: jmosshammer <jmosshammer at ws-jmosshammer.(none)>
Date:   Tue Apr  6 13:03:18 2010 +0200

Changes for console-context compatibility

---

 app/config/factories.xml                         |   10 +++++-
 app/config/output_types.xml                      |   27 +++------------
 bin/console.php                                  |   33 +++++++++++++++++++
 lib/appkit/AppKit.class.php                      |    8 +++-
 lib/appkit/database/models/.gitignore            |    3 ++
 lib/appkit/event/AppKitEventDispatcher.class.php |    5 +++
 lib/appkit/js/SessionProvider.js                 |   38 ++++++++++++++++++++++
 lib/appkit/js/ext/SessionProvider.js             |   38 ++++++++++++++++++++++
 8 files changed, 138 insertions(+), 24 deletions(-)

diff --git a/app/config/factories.xml b/app/config/factories.xml
index 208da0b..2797c4b 100755
--- a/app/config/factories.xml
+++ b/app/config/factories.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ae:configurations xmlns:ae="http://agavi.org/agavi/config/global/envelope/1.0" xmlns="http://agavi.org/agavi/config/parts/factories/1.0">
 	
-	<ae:configuration>
+	<ae:configuration >
 		
 		<controller class="AgaviController" />
 		
@@ -60,4 +60,12 @@
 		
 	</ae:configuration>
 	
+	<ae:configuration context="console">
+		<request class="AgaviConsoleRequest" />
+		<response class="AgaviConsoleResponse" />
+		<routing class="AgaviConsoleRouting" />
+		<user class="AppKitSecurityUser" />
+		<logger_manager class="AppKitLoggerManager" />
+	</ae:configuration>
+	
 </ae:configurations>
\ No newline at end of file
diff --git a/app/config/output_types.xml b/app/config/output_types.xml
index be849da..8dadc65 100644
--- a/app/config/output_types.xml
+++ b/app/config/output_types.xml
@@ -102,27 +102,6 @@
 					<parameter name="Content-Type">text/javascript; charset=UTF-8</parameter>
 					<!-- <parameter name="Content-Type">text/plain; charset=UTF-8</parameter> -->
 				</parameter>
-				
-				<renderers default="php">
-					<renderer name="php" class="AgaviPhpRenderer">
-						<parameter name="assigns">
-							<parameter name="routing">ro</parameter>
-							<parameter name="request">rq</parameter>
-							<parameter name="controller">ct</parameter>
-							<parameter name="user">us</parameter>
-							<parameter name="translation_manager">tm</parameter>
-							<parameter name="request_data">rd</parameter>
-						</parameter>
-						<!-- this changes the name of the variable with all template attributes from the default $template to $t -->
-						<parameter name="var_name">t</parameter>
-					</renderer>
-				</renderers>
-				
-				<layouts default="simple">
-					<layout name="simple">
-						<layer name="content" />
-					</layout>
-				</layouts>
 			</output_type>
 			
 			<output_type name="ajax">
@@ -187,4 +166,10 @@
 		
 	</configuration>
 	
+	<configuration context="console">
+		<output_types default="console">
+			<output_type name="console" />
+		</output_types>
+	</configuration>
+	
 </configurations>
\ No newline at end of file
diff --git a/bin/console.php b/bin/console.php
new file mode 100644
index 0000000..d42065f
--- /dev/null
+++ b/bin/console.php
@@ -0,0 +1,33 @@
+<?php
+
+error_reporting(E_ALL);
+
+// +---------------------------------------------------------------------------+
+// | An absolute filesystem path to the agavi/agavi.php script.                |
+// +---------------------------------------------------------------------------+
+require(dirname(__FILE__) . '/../lib/agavi/src/agavi.php');
+
+// +---------------------------------------------------------------------------+
+// | An absolute filesystem path to our app/config.php script.                 |
+// +---------------------------------------------------------------------------+
+require(dirname(__FILE__) . '/../app/config.php');
+
+// +---------------------------------------------------------------------------+
+// | Initialize the framework. You may pass an environment name to this method.|
+// | By default the 'development' environment sets Agavi into a debug mode.    |
+// | In debug mode among other things the cache is cleaned on every request.   |
+// +---------------------------------------------------------------------------+
+// Setting the running context to web ...
+
+AgaviConfig::set('core.default_context', 'console');
+Agavi::bootstrap('development');
+AppKit::bootstrap();
+
+
+
+// +---------------------------------------------------------------------------+
+// | Call the controller's dispatch method on the default context              |
+// +---------------------------------------------------------------------------+
+AgaviContext::getInstance('console')->getController()->dispatch();
+
+?>
diff --git a/lib/appkit/AppKit.class.php b/lib/appkit/AppKit.class.php
index 177d9b1..a42d6f0 100644
--- a/lib/appkit/AppKit.class.php
+++ b/lib/appkit/AppKit.class.php
@@ -212,10 +212,14 @@ class AppKit {
 	 */
 	private static function initAutoSettings() {
 		// Try to set the web path to correct urls within the frontend
-		if (AgaviConfig::get('de.icinga.appkit.web_path') == null) {
-			AgaviConfig::set('de.icinga.appkit.web_path', AppKitStringUtil::extractWebPath(), true, true);
+		if(AgaviConfig::get('core.default_context') =='web') {
+			// Try to set the web path to correct urls within the frontend
+			if (AgaviConfig::get('de.icinga.appkit.web_path') == null) {
+				AgaviConfig::set('de.icinga.appkit.web_path', AppKitStringUtil::extractWebPath(), true, true);
+			}
 		}
 		
+		
 		// Version
 		$version = sprintf(
 			'%s/v%d.%d.%d-%s',
diff --git a/lib/appkit/database/models/.gitignore b/lib/appkit/database/models/.gitignore
new file mode 100644
index 0000000..4446c6c
--- /dev/null
+++ b/lib/appkit/database/models/.gitignore
@@ -0,0 +1,3 @@
+lib/appkit/database/Hm*
+lib/appkit/database/BaseHm*
+
diff --git a/lib/appkit/event/AppKitEventDispatcher.class.php b/lib/appkit/event/AppKitEventDispatcher.class.php
index ee8a304..c9fb143 100755
--- a/lib/appkit/event/AppKitEventDispatcher.class.php
+++ b/lib/appkit/event/AppKitEventDispatcher.class.php
@@ -5,7 +5,11 @@ class AppKitEventDispatcher extends AppKitSingleton {
 	const ASTERISK		= '*';
 	
 	public static function registerEventClasses(array $events) {
+		$currentContext = AgaviContext::getInstance()->getName();
 		foreach ($events as $name=>$event) {
+			if($event['context'] != $currentContext) 
+				continue; 
+				
 			if ($event['event'] && $event['class']) {
 				
 				if (!array_key_exists('parameter', $events)) {
@@ -22,6 +26,7 @@ class AppKitEventDispatcher extends AppKitSingleton {
 		return true;
 	}
 	
+	
 	/**
 	 * 
 	 * @return AppKitEventDispatcher
diff --git a/lib/appkit/js/SessionProvider.js b/lib/appkit/js/SessionProvider.js
new file mode 100755
index 0000000..575cf52
--- /dev/null
+++ b/lib/appkit/js/SessionProvider.js
@@ -0,0 +1,38 @@
+/*!
+ * Ext JS Library 3.0.0
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing at extjs.com
+ * http://www.extjs.com/license
+ */
+Ext.state.SessionProvider = Ext.extend(Ext.state.CookieProvider, {
+    readCookies : function() {
+        if(this.state){
+        	
+//        	console.log("--- READ STATE START ---");
+        	
+//        	console.log(this.state);
+        	
+            for(var k in this.state){
+                if(typeof this.state[k] == 'string'){
+//                	console.log(this.state[k])
+                    this.state[k] = this.decodeValue(this.state[k]);
+                }
+            }
+            
+//            console.log("--- READ STATE STOP ---");
+            
+        }
+        
+        
+        return Ext.apply(this.state || {}, Ext.state.SessionProvider.superclass.readCookies.call(this));
+    },
+
+	encodeValue : function(v) {
+		return Ext.util.JSON.encode(v);
+	},
+	
+	decodeValue : function(v) {
+		return Ext.util.JSON.decode(v);
+	}
+
+});
\ No newline at end of file
diff --git a/lib/appkit/js/ext/SessionProvider.js b/lib/appkit/js/ext/SessionProvider.js
new file mode 100755
index 0000000..575cf52
--- /dev/null
+++ b/lib/appkit/js/ext/SessionProvider.js
@@ -0,0 +1,38 @@
+/*!
+ * Ext JS Library 3.0.0
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing at extjs.com
+ * http://www.extjs.com/license
+ */
+Ext.state.SessionProvider = Ext.extend(Ext.state.CookieProvider, {
+    readCookies : function() {
+        if(this.state){
+        	
+//        	console.log("--- READ STATE START ---");
+        	
+//        	console.log(this.state);
+        	
+            for(var k in this.state){
+                if(typeof this.state[k] == 'string'){
+//                	console.log(this.state[k])
+                    this.state[k] = this.decodeValue(this.state[k]);
+                }
+            }
+            
+//            console.log("--- READ STATE STOP ---");
+            
+        }
+        
+        
+        return Ext.apply(this.state || {}, Ext.state.SessionProvider.superclass.readCookies.call(this));
+    },
+
+	encodeValue : function(v) {
+		return Ext.util.JSON.encode(v);
+	},
+	
+	decodeValue : function(v) {
+		return Ext.util.JSON.decode(v);
+	}
+
+});
\ No newline at end of file





More information about the icinga-checkins mailing list