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 / Groups.php

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

76 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_Groups
4 * @package Minify
5 */
6
7 /**
8 * Controller class for serving predetermined groups of minimized sets, selected
9 * by PATH_INFO
10 *
11 * <code>
12 * Minify::serve('Groups', array(
13 * 'groups' => array(
14 * 'css' => array('//css/type.css', '//css/layout.css')
15 * ,'js' => array('//js/jquery.js', '//js/site.js')
16 * )
17 * ));
18 * </code>
19 *
20 * If the above code were placed in /serve.php, it would enable the URLs
21 * /serve.php/js and /serve.php/css
22 *
23 * @package Minify
24 * @author Stephen Clay <steve@mrclay.org>
25 */
26 class Minify_Controller_Groups extends Minify_Controller_Files
27 {
28
29 /**
30 * Set up groups of files as sources
31 *
32 * @param array $options controller and Minify options
33 *
34 * 'groups': (required) array mapping PATH_INFO strings to arrays
35 * of complete file paths. @see Minify_Controller_Groups
36 *
37 * @return array Minify options
38 */
39 public function createConfiguration(array $options)
40 {
41 // strip controller options
42 $groups = $options['groups'];
43 unset($options['groups']);
44
45 $server = $this->env->server();
46
47 // mod_fcgid places PATH_INFO in ORIG_PATH_INFO
48 if (isset($server['ORIG_PATH_INFO'])) {
49 $pathInfo = substr($server['ORIG_PATH_INFO'], 1);
50 } elseif (isset($server['PATH_INFO'])) {
51 $pathInfo = substr($server['PATH_INFO'], 1);
52 } else {
53 $pathInfo = false;
54 }
55
56 if (false === $pathInfo || ! isset($groups[$pathInfo])) {
57 // no PATH_INFO or not a valid group
58 $this->logger->info("Missing PATH_INFO or no group set for \"$pathInfo\"");
59
60 return new Minify_ServeConfiguration($options);
61 }
62
63 $files = $groups[$pathInfo];
64 // if $files is a single object, casting will break it
65 if (is_object($files)) {
66 $files = array($files);
67 } elseif (! is_array($files)) {
68 $files = (array)$files;
69 }
70
71 $options['files'] = $files;
72
73 return parent::createConfiguration($options);
74 }
75 }
76