Moodle  2.2.1
http://www.collinsharper.com
Minify Namespace Reference

Detailed Description

AJAX checks for zlib.output_compression

Configuration for default Minify application

Groups configuration for default Minify implementation

Class HTTP_ConditionalGet

HTTP

Implement conditional GET via a timestamp or hash of content

E.g. Content from DB with update time: list($updateTime, $content) = getDbUpdateAndContent(); $cg = new HTTP_ConditionalGet(array( 'lastModifiedTime' => $updateTime ,'isPublic' => true )); $cg->sendHeaders(); if ($cg->cacheIsValid) { exit(); } echo $content;

E.g. Shortcut for the above HTTP_ConditionalGet::check($updateTime, true); // exits if client has cache echo $content;

E.g. Content from DB with no update time: $content = getContentFromDB(); $cg = new HTTP_ConditionalGet(array( 'contentHash' => md5($content) )); $cg->sendHeaders(); if ($cg->cacheIsValid) { exit(); } echo $content;

E.g. Static content with some static includes: // before content $cg = new HTTP_ConditionalGet(array( 'lastUpdateTime' => max( filemtime(__FILE__) ,filemtime('/path/to/header.inc') ,filemtime('/path/to/footer.inc') ) )); $cg->sendHeaders(); if ($cg->cacheIsValid) { exit(); }

HTTP

Author:
Stephen Clay <steve@mrclay.org>

Class HTTP_Encoder

HTTP

Encode and send gzipped/deflated content

The "Vary: Accept-Encoding" header is sent. If the client allows encoding, Content-Encoding and Content-Length are added.

// Send a CSS file, compressed if possible $he = new HTTP_Encoder(array( 'content' => file_get_contents($cssFile) ,'type' => 'text/css' )); $he->encode(); $he->sendAll();

// Shortcut to encoding output header('Content-Type: text/css'); // needed if not HTML HTTP_Encoder::output($css);

// Just sniff for the accepted encoding $encoding = HTTP_Encoder::getAcceptedEncoding();

For more control over headers, use getHeaders() and getData() and send your own output.

Note: If you don't need header mgmt, use PHP's native gzencode, gzdeflate, and gzcompress functions for gzip, deflate, and compress-encoding respectively.

HTTP

Author:
Stephen Clay <steve@mrclay.org>

Class Minify_Build

Maintain a single last modification time for a group of Minify sources to allow use of far off Expires headers in Minify.

// in config file $groupSources = array( 'js' => array('file1.js', 'file2.js') ,'css' => array('file1.css', 'file2.css', 'file3.css') )

// during HTML generation $jsBuild = new Minify_Build($groupSources['js']); $cssBuild = new Minify_Build($groupSources['css']);

$script = "<script type='text/javascript' src='" . $jsBuild->uri('/min.php/js') . "'></script>"; $link = "<link rel='stylesheet' type='text/css' href='" . $cssBuild->uri('/min.php/css') . "'>";

// in min.php Minify::serve('Groups', array( 'groups' => $groupSources ,'setExpires' => (time() + 86400 * 365) ));

Author:
Stephen Clay <steve@mrclay.org>

Class Minify_Cache_APC

APC-based cache class for Minify

Minify::setCache(new Minify_Cache_APC());

Author:
Chris Edwards

Class Minify_Cache_File

Class Minify_Cache_Memcache

Class Minify_CommentPreserver

Process a string in pieces preserving C-style comments that begin with "/*!"

Author:
Stephen Clay <steve@mrclay.org>

Class Minify_Controller_Base

Base class for Minify controller

The controller class validates a request and uses it to create sources for minification and set options like contentType. It's also responsible for loading minifier code upon request.

Author:
Stephen Clay <steve@mrclay.org>

Class Minify_Controller_Files

Controller class for minifying a set of files

E.g. the following would serve the minified Javascript for a site Minify::serve('Files', array( 'files' => array( '//js/jquery.js' ,'//js/plugins.js' ,'/home/username/file.js' ) ));

As a shortcut, the controller will replace "//" at the beginning of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'.

Author:
Stephen Clay <steve@mrclay.org>

Class Minify_Controller_Groups

Controller class for serving predetermined groups of minimized sets, selected by PATH_INFO

Minify::serve('Groups', array( 'groups' => array( 'css' => array('//css/type.css', '//css/layout.css') ,'js' => array('//js/jquery.js', '//js/site.js') ) ));

If the above code were placed in /serve.php, it would enable the URLs /serve.php/js and /serve.php/css

As a shortcut, the controller will replace "//" at the beginning of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'.

Author:
Stephen Clay <steve@mrclay.org>

Class Minify_Controller_MinApp

Controller class for requests to /min/index.php

Author:
Stephen Clay <steve@mrclay.org>

Class Minify_Controller_Page

Controller class for serving a single HTML page

Stephen Clay <steve@mrclay.org> Class Minify_Controller_Version1 Controller class for emulating version 1 of minify.php Minify::serve('Version1'); Stephen Clay <steve@mrclay.org> Class Minify_CSS_Compressor Compress CSS This is a heavy regex-based removal of whitespace, unnecessary comments and tokens, and some CSS value minimization, where practical. Many steps have been taken to avoid breaking comment-based hacks, including the ie5/mac filter (and its inversion), but expect tricky hacks involving comment tokens in 'content' value strings to break minimization badly. A test suite is available. Stephen Clay <steve@mrclay.org> http://code.google.com/u/1stvamp/ (Issue 64 patch) Class Minify_CSS_UriRewriter Rewrite file-relative URIs as root-relative in CSS files Stephen Clay <steve@mrclay.org> Class Minify_CSS Minify CSS This class uses Minify_CSS_Compressor and Minify_CSS_UriRewriter to minify CSS and rewrite relative URIs. Stephen Clay <steve@mrclay.org> http://code.google.com/u/1stvamp/ (Issue 64 patch) Class Minify_HTML Compress HTML This is a heavy regex-based removal of whitespace, unnecessary comments and tokens. IE conditional comments are preserved. There are also options to have STYLE and SCRIPT blocks compressed by callback functions. A test suite is available. Stephen Clay <steve@mrclay.org> Class Minify_ImportProcessor Linearize a CSS/JS file by including content specified by CSS import declarations. In CSS files, relative URIs are fixed. will be processed regardless of where they appear in the source files; i.e. commented out or in string content will still be processed! This has a unit test but should be considered "experimental". Stephen Clay <steve@mrclay.org> Class Minify_Lines Add line numbers in C-style comments for easier debugging of combined content Stephen Clay <steve@mrclay.org> Adam Pedersen (Issue 55 fix) Class Minify_Logger Message logging class Stephen Clay <steve@mrclay.org> Class Minify_Packer To use this class you must first download the PHP port of Packer and place the file "class.JavaScriptPacker.php" in /lib (or your include_path). http://joliclic.free.fr/php/javascript-packer/en/ Be aware that, as long as HTTP encoding is used, scripts minified with JSMin will provide better client-side performance, as they need not be unpacked in client-side code. Minify Javascript using Dean Edward's Packer Class Minify_Source A content source to be minified by Minify. This allows per-source minification options and the mixing of files with content from other sources. Stephen Clay <steve@mrclay.org> Class Minify_YUICompressor Compress Javascript/CSS using the YUI Compressor You must set $jarFile and $tempDir before calling the minify functions. Also, depending on your shell's environment, you may need to specify the full path to java in $javaExecutable or use putenv() to setup the Java environment. Minify_YUICompressor::$jarFile = '/path/to/yuicompressor-2.3.5.jar'; Minify_YUICompressor::$tempDir = '/tmp'; $code = Minify_YUICompressor::minifyJs( $code ,array('nomunge' => true, 'line-break' => 1000) ); todo 92. Stephen Clay <steve@mrclay.org> Class Minify Minify_Source Minify - Combines, minifies, and caches JavaScript and CSS files on demand. See README for usage instructions (for now). This library was inspired by mailto:flashkot@mail.ru jscsscomp by Maxim Martynyuk} and by the article http://www.hunlock.com/blogs/Supercharged_Javascript "Supercharged JavaScript" by Patrick Hunlock}. Requires PHP 5.1.0. Tested on PHP 5.1.6. Ryan Grove <ryan@wonko.com> Stephen Clay <steve@mrclay.org> 2008 Ryan Grove, Stephen Clay. All rights reserved. http://opensource.org/licenses/bsd-license.php New BSD License http://code.google.com/p/minify/ Utility functions for generating group URIs in HTML files Before including this file, /min/lib must be in your include_path.

 All Data Structures Namespaces Files Functions Variables Enumerations