3 * Utility functions for generating URIs in HTML files
8 require_once dirname(__FILE__
) . '/lib/Minify/HTML/Helper.php';
12 * Get an HTML-escaped Minify URI for a group or set of files. By default, URIs
13 * will contain timestamps to allow far-future Expires headers.
16 * <link rel="stylesheet" type="text/css" href="<?= Minify_getUri('css'); ?>" />
17 * <script src="<?= Minify_getUri('js'); ?>"></script>
18 * <script src="<?= Minify_getUri(array(
19 * '//scripts/file1.js'
20 * ,'//scripts/file2.js'
24 * @param mixed $keyOrFiles a group key or array of file paths/URIs
25 * @param array $opts options:
26 * 'farExpires' : (default true) append a modified timestamp for cache revving
27 * 'debug' : (default false) append debug flag
28 * 'charset' : (default 'UTF-8') for htmlspecialchars
29 * 'minAppUri' : (default '/min') URI of min directory
30 * 'rewriteWorks' : (default true) does mod_rewrite work in min app?
31 * 'groupsConfigFile' : specify if different
34 function Minify_getUri($keyOrFiles, $opts = array())
36 return Minify_HTML_Helper
::getUri($keyOrFiles, $opts);
41 * Get the last modification time of several source js/css files. If you're
42 * caching the output of Minify_getUri(), you might want to know if one of the
43 * dependent source files has changed so you can update the HTML.
45 * Since this makes a bunch of stat() calls, you might not want to check this
48 * @param array $keysAndFiles group keys and/or file paths/URIs.
49 * @return int latest modification time of all given keys/files
51 function Minify_mtime($keysAndFiles, $groupsConfigFile = null)
54 if (! $groupsConfigFile) {
55 $groupsConfigFile = dirname(__FILE__
) . '/groupsConfig.php';
58 foreach ($keysAndFiles as $keyOrFile) {
59 if (is_object($keyOrFile)
60 ||
0 === strpos($keyOrFile, '/')
61 ||
1 === strpos($keyOrFile, ':\\')) {
63 $sources[] = $keyOrFile;
66 $gc = (require $groupsConfigFile);
68 foreach ($gc[$keyOrFile] as $source) {
73 return Minify_HTML_Helper
::getLastModified($sources);