1: <?php
2: /**
3: * Class to attach PHP actions to javascript elements.
4: *
5: * Copyright 2005-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (LGPL). If you
8: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
9: *
10: * @author Michael Slusarz <slusarz@horde.org>
11: * @category Horde
12: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
13: * @package Core
14: */
15: abstract class Horde_Core_Ajax_Imple
16: {
17: /**
18: * Parameters needed by the subclasses.
19: *
20: * @var array
21: */
22: protected $_params = array();
23:
24: /**
25: * Constructor.
26: *
27: * @param array $params Any parameters needed by the class.
28: */
29: public function __construct($params)
30: {
31: $this->_params = $params;
32: }
33:
34: /**
35: * Attach the object to a javascript event.
36: */
37: abstract public function attach();
38:
39: /**
40: * TODO
41: *
42: * @param array $args TODO
43: */
44: abstract public function handle($args, $post);
45:
46: /**
47: * TODO
48: *
49: * @param string $driver
50: * @param string $app
51: * @param array $params
52: * @param boolean $full
53: *
54: * @return Horde_Url
55: */
56: protected function _getUrl($driver, $app = 'horde', $params = array(),
57: $full = false)
58: {
59: $qstring = $driver;
60:
61: if ($app != 'horde') {
62: $qstring .= '/impleApp=' . $app;
63: }
64:
65: foreach ($params as $key => $val) {
66: $qstring .= '/' . $key . '=' . rawurlencode($val);
67: }
68:
69: return Horde::url(Horde::getServiceLink('imple')->url, $full, array('noajax' => true))->setRaw(true)->add('imple', $qstring);
70: }
71:
72: /**
73: * Generate a random ID string.
74: *
75: * @return string The random ID string.
76: */
77: protected function _randomid()
78: {
79: return strval(new Horde_Support_Randomid());
80: }
81:
82: }
83: