From: Michael M Slusarz Date: Wed, 14 Jul 2010 22:52:45 +0000 (-0600) Subject: Merge horde/Ajax into horde/Core. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=e149c7180ec549934c1f63334a466addd41710fb;p=horde.git 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). --- 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/Application/Base.php b/framework/Ajax/lib/Horde/Ajax/Application/Base.php deleted file mode 100644 index a84aaee63..000000000 --- a/framework/Ajax/lib/Horde/Ajax/Application/Base.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @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 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/lib/Horde/Ajax/Imple/AutoCompleter.php b/framework/Ajax/lib/Horde/Ajax/Imple/AutoCompleter.php deleted file mode 100644 index 452bf1272..000000000 --- a/framework/Ajax/lib/Horde/Ajax/Imple/AutoCompleter.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @package Horde_Ajax - */ -abstract class Horde_Ajax_Imple_AutoCompleter extends Horde_Ajax_Imple_Base -{ - /** - * Constructor. - * - * @param array $params Configuration parameters. - *
-     * 'triggerId' => (string) [optional] TODO
-     * 'no_onload' => (boolean) [optional] Don't wait for dom:onload to attach
-     * 
- */ - 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: - *
-     * 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.
-     * 
- */ - 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 index ee14297cf..000000000 --- a/framework/Ajax/lib/Horde/Ajax/Imple/Base.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @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 index b2193cf8f..000000000 --- a/framework/Ajax/lib/Horde/Ajax/Imple/Geocoder/Geonames.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @package Horde_Ajax - */ -class Horde_Ajax_Imple_Geocoder_Geonames extends Horde_Ajax_Imple_Base -{ - /** - * Constructor. - * - * @param array $params Configuration parameters. - *
-     * 'triggerId' => (string) [optional] TODO
-     * 
- */ - 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 index 860d912dc..000000000 --- a/framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @package Horde_Ajax - */ -class Horde_Ajax_Imple_SpellChecker extends Horde_Ajax_Imple_Base -{ - /** - * Constructor. - * - * @param array $params Configuration parameters. - *
-     * 'id' => TODO (optional)
-     * 'locales' => TODO (optional)
-     * 'states' => TODO (optional)
-     * 'targetId' => TODO (optional)
-     * 'triggerId' => TODO (optional)
-     * 
- */ - 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 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/Core/lib/Horde/Core/Ajax/Application.php b/framework/Core/lib/Horde/Core/Ajax/Application.php new file mode 100644 index 000000000..4f25e8393 --- /dev/null +++ b/framework/Core/lib/Horde/Core/Ajax/Application.php @@ -0,0 +1,198 @@ + + * @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 index 000000000..71a864a22 --- /dev/null +++ b/framework/Core/lib/Horde/Core/Ajax/Imple.php @@ -0,0 +1,83 @@ + + * @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 index 000000000..931fff5bb --- /dev/null +++ b/framework/Core/lib/Horde/Core/Ajax/Imple/AutoCompleter.php @@ -0,0 +1,122 @@ + + * @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. + *
+     * 'triggerId' => (string) [optional] TODO
+     * 'no_onload' => (boolean) [optional] Don't wait for dom:onload to attach
+     * 
+ */ + 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: + *
+     * 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.
+     * 
+ */ + 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 index 000000000..4b3c592db --- /dev/null +++ b/framework/Core/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php @@ -0,0 +1,75 @@ + + * @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. + *
+     * 'triggerId' => (string) [optional] TODO
+     * 
+ */ + 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 index 000000000..b8177c798 --- /dev/null +++ b/framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php @@ -0,0 +1,122 @@ + + * @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. + *
+     * 'id' => TODO (optional)
+     * 'locales' => TODO (optional)
+     * 'states' => TODO (optional)
+     * 'targetId' => TODO (optional)
+     * 'triggerId' => TODO (optional)
+     * 
+ */ + 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 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,