本文整理汇总了PHP中Horde::getCacheUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde::getCacheUrl方法的具体用法?PHP Horde::getCacheUrl怎么用?PHP Horde::getCacheUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde
的用法示例。
在下文中一共展示了Horde::getCacheUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
*/
public function process($css, $cacheid)
{
global $injector;
if (!empty($this->_params['filemtime'])) {
foreach ($css as &$val) {
$val['mtime'] = @filemtime($val['fs']);
}
}
$cache = $injector->getInstance('Horde_Cache');
$sig = hash(version_compare(PHP_VERSION, '5.4', '>=') ? 'fnv164' : 'sha1', json_encode($css) . $cacheid);
// Do lifetime checking here, not on cache display page.
if (!$cache->exists($sig, empty($this->_params['lifetime']) ? 0 : $this->_params['lifetime'])) {
$compress = new Horde_Themes_Css_Compress();
$cache->set($sig, $compress->compress($css));
}
return array(Horde::getCacheUrl('css', array('cid' => $sig)));
}
示例2: _process
/**
*/
protected function _process($scripts)
{
global $injector;
if (empty($scripts)) {
return array();
}
$tmp = array();
foreach ($scripts as $val) {
$tmp[] = $val->modified;
}
$mtime = max($tmp);
$hashes = array_keys($scripts);
sort($hashes);
$sig = hash(version_compare(PHP_VERSION, '5.4', '>=') ? 'fnv164' : 'sha1', json_encode($hashes) . $mtime);
$cache = $injector->getInstance('Horde_Cache');
$cache_lifetime = empty($this->_params['lifetime']) ? 0 : $this->_params['lifetime'];
// Do lifetime checking here, not on cache display page.
$js_url = Horde::getCacheUrl('js', array('cid' => $sig));
$out = array($js_url);
if ($cache->exists($sig, $cache_lifetime)) {
return $out;
}
/* Check for existing process creating compressed file. Maximum 15
* seconds wait time. */
for ($i = 0; $i < 15; ++$i) {
if ($cache->exists($sig . '.lock')) {
sleep(1);
} elseif ($i) {
return $out;
} else {
$cache->set($sig . '.lock', 1);
break;
}
}
if (!isset($this->_compress)) {
$this->_compress = new Horde_Script_Compress($this->_params['compress'], $this->_params);
}
$sourcemap_url = Horde::getCacheUrl('js', array('cid' => $sig . '.map'));
$jsmin = $this->_compress->getMinifier($scripts, $sourcemap_url);
$cache->set($sig, $jsmin->minify());
if ($this->_compress->sourcemap_support) {
$cache->set($sig . '.map', $jsmin->sourcemap());
}
$cache->expire($sig . '.lock');
return $out;
}