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:  * This class is responsible for parsing/building theme elements and then
  4:  * caching these results.
  5:  *
  6:  * Copyright 2010-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   Michael Slusarz <slusarz@horde.org>
 12:  * @category Horde
 13:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 14:  * @package  Core
 15:  */
 16: class Horde_Themes_Cache implements Serializable
 17: {
 18:     /* Constants */
 19:     const HORDE_DEFAULT = 1;
 20:     const APP_DEFAULT = 2;
 21:     const HORDE_THEME = 4;
 22:     const APP_THEME = 8;
 23: 
 24:     /**
 25:      * Has the data changed?
 26:      *
 27:      * @var boolean
 28:      */
 29:     public $changed = false;
 30: 
 31:     /**
 32:      * Application name.
 33:      *
 34:      * @var string
 35:      */
 36:     protected $_app;
 37: 
 38:     /**
 39:      * The cache ID.
 40:      *
 41:      * @var string
 42:      */
 43:     protected $_cacheid;
 44: 
 45:     /**
 46:      * Is this a complete representation of the theme?
 47:      *
 48:      * @var boolean
 49:      */
 50:     protected $_complete = false;
 51: 
 52:     /**
 53:      * Theme data.
 54:      *
 55:      * @var array
 56:      */
 57:     protected $_data = array();
 58: 
 59:     /**
 60:      * Theme name.
 61:      *
 62:      * @var string
 63:      */
 64:     protected $_theme;
 65: 
 66:     /**
 67:      * Constructor.
 68:      *
 69:      * @param string $app    The application name.
 70:      * @param string $theme  The theme name.
 71:      */
 72:     public function __construct($app, $theme)
 73:     {
 74:         $this->_app = $app;
 75:         $this->_theme = $theme;
 76:     }
 77: 
 78:     /**
 79:      * Build the entire theme data structure.
 80:      *
 81:      * @return array  The list of theme files.
 82:      */
 83:     public function build()
 84:     {
 85:         if (!$this->_complete) {
 86:             $this->_data = array();
 87: 
 88:             $this->_build('horde', 'default', self::HORDE_DEFAULT);
 89:             $this->_build('horde', $this->_theme, self::HORDE_THEME);
 90:             if ($this->_app != 'horde') {
 91:                 $this->_build($this->_app, 'default', self::APP_DEFAULT);
 92:                 $this->_build($this->_app, $this->_theme, self::APP_THEME);
 93:             }
 94: 
 95:             $this->changed = $this->_complete = true;
 96:         }
 97: 
 98:         return array_keys($this->_data);
 99:     }
100: 
101:     /**
102:      * Add theme data from an app/theme combo.
103:      *
104:      * @param string $app    The application name.
105:      * @param string $theme  The theme name.
106:      * @param integer $mask  Mask for the app/theme combo.
107:      */
108:     protected function _build($app, $theme, $mask)
109:     {
110:         $path = $GLOBALS['registry']->get('themesfs', $app) . '/'. $theme;
111: 
112:         try {
113:             $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
114:         } catch (UnexpectedValueException $e) {
115:             return;
116:         }
117: 
118:         foreach ($it as $val) {
119:             if (!$val->isDir()) {
120:                 $sub = $it->getSubPathname();
121: 
122:                 if (isset($this->_data[$sub])) {
123:                     $this->_data[$sub] |= $mask;
124:                 } else {
125:                     $this->_data[$sub] = $mask;
126:                 }
127:             }
128:         }
129:     }
130: 
131:     /**
132:      */
133:     public function get($item, $mask = 0)
134:     {
135:         if (!($entry = $this->_get($item))) {
136:             return null;
137:         }
138: 
139:         if ($mask) {
140:             $entry &= $mask;
141:         }
142: 
143:         if ($entry & self::APP_THEME) {
144:             $app = $this->_app;
145:             $theme = $this->_theme;
146:         } elseif ($entry & self::HORDE_THEME) {
147:             $app = 'horde';
148:             $theme = $this->_theme;
149:         } elseif ($entry & self::APP_DEFAULT) {
150:             $app = $this->_app;
151:             $theme = 'default';
152:         } elseif ($entry & self::HORDE_DEFAULT) {
153:             $app = 'horde';
154:             $theme = 'default';
155:         } else {
156:             return null;
157:         }
158: 
159:         return $this->_getOutput($app, $theme, $item);
160:     }
161: 
162:     /**
163:      */
164:     protected function _get($item)
165:     {
166:         if (!isset($this->_data[$item])) {
167:             $entry = 0;
168: 
169:             $path = $GLOBALS['registry']->get('themesfs', 'horde');
170:             if (file_exists($path . '/default/' . $item)) {
171:                 $entry |= self::HORDE_DEFAULT;
172:             }
173:             if (file_exists($path . '/' . $this->_theme . '/' . $item)) {
174:                 $entry |= self::HORDE_THEME;
175:             }
176: 
177:             if ($this->_app != 'horde') {
178:                 $path = $GLOBALS['registry']->get('themesfs', $this->_app);
179:                 if (file_exists($path . '/default/' . $item)) {
180:                     $entry |= self::APP_DEFAULT;
181:                 }
182:                 if (file_exists($path . '/' . $this->_theme . '/' . $item)) {
183:                     $entry |= self::APP_THEME;
184:                 }
185:             }
186: 
187:             $this->_data[$item] = $entry;
188:             $this->changed = true;
189:         }
190: 
191:         return $this->_data[$item];
192:     }
193: 
194:     /**
195:      */
196:     protected function _getOutput($app, $theme, $item)
197:     {
198:         return array(
199:             'fs' => $GLOBALS['registry']->get('themesfs', $app) . '/' . $theme . '/' . $item,
200:             'uri' => $GLOBALS['registry']->get('themesuri', $app) . '/' . $theme . '/' . $item
201:         );
202:     }
203: 
204:     /**
205:      */
206:     public function getAll($item, $mask = 0)
207:     {
208:         if (!($entry = $this->_get($item))) {
209:             return array();
210:         }
211: 
212:         if ($mask) {
213:             $entry &= $mask;
214:         }
215:         $out = array();
216: 
217:         if ($entry & self::APP_THEME) {
218:             $out[] = $this->_getOutput($this->_app, $this->_theme, $item);
219:         }
220:         if ($entry & self::HORDE_THEME) {
221:             $out[] = $this->_getOutput('horde', $this->_theme, $item);
222:         }
223:         if ($entry & self::APP_DEFAULT) {
224:             $out[] = $this->_getOutput($this->_app, 'default', $item);
225:         }
226:         if ($entry & self::HORDE_DEFAULT) {
227:             $out[] = $this->_getOutput('horde', 'default', $item);
228:         }
229: 
230:         return $out;
231:     }
232: 
233:     /**
234:      */
235:     public function getCacheId()
236:     {
237:         if (!isset($this->_cacheid)) {
238:             $check = isset($GLOBALS['conf']['cachethemesparams']['check']) ? $GLOBALS['conf']['cachethemesparams']['check'] : null;
239:             switch ($check) {
240:             case 'appversion':
241:             default:
242:                 $id = array($GLOBALS['registry']->getVersion($this->_app));
243:                 if ($this->_app != 'horde') {
244:                     $id[] = $GLOBALS['registry']->getVersion('horde');
245:                 }
246:                 $this->_cacheid = 'v:' . implode('|', $id);
247:                 break;
248: 
249:             case 'none':
250:                 $this->_cacheid = '';
251:                 break;
252:             }
253:         }
254: 
255:         return $this->_cacheid;
256:     }
257: 
258:     /* Serializable methods. */
259: 
260:     /**
261:      */
262:     public function serialize()
263:     {
264:         return serialize(array(
265:             'a' => $this->_app,
266:             'c' => $this->_complete,
267:             'd' => $this->_data,
268:             'id' => $this->getCacheId(),
269:             't' => $this->_theme
270:         ));
271:     }
272: 
273:     /**
274:      */
275:     public function unserialize($data)
276:     {
277:         $out = @unserialize($data);
278: 
279:         if (isset($out['id']) && ($out['id'] != $this->getCacheId())) {
280:             throw new Exception('Cache invalidated');
281:         }
282: 
283:         $this->_app = $out['a'];
284:         $this->_complete = $out['c'];
285:         $this->_data = $out['d'];
286:         $this->_theme = $out['t'];
287:     }
288: 
289: }
290: 
API documentation generated by ApiGen