From e149c7180ec549934c1f63334a466addd41710fb Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 14 Jul 2010 16:52:45 -0600 Subject: [PATCH] Merge horde/Ajax into horde/Core. 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). --- ansel/gallery.php | 8 +- ansel/lib/Ajax/Imple/EditCaption.php | 2 +- ansel/lib/Ajax/Imple/EditFaces.php | 2 +- ansel/lib/Ajax/Imple/Embed.php | 2 +- ansel/lib/Ajax/Imple/GallerySlugCheck.php | 2 +- ansel/lib/Ajax/Imple/ImageSaveGeotag.php | 2 +- ansel/lib/Ajax/Imple/LocationAutoCompleter.php | 2 +- ansel/lib/Ajax/Imple/TagActions.php | 2 +- ansel/lib/Ajax/Imple/ToggleGalleryActions.php | 2 +- ansel/lib/Ajax/Imple/ToggleOtherGalleries.php | 2 +- ansel/lib/Ansel.php | 5 +- ansel/lib/Tile/Image.php | 8 +- ansel/lib/View/Image.php | 10 +-- ansel/lib/Widget/Actions.php | 5 +- ansel/lib/Widget/Geotag.php | 2 +- ansel/lib/Widget/ImageFaces.php | 12 ++- ansel/lib/Widget/OtherGalleries.php | 5 +- ansel/lib/Widget/Tags.php | 10 +-- ansel/map_edit.php | 12 +-- framework/Ajax/lib/Horde/Ajax.php | 36 -------- framework/Ajax/lib/Horde/Ajax/Exception.php | 16 ---- framework/Ajax/lib/Horde/Ajax/Imple.php | 47 ----------- framework/Ajax/package.xml | 96 ---------------------- framework/Core/lib/Horde.php | 54 +++++++----- .../lib/Horde/Core/Ajax/Application.php} | 28 ++++--- .../lib/Horde/Core/Ajax/Imple.php} | 15 ++-- .../lib/Horde/Core}/Ajax/Imple/AutoCompleter.php | 12 +-- .../Horde/Core}/Ajax/Imple/Geocoder/Geonames.php | 25 +++--- .../lib/Horde/Core}/Ajax/Imple/SpellChecker.php | 12 +-- framework/Core/lib/Horde/Core/Binder/Ajax.php | 17 ++++ framework/Core/lib/Horde/Core/Binder/Imple.php | 17 ++++ framework/Core/lib/Horde/Core/Factory/Ajax.php | 68 +++++++++++++++ framework/Core/lib/Horde/Core/Factory/Imple.php | 84 +++++++++++++++++++ framework/Core/lib/Horde/Registry.php | 2 + framework/Core/package.xml | 30 ++++++- horde/config/hooks.php.dist | 4 +- horde/js/hordemap/map.js | 2 +- horde/services/ajax.php | 4 +- horde/services/imple.php | 4 +- imp/config/hooks.php.dist | 4 +- imp/lib/Ajax/Application.php | 2 +- imp/lib/Ajax/Imple/ContactAutoCompleter.php | 2 +- imp/lib/Ajax/Imple/PassphraseDialog.php | 2 +- imp/lib/Mime/Viewer/Pgp.php | 13 ++- imp/lib/Mime/Viewer/Smime.php | 5 +- imp/lib/Prefs/Ui.php | 10 ++- imp/lib/Ui/Compose.php | 10 ++- kronolith/attendees.php | 5 +- kronolith/calendars/edit.php | 7 +- kronolith/config/hooks.php.dist | 4 +- kronolith/index.php | 50 ++++++----- kronolith/lib/Ajax/Application.php | 2 +- kronolith/lib/Ajax/Imple/ContactAutoCompleter.php | 7 +- kronolith/lib/Ajax/Imple/Embed.php | 2 +- kronolith/lib/Ajax/Imple/TagActions.php | 2 +- kronolith/lib/Ajax/Imple/TagAutoCompleter.php | 7 +- kronolith/lib/Kronolith.php | 14 ++-- kronolith/templates/edit/edit.inc | 4 +- kronolith/templates/panel.inc | 32 ++++---- shout/lib/Ajax/Application.php | 2 +- whups/lib/Ajax/Imple/ContactAutoCompleter.php | 2 +- whups/lib/Forms/VarRenderer.php | 6 +- 62 files changed, 464 insertions(+), 398 deletions(-) delete mode 100644 framework/Ajax/lib/Horde/Ajax.php delete mode 100644 framework/Ajax/lib/Horde/Ajax/Exception.php delete mode 100644 framework/Ajax/lib/Horde/Ajax/Imple.php delete mode 100644 framework/Ajax/package.xml rename framework/{Ajax/lib/Horde/Ajax/Application/Base.php => Core/lib/Horde/Core/Ajax/Application.php} (85%) rename framework/{Ajax/lib/Horde/Ajax/Imple/Base.php => Core/lib/Horde/Core/Ajax/Imple.php} (76%) rename framework/{Ajax/lib/Horde => Core/lib/Horde/Core}/Ajax/Imple/AutoCompleter.php (92%) rename framework/{Ajax/lib/Horde => Core/lib/Horde/Core}/Ajax/Imple/Geocoder/Geonames.php (73%) rename framework/{Ajax/lib/Horde => Core/lib/Horde/Core}/Ajax/Imple/SpellChecker.php (90%) create mode 100644 framework/Core/lib/Horde/Core/Binder/Ajax.php create mode 100644 framework/Core/lib/Horde/Core/Binder/Imple.php create mode 100644 framework/Core/lib/Horde/Core/Factory/Ajax.php create mode 100644 framework/Core/lib/Horde/Core/Factory/Imple.php diff --git a/ansel/gallery.php b/ansel/gallery.php index 33cc2280a..aca84e3cd 100644 --- a/ansel/gallery.php +++ b/ansel/gallery.php @@ -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'; diff --git a/ansel/lib/Ajax/Imple/EditCaption.php b/ansel/lib/Ajax/Imple/EditCaption.php index b9489ca75..65f2e5da1 100644 --- a/ansel/lib/Ajax/Imple/EditCaption.php +++ b/ansel/lib/Ajax/Imple/EditCaption.php @@ -8,7 +8,7 @@ * @author Michael J. Rubinsky * @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) { diff --git a/ansel/lib/Ajax/Imple/EditFaces.php b/ansel/lib/Ajax/Imple/EditFaces.php index 0a08d86e3..4d0fc1ab0 100644 --- a/ansel/lib/Ajax/Imple/EditFaces.php +++ b/ansel/lib/Ajax/Imple/EditFaces.php @@ -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 diff --git a/ansel/lib/Ajax/Imple/Embed.php b/ansel/lib/Ajax/Imple/Embed.php index 81d8885e1..5ec925861 100644 --- a/ansel/lib/Ajax/Imple/Embed.php +++ b/ansel/lib/Ajax/Imple/Embed.php @@ -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(){} diff --git a/ansel/lib/Ajax/Imple/GallerySlugCheck.php b/ansel/lib/Ajax/Imple/GallerySlugCheck.php index 14e88781e..55ccabbe2 100644 --- a/ansel/lib/Ajax/Imple/GallerySlugCheck.php +++ b/ansel/lib/Ajax/Imple/GallerySlugCheck.php @@ -8,7 +8,7 @@ * @author Michael J. Rubinsky * @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() { diff --git a/ansel/lib/Ajax/Imple/ImageSaveGeotag.php b/ansel/lib/Ajax/Imple/ImageSaveGeotag.php index 4159134e3..6bc331830 100644 --- a/ansel/lib/Ajax/Imple/ImageSaveGeotag.php +++ b/ansel/lib/Ajax/Imple/ImageSaveGeotag.php @@ -11,7 +11,7 @@ * @author Michael J. Rubinsky * @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() {} diff --git a/ansel/lib/Ajax/Imple/LocationAutoCompleter.php b/ansel/lib/Ajax/Imple/LocationAutoCompleter.php index 682fe780d..31a9b98ad 100644 --- a/ansel/lib/Ajax/Imple/LocationAutoCompleter.php +++ b/ansel/lib/Ajax/Imple/LocationAutoCompleter.php @@ -10,7 +10,7 @@ * @author Michael J. Rubinsky * @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) { diff --git a/ansel/lib/Ajax/Imple/TagActions.php b/ansel/lib/Ajax/Imple/TagActions.php index cf2387555..69b08fa33 100644 --- a/ansel/lib/Ajax/Imple/TagActions.php +++ b/ansel/lib/Ajax/Imple/TagActions.php @@ -8,7 +8,7 @@ * @author Michael J. Rubinsky * @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() { diff --git a/ansel/lib/Ajax/Imple/ToggleGalleryActions.php b/ansel/lib/Ajax/Imple/ToggleGalleryActions.php index 4e3230d22..b96d9d30f 100644 --- a/ansel/lib/Ajax/Imple/ToggleGalleryActions.php +++ b/ansel/lib/Ajax/Imple/ToggleGalleryActions.php @@ -8,7 +8,7 @@ * @author Michael J. Rubinsky * @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() { diff --git a/ansel/lib/Ajax/Imple/ToggleOtherGalleries.php b/ansel/lib/Ajax/Imple/ToggleOtherGalleries.php index ec95d2b35..fb9e83970 100644 --- a/ansel/lib/Ajax/Imple/ToggleOtherGalleries.php +++ b/ansel/lib/Ajax/Imple/ToggleOtherGalleries.php @@ -8,7 +8,7 @@ * @author Michael J. Rubinsky * @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() { diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index cf34ee857..da244aab9 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -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 '
'; + return '
'; } } diff --git a/ansel/lib/Tile/Image.php b/ansel/lib/Tile/Image.php index 9df76c93a..179254d2b 100644 --- a/ansel/lib/Tile/Image.php +++ b/ansel/lib/Tile/Image.php @@ -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'; diff --git a/ansel/lib/View/Image.php b/ansel/lib/View/Image.php index 5fd8cbec9..d961f77e3 100644 --- a/ansel/lib/View/Image.php +++ b/ansel/lib/View/Image.php @@ -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 + )); } } diff --git a/ansel/lib/Widget/Actions.php b/ansel/lib/Widget/Actions.php index 69dd380da..bcaa42c9d 100644 --- a/ansel/lib/Widget/Actions.php +++ b/ansel/lib/Widget/Actions.php @@ -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 */ diff --git a/ansel/lib/Widget/Geotag.php b/ansel/lib/Widget/Geotag.php index ee3cfe799..4f7da3288 100644 --- a/ansel/lib/Widget/Geotag.php +++ b/ansel/lib/Widget/Geotag.php @@ -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); diff --git a/ansel/lib/Widget/ImageFaces.php b/ansel/lib/Widget/ImageFaces.php index ed102d087..e585d1de3 100644 --- a/ansel/lib/Widget/ImageFaces.php +++ b/ansel/lib/Widget/ImageFaces.php @@ -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(); } diff --git a/ansel/lib/Widget/OtherGalleries.php b/ansel/lib/Widget/OtherGalleries.php index 7396fcc17..1b7d233e3 100644 --- a/ansel/lib/Widget/OtherGalleries.php +++ b/ansel/lib/Widget/OtherGalleries.php @@ -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(); diff --git a/ansel/lib/Widget/Tags.php b/ansel/lib/Widget/Tags.php index 483840aec..dc8cfbf39 100644 --- a/ansel/lib/Widget/Tags.php +++ b/ansel/lib/Widget/Tags.php @@ -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( diff --git a/ansel/map_edit.php b/ansel/map_edit.php index 9e4806d02..286ee085e 100644 --- a/ansel/map_edit.php +++ b/ansel/map_edit.php @@ -66,7 +66,7 @@ $returnLink = Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => $gallery->id)); $image_tag = '[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; /* 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 index 0bb768440..000000000 --- a/framework/Ajax/lib/Horde/Ajax.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @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/Exception.php b/framework/Ajax/lib/Horde/Ajax/Exception.php deleted file mode 100644 index b6ca2921f..000000000 --- a/framework/Ajax/lib/Horde/Ajax/Exception.php +++ /dev/null @@ -1,16 +0,0 @@ - - * @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 index 68730f9c7..000000000 --- a/framework/Ajax/lib/Horde/Ajax/Imple.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @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/package.xml b/framework/Ajax/package.xml deleted file mode 100644 index 02fabc68b..000000000 --- a/framework/Ajax/package.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - Ajax - pear.horde.org - Horde Ajax utilities - This package provides utilities to aid with using AJAX with Horde applications. - - - Michael Slusarz - slusarz - slusarz@horde.org - yes - - 2009-07-16 - - 0.1.0 - 0.1.0 - - - beta - beta - - LGPL - * Add Application framework. - * Add AutoCompleter driver. - * Initial release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5.2.0 - - - 1.7.0 - - - Core - pear.horde.org - - - Util - pear.horde.org - - - - - SpellChecker - pear.horde.org - - - Serialize - pear.horde.org - - - - - - - - - - - - - - - - - diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index ee86ca397..6cfe9f418 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -448,9 +448,19 @@ HTML; * * @param string $type The service to display. *
-     * 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'
      * 
* @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/Ajax/lib/Horde/Ajax/Application/Base.php b/framework/Core/lib/Horde/Core/Ajax/Application.php similarity index 85% rename from framework/Ajax/lib/Horde/Ajax/Application/Base.php rename to framework/Core/lib/Horde/Core/Ajax/Application.php index a84aaee63..4f25e8393 100644 --- a/framework/Ajax/lib/Horde/Ajax/Application/Base.php +++ b/framework/Core/lib/Horde/Core/Ajax/Application.php @@ -4,13 +4,15 @@ * * 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. + * 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 - * @package Horde_Ajax + * @author Michael Slusarz + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Core */ -abstract class Horde_Ajax_Application_Base +abstract class Horde_Core_Ajax_Application { /** * Determines if notification information is sent in response. @@ -58,12 +60,14 @@ abstract class Horde_Ajax_Application_Base /** * Constructor. * - * @param string $app The application name. - * @param string $action The AJAX action to perform. + * @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, $action = null) + 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. */ @@ -79,7 +83,7 @@ abstract class Horde_Ajax_Application_Base * Performs the AJAX action. * * @return mixed The result of the action call. - * @throws Horde_Ajax_Exception + * @throws Horde_Exception */ public function doAction() { @@ -87,8 +91,6 @@ abstract class Horde_Ajax_Application_Base return false; } - $this->_vars = Horde_Variables::getDefaultVariables(); - if (method_exists($this, $this->_action)) { return call_user_func(array($this, $this->_action)); } @@ -97,9 +99,9 @@ abstract class Horde_Ajax_Application_Base try { return Horde::callHook('ajaxaction', array($this->_action, $this->_vars), $this->_app); } catch (Horde_Exception_HookNotSet $e) { - } catch (Horde_Ajax_Exception $e) {} + } catch (Horde_Exception $e) {} - throw new Horde_Ajax_Exception('Handler for action "' . $this->_action . '" does not exist.'); + throw new Horde_Exception('Handler for action "' . $this->_action . '" does not exist.'); } /** diff --git a/framework/Ajax/lib/Horde/Ajax/Imple/Base.php b/framework/Core/lib/Horde/Core/Ajax/Imple.php similarity index 76% rename from framework/Ajax/lib/Horde/Ajax/Imple/Base.php rename to framework/Core/lib/Horde/Core/Ajax/Imple.php index ee14297cf..71a864a22 100644 --- a/framework/Ajax/lib/Horde/Ajax/Imple/Base.php +++ b/framework/Core/lib/Horde/Core/Ajax/Imple.php @@ -4,13 +4,15 @@ * * 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. + * 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 - * @package Horde_Ajax + * @author Michael Slusarz + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Core */ -abstract class Horde_Ajax_Imple_Base +abstract class Horde_Core_Ajax_Imple { /** * Parameters needed by the subclasses. @@ -64,7 +66,8 @@ abstract class Horde_Ajax_Imple_Base $qstring .= '/' . $key . '=' . rawurlencode($val); } - return Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/imple.php?' . $qstring, $full); + $url = Horde::getServiceLink('imple'); + return Horde::url($url->url . '?' . $qstring, $full); } /** diff --git a/framework/Ajax/lib/Horde/Ajax/Imple/AutoCompleter.php b/framework/Core/lib/Horde/Core/Ajax/Imple/AutoCompleter.php similarity index 92% rename from framework/Ajax/lib/Horde/Ajax/Imple/AutoCompleter.php rename to framework/Core/lib/Horde/Core/Ajax/Imple/AutoCompleter.php index 452bf1272..931fff5bb 100644 --- a/framework/Ajax/lib/Horde/Ajax/Imple/AutoCompleter.php +++ b/framework/Core/lib/Horde/Core/Ajax/Imple/AutoCompleter.php @@ -4,13 +4,15 @@ * * 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. + * 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 - * @package Horde_Ajax + * @author Michael Slusarz + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Core */ -abstract class Horde_Ajax_Imple_AutoCompleter extends Horde_Ajax_Imple_Base +abstract class Horde_Core_Ajax_Imple_AutoCompleter extends Horde_Core_Ajax_Imple { /** * Constructor. diff --git a/framework/Ajax/lib/Horde/Ajax/Imple/Geocoder/Geonames.php b/framework/Core/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php similarity index 73% rename from framework/Ajax/lib/Horde/Ajax/Imple/Geocoder/Geonames.php rename to framework/Core/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php index b2193cf8f..4b3c592db 100644 --- a/framework/Ajax/lib/Horde/Ajax/Imple/Geocoder/Geonames.php +++ b/framework/Core/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php @@ -4,13 +4,15 @@ * * 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. + * 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 - * @package Horde_Ajax + * @author Michael J. Rubinsky + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Core */ -class Horde_Ajax_Imple_Geocoder_Geonames extends Horde_Ajax_Imple_Base +class Horde_Core_Ajax_Imple_Geocoder_Geonames extends Horde_Core_Ajax_Imple { /** * Constructor. @@ -32,7 +34,6 @@ class Horde_Ajax_Imple_Geocoder_Geonames extends Horde_Ajax_Imple_Base { } - /** * Handle the geocoding request. * @@ -45,7 +46,7 @@ class Horde_Ajax_Imple_Geocoder_Geonames extends Horde_Ajax_Imple_Base * $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) + * @see Horde_Core_Ajax_Imple#handle($args, $post) * @throws Horde_Exception */ public function handle($args, $post) @@ -57,14 +58,18 @@ class Horde_Ajax_Imple_Geocoder_Geonames extends Horde_Ajax_Imple_Base $url = new Horde_Url('http:/ws.geonames.org/findNearestJSON'); $url = $url->add(array('lat' => $args['lat'], 'lng' => $args['lon'])); } - $client = new Horde_Http_Client(); + + $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('status' => 200, - 'results' => $response->getBody()); + + return array( + 'results' => $response->getBody(), + 'status' => 200 + ); } } diff --git a/framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php b/framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php similarity index 90% rename from framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php rename to framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php index 860d912dc..b8177c798 100644 --- a/framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php +++ b/framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php @@ -4,13 +4,15 @@ * * 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. + * 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 - * @package Horde_Ajax + * @author Michael Slusarz + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Core */ -class Horde_Ajax_Imple_SpellChecker extends Horde_Ajax_Imple_Base +class Horde_Core_Ajax_Imple_SpellChecker extends Horde_Core_Ajax_Imple { /** * Constructor. diff --git a/framework/Core/lib/Horde/Core/Binder/Ajax.php b/framework/Core/lib/Horde/Core/Binder/Ajax.php new file mode 100644 index 000000000..ce23ee04b --- /dev/null +++ b/framework/Core/lib/Horde/Core/Binder/Ajax.php @@ -0,0 +1,17 @@ + + * @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 + * @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 index 000000000..c119524c2 --- /dev/null +++ b/framework/Core/lib/Horde/Core/Factory/Imple.php @@ -0,0 +1,84 @@ + + * @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 + * @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.'); + } + +} diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index 394da7bb0..c753bd716 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -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 diff --git a/framework/Core/package.xml b/framework/Core/package.xml index ac8826850..4d72958ad 100644 --- a/framework/Core/package.xml +++ b/framework/Core/package.xml @@ -34,8 +34,8 @@ Application Framework. beta LGPL - -* Import application auth driver from horde/Auth. + * 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. + + + + + + + + + + + @@ -80,6 +91,7 @@ Application Framework. + @@ -95,6 +107,7 @@ Application Framework. + @@ -113,6 +126,7 @@ Application Framework. + @@ -121,6 +135,7 @@ Application Framework. + @@ -312,7 +327,11 @@ Application Framework. - + + + + + @@ -325,6 +344,7 @@ Application Framework. + @@ -340,6 +360,7 @@ Application Framework. + @@ -356,6 +377,7 @@ Application Framework. + @@ -364,6 +386,7 @@ Application Framework. + @@ -382,6 +405,7 @@ Application Framework. + diff --git a/horde/config/hooks.php.dist b/horde/config/hooks.php.dist index 6249880b6..a6797c741 100644 --- a/horde/config/hooks.php.dist +++ b/horde/config/hooks.php.dist @@ -133,7 +133,7 @@ * $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). * * @@ -149,7 +149,7 @@ * $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. * diff --git a/horde/js/hordemap/map.js b/horde/js/hordemap/map.js index 62ac8077c..2d3ef605f 100644 --- a/horde/js/hordemap/map.js +++ b/horde/js/hordemap/map.js @@ -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. diff --git a/horde/services/ajax.php b/horde/services/ajax.php index 7d48e647f..7cadc939e 100644 --- a/horde/services/ajax.php +++ b/horde/services/ajax.php @@ -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('&', '&', $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) { diff --git a/horde/services/imple.php b/horde/services/imple.php index 8983470bc..db96e8715 100644 --- a/horde/services/imple.php +++ b/horde/services/imple.php @@ -1,6 +1,6 @@ getInstance('Horde_Ajax_Imple')->getImple($impleargs); $result = $imple->handle($args, $post); $ct = empty($_SERVER['Content-Type']) diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index 55bd375d9..21a4f5e60 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -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'); // } diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index 5a51f8226..8e256750e 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -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. diff --git a/imp/lib/Ajax/Imple/ContactAutoCompleter.php b/imp/lib/Ajax/Imple/ContactAutoCompleter.php index 373b658a1..5763af4ed 100644 --- a/imp/lib/Ajax/Imple/ContactAutoCompleter.php +++ b/imp/lib/Ajax/Imple/ContactAutoCompleter.php @@ -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? diff --git a/imp/lib/Ajax/Imple/PassphraseDialog.php b/imp/lib/Ajax/Imple/PassphraseDialog.php index 992909787..9706ff150 100644 --- a/imp/lib/Ajax/Imple/PassphraseDialog.php +++ b/imp/lib/Ajax/Imple/PassphraseDialog.php @@ -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. diff --git a/imp/lib/Mime/Viewer/Pgp.php b/imp/lib/Mime/Viewer/Pgp.php index cc7ce44b8..20c47b551 100644 --- a/imp/lib/Mime/Viewer/Pgp.php +++ b/imp/lib/Mime/Viewer/Pgp.php @@ -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.") . ''; 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.") . ''; return null; } diff --git a/imp/lib/Mime/Viewer/Smime.php b/imp/lib/Mime/Viewer/Smime.php index ac1747431..30272d2bb 100644 --- a/imp/lib/Mime/Viewer/Smime.php +++ b/imp/lib/Mime/Viewer/Smime.php @@ -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.") . ''; return null; } diff --git a/imp/lib/Prefs/Ui.php b/imp/lib/Prefs/Ui.php index 719a9c17a..a3f11a7cd 100644 --- a/imp/lib/Prefs/Ui.php +++ b/imp/lib/Prefs/Ui.php @@ -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(); diff --git a/imp/lib/Ui/Compose.php b/imp/lib/Ui/Compose.php index e10726706..4088840e7 100644 --- a/imp/lib/Ui/Compose.php +++ b/imp/lib/Ui/Compose.php @@ -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 + )); } /** diff --git a/kronolith/attendees.php b/kronolith/attendees.php index 3cee26127..6ba870a3b 100644 --- a/kronolith/attendees.php +++ b/kronolith/attendees.php @@ -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'; diff --git a/kronolith/calendars/edit.php b/kronolith/calendars/edit.php index 3f7966d24..a3cebd597 100644 --- a/kronolith/calendars/edit.php +++ b/kronolith/calendars/edit.php @@ -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(); diff --git a/kronolith/config/hooks.php.dist b/kronolith/config/hooks.php.dist index a6e89eed1..a6b01f872 100644 --- a/kronolith/config/hooks.php.dist +++ b/kronolith/config/hooks.php.dist @@ -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'); // } /** diff --git a/kronolith/index.php b/kronolith/index.php index 683a49dee..daee5c6a7 100644 --- a/kronolith/index.php +++ b/kronolith/index.php @@ -95,33 +95,39 @@ foreach ($injector->getInstance('Horde_Alarm')->handlers() as $method => $handle $taskAlarmParams = substr($taskAlarmParams, 0, - 6) . ''; } -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']); diff --git a/kronolith/lib/Ajax/Application.php b/kronolith/lib/Ajax/Application.php index a9356b616..8acbc3270 100644 --- a/kronolith/lib/Ajax/Application.php +++ b/kronolith/lib/Ajax/Application.php @@ -12,7 +12,7 @@ * @author Gonçalo Queirós * @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. diff --git a/kronolith/lib/Ajax/Imple/ContactAutoCompleter.php b/kronolith/lib/Ajax/Imple/ContactAutoCompleter.php index d385fa75d..1f7299e3a 100644 --- a/kronolith/lib/Ajax/Imple/ContactAutoCompleter.php +++ b/kronolith/lib/Ajax/Imple/ContactAutoCompleter.php @@ -10,14 +10,15 @@ * @author Michael Slusarz * @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) { diff --git a/kronolith/lib/Ajax/Imple/Embed.php b/kronolith/lib/Ajax/Imple/Embed.php index 438f03270..d51584368 100644 --- a/kronolith/lib/Ajax/Imple/Embed.php +++ b/kronolith/lib/Ajax/Imple/Embed.php @@ -9,7 +9,7 @@ * @author Michael J. Rubinsky * @package Kronolith */ -class Kronolith_Ajax_Imple_Embed extends Horde_Ajax_Imple_Base +class Kronolith_Ajax_Imple_Embed extends Horde_Core_Ajax_Imple { /** */ diff --git a/kronolith/lib/Ajax/Imple/TagActions.php b/kronolith/lib/Ajax/Imple/TagActions.php index 4580d5a80..3cbe16be1 100644 --- a/kronolith/lib/Ajax/Imple/TagActions.php +++ b/kronolith/lib/Ajax/Imple/TagActions.php @@ -8,7 +8,7 @@ * @author Michael J. Rubinsky * @package Kronolith */ -class Kronolith_Ajax_Imple_TagActions extends Horde_Ajax_Imple_Base +class Kronolith_Ajax_Imple_TagActions extends Horde_Core_Ajax_Imple { /** */ diff --git a/kronolith/lib/Ajax/Imple/TagAutoCompleter.php b/kronolith/lib/Ajax/Imple/TagAutoCompleter.php index db30ff5fd..ddcbe9d85 100644 --- a/kronolith/lib/Ajax/Imple/TagAutoCompleter.php +++ b/kronolith/lib/Ajax/Imple/TagAutoCompleter.php @@ -8,16 +8,17 @@ * @author Michael Slusarz * @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) { diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 2e8c9c2b2..410161126 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -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 = '
'; return $html; diff --git a/kronolith/templates/edit/edit.inc b/kronolith/templates/edit/edit.inc index 2dfa1267f..fbb1124df 100644 --- a/kronolith/templates/edit/edit.inc +++ b/kronolith/templates/edit/edit.inc @@ -408,9 +408,7 @@ endif; - 'tags', 'id' => $event->uid)); - $tac->attach(); - ?> + getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'tags', 'id' => $event->uid)); ?> diff --git a/kronolith/templates/panel.inc b/kronolith/templates/panel.inc index b41e408fd..1a006813d 100644 --- a/kronolith/templates/panel.inc +++ b/kronolith/templates/panel.inc @@ -92,13 +92,13 @@ if ($cal->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { . Horde::img('delete-small.png', _("Remove Tag")) . ''; } -$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' +)); ?> @@ -107,14 +107,16 @@ $ta->attach(); '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' + )); ?> diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index 10ed5e75e..22a91d9f6 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -11,7 +11,7 @@ * @author Ben Klang * @package Shout */ -class Shout_Ajax_Application extends Horde_Ajax_Application_Base +class Shout_Ajax_Application extends Horde_Core_Ajax_Application { protected $_responseType = 'json'; /** diff --git a/whups/lib/Ajax/Imple/ContactAutoCompleter.php b/whups/lib/Ajax/Imple/ContactAutoCompleter.php index 9699a8bf4..37957d843 100644 --- a/whups/lib/Ajax/Imple/ContactAutoCompleter.php +++ b/whups/lib/Ajax/Imple/ContactAutoCompleter.php @@ -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 { /** diff --git a/whups/lib/Forms/VarRenderer.php b/whups/lib/Forms/VarRenderer.php index 87da5d43b..725c36a0c 100644 --- a/whups/lib/Forms/VarRenderer.php +++ b/whups/lib/Forms/VarRenderer.php @@ -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('', $name, $name, -- 2.11.0