[icinga-checkins] icinga.org: icinga-web/master: * Configurable app name (fixes #1648)

git at icinga.org git at icinga.org
Tue Aug 23 12:31:48 CEST 2011


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Aug 23 12:30:52 2011 +0200

* Configurable app name (fixes #1648)

---

 app/config/settings.xml.in                         |    2 +-
 app/modules/AppKit/config/module.xml.in            |   21 ++++++++++++++++++
 .../Widgets/SquishLoaderSuccessView.class.php      |   23 +++++++++++++++++--
 app/modules/Cronks/lib/js/CronkTabpanel.js         |    2 +-
 .../Cronks/templates/System/PortalHelloSuccess.php |    2 +-
 configure                                          |   15 +++++++++++++
 configure.ac                                       |    8 +++++++
 7 files changed, 67 insertions(+), 6 deletions(-)

diff --git a/app/config/settings.xml.in b/app/config/settings.xml.in
index d8f551b..cb425d0 100755
--- a/app/config/settings.xml.in
+++ b/app/config/settings.xml.in
@@ -36,7 +36,7 @@
 		</system_actions>
 
 		<settings>
-			<setting name="app_name">icinga</setting>
+			<setting name="app_name">@app_name@</setting>
 
 			<setting name="available">true</setting>
 			
diff --git a/app/modules/AppKit/config/module.xml.in b/app/modules/AppKit/config/module.xml.in
index 3eb5953..330ef65 100755
--- a/app/modules/AppKit/config/module.xml.in
+++ b/app/modules/AppKit/config/module.xml.in
@@ -42,6 +42,27 @@
                     <ae:parameter name="org.icinga.autoRefresh">true</ae:parameter>
                     <ae:parameter name="org.icinga.status.refreshTime">60</ae:parameter>
                 </setting>
+
+                <!--
+                    Mapping between AgaviConfig and AppKit.util.Config
+                -->
+                <setting name="js_config_mapping">
+                    <ae:parameter name="path">org.icinga.appkit.web_path</ae:parameter>
+                    <ae:parameter name="image_path">org.icinga.appkit.image_path</ae:parameter>
+                    
+                    <!--
+                        Leaving source blank: target and source is just the same
+                    -->
+                    <ae:parameter name="core.app_name"></ae:parameter>
+                    <ae:parameter name="org.icinga.version.copyright"></ae:parameter>
+                    <ae:parameter name="org.icinga.version.homeref"></ae:parameter>
+                    <ae:parameter name="org.icinga.version.major"></ae:parameter>
+                    <ae:parameter name="org.icinga.version.minor"></ae:parameter>
+                    <ae:parameter name="org.icinga.version.patch"></ae:parameter>
+                    <ae:parameter name="org.icinga.version.extension"></ae:parameter>
+                    <ae:parameter name="org.icinga.version.releasedate"></ae:parameter>
+                    <ae:parameter name="org.icinga.version.name"></ae:parameter>
+                </setting>
                 
                 <!-- Ajax default request timeout (ms), 4 minutes == 240000 -->
                 <setting name="ajax.timeout">240000</setting>
diff --git a/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php b/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php
index 6006c93..3d7ddf2 100644
--- a/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php
+++ b/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php
@@ -6,10 +6,9 @@ class AppKit_Widgets_SquishLoaderSuccessView extends AppKitBaseView {
         if ($this->getAttribute('errors', false)) {
             return "throw '". join(", ", $this->getAttribute('errors')). "';";
         } else {
+            
             $content = $this->getAttribute('content');
-
-            $content .= 'AppKit.util.Config.add(\'path\', \''. AgaviConfig::get('org.icinga.appkit.web_path'). '\');'. chr(10);
-            $content .= 'AppKit.util.Config.add(\'image_path\', \''. AgaviConfig::get('org.icinga.appkit.image_path'). '\');'. chr(10);
+            $this->copyConfigToJavascript($content);
             
             $etag = $this->getAttribute("etag",rand());
             
@@ -22,6 +21,8 @@ class AppKit_Widgets_SquishLoaderSuccessView extends AppKitBaseView {
                 $this->getResponse()->setHttpStatusCode("304");
                 return "";
             }
+            
+
 
             return $content;
         }
@@ -36,5 +37,21 @@ class AppKit_Widgets_SquishLoaderSuccessView extends AppKitBaseView {
             return $content;
         }
     }
+    
+    /**
+     * Mapping configuration items from AgaviConfig to JS AppKit.util.Config
+     * @param string $content 
+     */
+    private function copyConfigToJavascript(&$content) {
+        $map = AgaviConfig::get('modules.appkit.js_config_mapping', array ());
+        if (count($map)) {
+            
+            foreach ($map as $target=>$source) {
+                $val = AgaviConfig::get($source ? $source : $target, null);
+                $content .= 'AppKit.util.Config.add('. json_encode($target). ', '. json_encode($val). ');'. chr(10);
+            }
+            
+        }
+    }
 
 }
diff --git a/app/modules/Cronks/lib/js/CronkTabpanel.js b/app/modules/Cronks/lib/js/CronkTabpanel.js
index 3a4793c..cbb02b8 100755
--- a/app/modules/Cronks/lib/js/CronkTabpanel.js
+++ b/app/modules/Cronks/lib/js/CronkTabpanel.js
@@ -121,7 +121,7 @@ Ext.extend(Cronk.util.Tabpanel, Ext.ux.panel.DDTabPanel, {
 	listeners: {
 		tabchange: function(tab) {
 			var aTab = tab.getActiveTab();	
-			document.title = "Icinga - "+aTab.title;
+			document.title = String.format('{0} - {1}', AppKit.util.Config.get('core.app_name'), aTab.title);
 		}
 	}
 });
diff --git a/app/modules/Cronks/templates/System/PortalHelloSuccess.php b/app/modules/Cronks/templates/System/PortalHelloSuccess.php
index d7e8586..21f32ea 100755
--- a/app/modules/Cronks/templates/System/PortalHelloSuccess.php
+++ b/app/modules/Cronks/templates/System/PortalHelloSuccess.php
@@ -5,7 +5,7 @@
 ?>
 <div style="margin: 10px auto; padding: 10px 10px;">
 
-	<h1>Welcome to Icinga (<?php echo $version_string; ?>)</h1>
+	<h1>Welcome to <?php echo AgaviConfig::get('core.app_name'); ?> (<?php echo $version_string; ?>)</h1>
 	
 	<p>Feel free to poke around and don't forget to visit the project homepage 	to post bug advisories or feature requests.</p>
 	
diff --git a/configure b/configure
index 27ee880..92f3fc2 100755
--- a/configure
+++ b/configure
@@ -594,6 +594,7 @@ web_absolute_path
 web_path
 web_group
 web_user
+app_name
 PHPCS
 PHPUNIT
 PHING
@@ -650,6 +651,7 @@ SHELL'
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
+with_app_name
 with_web_user
 with_web_group
 with_web_path
@@ -1297,6 +1299,7 @@ if test -n "$ac_init_help"; then
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-app-name=NAME    Application name (default Icinga)
   --with-web-user=USER    username for web writable files (default www-data)
   --with-web-group=GROUP  group for web writable files (default www-data)
   --with-web-path=PATH    web sub path (default /icinga-web)
@@ -2221,6 +2224,17 @@ fi
 
 # Define install options
 
+# Meta option
+
+# Check whether --with-app_name was given.
+if test "${with_app_name+set}" = set; then :
+  withval=$with_app_name; app_name=$withval
+else
+  app_name=Icinga
+
+fi
+
+
 # Users for webfiles
 
 # Check whether --with-web_user was given.
@@ -2740,6 +2754,7 @@ fi
 
 
 
+
 ac_config_files="$ac_config_files Makefile lib/Makefile pub/Makefile etc/Makefile bin/Makefile doc/Makefile app/Makefile etc/sitecfg/Makefile app/config/databases.xml app/config/icinga.xml app/config/logging.xml app/config/settings.xml app/config/translation.xml app/modules/Api/config/access.xml app/modules/AppKit/config/module.xml app/modules/AppKit/config/auth.xml app/modules/Cronks/config/module.xml etc/build.properties tests/phpunit/test.properties etc/apache2/icinga-web.conf bin/clearcache.sh pub/.htaccess pub/soap/.htaccess"
 
 
diff --git a/configure.ac b/configure.ac
index ab3ce60..00dfbb0 100755
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,13 @@ ACICINGA_CHECK_BIN([PHING], [phing])
 
 # Define install options
 
+# Meta option
+AC_ARG_WITH([app_name],
+	AS_HELP_STRING([--with-app-name=NAME], [Application name (default Icinga)]),
+	app_name=$withval,
+	app_name=Icinga
+)
+
 # Users for webfiles
 AC_ARG_WITH([web_user],
 	AS_HELP_STRING([--with-web-user=USER], [username for web writable files (default www-data)]),
@@ -261,6 +268,7 @@ CFLAGS=""
 ACICINGA_DEVEL_MODE()
 
 # Substitutions
+AC_SUBST(app_name)
 AC_SUBST(web_user)
 AC_SUBST(web_group)
 AC_SUBST(web_path)





More information about the icinga-checkins mailing list