Files
luos/thirdparty/html2ps_pdf/css.cache.class.php

56 lines
1.4 KiB
PHP
Raw Normal View History

2010-12-02 23:34:41 +00:00
<?php
/**
* "Singleton"
*/
class CSSCache {
function get() {
global $__g_css_manager;
if (!isset($__g_css_manager)) {
$__g_css_manager = new CSSCache();
};
return $__g_css_manager;
}
function _getCacheFilename($url) {
2017-08-02 16:06:56 -04:00
if(!class_exists('G')){
$realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] );
$docuroot = explode( '/', $realdocuroot );
array_pop( $docuroot );
$pathhome = implode( '/', $docuroot ) . '/';
array_pop( $docuroot );
$pathTrunk = implode( '/', $docuroot ) . '/';
require_once($pathTrunk.'gulliver/system/class.g.php');
}
return CACHE_DIR.G::encryptOld($url).'.css.compiled';
2010-12-02 23:34:41 +00:00
}
function _isCached($url) {
$cache_filename = $this->_getCacheFilename($url);
return is_readable($cache_filename);
}
function _readCached($url) {
$cache_filename = $this->_getCacheFilename($url);
return unserialize(file_get_contents($cache_filename));
}
function _putCached($url, $css) {
file_put_contents($this->_getCacheFilename($url), serialize($css));
}
function compile($url, $css) {
if ($this->_isCached($url)) {
return $this->_readCached($url);
} else {
$cssruleset = new CSSRuleset();
$cssruleset->parse_css($css, new Pipeline());
$this->_putCached($url, $cssruleset);
return $cssruleset;
};
}
}
?>