From: Michael M Slusarz Date: Fri, 17 Jul 2009 18:07:33 +0000 (-0600) Subject: Cache output handling has moved to Horde X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f8104ab9ee193a1dfee957d09c282fc020ff0e3c;p=horde.git Cache output handling has moved to Horde --- diff --git a/imp/cache.php b/imp/cache.php deleted file mode 100644 index 12eafaedf..000000000 --- a/imp/cache.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @package IMP - */ - -/* The amount of time (in minutes) to cache the generated CSS and JS files. - * DEFAULT: 525600 = 1 year */ -$expire_time = 525600; - -// Need to load Horde_Util:: to give us access to Horde_Util::getPathInfo(). -require_once dirname(__FILE__) . '/lib/base.load.php'; -require_once HORDE_BASE . '/lib/core.php'; -$path_info = trim(Horde_Util::getPathInfo(), '/'); -if (empty($path_info)) { - exit; -} - -// 'fckeditor' output won't have a second slash, so ignore errors -$old_error = error_reporting(0); -list($type, $cid) = explode('/', $path_info, 2); -error_reporting($old_error); - -/* Allow CSS and JS caches to be cached on the browser since there is no - * dynamic code that will change over the course of a session. Can't cache - * fckeditor setting as it may change. Only authenticate for 'fckeditor' - * actions (for access to user's prefs). */ -if ($type == 'fckeditor') { - $session_cache_limiter = 'nocache'; -} else { - $session_cache_limiter = 'public'; - session_cache_expire($expire_time); - @define('AUTH_HANDLER', true); - $authentication = 'none'; -} -$session_control = 'readonly'; -$session_timeout = 'none'; -require_once IMP_BASE . '/lib/base.php'; - -switch ($type) { -case 'css': - $type = 'text/css'; - $lifetime = (empty($GLOBALS['conf']['server']['cachecssparams']['lifetime'])) ? 0 : $GLOBALS['conf']['server']['cachecssparams']['lifetime']; - break; - -case 'fckeditor': - header('Content-Type: text/javascript'); - echo 'FCKConfig.ToolbarSets["ImpToolbar"] = ' . $GLOBALS['prefs']->getValue('fckeditor_buttons') . ';' . "\n" . - // To more closely match "normal" textarea behavior, send
on - // enter instead of

. - 'FCKConfig.EnterMode = \'br\';' . "\n" . - 'FCKConfig.ShiftEnterMode = \'p\';'; - exit; - -case 'js': - $type = 'text/javascript'; - $lifetime = (empty($GLOBALS['conf']['server']['cachejsparams']['lifetime'])) ? 0 : $GLOBALS['conf']['server']['cachejsparams']['lifetime']; - break; - -default: - exit; -} - -if (empty($cid)) { - exit; -} - -if (!($cache = IMP::getCache())) { - Horde::fatal(new Horde_Exception('No cache backend available.')); -} - -// If cache info doesn't exist, just output an empty body. -header('Content-Type: ' . $type); -$cache->output($cid, $lifetime); diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index a49d004e0..103aa3961 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -1354,8 +1354,9 @@ class IMP break; case 'horde_cache': + // Do lifetime checking here, not on cache display page. $exists = $cache->exists($sig, empty($conf['server']['cachejsparams']['lifetime']) ? 0 : $conf['server']['cachejsparams']['lifetime']); - $js_url = self::getCacheURL('js', $sig); + $js_url = Horde::getCacheUrl('js', array('cid' => $sig)); break; } @@ -1391,25 +1392,6 @@ class IMP } /** - * Creates a URL for cached IMP data. - * - * @param string $type The cache type. - * @param string $cid The cache id. - * - * @return string The URL to the cache page. - */ - static public function getCacheURL($type, $cid) - { - $parts = array( - $GLOBALS['registry']->get('webroot', 'imp'), - 'cache.php', - $type, - $cid - ); - return Horde::url(implode('/', $parts)); - } - - /** * Outputs the necessary style tags, honoring local configuration * choices as to stylesheet caching. * @@ -1466,8 +1448,9 @@ class IMP break; case 'horde_cache': + // Do lifetime checking here, not on cache display page. $exists = $cache->exists($sig, empty($GLOBALS['conf']['server']['cachecssparams']['lifetime']) ? 0 : $GLOBALS['conf']['server']['cachecssparams']['lifetime']); - $css_url = self::getCacheURL('css', $sig); + $css_url = Horde::getCacheUrl('css', array('cid' => $sig)); break; } diff --git a/imp/lib/UI/Compose.php b/imp/lib/UI/Compose.php index 8d552c1d6..a72da079d 100644 --- a/imp/lib/UI/Compose.php +++ b/imp/lib/UI/Compose.php @@ -182,7 +182,9 @@ class IMP_UI_Compose $fck_buttons = $GLOBALS['prefs']->getValue('fckeditor_buttons'); if (!empty($fck_buttons)) { $js_onload = array( - 'oFCKeditor.Config.CustomConfigurationsPath = "' . IMP::getCacheURL('fckeditor', null) . '"', + // This needs to work even if Horde_Cache is not available, + // so need to use app-specific cache output. + 'oFCKeditor.Config.CustomConfigurationsPath = "' . Horde::getCacheUrl('app', array('app' => 'imp', 'id' => 'fckeditor')) . '"', 'oFCKeditor.ToolbarSet = "ImpToolbar"' ); if ($mode == 'imp') { diff --git a/imp/lib/api.php b/imp/lib/api.php index aa1c11ac3..4b463cc6c 100644 --- a/imp/lib/api.php +++ b/imp/lib/api.php @@ -124,6 +124,15 @@ $_services = array_merge($_services, array( 'type' => 'boolean' ), + /* Cache display method. */ + 'cacheOutput' => array( + 'args' => array( + '{urn:horde}hashHash' + ), + 'type' => '{urn:horde}hashHash' + ), + + /* Horde_Auth_Application method. */ 'authAuthenticate' => array( 'args' => array( 'userID' => 'string', @@ -517,6 +526,37 @@ function _imp_changeLanguage() } /** + * Application-specific cache output driver. + * + * @param array $params A list of params needed (USED: 'id'). + * + * @return array See Horde::getCacheUrl(). + * @throws Horde_Exception + */ +function _imp_cacheOutput($params) +{ + $GLOBALS['authentication'] = 'none'; + require_once dirname(__FILE__) . '/base.php'; + + if (IMP::checkAuthentication(true)) { + switch ($params['id']) { + case 'fckeditor': + return array( + 'data' => + 'FCKConfig.ToolbarSets["ImpToolbar"] = ' . $GLOBALS['prefs']->getValue('fckeditor_buttons') . ';' . "\n" . + // To more closely match "normal" textarea behavior, + // send
on enter instead of

. + 'FCKConfig.EnterMode = \'br\';' . "\n" . + 'FCKConfig.ShiftEnterMode = \'p\';', + 'type' => 'text/javascript' + ); + } + } + + throw new Horde_Exception('No cache data available'); +} + +/** * Tries to authenticate with the mail server and create a mail session. * * @param string $userID The username of the user.