[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Utility functions for generating URIs in HTML files 4 * 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 8 * class is available. 9 * 10 * @package Minify 11 */ 12 13 if (! class_exists('Minify_Loader', false)) { 14 require dirname(__FILE__) . '/lib/Minify/Loader.php'; 15 Minify_Loader::register(); 16 } 17 18 /* 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. 21 * 22 * <code> 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' 28 * )); ?>"></script> 29 * </code> 30 * 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 39 * @return string 40 */ 41 function Minify_getUri($keyOrFiles, $opts = array()) 42 { 43 return Minify_HTML_Helper::getUri($keyOrFiles, $opts); 44 } 45 46 47 /** 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. 51 * 52 * Since this makes a bunch of stat() calls, you might not want to check this 53 * on every request. 54 * 55 * @param array $keysAndFiles group keys and/or file paths/URIs. 56 * @return int latest modification time of all given keys/files 57 */ 58 function Minify_mtime($keysAndFiles, $groupsConfigFile = null) 59 { 60 $gc = null; 61 if (! $groupsConfigFile) { 62 $groupsConfigFile = dirname(__FILE__) . '/groupsConfig.php'; 63 } 64 $sources = array(); 65 foreach ($keysAndFiles as $keyOrFile) { 66 if (is_object($keyOrFile) 67 || 0 === strpos($keyOrFile, '/') 68 || 1 === strpos($keyOrFile, ':\\')) { 69 // a file/source obj 70 $sources[] = $keyOrFile; 71 } else { 72 if (! $gc) { 73 $gc = (require $groupsConfigFile); 74 } 75 foreach ($gc[$keyOrFile] as $source) { 76 $sources[] = $source; 77 } 78 } 79 } 80 return Minify_HTML_Helper::getLastModified($sources); 81 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |