PluginProbe
WP Super Minify • Minify, Compress and Cache HTML, CSS & JavaScript / trunk
WP Super Minify • Minify, Compress and Cache HTML, CSS & JavaScript vtrunk
trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.4 1.5 1.5.1 1.6 2.0 2.0.1
wp-super-minify / includes / min / lib / Minify / Controller / Page.php

Page.php in WP Super Minify • Minify, Compress and Cache HTML, CSS & JavaScript trunk, at includes/min/lib/Minify/Controller/Page.php

69 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Minify_Controller_Page
4 * @package Minify
5 */
6
7 /**
8 * Controller class for serving a single HTML page
9 *
10 * @link http://code.google.com/p/minify/source/browse/trunk/web/examples/1/index.php#59
11 * @package Minify
12 * @author Stephen Clay <steve@mrclay.org>
13 */
14 class Minify_Controller_Page extends Minify_Controller_Base
15 {
16
17 /**
18 * Set up source of HTML content
19 *
20 * @param array $options controller and Minify options
21 * @return array Minify options
22 *
23 * Controller options:
24 *
25 * 'content': (required) HTML markup
26 *
27 * 'id': (required) id of page (string for use in server-side caching)
28 *
29 * 'lastModifiedTime': timestamp of when this content changed. This
30 * is recommended to allow both server and client-side caching.
31 *
32 * 'minifyAll': should all CSS and Javascript blocks be individually
33 * minified? (default false)
34 */
35 public function createConfiguration(array $options)
36 {
37 if (isset($options['file'])) {
38 $sourceSpec = array(
39 'filepath' => $options['file']
40 );
41 $f = $options['file'];
42 } else {
43 // strip controller options
44 $sourceSpec = array(
45 'content' => $options['content'],
46 'id' => $options['id'],
47 );
48 $f = $options['id'];
49 unset($options['content'], $options['id']);
50 }
51 // something like "builder,index.php" or "directory,file.html"
52 $selectionId = strtr(substr($f, 1 + strlen(dirname(dirname($f)))), '/\\', ',,');
53
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_CSSmin', 'minify'),
58 'jsMinifier' => array('JSMin\\JSMin', 'minify'),
59 );
60 unset($options['minifyAll']);
61 }
62
63 $sourceSpec['contentType'] = Minify::TYPE_HTML;
64 $sources[] = new Minify_Source($sourceSpec);
65
66 return new Minify_ServeConfiguration($options, $sources, $selectionId);
67 }
68 }
69