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:  * The Horde_Core_Tree_Javascript:: class provides javascript rendering of a
  4:  * tree.
  5:  *
  6:  * Copyright 2003-2012 Horde LLC (http://www.horde.org/)
  7:  *
  8:  * See the enclosed file COPYING for license information (LGPL). If you
  9:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 10:  *
 11:  * @author   Marko Djukic <marko@oblo.com>
 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: class Horde_Core_Tree_Javascript extends Horde_Core_Tree_Html
 18: {
 19:     /**
 20:      * Constructor.
 21:      *
 22:      * @param string $name   @see parent::__construct().
 23:      * @param array $params  @see parent::__construct(). Additional options:
 24:      * <pre>
 25:      * 'jsvar' - The JS variable name to store the tree object in.
 26:      *           DEFAULT: Instance name.
 27:      * </pre>
 28:      */
 29:     public function __construct($name, array $params = array())
 30:     {
 31:         parent::__construct($name, $params);
 32: 
 33:         Horde::addScriptFile('hordetree.js', 'horde');
 34: 
 35:         /* Check for a javascript session state. */
 36:         if (($session = $this->getOption('session')) &&
 37:             isset($_COOKIE[$this->_instance . '_expanded'])) {
 38:             /* Get current session expanded values. */
 39:             $curr = call_user_func($session['get'], $this->_instance, '', Horde_Session::TYPE_ARRAY);
 40: 
 41:             /* Remove "exp" prefix from cookie value. */
 42:             $exp = explode(',', substr($_COOKIE[$this->_instance . '_expanded'], 3));
 43: 
 44:             /* These are the expanded folders. */
 45:             foreach (array_filter($exp) as $val) {
 46:                 call_user_func($session['set'], $this->_instance, $val, true);
 47:             }
 48: 
 49:             /* These are previously expanded folders. */
 50:             foreach (array_diff(array_keys($curr), $exp) as $val) {
 51:                 call_user_func($session['set'], $this->_instance, $val, false);
 52:             }
 53:         }
 54:     }
 55: 
 56:     /**
 57:      * Provide a simpler renderer to fallback to.
 58:      *
 59:      * @return string  The next best renderer.
 60:      */
 61:     public function fallback()
 62:     {
 63:         return 'Horde_Core_Tree_Html';
 64:     }
 65: 
 66:     /**
 67:      * Returns the tree.
 68:      *
 69:      * @param boolean $static  If true the tree nodes can't be expanded and
 70:      *                         collapsed and the tree gets rendered expanded.
 71:      *
 72:      * @return string  The HTML code of the rendered tree.
 73:      */
 74:     public function getTree($static = false)
 75:     {
 76:         $this->_static = $static;
 77: 
 78:         $opts = array(
 79:             'extraColsLeft' => $this->_colsLeft,
 80:             'extraColsRight' => $this->_colsRight,
 81:             'header' => $this->_header,
 82:             'nocookie' => !$this->getOption('session'),
 83:             'options' => $this->_options,
 84:             'target' => $this->_instance,
 85: 
 86:             'cookieDomain' => $GLOBALS['conf']['cookie']['domain'],
 87:             'cookiePath' => $GLOBALS['conf']['cookie']['path'],
 88: 
 89:             'imgBlank' => $this->_images['blank'],
 90:             'imgFolder' => $this->_images['folder'],
 91:             'imgFolderOpen' => $this->_images['folderopen'],
 92:             'imgLine' => $this->_images['line'],
 93:             'imgJoin' => $this->_images['join'],
 94:             'imgJoinBottom' => $this->_images['join_bottom'],
 95:             'imgJoinTop' => $this->_images['join_top'],
 96:             'imgPlus' => $this->_images['plus'],
 97:             'imgPlusBottom' => $this->_images['plus_bottom'],
 98:             'imgPlusOnly' => $this->_images['plus_only'],
 99:             'imgMinus' => $this->_images['minus'],
100:             'imgMinusBottom' => $this->_images['minus_bottom'],
101:             'imgMinusOnly' => $this->_images['minus_only'],
102:             'imgNullOnly' => $this->_images['null_only'],
103:             'imgLeaf' => $this->_images['leaf'],
104: 
105:             'initTree' => $this->renderNodeDefinitions()
106:         );
107: 
108:         if (!($js_var = $this->getOption('jsvar'))) {
109:             $js_var = $this->_instance;
110:         }
111: 
112:         Horde::addInlineScript(array(
113:             'window.' . $js_var . ' = new Horde_Tree(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON) . ')'
114:         ), 'dom');
115: 
116:         return '<div id="' . $this->_instance . '"></div>';
117:     }
118: 
119:     /**
120:      * Check the current environment to see if we can render the HTML tree.
121:      * We check for DOM support in the browser.
122:      *
123:      * @return boolean  Whether or not this backend will function.
124:      */
125:     public function isSupported()
126:     {
127:         return $GLOBALS['browser']->hasFeature('dom');
128:     }
129: 
130:     /**
131:      * Returns just the JS node definitions as a string.
132:      *
133:      * @return object  Object with the following properties: 'is_static',
134:      *                 'nodes', 'root_nodes'.
135:      */
136:     public function renderNodeDefinitions()
137:     {
138:         $this->_buildIndents($this->_root_nodes);
139: 
140:         $result = new stdClass;
141:         $result->is_static = intval($this->_static);
142:         $result->nodes = $this->_nodes;
143:         $result->root_nodes = $this->_root_nodes;
144:         $result->files = array();
145: 
146:         foreach ($GLOBALS['injector']->getInstance('Horde_Script_Files')->listFiles() as $apps) {
147:             foreach ($apps as $file) {
148:                 /* Ignore files that are already loaded before building the
149:                  * tree. */
150:                 if ($file['f'] == 'prototype.js' ||
151:                     $file['f'] == 'hordetree.js' ||
152:                     $file['f'] == 'accesskeys.js') {
153:                     continue;
154:                 }
155:                 $result->files[] = (string)$file['u'];
156:             }
157:         }
158: 
159:         return $result;
160:     }
161: }
162: 
API documentation generated by ApiGen