1: <?php
2: /**
3: * Defines the AJAX interface for Horde.
4: *
5: * Copyright 2010-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 Horde
14: */
15: class Horde_Ajax_Application extends Horde_Core_Ajax_Application
16: {
17: /**
18: */
19: public function responseType()
20: {
21: switch ($this->_action) {
22: case 'blockAutoUpdate':
23: case 'blockRefresh':
24: return 'html';
25: }
26:
27: return parent::responseType();
28: }
29:
30: /**
31: * AJAX action: Update sidebar.
32: *
33: * @return object See Horde_Tree_Javascript#renderNodeDefinitions().
34: */
35: public function sidebarUpdate()
36: {
37: return $GLOBALS['injector']->getInstance('Horde_Core_Sidebar')->getTree()->renderNodeDefinitions();
38: }
39:
40: /**
41: * AJAX action: Auto-update portal block.
42: */
43: public function blockAutoUpdate()
44: {
45: if (isset($this->_vars->app) && isset($this->_vars->blockid)) {
46: try {
47: return $GLOBALS['injector']
48: ->getInstance('Horde_Core_Factory_BlockCollection')
49: ->create()
50: ->getBlock($this->_vars->app, $this->_vars->blockid)
51: ->getContent(isset($this->_vars->options) ? $this->_vars->options : null);
52: } catch (Exception $e) {
53: return $e->getMessage();
54: }
55: }
56:
57: return '';
58: }
59:
60: public function blockRefresh()
61: {
62: if (isset($this->_vars->app) && isset($this->_vars->blockid)) {
63: try {
64: return $GLOBALS['injector']
65: ->getInstance('Horde_Core_Factory_BlockCollection')
66: ->create()
67: ->getBlock($this->_vars->app, $this->_vars->blockid)
68: ->refreshContent($this->_vars);
69: } catch (Exception $e) {
70: return $e->getMessage();
71: }
72: }
73:
74: return '';
75: }
76:
77: /**
78: * AJAX action: Update portal block.
79: */
80: public function blockUpdate()
81: {
82: if (isset($this->_vars->blockid)) {
83: try {
84: return $GLOBALS['injector']
85: ->getInstance('Horde_Core_Factory_BlockCollection')
86: ->create()
87: ->getBlock($this->_vars->blockid)
88: ->getAjaxUpdate($this->_vars);
89: } catch (Exception $e) {
90: return $e->getMessage();
91: }
92: }
93:
94: return '';
95: }
96:
97: }
98: