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';
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-class Ansel_Ajax_Imple_EditCaption extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_EditCaption extends Horde_Core_Ajax_Imple
{
public function __construct($params)
{
*
* @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
*
* @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(){}
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-class Ansel_Ajax_Imple_GallerySlugCheck extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_GallerySlugCheck extends Horde_Core_Ajax_Imple
{
public function attach()
{
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-class Ansel_Ajax_Imple_ImageSaveGeotag extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_ImageSaveGeotag extends Horde_Core_Ajax_Imple
{
// Noop since this isn't attached to any UI Element
public function attach() {}
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Ajax_Imple_AutoCompleter
+class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Core_Ajax_Imple_AutoCompleter
{
protected function _attach($js_params)
{
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-class Ansel_Ajax_Imple_TagActions extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_TagActions extends Horde_Core_Ajax_Imple
{
public function attach()
{
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-class Ansel_Ajax_Imple_ToggleGalleryActions extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_ToggleGalleryActions extends Horde_Core_Ajax_Imple
{
public function attach()
{
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Ansel
*/
-class Ansel_Ajax_Imple_ToggleOtherGalleries extends Horde_Ajax_Imple_Base
+class Ansel_Ajax_Imple_ToggleOtherGalleries extends Horde_Core_Ajax_Imple
{
public function attach()
{
$domid = $options['container'];
}
- $imple = Horde_Ajax_Imple::factory(array('ansel', 'Embed'), $options);
- $src = $imple->getUrl();
+ $imple = $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'Embed'), $options);
- return '<script type="text/javascript" src="' . $src . '"></script><div id="' . $domid . '"></div>';
+ return '<script type="text/javascript" src="' . $imple->getUrl() . '"></script><div id="' . $domid . '"></div>';
}
}
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';
/* 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
+ ));
}
}
/* 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 */
$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);
// 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();
}
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();
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(
'gallery' => $gallery->id));
$image_tag = '<img src="' . Ansel::getImageUrl($image_id, 'thumb', true) . '" alt="[thumbnail]" />';
/* Url for geotag ajax helper */
-$gt = Horde_Ajax_Imple::factory(array('ansel', 'ImageSaveGeotag'));
+$gt = $injector->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'Imple_ImageSaveGeotag'));
$gtUrl = $gt->getUrl();
$loadingImg = Horde::img('loading.gif', _("Loading..."));
</script>
EOT;
/* Autocompleter for locations we already have in our DB */
-$ac = Horde_Ajax_Imple::factory(array('ansel', 'LocationAutoCompleter'),
- array('triggerId' => 'locationInput',
- 'resultsId' => 'locationInput_results',
- 'map' => 'mapEdit'));
-$ac->attach();
+$injector->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'LocationAutoCompleter'), array(
+ 'map' => 'mapEdit',
+ 'resultsId' => 'locationInput_results',
+ 'triggerId' => 'locationInput'
+));
//$html .= Horde_Util::bufferOutput(array($ac, 'attach'));
/* Start the output */
+++ /dev/null
-<?php
-/**
- * Perform AJAX actions.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @package Horde_Ajax
- */
-class Horde_Ajax
-{
- /**
- * Get a Horde_Ajax_Application_Base instance.
- *
- * @param string $app The application name.
- * @param string $action The AJAX action to perform.
- *
- * @return Horde_Ajax_Application_Base The requested instance.
- * @throws Horde_Exception
- */
- static public function getInstance($app, $action = null)
- {
- $class = $app . '_Ajax_Application';
-
- if (class_exists($class)) {
- return new $class($app, $action);
- }
-
- throw new Horde_Ajax_Exception('Ajax configuration for ' . $app . ' not found.');
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Defines the AJAX interface for an application.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ajax
- */
-abstract class Horde_Ajax_Application_Base
-{
- /**
- * Determines if notification information is sent in response.
- *
- * @var boolean
- */
- public $notify = false;
-
- /**
- * The Horde application.
- *
- * @var string
- */
- protected $_app;
-
- /**
- * The action to perform.
- *
- * @var string
- */
- protected $_action;
-
- /**
- * The request variables.
- *
- * @var Variables
- */
- protected $_vars;
-
- /**
- * The list of actions that require readonly access to the session.
- *
- * @var array
- */
- protected $_readOnly = array();
-
- /**
- * Default domain.
- *
- * @see parseEmailAddress()
- * @var string
- */
- protected $_defaultDomain;
-
- /**
- * Constructor.
- *
- * @param string $app The application name.
- * @param string $action The AJAX action to perform.
- */
- public function __construct($app, $action = null)
- {
- $this->_app = $app;
-
- if (!is_null($action)) {
- /* Close session if action is labeled as read-only. */
- if (in_array($action, $this->_readOnly)) {
- session_write_close();
- }
-
- $this->_action = $action;
- }
- }
-
- /**
- * Performs the AJAX action.
- *
- * @return mixed The result of the action call.
- * @throws Horde_Ajax_Exception
- */
- public function doAction()
- {
- if (!$this->_action) {
- return false;
- }
-
- $this->_vars = Horde_Variables::getDefaultVariables();
-
- if (method_exists($this, $this->_action)) {
- return call_user_func(array($this, $this->_action));
- }
-
- /* Look for hook in application. */
- try {
- return Horde::callHook('ajaxaction', array($this->_action, $this->_vars), $this->_app);
- } catch (Horde_Exception_HookNotSet $e) {
- } catch (Horde_Ajax_Exception $e) {}
-
- throw new Horde_Ajax_Exception('Handler for action "' . $this->_action . '" does not exist.');
- }
-
- /**
- * Determines the HTTP response output type.
- *
- * @see Horde::sendHTTPResponse().
- *
- * @return string The output type.
- */
- public function responseType()
- {
- return 'json';
- }
-
- /**
- * Logs the user off the Horde session.
- *
- * This needs to be done here (server), rather than on the browser,
- * because the logout tokens might otherwise expire.
- */
- public function logOut()
- {
- Horde::redirect(Horde::getServiceLink('logout', $this->_app)->setRaw(true));
- exit;
- }
-
- /**
- * Returns a hash of group IDs and group names that the user has access to.
- *
- * @return array Groups hash.
- */
- public function listGroups()
- {
- $result = new stdClass;
- try {
- $horde_groups = Horde_Group::singleton();
- $groups = empty($GLOBALS['conf']['share']['any_group'])
- ? $horde_groups->getGroupMemberships($GLOBALS['registry']->getAuth(), true)
- : $horde_groups->listGroups();
- if ($groups) {
- asort($groups);
- $result->groups = $groups;
- }
- } catch (Horde_Group_Exception $e) {
- Horde::logMessage($e);
- }
- return $result;
- }
-
- /**
- * Parses a valid email address out of a complete address string.
- *
- * Variables used:
- * - mbox (string): The name of the new mailbox.
- * - parent (string): The parent mailbox.
- *
- * @return string The parsed email address.
- * @throws Horde_Exception
- * @throws Horde_Mail_Exception
- */
- public function parseEmailAddress()
- {
- $rfc822 = new Horde_Mail_Rfc822();
- $params = array();
- if ($this->_defaultDomain) {
- $params['default_domain'] = $this->_defaultDomain;
- }
- $res = $rfc822->parseAddressList($this->_vars->email, $params);
- if (!count($res)) {
- throw new Horde_Exception(_("No valid email address found"));
- }
- return (object)array('email' => Horde_Mime_Address::writeAddress($res[0]->mailbox, $res[0]->host));
- }
-
- /**
- * Loads a chunk of PHP code (usually an HTML template) from the
- * application's templates directory.
- *
- * @return string A chunk of PHP output.
- */
- public function chunkContent()
- {
- $chunk = basename(Horde_Util::getPost('chunk'));
- $result = new stdClass;
- if (!empty($chunk)) {
- Horde::startBuffer();
- include $GLOBALS['registry']->get('templates', $this->_app) . '/chunks/' . $chunk . '.php';
- $result->chunk = Horde::endBuffer();
- }
-
- return $result;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Exception object for the Horde_Ajax package.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @package Horde_Ajax
- */
-class Horde_Ajax_Exception extends Horde_Exception
-{
-}
+++ /dev/null
-<?php
-/**
- * Class to attach PHP actions to javascript elements.
- * (Originally named 'Dimple' as it was first implemented in DIMP - rennamed
- * to 'Imple' when DIMP was merged into IMP.)
- *
- * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ajax
- */
-class Horde_Ajax_Imple
-{
- /**
- * Attempts to return a concrete instance based on $driver.
- *
- * @param mixed $driver The type of concrete subclass to return. If
- * $driver is an array, then look in
- * $driver[0]/lib/Ajax/Imple for the subclass
- * implementation named $driver[1].php.
- * @param array $params A hash containing any additional configuration or
- * parameters a subclass might need.
- *
- * @return Horde_Ajax_Imple_Base The newly created concrete instance.
- * @throws Horde_Exception
- */
- static public function factory($driver, $params = array())
- {
- if (is_array($driver)) {
- list($app, $driv_name) = $driver;
- $driver = basename($driv_name);
- } else {
- $driver = basename($driver);
- }
-
- $class = (empty($app) ? 'Horde' : $app) . '_Ajax_Imple_' . ucfirst($driver);
-
- if (class_exists($class)) {
- return new $class($params);
- }
-
- throw new Horde_Exception('Class definition of ' . $class . ' not found.');
- }
-}
+++ /dev/null
-<?php
-/**
- * Attach an auto completer to a javascript element.
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ajax
- */
-abstract class Horde_Ajax_Imple_AutoCompleter extends Horde_Ajax_Imple_Base
-{
- /**
- * Constructor.
- *
- * @param array $params Configuration parameters.
- * <pre>
- * 'triggerId' => (string) [optional] TODO
- * 'no_onload' => (boolean) [optional] Don't wait for dom:onload to attach
- * </pre>
- */
- public function __construct($params)
- {
- if (empty($params['triggerId'])) {
- $params['triggerId'] = $this->_randomid();
- }
-
- if (empty($params['triggerContainer'])) {
- $params['triggerContainer'] = $this->_randomid();
- }
-
- parent::__construct($params);
- }
-
- /**
- * Attach the object to a javascript event.
- */
- public function attach()
- {
- $params = array(
- '"' . $this->_params['triggerId'] . '"'
- );
-
- $config = $this->_attach(array('tokens' => array(',', ';')));
-
- Horde::addScriptFile('autocomplete.js', 'horde');
- Horde::addScriptFile('keynavlist.js', 'horde');
- Horde::addScriptFile('liquidmetal.js', 'horde');
- if (isset($config['ajax'])) {
- $func = 'Ajax.Autocompleter';
- $params[] = '"' . $this->_getUrl($config['ajax'], $GLOBALS['registry']->getApp(), array('input' => $this->_params['triggerId'])) . '"';
- } elseif (isset($config['browser'])) {
- $func = 'Autocompleter.Local';
- $params[] = $config['browser'];
- $config['params'] = array_merge(array(
- 'partialSearch' => 1,
- 'fullSearch' => 1,
- 'score' => 1
- ), $config['params']);
- } elseif (isset($config['pretty'])) {
- Horde::addScriptFile('prettyautocomplete.js', 'horde');
- $func = 'PrettyAutocompleter';
- $config['params'] = array_merge(array(
- 'boxClass' => 'hordeACBox kronolithLongField',
- 'trigger' => $this->_params['triggerId'],
- 'triggerContainer' => $this->_params['triggerContainer'],
- 'uri' => (string)$this->_getUrl($config['pretty'], $GLOBALS['registry']->getApp()),
- 'deleteIcon' => (string)Horde_Themes::img('delete-small.png', 'horde'),
- 'box' => !empty($this->_params['box']) ? $this->_params['box'] : ''
- ), $config['params']);
-
- if (!empty($this->_params['existing'])) {
- $config['params']['existing'] = $this->_params['existing'];
- }
- } else {
- return;
- }
-
- $config['raw_params'] = !empty($config['raw_params']) ? $config['raw_params'] : array();
- foreach ($config['raw_params'] as $name => $val) {
- $config['params'][$name] = 1;
- }
-
- $js_params = Horde_Serialize::serialize($config['params'], Horde_Serialize::JSON);
-
- foreach ($config['raw_params'] as $name => $val) {
- $js_params = str_replace('"' . $name . '":1', '"' . $name . '":' . $val, $js_params);
- }
-
- Horde::addScriptFile('effects.js', 'horde');
-
- Horde::addInlineScript((isset($config['var']) ? $config['var'] . ' = ' : '') . 'new ' . $func . '(' . implode(',', $params) . ',' . $js_params . ')', empty($this->_params['no_onload']) ? 'dom' : null);
- }
-
- /**
- * Attach the object to a javascript event.
- *
- * @return array An array with the following elements:
- * <pre>
- * ONE of the following:
- * 'ajax' - (string) Use 'Ajax.Autocompleter' class. Value is the AJAX
- * function name.
- * 'browser' - (string) Use 'Autocompleter.Local' class. Value is the
- * javascript list of items to search.
- * 'pretty' - (string) Use 'PrettyAutocompleter' class. Value is the AJAX
- * function name.
- *
- * Additional Options:
- * 'params' - (array) The list of javascript parameters to pass to the
- * autocomplete libraries.
- * 'raw_params' - (array) Adds raw javascript to the 'params' array.
- * 'var' - (string) If set, the autocomplete object will be assigned to
- * this variable.
- * </pre>
- */
- abstract protected function _attach($js_params);
-
-}
+++ /dev/null
-<?php
-/**
- * Class to attach PHP actions to javascript elements.
- *
- * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ajax
- */
-abstract class Horde_Ajax_Imple_Base
-{
- /**
- * Parameters needed by the subclasses.
- *
- * @var array
- */
- protected $_params = array();
-
- /**
- * Constructor.
- *
- * @param array $params Any parameters needed by the class.
- */
- public function __construct($params)
- {
- $this->_params = $params;
- }
-
- /**
- * Attach the object to a javascript event.
- */
- abstract public function attach();
-
- /**
- * TODO
- *
- * @param array $args TODO
- */
- abstract public function handle($args, $post);
-
- /**
- * TODO
- *
- * @param string $driver
- * @param string $app
- * @param array $params
- * @param boolean $full
- *
- * @return string
- */
- protected function _getUrl($driver, $app = 'horde', $params = array(),
- $full = false)
- {
- $qstring = 'imple=' . $driver;
-
- if ($app != 'horde') {
- $qstring .= '/impleApp=' . $app;
- }
-
- foreach ($params as $key => $val) {
- $qstring .= '/' . $key . '=' . rawurlencode($val);
- }
-
- return Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/imple.php?' . $qstring, $full);
- }
-
- /**
- * Generate a random ID string.
- *
- * @return string The random ID string.
- */
- protected function _randomid()
- {
- return 'imple_' . uniqid(mt_rand());
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Geocode client for the Geonames API.
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Horde_Ajax
- */
-class Horde_Ajax_Imple_Geocoder_Geonames extends Horde_Ajax_Imple_Base
-{
- /**
- * Constructor.
- *
- * @param array $params Configuration parameters.
- * <pre>
- * 'triggerId' => (string) [optional] TODO
- * </pre>
- */
- public function __construct($params)
- {
- parent::__construct($params);
- }
-
- /**
- * Attach the object to a javascript event.
- */
- public function attach()
- {
- }
-
-
- /**
- * Handle the geocoding request.
- *
- * @TODO: For reverse requests come up with a reasonable algorithm for
- * checking if we have a lat/lng in the US since the
- * findNearestAddress method is US only. If non-us, fallback to a
- * findNearest or findPostalcode or similar request. Also will need
- * to normalize the various response structures.
- *
- * $args['locations'] will trigger a forward geocoding request.
- * $args['lat'] and $args['lon'] will trigger a reverse geocoding request.
- *
- * @see framework/Ajax/lib/Horde/Ajax/Imple/Horde_Ajax_Imple_Base#handle($args, $post)
- * @throws Horde_Exception
- */
- public function handle($args, $post)
- {
- if ($args['location']) {
- $url = new Horde_Url('http://ws.geonames.org/searchJSON');
- $url = $url->add('q', $args['location']);
- } elseif (!empty($args['lat']) && !empty($args['lon'])) {
- $url = new Horde_Url('http:/ws.geonames.org/findNearestJSON');
- $url = $url->add(array('lat' => $args['lat'], 'lng' => $args['lon']));
- }
- $client = new Horde_Http_Client();
- try {
- $response = $client->get($url);
- } catch (Horde_Http_Exception $e) {
- throw new Horde_Exception_Prior($e);
- }
- return array('status' => 200,
- 'results' => $response->getBody());
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Attach the spellchecker to a javascript element.
- *
- * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ajax
- */
-class Horde_Ajax_Imple_SpellChecker extends Horde_Ajax_Imple_Base
-{
- /**
- * Constructor.
- *
- * @param array $params Configuration parameters.
- * <pre>
- * 'id' => TODO (optional)
- * 'locales' => TODO (optional)
- * 'states' => TODO (optional)
- * 'targetId' => TODO (optional)
- * 'triggerId' => TODO (optional)
- * </pre>
- */
- public function __construct($params = array())
- {
- if (empty($params['id'])) {
- $params['id'] = $this->_randomid();
- }
-
- if (empty($params['targetId'])) {
- $params['targetId'] = $this->_randomid();
- }
-
- if (empty($params['triggerId'])) {
- $params['triggerId'] = $params['targetId'] . '_trigger';
- }
-
- if (empty($params['locales'])) {
- $key_list = array_keys($GLOBALS['registry']->nlsconfig['spelling']);
- asort($key_list, SORT_LOCALE_STRING);
- $params['locales'] = array();
-
- foreach ($key_list as $lcode) {
- $params['locales'][] = array('l' => $GLOBALS['registry']->nlsconfig['languages'][$lcode], 'v' => $lcode);
- }
- }
-
- parent::__construct($params);
- }
-
- /**
- */
- public function attach()
- {
- Horde::addScriptFile('prototype.js', 'horde');
- Horde::addScriptFile('effects.js', 'horde');
- Horde::addScriptFile('keynavlist.js', 'horde');
- Horde::addScriptFile('spellchecker.js', 'horde');
-
- $opts = array(
- 'locales' => $this->_params['locales'],
- 'sc' => 'widget',
- 'statusButton' => $this->_params['triggerId'],
- 'target' => $this->_params['targetId'],
- 'url' => strval($this->_getUrl('SpellChecker', 'horde', array('input' => $this->_params['targetId'])))
- );
- if (isset($this->_params['states'])) {
- $opts['bs'] = $this->_params['states'];
- }
-
- Horde::addInlineScript(array(
- $this->_params['id'] . ' = new SpellChecker(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')'
- ), 'dom');
- }
-
- /**
- */
- public function handle($args, $post)
- {
- $spellArgs = array();
-
- if (!empty($GLOBALS['conf']['spell']['params'])) {
- $spellArgs = $GLOBALS['conf']['spell']['params'];
- }
-
- if (isset($args['locale'])) {
- $spellArgs['locale'] = $args['locale'];
- } elseif (isset($GLOBALS['language'])) {
- $spellArgs['locale'] = $GLOBALS['language'];
- }
-
- /* Add local dictionary words. */
- try {
- $result = Horde::loadConfiguration('spelling.php', 'ignore_list', 'horde');
- $spellArgs['localDict'] = $result;
- } catch (Horde_Exception $e) {}
-
- if (!empty($args['html'])) {
- $spellArgs['html'] = true;
- }
-
- try {
- $speller = Horde_SpellChecker::factory($GLOBALS['conf']['spell']['driver'], $spellArgs);
- } catch (Horde_Exception $e) {
- Horde::logMessage($e, 'ERR');
- return array();
- }
-
- try {
- return $speller->spellCheck(Horde_Util::getPost($args['input']));
- } catch (Horde_Exception $e) {
- Horde::logMessage($e, 'ERR');
- return array('bad' => array(), 'suggestions' => array());
- }
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.4.9" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
-http://pear.php.net/dtd/tasks-1.0.xsd
-http://pear.php.net/dtd/package-2.0
-http://pear.php.net/dtd/package-2.0.xsd">
- <name>Ajax</name>
- <channel>pear.horde.org</channel>
- <summary>Horde Ajax utilities</summary>
- <description>This package provides utilities to aid with using AJAX with Horde applications.
- </description>
- <lead>
- <name>Michael Slusarz</name>
- <user>slusarz</user>
- <email>slusarz@horde.org</email>
- <active>yes</active>
- </lead>
- <date>2009-07-16</date>
- <version>
- <release>0.1.0</release>
- <api>0.1.0</api>
- </version>
- <stability>
- <release>beta</release>
- <api>beta</api>
- </stability>
- <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Add Application framework.
- * Add AutoCompleter driver.
- * Initial release.
- </notes>
- <contents>
- <dir name="/">
- <dir name="lib">
- <dir name="Horde">
- <dir name="Ajax">
- <dir name="Application">
- <file name="Base.php" role="php" />
- </dir> <!-- /lib/Horde/Ajax/Application -->
- <dir name="Imple">
- <file name="AutoCompleter.php" role="php" />
- <file name="Base.php" role="php" />
- <file name="SpellChecker.php" role="php" />
- <dir name="Geocoder">
- <file name="Geonames.php" role="php" />
- </dir>
- </dir> <!-- /lib/Horde/Ajax/Imple -->
- <file name="Exception.php" role="php" />
- <file name="Imple.php" role="php" />
- </dir> <!-- /lib/Horde/Ajax -->
- <file name="Ajax.php" role="php" />
- </dir> <!-- /lib/Horde -->
- </dir> <!-- /lib -->
- </dir> <!-- / -->
- </contents>
- <dependencies>
- <required>
- <php>
- <min>5.2.0</min>
- </php>
- <pearinstaller>
- <min>1.7.0</min>
- </pearinstaller>
- <package>
- <name>Core</name>
- <channel>pear.horde.org</channel>
- </package>
- <package>
- <name>Util</name>
- <channel>pear.horde.org</channel>
- </package>
- </required>
- <optional>
- <package>
- <name>SpellChecker</name>
- <channel>pear.horde.org</channel>
- </package>
- <package>
- <name>Serialize</name>
- <channel>pear.horde.org</channel>
- </package>
- </optional>
- </dependencies>
- <phprelease>
- <filelist>
- <install name="lib/Horde/Ajax/Application/Base.php" as="Horde/Ajax/Application/Base.php" />
- <install name="lib/Horde/Ajax/Exception.php" as="Horde/Ajax/Exception.php" />
- <install name="lib/Horde/Ajax/Imple/AutoCompleter.php" as="Horde/Ajax/Imple/AutoCompleter.php" />
- <install name="lib/Horde/Ajax/Imple/Base.php" as="Horde/Ajax/Imple/Base.php" />
- <install name="lib/Horde/Ajax/Imple/SpellChecker.php" as="Horde/Ajax/Imple/SpellChecker.php" />
- <install name="lib/Horde/Ajax/Imple.php" as="Horde/Ajax/Imple.php" />
- <install name="lib/Horde/Ajax/Imple/Geocoder/Geonames.php" as="Horde/Ajax/Imple/Geocoder/Geonames.php" />
- <install name="lib/Horde/Ajax.php" as="Horde/Ajax.php" />
- </filelist>
- </phprelease>
- <changelog/>
-</package>
*
* @param string $type The service to display.
* <pre>
- * TODO
- * 'ajax', 'cache', 'download', 'go', 'logintasks', 'prefsapi'
- * 'help', 'problem', 'logout', 'login', 'options', 'sidebar'
+ * 'ajax'
+ * 'cache'
+ * 'download'
+ * 'go'
+ * 'help'
+ * 'imple'
+ * 'login'
+ * 'logintasks'
+ * 'logout'
+ * 'prefsapi
+ * 'problem'
+ * 'sidebar'
+ * 'options'
* </pre>
* @param string $app The name of the current Horde application.
*
$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':
}
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');
--- /dev/null
+<?php
+/**
+ * Defines the AJAX interface for an application.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Core
+ */
+abstract class Horde_Core_Ajax_Application
+{
+ /**
+ * Determines if notification information is sent in response.
+ *
+ * @var boolean
+ */
+ public $notify = false;
+
+ /**
+ * The Horde application.
+ *
+ * @var string
+ */
+ protected $_app;
+
+ /**
+ * The action to perform.
+ *
+ * @var string
+ */
+ protected $_action;
+
+ /**
+ * The request variables.
+ *
+ * @var Variables
+ */
+ protected $_vars;
+
+ /**
+ * The list of actions that require readonly access to the session.
+ *
+ * @var array
+ */
+ protected $_readOnly = array();
+
+ /**
+ * Default domain.
+ *
+ * @see parseEmailAddress()
+ * @var string
+ */
+ protected $_defaultDomain;
+
+ /**
+ * Constructor.
+ *
+ * @param string $app The application name.
+ * @param Horde_Variables $vars Form/request data.
+ * @param string $action The AJAX action to perform.
+ */
+ public function __construct($app, $vars, $action = null)
+ {
+ $this->_app = $app;
+ $this->_vars = $vars;
+
+ if (!is_null($action)) {
+ /* Close session if action is labeled as read-only. */
+ if (in_array($action, $this->_readOnly)) {
+ session_write_close();
+ }
+
+ $this->_action = $action;
+ }
+ }
+
+ /**
+ * Performs the AJAX action.
+ *
+ * @return mixed The result of the action call.
+ * @throws Horde_Exception
+ */
+ public function doAction()
+ {
+ if (!$this->_action) {
+ return false;
+ }
+
+ if (method_exists($this, $this->_action)) {
+ return call_user_func(array($this, $this->_action));
+ }
+
+ /* Look for hook in application. */
+ try {
+ return Horde::callHook('ajaxaction', array($this->_action, $this->_vars), $this->_app);
+ } catch (Horde_Exception_HookNotSet $e) {
+ } catch (Horde_Exception $e) {}
+
+ throw new Horde_Exception('Handler for action "' . $this->_action . '" does not exist.');
+ }
+
+ /**
+ * Determines the HTTP response output type.
+ *
+ * @see Horde::sendHTTPResponse().
+ *
+ * @return string The output type.
+ */
+ public function responseType()
+ {
+ return 'json';
+ }
+
+ /**
+ * Logs the user off the Horde session.
+ *
+ * This needs to be done here (server), rather than on the browser,
+ * because the logout tokens might otherwise expire.
+ */
+ public function logOut()
+ {
+ Horde::redirect(Horde::getServiceLink('logout', $this->_app)->setRaw(true));
+ exit;
+ }
+
+ /**
+ * Returns a hash of group IDs and group names that the user has access to.
+ *
+ * @return array Groups hash.
+ */
+ public function listGroups()
+ {
+ $result = new stdClass;
+ try {
+ $horde_groups = Horde_Group::singleton();
+ $groups = empty($GLOBALS['conf']['share']['any_group'])
+ ? $horde_groups->getGroupMemberships($GLOBALS['registry']->getAuth(), true)
+ : $horde_groups->listGroups();
+ if ($groups) {
+ asort($groups);
+ $result->groups = $groups;
+ }
+ } catch (Horde_Group_Exception $e) {
+ Horde::logMessage($e);
+ }
+ return $result;
+ }
+
+ /**
+ * Parses a valid email address out of a complete address string.
+ *
+ * Variables used:
+ * - mbox (string): The name of the new mailbox.
+ * - parent (string): The parent mailbox.
+ *
+ * @return string The parsed email address.
+ * @throws Horde_Exception
+ * @throws Horde_Mail_Exception
+ */
+ public function parseEmailAddress()
+ {
+ $rfc822 = new Horde_Mail_Rfc822();
+ $params = array();
+ if ($this->_defaultDomain) {
+ $params['default_domain'] = $this->_defaultDomain;
+ }
+ $res = $rfc822->parseAddressList($this->_vars->email, $params);
+ if (!count($res)) {
+ throw new Horde_Exception(_("No valid email address found"));
+ }
+ return (object)array('email' => Horde_Mime_Address::writeAddress($res[0]->mailbox, $res[0]->host));
+ }
+
+ /**
+ * Loads a chunk of PHP code (usually an HTML template) from the
+ * application's templates directory.
+ *
+ * @return string A chunk of PHP output.
+ */
+ public function chunkContent()
+ {
+ $chunk = basename(Horde_Util::getPost('chunk'));
+ $result = new stdClass;
+ if (!empty($chunk)) {
+ Horde::startBuffer();
+ include $GLOBALS['registry']->get('templates', $this->_app) . '/chunks/' . $chunk . '.php';
+ $result->chunk = Horde::endBuffer();
+ }
+
+ return $result;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Class to attach PHP actions to javascript elements.
+ *
+ * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Core
+ */
+abstract class Horde_Core_Ajax_Imple
+{
+ /**
+ * Parameters needed by the subclasses.
+ *
+ * @var array
+ */
+ protected $_params = array();
+
+ /**
+ * Constructor.
+ *
+ * @param array $params Any parameters needed by the class.
+ */
+ public function __construct($params)
+ {
+ $this->_params = $params;
+ }
+
+ /**
+ * Attach the object to a javascript event.
+ */
+ abstract public function attach();
+
+ /**
+ * TODO
+ *
+ * @param array $args TODO
+ */
+ abstract public function handle($args, $post);
+
+ /**
+ * TODO
+ *
+ * @param string $driver
+ * @param string $app
+ * @param array $params
+ * @param boolean $full
+ *
+ * @return string
+ */
+ protected function _getUrl($driver, $app = 'horde', $params = array(),
+ $full = false)
+ {
+ $qstring = 'imple=' . $driver;
+
+ if ($app != 'horde') {
+ $qstring .= '/impleApp=' . $app;
+ }
+
+ foreach ($params as $key => $val) {
+ $qstring .= '/' . $key . '=' . rawurlencode($val);
+ }
+
+ $url = Horde::getServiceLink('imple');
+ return Horde::url($url->url . '?' . $qstring, $full);
+ }
+
+ /**
+ * Generate a random ID string.
+ *
+ * @return string The random ID string.
+ */
+ protected function _randomid()
+ {
+ return 'imple_' . uniqid(mt_rand());
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Attach an auto completer to a javascript element.
+ *
+ * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Core
+ */
+abstract class Horde_Core_Ajax_Imple_AutoCompleter extends Horde_Core_Ajax_Imple
+{
+ /**
+ * Constructor.
+ *
+ * @param array $params Configuration parameters.
+ * <pre>
+ * 'triggerId' => (string) [optional] TODO
+ * 'no_onload' => (boolean) [optional] Don't wait for dom:onload to attach
+ * </pre>
+ */
+ public function __construct($params)
+ {
+ if (empty($params['triggerId'])) {
+ $params['triggerId'] = $this->_randomid();
+ }
+
+ if (empty($params['triggerContainer'])) {
+ $params['triggerContainer'] = $this->_randomid();
+ }
+
+ parent::__construct($params);
+ }
+
+ /**
+ * Attach the object to a javascript event.
+ */
+ public function attach()
+ {
+ $params = array(
+ '"' . $this->_params['triggerId'] . '"'
+ );
+
+ $config = $this->_attach(array('tokens' => array(',', ';')));
+
+ Horde::addScriptFile('autocomplete.js', 'horde');
+ Horde::addScriptFile('keynavlist.js', 'horde');
+ Horde::addScriptFile('liquidmetal.js', 'horde');
+ if (isset($config['ajax'])) {
+ $func = 'Ajax.Autocompleter';
+ $params[] = '"' . $this->_getUrl($config['ajax'], $GLOBALS['registry']->getApp(), array('input' => $this->_params['triggerId'])) . '"';
+ } elseif (isset($config['browser'])) {
+ $func = 'Autocompleter.Local';
+ $params[] = $config['browser'];
+ $config['params'] = array_merge(array(
+ 'partialSearch' => 1,
+ 'fullSearch' => 1,
+ 'score' => 1
+ ), $config['params']);
+ } elseif (isset($config['pretty'])) {
+ Horde::addScriptFile('prettyautocomplete.js', 'horde');
+ $func = 'PrettyAutocompleter';
+ $config['params'] = array_merge(array(
+ 'boxClass' => 'hordeACBox kronolithLongField',
+ 'trigger' => $this->_params['triggerId'],
+ 'triggerContainer' => $this->_params['triggerContainer'],
+ 'uri' => (string)$this->_getUrl($config['pretty'], $GLOBALS['registry']->getApp()),
+ 'deleteIcon' => (string)Horde_Themes::img('delete-small.png', 'horde'),
+ 'box' => !empty($this->_params['box']) ? $this->_params['box'] : ''
+ ), $config['params']);
+
+ if (!empty($this->_params['existing'])) {
+ $config['params']['existing'] = $this->_params['existing'];
+ }
+ } else {
+ return;
+ }
+
+ $config['raw_params'] = !empty($config['raw_params']) ? $config['raw_params'] : array();
+ foreach ($config['raw_params'] as $name => $val) {
+ $config['params'][$name] = 1;
+ }
+
+ $js_params = Horde_Serialize::serialize($config['params'], Horde_Serialize::JSON);
+
+ foreach ($config['raw_params'] as $name => $val) {
+ $js_params = str_replace('"' . $name . '":1', '"' . $name . '":' . $val, $js_params);
+ }
+
+ Horde::addScriptFile('effects.js', 'horde');
+
+ Horde::addInlineScript((isset($config['var']) ? $config['var'] . ' = ' : '') . 'new ' . $func . '(' . implode(',', $params) . ',' . $js_params . ')', empty($this->_params['no_onload']) ? 'dom' : null);
+ }
+
+ /**
+ * Attach the object to a javascript event.
+ *
+ * @return array An array with the following elements:
+ * <pre>
+ * ONE of the following:
+ * 'ajax' - (string) Use 'Ajax.Autocompleter' class. Value is the AJAX
+ * function name.
+ * 'browser' - (string) Use 'Autocompleter.Local' class. Value is the
+ * javascript list of items to search.
+ * 'pretty' - (string) Use 'PrettyAutocompleter' class. Value is the AJAX
+ * function name.
+ *
+ * Additional Options:
+ * 'params' - (array) The list of javascript parameters to pass to the
+ * autocomplete libraries.
+ * 'raw_params' - (array) Adds raw javascript to the 'params' array.
+ * 'var' - (string) If set, the autocomplete object will be assigned to
+ * this variable.
+ * </pre>
+ */
+ abstract protected function _attach($js_params);
+
+}
--- /dev/null
+<?php
+/**
+ * Geocode client for the Geonames API.
+ *
+ * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Core
+ */
+class Horde_Core_Ajax_Imple_Geocoder_Geonames extends Horde_Core_Ajax_Imple
+{
+ /**
+ * Constructor.
+ *
+ * @param array $params Configuration parameters.
+ * <pre>
+ * 'triggerId' => (string) [optional] TODO
+ * </pre>
+ */
+ public function __construct($params)
+ {
+ parent::__construct($params);
+ }
+
+ /**
+ * Attach the object to a javascript event.
+ */
+ public function attach()
+ {
+ }
+
+ /**
+ * Handle the geocoding request.
+ *
+ * @TODO: For reverse requests come up with a reasonable algorithm for
+ * checking if we have a lat/lng in the US since the
+ * findNearestAddress method is US only. If non-us, fallback to a
+ * findNearest or findPostalcode or similar request. Also will need
+ * to normalize the various response structures.
+ *
+ * $args['locations'] will trigger a forward geocoding request.
+ * $args['lat'] and $args['lon'] will trigger a reverse geocoding request.
+ *
+ * @see Horde_Core_Ajax_Imple#handle($args, $post)
+ * @throws Horde_Exception
+ */
+ public function handle($args, $post)
+ {
+ if ($args['location']) {
+ $url = new Horde_Url('http://ws.geonames.org/searchJSON');
+ $url = $url->add('q', $args['location']);
+ } elseif (!empty($args['lat']) && !empty($args['lon'])) {
+ $url = new Horde_Url('http:/ws.geonames.org/findNearestJSON');
+ $url = $url->add(array('lat' => $args['lat'], 'lng' => $args['lon']));
+ }
+
+ $client = $GLOBALS['injector']->getInstance('Horde_Http_Client')->getClient();
+ try {
+ $response = $client->get($url);
+ } catch (Horde_Http_Exception $e) {
+ throw new Horde_Exception_Prior($e);
+ }
+
+ return array(
+ 'results' => $response->getBody(),
+ 'status' => 200
+ );
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Attach the spellchecker to a javascript element.
+ *
+ * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Core
+ */
+class Horde_Core_Ajax_Imple_SpellChecker extends Horde_Core_Ajax_Imple
+{
+ /**
+ * Constructor.
+ *
+ * @param array $params Configuration parameters.
+ * <pre>
+ * 'id' => TODO (optional)
+ * 'locales' => TODO (optional)
+ * 'states' => TODO (optional)
+ * 'targetId' => TODO (optional)
+ * 'triggerId' => TODO (optional)
+ * </pre>
+ */
+ public function __construct($params = array())
+ {
+ if (empty($params['id'])) {
+ $params['id'] = $this->_randomid();
+ }
+
+ if (empty($params['targetId'])) {
+ $params['targetId'] = $this->_randomid();
+ }
+
+ if (empty($params['triggerId'])) {
+ $params['triggerId'] = $params['targetId'] . '_trigger';
+ }
+
+ if (empty($params['locales'])) {
+ $key_list = array_keys($GLOBALS['registry']->nlsconfig['spelling']);
+ asort($key_list, SORT_LOCALE_STRING);
+ $params['locales'] = array();
+
+ foreach ($key_list as $lcode) {
+ $params['locales'][] = array('l' => $GLOBALS['registry']->nlsconfig['languages'][$lcode], 'v' => $lcode);
+ }
+ }
+
+ parent::__construct($params);
+ }
+
+ /**
+ */
+ public function attach()
+ {
+ Horde::addScriptFile('prototype.js', 'horde');
+ Horde::addScriptFile('effects.js', 'horde');
+ Horde::addScriptFile('keynavlist.js', 'horde');
+ Horde::addScriptFile('spellchecker.js', 'horde');
+
+ $opts = array(
+ 'locales' => $this->_params['locales'],
+ 'sc' => 'widget',
+ 'statusButton' => $this->_params['triggerId'],
+ 'target' => $this->_params['targetId'],
+ 'url' => strval($this->_getUrl('SpellChecker', 'horde', array('input' => $this->_params['targetId'])))
+ );
+ if (isset($this->_params['states'])) {
+ $opts['bs'] = $this->_params['states'];
+ }
+
+ Horde::addInlineScript(array(
+ $this->_params['id'] . ' = new SpellChecker(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')'
+ ), 'dom');
+ }
+
+ /**
+ */
+ public function handle($args, $post)
+ {
+ $spellArgs = array();
+
+ if (!empty($GLOBALS['conf']['spell']['params'])) {
+ $spellArgs = $GLOBALS['conf']['spell']['params'];
+ }
+
+ if (isset($args['locale'])) {
+ $spellArgs['locale'] = $args['locale'];
+ } elseif (isset($GLOBALS['language'])) {
+ $spellArgs['locale'] = $GLOBALS['language'];
+ }
+
+ /* Add local dictionary words. */
+ try {
+ $result = Horde::loadConfiguration('spelling.php', 'ignore_list', 'horde');
+ $spellArgs['localDict'] = $result;
+ } catch (Horde_Exception $e) {}
+
+ if (!empty($args['html'])) {
+ $spellArgs['html'] = true;
+ }
+
+ try {
+ $speller = Horde_SpellChecker::factory($GLOBALS['conf']['spell']['driver'], $spellArgs);
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e, 'ERR');
+ return array();
+ }
+
+ try {
+ return $speller->spellCheck(Horde_Util::getPost($args['input']));
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e, 'ERR');
+ return array('bad' => array(), 'suggestions' => array());
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * @category Horde
+ * @package Core
+ */
+class Horde_Core_Binder_Ajax implements Horde_Injector_Binder
+{
+ public function create(Horde_Injector $injector)
+ {
+ return new Horde_Core_Factory_Ajax($injector);
+ }
+
+ public function equals(Horde_Injector_Binder $binder)
+ {
+ return false;
+ }
+}
--- /dev/null
+<?php
+/**
+ * @category Horde
+ * @package Core
+ */
+class Horde_Core_Binder_Imple implements Horde_Injector_Binder
+{
+ public function create(Horde_Injector $injector)
+ {
+ return new Horde_Core_Factory_Imple($injector);
+ }
+
+ public function equals(Horde_Injector_Binder $binder)
+ {
+ return false;
+ }
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector:: based Horde_Core_Ajax_Application:: factory.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Core
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Core
+ */
+
+/**
+ * A Horde_Injector:: based Horde_Core_Ajax_Application:: factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package Core
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Core
+ */
+class Horde_Core_Factory_Ajax
+{
+ /**
+ * The injector.
+ *
+ * @var Horde_Injector
+ */
+ private $_injector;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Injector $injector The injector to use.
+ */
+ public function __construct(Horde_Injector $injector)
+ {
+ $this->_injector = $injector;
+ }
+
+ /**
+ * Return a Horde_Core_Ajax_Application instance.
+ *
+ * @param string $app The application name.
+ * @param Horde_Variables $vars Form/request data.
+ * @param string $action The AJAX action to perform.
+ *
+ * @return Horde_Core_Ajax_Application The requested instance.
+ * @throws Horde_Exception
+ */
+ public function getAjax($app, $vars, $action = null)
+ {
+ $class = $app . '_Ajax_Application';
+
+ if (class_exists($class)) {
+ return new $class($app, $vars, $action);
+ }
+
+ throw new Horde_Exception('Ajax configuration for ' . $app . ' not found.');
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector:: based Horde_Core_Ajax_Imple:: factory.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Core
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Core
+ */
+
+/**
+ * A Horde_Injector:: based Horde_Core_Ajax_Imple:: factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package Core
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Core
+ */
+class Horde_Core_Factory_Imple
+{
+ /**
+ * The injector.
+ *
+ * @var Horde_Injector
+ */
+ private $_injector;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Injector $injector The injector to use.
+ */
+ public function __construct(Horde_Injector $injector)
+ {
+ $this->_injector = $injector;
+ }
+
+ /**
+ * Attempts to return a concrete Imple instance.
+ *
+ * @param mixed $driver The type of concrete subclass to return. If
+ * $driver is an array, then look in
+ * $driver[0]/lib/Ajax/Imple for the subclass
+ * implementation named $driver[1].php.
+ * @param array $params A hash containing any additional configuration or
+ * parameters a subclass might need.
+ * @param boolean $noattach Don't attach on creation.
+ *
+ * @return Horde_Core_Ajax_Imple The newly created instance.
+ * @throws Horde_Exception
+ */
+ public function getImple($driver, array $params = array(),
+ $noattach = false)
+ {
+ if (is_array($driver)) {
+ list($app, $driv_name) = $driver;
+ $driver = ucfirst(basename($driv_name));
+ $class = ucfirst($app) . '_Ajax_Imple_' . $driver;
+ } else {
+ $driver = basename($driver);
+ $class = 'Horde_Core_Ajax_Imple_' . $driver;
+ }
+
+ if (class_exists($class)) {
+ $ob = new $class($params);
+ if (!$noattach) {
+ $ob->attach();
+ }
+ return $ob;
+ }
+
+ throw new Horde_Exception('Imple driver ' . $driver . ' not found.');
+ }
+
+}
/* 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
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>
-* Import application auth driver from horde/Auth.
+ <notes>* Absorb horde/Ajax package.
+ * Import application auth driver from horde/Auth.
* Import signup code from horde/Auth.
* Import Horde backend driver from horde/LoginTasks.
* Import perms UI handling class from horde/Perms.
<file name="Form.php" role="php" />
</dir> <!-- /lib/Horde/Config -->
<dir name="Core">
+ <dir name="Ajax">
+ <dir name="Imple">
+ <file name="AutoCompleter.php" role="php" />
+ <file name="SpellChecker.php" role="php" />
+ <dir name="Geocoder">
+ <file name="Geonames.php" role="php" />
+ </dir> <!-- /lib/Horde/Core/Ajax/Imple/Geocoder -->
+ </dir> <!-- /lib/Horde/Core/Ajax/Imple -->
+ <file name="Application.php" role="php" />
+ <file name="Imple.php" role="php" />
+ </dir> <!-- /lib/Horde/Core/Ajax -->
<dir name="Auth">
<dir name="Signup">
<file name="Base.php" role="php" />
</dir> <!-- /lib/Horde/Core/Autoloader/Callback -->
</dir> <!-- /lib/Horde/Core/Autoloader -->
<dir name="Binder">
+ <file name="Ajax.php" role="php" />
<file name="Alarm.php" role="php" />
<file name="Auth.php" role="php" />
<file name="AuthSignup.php" role="php" />
<file name="History.php" role="php" />
<file name="HttpClient.php" role="php" />
<file name="Identity.php" role="php" />
+ <file name="Imple.php" role="php" />
<file name="Ldap.php" role="php" />
<file name="Lock.php" role="php" />
<file name="Logger.php" role="php" />
<file name="Vfs.php" role="php" />
</dir> <!-- /lib/Horde/Core/Binder -->
<dir name="Factory">
+ <file name="Ajax.php" role="php" />
<file name="Auth.php" role="php" />
<file name="Crypt.php" role="php" />
<file name="Data.php" role="php" />
<file name="Editor.php" role="php" />
<file name="HttpClient.php" role="php" />
<file name="Identity.php" role="php" />
+ <file name="Imple.php" role="php" />
<file name="KolabServer.php" role="php" />
<file name="KolabSession.php" role="php" />
<file name="KolabStorage.php" role="php" />
<install as="Horde/Registry.php" name="lib/Horde/Registry.php" />
<install as="Horde/Themes.php" name="lib/Horde/Themes.php" />
<install as="Horde/Config/Form.php" name="lib/Horde/Config/Form.php" />
- <install as="Horde/Core/Autoloader.php" name="lib/Horde/Core/Autoloader.php" />
+ <install as="Horde/Core/Ajax/Imple/AutoCompleter.php" name="lib/Horde/Core/Ajax/Imple/AutoCompleter.php" />
+ <install as="Horde/Core/Ajax/Imple/SpellChecker.php" name="lib/Horde/Core/Ajax/Imple/SpellChecker.php" />
+ <install as="Horde/Core/Ajax/Imple/Geocoder/Geonames.php" name="lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php" />
+ <install as="Horde/Core/Ajax/Application.php" name="lib/Horde/Core/Ajax/Application.php" />
+ <install as="Horde/Core/Ajax/Imple.php" name="lib/Horde/Core/Ajax/Imple.php" />
<install as="Horde/Core/Auth/Application.php" name="lib/Horde/Core/Auth/Application.php" />
<install as="Horde/Core/Auth/Ldap.php" name="lib/Horde/Core/Auth/Ldap.php" />
<install as="Horde/Core/Auth/Msad.php" name="lib/Horde/Core/Auth/Msad.php" />
<install as="Horde/Core/Auth/Signup/SqlObject.php" name="lib/Horde/Core/Auth/Signup/SqlObject.php" />
<install as="Horde/Core/Autoloader/Callback/Mime.php" name="lib/Horde/Core/Autoloader/Callback/Mime.php" />
<install as="Horde/Core/Autoloader/Callback/Nls.php" name="lib/Horde/Core/Autoloader/Callback/Nls.php" />
+ <install as="Horde/Core/Binder/Ajax.php" name="lib/Horde/Core/Binder/Ajax.php" />
<install as="Horde/Core/Binder/Alarm.php" name="lib/Horde/Core/Binder/Alarm.php" />
<install as="Horde/Core/Binder/Auth.php" name="lib/Horde/Core/Binder/Auth.php" />
<install as="Horde/Core/Binder/AuthSignup.php" name="lib/Horde/Core/Binder/AuthSignup.php" />
<install as="Horde/Core/Binder/History.php" name="lib/Horde/Core/Binder/History.php" />
<install as="Horde/Core/Binder/HttpClient.php" name="lib/Horde/Core/Binder/HttpClient.php" />
<install as="Horde/Core/Binder/Identity.php" name="lib/Horde/Core/Binder/Identity.php" />
+ <install as="Horde/Core/Binder/Imple.php" name="lib/Horde/Core/Binder/Imple.php" />
<install as="Horde/Core/Binder/Ldap.php" name="lib/Horde/Core/Binder/Ldap.php" />
<install as="Horde/Core/Binder/Lock.php" name="lib/Horde/Core/Binder/Lock.php" />
<install as="Horde/Core/Binder/Logger.php" name="lib/Horde/Core/Binder/Logger.php" />
<install as="Horde/Core/Binder/Token.php" name="lib/Horde/Core/Binder/Token.php" />
<install as="Horde/Core/Binder/Twitter.php" name="lib/Horde/Core/Binder/Twitter.php" />
<install as="Horde/Core/Binder/Vfs.php" name="lib/Horde/Core/Binder/Vfs.php" />
+ <install as="Horde/Core/Factory/Ajax.php" name="lib/Horde/Core/Factory/Ajax.php" />
<install as="Horde/Core/Factory/Auth.php" name="lib/Horde/Core/Factory/Auth.php" />
<install as="Horde/Core/Factory/Crypt.php" name="lib/Horde/Core/Factory/Crypt.php" />
<install as="Horde/Core/Factory/Data.php" name="lib/Horde/Core/Factory/Data.php" />
<install as="Horde/Core/Factory/Editor.php" name="lib/Horde/Core/Factory/Editor.php" />
<install as="Horde/Core/Factory/HttpClient.php" name="lib/Horde/Core/Factory/HttpClient.php" />
<install as="Horde/Core/Factory/Identity.php" name="lib/Horde/Core/Factory/Identity.php" />
+ <install as="Horde/Core/Factory/Imple.php" name="lib/Horde/Core/Factory/Imple.php" />
<install as="Horde/Core/Factory/KolabServer.php" name="lib/Horde/Core/Factory/KolabServer.php" />
<install as="Horde/Core/Factory/KolabSession.php" name="lib/Horde/Core/Factory/KolabSession.php" />
<install as="Horde/Core/Factory/KolabStorage.php" name="lib/Horde/Core/Factory/KolabStorage.php" />
<install as="Horde/Core/Text/Filter/Emoticons.php" name="lib/Horde/Core/Text/Filter/Emoticons.php" />
<install as="Horde/Core/Tree/Html.php" name="lib/Horde/Core/Tree/Html.php" />
<install as="Horde/Core/Tree/Javascript.php" name="lib/Horde/Core/Tree/Javascript.php" />
+ <install as="Horde/Core/Autoloader.php" name="lib/Horde/Core/Autoloader.php" />
<install as="Horde/Exception/HookNotSet.php" name="lib/Horde/Exception/HookNotSet.php" />
<install as="Horde/Registry/Api.php" name="lib/Horde/Registry/Api.php" />
<install as="Horde/Registry/Application.php" name="lib/Horde/Registry/Application.php" />
* $vars (Horde_Variables): The URL parameters.
*
* The return value from this hook is as follows:
- * [throw Horde_Ajax_Exception] - Fatal error.
+ * [throw Horde_Exception] - Fatal error.
* [mixed] - The data to send to the browser (will be JSON encoded).
*
*
* $theme (string): The current theme.
*
* The return value from this hook is as follows:
- * [throw Horde_Ajax_Exception] - Fatal error.
+ * [throw Horde_Exception] - Fatal error.
* [array] - An array of CSS files to add. Keys are the filesystem location,
* values are the URI location.
*
/**
* 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.
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;
// 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) {
<?php
/**
- * Handle Horde_Ajax_Imple:: requests.
+ * Handle Horde_Core_Ajax_Imple:: requests.
*
* Mandatory components:
* 'imple'
$impleargs = array($args['impleApp'], $impleName);
}
-$imple = Horde_Ajax_Imple::factory($impleargs);
+$imple = $injector->getInstance('Horde_Ajax_Imple')->getImple($impleargs);
$result = $imple->handle($args, $post);
$ct = empty($_SERVER['Content-Type'])
* @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)
// {
// return 'bar';
// }
//
-// throw new Horde_Ajax_Exception('Unknown action');
+// throw new Horde_Exception('Unknown action');
// }
* @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.
* @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?
* @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.
/* Ask for the correct passphrase if this is encrypted
* symmetrically. */
- $imple = Horde_Ajax_Imple::factory(array('imp', 'PassphraseDialog'), array('params' => array('symmetricid' => $symmetric_id), 'type' => 'pgpSymmetric'));
- $imple->attach();
+ $imple = $GLOBALS['registry']->getInstance('Horde_Ajax_Imple')->getImple(array('imp', 'PassphraseDialog'), array(
+ 'params' => array(
+ 'symmetricid' => $symmetric_id
+ ),
+ 'type' => 'pgpSymmetric'
+ ));
$status[] = Horde::link('#', '', '', '', '', '', '', array('id' => $imple->getPassphraseId())) . _("You must enter the passphrase used to encrypt this message to view it.") . '</a>';
return null;
}
if (is_null($personal_pass)) {
/* Ask for the private key's passphrase if this is
* encrypted asymmetrically. */
- $imple = Horde_Ajax_Imple::factory(array('imp', 'PassphraseDialog'), array('type' => 'pgpPersonal'));
- $imple->attach();
+ $imple = $GLOBALS['registry']->getInstance('Horde_Ajax_Imple')->getImple(array('imp', 'PassphraseDialog'), array(
+ 'type' => 'pgpPersonal'
+ ));
$status[] = Horde::link('#', '', '', '', '', '', '', array('id' => $imple->getPassphraseId())) . _("You must enter the passphrase for your PGP private key to view this message.") . '</a>';
return null;
}
/* Make sure we have a passphrase. */
$passphrase = $this->_impsmime->getPassphrase();
if (is_null($passphrase)) {
- $imple = Horde_Ajax_Imple::factory(array('imp', 'PassphraseDialog'), array('type' => 'smimePersonal'));
- $imple->attach();
+ $imple = $GLOBALS['registry']->getInstance('Horde_Ajax_Imple')->getImple(array('imp', 'PassphraseDialog'), array(
+ 'type' => 'smimePersonal'
+ ));
$status[] = Horde::link('#', '', '', '', '', '', '', array('id' => $imple->getPassphraseId())) . _("You must enter the passphrase for your S/MIME private key to view this data.") . '</a>';
return null;
}
$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');
$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();
{
/* 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));
}
}
)
);
- Horde_Ajax_Imple::factory('SpellChecker', $args)->attach();
+ $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple('SpellChecker', $args);
}
/**
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
+ ));
}
/**
$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';
$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();
* @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)
// {
// return 'bar';
// }
//
-// throw new Horde_Ajax_Exception('Unknown action');
+// throw new Horde_Exception('Unknown action');
// }
/**
$taskAlarmParams = substr($taskAlarmParams, 0, - 6) . '</div>';
}
-Horde_Ajax_Imple::factory(
+$injector->getInstance('Horde_Ajax_Imple')->getImple(
array('kronolith', 'TagAutoCompleter'),
- array('triggerId' => 'kronolithEventTags',
- 'box' => 'kronolithEventACBox',
- 'pretty' => true,
- 'var' => 'KronolithCore.eventTagAc'))
- ->attach();
+ array(
+ 'box' => 'kronolithEventACBox',
+ 'pretty' => true,
+ 'triggerId' => 'kronolithEventTags',
+ 'var' => 'KronolithCore.eventTagAc'
+ )
+);
-Horde_Ajax_Imple::factory(
+$injector->getInstance('Horde_Ajax_Imple')->getImple(
array('kronolith', 'TagAutoCompleter'),
- array('triggerId' => 'kronolithCalendarinternalTags',
- 'triggerContainer' => 'kronolithACCalendarTriggerContainer',
- 'box' => 'kronolithCalendarinternalACBox',
- 'pretty' => true,
- 'var' => 'KronolithCore.calendarTagAc'))
- ->attach();
+ array(
+ 'box' => 'kronolithCalendarinternalACBox',
+ 'pretty' => true,
+ 'triggerContainer' => 'kronolithACCalendarTriggerContainer',
+ 'triggerId' => 'kronolithCalendarinternalTags',
+ 'var' => 'KronolithCore.calendarTagAc'
+ )
+);
-Horde_Ajax_Imple::factory(
+$injector->getInstance('Horde_Ajax_Imple')->getImple(
array('kronolith', 'ContactAutoCompleter'),
- array('triggerId' => 'kronolithEventAttendees',
- 'triggerContainer' => 'kronolithAttendeesACTriggerContainer',
- 'box' => 'kronolithAttendeesACBox',
- 'pretty' => true,
- 'var' => 'KronolithCore.attendeesAc',
- 'onAdd' => 'KronolithCore.addAttendee.bind(KronolithCore)',
- 'onRemove' => 'KronolithCore.removeAttendee.bind(KronolithCore)'))
- ->attach();
+ array(
+ 'box' => 'kronolithAttendeesACBox',
+ 'onAdd' => 'KronolithCore.addAttendee.bind(KronolithCore)',
+ 'onRemove' => 'KronolithCore.removeAttendee.bind(KronolithCore)',
+ 'pretty' => true,
+ 'triggerContainer' => 'kronolithAttendeesACTriggerContainer',
+ 'triggerId' => 'kronolithEventAttendees',
+ 'var' => 'KronolithCore.attendeesAc'
+ )
+);
if ($conf['maps']['driver']) {
Kronolith::initEventMap($conf['maps']);
* @author Gonçalo Queirós <mail@goncaloqueiros.net>
* @package Kronolith
*/
-class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
+class Kronolith_Ajax_Application extends Horde_Core_Ajax_Application
{
/**
* Determines if notification information is sent in response.
* @author Michael Slusarz <slusarz@horde.org>
* @package Kronolith
*/
-class Kronolith_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_AutoCompleter
+class Kronolith_Ajax_Imple_ContactAutoCompleter extends Horde_Core_Ajax_Imple_AutoCompleter
{
/**
* Attach the Imple object to a javascript event.
*
- * @param array $js_params See Horde_Ajax_Imple_AutoCompleter::_attach().
+ * @param array $js_params See
+ * Horde_Core_Ajax_Imple_AutoCompleter::_attach().
*
- * @return array See Horde_Ajax_Imple_AutoCompleter::_attach().
+ * @return array See Horde_Core_Ajax_Imple_AutoCompleter::_attach().
*/
protected function _attach($js_params)
{
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Kronolith
*/
-class Kronolith_Ajax_Imple_Embed extends Horde_Ajax_Imple_Base
+class Kronolith_Ajax_Imple_Embed extends Horde_Core_Ajax_Imple
{
/**
*/
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Kronolith
*/
-class Kronolith_Ajax_Imple_TagActions extends Horde_Ajax_Imple_Base
+class Kronolith_Ajax_Imple_TagActions extends Horde_Core_Ajax_Imple
{
/**
*/
* @author Michael Slusarz <slusarz@horde.org>
* @package Kronolith
*/
-class Kronolith_Ajax_Imple_TagAutoCompleter extends Horde_Ajax_Imple_AutoCompleter
+class Kronolith_Ajax_Imple_TagAutoCompleter extends Horde_Core_Ajax_Imple_AutoCompleter
{
/**
* Attach the Imple object to a javascript event.
* If the 'pretty' parameter is empty then we want a
* traditional autocompleter, otherwise we get a spiffy pretty one.
*
- * @param array $js_params See Horde_Ajax_Imple_AutoCompleter::_attach().
+ * @param array $js_params See
+ * Horde_Core_Ajax_Imple_AutoCompleter::_attach().
*
- * @return array See Horde_Ajax_Imple_AutoCompleter::_attach().
+ * @return array See Horde_Core_Ajax_Imple_AutoCompleter::_attach().
*/
protected function _attach($js_params)
{
public static function embedCode($calendar)
{
/* Get the base url */
- $imple = Horde_Ajax_Imple::factory(array('kronolith', 'Embed'),
- array('container' => 'kronolithCal',
- 'view' => 'month',
- 'calendar' => $calendar));
+ $imple = $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'Embed'), array(
+ 'calendar' => $calendar,
+ 'container' => 'kronolithCal',
+ 'view' => 'month'
+ ), true);
-
- $url = $imple->getUrl();
-
- $html = '<div id="kronolithCal"></div><script src="' . $url
+ $html = '<div id="kronolithCal"></div><script src="' . $imple->getUrl()
. '" type="text/javascript"></script>';
return $html;
<td colspan="4">
<input type="text" name="tags" id="tags" value="<?php echo (!empty($tags) ? htmlspecialchars($tags) : '')?>" size="40" />
<span id="tags_loading_img" style="display:none;"><?php echo Horde::img('loading.gif', _("Loading...")) ?></span>
- <?php $tac = Horde_Ajax_Imple::factory(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'tags', 'id' => $event->uid));
- $tac->attach();
- ?>
+ <?php $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'tags', 'id' => $event->uid)); ?>
</td>
</tr>
<!-- spacer -->
. Horde::img('delete-small.png', _("Remove Tag"))
. '</a>';
}
-$ta = Horde_Ajax_Imple::factory(array('kronolith', 'TagActions'),
- array('triggerId' => 'remove' . md5($id . $tag_id),
- 'action' => 'delete',
- 'resource' => $id,
- 'type' => 'calendar',
- 'tagId' => $tag_id));
-$ta->attach();
+$GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'TagActions'), array(
+ 'action' => 'delete',
+ 'resource' => $id,
+ 'tagId' => $tag_id,
+ 'triggerId' => 'remove' . md5($id . $tag_id),
+ 'type' => 'calendar'
+));
?>
</li>
<?php endforeach;?>
<input type="text" name="newtags-input_<?php echo $id?>" id="newtags-input_<?php echo $id?>" size="10" /><input type="button" class="button" value="add" name="newtags-button_<?php echo $id?>" id="newtags-button_<?php echo $id?>" />
<span id="newtags-input_<?php echo $id?>_loading_img" style="display:none;"><?php echo Horde::img('loading.gif', _("Loading...")) ?></span>
<?php
- $tac = Horde_Ajax_Imple::factory(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'newtags-input_' . $id, 'id' => $id));
- $tac->attach();
- $ta = Horde_Ajax_Imple::factory(array('kronolith', 'TagActions'),
- array('triggerId' => 'newtags-button',
- 'resource' => $id,
- 'type' => 'calendar',
- 'action' => 'add'));
- $ta->attach();
+ $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'TagAutoCompleter'), array(
+ 'id' => $id,
+ 'triggerId' => 'newtags-input_' . $id
+ ));
+ $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('kronolith', 'TagActions'), array(
+ 'action' => 'add',
+ 'resource' => $id,
+ 'triggerId' => 'newtags-button',
+ 'type' => 'calendar'
+ ));
?>
</div>
</div>
* @author Ben Klang <ben@alkaloid.net>
* @package Shout
*/
-class Shout_Ajax_Application extends Horde_Ajax_Application_Base
+class Shout_Ajax_Application extends Horde_Core_Ajax_Application
{
protected $_responseType = 'json';
/**
* @package Whups
*/
-class Whups_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_AutoCompleter
+class Whups_Ajax_Imple_ContactAutoCompleter extends Horde_Core_Ajax_Imple_AutoCompleter
{
/**
{
$name = $var->getVarName();
- $imple = Horde_Ajax_Imple::factory(array('whups', 'ContactAutoCompleter'), array('triggerId' => $name));
- $imple->attach();
+ $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('whups', 'ContactAutoCompleter'), array(
+ 'triggerId' => $name
+ ));
+
return sprintf('<input type="text" name="%s" id="%s" value="%s" autocomplete="off"%s />',
$name,
$name,