Mercurial > SimpleWebPresenter
diff CacheTimeCheck.inc @ 48:c6d0892f81ff
Documentation.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Tue, 09 Oct 2012 20:05:12 +0200 |
| parents | 66382989353f |
| children | 2d0cda52f43f |
line wrap: on
line diff
--- a/CacheTimeCheck.inc Mon Oct 08 17:35:08 2012 +0200 +++ b/CacheTimeCheck.inc Tue Oct 09 20:05:12 2012 +0200 @@ -1,4 +1,10 @@ <?php +/** + * CacheTimeCheck provides a set of functions to enable generating a + * correct time for the latest update for a given file. + * + * @author Tom Fredrik Blenning Klaussen + */ class CacheTimeCheck { private $newest; @@ -12,6 +18,13 @@ $this->cache_time(__FILE__); } + /** + * List a set of files which contributes to this pages cacheset. + * + * @param $humanReadable If the timestamp should be humand readable. + * + * @return an associative array of file, and timestamp + */ function cacheSet($humanReadable = False) { $retVal = array(); @@ -25,6 +38,13 @@ return $retVal; } + /** + * Generates a singleton instance of this CacheTimeCheck + * + * @param $filename an optional file to include in the cacheset + * + * @return a CacheTimeCheck object + */ function instance($filename = False) { if (! self::$myInstance) @@ -34,6 +54,11 @@ return self::$myInstance; } + /** + * Checks if a HTTP_IF_MODIFIED_SINCE header is set, if this file is + * newer, set a Last-Modified header, otherwise abort with an 304 + * status code + */ function CheckHttpModified() { if (DEBUG_LEVEL >= VERBOSITY_DEBUG) @@ -54,6 +79,12 @@ header("Last-Modified: $gmdate_mod"); } + /** + * Include a file in the cacheset + * + * @param $path the path of the file + * @param $basedir ***REMOVE THIS*** + */ function cache_time($path, $basedir = False) { if (!file_exists($path)) { @@ -68,6 +99,12 @@ } } + /** + * Convenience function to include a file, and add it to the cacheset. + * + * @param $path path of the file + * @param $basedir a directory to prepend to the path + */ function includeOnce($path, $basedir = false) { if ($basedir) @@ -76,6 +113,12 @@ include_once($path); } + /** + * Convenience function to load a file, and add it to the cacheset + * + * @param $path path of the file + * @return the contents of the file + */ function loadFile($path) { $this->cache_time($path);
