diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 15:11:12 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 15:11:12 -0300 |
commit | d42607998482e36865c1d8a443f92a457f6b2f3b (patch) | |
tree | 9840be82dbf1b58da42d0a66f20b23ea0b01cf55 /vendors/min/lib/Minify/Controller/Page.php | |
download | elgg-d42607998482e36865c1d8a443f92a457f6b2f3b.tar.gz elgg-d42607998482e36865c1d8a443f92a457f6b2f3b.tar.bz2 |
Squashed 'mod/minify/' content from commit 5949018
git-subtree-dir: mod/minify
git-subtree-split: 594901859d5afc1fa364322428bd7a6d5c6a3f96
Diffstat (limited to 'vendors/min/lib/Minify/Controller/Page.php')
-rw-r--r-- | vendors/min/lib/Minify/Controller/Page.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/vendors/min/lib/Minify/Controller/Page.php b/vendors/min/lib/Minify/Controller/Page.php new file mode 100644 index 000000000..fa4599abd --- /dev/null +++ b/vendors/min/lib/Minify/Controller/Page.php @@ -0,0 +1,82 @@ +<?php +/** + * Class Minify_Controller_Page + * @package Minify + */ + +require_once 'Minify/Controller/Base.php'; + +/** + * Controller class for serving a single HTML page + * + * @link http://code.google.com/p/minify/source/browse/trunk/web/examples/1/index.php#59 + * @package Minify + * @author Stephen Clay <steve@mrclay.org> + */ +class Minify_Controller_Page extends Minify_Controller_Base { + + /** + * Set up source of HTML content + * + * @param array $options controller and Minify options + * @return array Minify options + * + * Controller options: + * + * 'content': (required) HTML markup + * + * 'id': (required) id of page (string for use in server-side caching) + * + * 'lastModifiedTime': timestamp of when this content changed. This + * is recommended to allow both server and client-side caching. + * + * 'minifyAll': should all CSS and Javascript blocks be individually + * minified? (default false) + * + * @todo Add 'file' option to read HTML file. + */ + public function setupSources($options) { + if (isset($options['file'])) { + $sourceSpec = array( + 'filepath' => $options['file'] + ); + } else { + // strip controller options + $sourceSpec = array( + 'content' => $options['content'] + ,'id' => $options['id'] + ); + unset($options['content'], $options['id']); + } + if (isset($options['minifyAll'])) { + // this will be the 2nd argument passed to Minify_HTML::minify() + $sourceSpec['minifyOptions'] = array( + 'cssMinifier' => array('Minify_CSS', 'minify') + ,'jsMinifier' => array('JSMin', 'minify') + ); + $this->_loadCssJsMinifiers = true; + unset($options['minifyAll']); + } + $this->sources[] = new Minify_Source($sourceSpec); + + $options['contentType'] = Minify::TYPE_HTML; + return $options; + } + + protected $_loadCssJsMinifiers = false; + + /** + * @see Minify_Controller_Base::loadMinifier() + */ + public function loadMinifier($minifierCallback) + { + if ($this->_loadCssJsMinifiers) { + // Minify will not call for these so we must manually load + // them when Minify/HTML.php is called for. + require_once 'Minify/CSS.php'; + require_once 'JSMin.php'; + } + parent::loadMinifier($minifierCallback); // load Minify/HTML.php + } +} + |