62 global $css_cache_timestamp;
63 $css_cache_timestamp = Cache::get(
"css_cache_timestamp");
68 Cache::invalidate(
"script_cache");
69 Cache::invalidate(
"script_cache_timestamp");
70 Cache::invalidate(
"css_cache");
71 Cache::invalidate(
"css_cache_timestamp");
72 Settings::setDefaultValue(
"optimize",
"optimize_scripts",
"", Boolean,
"Combine site Javascript into a single file",
"Javascript",
null, 1);
73 Settings::setDefaultValue(
"optimize",
"optimize_styles",
"", Boolean,
"Combine site CSS into a single file",
"CSS",
null, 1);
75 Settings::setDefaultValue(
"optimize",
"compress_javascript",
"", Boolean,
"Enable zip compression when serving Javascript",
"Javascript",
null, 2);
76 Settings::setDefaultValue(
"optimize",
"compress_styles",
"", Boolean,
"Enable zip compression when serving CSS",
"CSS",
null, 2);
78 Settings::setDefaultValue(
"optimize",
"compress_page_content",
"", Boolean,
"Enable zip compression when serving page content",
"Page Content",
null, 1);
79 Settings::setDefaultValue(
"optimize",
"append_timestamp",
false, Boolean,
"Specifies whether to include a timestamp in the generated link for optimized scripts and styles",
"Page Content",
null, 2);
91 $cachedScripts = Cache::get(
"script_cache");
100 $file_modified = filemtime($resource);
106 $cachedScripts .= file_get_contents($resource);
107 $cachedScripts .=
"\r\n";
108 trace(
"Added $script", 3);
112 trace(
"Could not resolve script $script", 2);
121 Cache::put(
"script_cache", $cachedScripts);
125 $scriptLink =
Settings::getValue(
"optimize",
"append_timestamp") ?
"/action/optimize/scripts?".Cache::get(
"script_cache_timestamp") :
"/action/optimize/scripts";
127 $scripts = array($scriptLink);
135 $content = Cache::get(
"script_cache");
140 $content = Cache::get(
"script_cache");
155 $cachedStyles = Cache::get(
"css_cache");
164 $file_modified = filemtime($resource);
170 $cachedStyles .= file_get_contents($resource);
171 $cachedStyles .=
"\r\n";
175 $cachedStyles = preg_replace(
"/^@CHARSET.*$/mi",
"", $cachedStyles);
176 $cachedStyles = str_replace(
"\r\n",
"\n", $cachedStyles);
177 $cachedStyles = str_replace(
"\n",
"\r\n", $cachedStyles);
184 Cache::put(
"css_cache", $cachedStyles);
188 $styleLink =
Settings::getValue(
"optimize",
"append_timestamp") ?
"/action/optimize/styles?".Cache::get(
"css_cache_timestamp") :
"/action/optimize/styles";
198 $cachedStyles = Cache::get(
"css_cache");
204 $cachedStyles = Cache::get(
"css_cache");
207 return $cachedStyles;
212 if (
Settings::getValue(
"optimize",
"compress_page_content") && substr_count($_SERVER[
'HTTP_ACCEPT_ENCODING'],
'gzip'))
214 ob_start(
"ob_gzhandler");
215 $level = ob_get_level();
216 trace(
"ZIP output buffer level: $level", 3);
224 trace(
"PreAction: $action", 3);
228 if (
Settings::getValue(
"optimize",
"compress_javascript") && substr_count($_SERVER[
'HTTP_ACCEPT_ENCODING'],
'gzip'))
230 trace(
"Compressing scripts", 3);
237 if (
Settings::getValue(
"optimize",
"compress_styles") && substr_count($_SERVER[
'HTTP_ACCEPT_ENCODING'],
'gzip'))
239 trace(
"Compressing styles", 3);
252 if (extension_loaded(
"zlib") && (ini_get(
"output_handler") !=
"ob_gzhandler"))
254 trace(
"Setting zlib.output_compression to On", 3);
257 @ini_set(
"zlib.output_compression",
'On');
258 @ini_set(
"zlib.output_compression_level", 9);
268 trace(
"zlib.output_compression = ".ini_get(
"zlib.output_compression"), 3);
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
static resolveResource($resource, $component="")
Resolves the path to a web resource based on the PHP include path.
static usingFeature()
Uses the specified framework feature(s).
static $outputBufferLevel
Records the level at which gzip output buffering began.
static loadStyles()
Load the list of CSS files from the manifests of all registered, active components.
static loadScripts()
Load the list of JS scripts from the manifests of all registered, active components.
static using()
Import the datamodels, views and manifest for the specified component(s).
registerMinifier($minifier)
static preProcessPage($template)
static postAction($action)
static preAction($action)
static getScriptsContent()
static preProcessStyles($styles)
static getStylesContent()
static preprocessScripts($scripts)
static getValue($component, $name)
Retrieve the value of the specified Setting.
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
while(ob_get_level()) $last_modified
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content