Merge horde/Ajax into horde/Core.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Jul 2010 22:52:45 +0000 (16:52 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 16 Jul 2010 22:52:50 +0000 (16:52 -0600)
Ajax related code is so interrelated to core Horde code that it is
simply too much overhead to maintain as a separate package.

Add binders for Application file (Horde_Ajax) and Imple
(Horde_Ajax_Imple).

67 files changed:
ansel/gallery.php
ansel/lib/Ajax/Imple/EditCaption.php
ansel/lib/Ajax/Imple/EditFaces.php
ansel/lib/Ajax/Imple/Embed.php
ansel/lib/Ajax/Imple/GallerySlugCheck.php
ansel/lib/Ajax/Imple/ImageSaveGeotag.php
ansel/lib/Ajax/Imple/LocationAutoCompleter.php
ansel/lib/Ajax/Imple/TagActions.php
ansel/lib/Ajax/Imple/ToggleGalleryActions.php
ansel/lib/Ajax/Imple/ToggleOtherGalleries.php
ansel/lib/Ansel.php
ansel/lib/Tile/Image.php
ansel/lib/View/Image.php
ansel/lib/Widget/Actions.php
ansel/lib/Widget/Geotag.php
ansel/lib/Widget/ImageFaces.php
ansel/lib/Widget/OtherGalleries.php
ansel/lib/Widget/Tags.php
ansel/map_edit.php
framework/Ajax/lib/Horde/Ajax.php [deleted file]
framework/Ajax/lib/Horde/Ajax/Application/Base.php [deleted file]
framework/Ajax/lib/Horde/Ajax/Exception.php [deleted file]
framework/Ajax/lib/Horde/Ajax/Imple.php [deleted file]
framework/Ajax/lib/Horde/Ajax/Imple/AutoCompleter.php [deleted file]
framework/Ajax/lib/Horde/Ajax/Imple/Base.php [deleted file]
framework/Ajax/lib/Horde/Ajax/Imple/Geocoder/Geonames.php [deleted file]
framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php [deleted file]
framework/Ajax/package.xml [deleted file]
framework/Core/lib/Horde.php
framework/Core/lib/Horde/Core/Ajax/Application.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ajax/Imple.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ajax/Imple/AutoCompleter.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Binder/Ajax.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Binder/Imple.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Factory/Ajax.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Factory/Imple.php [new file with mode: 0644]
framework/Core/lib/Horde/Registry.php
framework/Core/package.xml
horde/config/hooks.php.dist
horde/js/hordemap/map.js
horde/services/ajax.php
horde/services/imple.php
imp/config/hooks.php.dist
imp/lib/Ajax/Application.php
imp/lib/Ajax/Imple/ContactAutoCompleter.php
imp/lib/Ajax/Imple/PassphraseDialog.php
imp/lib/Mime/Viewer/Pgp.php
imp/lib/Mime/Viewer/Smime.php
imp/lib/Prefs/Ui.php
imp/lib/Ui/Compose.php
kronolith/attendees.php
kronolith/calendars/edit.php
kronolith/config/hooks.php.dist
kronolith/index.php
kronolith/lib/Ajax/Application.php
kronolith/lib/Ajax/Imple/ContactAutoCompleter.php
kronolith/lib/Ajax/Imple/Embed.php
kronolith/lib/Ajax/Imple/TagActions.php
kronolith/lib/Ajax/Imple/TagAutoCompleter.php
kronolith/lib/Kronolith.php
kronolith/templates/edit/edit.inc
kronolith/templates/panel.inc
shout/lib/Ajax/Application.php
whups/lib/Ajax/Imple/ContactAutoCompleter.php
whups/lib/Forms/VarRenderer.php

index 33cc228..aca84e3 100644 (file)
@@ -362,10 +362,10 @@ Horde::addScriptFile('stripe.js', 'horde');
 require ANSEL_TEMPLATES . '/common-header.inc';
 
 /* Attach the slug check action to the form */
-$imple = Horde_Ajax_Imple::factory(array('ansel', 'GallerySlugCheck'),
-                                   array('slug' => $gallery_slug,
-                                         'bindTo' => 'gallery_slug'));
-$imple->attach();
+$injector->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'GallerySlugCheck'), array(
+    'bindTo' => 'gallery_slug',
+    'slug' => $gallery_slug
+));
 Horde::addScriptFile('popup.js', 'horde');
 require ANSEL_TEMPLATES . '/menu.inc';
 require ANSEL_TEMPLATES . '/gallery/gallery.inc';
index b9489ca..65f2e5d 100644 (file)
@@ -8,7 +8,7 @@
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  * @package Ansel
  */
-class Ansel_Ajax_Imple_EditCaption extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_EditCaption extends Horde_Core_Ajax_Imple
 {
     public function __construct($params)
     {
index 0a08d86..4d0fc1a 100644 (file)
@@ -10,7 +10,7 @@
  *
  * @package Ansel
  */
-class Ansel_Ajax_Imple_EditFaces extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_EditFaces extends Horde_Core_Ajax_Imple
 {
     /**
      * Attach these actions to the view
index 81d8885..5ec9258 100644 (file)
@@ -10,7 +10,7 @@
  *
  * @package Ansel
  */
-class Ansel_Ajax_Imple_Embed extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_Embed extends Horde_Core_Ajax_Imple
 {
     // Noop since we don't attach this to any UI element.
     public function attach(){}
index 14e8878..55ccabb 100644 (file)
@@ -8,7 +8,7 @@
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  * @package Ansel
  */
-class Ansel_Ajax_Imple_GallerySlugCheck extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_GallerySlugCheck extends Horde_Core_Ajax_Imple
 {
     public function attach()
     {
index 4159134..6bc3318 100644 (file)
@@ -11,7 +11,7 @@
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  * @package Ansel
  */
-class Ansel_Ajax_Imple_ImageSaveGeotag extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_ImageSaveGeotag extends Horde_Core_Ajax_Imple
 {
     // Noop since this isn't attached to any UI Element
     public function attach() {}
index 682fe78..31a9b98 100644 (file)
@@ -10,7 +10,7 @@
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  * @package Ansel
  */
-class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Ajax_Imple_AutoCompleter
+class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Core_Ajax_Imple_AutoCompleter
 {
     protected function _attach($js_params)
     {
index cf23875..69b08fa 100644 (file)
@@ -8,7 +8,7 @@
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  * @package Ansel
  */
-class Ansel_Ajax_Imple_TagActions extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_TagActions extends Horde_Core_Ajax_Imple
 {
     public function attach()
     {
index 4e3230d..b96d9d3 100644 (file)
@@ -8,7 +8,7 @@
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  * @package Ansel
  */
-class Ansel_Ajax_Imple_ToggleGalleryActions extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_ToggleGalleryActions extends Horde_Core_Ajax_Imple
 {
     public function attach()
     {
index ec95d2b..fb9e839 100644 (file)
@@ -8,7 +8,7 @@
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  * @package Ansel
  */
-class Ansel_Ajax_Imple_ToggleOtherGalleries extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_ToggleOtherGalleries extends Horde_Core_Ajax_Imple
 {
     public function attach()
     {
index cf34ee8..da244aa 100644 (file)
@@ -1002,10 +1002,9 @@ class Ansel
             $domid = $options['container'];
         }
 
-        $imple = Horde_Ajax_Imple::factory(array('ansel', 'Embed'), $options);
-        $src = $imple->getUrl();
+        $imple = $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'Embed'), $options);
 
-       return '<script type="text/javascript" src="' . $src . '"></script><div id="' . $domid . '"></div>';
+       return '<script type="text/javascript" src="' . $imple->getUrl() . '"></script><div id="' . $domid . '"></div>';
     }
 
 }
index 9df76c9..179254d 100644 (file)
@@ -115,10 +115,10 @@ class Ansel_Tile_Image
         Horde::startBuffer();
         // In-line caption editing if we have Horde_Perms::EDIT
         if ($option_edit) {
-            $imple = Horde_Ajax_Imple::factory(array('ansel', 'EditCaption'),
-                                               array('id' => $image->id,
-                                                     'domid' => $image->id . 'caption'));
-            $imple->attach();
+            $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'EditCaption'), array(
+                'domid' => $image->id . 'caption',
+                'id' => $image->id
+            ));
         }
         include ANSEL_BASE . '/templates/tile/image.inc';
 
index 5fd8cbe..d961f77 100644 (file)
@@ -363,11 +363,11 @@ class Ansel_View_Image extends Ansel_View_Base
 
             /* In line caption editing */
             if ($this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
-                $imple = Horde_Ajax_Imple::factory(array('ansel', 'EditCaption'),
-                                                array('id' => $this->resource->id,
-                                                      'domid' => "Caption",
-                                                      'cols' => 120));
-                $imple->attach();
+                $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'EditCaption'), array(
+                    'cols' => 120,
+                    'domid' => "Caption",
+                    'id' => $this->resource->id
+                ));
             }
         }
 
index 69dd380..bcaa42c 100644 (file)
@@ -97,8 +97,9 @@ class Ansel_Widget_Actions extends Ansel_Widget_Base
 
         /* Attach the ajax action */
         Horde::startBuffer();
-        $imple = Horde_Ajax_Imple::factory(array('ansel', 'ToggleGalleryActions'), array('bindTo' => 'gallery-actions'));
-        $imple->attach();
+        $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'ToggleGalleryActions'), array(
+            'bindTo' => 'gallery-actions'
+        ));
         $html .= Horde::endBuffer();
 
         /* Buid the url parameters to the zip link */
index ee3cfe7..4f7da32 100644 (file)
@@ -75,7 +75,7 @@ class Ansel_Widget_Geotag extends Ansel_Widget_Base
         $rtext = _("Relocate this image");
         $dtext = _("Delete geotag");
 
-        $imple = Horde_Ajax_Imple::factory(array('ansel', 'ImageSaveGeotag'), array());
+        $imple = $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'ImageSaveGeotag'));
         $impleUrl = $imple->getUrl();
 
         $permsEdit = $this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
index ed102d0..e585d1d 100644 (file)
@@ -76,13 +76,11 @@ class Ansel_Widget_ImageFaces extends Ansel_Widget_Base
 
             // Attach the ajax edit actions
             Horde::startBuffer();
-            $imple = Horde_Ajax_Imple::factory(
-                array('ansel', 'EditFaces'),
-                array('image_id' => $this->_view->resource->id,
-                      'domid' => 'edit_faces',
-                      'selfUrl' => $this->_params['selfUrl']));
-
-            $imple->attach();
+            $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'EditFaces'), array(
+                'domid' => 'edit_faces',
+                'image_id' => $this->_view->resource->id,
+                'selfUrl' => $this->_params['selfUrl']
+            ));
             $html .= Horde::endBuffer();
         }
 
index 7396fcc..1b7d233 100644 (file)
@@ -101,8 +101,9 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base
                            array('icon' => $img, 'icondir' => '', 'url' => $link));
         }
         Horde::startBuffer();
-        $imple = Horde_Ajax_Imple::factory(array('ansel', 'ToggleOtherGalleries'), array('bindTo' => 'othergalleries'));
-        $imple->attach();
+        $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'ToggleOtherGalleries'), array(
+            'bindTo' => 'othergalleries'
+        ));
 
         $tree->sort('label');
         $tree->renderTree();
index 483840a..dc8cfbf 100644 (file)
@@ -36,11 +36,11 @@ class Ansel_Widget_Tags extends Ansel_Widget_Base
         if ($this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             Horde::startBuffer();
             /* Attach the Ajax action */
-            $imple = Horde_Ajax_Imple::factory(array('ansel', 'TagActions'),
-                                               array('bindTo' => array('add' => 'tagbutton'),
-                                                     'gallery' => $this->_view->gallery->id,
-                                                     'image' => $image_id));
-            $imple->attach();
+            $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'TagActions'), array(
+                'bindTo' => array('add' => 'tagbutton'),
+                'gallery' => $this->_view->gallery->id,
+                'image' => $image_id
+            ));
             $html .= Horde::endBuffer();
 
             $actionUrl = Horde::applicationUrl('image.php')->add(
index 9e4806d..286ee08 100644 (file)
@@ -66,7 +66,7 @@ $returnLink = Ansel::getUrlFor('view', array('view' => 'Image',
                                              'gallery' => $gallery->id));
 $image_tag = '<img src="' . Ansel::getImageUrl($image_id, 'thumb', true) . '" alt="[thumbnail]" />';
 /* Url for geotag ajax helper */
-$gt = Horde_Ajax_Imple::factory(array('ansel', 'ImageSaveGeotag'));
+$gt = $injector->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'Imple_ImageSaveGeotag'));
 $gtUrl = $gt->getUrl();
 
 $loadingImg = Horde::img('loading.gif', _("Loading..."));
@@ -138,11 +138,11 @@ $html = <<<EOT
 </script>
 EOT;
 /* Autocompleter for locations we already have in our DB */
-$ac = Horde_Ajax_Imple::factory(array('ansel', 'LocationAutoCompleter'),
-                                array('triggerId' => 'locationInput',
-                                      'resultsId' => 'locationInput_results',
-                                      'map' => 'mapEdit'));
-$ac->attach();
+$injector->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'LocationAutoCompleter'), array(
+    'map' => 'mapEdit',
+    'resultsId' => 'locationInput_results',
+    'triggerId' => 'locationInput'
+));
 //$html .= Horde_Util::bufferOutput(array($ac, 'attach'));
 
 /* Start the output */
diff --git a/framework/Ajax/lib/Horde/Ajax.php b/framework/Ajax/lib/Horde/Ajax.php
deleted file mode 100644 (file)
index 0bb7684..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * Perform AJAX actions.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @package  Horde_Ajax
- */
-class Horde_Ajax
-{
-    /**
-     * Get a Horde_Ajax_Application_Base instance.
-     *
-     * @param string $app     The application name.
-     * @param string $action  The AJAX action to perform.
-     *
-     * @return Horde_Ajax_Application_Base  The requested instance.
-     * @throws Horde_Exception
-     */
-    static public function getInstance($app, $action = null)
-    {
-        $class = $app . '_Ajax_Application';
-
-        if (class_exists($class)) {
-            return new $class($app, $action);
-        }
-
-        throw new Horde_Ajax_Exception('Ajax configuration for ' . $app . ' not found.');
-    }
-
-}
diff --git a/framework/Ajax/lib/Horde/Ajax/Application/Base.php b/framework/Ajax/lib/Horde/Ajax/Application/Base.php
deleted file mode 100644 (file)
index a84aaee..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-<?php
-/**
- * Defines the AJAX interface for an application.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ajax
- */
-abstract class Horde_Ajax_Application_Base
-{
-    /**
-     * Determines if notification information is sent in response.
-     *
-     * @var boolean
-     */
-    public $notify = false;
-
-    /**
-     * The Horde application.
-     *
-     * @var string
-     */
-    protected $_app;
-
-    /**
-     * The action to perform.
-     *
-     * @var string
-     */
-    protected $_action;
-
-    /**
-     * The request variables.
-     *
-     * @var Variables
-     */
-    protected $_vars;
-
-    /**
-     * The list of actions that require readonly access to the session.
-     *
-     * @var array
-     */
-    protected $_readOnly = array();
-
-    /**
-     * Default domain.
-     *
-     * @see parseEmailAddress()
-     * @var string
-     */
-    protected $_defaultDomain;
-
-    /**
-     * Constructor.
-     *
-     * @param string $app     The application name.
-     * @param string $action  The AJAX action to perform.
-     */
-    public function __construct($app, $action = null)
-    {
-        $this->_app = $app;
-
-        if (!is_null($action)) {
-            /* Close session if action is labeled as read-only. */
-            if (in_array($action, $this->_readOnly)) {
-                session_write_close();
-            }
-
-            $this->_action = $action;
-        }
-    }
-
-    /**
-     * Performs the AJAX action.
-     *
-     * @return mixed  The result of the action call.
-     * @throws Horde_Ajax_Exception
-     */
-    public function doAction()
-    {
-        if (!$this->_action) {
-            return false;
-        }
-
-        $this->_vars = Horde_Variables::getDefaultVariables();
-
-        if (method_exists($this, $this->_action)) {
-            return call_user_func(array($this, $this->_action));
-        }
-
-        /* Look for hook in application. */
-        try {
-            return Horde::callHook('ajaxaction', array($this->_action, $this->_vars), $this->_app);
-        } catch (Horde_Exception_HookNotSet $e) {
-        } catch (Horde_Ajax_Exception $e) {}
-
-        throw new Horde_Ajax_Exception('Handler for action "' . $this->_action . '" does not exist.');
-    }
-
-    /**
-     * Determines the HTTP response output type.
-     *
-     * @see Horde::sendHTTPResponse().
-     *
-     * @return string  The output type.
-     */
-    public function responseType()
-    {
-        return 'json';
-    }
-
-    /**
-     * Logs the user off the Horde session.
-     *
-     * This needs to be done here (server), rather than on the browser,
-     * because the logout tokens might otherwise expire.
-     */
-    public function logOut()
-    {
-        Horde::redirect(Horde::getServiceLink('logout', $this->_app)->setRaw(true));
-        exit;
-    }
-
-    /**
-     * Returns a hash of group IDs and group names that the user has access to.
-     *
-     * @return array  Groups hash.
-     */
-    public function listGroups()
-    {
-        $result = new stdClass;
-        try {
-            $horde_groups = Horde_Group::singleton();
-            $groups = empty($GLOBALS['conf']['share']['any_group'])
-                ? $horde_groups->getGroupMemberships($GLOBALS['registry']->getAuth(), true)
-                : $horde_groups->listGroups();
-            if ($groups) {
-                asort($groups);
-                $result->groups = $groups;
-            }
-        } catch (Horde_Group_Exception $e) {
-            Horde::logMessage($e);
-        }
-        return $result;
-    }
-
-    /**
-     * Parses a valid email address out of a complete address string.
-     *
-     * Variables used:
-     * - mbox (string): The name of the new mailbox.
-     * - parent (string): The parent mailbox.
-     *
-     * @return string  The parsed email address.
-     * @throws Horde_Exception
-     * @throws Horde_Mail_Exception
-     */
-    public function parseEmailAddress()
-    {
-        $rfc822 = new Horde_Mail_Rfc822();
-        $params = array();
-        if ($this->_defaultDomain) {
-            $params['default_domain'] = $this->_defaultDomain;
-        }
-        $res = $rfc822->parseAddressList($this->_vars->email, $params);
-        if (!count($res)) {
-            throw new Horde_Exception(_("No valid email address found"));
-        }
-        return (object)array('email' => Horde_Mime_Address::writeAddress($res[0]->mailbox, $res[0]->host));
-    }
-
-    /**
-     * Loads a chunk of PHP code (usually an HTML template) from the
-     * application's templates directory.
-     *
-     * @return string  A chunk of PHP output.
-     */
-    public function chunkContent()
-    {
-        $chunk = basename(Horde_Util::getPost('chunk'));
-        $result = new stdClass;
-        if (!empty($chunk)) {
-            Horde::startBuffer();
-            include $GLOBALS['registry']->get('templates', $this->_app) . '/chunks/' . $chunk . '.php';
-            $result->chunk = Horde::endBuffer();
-        }
-
-        return $result;
-    }
-
-}
diff --git a/framework/Ajax/lib/Horde/Ajax/Exception.php b/framework/Ajax/lib/Horde/Ajax/Exception.php
deleted file mode 100644 (file)
index b6ca292..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Exception object for the Horde_Ajax package.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @package  Horde_Ajax
- */
-class Horde_Ajax_Exception extends Horde_Exception
-{
-}
diff --git a/framework/Ajax/lib/Horde/Ajax/Imple.php b/framework/Ajax/lib/Horde/Ajax/Imple.php
deleted file mode 100644 (file)
index 68730f9..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * Class to attach PHP actions to javascript elements.
- * (Originally named 'Dimple' as it was first implemented in DIMP - rennamed
- * to 'Imple' when DIMP was merged into IMP.)
- *
- * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ajax
- */
-class Horde_Ajax_Imple
-{
-    /**
-     * Attempts to return a concrete instance based on $driver.
-     *
-     * @param mixed $driver  The type of concrete subclass to return. If
-     *                       $driver is an array, then look in
-     *                       $driver[0]/lib/Ajax/Imple for the subclass
-     *                       implementation named $driver[1].php.
-     * @param array $params  A hash containing any additional configuration or
-     *                       parameters a subclass might need.
-     *
-     * @return Horde_Ajax_Imple_Base  The newly created concrete instance.
-     * @throws Horde_Exception
-     */
-    static public function factory($driver, $params = array())
-    {
-        if (is_array($driver)) {
-            list($app, $driv_name) = $driver;
-            $driver = basename($driv_name);
-        } else {
-            $driver = basename($driver);
-        }
-
-        $class = (empty($app) ? 'Horde' : $app) . '_Ajax_Imple_' . ucfirst($driver);
-
-        if (class_exists($class)) {
-            return new $class($params);
-        }
-
-        throw new Horde_Exception('Class definition of ' . $class . ' not found.');
-    }
-}
diff --git a/framework/Ajax/lib/Horde/Ajax/Imple/AutoCompleter.php b/framework/Ajax/lib/Horde/Ajax/Imple/AutoCompleter.php
deleted file mode 100644 (file)
index 452bf12..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-<?php
-/**
- * Attach an auto completer to a javascript element.
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ajax
- */
-abstract class Horde_Ajax_Imple_AutoCompleter extends Horde_Ajax_Imple_Base
-{
-    /**
-     * Constructor.
-     *
-     * @param array $params  Configuration parameters.
-     * <pre>
-     * 'triggerId' => (string) [optional] TODO
-     * 'no_onload' => (boolean) [optional] Don't wait for dom:onload to attach
-     * </pre>
-     */
-    public function __construct($params)
-    {
-        if (empty($params['triggerId'])) {
-            $params['triggerId'] = $this->_randomid();
-        }
-
-        if (empty($params['triggerContainer'])) {
-            $params['triggerContainer'] = $this->_randomid();
-        }
-
-        parent::__construct($params);
-    }
-
-    /**
-     * Attach the object to a javascript event.
-     */
-    public function attach()
-    {
-        $params = array(
-            '"' . $this->_params['triggerId'] . '"'
-        );
-
-        $config = $this->_attach(array('tokens' => array(',', ';')));
-
-        Horde::addScriptFile('autocomplete.js', 'horde');
-        Horde::addScriptFile('keynavlist.js', 'horde');
-        Horde::addScriptFile('liquidmetal.js', 'horde');
-        if (isset($config['ajax'])) {
-            $func = 'Ajax.Autocompleter';
-            $params[] = '"' . $this->_getUrl($config['ajax'], $GLOBALS['registry']->getApp(), array('input' => $this->_params['triggerId'])) . '"';
-        } elseif (isset($config['browser'])) {
-            $func = 'Autocompleter.Local';
-            $params[] = $config['browser'];
-            $config['params'] = array_merge(array(
-                'partialSearch' => 1,
-                'fullSearch' => 1,
-                'score' => 1
-            ), $config['params']);
-        } elseif (isset($config['pretty'])) {
-            Horde::addScriptFile('prettyautocomplete.js', 'horde');
-            $func = 'PrettyAutocompleter';
-            $config['params'] = array_merge(array(
-                'boxClass' => 'hordeACBox kronolithLongField',
-                'trigger' => $this->_params['triggerId'],
-                'triggerContainer' => $this->_params['triggerContainer'],
-                'uri' => (string)$this->_getUrl($config['pretty'], $GLOBALS['registry']->getApp()),
-                'deleteIcon' => (string)Horde_Themes::img('delete-small.png', 'horde'),
-                'box' => !empty($this->_params['box']) ? $this->_params['box'] : ''
-            ), $config['params']);
-
-            if (!empty($this->_params['existing'])) {
-                $config['params']['existing'] = $this->_params['existing'];
-            }
-        } else {
-            return;
-        }
-
-        $config['raw_params'] = !empty($config['raw_params']) ? $config['raw_params'] : array();
-        foreach ($config['raw_params'] as $name => $val) {
-            $config['params'][$name] = 1;
-        }
-
-        $js_params = Horde_Serialize::serialize($config['params'], Horde_Serialize::JSON);
-
-        foreach ($config['raw_params'] as $name => $val) {
-            $js_params = str_replace('"' . $name . '":1', '"' . $name . '":' . $val, $js_params);
-        }
-
-        Horde::addScriptFile('effects.js', 'horde');
-
-        Horde::addInlineScript((isset($config['var']) ? $config['var'] . ' = ' : '') . 'new ' . $func . '(' . implode(',', $params) . ',' . $js_params . ')', empty($this->_params['no_onload']) ? 'dom' : null);
-    }
-
-    /**
-     * Attach the object to a javascript event.
-     *
-     * @return array  An array with the following elements:
-     * <pre>
-     * ONE of the following:
-     * 'ajax' - (string) Use 'Ajax.Autocompleter' class. Value is the AJAX
-     *          function name.
-     * 'browser' - (string) Use 'Autocompleter.Local' class. Value is the
-     *             javascript list of items to search.
-     * 'pretty' - (string) Use 'PrettyAutocompleter' class. Value is the AJAX
-     *            function name.
-     *
-     * Additional Options:
-     * 'params' - (array) The list of javascript parameters to pass to the
-     *            autocomplete libraries.
-     * 'raw_params' - (array) Adds raw javascript to the 'params' array.
-     * 'var' - (string) If set, the autocomplete object will be assigned to
-     *         this variable.
-     * </pre>
-     */
-    abstract protected function _attach($js_params);
-
-}
diff --git a/framework/Ajax/lib/Horde/Ajax/Imple/Base.php b/framework/Ajax/lib/Horde/Ajax/Imple/Base.php
deleted file mode 100644 (file)
index ee14297..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-/**
- * Class to attach PHP actions to javascript elements.
- *
- * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ajax
- */
-abstract class Horde_Ajax_Imple_Base
-{
-    /**
-     * Parameters needed by the subclasses.
-     *
-     * @var array
-     */
-    protected $_params = array();
-
-    /**
-     * Constructor.
-     *
-     * @param array $params  Any parameters needed by the class.
-     */
-    public function __construct($params)
-    {
-        $this->_params = $params;
-    }
-
-    /**
-     * Attach the object to a javascript event.
-     */
-    abstract public function attach();
-
-    /**
-     * TODO
-     *
-     * @param array $args  TODO
-     */
-    abstract public function handle($args, $post);
-
-    /**
-     * TODO
-     *
-     * @param string $driver
-     * @param string $app
-     * @param array $params
-     * @param boolean $full
-     *
-     * @return string
-     */
-    protected function _getUrl($driver, $app = 'horde', $params = array(),
-                               $full = false)
-    {
-        $qstring = 'imple=' . $driver;
-
-        if ($app != 'horde') {
-            $qstring .= '/impleApp=' . $app;
-        }
-
-        foreach ($params as $key => $val) {
-            $qstring .= '/' . $key . '=' . rawurlencode($val);
-        }
-
-        return Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/imple.php?' . $qstring, $full);
-    }
-
-    /**
-     * Generate a random ID string.
-     *
-     * @return string  The random ID string.
-     */
-    protected function _randomid()
-    {
-        return 'imple_' . uniqid(mt_rand());
-    }
-
-}
diff --git a/framework/Ajax/lib/Horde/Ajax/Imple/Geocoder/Geonames.php b/framework/Ajax/lib/Horde/Ajax/Imple/Geocoder/Geonames.php
deleted file mode 100644 (file)
index b2193cf..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * Geocode client for the Geonames API.
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Horde_Ajax
- */
-class Horde_Ajax_Imple_Geocoder_Geonames extends Horde_Ajax_Imple_Base
-{
-    /**
-     * Constructor.
-     *
-     * @param array $params  Configuration parameters.
-     * <pre>
-     * 'triggerId' => (string) [optional] TODO
-     * </pre>
-     */
-    public function __construct($params)
-    {
-        parent::__construct($params);
-    }
-
-    /**
-     * Attach the object to a javascript event.
-     */
-    public function attach()
-    {
-    }
-
-
-    /**
-     * Handle the geocoding request.
-     *
-     * @TODO: For reverse requests come up with a reasonable algorithm for
-     *        checking if we have a lat/lng in the US since the
-     *        findNearestAddress method is US only. If non-us, fallback to a
-     *        findNearest or findPostalcode or similar request. Also will need
-     *        to normalize the various response structures.
-     *
-     * $args['locations'] will trigger a forward geocoding request.
-     * $args['lat'] and $args['lon'] will trigger a reverse geocoding request.
-     *
-     * @see framework/Ajax/lib/Horde/Ajax/Imple/Horde_Ajax_Imple_Base#handle($args, $post)
-     * @throws Horde_Exception
-     */
-    public function handle($args, $post)
-    {
-        if ($args['location']) {
-            $url = new Horde_Url('http://ws.geonames.org/searchJSON');
-            $url = $url->add('q', $args['location']);
-        } elseif (!empty($args['lat']) && !empty($args['lon'])) {
-            $url = new Horde_Url('http:/ws.geonames.org/findNearestJSON');
-            $url = $url->add(array('lat' => $args['lat'], 'lng' => $args['lon']));
-        }
-        $client = new Horde_Http_Client();
-        try {
-            $response = $client->get($url);
-        } catch (Horde_Http_Exception $e) {
-            throw new Horde_Exception_Prior($e);
-        }
-        return array('status' => 200,
-                     'results' => $response->getBody());
-    }
-
-}
diff --git a/framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php b/framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php
deleted file mode 100644 (file)
index 860d912..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-<?php
-/**
- * Attach the spellchecker to a javascript element.
- *
- * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ajax
- */
-class Horde_Ajax_Imple_SpellChecker extends Horde_Ajax_Imple_Base
-{
-    /**
-     * Constructor.
-     *
-     * @param array $params  Configuration parameters.
-     * <pre>
-     * 'id' => TODO (optional)
-     * 'locales' => TODO (optional)
-     * 'states' => TODO (optional)
-     * 'targetId' => TODO (optional)
-     * 'triggerId' => TODO (optional)
-     * </pre>
-     */
-    public function __construct($params = array())
-    {
-        if (empty($params['id'])) {
-            $params['id'] = $this->_randomid();
-        }
-
-        if (empty($params['targetId'])) {
-            $params['targetId'] = $this->_randomid();
-        }
-
-        if (empty($params['triggerId'])) {
-            $params['triggerId'] = $params['targetId'] . '_trigger';
-        }
-
-        if (empty($params['locales'])) {
-            $key_list = array_keys($GLOBALS['registry']->nlsconfig['spelling']);
-            asort($key_list, SORT_LOCALE_STRING);
-            $params['locales'] = array();
-
-            foreach ($key_list as $lcode) {
-                $params['locales'][] = array('l' => $GLOBALS['registry']->nlsconfig['languages'][$lcode], 'v' => $lcode);
-            }
-        }
-
-        parent::__construct($params);
-    }
-
-    /**
-     */
-    public function attach()
-    {
-        Horde::addScriptFile('prototype.js', 'horde');
-        Horde::addScriptFile('effects.js', 'horde');
-        Horde::addScriptFile('keynavlist.js', 'horde');
-        Horde::addScriptFile('spellchecker.js', 'horde');
-
-        $opts = array(
-            'locales' => $this->_params['locales'],
-            'sc' => 'widget',
-            'statusButton' => $this->_params['triggerId'],
-            'target' => $this->_params['targetId'],
-            'url' => strval($this->_getUrl('SpellChecker', 'horde', array('input' => $this->_params['targetId'])))
-        );
-        if (isset($this->_params['states'])) {
-            $opts['bs'] = $this->_params['states'];
-        }
-
-        Horde::addInlineScript(array(
-            $this->_params['id'] . ' = new SpellChecker(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')'
-        ), 'dom');
-    }
-
-    /**
-     */
-    public function handle($args, $post)
-    {
-        $spellArgs = array();
-
-        if (!empty($GLOBALS['conf']['spell']['params'])) {
-            $spellArgs = $GLOBALS['conf']['spell']['params'];
-        }
-
-        if (isset($args['locale'])) {
-            $spellArgs['locale'] = $args['locale'];
-        } elseif (isset($GLOBALS['language'])) {
-            $spellArgs['locale'] = $GLOBALS['language'];
-        }
-
-        /* Add local dictionary words. */
-        try {
-            $result = Horde::loadConfiguration('spelling.php', 'ignore_list', 'horde');
-            $spellArgs['localDict'] = $result;
-        } catch (Horde_Exception $e) {}
-
-        if (!empty($args['html'])) {
-            $spellArgs['html'] = true;
-        }
-
-        try {
-            $speller = Horde_SpellChecker::factory($GLOBALS['conf']['spell']['driver'], $spellArgs);
-        } catch (Horde_Exception $e) {
-            Horde::logMessage($e, 'ERR');
-            return array();
-        }
-
-        try {
-            return $speller->spellCheck(Horde_Util::getPost($args['input']));
-        } catch (Horde_Exception $e) {
-            Horde::logMessage($e, 'ERR');
-            return array('bad' => array(), 'suggestions' => array());
-        }
-    }
-
-}
diff --git a/framework/Ajax/package.xml b/framework/Ajax/package.xml
deleted file mode 100644 (file)
index 02fabc6..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.4.9" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
-http://pear.php.net/dtd/tasks-1.0.xsd
-http://pear.php.net/dtd/package-2.0
-http://pear.php.net/dtd/package-2.0.xsd">
- <name>Ajax</name>
- <channel>pear.horde.org</channel>
- <summary>Horde Ajax utilities</summary>
- <description>This package provides utilities to aid with using AJAX with Horde applications.
- </description>
- <lead>
-  <name>Michael Slusarz</name>
-  <user>slusarz</user>
-  <email>slusarz@horde.org</email>
-  <active>yes</active>
- </lead>
- <date>2009-07-16</date>
- <version>
-  <release>0.1.0</release>
-  <api>0.1.0</api>
- </version>
- <stability>
-  <release>beta</release>
-  <api>beta</api>
- </stability>
- <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Add Application framework.
- * Add AutoCompleter driver.
- * Initial release.
- </notes>
- <contents>
-  <dir name="/">
-   <dir name="lib">
-    <dir name="Horde">
-     <dir name="Ajax">
-      <dir name="Application">
-       <file name="Base.php" role="php" />
-      </dir> <!-- /lib/Horde/Ajax/Application -->
-      <dir name="Imple">
-       <file name="AutoCompleter.php" role="php" />
-       <file name="Base.php" role="php" />
-       <file name="SpellChecker.php" role="php" />
-       <dir name="Geocoder">
-        <file name="Geonames.php" role="php" />
-       </dir>
-      </dir> <!-- /lib/Horde/Ajax/Imple -->
-      <file name="Exception.php" role="php" />
-      <file name="Imple.php" role="php" />
-     </dir> <!-- /lib/Horde/Ajax -->
-     <file name="Ajax.php" role="php" />
-    </dir> <!-- /lib/Horde -->
-   </dir> <!-- /lib -->
-  </dir> <!-- / -->
- </contents>
- <dependencies>
-  <required>
-   <php>
-    <min>5.2.0</min>
-   </php>
-   <pearinstaller>
-    <min>1.7.0</min>
-   </pearinstaller>
-   <package>
-    <name>Core</name>
-    <channel>pear.horde.org</channel>
-   </package>
-   <package>
-    <name>Util</name>
-    <channel>pear.horde.org</channel>
-   </package>
-  </required>
-  <optional>
-   <package>
-    <name>SpellChecker</name>
-    <channel>pear.horde.org</channel>
-   </package>
-   <package>
-    <name>Serialize</name>
-    <channel>pear.horde.org</channel>
-   </package>
-  </optional>
- </dependencies>
- <phprelease>
-  <filelist>
-   <install name="lib/Horde/Ajax/Application/Base.php" as="Horde/Ajax/Application/Base.php" />
-   <install name="lib/Horde/Ajax/Exception.php" as="Horde/Ajax/Exception.php" />
-   <install name="lib/Horde/Ajax/Imple/AutoCompleter.php" as="Horde/Ajax/Imple/AutoCompleter.php" />
-   <install name="lib/Horde/Ajax/Imple/Base.php" as="Horde/Ajax/Imple/Base.php" />
-   <install name="lib/Horde/Ajax/Imple/SpellChecker.php" as="Horde/Ajax/Imple/SpellChecker.php" />
-   <install name="lib/Horde/Ajax/Imple.php" as="Horde/Ajax/Imple.php" />
-   <install name="lib/Horde/Ajax/Imple/Geocoder/Geonames.php" as="Horde/Ajax/Imple/Geocoder/Geonames.php" />
-   <install name="lib/Horde/Ajax.php" as="Horde/Ajax.php" />
-  </filelist>
- </phprelease>
- <changelog/>
-</package>
index ee86ca3..6cfe9f4 100644 (file)
@@ -448,9 +448,19 @@ HTML;
      *
      * @param string $type       The service to display.
      * <pre>
-     * TODO
-     * 'ajax', 'cache', 'download', 'go', 'logintasks', 'prefsapi'
-     * 'help', 'problem', 'logout', 'login', 'options', 'sidebar'
+     * 'ajax'
+     * 'cache'
+     * 'download'
+     * 'go'
+     * 'help'
+     * 'imple'
+     * 'login'
+     * 'logintasks'
+     * 'logout'
+     * 'prefsapi
+     * 'problem'
+     * 'sidebar'
+     * 'options'
      * </pre>
      * @param string $app        The name of the current Horde application.
      *
@@ -461,21 +471,32 @@ HTML;
         $webroot = $GLOBALS['registry']->get('webroot', 'horde');
 
         switch ($type) {
+        case 'ajax':
+            return self::url($webroot . '/services/ajax.php/' . $app . '/');
+
+        case 'cache':
+            return self::url($webroot . '/services/cache.php', false, -1);
+
+        case 'download':
+            return self::url($webroot . '/services/download/')
+                ->add('module', $app);
+
+        case 'go':
+            return self::url($webroot . '/services/go.php');
+
         case 'help':
             return self::url($webroot . '/services/help/')->add('module', $app);
 
-        case 'problem':
-            return self::url($webroot . '/services/problem.php')
-                ->add('return_url', urlencode(self::selfUrl(true, true, true)));
-
-        case 'logout':
-            return $GLOBALS['registry']->getLogoutUrl(array('reason' => Horde_Auth::REASON_LOGOUT))->setRaw(false);
+        case 'imple':
+            return self::url($webroot . '/services/imple.php');
 
         case 'login':
             return self::url($webroot . '/login.php');
 
         case 'logintasks':
             return self::url($webroot . '/services/logintasks.php')->add('app', $app);
+        case 'logout':
+            return $GLOBALS['registry']->getLogoutUrl(array('reason' => Horde_Auth::REASON_LOGOUT))->setRaw(false);
 
         case 'options':
         case 'prefsapi':
@@ -488,18 +509,9 @@ HTML;
             }
             break;
 
-        case 'cache':
-            return self::url($webroot . '/services/cache.php', false, -1);
-
-        case 'download':
-            return self::url($webroot . '/services/download/')
-                ->add('module', $app);
-
-        case 'go':
-            return self::url($webroot . '/services/go.php');
-
-        case 'ajax':
-            return self::url($webroot . '/services/ajax.php/' . $app . '/');
+        case 'problem':
+            return self::url($webroot . '/services/problem.php')
+                ->add('return_url', urlencode(self::selfUrl(true, true, true)));
 
         case 'sidebar':
             return self::url($webroot . '/services/portal/sidebar.php');
diff --git a/framework/Core/lib/Horde/Core/Ajax/Application.php b/framework/Core/lib/Horde/Core/Ajax/Application.php
new file mode 100644 (file)
index 0000000..4f25e83
--- /dev/null
@@ -0,0 +1,198 @@
+<?php
+/**
+ * Defines the AJAX interface for an application.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+abstract class Horde_Core_Ajax_Application
+{
+    /**
+     * Determines if notification information is sent in response.
+     *
+     * @var boolean
+     */
+    public $notify = false;
+
+    /**
+     * The Horde application.
+     *
+     * @var string
+     */
+    protected $_app;
+
+    /**
+     * The action to perform.
+     *
+     * @var string
+     */
+    protected $_action;
+
+    /**
+     * The request variables.
+     *
+     * @var Variables
+     */
+    protected $_vars;
+
+    /**
+     * The list of actions that require readonly access to the session.
+     *
+     * @var array
+     */
+    protected $_readOnly = array();
+
+    /**
+     * Default domain.
+     *
+     * @see parseEmailAddress()
+     * @var string
+     */
+    protected $_defaultDomain;
+
+    /**
+     * Constructor.
+     *
+     * @param string $app            The application name.
+     * @param Horde_Variables $vars  Form/request data.
+     * @param string $action         The AJAX action to perform.
+     */
+    public function __construct($app, $vars, $action = null)
+    {
+        $this->_app = $app;
+        $this->_vars = $vars;
+
+        if (!is_null($action)) {
+            /* Close session if action is labeled as read-only. */
+            if (in_array($action, $this->_readOnly)) {
+                session_write_close();
+            }
+
+            $this->_action = $action;
+        }
+    }
+
+    /**
+     * Performs the AJAX action.
+     *
+     * @return mixed  The result of the action call.
+     * @throws Horde_Exception
+     */
+    public function doAction()
+    {
+        if (!$this->_action) {
+            return false;
+        }
+
+        if (method_exists($this, $this->_action)) {
+            return call_user_func(array($this, $this->_action));
+        }
+
+        /* Look for hook in application. */
+        try {
+            return Horde::callHook('ajaxaction', array($this->_action, $this->_vars), $this->_app);
+        } catch (Horde_Exception_HookNotSet $e) {
+        } catch (Horde_Exception $e) {}
+
+        throw new Horde_Exception('Handler for action "' . $this->_action . '" does not exist.');
+    }
+
+    /**
+     * Determines the HTTP response output type.
+     *
+     * @see Horde::sendHTTPResponse().
+     *
+     * @return string  The output type.
+     */
+    public function responseType()
+    {
+        return 'json';
+    }
+
+    /**
+     * Logs the user off the Horde session.
+     *
+     * This needs to be done here (server), rather than on the browser,
+     * because the logout tokens might otherwise expire.
+     */
+    public function logOut()
+    {
+        Horde::redirect(Horde::getServiceLink('logout', $this->_app)->setRaw(true));
+        exit;
+    }
+
+    /**
+     * Returns a hash of group IDs and group names that the user has access to.
+     *
+     * @return array  Groups hash.
+     */
+    public function listGroups()
+    {
+        $result = new stdClass;
+        try {
+            $horde_groups = Horde_Group::singleton();
+            $groups = empty($GLOBALS['conf']['share']['any_group'])
+                ? $horde_groups->getGroupMemberships($GLOBALS['registry']->getAuth(), true)
+                : $horde_groups->listGroups();
+            if ($groups) {
+                asort($groups);
+                $result->groups = $groups;
+            }
+        } catch (Horde_Group_Exception $e) {
+            Horde::logMessage($e);
+        }
+        return $result;
+    }
+
+    /**
+     * Parses a valid email address out of a complete address string.
+     *
+     * Variables used:
+     * - mbox (string): The name of the new mailbox.
+     * - parent (string): The parent mailbox.
+     *
+     * @return string  The parsed email address.
+     * @throws Horde_Exception
+     * @throws Horde_Mail_Exception
+     */
+    public function parseEmailAddress()
+    {
+        $rfc822 = new Horde_Mail_Rfc822();
+        $params = array();
+        if ($this->_defaultDomain) {
+            $params['default_domain'] = $this->_defaultDomain;
+        }
+        $res = $rfc822->parseAddressList($this->_vars->email, $params);
+        if (!count($res)) {
+            throw new Horde_Exception(_("No valid email address found"));
+        }
+        return (object)array('email' => Horde_Mime_Address::writeAddress($res[0]->mailbox, $res[0]->host));
+    }
+
+    /**
+     * Loads a chunk of PHP code (usually an HTML template) from the
+     * application's templates directory.
+     *
+     * @return string  A chunk of PHP output.
+     */
+    public function chunkContent()
+    {
+        $chunk = basename(Horde_Util::getPost('chunk'));
+        $result = new stdClass;
+        if (!empty($chunk)) {
+            Horde::startBuffer();
+            include $GLOBALS['registry']->get('templates', $this->_app) . '/chunks/' . $chunk . '.php';
+            $result->chunk = Horde::endBuffer();
+        }
+
+        return $result;
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ajax/Imple.php b/framework/Core/lib/Horde/Core/Ajax/Imple.php
new file mode 100644 (file)
index 0000000..71a864a
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Class to attach PHP actions to javascript elements.
+ *
+ * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+abstract class Horde_Core_Ajax_Imple
+{
+    /**
+     * Parameters needed by the subclasses.
+     *
+     * @var array
+     */
+    protected $_params = array();
+
+    /**
+     * Constructor.
+     *
+     * @param array $params  Any parameters needed by the class.
+     */
+    public function __construct($params)
+    {
+        $this->_params = $params;
+    }
+
+    /**
+     * Attach the object to a javascript event.
+     */
+    abstract public function attach();
+
+    /**
+     * TODO
+     *
+     * @param array $args  TODO
+     */
+    abstract public function handle($args, $post);
+
+    /**
+     * TODO
+     *
+     * @param string $driver
+     * @param string $app
+     * @param array $params
+     * @param boolean $full
+     *
+     * @return string
+     */
+    protected function _getUrl($driver, $app = 'horde', $params = array(),
+                               $full = false)
+    {
+        $qstring = 'imple=' . $driver;
+
+        if ($app != 'horde') {
+            $qstring .= '/impleApp=' . $app;
+        }
+
+        foreach ($params as $key => $val) {
+            $qstring .= '/' . $key . '=' . rawurlencode($val);
+        }
+
+        $url = Horde::getServiceLink('imple');
+        return Horde::url($url->url . '?' . $qstring, $full);
+    }
+
+    /**
+     * Generate a random ID string.
+     *
+     * @return string  The random ID string.
+     */
+    protected function _randomid()
+    {
+        return 'imple_' . uniqid(mt_rand());
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ajax/Imple/AutoCompleter.php b/framework/Core/lib/Horde/Core/Ajax/Imple/AutoCompleter.php
new file mode 100644 (file)
index 0000000..931fff5
--- /dev/null
@@ -0,0 +1,122 @@
+<?php
+/**
+ * Attach an auto completer to a javascript element.
+ *
+ * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+abstract class Horde_Core_Ajax_Imple_AutoCompleter extends Horde_Core_Ajax_Imple
+{
+    /**
+     * Constructor.
+     *
+     * @param array $params  Configuration parameters.
+     * <pre>
+     * 'triggerId' => (string) [optional] TODO
+     * 'no_onload' => (boolean) [optional] Don't wait for dom:onload to attach
+     * </pre>
+     */
+    public function __construct($params)
+    {
+        if (empty($params['triggerId'])) {
+            $params['triggerId'] = $this->_randomid();
+        }
+
+        if (empty($params['triggerContainer'])) {
+            $params['triggerContainer'] = $this->_randomid();
+        }
+
+        parent::__construct($params);
+    }
+
+    /**
+     * Attach the object to a javascript event.
+     */
+    public function attach()
+    {
+        $params = array(
+            '"' . $this->_params['triggerId'] . '"'
+        );
+
+        $config = $this->_attach(array('tokens' => array(',', ';')));
+
+        Horde::addScriptFile('autocomplete.js', 'horde');
+        Horde::addScriptFile('keynavlist.js', 'horde');
+        Horde::addScriptFile('liquidmetal.js', 'horde');
+        if (isset($config['ajax'])) {
+            $func = 'Ajax.Autocompleter';
+            $params[] = '"' . $this->_getUrl($config['ajax'], $GLOBALS['registry']->getApp(), array('input' => $this->_params['triggerId'])) . '"';
+        } elseif (isset($config['browser'])) {
+            $func = 'Autocompleter.Local';
+            $params[] = $config['browser'];
+            $config['params'] = array_merge(array(
+                'partialSearch' => 1,
+                'fullSearch' => 1,
+                'score' => 1
+            ), $config['params']);
+        } elseif (isset($config['pretty'])) {
+            Horde::addScriptFile('prettyautocomplete.js', 'horde');
+            $func = 'PrettyAutocompleter';
+            $config['params'] = array_merge(array(
+                'boxClass' => 'hordeACBox kronolithLongField',
+                'trigger' => $this->_params['triggerId'],
+                'triggerContainer' => $this->_params['triggerContainer'],
+                'uri' => (string)$this->_getUrl($config['pretty'], $GLOBALS['registry']->getApp()),
+                'deleteIcon' => (string)Horde_Themes::img('delete-small.png', 'horde'),
+                'box' => !empty($this->_params['box']) ? $this->_params['box'] : ''
+            ), $config['params']);
+
+            if (!empty($this->_params['existing'])) {
+                $config['params']['existing'] = $this->_params['existing'];
+            }
+        } else {
+            return;
+        }
+
+        $config['raw_params'] = !empty($config['raw_params']) ? $config['raw_params'] : array();
+        foreach ($config['raw_params'] as $name => $val) {
+            $config['params'][$name] = 1;
+        }
+
+        $js_params = Horde_Serialize::serialize($config['params'], Horde_Serialize::JSON);
+
+        foreach ($config['raw_params'] as $name => $val) {
+            $js_params = str_replace('"' . $name . '":1', '"' . $name . '":' . $val, $js_params);
+        }
+
+        Horde::addScriptFile('effects.js', 'horde');
+
+        Horde::addInlineScript((isset($config['var']) ? $config['var'] . ' = ' : '') . 'new ' . $func . '(' . implode(',', $params) . ',' . $js_params . ')', empty($this->_params['no_onload']) ? 'dom' : null);
+    }
+
+    /**
+     * Attach the object to a javascript event.
+     *
+     * @return array  An array with the following elements:
+     * <pre>
+     * ONE of the following:
+     * 'ajax' - (string) Use 'Ajax.Autocompleter' class. Value is the AJAX
+     *          function name.
+     * 'browser' - (string) Use 'Autocompleter.Local' class. Value is the
+     *             javascript list of items to search.
+     * 'pretty' - (string) Use 'PrettyAutocompleter' class. Value is the AJAX
+     *            function name.
+     *
+     * Additional Options:
+     * 'params' - (array) The list of javascript parameters to pass to the
+     *            autocomplete libraries.
+     * 'raw_params' - (array) Adds raw javascript to the 'params' array.
+     * 'var' - (string) If set, the autocomplete object will be assigned to
+     *         this variable.
+     * </pre>
+     */
+    abstract protected function _attach($js_params);
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php b/framework/Core/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php
new file mode 100644 (file)
index 0000000..4b3c592
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Geocode client for the Geonames API.
+ *
+ * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ajax_Imple_Geocoder_Geonames extends Horde_Core_Ajax_Imple
+{
+    /**
+     * Constructor.
+     *
+     * @param array $params  Configuration parameters.
+     * <pre>
+     * 'triggerId' => (string) [optional] TODO
+     * </pre>
+     */
+    public function __construct($params)
+    {
+        parent::__construct($params);
+    }
+
+    /**
+     * Attach the object to a javascript event.
+     */
+    public function attach()
+    {
+    }
+
+    /**
+     * Handle the geocoding request.
+     *
+     * @TODO: For reverse requests come up with a reasonable algorithm for
+     *        checking if we have a lat/lng in the US since the
+     *        findNearestAddress method is US only. If non-us, fallback to a
+     *        findNearest or findPostalcode or similar request. Also will need
+     *        to normalize the various response structures.
+     *
+     * $args['locations'] will trigger a forward geocoding request.
+     * $args['lat'] and $args['lon'] will trigger a reverse geocoding request.
+     *
+     * @see Horde_Core_Ajax_Imple#handle($args, $post)
+     * @throws Horde_Exception
+     */
+    public function handle($args, $post)
+    {
+        if ($args['location']) {
+            $url = new Horde_Url('http://ws.geonames.org/searchJSON');
+            $url = $url->add('q', $args['location']);
+        } elseif (!empty($args['lat']) && !empty($args['lon'])) {
+            $url = new Horde_Url('http:/ws.geonames.org/findNearestJSON');
+            $url = $url->add(array('lat' => $args['lat'], 'lng' => $args['lon']));
+        }
+
+        $client = $GLOBALS['injector']->getInstance('Horde_Http_Client')->getClient();
+        try {
+            $response = $client->get($url);
+        } catch (Horde_Http_Exception $e) {
+            throw new Horde_Exception_Prior($e);
+        }
+
+        return array(
+            'results' => $response->getBody(),
+            'status' => 200
+        );
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php b/framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php
new file mode 100644 (file)
index 0000000..b8177c7
--- /dev/null
@@ -0,0 +1,122 @@
+<?php
+/**
+ * Attach the spellchecker to a javascript element.
+ *
+ * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ajax_Imple_SpellChecker extends Horde_Core_Ajax_Imple
+{
+    /**
+     * Constructor.
+     *
+     * @param array $params  Configuration parameters.
+     * <pre>
+     * 'id' => TODO (optional)
+     * 'locales' => TODO (optional)
+     * 'states' => TODO (optional)
+     * 'targetId' => TODO (optional)
+     * 'triggerId' => TODO (optional)
+     * </pre>
+     */
+    public function __construct($params = array())
+    {
+        if (empty($params['id'])) {
+            $params['id'] = $this->_randomid();
+        }
+
+        if (empty($params['targetId'])) {
+            $params['targetId'] = $this->_randomid();
+        }
+
+        if (empty($params['triggerId'])) {
+            $params['triggerId'] = $params['targetId'] . '_trigger';
+        }
+
+        if (empty($params['locales'])) {
+            $key_list = array_keys($GLOBALS['registry']->nlsconfig['spelling']);
+            asort($key_list, SORT_LOCALE_STRING);
+            $params['locales'] = array();
+
+            foreach ($key_list as $lcode) {
+                $params['locales'][] = array('l' => $GLOBALS['registry']->nlsconfig['languages'][$lcode], 'v' => $lcode);
+            }
+        }
+
+        parent::__construct($params);
+    }
+
+    /**
+     */
+    public function attach()
+    {
+        Horde::addScriptFile('prototype.js', 'horde');
+        Horde::addScriptFile('effects.js', 'horde');
+        Horde::addScriptFile('keynavlist.js', 'horde');
+        Horde::addScriptFile('spellchecker.js', 'horde');
+
+        $opts = array(
+            'locales' => $this->_params['locales'],
+            'sc' => 'widget',
+            'statusButton' => $this->_params['triggerId'],
+            'target' => $this->_params['targetId'],
+            'url' => strval($this->_getUrl('SpellChecker', 'horde', array('input' => $this->_params['targetId'])))
+        );
+        if (isset($this->_params['states'])) {
+            $opts['bs'] = $this->_params['states'];
+        }
+
+        Horde::addInlineScript(array(
+            $this->_params['id'] . ' = new SpellChecker(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')'
+        ), 'dom');
+    }
+
+    /**
+     */
+    public function handle($args, $post)
+    {
+        $spellArgs = array();
+
+        if (!empty($GLOBALS['conf']['spell']['params'])) {
+            $spellArgs = $GLOBALS['conf']['spell']['params'];
+        }
+
+        if (isset($args['locale'])) {
+            $spellArgs['locale'] = $args['locale'];
+        } elseif (isset($GLOBALS['language'])) {
+            $spellArgs['locale'] = $GLOBALS['language'];
+        }
+
+        /* Add local dictionary words. */
+        try {
+            $result = Horde::loadConfiguration('spelling.php', 'ignore_list', 'horde');
+            $spellArgs['localDict'] = $result;
+        } catch (Horde_Exception $e) {}
+
+        if (!empty($args['html'])) {
+            $spellArgs['html'] = true;
+        }
+
+        try {
+            $speller = Horde_SpellChecker::factory($GLOBALS['conf']['spell']['driver'], $spellArgs);
+        } catch (Horde_Exception $e) {
+            Horde::logMessage($e, 'ERR');
+            return array();
+        }
+
+        try {
+            return $speller->spellCheck(Horde_Util::getPost($args['input']));
+        } catch (Horde_Exception $e) {
+            Horde::logMessage($e, 'ERR');
+            return array('bad' => array(), 'suggestions' => array());
+        }
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Binder/Ajax.php b/framework/Core/lib/Horde/Core/Binder/Ajax.php
new file mode 100644 (file)
index 0000000..ce23ee0
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+/**
+ * @category Horde
+ * @package  Core
+ */
+class Horde_Core_Binder_Ajax implements Horde_Injector_Binder
+{
+    public function create(Horde_Injector $injector)
+    {
+        return new Horde_Core_Factory_Ajax($injector);
+    }
+
+    public function equals(Horde_Injector_Binder $binder)
+    {
+        return false;
+    }
+}
diff --git a/framework/Core/lib/Horde/Core/Binder/Imple.php b/framework/Core/lib/Horde/Core/Binder/Imple.php
new file mode 100644 (file)
index 0000000..394c56e
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+/**
+ * @category Horde
+ * @package  Core
+ */
+class Horde_Core_Binder_Imple implements Horde_Injector_Binder
+{
+    public function create(Horde_Injector $injector)
+    {
+        return new Horde_Core_Factory_Imple($injector);
+    }
+
+    public function equals(Horde_Injector_Binder $binder)
+    {
+        return false;
+    }
+}
diff --git a/framework/Core/lib/Horde/Core/Factory/Ajax.php b/framework/Core/lib/Horde/Core/Factory/Ajax.php
new file mode 100644 (file)
index 0000000..daa0aa2
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/**
+ * A Horde_Injector:: based Horde_Core_Ajax_Application:: factory.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  Core
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Core
+ */
+
+/**
+ * A Horde_Injector:: based Horde_Core_Ajax_Application:: factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package  Core
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Core
+ */
+class Horde_Core_Factory_Ajax
+{
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * Return a Horde_Core_Ajax_Application instance.
+     *
+     * @param string $app            The application name.
+     * @param Horde_Variables $vars  Form/request data.
+     * @param string $action         The AJAX action to perform.
+     *
+     * @return Horde_Core_Ajax_Application  The requested instance.
+     * @throws Horde_Exception
+     */
+    public function getAjax($app, $vars, $action = null)
+    {
+        $class = $app . '_Ajax_Application';
+
+        if (class_exists($class)) {
+            return new $class($app, $vars, $action);
+        }
+
+        throw new Horde_Exception('Ajax configuration for ' . $app . ' not found.');
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Factory/Imple.php b/framework/Core/lib/Horde/Core/Factory/Imple.php
new file mode 100644 (file)
index 0000000..c119524
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+/**
+ * A Horde_Injector:: based Horde_Core_Ajax_Imple:: factory.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  Core
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Core
+ */
+
+/**
+ * A Horde_Injector:: based Horde_Core_Ajax_Imple:: factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package  Core
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Core
+ */
+class Horde_Core_Factory_Imple
+{
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * Attempts to return a concrete Imple instance.
+     *
+     * @param mixed $driver  The type of concrete subclass to return. If
+     *                       $driver is an array, then look in
+     *                       $driver[0]/lib/Ajax/Imple for the subclass
+     *                       implementation named $driver[1].php.
+     * @param array $params  A hash containing any additional configuration or
+     *                       parameters a subclass might need.
+     * @param boolean $noattach  Don't attach on creation.
+     *
+     * @return Horde_Core_Ajax_Imple  The newly created instance.
+     * @throws Horde_Exception
+     */
+    public function getImple($driver, array $params = array(),
+                             $noattach = false)
+    {
+        if (is_array($driver)) {
+            list($app, $driv_name) = $driver;
+            $driver = ucfirst(basename($driv_name));
+            $class = ucfirst($app) . '_Ajax_Imple_' . $driver;
+        } else {
+            $driver = basename($driver);
+            $class = 'Horde_Core_Ajax_Imple_' . $driver;
+        }
+
+        if (class_exists($class)) {
+            $ob = new $class($params);
+            if (!$noattach) {
+                $ob->attach();
+            }
+            return $ob;
+        }
+
+        throw new Horde_Exception('Imple driver ' . $driver . ' not found.');
+    }
+
+}
index 394da7b..c753bd7 100644 (file)
@@ -259,6 +259,8 @@ class Horde_Registry
 
         /* Define binders. */
         $binders = array(
+            'Horde_Ajax' => new Horde_Core_Binder_Ajax(),
+            'Horde_Ajax_Imple' => new Horde_Core_Binder_Imple(),
             'Horde_Alarm' => new Horde_Core_Binder_Alarm(),
             'Horde_Auth' => new Horde_Core_Binder_Auth(),
             // 'Horde_Browser' - initialized below
index ac88268..4d72958 100644 (file)
@@ -34,8 +34,8 @@ Application Framework.</description>
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>
-* Import application auth driver from horde/Auth.
+ <notes>* Absorb horde/Ajax package.
+ * Import application auth driver from horde/Auth.
  * Import signup code from horde/Auth.
  * Import Horde backend driver from horde/LoginTasks.
  * Import perms UI handling class from horde/Perms.
@@ -59,6 +59,17 @@ Application Framework.</description>
       <file name="Form.php" role="php" />
      </dir> <!-- /lib/Horde/Config -->
      <dir name="Core">
+      <dir name="Ajax">
+       <dir name="Imple">
+        <file name="AutoCompleter.php" role="php" />
+        <file name="SpellChecker.php" role="php" />
+        <dir name="Geocoder">
+         <file name="Geonames.php" role="php" />
+        </dir> <!-- /lib/Horde/Core/Ajax/Imple/Geocoder -->
+       </dir> <!-- /lib/Horde/Core/Ajax/Imple -->
+       <file name="Application.php" role="php" />
+       <file name="Imple.php" role="php" />
+      </dir> <!-- /lib/Horde/Core/Ajax -->
       <dir name="Auth">
        <dir name="Signup">
         <file name="Base.php" role="php" />
@@ -80,6 +91,7 @@ Application Framework.</description>
        </dir> <!-- /lib/Horde/Core/Autoloader/Callback -->
       </dir> <!-- /lib/Horde/Core/Autoloader -->
       <dir name="Binder">
+       <file name="Ajax.php" role="php" />
        <file name="Alarm.php" role="php" />
        <file name="Auth.php" role="php" />
        <file name="AuthSignup.php" role="php" />
@@ -95,6 +107,7 @@ Application Framework.</description>
        <file name="History.php" role="php" />
        <file name="HttpClient.php" role="php" />
        <file name="Identity.php" role="php" />
+       <file name="Imple.php" role="php" />
        <file name="Ldap.php" role="php" />
        <file name="Lock.php" role="php" />
        <file name="Logger.php" role="php" />
@@ -113,6 +126,7 @@ Application Framework.</description>
        <file name="Vfs.php" role="php" />
       </dir> <!-- /lib/Horde/Core/Binder -->
       <dir name="Factory">
+       <file name="Ajax.php" role="php" />
        <file name="Auth.php" role="php" />
        <file name="Crypt.php" role="php" />
        <file name="Data.php" role="php" />
@@ -121,6 +135,7 @@ Application Framework.</description>
        <file name="Editor.php" role="php" />
        <file name="HttpClient.php" role="php" />
        <file name="Identity.php" role="php" />
+       <file name="Imple.php" role="php" />
        <file name="KolabServer.php" role="php" />
        <file name="KolabSession.php" role="php" />
        <file name="KolabStorage.php" role="php" />
@@ -312,7 +327,11 @@ Application Framework.</description>
    <install as="Horde/Registry.php" name="lib/Horde/Registry.php" />
    <install as="Horde/Themes.php" name="lib/Horde/Themes.php" />
    <install as="Horde/Config/Form.php" name="lib/Horde/Config/Form.php" />
-   <install as="Horde/Core/Autoloader.php" name="lib/Horde/Core/Autoloader.php" />
+   <install as="Horde/Core/Ajax/Imple/AutoCompleter.php" name="lib/Horde/Core/Ajax/Imple/AutoCompleter.php" />
+   <install as="Horde/Core/Ajax/Imple/SpellChecker.php" name="lib/Horde/Core/Ajax/Imple/SpellChecker.php" />
+   <install as="Horde/Core/Ajax/Imple/Geocoder/Geonames.php" name="lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php" />
+   <install as="Horde/Core/Ajax/Application.php" name="lib/Horde/Core/Ajax/Application.php" />
+   <install as="Horde/Core/Ajax/Imple.php" name="lib/Horde/Core/Ajax/Imple.php" />
    <install as="Horde/Core/Auth/Application.php" name="lib/Horde/Core/Auth/Application.php" />
    <install as="Horde/Core/Auth/Ldap.php" name="lib/Horde/Core/Auth/Ldap.php" />
    <install as="Horde/Core/Auth/Msad.php" name="lib/Horde/Core/Auth/Msad.php" />
@@ -325,6 +344,7 @@ Application Framework.</description>
    <install as="Horde/Core/Auth/Signup/SqlObject.php" name="lib/Horde/Core/Auth/Signup/SqlObject.php" />
    <install as="Horde/Core/Autoloader/Callback/Mime.php" name="lib/Horde/Core/Autoloader/Callback/Mime.php" />
    <install as="Horde/Core/Autoloader/Callback/Nls.php" name="lib/Horde/Core/Autoloader/Callback/Nls.php" />
+   <install as="Horde/Core/Binder/Ajax.php" name="lib/Horde/Core/Binder/Ajax.php" />
    <install as="Horde/Core/Binder/Alarm.php" name="lib/Horde/Core/Binder/Alarm.php" />
    <install as="Horde/Core/Binder/Auth.php" name="lib/Horde/Core/Binder/Auth.php" />
    <install as="Horde/Core/Binder/AuthSignup.php" name="lib/Horde/Core/Binder/AuthSignup.php" />
@@ -340,6 +360,7 @@ Application Framework.</description>
    <install as="Horde/Core/Binder/History.php" name="lib/Horde/Core/Binder/History.php" />
    <install as="Horde/Core/Binder/HttpClient.php" name="lib/Horde/Core/Binder/HttpClient.php" />
    <install as="Horde/Core/Binder/Identity.php" name="lib/Horde/Core/Binder/Identity.php" />
+   <install as="Horde/Core/Binder/Imple.php" name="lib/Horde/Core/Binder/Imple.php" />
    <install as="Horde/Core/Binder/Ldap.php" name="lib/Horde/Core/Binder/Ldap.php" />
    <install as="Horde/Core/Binder/Lock.php" name="lib/Horde/Core/Binder/Lock.php" />
    <install as="Horde/Core/Binder/Logger.php" name="lib/Horde/Core/Binder/Logger.php" />
@@ -356,6 +377,7 @@ Application Framework.</description>
    <install as="Horde/Core/Binder/Token.php" name="lib/Horde/Core/Binder/Token.php" />
    <install as="Horde/Core/Binder/Twitter.php" name="lib/Horde/Core/Binder/Twitter.php" />
    <install as="Horde/Core/Binder/Vfs.php" name="lib/Horde/Core/Binder/Vfs.php" />
+   <install as="Horde/Core/Factory/Ajax.php" name="lib/Horde/Core/Factory/Ajax.php" />
    <install as="Horde/Core/Factory/Auth.php" name="lib/Horde/Core/Factory/Auth.php" />
    <install as="Horde/Core/Factory/Crypt.php" name="lib/Horde/Core/Factory/Crypt.php" />
    <install as="Horde/Core/Factory/Data.php" name="lib/Horde/Core/Factory/Data.php" />
@@ -364,6 +386,7 @@ Application Framework.</description>
    <install as="Horde/Core/Factory/Editor.php" name="lib/Horde/Core/Factory/Editor.php" />
    <install as="Horde/Core/Factory/HttpClient.php" name="lib/Horde/Core/Factory/HttpClient.php" />
    <install as="Horde/Core/Factory/Identity.php" name="lib/Horde/Core/Factory/Identity.php" />
+   <install as="Horde/Core/Factory/Imple.php" name="lib/Horde/Core/Factory/Imple.php" />
    <install as="Horde/Core/Factory/KolabServer.php" name="lib/Horde/Core/Factory/KolabServer.php" />
    <install as="Horde/Core/Factory/KolabSession.php" name="lib/Horde/Core/Factory/KolabSession.php" />
    <install as="Horde/Core/Factory/KolabStorage.php" name="lib/Horde/Core/Factory/KolabStorage.php" />
@@ -382,6 +405,7 @@ Application Framework.</description>
    <install as="Horde/Core/Text/Filter/Emoticons.php" name="lib/Horde/Core/Text/Filter/Emoticons.php" />
    <install as="Horde/Core/Tree/Html.php" name="lib/Horde/Core/Tree/Html.php" />
    <install as="Horde/Core/Tree/Javascript.php" name="lib/Horde/Core/Tree/Javascript.php" />
+   <install as="Horde/Core/Autoloader.php" name="lib/Horde/Core/Autoloader.php" />
    <install as="Horde/Exception/HookNotSet.php" name="lib/Horde/Exception/HookNotSet.php" />
    <install as="Horde/Registry/Api.php" name="lib/Horde/Registry/Api.php" />
    <install as="Horde/Registry/Application.php" name="lib/Horde/Registry/Application.php" />
index 6249880..a6797c7 100644 (file)
  *   $vars (Horde_Variables): The URL parameters.
  *
  * The return value from this hook is as follows:
- *   [throw Horde_Ajax_Exception] - Fatal error.
+ *   [throw Horde_Exception] - Fatal error.
  *   [mixed] - The data to send to the browser (will be JSON encoded).
  *
  *
  *   $theme (string): The current theme.
  *
  * The return value from this hook is as follows:
- *   [throw Horde_Ajax_Exception] - Fatal error.
+ *   [throw Horde_Exception] - Fatal error.
  *   [array] - An array of CSS files to add. Keys are the filesystem location,
  *             values are the URI location.
  *
index 62ac807..2d3ef60 100644 (file)
@@ -143,7 +143,7 @@ HordeMap = {
     /**
      * Base Geocoder implementations.
      * The Horde Class will implement a geocoding service utilizing the various
-     * Horde_Ajax_Imple_Geocoder_* classes. Mapping providers that include
+     * Horde_Core_Ajax_Imple_Geocoder_* classes. Mapping providers that include
      * geocoding services will have HordeMap.Geocoder implementations in their
      * respective *.js files.  The Null driver provides fallback implementaions
      * for those without geocoder support.
index 7d48e64..7cadc93 100644 (file)
@@ -37,7 +37,7 @@ try {
     if ($action != 'logOut') {
         /* Handle session timeouts when they come from an AJAX request. */
         if ($e->getCode() == Horde_Registry::AUTH_FAILURE) {
-            $ajax = Horde_Ajax::getInstance($app);
+            $ajax = $injector->getInstance('Horde_Ajax')->getAjax($app, Horde_Variables::getDefaultVariables());
             $notification->push(str_replace('&amp;', '&', $registry->getLogoutUrl(array('reason' => Horde_Auth::REASON_SESSION))), 'horde.ajaxtimeout', array('content.raw'));
             Horde::sendHTTPResponse(Horde::prepareResponse(null, $ajax->notify), $ajax->responseType());
             exit;
@@ -51,7 +51,7 @@ try {
 // encoding.
 ob_start();
 
-$ajax = Horde_Ajax::getInstance($app, $action);
+$ajax = $injector->getInstance('Horde_Ajax')->getAjax($app, Horde_Variables::getDefaultVariables(), $action);
 try {
     $result = $ajax->doAction();
 } catch (Exception $e) {
index 8983470..db96e87 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Handle Horde_Ajax_Imple:: requests.
+ * Handle Horde_Core_Ajax_Imple:: requests.
  *
  * Mandatory components:
  * 'imple'
@@ -65,7 +65,7 @@ if (isset($args['impleApp'])) {
     $impleargs = array($args['impleApp'], $impleName);
 }
 
-$imple = Horde_Ajax_Imple::factory($impleargs);
+$imple = $injector->getInstance('Horde_Ajax_Imple')->getImple($impleargs);
 $result = $imple->handle($args, $post);
 
 $ct = empty($_SERVER['Content-Type'])
index 55bd375..21a4f5e 100644 (file)
@@ -121,7 +121,7 @@ class IMP_Hooks
      * @param Horde_Variables $vars  The URL parameters.
      *
      * @return mixed  The data to send to the browser (will be JSON encoded).
-     * @throws Horde_Ajax_Exception
+     * @throws Horde_Exception
      */
 //     public function ajaxaction($action, $vars)
 //     {
@@ -130,7 +130,7 @@ class IMP_Hooks
 //            return 'bar';
 //        }
 //
-//        throw new Horde_Ajax_Exception('Unknown action');
+//        throw new Horde_Exception('Unknown action');
 //     }
 
 
index 5a51f82..8e25675 100644 (file)
@@ -12,7 +12,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Ajax_Application extends Horde_Ajax_Application_Base
+class IMP_Ajax_Application extends Horde_Core_Ajax_Application
 {
     /**
      * Determines if notification information is sent in response.
index 373b658..5763af4 100644 (file)
@@ -12,7 +12,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_AutoCompleter
+class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Core_Ajax_Imple_AutoCompleter
 {
     /**
      * Has the address book been output to the browser?
index 9929097..9706ff1 100644 (file)
@@ -12,7 +12,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Ajax_Imple_PassphraseDialog extends Horde_Ajax_Imple_Base
+class IMP_Ajax_Imple_PassphraseDialog extends Horde_Core_Ajax_Imple
 {
     /**
      * Passphrase DOM ID counter.
index cc7ce44..20c47b5 100644 (file)
@@ -205,8 +205,12 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
 
                     /* Ask for the correct passphrase if this is encrypted
                      * symmetrically. */
-                    $imple = Horde_Ajax_Imple::factory(array('imp', 'PassphraseDialog'), array('params' => array('symmetricid' => $symmetric_id), 'type' => 'pgpSymmetric'));
-                    $imple->attach();
+                    $imple = $GLOBALS['registry']->getInstance('Horde_Ajax_Imple')->getImple(array('imp', 'PassphraseDialog'), array(
+                        'params' => array(
+                            'symmetricid' => $symmetric_id
+                        ),
+                        'type' => 'pgpSymmetric'
+                    ));
                     $status[] = Horde::link('#', '', '', '', '', '', '', array('id' => $imple->getPassphraseId())) . _("You must enter the passphrase used to encrypt this message to view it.") . '</a>';
                     return null;
                 }
@@ -236,8 +240,9 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
                     if (is_null($personal_pass)) {
                         /* Ask for the private key's passphrase if this is
                          * encrypted asymmetrically. */
-                        $imple = Horde_Ajax_Imple::factory(array('imp', 'PassphraseDialog'), array('type' => 'pgpPersonal'));
-                        $imple->attach();
+                        $imple = $GLOBALS['registry']->getInstance('Horde_Ajax_Imple')->getImple(array('imp', 'PassphraseDialog'), array(
+                            'type' => 'pgpPersonal'
+                        ));
                         $status[] = Horde::link('#', '', '', '', '', '', '', array('id' => $imple->getPassphraseId())) . _("You must enter the passphrase for your PGP private key to view this message.") . '</a>';
                         return null;
                     }
index ac17474..30272d2 100644 (file)
@@ -197,8 +197,9 @@ class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Driver
         /* Make sure we have a passphrase. */
         $passphrase = $this->_impsmime->getPassphrase();
         if (is_null($passphrase)) {
-            $imple = Horde_Ajax_Imple::factory(array('imp', 'PassphraseDialog'), array('type' => 'smimePersonal'));
-            $imple->attach();
+            $imple = $GLOBALS['registry']->getInstance('Horde_Ajax_Imple')->getImple(array('imp', 'PassphraseDialog'), array(
+                'type' => 'smimePersonal'
+            ));
             $status[] = Horde::link('#', '', '', '', '', '', '', array('id' => $imple->getPassphraseId())) . _("You must enter the passphrase for your S/MIME private key to view this data.") . '</a>';
             return null;
         }
index 719a9c1..a3f11a7 100644 (file)
@@ -1029,8 +1029,9 @@ class IMP_Prefs_Ui
                 $t->set('sendkey', Horde::link($ui->selfUrl(array('special' => true))->add('send_pgp_key', 1), _("Send Key to Public Keyserver")));
                 $t->set('personalkey-public-help', Horde_Help::link('imp', 'pgp-personalkey-public'));
 
-                $imple = Horde_Ajax_Imple::factory(array('imp', 'PassphraseDialog'), array('type' => 'pgpPersonal'));
-                $imple->attach();
+                $imple = $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('imp', 'PassphraseDialog'), array(
+                    'type' => 'pgpPersonal'
+                ));
 
                 $imp_pgp = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp');
                 $passphrase = $imp_pgp->getPassphrase('personal');
@@ -1276,8 +1277,9 @@ class IMP_Prefs_Ui
                 $t->set('viewpublic', Horde::link($smime_url->copy()->add('actionID', 'view_personal_public_key'), _("View Personal Public Certificate"), null, 'view_key'));
                 $t->set('infopublic', Horde::link($smime_url->copy()->add('actionID', 'info_personal_public_key'), _("Information on Personal Public Certificate"), null, 'info_key'));
 
-                $imple = Horde_Ajax_Imple::factory(array('imp', 'PassphraseDialog'), array('type' => 'smimePersonal'));
-                $imple->attach();
+                $imple = $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('imp', 'PassphraseDialog'), array(
+                    'type' => 'smimePersonal'
+                ));
 
                 $imp_smime = $GLOBALS['injector']->getInstance('IMP_Crypt_Smime');
                 $passphrase = $imp_smime->getPassphrase();
index e107267..4088840 100644 (file)
@@ -74,7 +74,7 @@ class IMP_Ui_Compose
     {
         /* Attach autocompleters to the compose form elements. */
         foreach ($fields as $val) {
-            Horde_Ajax_Imple::factory(array('imp', 'ContactAutoCompleter'), array('triggerId' => $val))->attach();
+            $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('imp', 'ContactAutoCompleter'), array('triggerId' => $val));
         }
     }
 
@@ -106,7 +106,7 @@ class IMP_Ui_Compose
             )
         );
 
-        Horde_Ajax_Imple::factory('SpellChecker', $args)->attach();
+        $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple('SpellChecker', $args);
     }
 
     /**
@@ -271,7 +271,11 @@ class IMP_Ui_Compose
             break;
         }
 
-        Horde_Ajax_Imple::factory(array('imp', 'PassphraseDialog'), array('onload' => true, 'params' => $params, 'type' => $type))->attach();
+        $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('imp', 'PassphraseDialog'), array(
+            'onload' => true,
+            'params' => $params,
+            'type' => $type
+        ));
     }
 
     /**
index 3cee261..6ba870a 100644 (file)
@@ -263,8 +263,9 @@ $end =  new Horde_Date(Horde_Util::getFormData('enddate', date('Ymd') . '000000'
 $vfb_html = $attendee_view->render($date);
 
 // Add the ContactAutoCompleter
-$cac = Horde_Ajax_Imple::factory(array('kronolith', 'ContactAutoCompleter'), array('triggerId' => 'newAttendees'));
-$cac->attach();
+$injector->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'ContactAutoCompleter'), array(
+    'triggerId' => 'newAttendees'
+));
 
 $title = _("Edit attendees");
 require KRONOLITH_TEMPLATES . '/common-header.inc';
index 3f7966d..a3cebd5 100644 (file)
@@ -59,9 +59,12 @@ $tagger = Kronolith::getTagger();
 $vars->set('tags', implode(',', array_values($tagger->getTags($calendar->getName(), 'calendar'))));
 $vars->set('system', is_null($calendar->get('owner')));
 $title = $form->getTitle();
+
+$injector->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'TagAutoCompleter'), array(
+    'triggerId' => 'tags'
+));
+
 require KRONOLITH_TEMPLATES . '/common-header.inc';
 require KRONOLITH_TEMPLATES . '/menu.inc';
 echo $form->renderActive($form->getRenderer(), $vars, 'edit.php', 'post');
 require $registry->get('templates', 'horde') . '/common-footer.inc';
-$ac = Horde_Ajax_Imple::factory(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'tags', 'id'));
-$ac->attach();
index a6e89ee..a6b01f8 100644 (file)
@@ -20,7 +20,7 @@ class Kronolith_Hooks
      * @param Horde_Variables $vars  The URL parameters.
      *
      * @return mixed  The data to send to the browser (will be JSON encoded).
-     * @throws Horde_Ajax_Exception
+     * @throws Horde_Exception
      */
 //     public function ajaxaction($action, $vars)
 //     {
@@ -29,7 +29,7 @@ class Kronolith_Hooks
 //            return 'bar';
 //        }
 //
-//        throw new Horde_Ajax_Exception('Unknown action');
+//        throw new Horde_Exception('Unknown action');
 //     }
 
     /**
index 683a49d..daee5c6 100644 (file)
@@ -95,33 +95,39 @@ foreach ($injector->getInstance('Horde_Alarm')->handlers() as $method => $handle
     $taskAlarmParams = substr($taskAlarmParams, 0, - 6) . '</div>';
 }
 
-Horde_Ajax_Imple::factory(
+$injector->getInstance('Horde_Ajax_Imple')->getImple(
     array('kronolith', 'TagAutoCompleter'),
-    array('triggerId' => 'kronolithEventTags',
-          'box' => 'kronolithEventACBox',
-          'pretty' => true,
-          'var' => 'KronolithCore.eventTagAc'))
-    ->attach();
+    array(
+        'box' => 'kronolithEventACBox',
+        'pretty' => true,
+        'triggerId' => 'kronolithEventTags',
+        'var' => 'KronolithCore.eventTagAc'
+    )
+);
 
-Horde_Ajax_Imple::factory(
+$injector->getInstance('Horde_Ajax_Imple')->getImple(
     array('kronolith', 'TagAutoCompleter'),
-    array('triggerId' => 'kronolithCalendarinternalTags',
-          'triggerContainer' => 'kronolithACCalendarTriggerContainer',
-          'box' => 'kronolithCalendarinternalACBox',
-          'pretty' => true,
-          'var' => 'KronolithCore.calendarTagAc'))
-    ->attach();
+    array(
+        'box' => 'kronolithCalendarinternalACBox',
+        'pretty' => true,
+        'triggerContainer' => 'kronolithACCalendarTriggerContainer',
+        'triggerId' => 'kronolithCalendarinternalTags',
+        'var' => 'KronolithCore.calendarTagAc'
+    )
+);
 
-Horde_Ajax_Imple::factory(
+$injector->getInstance('Horde_Ajax_Imple')->getImple(
     array('kronolith', 'ContactAutoCompleter'),
-    array('triggerId' => 'kronolithEventAttendees',
-          'triggerContainer' => 'kronolithAttendeesACTriggerContainer',
-          'box' => 'kronolithAttendeesACBox',
-          'pretty' => true,
-          'var' => 'KronolithCore.attendeesAc',
-          'onAdd' => 'KronolithCore.addAttendee.bind(KronolithCore)',
-          'onRemove' => 'KronolithCore.removeAttendee.bind(KronolithCore)'))
-    ->attach();
+    array(
+        'box' => 'kronolithAttendeesACBox',
+        'onAdd' => 'KronolithCore.addAttendee.bind(KronolithCore)',
+        'onRemove' => 'KronolithCore.removeAttendee.bind(KronolithCore)',
+        'pretty' => true,
+        'triggerContainer' => 'kronolithAttendeesACTriggerContainer',
+        'triggerId' => 'kronolithEventAttendees',
+        'var' => 'KronolithCore.attendeesAc'
+    )
+);
 
 if ($conf['maps']['driver']) {
     Kronolith::initEventMap($conf['maps']);
index a9356b6..8acbc32 100644 (file)
@@ -12,7 +12,7 @@
  * @author  Gonçalo Queirós <mail@goncaloqueiros.net>
  * @package Kronolith
  */
-class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
+class Kronolith_Ajax_Application extends Horde_Core_Ajax_Application
 {
     /**
      * Determines if notification information is sent in response.
index d385fa7..1f7299e 100644 (file)
  * @author  Michael Slusarz <slusarz@horde.org>
  * @package Kronolith
  */
-class Kronolith_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_AutoCompleter
+class Kronolith_Ajax_Imple_ContactAutoCompleter extends Horde_Core_Ajax_Imple_AutoCompleter
 {
     /**
      * Attach the Imple object to a javascript event.
      *
-     * @param array $js_params  See Horde_Ajax_Imple_AutoCompleter::_attach().
+     * @param array $js_params  See
+     *                          Horde_Core_Ajax_Imple_AutoCompleter::_attach().
      *
-     * @return array  See Horde_Ajax_Imple_AutoCompleter::_attach().
+     * @return array  See Horde_Core_Ajax_Imple_AutoCompleter::_attach().
      */
     protected function _attach($js_params)
     {
index 438f032..d515843 100644 (file)
@@ -9,7 +9,7 @@
  * @author  Michael J. Rubinsky <mrubinsk@horde.org>
  * @package Kronolith
  */
-class Kronolith_Ajax_Imple_Embed extends Horde_Ajax_Imple_Base
+class Kronolith_Ajax_Imple_Embed extends Horde_Core_Ajax_Imple
 {
     /**
      */
index 4580d5a..3cbe16b 100644 (file)
@@ -8,7 +8,7 @@
  * @author  Michael J. Rubinsky <mrubinsk@horde.org>
  * @package Kronolith
  */
-class Kronolith_Ajax_Imple_TagActions extends Horde_Ajax_Imple_Base
+class Kronolith_Ajax_Imple_TagActions extends Horde_Core_Ajax_Imple
 {
     /**
      */
index db30ff5..ddcbe9d 100644 (file)
@@ -8,16 +8,17 @@
  * @author  Michael Slusarz <slusarz@horde.org>
  * @package Kronolith
  */
-class Kronolith_Ajax_Imple_TagAutoCompleter extends Horde_Ajax_Imple_AutoCompleter
+class Kronolith_Ajax_Imple_TagAutoCompleter extends Horde_Core_Ajax_Imple_AutoCompleter
 {
     /**
      * Attach the Imple object to a javascript event.
      * If the 'pretty' parameter is empty then we want a
      * traditional autocompleter, otherwise we get a spiffy pretty one.
      *
-     * @param array $js_params  See Horde_Ajax_Imple_AutoCompleter::_attach().
+     * @param array $js_params  See
+     *                          Horde_Core_Ajax_Imple_AutoCompleter::_attach().
      *
-     * @return array  See Horde_Ajax_Imple_AutoCompleter::_attach().
+     * @return array  See Horde_Core_Ajax_Imple_AutoCompleter::_attach().
      */
     protected function _attach($js_params)
     {
index 2e8c9c2..4101611 100644 (file)
@@ -2011,15 +2011,13 @@ class Kronolith
     public static function embedCode($calendar)
     {
         /* Get the base url */
-        $imple = Horde_Ajax_Imple::factory(array('kronolith', 'Embed'),
-                                           array('container' => 'kronolithCal',
-                                                 'view' => 'month',
-                                                 'calendar' => $calendar));
+        $imple = $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'Embed'), array(
+            'calendar' => $calendar,
+            'container' => 'kronolithCal',
+            'view' => 'month'
+        ), true);
 
-
-        $url = $imple->getUrl();
-
-        $html = '<div id="kronolithCal"></div><script src="' . $url
+        $html = '<div id="kronolithCal"></div><script src="' . $imple->getUrl()
             . '" type="text/javascript"></script>';
 
         return $html;
index 2dfa126..fbb1124 100644 (file)
@@ -408,9 +408,7 @@ endif;
  <td colspan="4">
    <input type="text" name="tags" id="tags" value="<?php echo (!empty($tags) ? htmlspecialchars($tags) : '')?>" size="40" />
    <span id="tags_loading_img" style="display:none;"><?php echo Horde::img('loading.gif', _("Loading...")) ?></span>
-   <?php $tac = Horde_Ajax_Imple::factory(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'tags', 'id' => $event->uid));
-         $tac->attach();
-   ?>
+   <?php $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'tags', 'id' => $event->uid)); ?>
  </td>
 </tr>
 <!-- spacer -->
index b41e408..1a00681 100644 (file)
@@ -92,13 +92,13 @@ if ($cal->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
         . Horde::img('delete-small.png', _("Remove Tag"))
         . '</a>';
 }
-$ta = Horde_Ajax_Imple::factory(array('kronolith', 'TagActions'),
-                                array('triggerId' => 'remove' . md5($id . $tag_id),
-                                      'action' => 'delete',
-                                      'resource' => $id,
-                                      'type' => 'calendar',
-                                      'tagId' => $tag_id));
-$ta->attach();
+$GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'TagActions'), array(
+    'action' => 'delete',
+    'resource' => $id,
+    'tagId' => $tag_id,
+    'triggerId' => 'remove' . md5($id . $tag_id),
+    'type' => 'calendar'
+));
 ?>
         </li>
         <?php endforeach;?>
@@ -107,14 +107,16 @@ $ta->attach();
       <input type="text" name="newtags-input_<?php echo $id?>" id="newtags-input_<?php echo $id?>" size="10" /><input type="button" class="button" value="add" name="newtags-button_<?php echo $id?>" id="newtags-button_<?php echo $id?>" />
       <span id="newtags-input_<?php echo $id?>_loading_img" style="display:none;"><?php echo Horde::img('loading.gif', _("Loading...")) ?></span>
      <?php
-      $tac = Horde_Ajax_Imple::factory(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'newtags-input_' . $id, 'id' => $id));
-      $tac->attach();
-      $ta = Horde_Ajax_Imple::factory(array('kronolith', 'TagActions'),
-                                          array('triggerId' => 'newtags-button',
-                                                'resource' => $id,
-                                                'type' => 'calendar',
-                                                'action' => 'add'));
-      $ta->attach();
+      $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'TagAutoCompleter'), array(
+          'id' => $id,
+          'triggerId' => 'newtags-input_' . $id
+      ));
+      $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'TagActions'), array(
+          'action' => 'add',
+          'resource' => $id,
+          'triggerId' => 'newtags-button',
+          'type' => 'calendar'
+      ));
       ?>
   </div>
   </div>
index 10ed5e7..22a91d9 100644 (file)
@@ -11,7 +11,7 @@
  * @author  Ben Klang <ben@alkaloid.net>
  * @package Shout
  */
-class Shout_Ajax_Application extends Horde_Ajax_Application_Base
+class Shout_Ajax_Application extends Horde_Core_Ajax_Application
 {
     protected $_responseType = 'json';
     /**
index 9699a8b..37957d8 100644 (file)
@@ -9,7 +9,7 @@
  * @package Whups
  */
 
-class Whups_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_AutoCompleter
+class Whups_Ajax_Imple_ContactAutoCompleter extends Horde_Core_Ajax_Imple_AutoCompleter
 {
 
     /**
index 87da5d4..725c36a 100644 (file)
@@ -25,8 +25,10 @@ class Horde_Ui_VarRenderer_whups extends Horde_Ui_VarRenderer_Html {
     {
         $name = $var->getVarName();
 
-        $imple = Horde_Ajax_Imple::factory(array('whups', 'ContactAutoCompleter'), array('triggerId' => $name));
-        $imple->attach();
+        $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('whups', 'ContactAutoCompleter'), array(
+            'triggerId' => $name
+        ));
+
         return sprintf('<input type="text" name="%s" id="%s" value="%s" autocomplete="off"%s />',
                        $name,
                        $name,