3 * Class Minify_Controller_Page
8 * Controller class for serving a single HTML page
10 * @link http://code.google.com/p/minify/source/browse/trunk/web/examples/1/index.php#59
12 * @author Stephen Clay <steve@mrclay.org>
14 class Minify_Controller_Page extends Minify_Controller_Base {
17 * Set up source of HTML content
19 * @param array $options controller and Minify options
20 * @return array Minify options
24 * 'content': (required) HTML markup
26 * 'id': (required) id of page (string for use in server-side caching)
28 * 'lastModifiedTime': timestamp of when this content changed. This
29 * is recommended to allow both server and client-side caching.
31 * 'minifyAll': should all CSS and Javascript blocks be individually
32 * minified? (default false)
34 * @todo Add 'file' option to read HTML file.
36 public function setupSources($options) {
37 if (isset($options['file'])) {
39 'filepath' => $options['file']
41 $f = $options['file'];
43 // strip controller options
45 'content' => $options['content']
46 ,'id' => $options['id']
49 unset($options['content'], $options['id']);
51 // something like "builder,index.php" or "directory,file.html"
52 $this->selectionId = strtr(substr($f, 1 + strlen(dirname(dirname($f)))), '/\\', ',,');
54 if (isset($options['minifyAll'])) {
55 // this will be the 2nd argument passed to Minify_HTML::minify()
56 $sourceSpec['minifyOptions'] = array(
57 'cssMinifier' => array('Minify_CSS', 'minify')
58 ,'jsMinifier' => array('JSMin', 'minify')
60 unset($options['minifyAll']);
62 $this->sources[] = new Minify_Source($sourceSpec);
64 $options['contentType'] = Minify::TYPE_HTML;