Add Horde_Registry#hasAjaxView() and load non-ajax applications in iframe.
authorJan Schneider <jan@horde.org>
Wed, 17 Feb 2010 22:14:09 +0000 (23:14 +0100)
committerJan Schneider <jan@horde.org>
Wed, 17 Feb 2010 22:14:26 +0000 (23:14 +0100)
framework/Core/lib/Horde/Registry.php
imp/lib/Application.php
kronolith/js/kronolith.js
kronolith/lib/Application.php
kronolith/lib/Kronolith.php
kronolith/templates/index/index.inc

index f723cf0..7c58e3a 100644 (file)
@@ -1294,7 +1294,28 @@ class Horde_Registry
 
         try {
             $api = $this->getApiInstance($app, 'application');
-            return $api->mobileView;
+            return !empty($api->mobileView);
+        } catch (Horde_Exception $e) {
+            return false;
+        }
+    }
+
+    /**
+     * Does the given application have an ajax view?
+     *
+     * @param string $app  The application to check.
+     *
+     * @return boolean  Whether app has an ajax view.
+     */
+    public function hasAjaxView($app = null)
+    {
+        if (empty($app)) {
+            $app = $this->getApp();
+        }
+
+        try {
+            $api = $this->getApiInstance($app, 'application');
+            return !empty($api->ajaxView);
         } catch (Horde_Exception $e) {
             return false;
         }
index 3e01609..259fd1c 100644 (file)
@@ -35,6 +35,13 @@ require_once HORDE_BASE . '/lib/core.php';
 class IMP_Application extends Horde_Registry_Application
 {
     /**
+     * Does this application support an ajax view?
+     *
+     * @var boolean
+     */
+    public $ajaxView = true;
+
+    /**
      * Does this application support a mobile view?
      *
      * @var boolean
index 1d5fda7..8e0710e 100644 (file)
@@ -434,6 +434,19 @@ KronolithCore = {
             this._addHistory(loc);
             this.view = 'iframe';
             break;
+
+        case 'app':
+            this.closeView('iframe');
+            var app = locParts.shift();
+            if (data) {
+                this.iframeContent(loc, data);
+            } else if (Kronolith.conf.app_urls[app]) {
+                this.iframeContent(loc, Kronolith.conf.app_urls[app]);
+            }
+            this.updateMinical(this.date);
+            this._addHistory(fullloc);
+            this.view = 'iframe';
+            break;
         }
     },
 
index 8ea37b8..188e2dd 100644 (file)
@@ -35,6 +35,13 @@ require_once HORDE_BASE . '/lib/core.php';
 class Kronolith_Application extends Horde_Registry_Application
 {
     /**
+     * Does this application support an ajax view?
+     *
+     * @var boolean
+     */
+    public $ajaxView = true;
+
+    /**
      * The application's version.
      *
      * @var string
index cd1047a..6c8ef01 100644 (file)
@@ -174,6 +174,13 @@ class Kronolith
         $kronolith_webroot = $registry->get('webroot');
         $horde_webroot = $registry->get('webroot', 'horde');
         $has_tasks = $GLOBALS['registry']->hasInterface('tasks');
+        $app_urls = array();
+        if (isset($GLOBALS['conf']['menu']['apps']) &&
+            is_array($GLOBALS['conf']['menu']['apps'])) {
+            foreach ($GLOBALS['conf']['menu']['apps'] as $app) {
+                $app_urls[$app] = (string) Horde::url($GLOBALS['registry']->getInitialPage($app), true);
+            }
+        }
 
         /* Variables used in core javascript files. */
         $code['conf'] = array(
@@ -183,6 +190,7 @@ class Kronolith
             'SESSION_ID' => defined('SID') ? SID : '',
             'user' => Horde_Auth::getAuth(),
             'prefs_url' => str_replace('&amp;', '&', Horde::getServiceLink('options', 'kronolith')),
+            'app_urls' => $app_urls,
             'name' => $registry->get('name'),
             'has_tasks' => $has_tasks,
             'is_ie6' => ($browser->isBrowser('msie') && ($browser->getMajor() < 7)),
index 73137c8..a4ea5d5 100644 (file)
@@ -7,9 +7,13 @@
     <?php if (count($GLOBALS['conf']['menu']['apps'])): ?>
     <div id="kronolithApplications">
       <ul>
-        <li class="kronolithApplicationSelected"><a href="" id="kronolithApplication-kronolith" title="<?php echo $GLOBALS['registry']->get('name') ?>"><img src="<?php echo $GLOBALS['registry']->get('icon') ?>" /> <?php echo $GLOBALS['registry']->get('name') ?></a></li>
+        <li class="kronolithApplicationSelected"><a href="#" id="kronolithApplication-kronolith" title="<?php echo $GLOBALS['registry']->get('name') ?>"><img src="<?php echo $GLOBALS['registry']->get('icon') ?>" /> <?php echo $GLOBALS['registry']->get('name') ?></a></li>
         <?php foreach ($GLOBALS['conf']['menu']['apps'] as $app): ?>
+        <?php if ($GLOBALS['registry']->hasAjaxView($app)): ?>
         <li><a href="<?php echo $GLOBALS['registry']->get('webroot', $app) ?>" id="kronolithApplication-<?php echo $app ?>" title="<?php echo $GLOBALS['registry']->get('name', $app) ?>"><img src="<?php echo $GLOBALS['registry']->get('icon', $app) ?>" /> <?php echo $GLOBALS['registry']->get('name', $app) ?></a></li>
+        <?php else: ?>
+        <li><a href="#" onclick="KronolithCore.go('app:<?php echo $app ?>')" id="kronolithApplication-<?php echo $app ?>" title="<?php echo $GLOBALS['registry']->get('name', $app) ?>"><img src="<?php echo $GLOBALS['registry']->get('icon', $app) ?>" /> <?php echo $GLOBALS['registry']->get('name', $app) ?></a></li>
+        <?php endif; ?>
         <?php endforeach; ?>
       </ul>
       <span class="kronolithSeparator">|</span>