3 * Class Minify_Controller_Page
7 require_once 'Minify/Controller/Base.php';
10 * Controller class for serving a single HTML page
12 * @link http://code.google.com/p/minify/source/browse/trunk/web/examples/1/index.php#59
14 * @author Stephen Clay <steve@mrclay.org>
16 class Minify_Controller_Page extends Minify_Controller_Base {
19 * Set up source of HTML content
21 * @param array $options controller and Minify options
22 * @return array Minify options
26 * 'content': (required) HTML markup
28 * 'id': (required) id of page (string for use in server-side caching)
30 * 'lastModifiedTime': timestamp of when this content changed. This
31 * is recommended to allow both server and client-side caching.
33 * 'minifyAll': should all CSS and Javascript blocks be individually
34 * minified? (default false)
36 * @todo Add 'file' option to read HTML file.
38 public function setupSources($options) {
39 if (isset($options['file'])) {
41 'filepath' => $options['file']
44 // strip controller options
46 'content' => $options['content']
47 ,'id' => $options['id']
49 unset($options['content'], $options['id']);
51 if (isset($options['minifyAll'])) {
52 // this will be the 2nd argument passed to Minify_HTML::minify()
53 $sourceSpec['minifyOptions'] = array(
54 'cssMinifier' => array('Minify_CSS', 'minify')
55 ,'jsMinifier' => array('JSMin', 'minify')
57 $this->_loadCssJsMinifiers = true;
58 unset($options['minifyAll']);
60 $this->sources[] = new Minify_Source($sourceSpec);
62 $options['contentType'] = Minify::TYPE_HTML;
66 protected $_loadCssJsMinifiers = false;
69 * @see Minify_Controller_Base::loadMinifier()
71 public function loadMinifier($minifierCallback)
73 if ($this->_loadCssJsMinifiers) {
74 // Minify will not call for these so we must manually load
75 // them when Minify/HTML.php is called for.
76 require_once 'Minify/CSS.php';
77 require_once 'JSMin.php';
79 parent::loadMinifier($minifierCallback); // load Minify/HTML.php