3 * Utility functions for generating URIs in HTML files
5 * @warning These functions execute min/groupsConfig.php, sometimes multiple times.
6 * You must make sure that functions are not redefined, and if your use custom sources,
7 * you must require_once dirname(__FILE__) . '/lib/Minify/Source.php' so that
13 if (! class_exists('Minify_Loader', false)) {
14 require dirname(__FILE__
) . '/lib/Minify/Loader.php';
15 Minify_Loader
::register();
19 * Get an HTML-escaped Minify URI for a group or set of files. By default, URIs
20 * will contain timestamps to allow far-future Expires headers.
23 * <link rel="stylesheet" type="text/css" href="<?= Minify_getUri('css'); ?>" />
24 * <script src="<?= Minify_getUri('js'); ?>"></script>
25 * <script src="<?= Minify_getUri(array(
26 * '//scripts/file1.js'
27 * ,'//scripts/file2.js'
31 * @param mixed $keyOrFiles a group key or array of file paths/URIs
32 * @param array $opts options:
33 * 'farExpires' : (default true) append a modified timestamp for cache revving
34 * 'debug' : (default false) append debug flag
35 * 'charset' : (default 'UTF-8') for htmlspecialchars
36 * 'minAppUri' : (default '/min') URI of min directory
37 * 'rewriteWorks' : (default true) does mod_rewrite work in min app?
38 * 'groupsConfigFile' : specify if different
41 function Minify_getUri($keyOrFiles, $opts = array())
43 return Minify_HTML_Helper
::getUri($keyOrFiles, $opts);
48 * Get the last modification time of several source js/css files. If you're
49 * caching the output of Minify_getUri(), you might want to know if one of the
50 * dependent source files has changed so you can update the HTML.
52 * Since this makes a bunch of stat() calls, you might not want to check this
55 * @param array $keysAndFiles group keys and/or file paths/URIs.
56 * @return int latest modification time of all given keys/files
58 function Minify_mtime($keysAndFiles, $groupsConfigFile = null)
61 if (! $groupsConfigFile) {
62 $groupsConfigFile = dirname(__FILE__
) . '/groupsConfig.php';
65 foreach ($keysAndFiles as $keyOrFile) {
66 if (is_object($keyOrFile)
67 ||
0 === strpos($keyOrFile, '/')
68 ||
1 === strpos($keyOrFile, ':\\')) {
70 $sources[] = $keyOrFile;
73 $gc = (require $groupsConfigFile);
75 foreach ($gc[$keyOrFile] as $source) {
80 return Minify_HTML_Helper
::getLastModified($sources);