--- /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-2009 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
+{
+ /**
+ * Parameters needed by the subclasses.
+ *
+ * @var array
+ */
+ protected $_params = array();
+
+ /**
+ * 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 getInstance($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
+/**
+ * Class to attach PHP actions to javascript elements.
+ *
+ * Copyright 2005-2009 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);
+
+ /**
+ * TODO
+ *
+ * @param string $driver
+ * @param string $app
+ * @param array $params
+ *
+ * @return string
+ */
+ protected function _getUrl($driver, $app = 'horde', $params = array())
+ {
+ $qstring = 'imple=' . $driver;
+
+ if ($app != 'horde') {
+ $qstring .= '/impleApp=' . $app;
+ }
+
+ foreach ($params as $key => $val) {
+ $qstring .= '/' . $key . '=' . rawurlencode($val);
+ }
+
+ $registry = Horde_Registry::singleton();
+ return Horde::url($registry->get('webroot', 'horde') . '/services/imple.php?' . $qstring);
+ }
+
+ /**
+ * Generate a random ID string.
+ *
+ * @return string The random ID string.
+ */
+ protected function _randomid()
+ {
+ return 'imple_' . uniqid(mt_rand());
+ }
+
+}
--- /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>* Initial release.
+ </notes>
+ <contents>
+ <dir name="/">
+ <dir name="lib">
+ <dir name="Horde">
+ <dir name="Ajax">
+ <dir name="Imple">
+ <file name="Base.php" role="php" />
+ </dir> <!-- /lib/Horde/Ajax/Imple -->
+ <file name="Imple.php" role="php" />
+ </dir> <!-- /lib/Horde/Ajax -->
+ </dir> <!-- /lib/Horde -->
+ </dir> <!-- /lib -->
+ </dir> <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.7.0</min>
+ </pearinstaller>
+ </required>
+ <package>
+ <name>Core</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <optional/>
+ </dependencies>
+ <phprelease>
+ <filelist>
+ <install name="lib/Horde/Ajax/Imple/Base.php" as="Horde/Ajax/Imple/Base.php" />
+ <install name="lib/Horde/Ajax/Imple.php" as="Horde/Ajax/Imple.php" />
+ </filelist>
+ </phprelease>
+ <changelog/>
+</package>