Overview

Packages

  • Auth
  • Core
  • Horde
    • Imsp
  • None
  • Notification

Classes

  • Horde
  • Horde_Config
  • Horde_Config_Form
  • Horde_Core_ActiveSync_Connector
  • Horde_Core_ActiveSync_Driver
  • Horde_Core_Ajax_Application
  • Horde_Core_Ajax_Imple
  • Horde_Core_Ajax_Imple_AutoCompleter
  • Horde_Core_Ajax_Imple_Geocoder_Geonames
  • Horde_Core_Ajax_Imple_SpellChecker
  • Horde_Core_Alarm_Handler_Notify
  • Horde_Core_Auth_Application
  • Horde_Core_Auth_Composite
  • Horde_Core_Auth_Ldap
  • Horde_Core_Auth_Msad
  • Horde_Core_Auth_Shibboleth
  • Horde_Core_Auth_Signup_Base
  • Horde_Core_Auth_Signup_Form
  • Horde_Core_Auth_Signup_Null
  • Horde_Core_Auth_Signup_Sql
  • Horde_Core_Auth_Signup_SqlObject
  • Horde_Core_Autoloader_Callback_Mime
  • Horde_Core_Autoloader_Callback_Nls
  • Horde_Core_Block
  • Horde_Core_Block_Collection
  • Horde_Core_Block_Layout
  • Horde_Core_Block_Layout_Manager
  • Horde_Core_Block_Layout_View
  • Horde_Core_Block_Upgrade
  • Horde_Core_Browser
  • Horde_Core_Bundle
  • Horde_Core_Cli
  • Horde_Core_Controller_NotFound
  • Horde_Core_Controller_RequestConfiguration
  • Horde_Core_Controller_RequestMapper
  • Horde_Core_Controller_SettingsFinder
  • Horde_Core_Db_Migration
  • Horde_Core_Factory_ActiveSyncBackend
  • Horde_Core_Factory_ActiveSyncServer
  • Horde_Core_Factory_ActiveSyncState
  • Horde_Core_Factory_Ajax
  • Horde_Core_Factory_Alarm
  • Horde_Core_Factory_Auth
  • Horde_Core_Factory_AuthSignup
  • Horde_Core_Factory_Base
  • Horde_Core_Factory_BlockCollection
  • Horde_Core_Factory_Browser
  • Horde_Core_Factory_Cache
  • Horde_Core_Factory_Crypt
  • Horde_Core_Factory_Data
  • Horde_Core_Factory_Db
  • Horde_Core_Factory_DbBase
  • Horde_Core_Factory_DbPear
  • Horde_Core_Factory_Dns
  • Horde_Core_Factory_Editor
  • Horde_Core_Factory_Facebook
  • Horde_Core_Factory_Group
  • Horde_Core_Factory_History
  • Horde_Core_Factory_HttpClient
  • Horde_Core_Factory_Identity
  • Horde_Core_Factory_Image
  • Horde_Core_Factory_Imple
  • Horde_Core_Factory_Imsp
  • Horde_Core_Factory_ImspAuth
  • Horde_Core_Factory_Injector
  • Horde_Core_Factory_KolabServer
  • Horde_Core_Factory_KolabSession
  • Horde_Core_Factory_KolabStorage
  • Horde_Core_Factory_Ldap
  • Horde_Core_Factory_Lock
  • Horde_Core_Factory_Logger
  • Horde_Core_Factory_LoginTasks
  • Horde_Core_Factory_Mail
  • Horde_Core_Factory_Mapper
  • Horde_Core_Factory_Matcher
  • Horde_Core_Factory_Memcache
  • Horde_Core_Factory_MimeViewer
  • Horde_Core_Factory_Notification
  • Horde_Core_Factory_Perms
  • Horde_Core_Factory_PermsCore
  • Horde_Core_Factory_Prefs
  • Horde_Core_Factory_Request
  • Horde_Core_Factory_Secret
  • Horde_Core_Factory_SessionHandler
  • Horde_Core_Factory_Share
  • Horde_Core_Factory_ShareBase
  • Horde_Core_Factory_Template
  • Horde_Core_Factory_TextFilter
  • Horde_Core_Factory_ThemesCache
  • Horde_Core_Factory_Token
  • Horde_Core_Factory_Tree
  • Horde_Core_Factory_Twitter
  • Horde_Core_Factory_UrlShortener
  • Horde_Core_Factory_Vfs
  • Horde_Core_Factory_View
  • Horde_Core_Factory_Weather
  • Horde_Core_Group_Ldap
  • Horde_Core_Log_Logger
  • Horde_Core_LoginTasks
  • Horde_Core_LoginTasks_Backend_Horde
  • Horde_Core_LoginTasks_SystemTask_Upgrade
  • Horde_Core_Mime_Viewer_Syntaxhighlighter
  • Horde_Core_Mime_Viewer_Vcard
  • Horde_Core_Notification_Event_Status
  • Horde_Core_Notification_Handler_Decorator_Hordelog
  • Horde_Core_Notification_Storage_Session
  • Horde_Core_Perms
  • Horde_Core_Perms_Ui
  • Horde_Core_Prefs_Cache_Session
  • Horde_Core_Prefs_Identity
  • Horde_Core_Prefs_Storage_Configuration
  • Horde_Core_Prefs_Storage_Hooks
  • Horde_Core_Prefs_Storage_Upgrade
  • Horde_Core_Prefs_Ui
  • Horde_Core_Prefs_Ui_Widgets
  • Horde_Core_Share_Driver
  • Horde_Core_Share_FactoryCallback
  • Horde_Core_Sidebar
  • Horde_Core_Text_Filter_Bbcode
  • Horde_Core_Text_Filter_Emails
  • Horde_Core_Text_Filter_Emoticons
  • Horde_Core_Text_Filter_Highlightquotes
  • Horde_Core_Translation
  • Horde_Core_Tree_Html
  • Horde_Core_Tree_Javascript
  • Horde_Core_Tree_Simplehtml
  • Horde_Core_Ui_FlagImage
  • Horde_Core_Ui_JsCalendar
  • Horde_Core_Ui_Language
  • Horde_Core_Ui_Layout
  • Horde_Core_Ui_ModalFormRenderer
  • Horde_Core_Ui_Pager
  • Horde_Core_Ui_Tabs
  • Horde_Core_Ui_TagCloud
  • Horde_Core_Ui_VarRenderer
  • Horde_Core_Ui_VarRenderer_Html
  • Horde_Core_Ui_VarRenderer_TablesetHtml
  • Horde_Core_Ui_Widget
  • Horde_ErrorHandler
  • Horde_Help
  • Horde_Menu
  • Horde_Registry
  • Horde_Registry_Api
  • Horde_Registry_Application
  • Horde_Registry_Caller
  • Horde_Registry_Nlsconfig
  • Horde_Script_Files
  • Horde_Session
  • Horde_Session_Null
  • Horde_Themes
  • Horde_Themes_Cache
  • Horde_Themes_Css
  • Horde_Themes_Element
  • Horde_Themes_Image
  • Horde_Themes_Sound

Exceptions

  • Horde_Exception_HookNotSet
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * An abstract class representing a single block in the portal/block display.
  4:  *
  5:  * Copyright 2003-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   Mike Cochrane <mike@graftonhall.co.nz>
 11:  * @author   Jan Schneider <jan@horde.org>
 12:  * @author   Michael Slusarz <slusarz@horde.org>
 13:  * @category Horde
 14:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 15:  * @package  Core
 16:  */
 17: abstract class Horde_Core_Block
 18: {
 19:     /**
 20:      * Is this block enabled?
 21:      *
 22:      * @var boolean
 23:      */
 24:     public $enabled = true;
 25: 
 26:     /**
 27:      * Whether this block has changing content.
 28:      *
 29:      * @var boolean
 30:      */
 31:     public $updateable = false;
 32: 
 33:     /**
 34:      * Application that this block originated from.
 35:      *
 36:      * @var string
 37:      */
 38:     protected $_app;
 39: 
 40:     /**
 41:      * Block name. Should be set in the constructor.
 42:      *
 43:      * @var string
 44:      */
 45:     protected $_name = '';
 46: 
 47:     /**
 48:      * Block specific parameters.
 49:      *
 50:      * @var array
 51:      */
 52:     protected $_params = array();
 53: 
 54:     /**
 55:      * Constructor.
 56:      *
 57:      * @param string $app            The application name.
 58:      * @param array|boolean $params  Any parameters the block needs. If false,
 59:      *                               the default parameter will be used.
 60:      */
 61:     public function __construct($app, $params = array())
 62:     {
 63:         $this->_app = $app;
 64: 
 65:         // @todo: we can't simply merge the default values and stored values
 66:         // because empty parameter values are not stored at all, so they would
 67:         // always be overwritten by the defaults.
 68:         if ($params === false) {
 69:             foreach ($this->getParams() as $name => $param) {
 70:                 $this->_params[$name] = $param['default'];
 71:             }
 72:         } else {
 73:             $this->_params = $params;
 74:         }
 75:     }
 76: 
 77:     /**
 78:      * Returns the application that this block belongs to.
 79:      *
 80:      * @return string  The application name.
 81:      */
 82:     public function getApp()
 83:     {
 84:         return $this->_app;
 85:     }
 86: 
 87:     /**
 88:      * Return the block name.
 89:      *
 90:      * @return string  The block name.
 91:      */
 92:     public function getName()
 93:     {
 94:         return $this->_name;
 95:     }
 96: 
 97:     /**
 98:      * Returns any settable parameters for this block.
 99:      * It does *not* reference $this->_params; that is for runtime
100:      * parameters (the choices made from these options).
101:      *
102:      * @return array  The block's configurable parameters.
103:      */
104:     public function getParams()
105:     {
106:         return $this->_call('_params', array());
107:     }
108: 
109:     /**
110:      * Returns the parameters needed by block.
111:      *
112:      * @return array  The block's parameters.
113:      */
114:     protected function _params()
115:     {
116:         return array();
117:     }
118: 
119:     /**
120:      * Returns a hash of block parameters and their configured values.
121:      *
122:      * @return array  Parameter values.
123:      */
124:     public function getParamValues()
125:     {
126:         return $this->_params;
127:     }
128: 
129:     /**
130:      * Returns the text to go in the title of this block.
131:      *
132:      * This function handles the changing of current application as
133:      * needed so code is executed in the scope of the application the
134:      * block originated from.
135:      *
136:      * @return string  The block's title.
137:      */
138:     public function getTitle()
139:     {
140:         return $this->_call('_title', '');
141:     }
142: 
143:     /**
144:      * Returns the title to go in this block.
145:      *
146:      * @return string  The block title.
147:      */
148:     protected function _title()
149:     {
150:         return $this->_name;
151:     }
152: 
153:     /**
154:      * Returns the content for this block.
155:      *
156:      * This function handles the changing of current application as
157:      * needed so code is executed in the scope of the application the
158:      * block originated from.
159:      *
160:      * @return string  The block's content.
161:      */
162:     public function getContent()
163:     {
164:         return $this->_call('_content', '');
165:     }
166: 
167:     /**
168:      * Returns this block's content.
169:      *
170:      * @return string  The block's content.
171:      */
172:     abstract protected function _content();
173: 
174:     /**
175:      * The data to send on an AJAX update request.
176:      *
177:      * @param Horde_Variables $vars  The form variables for the request.
178:      *
179:      * @return string  Update data.
180:      */
181:     public function getAjaxUpdate(Horde_Variables $vars)
182:     {
183:         return $this->_call('_ajaxUpdate', '', $vars);
184:     }
185: 
186:     /**
187:      * Returns this block's content for AJAX updates.
188:      *
189:      * @param Horde_Variables $vars  The form variables for the request.
190:      *
191:      * @return string  The update content.
192:      */
193:     protected function _ajaxUpdate(Horde_Variables $vars)
194:     {
195:         return '';
196:     }
197: 
198:     /**
199:      * Return the URL to use for AJAX update requests.
200:      *
201:      * @return Horde_Url  The update URL.
202:      */
203:     protected function _ajaxUpdateUrl()
204:     {
205:         $ajax_url = Horde::getServiceLink('ajax', 'horde');
206:         $ajax_url->pathInfo = 'blockUpdate';
207:         $ajax_url->add('blockid', get_class($this));
208: 
209:         return $ajax_url;
210:     }
211: 
212:     /**
213:      * Calls the application driver in the proper context.
214:      *
215:      * @param string $name string
216:      * @param mixed $default
217:      * @param mixed $args
218:      *
219:      * @return mixed
220:      */
221:     protected function _call($name, $default, $args = null)
222:     {
223:         try {
224:             $pushed = $GLOBALS['registry']->pushApp($this->getApp(), array(
225:                 'check_perms' => true,
226:                 'logintasks' => false
227:             ));
228:         } catch (Horde_Exception $e) {
229:             return $default;
230:         }
231: 
232:         try {
233:             $ret = is_null($args)
234:                 ? $this->$name()
235:                 : call_user_func($name, $args);
236:         } catch (Horde_Exception $e) {
237:             $ret = $default;
238:         }
239: 
240:         if ($pushed) {
241:             $GLOBALS['registry']->popApp();
242:         }
243: 
244:         return $ret;
245:     }
246: 
247: }
248: 
API documentation generated by ApiGen