protected $_app;
/**
+ * The cache ID.
+ *
+ * @var string
+ */
+ protected $_cacheid;
+
+ /**
* Theme data.
*
* @var array
/**
*/
- protected function _getExpireId()
+ public function getCacheId()
{
- switch ($GLOBALS['config']['themescacheparams']['check']) {
- case 'appversion':
- default:
- $id = array($GLOBALS['registry']->getVersion($this->_app));
- if ($this->_app != 'horde') {
- $id[] = $GLOBALS['registry']->getVersion('horde');
- }
- return 'v:' . implode('|', $id);
+ if (!isset($this->_cacheid)) {
+ switch ($GLOBALS['config']['themescacheparams']['check']) {
+ case 'appversion':
+ default:
+ $id = array($GLOBALS['registry']->getVersion($this->_app));
+ if ($this->_app != 'horde') {
+ $id[] = $GLOBALS['registry']->getVersion('horde');
+ }
+ $this->_cacheid = 'v:' . implode('|', $id);
+ break;
- case 'none':
- return '';
+ case 'none':
+ $this->_cacheid = '';
+ break;
+ }
}
+
+ return $this->_cacheid;
}
/* Serializable methods. */
public function serialize()
{
return serialize(array(
- $this->_getExpireId(),
+ $this->getCacheId(),
$this->_app,
$this->_data,
$this->_theme
$this->_theme
) = unserialize($data);
- if ($expire_id && ($expire_id != $this->_getExpireId())) {
+ if ($expire_id && ($expire_id != $this->getCacheId())) {
throw new Exception('Cache invalidated');
}
}
class Horde_Themes_Css
{
/**
+ * The theme cache ID.
+ *
+ * @var string
+ */
+ protected $_cacheid;
+
+ /**
* A list of additional stylesheet files to add to the output.
*
* @var array
* Generate the stylesheet URLs needed to display the current page.
* Honors configuration choices as to stylesheet caching.
*
- * @param array $options Additional options:
+ * @param array $opts Additional options:
* <pre>
* 'nohorde' - (boolean) If true, don't load files from Horde.
* 'sub' - (string) A subdirectory containing additional CSS files to
*
* @return array The list of URLs to display.
*/
- public function getStylesheetUrls($options = array())
+ public function getStylesheetUrls(array $opts = array())
{
global $conf, $injector, $prefs, $registry;
$themesfs = $registry->get('themesfs');
$themesuri = $registry->get('themesuri');
- $css = $this->getStylesheets(isset($options['theme']) ? $options['theme'] : $prefs->getValue('theme'), $options);
+ $theme = isset($opts['theme'])
+ ? $opts['theme']
+ : $prefs->getValue('theme');
+ $css = $this->getStylesheets($theme, $opts);
$cache_type = empty($conf['cachecss'])
? 'none'
return $css_out;
}
- $mtime = array(0);
$out = '';
-
- foreach ($css as $file) {
- $mtime[] = filemtime($file['fs']);
- }
-
- $sig = hash('md5', serialize($css) . max($mtime));
+ $sig = hash('md5', serialize($css) . $this->_cacheid);
switch ($cache_type) {
case 'filesystem':
: $opts['sub'];
$build = $GLOBALS['injector']->getInstance('Horde_Core_Factory_ThemesCache')->create($curr_app, $theme);
+ $this->_cacheid = $build->getCacheId();
foreach ($css_list as $css_name) {
if (empty($opts['subonly'])) {