From 56df9ea9ad0810b8c1e6b581fdf44a55750a5c04 Mon Sep 17 00:00:00 2001 From: Alib Date: Mon, 22 Mar 2010 20:31:41 +0100 Subject: Added Minify to concatenate and minimize css and js file and gzip them. Cleaned directories, moved all css and js in respective folders. --- min/lib/Minify/Controller/Files.php | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 min/lib/Minify/Controller/Files.php (limited to 'min/lib/Minify/Controller/Files.php') diff --git a/min/lib/Minify/Controller/Files.php b/min/lib/Minify/Controller/Files.php new file mode 100644 index 0000000..83f028a --- /dev/null +++ b/min/lib/Minify/Controller/Files.php @@ -0,0 +1,78 @@ + + * Minify::serve('Files', array( + * 'files' => array( + * '//js/jquery.js' + * ,'//js/plugins.js' + * ,'/home/username/file.js' + * ) + * )); + * + * + * As a shortcut, the controller will replace "//" at the beginning + * of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'. + * + * @package Minify + * @author Stephen Clay + */ +class Minify_Controller_Files extends Minify_Controller_Base { + + /** + * Set up file sources + * + * @param array $options controller and Minify options + * @return array Minify options + * + * Controller options: + * + * 'files': (required) array of complete file paths, or a single path + */ + public function setupSources($options) { + // strip controller options + + $files = $options['files']; + // if $files is a single object, casting will break it + if (is_object($files)) { + $files = array($files); + } elseif (! is_array($files)) { + $files = (array)$files; + } + unset($options['files']); + + $sources = array(); + foreach ($files as $file) { + if ($file instanceof Minify_Source) { + $sources[] = $file; + continue; + } + if (0 === strpos($file, '//')) { + $file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1); + } + $realPath = realpath($file); + if (is_file($realPath)) { + $sources[] = new Minify_Source(array( + 'filepath' => $realPath + )); + } else { + $this->log("The path \"{$file}\" could not be found (or was not a file)"); + return $options; + } + } + if ($sources) { + $this->sources = $sources; + } + return $options; + } +} + -- cgit v1.2.3