--- /dev/null
+<?php
+/*
+StatusNet Plugin: 0.9
+Plugin Name: Minify
+Description: Minifies resources (Javascript and CSS)
+Version: 0.1
+Author: Craig Andrews <candrews@integralblue.com>
+Author URI: http://candrews.integralblue.com/
+*/
+
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @package MinifyPlugin
+ * @maintainer Craig Andrews <candrews@integralblue.com>
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+
+class MinifyPlugin extends Plugin
+{
+
+ /**
+ * Add Minification related paths to the router table
+ *
+ * Hook for RouterInitialized event.
+ *
+ * @return boolean hook return
+ */
+
+ function onStartInitializeRouter($m)
+ {
+ $m->connect('main/min',
+ array('action' => 'minify'));
+ return true;
+ }
+
+ function onAutoload($cls)
+ {
+ switch ($cls)
+ {
+ case 'MinifyAction':
+ require_once(INSTALLDIR.'/plugins/Minify/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ function onLoginAction($action, &$login)
+ {
+ switch ($action)
+ {
+ case 'minify':
+ $login = true;
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ function onStartScriptElement($action,&$src,&$type) {
+ $url = parse_url($src);
+ if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment))
+ {
+ $src = common_path('main/min?f='.$src.'&v=' . STATUSNET_VERSION);
+ }
+ }
+
+ function onStartCssLinkElement($action,&$src,&$theme,&$media) {
+ $url = parse_url($src);
+ if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment))
+ {
+ if(file_exists(Theme::file($src,$theme))){
+ //src is a relative path, so we can do minification
+ if(isset($theme)) {
+ $src = common_path('main/min?f=theme/'.$theme.'/'.$src.'&v=' . STATUSNET_VERSION);
+ } else {
+ $src = common_path('main/min?f=theme/default/'.$src.'&v=' . STATUSNET_VERSION);
+ }
+ }
+ }
+ }
+}
+
--- /dev/null
+The Minify plugin minifies your CSS and Javascript, removing whitespace and comments.
+
+Note that if enabled this plugin and use a theme server
+ ($config['theme']['server']), your theme server will not be used.
+
+Installation
+============
+add "addPlugin('minify',
+ array('setting'=>'value', 'setting2'=>'value2', ...);"
+to the bottom of your config.php
+
+Settings
+========
+None at the moment
+
+Example
+=======
+
+addPlugin('minify', array());
+
--- /dev/null
+Minify Release History
+
+Version 2.1.3
+ * HTTP fixes
+ * ETag generation now valid (different when gzipped)
+ * Vary header always sent when Accept-Encoding is sniffed
+ * Cache-Control no longer has "must-revalidate" due to webkit bug
+ See: http://mrclay.org/index.php/2009/02/24/safari-4-beta-cache-controlmust-revalidate-bug/
+ * Dropped deflate encoding. Browser and proxy support could be buggy.
+ See: http://stackoverflow.com/questions/883841/
+ * File cache now works w/o setting $min_cachePath
+ * Allow setting contentType in Minify_Source objects
+ * No more 5.3 deprecation warnings: split() removed
+
+Version 2.1.2
+ * Javascript fixes
+ * Debug mode no longer confused by "*/*" in strings/RegExps (jQuery)
+ * quote characters inside RegExp literals no longer cause exception
+ * files ending in single-line comments no longer cause code loss
+ * CSS: data: URLs no longer mangled
+ * Optional error logging to Firefox's FirePHP extension
+ * Unit tests to check for common DOCUMENT_ROOT problems
+ * DOCUMENT_ROOT no longer overwritten on IIS servers
+ * Builder app doesn't fail on systems without gzdeflate()
+ * APC caching class included
+
+Version 2.1.1
+ * Bug fix release
+ * Detection and workarounds for zlib.output_compression and non-PHP encoding modules
+ * Zlib not required (mod_rewrite, et.al., can still be used for encoding)
+ * HTML : More IE conditional comments preserved
+ * Minify_groupUri() utility fixed
+
+Version 2.1.0
+ * "min" default application for quick deployment
+ * Minify URI Builder app & bookmarklet for quickly creating minify URIs
+ * Relative URIs in CSS file are fixed automatically by default
+ * "debug" mode for revealing original line #s in combined files
+ * Better IIS support
+ * Improved minifier classes:
+ * JS: preserves IE conditional comments
+ * CSS: smaller output, preserves more hacks and valid CSS syntax,
+ shorter line lengths, other bug fixes
+ * HTML: smaller output, shorter line lengths, other bug fixes
+ * Default Cache-Control: max-age of 30 minutes
+ * Conditional GETs supported even when max-age sent
+ * Experimental memcache cache class (default is files)
+ * Minify_Cache_File has flock()s (by default)
+ * Workaround for Windows mtime reporting bug
+
+Version 2.0.2 beta (2008-06-24)
+ * Fast new cache system. Cached files served almost 3x as fast.
+ * Dropped support of compress encoding (though HTTP_Encoder still supports it)
+
+Version 2.0.1 (2008-05-31)
+ * E_STRICT compliance (Cache_Lite_File).
+
+Version 2.0.0 (2008-05-22)
+ * Complete code overhaul. Minify is now a PEAR-style class and toolkit
+ for building customized minifying file servers.
+ * Content-Encoding: deflate/gzip/compress, based on request headers
+ * Expanded CSS and HTML minifiers with test cases
+ * Easily plug-in 3rd-party minifiers (like Packer)
+ * Plug-able front end controller allows changing the way files are chosen
+ * Compression & encoding modules lazy-loaded as needed (304 responses use
+ use minimal code)
+ * Separate utility classes for HTTP encoding and cache control
+
+Version 1.0.1 (2007-05-05)
+ * Fixed various problems resolving pathnames when hosted on an NFS mount.
+ * Fixed 'undefined constant' notice.
+ * Replaced old JSMin library with a much faster custom implementation.
+
+Version 1.0.0 (2007-05-02)
+ * First release.
\ No newline at end of file
--- /dev/null
+Copyright (c) 2008 Ryan Grove <ryan@wonko.com>
+Copyright (c) 2008 Steve Clay <steve@mrclay.org>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of this project nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- /dev/null
+WELCOME TO MINIFY 2.1!
+
+Minify is an HTTP content server. It compresses sources of content
+(usually files), combines the result and serves it with appropriate
+HTTP headers. These headers can allow clients to perform conditional
+GETs (serving content only when clients do not have a valid cache)
+and tell clients to cache the file for a period of time.
+More info: http://code.google.com/p/minify/
+
+
+UPGRADING
+
+See UPGRADING.txt for instructions.
+
+
+INSTALLATION AND USAGE:
+
+1. Place the /min/ directory as a child of your DOCUMENT_ROOT
+directory: i.e. you will have: /home/user/www/public_html/min
+
+2. Open http://yourdomain/min/ in a web browser. This will forward
+you to the Minify URI Builder application, which will help you
+quickly start using Minify to serve content on your site.
+
+
+UNIT TESTING:
+
+1. Place the /min_unit_tests/ directory as a child of your DOCUMENT_ROOT
+directory: i.e. you will have: /home/user/www/public_html/min_unit_tests
+
+2. To run unit tests, access: http://yourdomain/min_unit_tests/test_all.php
+
+(If you wish, the other test_*.php files can be run to test individual
+components with more verbose output.)
+
+3. Remove /min_unit_tests/ from your DOCUMENT_ROOT when you are done.
+
+
+EXTRAS:
+
+The min_extras folder contains files for benchmarking using Apache ab on Windows
+and a couple single-use tools. DO NOT place this on your production server.
+
+
+FILE ENCODINGS
+
+Minify *should* work fine with files encoded in UTF-8 or other 8-bit
+encodings like ISO 8859/Windows-1252. By default Minify appends
+";charset=utf-8" to the Content-Type headers it sends.
+
+Leading UTF-8 BOMs are stripped from all sources to prevent
+duplication in output files, and files are converted to Unix newlines.
+
--- /dev/null
+Minify Upgrade Guide
+
+UPGRADING FROM 2.1.*
+
+1. Rename the following files:
+
+ /min/config.php --> /min/old_config.php\r
+ /min/groupsConfig.php --> /min/old_groupsConfig.php
+
+2. Overwrite all files in /min (and /min_unit_tests) with those from this zip.
+
+3. Delete /min/groupsConfig.php
+
+4. Rename /min/old_groupsConfig.php --> /min/groupsConfig.php
+
+5. Merge your settings in old_config.php into config.php.
+
+ * If you've set $_SERVER['DOCUMENT_ROOT'], instead set the new option
+ $min_documentRoot. This is advantageous on IIS systems because Minify
+ will no longer overwrite the path you specified.
+
+ * $min_errorLogger adds the ability to enable FirePHP logging.
+
+6. (optional) Delete /min/old_config.php and the Minify files from your cache
+ directory (specified in $min_cachePath).
+
+
+INSTALLING FRESH
+
+See README.txt for instructions on installing this app for the first time.
+
+
+SUPPORT
+
+Send a message to http://groups.google.com/group/minify
\ No newline at end of file
--- /dev/null
+The files in this directory represent the default Minify setup designed to ease
+integration with your site. This app will combine and minify your Javascript or
+CSS files and serve them with HTTP compression and cache headers.
+
+
+RECOMMENDED
+
+It's recommended to edit config.php to set $min_cachePath to a writeable
+(by PHP) directory on your system. This will improve performance.
+
+
+GETTING STARTED
+
+The quickest way to get started is to use the Minify URI Builder application
+on your website: http://example.com/min/builder/
+
+
+MINIFYING A SINGLE FILE
+
+Let's say you want to serve this file:
+ http://example.com/wp-content/themes/default/default.css
+
+Here's the "Minify URL" for this file:
+ http://example.com/min/?f=wp-content/themes/default/default.css
+
+In other words, the "f" argument is set to the file path from root without the
+initial "/". As CSS files may contain relative URIs, Minify will automatically
+"fix" these by rewriting them as root relative.
+
+
+COMBINING MULTIPLE FILES IN ONE DOWNLOAD
+
+Separate the paths given to "f" with commas.
+
+Let's say you have CSS files at these URLs:
+ http://example.com/scripts/jquery-1.2.6.js
+ http://example.com/scripts/site.js
+
+You can combine these files through Minify by requesting this URL:
+ http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js
+
+
+SIMPLIFYING URLS WITH A BASE PATH
+
+If you're combining files that share the same ancestor directory, you can use
+the "b" argument to set the base directory for the "f" argument. Do not include
+the leading or trailing "/" characters.
+
+E.g., the following URLs will serve the exact same content:
+ http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js,scripts/home.js
+ http://example.com/min/?b=scripts&f=jquery-1.2.6.js,site.js,home.js
+
+
+MINIFY URLS IN HTML
+
+In (X)HTML files, don't forget to replace any "&" characters with "&".
+
+
+SPECIFYING ALLOWED DIRECTORIES
+
+By default, Minify will serve any *.css/*.js files within the DOCUMENT_ROOT. If
+you'd prefer to limit Minify's access to certain directories, set the
+$min_serveOptions['minApp']['allowDirs'] array in config.php. E.g. to limit
+to the /js and /themes/default directories, use:
+
+$min_serveOptions['minApp']['allowDirs'] = array('//js', '//themes/default');
+
+
+GROUPS: FASTER PERFORMANCE AND BETTER URLS
+
+For the best performance, edit groupsConfig.php to pre-specify groups of files
+to be combined under preset keys. E.g., here's an example configuration in
+groupsConfig.php:
+
+return array(\r
+ 'js' => array('//js/Class.js', '//js/email.js')\r
+);
+
+This pre-selects the following files to be combined under the key "js":
+ http://example.com/js/Class.js
+ http://example.com/js/email.js
+
+You can now serve these files with this simple URL:
+ http://example.com/min/?g=js
+
+
+GROUPS: SPECIFYING FILES OUTSIDE THE DOC_ROOT
+
+In the groupsConfig.php array, the "//" in the file paths is a shortcut for
+the DOCUMENT_ROOT, but you can also specify paths from the root of the filesystem
+or relative to the DOC_ROOT:
+
+return array(
+ 'js' => array(
+ '//js/file.js' // file within DOC_ROOT
+ ,'//../file.js' // file in parent directory of DOC_ROOT
+ ,'C:/Users/Steve/file.js' // file anywhere on filesystem
+ )
+);
+
+
+FAR-FUTURE EXPIRES HEADERS
+
+Minify can send far-future (one year) Expires headers. To enable this you must
+add a number to the querystring (e.g. /min/?g=js&1234 or /min/f=file.js&1234)
+and alter it whenever a source file is changed. If you have a build process you
+can use a build/source control revision number.
+
+If you serve files as a group, you can use the utility function Minify_groupUri()
+to get a "versioned" Minify URI for use in your HTML. E.g.:
+
+<?php
+// add /min/lib to your include_path first!
+require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
+
+$jsUri = Minify_groupUri('js');
+echo "<script type='text/javascript' src='{$jsUri}'></script>";
+
+
+DEBUG MODE
+
+In debug mode, instead of compressing files, Minify sends combined files with
+comments prepended to each line to show the line number in the original source
+file. To enable this, set $min_allowDebugFlag to true in config.php and append
+"&debug=1" to your URIs. E.g. /min/?f=script1.js,script2.js&debug=1
+
+Known issue: files with comment-like strings/regexps can cause problems in this mode.
+
+
+QUESTIONS?
+
+http://groups.google.com/group/minify
\ No newline at end of file
--- /dev/null
+var MUB = {
+ _uid : 0
+ ,_minRoot : '/min/?'
+ ,checkRewrite : function () {
+ var testUri = location.pathname.replace(/\/[^\/]*$/, '/rewriteTest.js').substr(1);
+ function fail() {
+ $('#minRewriteFailed')[0].className = 'topNote';
+ };
+ $.ajax({
+ url : '../f=' + testUri + '&' + (new Date()).getTime()
+ ,success : function (data) {
+ if (data === '1') {
+ MUB._minRoot = '/min/';
+ $('span.minRoot').html('/min/');
+ } else
+ fail();
+ }
+ ,error : fail
+ });
+ }
+ /**
+ * Get markup for new source LI element
+ */
+ ,newLi : function () {
+ return '<li id="li' + MUB._uid + '">http://' + location.host + '/<input type=text size=20>'
+ + ' <button title="Remove">x</button> <button title="Include Earlier">↑</button>'
+ + ' <button title="Include Later">↓</button> <span></span></li>';
+ }
+ /**
+ * Add new empty source LI and attach handlers to buttons
+ */
+ ,addLi : function () {
+ $('#sources').append(MUB.newLi());
+ var li = $('#li' + MUB._uid)[0];
+ $('button[title=Remove]', li).click(function () {
+ $('#results').hide();
+ var hadValue = !!$('input', li)[0].value;
+ $(li).remove();
+ });
+ $('button[title$=Earlier]', li).click(function () {
+ $(li).prev('li').find('input').each(function () {
+ $('#results').hide();
+ // this = previous li input
+ var tmp = this.value;
+ this.value = $('input', li).val();
+ $('input', li).val(tmp);
+ MUB.updateAllTestLinks();
+ });
+ });
+ $('button[title$=Later]', li).click(function () {
+ $(li).next('li').find('input').each(function () {
+ $('#results').hide();
+ // this = next li input
+ var tmp = this.value;
+ this.value = $('input', li).val();
+ $('input', li).val(tmp);
+ MUB.updateAllTestLinks();
+ });
+ });
+ ++MUB._uid;
+ }
+ /**
+ * In the context of a source LI element, this will analyze the URI in
+ * the INPUT and check the URL on the site.
+ */
+ ,liUpdateTestLink : function () { // call in context of li element
+ if (! $('input', this)[0].value)
+ return;
+ var li = this;
+ $('span', this).html('');
+ var url = 'http://' + location.host + '/'
+ + $('input', this)[0].value.replace(/^\//, '');
+ $.ajax({
+ url : url
+ ,complete : function (xhr, stat) {
+ if ('success' == stat)
+ $('span', li).html('✓');
+ else {
+ $('span', li).html('<button><b>404! </b> recheck</button>')
+ .find('button').click(function () {
+ MUB.liUpdateTestLink.call(li);
+ });
+ }
+ }
+ ,dataType : 'text'
+ });
+ }
+ /**
+ * Check all source URLs
+ */
+ ,updateAllTestLinks : function () {
+ $('#sources li').each(MUB.liUpdateTestLink);
+ }
+ /**
+ * In a given array of strings, find the character they all have at
+ * a particular index
+ * @param Array arr array of strings
+ * @param Number pos index to check
+ * @return mixed a common char or '' if any do not match
+ */
+ ,getCommonCharAtPos : function (arr, pos) {
+ var i
+ ,l = arr.length
+ ,c = arr[0].charAt(pos);
+ if (c === '' || l === 1)
+ return c;
+ for (i = 1; i < l; ++i)
+ if (arr[i].charAt(pos) !== c)
+ return '';
+ return c;
+ }
+ /**
+ * Get the shortest URI to minify the set of source files
+ * @param Array sources URIs
+ */
+ ,getBestUri : function (sources) {
+ var pos = 0
+ ,base = ''
+ ,c;
+ while (true) {
+ c = MUB.getCommonCharAtPos(sources, pos);
+ if (c === '')
+ break;
+ else
+ base += c;
+ ++pos;
+ }
+ base = base.replace(/[^\/]+$/, '');
+ var uri = MUB._minRoot + 'f=' + sources.join(',');
+ if (base.charAt(base.length - 1) === '/') {
+ // we have a base dir!
+ var basedSources = sources
+ ,i
+ ,l = sources.length;
+ for (i = 0; i < l; ++i) {
+ basedSources[i] = sources[i].substr(base.length);
+ }
+ base = base.substr(0, base.length - 1);
+ var bUri = MUB._minRoot + 'b=' + base + '&f=' + basedSources.join(',');
+ //window.console && console.log([uri, bUri]);
+ uri = uri.length < bUri.length
+ ? uri
+ : bUri;
+ }
+ return uri;
+ }
+ /**
+ * Create the Minify URI for the sources
+ */
+ ,update : function () {
+ MUB.updateAllTestLinks();
+ var sources = []
+ ,ext = false
+ ,fail = false;
+ $('#sources input').each(function () {
+ var m, val;
+ if (! fail && this.value && (m = this.value.match(/\.(css|js)$/))) {
+ var thisExt = m[1];
+ if (ext === false)
+ ext = thisExt;
+ else if (thisExt !== ext) {
+ fail = true;
+ return alert('extensions must match!');
+ }
+ this.value = this.value.replace(/^\//, '');
+ if (-1 != $.inArray(this.value, sources)) {
+ fail = true;
+ return alert('duplicate file!');
+ }
+ sources.push(this.value);
+ }
+ });
+ if (fail || ! sources.length)
+ return;
+ $('#groupConfig').val(" 'keyName' => array('//" + sources.join("', '//") + "'),");
+ var uri = MUB.getBestUri(sources)
+ ,uriH = uri.replace(/</, '<').replace(/>/, '>').replace(/&/, '&');
+ $('#uriA').html(uriH)[0].href = uri;
+ $('#uriHtml').val(
+ ext === 'js'
+ ? '<script type="text/javascript" src="' + uriH + '"></script>'
+ : '<link type="text/css" rel="stylesheet" href="' + uriH + '" />'
+ );
+ $('#results').show();
+ }
+ /**
+ * Handler for the "Add file +" button
+ */
+ ,addButtonClick : function () {
+ $('#results').hide();
+ MUB.addLi();
+ MUB.updateAllTestLinks();
+ $('#update').show().click(MUB.update);
+ $('#sources li:last input')[0].focus();
+ }
+ /**
+ * Runs on DOMready
+ */
+ ,init : function () {
+ $('#app').show();
+ $('#sources').html('');
+ $('#add button').click(MUB.addButtonClick);
+ // make easier to copy text out of
+ $('#uriHtml, #groupConfig').click(function () {
+ this.select();
+ }).focus(function () {
+ this.select();
+ });
+ $('a.ext').attr({target:'_blank'});
+ if (location.hash) {
+ // make links out of URIs from bookmarklet
+ $('#getBm').hide();
+ $('#bmUris').html('<p><strong>Found by bookmarklet:</strong> /<a href=#>'
+ + location.hash.substr(1).split(',').join('</a> | /<a href=#>')
+ + '</a></p>'
+ );
+ $('#bmUris a').click(function () {
+ MUB.addButtonClick();
+ $('#sources li:last input').val(this.innerHTML)
+ MUB.liUpdateTestLink.call($('#sources li:last')[0]);
+ $('#results').hide();
+ return false;
+ }).attr({title:'Add file +'});
+ } else {
+ // copy bookmarklet code into href
+ var bmUri = location.pathname.replace(/\/[^\/]*$/, '/bm.js').substr(1);
+ $.ajax({
+ url : '../?f=' + bmUri
+ ,success : function (code) {
+ $('#bm')[0].href = code
+ .replace('%BUILDER_URL%', location.href)
+ .replace(/\n/g, ' ');
+ }
+ ,dataType : 'text'
+ });
+ $.browser.msie && $('#getBm p:last').append(' Sorry, not supported in MSIE!');
+ MUB.addButtonClick();
+ }
+ MUB.checkRewrite();
+ }
+};
+window.onload = MUB.init;
\ No newline at end of file
--- /dev/null
+javascript:(function() {
+ var d = document
+ ,uris = []
+ ,i = 0
+ ,o
+ ,home = (location + '').split('/').splice(0, 3).join('/') + '/';
+ function add(uri) {
+ return (0 === uri.indexOf(home))
+ && (!/[\?&]/.test(uri))
+ && uris.push(escape(uri.substr(home.length)));
+ };
+ function sheet(ss) {
+ // we must check the domain with add() before accessing ss.cssRules
+ // otherwise a security exception will be thrown
+ if (ss.href && add(ss.href) && ss.cssRules) {
+ var i = 0, r;
+ while (r = ss.cssRules[i++])
+ r.styleSheet && sheet(r.styleSheet);
+ }
+ };
+ while (o = d.getElementsByTagName('script')[i++])
+ o.src && !(o.type && /vbs/i.test(o.type)) && add(o.src);
+ i = 0;
+ while (o = d.styleSheets[i++])
+ /* http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-DocumentStyle-styleSheets
+ document.styleSheet is a list property where [0] accesses the 1st element and
+ [outOfRange] returns null. In IE, styleSheets is a function, and also throws an
+ exception when you check the out of bounds index. (sigh) */
+ sheet(o);
+ if (uris.length)
+ window.open('%BUILDER_URL%#' + uris.join(','));
+ else
+ alert('No js/css files found with URLs within "'
+ + home.split('/')[2]
+ + '".\n(This tool is limited to URLs with the same domain.)');
+})();
\ No newline at end of file
--- /dev/null
+<?php
+
+if (phpversion() < 5) {
+ exit('Minify requires PHP5 or greater.');
+}
+
+// check for auto-encoding
+$encodeOutput = (function_exists('gzdeflate')
+ && !ini_get('zlib.output_compression'));
+
+require dirname(__FILE__) . '/../config.php';
+
+if (! $min_enableBuilder) {
+ header('Location: /');
+ exit();
+}
+
+ob_start();
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<head>
+ <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
+ <title>Minify URI Builder</title>
+ <style type="text/css">
+body {margin:1em 60px;}
+h1, h2, h3 {margin-left:-25px; position:relative;}
+h1 {margin-top:0;}
+#sources {margin:0; padding:0;}
+#sources li {margin:0 0 0 40px}
+#sources li input {margin-left:2px}
+#add {margin:5px 0 1em 40px}
+.hide {display:none}
+#uriTable {border-collapse:collapse;}
+#uriTable td, #uriTable th {padding-top:10px;}
+#uriTable th {padding-right:10px;}
+#groupConfig {font-family:monospace;}
+b {color:#c00}
+.topNote {background: #ff9; display:inline-block; padding:.5em .6em; margin:0 0 1em;}
+.topWarning {background:#c00; color:#fff; padding:.5em .6em; margin:0 0 1em;}
+ </style>
+</head>
+
+<?php if (! isset($min_cachePath)): ?>
+<p class=topNote><strong>Note:</strong> Please set <code>$min_cachePath</code>
+in /min/config.php to improve performance.</p>
+<?php endIf; ?>
+
+<p id=minRewriteFailed class="hide"><strong>Note:</strong> Your webserver does not seem to
+ support mod_rewrite (used in /min/.htaccess). Your Minify URIs will contain "?", which
+<a href="http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/"
+>may reduce the benefit of proxy cache servers</a>.</p>
+
+<h1>Minify URI Builder</h1>
+
+<noscript><p class="topNote">Javascript and a browser supported by jQuery 1.2.6 is required
+for this application.</p></noscript>
+
+<div id=app class=hide>
+
+<p>Create a list of Javascript or CSS files (or 1 is fine) you'd like to combine
+and click [Update].</p>
+
+<ol id=sources><li></li></ol>
+<div id=add><button>Add file +</button></div>
+
+<div id=bmUris></div>
+
+<p><button id=update class=hide>Update</button></p>
+
+<div id=results class=hide>
+
+<h2>Minify URI</h2>
+<p>Place this URI in your HTML to serve the files above combined, minified, compressed and
+with cache headers.</p>
+<table id=uriTable>
+ <tr><th>URI</th><td><a id=uriA class=ext>/min</a> <small>(opens in new window)</small></td></tr>
+ <tr><th>HTML</th><td><input id=uriHtml type=text size=100 readonly></td></tr>
+</table>
+
+<h2>How to serve these files as a group</h2>
+<p>For the best performance you can serve these files as a pre-defined group with a URI
+like: <code><span class=minRoot>/min/?</span>g=keyName</code></p>
+<p>To do this, add a line like this to /min/groupsConfig.php:</p>
+
+<pre><code>return array(
+ <span style="color:#666">... your existing groups here ...</span>
+<input id=groupConfig size=100 type=text readonly>
+);</code></pre>
+
+<p><em>Make sure to replace <code>keyName</code> with a unique key for this group.</em></p>
+</div>
+
+<div id=getBm>
+<h3>Find URIs on a Page</h3>
+<p>You can use the bookmarklet below to fetch all CSS & Javascript URIs from a page
+on your site. When you active it, this page will open in a new window with a list of
+available URIs to add.</p>
+
+<p><a id=bm>Create Minify URIs</a> <small>(right-click, add to bookmarks)</small></p>
+</div>
+
+<h3>Combining CSS files that contain <code>@import</code></h3>
+<p>If your CSS files contain <code>@import</code> declarations, Minify will not
+remove them. Therefore, you will want to remove those that point to files already
+in your list, and move any others to the top of the first file in your list
+(imports below any styles will be ignored by browsers as invalid).</p>
+<p>If you desire, you can use Minify URIs in imports and they will not be touched
+by Minify. E.g. <code>@import "<span class=minRoot>/min/?</span>g=css2";</code></p>
+
+</div><!-- #app -->
+
+<hr>
+<p>Need help? Search or post to the <a class=ext
+href="http://groups.google.com/group/minify">Minify discussion list</a>.</p>
+<p><small>This app is minified :) <a class=ext
+href="http://code.google.com/p/minify/source/browse/trunk/min/builder/index.php">view
+source</a></small></p>
+
+<script type="text/javascript"
+src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
+
+<script type="text/javascript">
+$(function () {
+ // detection of double output encoding
+ var msg = '<\p class=topWarning><\strong>Warning:<\/strong> ';
+ var url = 'ocCheck.php?' + (new Date()).getTime();
+ $.get(url, function (ocStatus) {
+ $.get(url + '&hello=1', function (ocHello) {
+ if (ocHello != 'World!') {
+ msg += 'It appears output is being automatically compressed, interfering '
+ + ' with Minify\'s own compression. ';
+ if (ocStatus == '1')
+ msg += 'The option "zlib.output_compression" is enabled in your PHP configuration. '
+ + 'Minify set this to "0", but it had no effect. This option must be disabled '
+ + 'in php.ini or .htaccess.';
+ else
+ msg += 'The option "zlib.output_compression" is disabled in your PHP configuration '
+ + 'so this behavior is likely due to a server option.';
+ $(document.body).prepend(msg + '<\/p>');
+ } else
+ if (ocStatus == '1')
+ $(document.body).prepend('<\p class=topNote><\strong>Note:</\strong> The option '
+ + '"zlib.output_compression" is enabled in your PHP configuration, but has been '
+ + 'successfully disabled via ini_set(). If you experience mangled output you '
+ + 'may want to consider disabling this option in your PHP configuration.<\/p>'
+ );
+ });
+ });
+});
+</script>
+<script type="text/javascript">
+ // workaround required to test when /min isn't child of web root
+ var src = location.pathname.replace(/\/[^\/]*$/, '/_index.js').substr(1);
+ document.write('<\script type="text/javascript" src="../?f=' + src + '"><\/script>');
+</script>
+
+<?php
+
+$serveOpts = array(
+ 'content' => ob_get_contents()
+ ,'id' => __FILE__
+ ,'lastModifiedTime' => max(
+ // regenerate cache if either of these change
+ filemtime(__FILE__)
+ ,filemtime(dirname(__FILE__) . '/../config.php')
+ )
+ ,'minifyAll' => true
+ ,'encodeOutput' => $encodeOutput
+);
+ob_end_clean();
+
+set_include_path(dirname(__FILE__) . '/../lib' . PATH_SEPARATOR . get_include_path());
+
+require 'Minify.php';
+
+if (0 === stripos(PHP_OS, 'win')) {
+ Minify::setDocRoot(); // we may be on IIS
+}
+Minify::setCache(isset($min_cachePath) ? $min_cachePath : null);
+Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
+
+Minify::serve('Page', $serveOpts);
--- /dev/null
+<?php
+/**
+ * AJAX checks for zlib.output_compression
+ *
+ * @package Minify
+ */
+
+$_oc = ini_get('zlib.output_compression');
+
+// allow access only if builder is enabled
+require dirname(__FILE__) . '/../config.php';
+if (! $min_enableBuilder) {
+ header('Location: /');
+ exit();
+}
+
+if (isset($_GET['hello'])) {
+ // echo 'World!'
+
+ // try to prevent double encoding (may not have an effect)
+ ini_set('zlib.output_compression', '0');
+
+ require $min_libPath . '/HTTP/Encoder.php';
+ HTTP_Encoder::$encodeToIe6 = true; // just in case
+ $he = new HTTP_Encoder(array(
+ 'content' => 'World!'
+ ,'method' => 'deflate'
+ ));
+ $he->encode();\r
+ $he->sendAll();\r
+
+} else {
+ // echo status "0" or "1"
+ header('Content-Type: text/plain');
+ echo (int)$_oc;
+}
--- /dev/null
+1
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Groups configuration for default Minify implementation
+ * @package Minify
+ */
+
+/**
+ * You may wish to use the Minify URI Builder app to suggest
+ * changes. http://yourdomain/min/builder/
+ **/
+
+return array(
+ // 'js' => array('//js/file1.js', '//js/file2.js'),
+ // 'css' => array('//css/file1.css', '//css/file2.css'),
+
+ // custom source example
+ /*'js2' => array(
+ dirname(__FILE__) . '/../min_unit_tests/_test_files/js/before.js',
+ // do NOT process this file
+ new Minify_Source(array(
+ 'filepath' => dirname(__FILE__) . '/../min_unit_tests/_test_files/js/before.js',
+ 'minifier' => create_function('$a', 'return $a;')
+ ))
+ ),//*/
+
+ /*'js3' => array(
+ dirname(__FILE__) . '/../min_unit_tests/_test_files/js/before.js',
+ // do NOT process this file
+ new Minify_Source(array(
+ 'filepath' => dirname(__FILE__) . '/../min_unit_tests/_test_files/js/before.js',
+ 'minifier' => array('Minify_Packer', 'minify')
+ ))
+ ),//*/
+);
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Front controller for default Minify implementation
+ *
+ * DO NOT EDIT! Configure this utility via config.php and groupsConfig.php
+ *
+ * @package Minify
+ */
+
+define('MINIFY_MIN_DIR', dirname(__FILE__));
+
+// load config
+require MINIFY_MIN_DIR . '/config.php';
+
+// setup include path
+set_include_path($min_libPath . PATH_SEPARATOR . get_include_path());
+
+require 'Minify.php';
+
+Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
+Minify::setCache(
+ isset($min_cachePath) ? $min_cachePath : ''
+ ,$min_cacheFileLocking
+);
+
+if ($min_documentRoot) {
+ $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
+} elseif (0 === stripos(PHP_OS, 'win')) {
+ Minify::setDocRoot(); // IIS may need help
+}
+
+$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
+
+if ($min_allowDebugFlag && isset($_GET['debug'])) {
+ $min_serveOptions['debug'] = true;
+}
+
+if ($min_errorLogger) {
+ require_once 'Minify/Logger.php';
+ if (true === $min_errorLogger) {
+ require_once 'FirePHP.php';
+ Minify_Logger::setLogger(FirePHP::getInstance(true));
+ } else {
+ Minify_Logger::setLogger($min_errorLogger);
+ }
+}
+
+// check for URI versioning
+if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
+ $min_serveOptions['maxAge'] = 31536000;
+}
+if (isset($_GET['g'])) {
+ // well need groups config
+ $min_serveOptions['minApp']['groups'] = (require MINIFY_MIN_DIR . '/groupsConfig.php');
+}
+if (isset($_GET['f']) || isset($_GET['g'])) {
+ // serve!
+ Minify::serve('MinApp', $min_serveOptions);
+
+} elseif ($min_enableBuilder) {
+ header('Location: builder/');
+ exit();
+} else {
+ header("Location: /");
+ exit();
+}
--- /dev/null
+<?php
+/**
+ * *** BEGIN LICENSE BLOCK *****
+ *
+ * This file is part of FirePHP (http://www.firephp.org/).
+ *
+ * Software License Agreement (New BSD License)
+ *
+ * Copyright (c) 2006-2008, Christoph Dorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Christoph Dorn nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK *****
+ *
+ * @copyright Copyright (C) 2007-2008 Christoph Dorn
+ * @author Christoph Dorn <christoph@christophdorn.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * @package FirePHP
+ */
+
+
+/**
+ * Sends the given data to the FirePHP Firefox Extension.
+ * The data can be displayed in the Firebug Console or in the
+ * "Server" request tab.
+ *
+ * For more information see: http://www.firephp.org/
+ *
+ * @copyright Copyright (C) 2007-2008 Christoph Dorn
+ * @author Christoph Dorn <christoph@christophdorn.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * @package FirePHP
+ */
+class FirePHP {
+
+ /**
+ * FirePHP version
+ *
+ * @var string
+ */
+ const VERSION = '0.2.0';
+
+ /**
+ * Firebug LOG level
+ *
+ * Logs a message to firebug console.
+ *
+ * @var string
+ */
+ const LOG = 'LOG';
+
+ /**
+ * Firebug INFO level
+ *
+ * Logs a message to firebug console and displays an info icon before the message.
+ *
+ * @var string
+ */
+ const INFO = 'INFO';
+
+ /**
+ * Firebug WARN level
+ *
+ * Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise.
+ *
+ * @var string
+ */
+ const WARN = 'WARN';
+
+ /**
+ * Firebug ERROR level
+ *
+ * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count.
+ *
+ * @var string
+ */
+ const ERROR = 'ERROR';
+
+ /**
+ * Dumps a variable to firebug's server panel
+ *
+ * @var string
+ */
+ const DUMP = 'DUMP';
+
+ /**
+ * Displays a stack trace in firebug console
+ *
+ * @var string
+ */
+ const TRACE = 'TRACE';
+
+ /**
+ * Displays an exception in firebug console
+ *
+ * Increments the firebug error count.
+ *
+ * @var string
+ */
+ const EXCEPTION = 'EXCEPTION';
+
+ /**
+ * Displays an table in firebug console
+ *
+ * @var string
+ */
+ const TABLE = 'TABLE';
+
+ /**
+ * Starts a group in firebug console
+ *
+ * @var string
+ */
+ const GROUP_START = 'GROUP_START';
+
+ /**
+ * Ends a group in firebug console
+ *
+ * @var string
+ */
+ const GROUP_END = 'GROUP_END';
+
+ /**
+ * Singleton instance of FirePHP
+ *
+ * @var FirePHP
+ */
+ protected static $instance = null;
+
+ /**
+ * Wildfire protocol message index
+ *
+ * @var int
+ */
+ protected $messageIndex = 1;
+
+ /**
+ * Options for the library
+ *
+ * @var array
+ */
+ protected $options = array();
+
+ /**
+ * Filters used to exclude object members when encoding
+ *
+ * @var array
+ */
+ protected $objectFilters = array();
+
+ /**
+ * A stack of objects used to detect recursion during object encoding
+ *
+ * @var object
+ */
+ protected $objectStack = array();
+
+ /**
+ * Flag to enable/disable logging
+ *
+ * @var boolean
+ */
+ protected $enabled = true;
+
+ /**
+ * The object constructor
+ */
+ function __construct() {
+ $this->options['maxObjectDepth'] = 10;
+ $this->options['maxArrayDepth'] = 20;
+ $this->options['useNativeJsonEncode'] = true;
+ $this->options['includeLineNumbers'] = true;
+ }
+
+ /**
+ * When the object gets serialized only include specific object members.
+ *
+ * @return array
+ */
+ public function __sleep() {
+ return array('options','objectFilters','enabled');
+ }
+
+ /**
+ * Gets singleton instance of FirePHP
+ *
+ * @param boolean $AutoCreate
+ * @return FirePHP
+ */
+ public static function getInstance($AutoCreate=false) {
+ if($AutoCreate===true && !self::$instance) {
+ self::init();
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Creates FirePHP object and stores it for singleton access
+ *
+ * @return FirePHP
+ */
+ public static function init() {
+ return self::$instance = new self();
+ }
+
+ /**
+ * Enable and disable logging to Firebug
+ *
+ * @param boolean $Enabled TRUE to enable, FALSE to disable
+ * @return void
+ */
+ public function setEnabled($Enabled) {
+ $this->enabled = $Enabled;
+ }
+
+ /**
+ * Check if logging is enabled
+ *
+ * @return boolean TRUE if enabled
+ */
+ public function getEnabled() {
+ return $this->enabled;
+ }
+
+ /**
+ * Specify a filter to be used when encoding an object
+ *
+ * Filters are used to exclude object members.
+ *
+ * @param string $Class The class name of the object
+ * @param array $Filter An array or members to exclude
+ * @return void
+ */
+ public function setObjectFilter($Class, $Filter) {
+ $this->objectFilters[$Class] = $Filter;
+ }
+
+ /**
+ * Set some options for the library
+ *
+ * Options:
+ * - maxObjectDepth: The maximum depth to traverse objects (default: 10)
+ * - maxArrayDepth: The maximum depth to traverse arrays (default: 20)
+ * - useNativeJsonEncode: If true will use json_encode() (default: true)
+ * - includeLineNumbers: If true will include line numbers and filenames (default: true)
+ *
+ * @param array $Options The options to be set
+ * @return void
+ */
+ public function setOptions($Options) {
+ $this->options = array_merge($this->options,$Options);
+ }
+
+ /**
+ * Register FirePHP as your error handler
+ *
+ * Will throw exceptions for each php error.
+ */
+ public function registerErrorHandler()
+ {
+ //NOTE: The following errors will not be caught by this error handler:
+ // E_ERROR, E_PARSE, E_CORE_ERROR,
+ // E_CORE_WARNING, E_COMPILE_ERROR,
+ // E_COMPILE_WARNING, E_STRICT
+
+ set_error_handler(array($this,'errorHandler'));
+ }
+
+ /**
+ * FirePHP's error handler
+ *
+ * Throws exception for each php error that will occur.
+ *
+ * @param int $errno
+ * @param string $errstr
+ * @param string $errfile
+ * @param int $errline
+ * @param array $errcontext
+ */
+ public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
+ {
+ // Don't throw exception if error reporting is switched off
+ if (error_reporting() == 0) {
+ return;
+ }
+ // Only throw exceptions for errors we are asking for
+ if (error_reporting() & $errno) {
+ throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
+ }
+ }
+
+ /**
+ * Register FirePHP as your exception handler
+ */
+ public function registerExceptionHandler()
+ {
+ set_exception_handler(array($this,'exceptionHandler'));
+ }
+
+ /**
+ * FirePHP's exception handler
+ *
+ * Logs all exceptions to your firebug console and then stops the script.
+ *
+ * @param Exception $Exception
+ * @throws Exception
+ */
+ function exceptionHandler($Exception) {
+ $this->fb($Exception);
+ }
+
+ /**
+ * Set custom processor url for FirePHP
+ *
+ * @param string $URL
+ */
+ public function setProcessorUrl($URL)
+ {
+ $this->setHeader('X-FirePHP-ProcessorURL', $URL);
+ }
+
+ /**
+ * Set custom renderer url for FirePHP
+ *
+ * @param string $URL
+ */
+ public function setRendererUrl($URL)
+ {
+ $this->setHeader('X-FirePHP-RendererURL', $URL);
+ }
+
+ /**
+ * Start a group for following messages
+ *
+ * @param string $Name
+ * @return true
+ * @throws Exception
+ */
+ public function group($Name) {
+ return $this->fb(null, $Name, FirePHP::GROUP_START);
+ }
+
+ /**
+ * Ends a group you have started before
+ *
+ * @return true
+ * @throws Exception
+ */
+ public function groupEnd() {
+ return $this->fb(null, null, FirePHP::GROUP_END);
+ }
+
+ /**
+ * Log object with label to firebug console
+ *
+ * @see FirePHP::LOG
+ * @param mixes $Object
+ * @param string $Label
+ * @return true
+ * @throws Exception
+ */
+ public function log($Object, $Label=null) {
+ return $this->fb($Object, $Label, FirePHP::LOG);
+ }
+
+ /**
+ * Log object with label to firebug console
+ *
+ * @see FirePHP::INFO
+ * @param mixes $Object
+ * @param string $Label
+ * @return true
+ * @throws Exception
+ */
+ public function info($Object, $Label=null) {
+ return $this->fb($Object, $Label, FirePHP::INFO);
+ }
+
+ /**
+ * Log object with label to firebug console
+ *
+ * @see FirePHP::WARN
+ * @param mixes $Object
+ * @param string $Label
+ * @return true
+ * @throws Exception
+ */
+ public function warn($Object, $Label=null) {
+ return $this->fb($Object, $Label, FirePHP::WARN);
+ }
+
+ /**
+ * Log object with label to firebug console
+ *
+ * @see FirePHP::ERROR
+ * @param mixes $Object
+ * @param string $Label
+ * @return true
+ * @throws Exception
+ */
+ public function error($Object, $Label=null) {
+ return $this->fb($Object, $Label, FirePHP::ERROR);
+ }
+
+ /**
+ * Dumps key and variable to firebug server panel
+ *
+ * @see FirePHP::DUMP
+ * @param string $Key
+ * @param mixed $Variable
+ * @return true
+ * @throws Exception
+ */
+ public function dump($Key, $Variable) {
+ return $this->fb($Variable, $Key, FirePHP::DUMP);
+ }
+
+ /**
+ * Log a trace in the firebug console
+ *
+ * @see FirePHP::TRACE
+ * @param string $Label
+ * @return true
+ * @throws Exception
+ */
+ public function trace($Label) {
+ return $this->fb($Label, FirePHP::TRACE);
+ }
+
+ /**
+ * Log a table in the firebug console
+ *
+ * @see FirePHP::TABLE
+ * @param string $Label
+ * @param string $Table
+ * @return true
+ * @throws Exception
+ */
+ public function table($Label, $Table) {
+ return $this->fb($Table, $Label, FirePHP::TABLE);
+ }
+
+ /**
+ * Check if FirePHP is installed on client
+ *
+ * @return boolean
+ */
+ public function detectClientExtension() {
+ /* Check if FirePHP is installed on client */
+ if(!@preg_match_all('/\sFirePHP\/([\.|\d]*)\s?/si',$this->getUserAgent(),$m) ||
+ !version_compare($m[1][0],'0.0.6','>=')) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Log varible to Firebug
+ *
+ * @see http://www.firephp.org/Wiki/Reference/Fb
+ * @param mixed $Object The variable to be logged
+ * @return true Return TRUE if message was added to headers, FALSE otherwise
+ * @throws Exception
+ */
+ public function fb($Object) {
+
+ if(!$this->enabled) {
+ return false;
+ }
+
+ if (headers_sent($filename, $linenum)) {
+ throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.');
+ }
+
+ $Type = null;
+ $Label = null;
+
+ if(func_num_args()==1) {
+ } else
+ if(func_num_args()==2) {
+ switch(func_get_arg(1)) {
+ case self::LOG:
+ case self::INFO:
+ case self::WARN:
+ case self::ERROR:
+ case self::DUMP:
+ case self::TRACE:
+ case self::EXCEPTION:
+ case self::TABLE:
+ case self::GROUP_START:
+ case self::GROUP_END:
+ $Type = func_get_arg(1);
+ break;
+ default:
+ $Label = func_get_arg(1);
+ break;
+ }
+ } else
+ if(func_num_args()==3) {
+ $Type = func_get_arg(2);
+ $Label = func_get_arg(1);
+ } else {
+ throw $this->newException('Wrong number of arguments to fb() function!');
+ }
+
+
+ if(!$this->detectClientExtension()) {
+ return false;
+ }
+
+ $meta = array();
+ $skipFinalObjectEncode = false;
+
+ if($Object instanceof Exception) {
+
+ $meta['file'] = $this->_escapeTraceFile($Object->getFile());
+ $meta['line'] = $Object->getLine();
+
+ $trace = $Object->getTrace();
+ if($Object instanceof ErrorException
+ && isset($trace[0]['function'])
+ && $trace[0]['function']=='errorHandler'
+ && isset($trace[0]['class'])
+ && $trace[0]['class']=='FirePHP') {
+
+ $severity = false;
+ switch($Object->getSeverity()) {
+ case E_WARNING: $severity = 'E_WARNING'; break;
+ case E_NOTICE: $severity = 'E_NOTICE'; break;
+ case E_USER_ERROR: $severity = 'E_USER_ERROR'; break;
+ case E_USER_WARNING: $severity = 'E_USER_WARNING'; break;
+ case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break;
+ case E_STRICT: $severity = 'E_STRICT'; break;
+ case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break;
+ case E_DEPRECATED: $severity = 'E_DEPRECATED'; break;
+ case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break;
+ }
+
+ $Object = array('Class'=>get_class($Object),
+ 'Message'=>$severity.': '.$Object->getMessage(),
+ 'File'=>$this->_escapeTraceFile($Object->getFile()),
+ 'Line'=>$Object->getLine(),
+ 'Type'=>'trigger',
+ 'Trace'=>$this->_escapeTrace(array_splice($trace,2)));
+ $skipFinalObjectEncode = true;
+ } else {
+ $Object = array('Class'=>get_class($Object),
+ 'Message'=>$Object->getMessage(),
+ 'File'=>$this->_escapeTraceFile($Object->getFile()),
+ 'Line'=>$Object->getLine(),
+ 'Type'=>'throw',
+ 'Trace'=>$this->_escapeTrace($trace));
+ $skipFinalObjectEncode = true;
+ }
+ $Type = self::EXCEPTION;
+
+ } else
+ if($Type==self::TRACE) {
+
+ $trace = debug_backtrace();
+ if(!$trace) return false;
+ for( $i=0 ; $i<sizeof($trace) ; $i++ ) {
+
+ if(isset($trace[$i]['class'])
+ && isset($trace[$i]['file'])
+ && ($trace[$i]['class']=='FirePHP'
+ || $trace[$i]['class']=='FB')
+ && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php'
+ || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) {
+ /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */
+ } else
+ if(isset($trace[$i]['class'])
+ && isset($trace[$i+1]['file'])
+ && $trace[$i]['class']=='FirePHP'
+ && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') {
+ /* Skip fb() */
+ } else
+ if($trace[$i]['function']=='fb'
+ || $trace[$i]['function']=='trace'
+ || $trace[$i]['function']=='send') {
+ $Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'',
+ 'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'',
+ 'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'',
+ 'Message'=>$trace[$i]['args'][0],
+ 'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'',
+ 'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'',
+ 'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'',
+ 'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1)));
+
+ $skipFinalObjectEncode = true;
+ $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'';
+ $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:'';
+ break;
+ }
+ }
+
+ } else
+ if($Type==self::TABLE) {
+
+ if(isset($Object[0]) && is_string($Object[0])) {
+ $Object[1] = $this->encodeTable($Object[1]);
+ } else {
+ $Object = $this->encodeTable($Object);
+ }
+
+ $skipFinalObjectEncode = true;
+
+ } else {
+ if($Type===null) {
+ $Type = self::LOG;
+ }
+ }
+
+ if($this->options['includeLineNumbers']) {
+ if(!isset($meta['file']) || !isset($meta['line'])) {
+
+ $trace = debug_backtrace();
+ for( $i=0 ; $trace && $i<sizeof($trace) ; $i++ ) {
+
+ if(isset($trace[$i]['class'])
+ && isset($trace[$i]['file'])
+ && ($trace[$i]['class']=='FirePHP'
+ || $trace[$i]['class']=='FB')
+ && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php'
+ || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) {
+ /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */
+ } else
+ if(isset($trace[$i]['class'])
+ && isset($trace[$i+1]['file'])
+ && $trace[$i]['class']=='FirePHP'
+ && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') {
+ /* Skip fb() */
+ } else
+ if(isset($trace[$i]['file'])
+ && substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') {
+ /* Skip FB::fb() */
+ } else {
+ $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'';
+ $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:'';
+ break;
+ }
+ }
+
+ }
+ } else {
+ unset($meta['file']);
+ unset($meta['line']);
+ }
+
+ $this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
+ $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::VERSION);
+
+ $structure_index = 1;
+ if($Type==self::DUMP) {
+ $structure_index = 2;
+ $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1');
+ } else {
+ $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
+ }
+
+ if($Type==self::DUMP) {
+ $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}';
+ } else {
+ $msg_meta = array('Type'=>$Type);
+ if($Label!==null) {
+ $msg_meta['Label'] = $Label;
+ }
+ if(isset($meta['file'])) {
+ $msg_meta['File'] = $meta['file'];
+ }
+ if(isset($meta['line'])) {
+ $msg_meta['Line'] = $meta['line'];
+ }
+ $msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']';
+ }
+
+ $parts = explode("\n",chunk_split($msg, 5000, "\n"));
+
+ for( $i=0 ; $i<count($parts) ; $i++) {
+
+ $part = $parts[$i];
+ if ($part) {
+
+ if(count($parts)>2) {
+ // Message needs to be split into multiple parts
+ $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex,
+ (($i==0)?strlen($msg):'')
+ . '|' . $part . '|'
+ . (($i<count($parts)-2)?'\\':''));
+ } else {
+ $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex,
+ strlen($part) . '|' . $part . '|');
+ }
+
+ $this->messageIndex++;
+
+ if ($this->messageIndex > 99999) {
+ throw new Exception('Maximum number (99,999) of messages reached!');
+ }
+ }
+ }
+
+ $this->setHeader('X-Wf-1-Index',$this->messageIndex-1);
+
+ return true;
+ }
+
+ /**
+ * Standardizes path for windows systems.
+ *
+ * @param string $Path
+ * @return string
+ */
+ protected function _standardizePath($Path) {
+ return preg_replace('/\\\\+/','/',$Path);
+ }
+
+ /**
+ * Escape trace path for windows systems
+ *
+ * @param array $Trace
+ * @return array
+ */
+ protected function _escapeTrace($Trace) {
+ if(!$Trace) return $Trace;
+ for( $i=0 ; $i<sizeof($Trace) ; $i++ ) {
+ if(isset($Trace[$i]['file'])) {
+ $Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']);
+ }
+ if(isset($Trace[$i]['args'])) {
+ $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']);
+ }
+ }
+ return $Trace;
+ }
+
+ /**
+ * Escape file information of trace for windows systems
+ *
+ * @param string $File
+ * @return string
+ */
+ protected function _escapeTraceFile($File) {
+ /* Check if we have a windows filepath */
+ if(strpos($File,'\\')) {
+ /* First strip down to single \ */
+
+ $file = preg_replace('/\\\\+/','\\',$File);
+
+ return $file;
+ }
+ return $File;
+ }
+
+ /**
+ * Send header
+ *
+ * @param string $Name
+ * @param string_type $Value
+ */
+ protected function setHeader($Name, $Value) {
+ return header($Name.': '.$Value);
+ }
+
+ /**
+ * Get user agent
+ *
+ * @return string|false
+ */
+ protected function getUserAgent() {
+ if(!isset($_SERVER['HTTP_USER_AGENT'])) return false;
+ return $_SERVER['HTTP_USER_AGENT'];
+ }
+
+ /**
+ * Returns a new exception
+ *
+ * @param string $Message
+ * @return Exception
+ */
+ protected function newException($Message) {
+ return new Exception($Message);
+ }
+
+ /**
+ * Encode an object into a JSON string
+ *
+ * Uses PHP's jeson_encode() if available
+ *
+ * @param object $Object The object to be encoded
+ * @return string The JSON string
+ */
+ protected function jsonEncode($Object, $skipObjectEncode=false)
+ {
+ if(!$skipObjectEncode) {
+ $Object = $this->encodeObject($Object);
+ }
+
+ if(function_exists('json_encode')
+ && $this->options['useNativeJsonEncode']!=false) {
+
+ return json_encode($Object);
+ } else {
+ return $this->json_encode($Object);
+ }
+ }
+
+ /**
+ * Encodes a table by encoding each row and column with encodeObject()
+ *
+ * @param array $Table The table to be encoded
+ * @return array
+ */
+ protected function encodeTable($Table) {
+ if(!$Table) return $Table;
+ for( $i=0 ; $i<count($Table) ; $i++ ) {
+ if(is_array($Table[$i])) {
+ for( $j=0 ; $j<count($Table[$i]) ; $j++ ) {
+ $Table[$i][$j] = $this->encodeObject($Table[$i][$j]);
+ }
+ }
+ }
+ return $Table;
+ }
+
+ /**
+ * Encodes an object including members with
+ * protected and private visibility
+ *
+ * @param Object $Object The object to be encoded
+ * @param int $Depth The current traversal depth
+ * @return array All members of the object
+ */
+ protected function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1)
+ {
+ $return = array();
+
+ if (is_object($Object)) {
+
+ if ($ObjectDepth > $this->options['maxObjectDepth']) {
+ return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **';
+ }
+
+ foreach ($this->objectStack as $refVal) {
+ if ($refVal === $Object) {
+ return '** Recursion ('.get_class($Object).') **';
+ }
+ }
+ array_push($this->objectStack, $Object);
+
+ $return['__className'] = $class = get_class($Object);
+
+ $reflectionClass = new ReflectionClass($class);
+ $properties = array();
+ foreach( $reflectionClass->getProperties() as $property) {
+ $properties[$property->getName()] = $property;
+ }
+
+ $members = (array)$Object;
+
+ foreach( $properties as $raw_name => $property ) {
+
+ $name = $raw_name;
+ if($property->isStatic()) {
+ $name = 'static:'.$name;
+ }
+ if($property->isPublic()) {
+ $name = 'public:'.$name;
+ } else
+ if($property->isPrivate()) {
+ $name = 'private:'.$name;
+ $raw_name = "\0".$class."\0".$raw_name;
+ } else
+ if($property->isProtected()) {
+ $name = 'protected:'.$name;
+ $raw_name = "\0".'*'."\0".$raw_name;
+ }
+
+ if(!(isset($this->objectFilters[$class])
+ && is_array($this->objectFilters[$class])
+ && in_array($raw_name,$this->objectFilters[$class]))) {
+
+ if(array_key_exists($raw_name,$members)
+ && !$property->isStatic()) {
+
+ $return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1);
+
+ } else {
+ if(method_exists($property,'setAccessible')) {
+ $property->setAccessible(true);
+ $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1);
+ } else
+ if($property->isPublic()) {
+ $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1);
+ } else {
+ $return[$name] = '** Need PHP 5.3 to get value **';
+ }
+ }
+ } else {
+ $return[$name] = '** Excluded by Filter **';
+ }
+ }
+
+ // Include all members that are not defined in the class
+ // but exist in the object
+ foreach( $members as $raw_name => $value ) {
+
+ $name = $raw_name;
+
+ if ($name{0} == "\0") {
+ $parts = explode("\0", $name);
+ $name = $parts[2];
+ }
+
+ if(!isset($properties[$name])) {
+ $name = 'undeclared:'.$name;
+
+ if(!(isset($this->objectFilters[$class])
+ && is_array($this->objectFilters[$class])
+ && in_array($raw_name,$this->objectFilters[$class]))) {
+
+ $return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1);
+ } else {
+ $return[$name] = '** Excluded by Filter **';
+ }
+ }
+ }
+
+ array_pop($this->objectStack);
+
+ } elseif (is_array($Object)) {
+
+ if ($ArrayDepth > $this->options['maxArrayDepth']) {
+ return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **';
+ }
+
+ foreach ($Object as $key => $val) {
+
+ // Encoding the $GLOBALS PHP array causes an infinite loop
+ // if the recursion is not reset here as it contains
+ // a reference to itself. This is the only way I have come up
+ // with to stop infinite recursion in this case.
+ if($key=='GLOBALS'
+ && is_array($val)
+ && array_key_exists('GLOBALS',$val)) {
+ $val['GLOBALS'] = '** Recursion (GLOBALS) **';
+ }
+
+ $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1);
+ }
+ } else {
+ if(self::is_utf8($Object)) {
+ return $Object;
+ } else {
+ return utf8_encode($Object);
+ }
+ }
+ return $return;
+ }
+
+ /**
+ * Returns true if $string is valid UTF-8 and false otherwise.
+ *
+ * @param mixed $str String to be tested
+ * @return boolean
+ */
+ protected static function is_utf8($str) {
+ $c=0; $b=0;
+ $bits=0;
+ $len=strlen($str);
+ for($i=0; $i<$len; $i++){
+ $c=ord($str[$i]);
+ if($c > 128){
+ if(($c >= 254)) return false;
+ elseif($c >= 252) $bits=6;
+ elseif($c >= 248) $bits=5;
+ elseif($c >= 240) $bits=4;
+ elseif($c >= 224) $bits=3;
+ elseif($c >= 192) $bits=2;
+ else return false;
+ if(($i+$bits) > $len) return false;
+ while($bits > 1){
+ $i++;
+ $b=ord($str[$i]);
+ if($b < 128 || $b > 191) return false;
+ $bits--;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Converts to and from JSON format.
+ *
+ * JSON (JavaScript Object Notation) is a lightweight data-interchange
+ * format. It is easy for humans to read and write. It is easy for machines
+ * to parse and generate. It is based on a subset of the JavaScript
+ * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
+ * This feature can also be found in Python. JSON is a text format that is
+ * completely language independent but uses conventions that are familiar
+ * to programmers of the C-family of languages, including C, C++, C#, Java,
+ * JavaScript, Perl, TCL, and many others. These properties make JSON an
+ * ideal data-interchange language.
+ *
+ * This package provides a simple encoder and decoder for JSON notation. It
+ * is intended for use with client-side Javascript applications that make
+ * use of HTTPRequest to perform server communication functions - data can
+ * be encoded into JSON notation for use in a client-side javascript, or
+ * decoded from incoming Javascript requests. JSON format is native to
+ * Javascript, and can be directly eval()'ed with no further parsing
+ * overhead
+ *
+ * All strings should be in ASCII or UTF-8 format!
+ *
+ * LICENSE: Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met: Redistributions of source code must retain the
+ * above copyright notice, this list of conditions and the following
+ * disclaimer. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * @category
+ * @package Services_JSON
+ * @author Michal Migurski <mike-json@teczno.com>
+ * @author Matt Knapp <mdknapp[at]gmail[dot]com>
+ * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
+ * @author Christoph Dorn <christoph@christophdorn.com>
+ * @copyright 2005 Michal Migurski
+ * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
+ */
+
+
+ /**
+ * Keep a list of objects as we descend into the array so we can detect recursion.
+ */
+ private $json_objectStack = array();
+
+
+ /**
+ * convert a string from one UTF-8 char to one UTF-16 char
+ *
+ * Normally should be handled by mb_convert_encoding, but
+ * provides a slower PHP-only method for installations
+ * that lack the multibye string extension.
+ *
+ * @param string $utf8 UTF-8 character
+ * @return string UTF-16 character
+ * @access private
+ */
+ private function json_utf82utf16($utf8)
+ {
+ // oh please oh please oh please oh please oh please
+ if(function_exists('mb_convert_encoding')) {
+ return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
+ }
+
+ switch(strlen($utf8)) {
+ case 1:
+ // this case should never be reached, because we are in ASCII range
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ return $utf8;
+
+ case 2:
+ // return a UTF-16 character from a 2-byte UTF-8 char
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ return chr(0x07 & (ord($utf8{0}) >> 2))
+ . chr((0xC0 & (ord($utf8{0}) << 6))
+ | (0x3F & ord($utf8{1})));
+
+ case 3:
+ // return a UTF-16 character from a 3-byte UTF-8 char
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ return chr((0xF0 & (ord($utf8{0}) << 4))
+ | (0x0F & (ord($utf8{1}) >> 2)))
+ . chr((0xC0 & (ord($utf8{1}) << 6))
+ | (0x7F & ord($utf8{2})));
+ }
+
+ // ignoring UTF-32 for now, sorry
+ return '';
+ }
+
+ /**
+ * encodes an arbitrary variable into JSON format
+ *
+ * @param mixed $var any number, boolean, string, array, or object to be encoded.
+ * see argument 1 to Services_JSON() above for array-parsing behavior.
+ * if var is a strng, note that encode() always expects it
+ * to be in ASCII or UTF-8 format!
+ *
+ * @return mixed JSON string representation of input var or an error if a problem occurs
+ * @access public
+ */
+ private function json_encode($var)
+ {
+
+ if(is_object($var)) {
+ if(in_array($var,$this->json_objectStack)) {
+ return '"** Recursion **"';
+ }
+ }
+
+ switch (gettype($var)) {
+ case 'boolean':
+ return $var ? 'true' : 'false';
+
+ case 'NULL':
+ return 'null';
+
+ case 'integer':
+ return (int) $var;
+
+ case 'double':
+ case 'float':
+ return (float) $var;
+
+ case 'string':
+ // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
+ $ascii = '';
+ $strlen_var = strlen($var);
+
+ /*
+ * Iterate over every character in the string,
+ * escaping with a slash or encoding to UTF-8 where necessary
+ */
+ for ($c = 0; $c < $strlen_var; ++$c) {
+
+ $ord_var_c = ord($var{$c});
+
+ switch (true) {
+ case $ord_var_c == 0x08:
+ $ascii .= '\b';
+ break;
+ case $ord_var_c == 0x09:
+ $ascii .= '\t';
+ break;
+ case $ord_var_c == 0x0A:
+ $ascii .= '\n';
+ break;
+ case $ord_var_c == 0x0C:
+ $ascii .= '\f';
+ break;
+ case $ord_var_c == 0x0D:
+ $ascii .= '\r';
+ break;
+
+ case $ord_var_c == 0x22:
+ case $ord_var_c == 0x2F:
+ case $ord_var_c == 0x5C:
+ // double quote, slash, slosh
+ $ascii .= '\\'.$var{$c};
+ break;
+
+ case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
+ // characters U-00000000 - U-0000007F (same as ASCII)
+ $ascii .= $var{$c};
+ break;
+
+ case (($ord_var_c & 0xE0) == 0xC0):
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
+ $c += 1;
+ $utf16 = $this->json_utf82utf16($char);
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
+ break;
+
+ case (($ord_var_c & 0xF0) == 0xE0):
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $char = pack('C*', $ord_var_c,
+ ord($var{$c + 1}),
+ ord($var{$c + 2}));
+ $c += 2;
+ $utf16 = $this->json_utf82utf16($char);
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
+ break;
+
+ case (($ord_var_c & 0xF8) == 0xF0):
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $char = pack('C*', $ord_var_c,
+ ord($var{$c + 1}),
+ ord($var{$c + 2}),
+ ord($var{$c + 3}));
+ $c += 3;
+ $utf16 = $this->json_utf82utf16($char);
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
+ break;
+
+ case (($ord_var_c & 0xFC) == 0xF8):
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $char = pack('C*', $ord_var_c,
+ ord($var{$c + 1}),
+ ord($var{$c + 2}),
+ ord($var{$c + 3}),
+ ord($var{$c + 4}));
+ $c += 4;
+ $utf16 = $this->json_utf82utf16($char);
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
+ break;
+
+ case (($ord_var_c & 0xFE) == 0xFC):
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $char = pack('C*', $ord_var_c,
+ ord($var{$c + 1}),
+ ord($var{$c + 2}),
+ ord($var{$c + 3}),
+ ord($var{$c + 4}),
+ ord($var{$c + 5}));
+ $c += 5;
+ $utf16 = $this->json_utf82utf16($char);
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
+ break;
+ }
+ }
+
+ return '"'.$ascii.'"';
+
+ case 'array':
+ /*
+ * As per JSON spec if any array key is not an integer
+ * we must treat the the whole array as an object. We
+ * also try to catch a sparsely populated associative
+ * array with numeric keys here because some JS engines
+ * will create an array with empty indexes up to
+ * max_index which can cause memory issues and because
+ * the keys, which may be relevant, will be remapped
+ * otherwise.
+ *
+ * As per the ECMA and JSON specification an object may
+ * have any string as a property. Unfortunately due to
+ * a hole in the ECMA specification if the key is a
+ * ECMA reserved word or starts with a digit the
+ * parameter is only accessible using ECMAScript's
+ * bracket notation.
+ */
+
+ // treat as a JSON object
+ if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
+
+ $this->json_objectStack[] = $var;
+
+ $properties = array_map(array($this, 'json_name_value'),
+ array_keys($var),
+ array_values($var));
+
+ array_pop($this->json_objectStack);
+
+ foreach($properties as $property) {
+ if($property instanceof Exception) {
+ return $property;
+ }
+ }
+
+ return '{' . join(',', $properties) . '}';
+ }
+
+ $this->json_objectStack[] = $var;
+
+ // treat it like a regular array
+ $elements = array_map(array($this, 'json_encode'), $var);
+
+ array_pop($this->json_objectStack);
+
+ foreach($elements as $element) {
+ if($element instanceof Exception) {
+ return $element;
+ }
+ }
+
+ return '[' . join(',', $elements) . ']';
+
+ case 'object':
+ $vars = self::encodeObject($var);
+
+ $this->json_objectStack[] = $var;
+
+ $properties = array_map(array($this, 'json_name_value'),
+ array_keys($vars),
+ array_values($vars));
+
+ array_pop($this->json_objectStack);
+
+ foreach($properties as $property) {
+ if($property instanceof Exception) {
+ return $property;
+ }
+ }
+
+ return '{' . join(',', $properties) . '}';
+
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * array-walking function for use in generating JSON-formatted name-value pairs
+ *
+ * @param string $name name of key to use
+ * @param mixed $value reference to an array element to be encoded
+ *
+ * @return string JSON-formatted name-value pair, like '"name":value'
+ * @access private
+ */
+ private function json_name_value($name, $value)
+ {
+ // Encoding the $GLOBALS PHP array causes an infinite loop
+ // if the recursion is not reset here as it contains
+ // a reference to itself. This is the only way I have come up
+ // with to stop infinite recursion in this case.
+ if($name=='GLOBALS'
+ && is_array($value)
+ && array_key_exists('GLOBALS',$value)) {
+ $value['GLOBALS'] = '** Recursion **';
+ }
+
+ $encoded_value = $this->json_encode($value);
+
+ if($encoded_value instanceof Exception) {
+ return $encoded_value;
+ }
+
+ return $this->json_encode(strval($name)) . ':' . $encoded_value;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class HTTP_ConditionalGet
+ * @package Minify
+ * @subpackage HTTP
+ */
+
+/**
+ * Implement conditional GET via a timestamp or hash of content
+ *
+ * E.g. Content from DB with update time:
+ * <code>
+ * list($updateTime, $content) = getDbUpdateAndContent();
+ * $cg = new HTTP_ConditionalGet(array(
+ * 'lastModifiedTime' => $updateTime
+ * ,'isPublic' => true
+ * ));
+ * $cg->sendHeaders();
+ * if ($cg->cacheIsValid) {
+ * exit();
+ * }
+ * echo $content;
+ * </code>
+ *
+ * E.g. Shortcut for the above
+ * <code>
+ * HTTP_ConditionalGet::check($updateTime, true); // exits if client has cache
+ * echo $content;
+ * </code>
+ *
+ * E.g. Content from DB with no update time:
+ * <code>
+ * $content = getContentFromDB();
+ * $cg = new HTTP_ConditionalGet(array(
+ * 'contentHash' => md5($content)
+ * ));
+ * $cg->sendHeaders();
+ * if ($cg->cacheIsValid) {
+ * exit();
+ * }
+ * echo $content;
+ * </code>
+ *
+ * E.g. Static content with some static includes:
+ * <code>
+ * // 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();
+ * }
+ * </code>
+ * @package Minify
+ * @subpackage HTTP
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class HTTP_ConditionalGet {
+
+ /**
+ * Does the client have a valid copy of the requested resource?
+ *
+ * You'll want to check this after instantiating the object. If true, do
+ * not send content, just call sendHeaders() if you haven't already.
+ *
+ * @var bool
+ */
+ public $cacheIsValid = null;
+
+ /**
+ * @param array $spec options
+ *
+ * 'isPublic': (bool) if true, the Cache-Control header will contain
+ * "public", allowing proxies to cache the content. Otherwise "private" will
+ * be sent, allowing only browser caching. (default false)
+ *
+ * 'lastModifiedTime': (int) if given, both ETag AND Last-Modified headers
+ * will be sent with content. This is recommended.
+ *
+ * 'encoding': (string) if set, the header "Vary: Accept-Encoding" will
+ * always be sent and a truncated version of the encoding will be appended
+ * to the ETag. E.g. "pub123456;gz". This will also trigger a more lenient
+ * checking of the client's If-None-Match header, as the encoding portion of
+ * the ETag will be stripped before comparison.
+ *
+ * 'contentHash': (string) if given, only the ETag header can be sent with
+ * content (only HTTP1.1 clients can conditionally GET). The given string
+ * should be short with no quote characters and always change when the
+ * resource changes (recommend md5()). This is not needed/used if
+ * lastModifiedTime is given.
+ *
+ * 'eTag': (string) if given, this will be used as the ETag header rather
+ * than values based on lastModifiedTime or contentHash. Also the encoding
+ * string will not be appended to the given value as described above.
+ *
+ * 'invalidate': (bool) if true, the client cache will be considered invalid
+ * without testing. Effectively this disables conditional GET.
+ * (default false)
+ *
+ * 'maxAge': (int) if given, this will set the Cache-Control max-age in
+ * seconds, and also set the Expires header to the equivalent GMT date.
+ * After the max-age period has passed, the browser will again send a
+ * conditional GET to revalidate its cache.
+ *
+ * @return null
+ */
+ public function __construct($spec)
+ {
+ $scope = (isset($spec['isPublic']) && $spec['isPublic'])
+ ? 'public'
+ : 'private';
+ $maxAge = 0;
+ // backwards compatibility (can be removed later)
+ if (isset($spec['setExpires'])
+ && is_numeric($spec['setExpires'])
+ && ! isset($spec['maxAge'])) {
+ $spec['maxAge'] = $spec['setExpires'] - $_SERVER['REQUEST_TIME'];
+ }
+ if (isset($spec['maxAge'])) {
+ $maxAge = $spec['maxAge'];
+ $this->_headers['Expires'] = self::gmtDate(
+ $_SERVER['REQUEST_TIME'] + $spec['maxAge']
+ );
+ }
+ $etagAppend = '';
+ if (isset($spec['encoding'])) {
+ $this->_stripEtag = true;
+ $this->_headers['Vary'] = 'Accept-Encoding';
+ if ('' !== $spec['encoding']) {
+ if (0 === strpos($spec['encoding'], 'x-')) {
+ $spec['encoding'] = substr($spec['encoding'], 2);
+ }
+ $etagAppend = ';' . substr($spec['encoding'], 0, 2);
+ }
+ }
+ if (isset($spec['lastModifiedTime'])) {
+ $this->_setLastModified($spec['lastModifiedTime']);
+ if (isset($spec['eTag'])) { // Use it
+ $this->_setEtag($spec['eTag'], $scope);
+ } else { // base both headers on time
+ $this->_setEtag($spec['lastModifiedTime'] . $etagAppend, $scope);
+ }
+ } elseif (isset($spec['eTag'])) { // Use it
+ $this->_setEtag($spec['eTag'], $scope);
+ } elseif (isset($spec['contentHash'])) { // Use the hash as the ETag
+ $this->_setEtag($spec['contentHash'] . $etagAppend, $scope);
+ }
+ $this->_headers['Cache-Control'] = "max-age={$maxAge}, {$scope}";
+ // invalidate cache if disabled, otherwise check
+ $this->cacheIsValid = (isset($spec['invalidate']) && $spec['invalidate'])
+ ? false
+ : $this->_isCacheValid();
+ }
+
+ /**
+ * Get array of output headers to be sent
+ *
+ * In the case of 304 responses, this array will only contain the response
+ * code header: array('_responseCode' => 'HTTP/1.0 304 Not Modified')
+ *
+ * Otherwise something like:
+ * <code>
+ * array(
+ * 'Cache-Control' => 'max-age=0, public'
+ * ,'ETag' => '"foobar"'
+ * )
+ * </code>
+ *
+ * @return array
+ */
+ public function getHeaders()
+ {
+ return $this->_headers;
+ }
+
+ /**
+ * Set the Content-Length header in bytes
+ *
+ * With most PHP configs, as long as you don't flush() output, this method
+ * is not needed and PHP will buffer all output and set Content-Length for
+ * you. Otherwise you'll want to call this to let the client know up front.
+ *
+ * @param int $bytes
+ *
+ * @return int copy of input $bytes
+ */
+ public function setContentLength($bytes)
+ {
+ return $this->_headers['Content-Length'] = $bytes;
+ }
+
+ /**
+ * Send headers
+ *
+ * @see getHeaders()
+ *
+ * Note this doesn't "clear" the headers. Calling sendHeaders() will
+ * call header() again (but probably have not effect) and getHeaders() will
+ * still return the headers.
+ *
+ * @return null
+ */
+ public function sendHeaders()
+ {
+ $headers = $this->_headers;
+ if (array_key_exists('_responseCode', $headers)) {
+ header($headers['_responseCode']);
+ unset($headers['_responseCode']);
+ }
+ foreach ($headers as $name => $val) {
+ header($name . ': ' . $val);
+ }
+ }
+
+ /**
+ * Exit if the client's cache is valid for this resource
+ *
+ * This is a convenience method for common use of the class
+ *
+ * @param int $lastModifiedTime if given, both ETag AND Last-Modified headers
+ * will be sent with content. This is recommended.
+ *
+ * @param bool $isPublic (default false) if true, the Cache-Control header
+ * will contain "public", allowing proxies to cache the content. Otherwise
+ * "private" will be sent, allowing only browser caching.
+ *
+ * @param array $options (default empty) additional options for constructor
+ *
+ * @return null
+ */
+ public static function check($lastModifiedTime = null, $isPublic = false, $options = array())
+ {
+ if (null !== $lastModifiedTime) {
+ $options['lastModifiedTime'] = (int)$lastModifiedTime;
+ }
+ $options['isPublic'] = (bool)$isPublic;
+ $cg = new HTTP_ConditionalGet($options);
+ $cg->sendHeaders();
+ if ($cg->cacheIsValid) {
+ exit();
+ }
+ }
+
+
+ /**
+ * Get a GMT formatted date for use in HTTP headers
+ *
+ * <code>
+ * header('Expires: ' . HTTP_ConditionalGet::gmtdate($time));
+ * </code>
+ *
+ * @param int $time unix timestamp
+ *
+ * @return string
+ */
+ public static function gmtDate($time)
+ {
+ return gmdate('D, d M Y H:i:s \G\M\T', $time);
+ }
+
+ protected $_headers = array();
+ protected $_lmTime = null;
+ protected $_etag = null;
+ protected $_stripEtag = false;
+
+ protected function _setEtag($hash, $scope)
+ {
+ $this->_etag = '"' . substr($scope, 0, 3) . $hash . '"';
+ $this->_headers['ETag'] = $this->_etag;
+ }
+
+ protected function _setLastModified($time)
+ {
+ $this->_lmTime = (int)$time;
+ $this->_headers['Last-Modified'] = self::gmtDate($time);
+ }
+
+ /**
+ * Determine validity of client cache and queue 304 header if valid
+ */
+ protected function _isCacheValid()
+ {
+ if (null === $this->_etag) {
+ // lmTime is copied to ETag, so this condition implies that the
+ // server sent neither ETag nor Last-Modified, so the client can't
+ // possibly has a valid cache.
+ return false;
+ }
+ $isValid = ($this->resourceMatchedEtag() || $this->resourceNotModified());
+ if ($isValid) {
+ $this->_headers['_responseCode'] = 'HTTP/1.0 304 Not Modified';
+ }
+ return $isValid;
+ }
+
+ protected function resourceMatchedEtag()
+ {
+ if (!isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
+ return false;
+ }
+ $clientEtagList = get_magic_quotes_gpc()
+ ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])
+ : $_SERVER['HTTP_IF_NONE_MATCH'];
+ $clientEtags = explode(',', $clientEtagList);
+
+ $compareTo = $this->normalizeEtag($this->_etag);
+ foreach ($clientEtags as $clientEtag) {
+ if ($this->normalizeEtag($clientEtag) === $compareTo) {
+ // respond with the client's matched ETag, even if it's not what
+ // we would've sent by default
+ $this->_headers['ETag'] = trim($clientEtag);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected function normalizeEtag($etag) {
+ $etag = trim($etag);
+ return $this->_stripEtag
+ ? preg_replace('/;\\w\\w"$/', '"', $etag)
+ : $etag;
+ }
+
+ protected function resourceNotModified()
+ {
+ if (!isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+ return false;
+ }
+ $ifModifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
+ if (false !== ($semicolon = strrpos($ifModifiedSince, ';'))) {
+ // IE has tacked on extra data to this header, strip it
+ $ifModifiedSince = substr($ifModifiedSince, 0, $semicolon);
+ }
+ if ($ifModifiedSince == self::gmtDate($this->_lmTime)) {
+ // Apache 2.2's behavior. If there was no ETag match, send the
+ // non-encoded version of the ETag value.
+ $this->_headers['ETag'] = $this->normalizeEtag($this->_etag);
+ return true;
+ }
+ return false;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class HTTP_Encoder
+ * @package Minify
+ * @subpackage 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.
+ *
+ * <code>
+ * // Send a CSS file, compressed if possible
+ * $he = new HTTP_Encoder(array(
+ * 'content' => file_get_contents($cssFile)
+ * ,'type' => 'text/css'
+ * ));
+ * $he->encode();
+ * $he->sendAll();
+ * </code>
+ *
+ * <code>
+ * // Shortcut to encoding output
+ * header('Content-Type: text/css'); // needed if not HTML
+ * HTTP_Encoder::output($css);
+ * </code>
+ *
+ * <code>
+ * // Just sniff for the accepted encoding
+ * $encoding = HTTP_Encoder::getAcceptedEncoding();
+ * </code>
+ *
+ * For more control over headers, use getHeaders() and getData() and send your
+ * own output.\r
+ * \r
+ * Note: If you don't need header mgmt, use PHP's native gzencode, gzdeflate, \r
+ * and gzcompress functions for gzip, deflate, and compress-encoding\r
+ * respectively.\r
+ *
+ * @package Minify
+ * @subpackage HTTP
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class HTTP_Encoder {
+
+ /**
+ * Should the encoder allow HTTP encoding to IE6?
+ *
+ * If you have many IE6 users and the bandwidth savings is worth troubling
+ * some of them, set this to true.
+ *
+ * By default, encoding is only offered to IE7+. When this is true,
+ * getAcceptedEncoding() will return an encoding for IE6 if its user agent
+ * string contains "SV1". This has been documented in many places as "safe",
+ * but there seem to be remaining, intermittent encoding bugs in patched
+ * IE6 on the wild web.
+ *
+ * @var bool
+ */
+ public static $encodeToIe6 = false;
+
+
+ /**
+ * Default compression level for zlib operations
+ *
+ * This level is used if encode() is not given a $compressionLevel
+ *
+ * @var int
+ */
+ public static $compressionLevel = 6;
+
+
+ /**
+ * Get an HTTP Encoder object
+ *
+ * @param array $spec options
+ *
+ * 'content': (string required) content to be encoded
+ *
+ * 'type': (string) if set, the Content-Type header will have this value.
+ *
+ * 'method: (string) only set this if you are forcing a particular encoding
+ * method. If not set, the best method will be chosen by getAcceptedEncoding()
+ * The available methods are 'gzip', 'deflate', 'compress', and '' (no
+ * encoding)
+ *
+ * @return null
+ */
+ public function __construct($spec) \r
+ {
+ $this->_content = $spec['content'];
+ $this->_headers['Content-Length'] = (string)strlen($this->_content);
+ if (isset($spec['type'])) {
+ $this->_headers['Content-Type'] = $spec['type'];
+ }
+ if (isset($spec['method'])
+ && in_array($spec['method'], array('gzip', 'deflate', 'compress', '')))
+ {
+ $this->_encodeMethod = array($spec['method'], $spec['method']);
+ } else {
+ $this->_encodeMethod = self::getAcceptedEncoding();
+ }
+ }
+
+ /**
+ * Get content in current form
+ *
+ * Call after encode() for encoded content.
+ *
+ * return string
+ */
+ public function getContent() \r
+ {
+ return $this->_content;
+ }
+
+ /**
+ * Get array of output headers to be sent
+ *
+ * E.g.
+ * <code>
+ * array(
+ * 'Content-Length' => '615'
+ * ,'Content-Encoding' => 'x-gzip'
+ * ,'Vary' => 'Accept-Encoding'
+ * )
+ * </code>
+ *
+ * @return array
+ */
+ public function getHeaders()\r
+ {
+ return $this->_headers;
+ }
+
+ /**
+ * Send output headers
+ *
+ * You must call this before headers are sent and it probably cannot be
+ * used in conjunction with zlib output buffering / mod_gzip. Errors are
+ * not handled purposefully.
+ *
+ * @see getHeaders()
+ *
+ * @return null
+ */
+ public function sendHeaders()\r
+ {
+ foreach ($this->_headers as $name => $val) {
+ header($name . ': ' . $val);
+ }
+ }
+
+ /**
+ * Send output headers and content
+ *
+ * A shortcut for sendHeaders() and echo getContent()
+ *
+ * You must call this before headers are sent and it probably cannot be
+ * used in conjunction with zlib output buffering / mod_gzip. Errors are
+ * not handled purposefully.
+ *
+ * @return null
+ */
+ public function sendAll()\r
+ {
+ $this->sendHeaders();
+ echo $this->_content;
+ }
+
+ /**
+ * Determine the client's best encoding method from the HTTP Accept-Encoding
+ * header.
+ *
+ * If no Accept-Encoding header is set, or the browser is IE before v6 SP2,
+ * this will return ('', ''), the "identity" encoding.
+ *
+ * A syntax-aware scan is done of the Accept-Encoding, so the method must
+ * be non 0. The methods are favored in order of gzip, deflate, then
+ * compress. Deflate is always smallest and generally faster, but is
+ * rarely sent by servers, so client support could be buggier.
+ * \r
+ * @param bool $allowCompress allow the older compress encoding
+ *
+ * @param bool $allowDeflate allow the more recent deflate encoding\r
+ *
+ * @return array two values, 1st is the actual encoding method, 2nd is the
+ * alias of that method to use in the Content-Encoding header (some browsers
+ * call gzip "x-gzip" etc.)
+ */
+ public static function getAcceptedEncoding($allowCompress = true, $allowDeflate = true)\r
+ {
+ // @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
+
+ if (! isset($_SERVER['HTTP_ACCEPT_ENCODING'])
+ || self::_isBuggyIe())
+ {
+ return array('', '');
+ }
+ $ae = $_SERVER['HTTP_ACCEPT_ENCODING'];
+ // gzip checks (quick)
+ if (0 === strpos($ae, 'gzip,') // most browsers
+ || 0 === strpos($ae, 'deflate, gzip,') // opera
+ ) {
+ return array('gzip', 'gzip');
+ }
+ // gzip checks (slow)
+ if (preg_match(
+ '@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
+ ,$ae
+ ,$m)) {
+ return array('gzip', $m[1]);
+ }
+ if ($allowDeflate) {
+ // deflate checks
+ $aeRev = strrev($ae);
+ if (0 === strpos($aeRev, 'etalfed ,') // ie, webkit
+ || 0 === strpos($aeRev, 'etalfed,') // gecko
+ || 0 === strpos($ae, 'deflate,') // opera
+ // slow parsing
+ || preg_match(
+ '@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae)) {
+ return array('deflate', 'deflate');
+ }
+ }
+ if ($allowCompress && preg_match(
+ '@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
+ ,$ae
+ ,$m)) {
+ return array('compress', $m[1]);
+ }
+ return array('', '');
+ }
+
+ /**
+ * Encode (compress) the content
+ *
+ * If the encode method is '' (none) or compression level is 0, or the 'zlib'
+ * extension isn't loaded, we return false.
+ *
+ * Then the appropriate gz_* function is called to compress the content. If
+ * this fails, false is returned.
+ *
+ * The header "Vary: Accept-Encoding" is added. If encoding is successful,
+ * the Content-Length header is updated, and Content-Encoding is also added.\r
+ * \r
+ * @param int $compressionLevel given to zlib functions. If not given, the
+ * class default will be used.
+ *
+ * @return bool success true if the content was actually compressed
+ */
+ public function encode($compressionLevel = null)\r
+ {
+ $this->_headers['Vary'] = 'Accept-Encoding';
+ if (null === $compressionLevel) {
+ $compressionLevel = self::$compressionLevel;
+ }
+ if ('' === $this->_encodeMethod[0]
+ || ($compressionLevel == 0)
+ || !extension_loaded('zlib'))
+ {
+ return false;
+ }\r
+ if ($this->_encodeMethod[0] === 'deflate') {\r
+ $encoded = gzdeflate($this->_content, $compressionLevel);\r
+ } elseif ($this->_encodeMethod[0] === 'gzip') {
+ $encoded = gzencode($this->_content, $compressionLevel);
+ } else {
+ $encoded = gzcompress($this->_content, $compressionLevel);
+ }
+ if (false === $encoded) {
+ return false;
+ }
+ $this->_headers['Content-Length'] = strlen($encoded);
+ $this->_headers['Content-Encoding'] = $this->_encodeMethod[1];
+ $this->_content = $encoded;
+ return true;
+ }
+
+ /**
+ * Encode and send appropriate headers and content
+ *
+ * This is a convenience method for common use of the class
+ *
+ * @param string $content
+ * \r
+ * @param int $compressionLevel given to zlib functions. If not given, the
+ * class default will be used.
+ *
+ * @return bool success true if the content was actually compressed
+ */
+ public static function output($content, $compressionLevel = null)
+ {
+ if (null === $compressionLevel) {
+ $compressionLevel = self::$compressionLevel;
+ }
+ $he = new HTTP_Encoder(array('content' => $content));\r
+ $ret = $he->encode($compressionLevel);\r
+ $he->sendAll();
+ return $ret;
+ }\r
+ \r
+ protected $_content = '';
+ protected $_headers = array();
+ protected $_encodeMethod = array('', '');
+
+ /**
+ * Is the browser an IE version earlier than 6 SP2?
+ */
+ protected static function _isBuggyIe()
+ {
+ $ua = $_SERVER['HTTP_USER_AGENT'];
+ // quick escape for non-IEs
+ if (0 !== strpos($ua, 'Mozilla/4.0 (compatible; MSIE ')
+ || false !== strpos($ua, 'Opera')) {
+ return false;
+ }
+ // no regex = faaast
+ $version = (float)substr($ua, 30);
+ return self::$encodeToIe6
+ ? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1')))
+ : ($version < 7);
+ }
+}
--- /dev/null
+<?php
+/**
+ * jsmin.php - PHP implementation of Douglas Crockford's JSMin.
+ *
+ * This is a direct port of jsmin.c to PHP with a few PHP performance tweaks and
+ * modifications to preserve some comments (see below). Also, rather than using
+ * stdin/stdout, JSMin::minify() accepts a string as input and returns another
+ * string as output.
+ *
+ * Comments containing IE conditional compilation are preserved, as are multi-line
+ * comments that begin with "/*!" (for documentation purposes). In the latter case
+ * newlines are inserted around the comment to enhance readability.
+ *
+ * PHP 5 or higher is required.
+ *
+ * Permission is hereby granted to use this version of the library under the
+ * same terms as jsmin.c, which has the following license:
+ *
+ * --
+ * Copyright (c) 2002 Douglas Crockford (www.crockford.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * The Software shall be used for Good, not Evil.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * --
+ *
+ * @package JSMin
+ * @author Ryan Grove <ryan@wonko.com> (PHP port)
+ * @author Steve Clay <steve@mrclay.org> (modifications + cleanup)
+ * @author Andrea Giammarchi <http://www.3site.eu> (spaceBeforeRegExp)
+ * @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
+ * @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
+ * @license http://opensource.org/licenses/mit-license.php MIT License
+ * @link http://code.google.com/p/jsmin-php/
+ */
+
+class JSMin {
+ const ORD_LF = 10;
+ const ORD_SPACE = 32;
+ const ACTION_KEEP_A = 1;
+ const ACTION_DELETE_A = 2;
+ const ACTION_DELETE_A_B = 3;
+
+ protected $a = "\n";
+ protected $b = '';
+ protected $input = '';
+ protected $inputIndex = 0;
+ protected $inputLength = 0;
+ protected $lookAhead = null;
+ protected $output = '';
+
+ /**
+ * Minify Javascript
+ *
+ * @param string $js Javascript to be minified
+ * @return string
+ */
+ public static function minify($js)
+ {
+ $jsmin = new JSMin($js);
+ return $jsmin->min();
+ }
+
+ /**
+ * Setup process
+ */
+ public function __construct($input)
+ {
+ $this->input = str_replace("\r\n", "\n", $input);
+ $this->inputLength = strlen($this->input);
+ }
+
+ /**
+ * Perform minification, return result
+ */
+ public function min()
+ {
+ if ($this->output !== '') { // min already run
+ return $this->output;
+ }
+ $this->action(self::ACTION_DELETE_A_B);
+
+ while ($this->a !== null) {
+ // determine next command
+ $command = self::ACTION_KEEP_A; // default
+ if ($this->a === ' ') {
+ if (! $this->isAlphaNum($this->b)) {
+ $command = self::ACTION_DELETE_A;
+ }
+ } elseif ($this->a === "\n") {
+ if ($this->b === ' ') {
+ $command = self::ACTION_DELETE_A_B;
+ } elseif (false === strpos('{[(+-', $this->b)
+ && ! $this->isAlphaNum($this->b)) {
+ $command = self::ACTION_DELETE_A;
+ }
+ } elseif (! $this->isAlphaNum($this->a)) {
+ if ($this->b === ' '
+ || ($this->b === "\n"
+ && (false === strpos('}])+-"\'', $this->a)))) {
+ $command = self::ACTION_DELETE_A_B;
+ }
+ }
+ $this->action($command);
+ }
+ $this->output = trim($this->output);
+ return $this->output;
+ }
+
+ /**
+ * ACTION_KEEP_A = Output A. Copy B to A. Get the next B.
+ * ACTION_DELETE_A = Copy B to A. Get the next B.
+ * ACTION_DELETE_A_B = Get the next B.
+ */
+ protected function action($command)
+ {
+ switch ($command) {
+ case self::ACTION_KEEP_A:
+ $this->output .= $this->a;
+ // fallthrough
+ case self::ACTION_DELETE_A:
+ $this->a = $this->b;
+ if ($this->a === "'" || $this->a === '"') { // string literal
+ $str = $this->a; // in case needed for exception
+ while (true) {
+ $this->output .= $this->a;
+ $this->a = $this->get();
+ if ($this->a === $this->b) { // end quote
+ break;
+ }
+ if (ord($this->a) <= self::ORD_LF) {
+ throw new JSMin_UnterminatedStringException(
+ 'Unterminated String: ' . var_export($str, true));
+ }
+ $str .= $this->a;
+ if ($this->a === '\\') {
+ $this->output .= $this->a;
+ $this->a = $this->get();
+ $str .= $this->a;
+ }
+ }
+ }
+ // fallthrough
+ case self::ACTION_DELETE_A_B:
+ $this->b = $this->next();
+ if ($this->b === '/' && $this->isRegexpLiteral()) { // RegExp literal
+ $this->output .= $this->a . $this->b;
+ $pattern = '/'; // in case needed for exception
+ while (true) {
+ $this->a = $this->get();
+ $pattern .= $this->a;
+ if ($this->a === '/') { // end pattern
+ break; // while (true)
+ } elseif ($this->a === '\\') {
+ $this->output .= $this->a;
+ $this->a = $this->get();
+ $pattern .= $this->a;
+ } elseif (ord($this->a) <= self::ORD_LF) {
+ throw new JSMin_UnterminatedRegExpException(
+ 'Unterminated RegExp: '. var_export($pattern, true));
+ }
+ $this->output .= $this->a;
+ }
+ $this->b = $this->next();
+ }
+ // end case ACTION_DELETE_A_B
+ }
+ }
+
+ protected function isRegexpLiteral()
+ {
+ if (false !== strpos("\n{;(,=:[!&|?", $this->a)) { // we aren't dividing
+ return true;
+ }
+ if (' ' === $this->a) {
+ $length = strlen($this->output);
+ if ($length < 2) { // weird edge case
+ return true;
+ }
+ // you can't divide a keyword
+ if (preg_match('/(?:case|else|in|return|typeof)$/', $this->output, $m)) {
+ if ($this->output === $m[0]) { // odd but could happen
+ return true;
+ }
+ // make sure it's a keyword, not end of an identifier
+ $charBeforeKeyword = substr($this->output, $length - strlen($m[0]) - 1, 1);
+ if (! $this->isAlphaNum($charBeforeKeyword)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get next char. Convert ctrl char to space.
+ */
+ protected function get()
+ {
+ $c = $this->lookAhead;
+ $this->lookAhead = null;
+ if ($c === null) {
+ if ($this->inputIndex < $this->inputLength) {
+ $c = $this->input[$this->inputIndex];
+ $this->inputIndex += 1;
+ } else {
+ return null;
+ }
+ }
+ if ($c === "\r" || $c === "\n") {
+ return "\n";
+ }
+ if (ord($c) < self::ORD_SPACE) { // control char
+ return ' ';
+ }
+ return $c;
+ }
+
+ /**
+ * Get next char. If is ctrl character, translate to a space or newline.
+ */
+ protected function peek()
+ {
+ $this->lookAhead = $this->get();
+ return $this->lookAhead;
+ }
+
+ /**
+ * Is $c a letter, digit, underscore, dollar sign, escape, or non-ASCII?
+ */
+ protected function isAlphaNum($c)
+ {
+ return (preg_match('/^[0-9a-zA-Z_\\$\\\\]$/', $c) || ord($c) > 126);
+ }
+
+ protected function singleLineComment()
+ {
+ $comment = '';
+ while (true) {
+ $get = $this->get();
+ $comment .= $get;
+ if (ord($get) <= self::ORD_LF) { // EOL reached
+ // if IE conditional comment
+ if (preg_match('/^\\/@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
+ return "/{$comment}";
+ }
+ return $get;
+ }
+ }
+ }
+
+ protected function multipleLineComment()
+ {
+ $this->get();
+ $comment = '';
+ while (true) {
+ $get = $this->get();
+ if ($get === '*') {
+ if ($this->peek() === '/') { // end of comment reached
+ $this->get();
+ // if comment preserved by YUI Compressor
+ if (0 === strpos($comment, '!')) {
+ return "\n/*" . substr($comment, 1) . "*/\n";
+ }
+ // if IE conditional comment
+ if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
+ return "/*{$comment}*/";
+ }
+ return ' ';
+ }
+ } elseif ($get === null) {
+ throw new JSMin_UnterminatedCommentException('Unterminated Comment: ' . var_export('/*' . $comment, true));
+ }
+ $comment .= $get;
+ }
+ }
+
+ /**
+ * Get the next character, skipping over comments.
+ * Some comments may be preserved.
+ */
+ protected function next()
+ {
+ $get = $this->get();
+ if ($get !== '/') {
+ return $get;
+ }
+ switch ($this->peek()) {
+ case '/': return $this->singleLineComment();
+ case '*': return $this->multipleLineComment();
+ default: return $get;
+ }
+ }
+}
+
+class JSMin_UnterminatedStringException extends Exception {}
+class JSMin_UnterminatedCommentException extends Exception {}
+class JSMin_UnterminatedRegExpException extends Exception {}
--- /dev/null
+<?php
+
+/**
+ * JSMinPlus version 1.1
+ *
+ * Minifies a javascript file using a javascript parser
+ *
+ * This implements a PHP port of Brendan Eich's Narcissus open source javascript engine (in javascript)
+ * References: http://en.wikipedia.org/wiki/Narcissus_(JavaScript_engine)
+ * Narcissus sourcecode: http://mxr.mozilla.org/mozilla/source/js/narcissus/
+ * JSMinPlus weblog: http://crisp.tweakblogs.net/blog/cat/716
+ *
+ * Tino Zijdel <crisp@tweakers.net>
+ *
+ * Usage: $minified = JSMinPlus::minify($script [, $filename])
+ *
+ * Versionlog (see also changelog.txt):
+ * 12-04-2009 - some small bugfixes and performance improvements
+ * 09-04-2009 - initial open sourced version 1.0
+ *
+ * Latest version of this script: http://files.tweakers.net/jsminplus/jsminplus.zip
+ *
+ */
+
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Narcissus JavaScript engine.
+ *
+ * The Initial Developer of the Original Code is
+ * Brendan Eich <brendan@mozilla.org>.
+ * Portions created by the Initial Developer are Copyright (C) 2004
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Tino Zijdel <crisp@tweakers.net>
+ * PHP port, modifications and minifier routine are (C) 2009
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define('TOKEN_END', 1);
+define('TOKEN_NUMBER', 2);
+define('TOKEN_IDENTIFIER', 3);
+define('TOKEN_STRING', 4);
+define('TOKEN_REGEXP', 5);
+define('TOKEN_NEWLINE', 6);
+define('TOKEN_CONDCOMMENT_MULTILINE', 7);
+
+define('JS_SCRIPT', 100);
+define('JS_BLOCK', 101);
+define('JS_LABEL', 102);
+define('JS_FOR_IN', 103);
+define('JS_CALL', 104);
+define('JS_NEW_WITH_ARGS', 105);
+define('JS_INDEX', 106);
+define('JS_ARRAY_INIT', 107);
+define('JS_OBJECT_INIT', 108);
+define('JS_PROPERTY_INIT', 109);
+define('JS_GETTER', 110);
+define('JS_SETTER', 111);
+define('JS_GROUP', 112);
+define('JS_LIST', 113);
+
+define('DECLARED_FORM', 0);
+define('EXPRESSED_FORM', 1);
+define('STATEMENT_FORM', 2);
+
+class JSMinPlus
+{
+ private $parser;
+ private $reserved = array(
+ 'break', 'case', 'catch', 'continue', 'default', 'delete', 'do',
+ 'else', 'finally', 'for', 'function', 'if', 'in', 'instanceof',
+ 'new', 'return', 'switch', 'this', 'throw', 'try', 'typeof', 'var',
+ 'void', 'while', 'with',
+ // Words reserved for future use
+ 'abstract', 'boolean', 'byte', 'char', 'class', 'const', 'debugger',
+ 'double', 'enum', 'export', 'extends', 'final', 'float', 'goto',
+ 'implements', 'import', 'int', 'interface', 'long', 'native',
+ 'package', 'private', 'protected', 'public', 'short', 'static',
+ 'super', 'synchronized', 'throws', 'transient', 'volatile',
+ // These are not reserved, but should be taken into account
+ // in isValidIdentifier (See jslint source code)
+ 'arguments', 'eval', 'true', 'false', 'Infinity', 'NaN', 'null', 'undefined'
+ );
+
+ private function __construct()
+ {
+ $this->parser = new JSParser();
+ }
+
+ public static function minify($js, $filename='')
+ {
+ static $instance;
+
+ // this is a singleton
+ if(!$instance)
+ $instance = new JSMinPlus();
+
+ return $instance->min($js, $filename);
+ }
+
+ private function min($js, $filename)
+ {
+ try
+ {
+ $n = $this->parser->parse($js, $filename, 1);
+ return $this->parseTree($n);
+ }
+ catch(Exception $e)
+ {
+ echo $e->getMessage() . "\n";
+ }
+
+ return false;
+ }
+
+ private function parseTree($n, $noBlockGrouping = false)
+ {
+ $s = '';
+
+ switch ($n->type)
+ {
+ case KEYWORD_FUNCTION:
+ $s .= 'function' . ($n->name ? ' ' . $n->name : '') . '(';
+ $params = $n->params;
+ for ($i = 0, $j = count($params); $i < $j; $i++)
+ $s .= ($i ? ',' : '') . $params[$i];
+ $s .= '){' . $this->parseTree($n->body, true) . '}';
+ break;
+
+ case JS_SCRIPT:
+ // we do nothing with funDecls or varDecls
+ $noBlockGrouping = true;
+ // fall through
+ case JS_BLOCK:
+ $childs = $n->treeNodes;
+ for ($c = 0, $i = 0, $j = count($childs); $i < $j; $i++)
+ {
+ $t = $this->parseTree($childs[$i]);
+ if (strlen($t))
+ {
+ if ($c)
+ {
+ if ($childs[$i]->type == KEYWORD_FUNCTION && $childs[$i]->functionForm == DECLARED_FORM)
+ $s .= "\n"; // put declared functions on a new line
+ else
+ $s .= ';';
+ }
+
+ $s .= $t;
+
+ $c++;
+ }
+ }
+
+ if ($c > 1 && !$noBlockGrouping)
+ {
+ $s = '{' . $s . '}';
+ }
+ break;
+
+ case KEYWORD_IF:
+ $s = 'if(' . $this->parseTree($n->condition) . ')';
+ $thenPart = $this->parseTree($n->thenPart);
+ $elsePart = $n->elsePart ? $this->parseTree($n->elsePart) : null;
+
+ // quite a rancid hack to see if we should enclose the thenpart in brackets
+ if ($thenPart[0] != '{')
+ {
+ if (strpos($thenPart, 'if(') !== false)
+ $thenPart = '{' . $thenPart . '}';
+ elseif ($elsePart)
+ $thenPart .= ';';
+ }
+
+ $s .= $thenPart;
+
+ if ($elsePart)
+ {
+ $s .= 'else';
+
+ if ($elsePart[0] != '{')
+ $s .= ' ';
+
+ $s .= $elsePart;
+ }
+ break;
+
+ case KEYWORD_SWITCH:
+ $s = 'switch(' . $this->parseTree($n->discriminant) . '){';
+ $cases = $n->cases;
+ for ($i = 0, $j = count($cases); $i < $j; $i++)
+ {
+ $case = $cases[$i];
+ if ($case->type == KEYWORD_CASE)
+ $s .= 'case' . ($case->caseLabel->type != TOKEN_STRING ? ' ' : '') . $this->parseTree($case->caseLabel) . ':';
+ else
+ $s .= 'default:';
+
+ $statement = $this->parseTree($case->statements);
+ if ($statement)
+ $s .= $statement . ';';
+ }
+ $s = rtrim($s, ';') . '}';
+ break;
+
+ case KEYWORD_FOR:
+ $s = 'for(' . ($n->setup ? $this->parseTree($n->setup) : '')
+ . ';' . ($n->condition ? $this->parseTree($n->condition) : '')
+ . ';' . ($n->update ? $this->parseTree($n->update) : '') . ')'
+ . $this->parseTree($n->body);
+ break;
+
+ case KEYWORD_WHILE:
+ $s = 'while(' . $this->parseTree($n->condition) . ')' . $this->parseTree($n->body);
+ break;
+
+ case JS_FOR_IN:
+ $s = 'for(' . ($n->varDecl ? $this->parseTree($n->varDecl) : $this->parseTree($n->iterator)) . ' in ' . $this->parseTree($n->object) . ')' . $this->parseTree($n->body);
+ break;
+
+ case KEYWORD_DO:
+ $s = 'do{' . $this->parseTree($n->body, true) . '}while(' . $this->parseTree($n->condition) . ')';
+ break;
+
+ case KEYWORD_BREAK:
+ case KEYWORD_CONTINUE:
+ $s = $n->value . ($n->label ? ' ' . $n->label : '');
+ break;
+
+ case KEYWORD_TRY:
+ $s = 'try{' . $this->parseTree($n->tryBlock, true) . '}';
+ $catchClauses = $n->catchClauses;
+ for ($i = 0, $j = count($catchClauses); $i < $j; $i++)
+ {
+ $t = $catchClauses[$i];
+ $s .= 'catch(' . $t->varName . ($t->guard ? ' if ' . $this->parseTree($t->guard) : '') . '){' . $this->parseTree($t->block, true) . '}';
+ }
+ if ($n->finallyBlock)
+ $s .= 'finally{' . $this->parseTree($n->finallyBlock, true) . '}';
+ break;
+
+ case KEYWORD_THROW:
+ $s = 'throw ' . $this->parseTree($n->exception);
+ break;
+
+ case KEYWORD_RETURN:
+ $s = 'return' . ($n->value ? ' ' . $this->parseTree($n->value) : '');
+ break;
+
+ case KEYWORD_WITH:
+ $s = 'with(' . $this->parseTree($n->object) . ')' . $this->parseTree($n->body);
+ break;
+
+ case KEYWORD_VAR:
+ case KEYWORD_CONST:
+ $s = $n->value . ' ';
+ $childs = $n->treeNodes;
+ for ($i = 0, $j = count($childs); $i < $j; $i++)
+ {
+ $t = $childs[$i];
+ $s .= ($i ? ',' : '') . $t->name;
+ $u = $t->initializer;
+ if ($u)
+ $s .= '=' . $this->parseTree($u);
+ }
+ break;
+
+ case KEYWORD_DEBUGGER:
+ throw new Exception('NOT IMPLEMENTED: DEBUGGER');
+ break;
+
+ case TOKEN_CONDCOMMENT_MULTILINE:
+ $s = $n->value . ' ';
+ $childs = $n->treeNodes;
+ for ($i = 0, $j = count($childs); $i < $j; $i++)
+ $s .= $this->parseTree($childs[$i]);
+ break;
+
+ case OP_SEMICOLON:
+ if ($expression = $n->expression)
+ $s = $this->parseTree($expression);
+ break;
+
+ case JS_LABEL:
+ $s = $n->label . ':' . $this->parseTree($n->statement);
+ break;
+
+ case OP_COMMA:
+ $childs = $n->treeNodes;
+ for ($i = 0, $j = count($childs); $i < $j; $i++)
+ $s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
+ break;
+
+ case OP_ASSIGN:
+ $s = $this->parseTree($n->treeNodes[0]) . $n->value . $this->parseTree($n->treeNodes[1]);
+ break;
+
+ case OP_HOOK:
+ $s = $this->parseTree($n->treeNodes[0]) . '?' . $this->parseTree($n->treeNodes[1]) . ':' . $this->parseTree($n->treeNodes[2]);
+ break;
+
+ case OP_OR: case OP_AND:
+ case OP_BITWISE_OR: case OP_BITWISE_XOR: case OP_BITWISE_AND:
+ case OP_EQ: case OP_NE: case OP_STRICT_EQ: case OP_STRICT_NE:
+ case OP_LT: case OP_LE: case OP_GE: case OP_GT:
+ case OP_LSH: case OP_RSH: case OP_URSH:
+ case OP_MUL: case OP_DIV: case OP_MOD:
+ $s = $this->parseTree($n->treeNodes[0]) . $n->type . $this->parseTree($n->treeNodes[1]);
+ break;
+
+ case OP_PLUS:
+ case OP_MINUS:
+ $s = $this->parseTree($n->treeNodes[0]) . $n->type;
+ $nextTokenType = $n->treeNodes[1]->type;
+ if ( $nextTokenType == OP_PLUS || $nextTokenType == OP_MINUS ||
+ $nextTokenType == OP_INCREMENT || $nextTokenType == OP_DECREMENT ||
+ $nextTokenType == OP_UNARY_PLUS || $nextTokenType == OP_UNARY_MINUS
+ )
+ $s .= ' ';
+ $s .= $this->parseTree($n->treeNodes[1]);
+ break;
+
+ case KEYWORD_IN:
+ $s = $this->parseTree($n->treeNodes[0]) . ' in ' . $this->parseTree($n->treeNodes[1]);
+ break;
+
+ case KEYWORD_INSTANCEOF:
+ $s = $this->parseTree($n->treeNodes[0]) . ' instanceof ' . $this->parseTree($n->treeNodes[1]);
+ break;
+
+ case KEYWORD_DELETE:
+ $s = 'delete ' . $this->parseTree($n->treeNodes[0]);
+ break;
+
+ case KEYWORD_VOID:
+ $s = 'void(' . $this->parseTree($n->treeNodes[0]) . ')';
+ break;
+
+ case KEYWORD_TYPEOF:
+ $s = 'typeof ' . $this->parseTree($n->treeNodes[0]);
+ break;
+
+ case OP_NOT:
+ case OP_BITWISE_NOT:
+ case OP_UNARY_PLUS:
+ case OP_UNARY_MINUS:
+ $s = $n->value . $this->parseTree($n->treeNodes[0]);
+ break;
+
+ case OP_INCREMENT:
+ case OP_DECREMENT:
+ if ($n->postfix)
+ $s = $this->parseTree($n->treeNodes[0]) . $n->value;
+ else
+ $s = $n->value . $this->parseTree($n->treeNodes[0]);
+ break;
+
+ case OP_DOT:
+ $s = $this->parseTree($n->treeNodes[0]) . '.' . $this->parseTree($n->treeNodes[1]);
+ break;
+
+ case JS_INDEX:
+ $s = $this->parseTree($n->treeNodes[0]);
+ // See if we can replace named index with a dot saving 3 bytes
+ if ( $n->treeNodes[0]->type == TOKEN_IDENTIFIER &&
+ $n->treeNodes[1]->type == TOKEN_STRING &&
+ $this->isValidIdentifier(substr($n->treeNodes[1]->value, 1, -1))
+ )
+ $s .= '.' . substr($n->treeNodes[1]->value, 1, -1);
+ else
+ $s .= '[' . $this->parseTree($n->treeNodes[1]) . ']';
+ break;
+
+ case JS_LIST:
+ $childs = $n->treeNodes;
+ for ($i = 0, $j = count($childs); $i < $j; $i++)
+ $s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
+ break;
+
+ case JS_CALL:
+ $s = $this->parseTree($n->treeNodes[0]) . '(' . $this->parseTree($n->treeNodes[1]) . ')';
+ break;
+
+ case KEYWORD_NEW:
+ case JS_NEW_WITH_ARGS:
+ $s = 'new ' . $this->parseTree($n->treeNodes[0]) . '(' . ($n->type == JS_NEW_WITH_ARGS ? $this->parseTree($n->treeNodes[1]) : '') . ')';
+ break;
+
+ case JS_ARRAY_INIT:
+ $s = '[';
+ $childs = $n->treeNodes;
+ for ($i = 0, $j = count($childs); $i < $j; $i++)
+ {
+ $s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
+ }
+ $s .= ']';
+ break;
+
+ case JS_OBJECT_INIT:
+ $s = '{';
+ $childs = $n->treeNodes;
+ for ($i = 0, $j = count($childs); $i < $j; $i++)
+ {
+ $t = $childs[$i];
+ if ($i)
+ $s .= ',';
+ if ($t->type == JS_PROPERTY_INIT)
+ {
+ // Ditch the quotes when the index is a valid identifier
+ if ( $t->treeNodes[0]->type == TOKEN_STRING &&
+ $this->isValidIdentifier(substr($t->treeNodes[0]->value, 1, -1))
+ )
+ $s .= substr($t->treeNodes[0]->value, 1, -1);
+ else
+ $s .= $t->treeNodes[0]->value;
+
+ $s .= ':' . $this->parseTree($t->treeNodes[1]);
+ }
+ else
+ {
+ $s .= $t->type == JS_GETTER ? 'get' : 'set';
+ $s .= ' ' . $t->name . '(';
+ $params = $t->params;
+ for ($i = 0, $j = count($params); $i < $j; $i++)
+ $s .= ($i ? ',' : '') . $params[$i];
+ $s .= '){' . $this->parseTree($t->body, true) . '}';
+ }
+ }
+ $s .= '}';
+ break;
+
+ case KEYWORD_NULL: case KEYWORD_THIS: case KEYWORD_TRUE: case KEYWORD_FALSE:
+ case TOKEN_IDENTIFIER: case TOKEN_NUMBER: case TOKEN_STRING: case TOKEN_REGEXP:
+ $s = $n->value;
+ break;
+
+ case JS_GROUP:
+ $s = '(' . $this->parseTree($n->treeNodes[0]) . ')';
+ break;
+
+ default:
+ throw new Exception('UNKNOWN TOKEN TYPE: ' . $n->type);
+ }
+
+ return $s;
+ }
+
+ private function isValidIdentifier($string)
+ {
+ return preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $string) && !in_array($string, $this->reserved);
+ }
+}
+
+class JSParser
+{
+ private $t;
+
+ private $opPrecedence = array(
+ ';' => 0,
+ ',' => 1,
+ '=' => 2, '?' => 2, ':' => 2,
+ // The above all have to have the same precedence, see bug 330975.
+ '||' => 4,
+ '&&' => 5,
+ '|' => 6,
+ '^' => 7,
+ '&' => 8,
+ '==' => 9, '!=' => 9, '===' => 9, '!==' => 9,
+ '<' => 10, '<=' => 10, '>=' => 10, '>' => 10, 'in' => 10, 'instanceof' => 10,
+ '<<' => 11, '>>' => 11, '>>>' => 11,
+ '+' => 12, '-' => 12,
+ '*' => 13, '/' => 13, '%' => 13,
+ 'delete' => 14, 'void' => 14, 'typeof' => 14,
+ '!' => 14, '~' => 14, 'U+' => 14, 'U-' => 14,
+ '++' => 15, '--' => 15,
+ 'new' => 16,
+ '.' => 17,
+ JS_NEW_WITH_ARGS => 0, JS_INDEX => 0, JS_CALL => 0,
+ JS_ARRAY_INIT => 0, JS_OBJECT_INIT => 0, JS_GROUP => 0
+ );
+
+ private $opArity = array(
+ ',' => -2,
+ '=' => 2,
+ '?' => 3,
+ '||' => 2,
+ '&&' => 2,
+ '|' => 2,
+ '^' => 2,
+ '&' => 2,
+ '==' => 2, '!=' => 2, '===' => 2, '!==' => 2,
+ '<' => 2, '<=' => 2, '>=' => 2, '>' => 2, 'in' => 2, 'instanceof' => 2,
+ '<<' => 2, '>>' => 2, '>>>' => 2,
+ '+' => 2, '-' => 2,
+ '*' => 2, '/' => 2, '%' => 2,
+ 'delete' => 1, 'void' => 1, 'typeof' => 1,
+ '!' => 1, '~' => 1, 'U+' => 1, 'U-' => 1,
+ '++' => 1, '--' => 1,
+ 'new' => 1,
+ '.' => 2,
+ JS_NEW_WITH_ARGS => 2, JS_INDEX => 2, JS_CALL => 2,
+ JS_ARRAY_INIT => 1, JS_OBJECT_INIT => 1, JS_GROUP => 1,
+ TOKEN_CONDCOMMENT_MULTILINE => 1
+ );
+
+ public function __construct()
+ {
+ $this->t = new JSTokenizer();
+ }
+
+ public function parse($s, $f, $l)
+ {
+ // initialize tokenizer
+ $this->t->init($s, $f, $l);
+
+ $x = new JSCompilerContext(false);
+ $n = $this->Script($x);
+ if (!$this->t->isDone())
+ throw $this->t->newSyntaxError('Syntax error');
+
+ return $n;
+ }
+
+ private function Script($x)
+ {
+ $n = $this->Statements($x);
+ $n->type = JS_SCRIPT;
+ $n->funDecls = $x->funDecls;
+ $n->varDecls = $x->varDecls;
+
+ return $n;
+ }
+
+ private function Statements($x)
+ {
+ $n = new JSNode($this->t, JS_BLOCK);
+ array_push($x->stmtStack, $n);
+
+ while (!$this->t->isDone() && $this->t->peek() != OP_RIGHT_CURLY)
+ $n->addNode($this->Statement($x));
+
+ array_pop($x->stmtStack);
+
+ return $n;
+ }
+
+ private function Block($x)
+ {
+ $this->t->mustMatch(OP_LEFT_CURLY);
+ $n = $this->Statements($x);
+ $this->t->mustMatch(OP_RIGHT_CURLY);
+
+ return $n;
+ }
+
+ private function Statement($x)
+ {
+ $tt = $this->t->get();
+ $n2 = null;
+
+ // Cases for statements ending in a right curly return early, avoiding the
+ // common semicolon insertion magic after this switch.
+ switch ($tt)
+ {
+ case KEYWORD_FUNCTION:
+ return $this->FunctionDefinition(
+ $x,
+ true,
+ count($x->stmtStack) > 1 ? STATEMENT_FORM : DECLARED_FORM
+ );
+ break;
+
+ case OP_LEFT_CURLY:
+ $n = $this->Statements($x);
+ $this->t->mustMatch(OP_RIGHT_CURLY);
+ return $n;
+
+ case KEYWORD_IF:
+ $n = new JSNode($this->t);
+ $n->condition = $this->ParenExpression($x);
+ array_push($x->stmtStack, $n);
+ $n->thenPart = $this->Statement($x);
+ $n->elsePart = $this->t->match(KEYWORD_ELSE) ? $this->Statement($x) : null;
+ array_pop($x->stmtStack);
+ return $n;
+
+ case KEYWORD_SWITCH:
+ $n = new JSNode($this->t);
+ $this->t->mustMatch(OP_LEFT_PAREN);
+ $n->discriminant = $this->Expression($x);
+ $this->t->mustMatch(OP_RIGHT_PAREN);
+ $n->cases = array();
+ $n->defaultIndex = -1;
+
+ array_push($x->stmtStack, $n);
+
+ $this->t->mustMatch(OP_LEFT_CURLY);
+
+ while (($tt = $this->t->get()) != OP_RIGHT_CURLY)
+ {
+ switch ($tt)
+ {
+ case KEYWORD_DEFAULT:
+ if ($n->defaultIndex >= 0)
+ throw $this->t->newSyntaxError('More than one switch default');
+ // FALL THROUGH
+ case KEYWORD_CASE:
+ $n2 = new JSNode($this->t);
+ if ($tt == KEYWORD_DEFAULT)
+ $n->defaultIndex = count($n->cases);
+ else
+ $n2->caseLabel = $this->Expression($x, OP_COLON);
+ break;
+ default:
+ throw $this->t->newSyntaxError('Invalid switch case');
+ }
+
+ $this->t->mustMatch(OP_COLON);
+ $n2->statements = new JSNode($this->t, JS_BLOCK);
+ while (($tt = $this->t->peek()) != KEYWORD_CASE && $tt != KEYWORD_DEFAULT && $tt != OP_RIGHT_CURLY)
+ $n2->statements->addNode($this->Statement($x));
+
+ array_push($n->cases, $n2);
+ }
+
+ array_pop($x->stmtStack);
+ return $n;
+
+ case KEYWORD_FOR:
+ $n = new JSNode($this->t);
+ $n->isLoop = true;
+ $this->t->mustMatch(OP_LEFT_PAREN);
+
+ if (($tt = $this->t->peek()) != OP_SEMICOLON)
+ {
+ $x->inForLoopInit = true;
+ if ($tt == KEYWORD_VAR || $tt == KEYWORD_CONST)
+ {
+ $this->t->get();
+ $n2 = $this->Variables($x);
+ }
+ else
+ {
+ $n2 = $this->Expression($x);
+ }
+ $x->inForLoopInit = false;
+ }
+
+ if ($n2 && $this->t->match(KEYWORD_IN))
+ {
+ $n->type = JS_FOR_IN;
+ if ($n2->type == KEYWORD_VAR)
+ {
+ if (count($n2->treeNodes) != 1)
+ {
+ throw $this->t->SyntaxError(
+ 'Invalid for..in left-hand side',
+ $this->t->filename,
+ $n2->lineno
+ );
+ }
+
+ // NB: n2[0].type == IDENTIFIER and n2[0].value == n2[0].name.
+ $n->iterator = $n2->treeNodes[0];
+ $n->varDecl = $n2;
+ }
+ else
+ {
+ $n->iterator = $n2;
+ $n->varDecl = null;
+ }
+
+ $n->object = $this->Expression($x);
+ }
+ else
+ {
+ $n->setup = $n2 ? $n2 : null;
+ $this->t->mustMatch(OP_SEMICOLON);
+ $n->condition = $this->t->peek() == OP_SEMICOLON ? null : $this->Expression($x);
+ $this->t->mustMatch(OP_SEMICOLON);
+ $n->update = $this->t->peek() == OP_RIGHT_PAREN ? null : $this->Expression($x);
+ }
+
+ $this->t->mustMatch(OP_RIGHT_PAREN);
+ $n->body = $this->nest($x, $n);
+ return $n;
+
+ case KEYWORD_WHILE:
+ $n = new JSNode($this->t);
+ $n->isLoop = true;
+ $n->condition = $this->ParenExpression($x);
+ $n->body = $this->nest($x, $n);
+ return $n;
+
+ case KEYWORD_DO:
+ $n = new JSNode($this->t);
+ $n->isLoop = true;
+ $n->body = $this->nest($x, $n, KEYWORD_WHILE);
+ $n->condition = $this->ParenExpression($x);
+ if (!$x->ecmaStrictMode)
+ {
+ // <script language="JavaScript"> (without version hints) may need
+ // automatic semicolon insertion without a newline after do-while.
+ // See http://bugzilla.mozilla.org/show_bug.cgi?id=238945.
+ $this->t->match(OP_SEMICOLON);
+ return $n;
+ }
+ break;
+
+ case KEYWORD_BREAK:
+ case KEYWORD_CONTINUE:
+ $n = new JSNode($this->t);
+
+ if ($this->t->peekOnSameLine() == TOKEN_IDENTIFIER)
+ {
+ $this->t->get();
+ $n->label = $this->t->currentToken()->value;
+ }
+
+ $ss = $x->stmtStack;
+ $i = count($ss);
+ $label = $n->label;
+ if ($label)
+ {
+ do
+ {
+ if (--$i < 0)
+ throw $this->t->newSyntaxError('Label not found');
+ }
+ while ($ss[$i]->label != $label);
+ }
+ else
+ {
+ do
+ {
+ if (--$i < 0)
+ throw $this->t->newSyntaxError('Invalid ' . $tt);
+ }
+ while (!$ss[$i]->isLoop && ($tt != KEYWORD_BREAK || $ss[$i]->type != KEYWORD_SWITCH));
+ }
+
+ $n->target = $ss[$i];
+ break;
+
+ case KEYWORD_TRY:
+ $n = new JSNode($this->t);
+ $n->tryBlock = $this->Block($x);
+ $n->catchClauses = array();
+
+ while ($this->t->match(KEYWORD_CATCH))
+ {
+ $n2 = new JSNode($this->t);
+ $this->t->mustMatch(OP_LEFT_PAREN);
+ $n2->varName = $this->t->mustMatch(TOKEN_IDENTIFIER)->value;
+
+ if ($this->t->match(KEYWORD_IF))
+ {
+ if ($x->ecmaStrictMode)
+ throw $this->t->newSyntaxError('Illegal catch guard');
+
+ if (count($n->catchClauses) && !end($n->catchClauses)->guard)
+ throw $this->t->newSyntaxError('Guarded catch after unguarded');
+
+ $n2->guard = $this->Expression($x);
+ }
+ else
+ {
+ $n2->guard = null;
+ }
+
+ $this->t->mustMatch(OP_RIGHT_PAREN);
+ $n2->block = $this->Block($x);
+ array_push($n->catchClauses, $n2);
+ }
+
+ if ($this->t->match(KEYWORD_FINALLY))
+ $n->finallyBlock = $this->Block($x);
+
+ if (!count($n->catchClauses) && !$n->finallyBlock)
+ throw $this->t->newSyntaxError('Invalid try statement');
+ return $n;
+
+ case KEYWORD_CATCH:
+ case KEYWORD_FINALLY:
+ throw $this->t->newSyntaxError($tt + ' without preceding try');
+
+ case KEYWORD_THROW:
+ $n = new JSNode($this->t);
+ $n->exception = $this->Expression($x);
+ break;
+
+ case KEYWORD_RETURN:
+ if (!$x->inFunction)
+ throw $this->t->newSyntaxError('Invalid return');
+
+ $n = new JSNode($this->t);
+ $tt = $this->t->peekOnSameLine();
+ if ($tt != TOKEN_END && $tt != TOKEN_NEWLINE && $tt != OP_SEMICOLON && $tt != OP_RIGHT_CURLY)
+ $n->value = $this->Expression($x);
+ else
+ $n->value = null;
+ break;
+
+ case KEYWORD_WITH:
+ $n = new JSNode($this->t);
+ $n->object = $this->ParenExpression($x);
+ $n->body = $this->nest($x, $n);
+ return $n;
+
+ case KEYWORD_VAR:
+ case KEYWORD_CONST:
+ $n = $this->Variables($x);
+ break;
+
+ case TOKEN_CONDCOMMENT_MULTILINE:
+ $n = new JSNode($this->t);
+ return $n;
+
+ case KEYWORD_DEBUGGER:
+ $n = new JSNode($this->t);
+ break;
+
+ case TOKEN_NEWLINE:
+ case OP_SEMICOLON:
+ $n = new JSNode($this->t, OP_SEMICOLON);
+ $n->expression = null;
+ return $n;
+
+ default:
+ if ($tt == TOKEN_IDENTIFIER)
+ {
+ $this->t->scanOperand = false;
+ $tt = $this->t->peek();
+ $this->t->scanOperand = true;
+ if ($tt == OP_COLON)
+ {
+ $label = $this->t->currentToken()->value;
+ $ss = $x->stmtStack;
+ for ($i = count($ss) - 1; $i >= 0; --$i)
+ {
+ if ($ss[$i]->label == $label)
+ throw $this->t->newSyntaxError('Duplicate label');
+ }
+
+ $this->t->get();
+ $n = new JSNode($this->t, JS_LABEL);
+ $n->label = $label;
+ $n->statement = $this->nest($x, $n);
+
+ return $n;
+ }
+ }
+
+ $n = new JSNode($this->t, OP_SEMICOLON);
+ $this->t->unget();
+ $n->expression = $this->Expression($x);
+ $n->end = $n->expression->end;
+ break;
+ }
+
+ if ($this->t->lineno == $this->t->currentToken()->lineno)
+ {
+ $tt = $this->t->peekOnSameLine();
+ if ($tt != TOKEN_END && $tt != TOKEN_NEWLINE && $tt != OP_SEMICOLON && $tt != OP_RIGHT_CURLY)
+ throw $this->t->newSyntaxError('Missing ; before statement');
+ }
+
+ $this->t->match(OP_SEMICOLON);
+
+ return $n;
+ }
+
+ private function FunctionDefinition($x, $requireName, $functionForm)
+ {
+ $f = new JSNode($this->t);
+
+ if ($f->type != KEYWORD_FUNCTION)
+ $f->type = ($f->value == 'get') ? JS_GETTER : JS_SETTER;
+
+ if ($this->t->match(TOKEN_IDENTIFIER))
+ $f->name = $this->t->currentToken()->value;
+ elseif ($requireName)
+ throw $this->t->newSyntaxError('Missing function identifier');
+
+ $this->t->mustMatch(OP_LEFT_PAREN);
+ $f->params = array();
+
+ while (($tt = $this->t->get()) != OP_RIGHT_PAREN)
+ {
+ if ($tt != TOKEN_IDENTIFIER)
+ throw $this->t->newSyntaxError('Missing formal parameter');
+
+ array_push($f->params, $this->t->currentToken()->value);
+
+ if ($this->t->peek() != OP_RIGHT_PAREN)
+ $this->t->mustMatch(OP_COMMA);
+ }
+
+ $this->t->mustMatch(OP_LEFT_CURLY);
+
+ $x2 = new JSCompilerContext(true);
+ $f->body = $this->Script($x2);
+
+ $this->t->mustMatch(OP_RIGHT_CURLY);
+ $f->end = $this->t->currentToken()->end;
+
+ $f->functionForm = $functionForm;
+ if ($functionForm == DECLARED_FORM)
+ array_push($x->funDecls, $f);
+
+ return $f;
+ }
+
+ private function Variables($x)
+ {
+ $n = new JSNode($this->t);
+
+ do
+ {
+ $this->t->mustMatch(TOKEN_IDENTIFIER);
+
+ $n2 = new JSNode($this->t);
+ $n2->name = $n2->value;
+
+ if ($this->t->match(OP_ASSIGN))
+ {
+ if ($this->t->currentToken()->assignOp)
+ throw $this->t->newSyntaxError('Invalid variable initialization');
+
+ $n2->initializer = $this->Expression($x, OP_COMMA);
+ }
+
+ $n2->readOnly = $n->type == KEYWORD_CONST;
+
+ $n->addNode($n2);
+ array_push($x->varDecls, $n2);
+ }
+ while ($this->t->match(OP_COMMA));
+
+ return $n;
+ }
+
+ private function Expression($x, $stop=false)
+ {
+ $operators = array();
+ $operands = array();
+ $n = false;
+
+ $bl = $x->bracketLevel;
+ $cl = $x->curlyLevel;
+ $pl = $x->parenLevel;
+ $hl = $x->hookLevel;
+
+ while (($tt = $this->t->get()) != TOKEN_END)
+ {
+ if ($tt == $stop &&
+ $x->bracketLevel == $bl &&
+ $x->curlyLevel == $cl &&
+ $x->parenLevel == $pl &&
+ $x->hookLevel == $hl
+ )
+ {
+ // Stop only if tt matches the optional stop parameter, and that
+ // token is not quoted by some kind of bracket.
+ break;
+ }
+
+ switch ($tt)
+ {
+ case OP_SEMICOLON:
+ // NB: cannot be empty, Statement handled that.
+ break 2;
+
+ case OP_ASSIGN:
+ case OP_HOOK:
+ case OP_COLON:
+ if ($this->t->scanOperand)
+ break 2;
+
+ // Use >, not >=, for right-associative ASSIGN and HOOK/COLON.
+ while ( !empty($operators) &&
+ ( $this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt] ||
+ ($tt == OP_COLON && end($operators)->type == OP_ASSIGN)
+ )
+ )
+ $this->reduce($operators, $operands);
+
+ if ($tt == OP_COLON)
+ {
+ $n = end($operators);
+ if ($n->type != OP_HOOK)
+ throw $this->t->newSyntaxError('Invalid label');
+
+ --$x->hookLevel;
+ }
+ else
+ {
+ array_push($operators, new JSNode($this->t));
+ if ($tt == OP_ASSIGN)
+ end($operands)->assignOp = $this->t->currentToken()->assignOp;
+ else
+ ++$x->hookLevel;
+ }
+
+ $this->t->scanOperand = true;
+ break;
+
+ case KEYWORD_IN:
+ // An in operator should not be parsed if we're parsing the head of
+ // a for (...) loop, unless it is in the then part of a conditional
+ // expression, or parenthesized somehow.
+ if ($x->inForLoopInit && !$x->hookLevel &&
+ !$x->bracketLevel && !$x->curlyLevel &&
+ !$x->parenLevel
+ )
+ {
+ break 2;
+ }
+ // FALL THROUGH
+ case OP_COMMA:
+ // Treat comma as left-associative so reduce can fold left-heavy
+ // COMMA trees into a single array.
+ // FALL THROUGH
+ case OP_OR:
+ case OP_AND:
+ case OP_BITWISE_OR:
+ case OP_BITWISE_XOR:
+ case OP_BITWISE_AND:
+ case OP_EQ: case OP_NE: case OP_STRICT_EQ: case OP_STRICT_NE:
+ case OP_LT: case OP_LE: case OP_GE: case OP_GT:
+ case KEYWORD_INSTANCEOF:
+ case OP_LSH: case OP_RSH: case OP_URSH:
+ case OP_PLUS: case OP_MINUS:
+ case OP_MUL: case OP_DIV: case OP_MOD:
+ case OP_DOT:
+ if ($this->t->scanOperand)
+ break 2;
+
+ while ( !empty($operators) &&
+ $this->opPrecedence[end($operators)->type] >= $this->opPrecedence[$tt]
+ )
+ $this->reduce($operators, $operands);
+
+ if ($tt == OP_DOT)
+ {
+ $this->t->mustMatch(TOKEN_IDENTIFIER);
+ array_push($operands, new JSNode($this->t, OP_DOT, array_pop($operands), new JSNode($this->t)));
+ }
+ else
+ {
+ array_push($operators, new JSNode($this->t));
+ $this->t->scanOperand = true;
+ }
+ break;
+
+ case KEYWORD_DELETE: case KEYWORD_VOID: case KEYWORD_TYPEOF:
+ case OP_NOT: case OP_BITWISE_NOT: case OP_UNARY_PLUS: case OP_UNARY_MINUS:
+ case KEYWORD_NEW:
+ if (!$this->t->scanOperand)
+ break 2;
+
+ array_push($operators, new JSNode($this->t));
+ break;
+
+ case OP_INCREMENT: case OP_DECREMENT:
+ if ($this->t->scanOperand)
+ {
+ array_push($operators, new JSNode($this->t)); // prefix increment or decrement
+ }
+ else
+ {
+ // Don't cross a line boundary for postfix {in,de}crement.
+ $t = $this->t->tokens[($this->t->tokenIndex + $this->t->lookahead - 1) & 3];
+ if ($t && $t->lineno != $this->t->lineno)
+ break 2;
+
+ if (!empty($operators))
+ {
+ // Use >, not >=, so postfix has higher precedence than prefix.
+ while ($this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt])
+ $this->reduce($operators, $operands);
+ }
+
+ $n = new JSNode($this->t, $tt, array_pop($operands));
+ $n->postfix = true;
+ array_push($operands, $n);
+ }
+ break;
+
+ case KEYWORD_FUNCTION:
+ if (!$this->t->scanOperand)
+ break 2;
+
+ array_push($operands, $this->FunctionDefinition($x, false, EXPRESSED_FORM));
+ $this->t->scanOperand = false;
+ break;
+
+ case KEYWORD_NULL: case KEYWORD_THIS: case KEYWORD_TRUE: case KEYWORD_FALSE:
+ case TOKEN_IDENTIFIER: case TOKEN_NUMBER: case TOKEN_STRING: case TOKEN_REGEXP:
+ if (!$this->t->scanOperand)
+ break 2;
+
+ array_push($operands, new JSNode($this->t));
+ $this->t->scanOperand = false;
+ break;
+
+ case TOKEN_CONDCOMMENT_MULTILINE:
+ if ($this->t->scanOperand)
+ array_push($operators, new JSNode($this->t));
+ else
+ array_push($operands, new JSNode($this->t));
+ break;
+
+ case OP_LEFT_BRACKET:
+ if ($this->t->scanOperand)
+ {
+ // Array initialiser. Parse using recursive descent, as the
+ // sub-grammar here is not an operator grammar.
+ $n = new JSNode($this->t, JS_ARRAY_INIT);
+ while (($tt = $this->t->peek()) != OP_RIGHT_BRACKET)
+ {
+ if ($tt == OP_COMMA)
+ {
+ $this->t->get();
+ $n->addNode(null);
+ continue;
+ }
+
+ $n->addNode($this->Expression($x, OP_COMMA));
+ if (!$this->t->match(OP_COMMA))
+ break;
+ }
+
+ $this->t->mustMatch(OP_RIGHT_BRACKET);
+ array_push($operands, $n);
+ $this->t->scanOperand = false;
+ }
+ else
+ {
+ // Property indexing operator.
+ array_push($operators, new JSNode($this->t, JS_INDEX));
+ $this->t->scanOperand = true;
+ ++$x->bracketLevel;
+ }
+ break;
+
+ case OP_RIGHT_BRACKET:
+ if ($this->t->scanOperand || $x->bracketLevel == $bl)
+ break 2;
+
+ while ($this->reduce($operators, $operands)->type != JS_INDEX)
+ continue;
+
+ --$x->bracketLevel;
+ break;
+
+ case OP_LEFT_CURLY:
+ if (!$this->t->scanOperand)
+ break 2;
+
+ // Object initialiser. As for array initialisers (see above),
+ // parse using recursive descent.
+ ++$x->curlyLevel;
+ $n = new JSNode($this->t, JS_OBJECT_INIT);
+ while (!$this->t->match(OP_RIGHT_CURLY))
+ {
+ do
+ {
+ $tt = $this->t->get();
+ $tv = $this->t->currentToken()->value;
+ if (($tv == 'get' || $tv == 'set') && $this->t->peek() == TOKEN_IDENTIFIER)
+ {
+ if ($x->ecmaStrictMode)
+ throw $this->t->newSyntaxError('Illegal property accessor');
+
+ $n->addNode($this->FunctionDefinition($x, true, EXPRESSED_FORM));
+ }
+ else
+ {
+ switch ($tt)
+ {
+ case TOKEN_IDENTIFIER:
+ case TOKEN_NUMBER:
+ case TOKEN_STRING:
+ $id = new JSNode($this->t);
+ break;
+
+ case OP_RIGHT_CURLY:
+ if ($x->ecmaStrictMode)
+ throw $this->t->newSyntaxError('Illegal trailing ,');
+ break 3;
+
+ default:
+ throw $this->t->newSyntaxError('Invalid property name');
+ }
+
+ $this->t->mustMatch(OP_COLON);
+ $n->addNode(new JSNode($this->t, JS_PROPERTY_INIT, $id, $this->Expression($x, OP_COMMA)));
+ }
+ }
+ while ($this->t->match(OP_COMMA));
+
+ $this->t->mustMatch(OP_RIGHT_CURLY);
+ break;
+ }
+
+ array_push($operands, $n);
+ $this->t->scanOperand = false;
+ --$x->curlyLevel;
+ break;
+
+ case OP_RIGHT_CURLY:
+ if (!$this->t->scanOperand && $x->curlyLevel != $cl)
+ throw new Exception('PANIC: right curly botch');
+ break 2;
+
+ case OP_LEFT_PAREN:
+ if ($this->t->scanOperand)
+ {
+ array_push($operators, new JSNode($this->t, JS_GROUP));
+ }
+ else
+ {
+ while ( !empty($operators) &&
+ $this->opPrecedence[end($operators)->type] > $this->opPrecedence[KEYWORD_NEW]
+ )
+ $this->reduce($operators, $operands);
+
+ // Handle () now, to regularize the n-ary case for n > 0.
+ // We must set scanOperand in case there are arguments and
+ // the first one is a regexp or unary+/-.
+ $n = end($operators);
+ $this->t->scanOperand = true;
+ if ($this->t->match(OP_RIGHT_PAREN))
+ {
+ if ($n && $n->type == KEYWORD_NEW)
+ {
+ array_pop($operators);
+ $n->addNode(array_pop($operands));
+ }
+ else
+ {
+ $n = new JSNode($this->t, JS_CALL, array_pop($operands), new JSNode($this->t, JS_LIST));
+ }
+
+ array_push($operands, $n);
+ $this->t->scanOperand = false;
+ break;
+ }
+
+ if ($n && $n->type == KEYWORD_NEW)
+ $n->type = JS_NEW_WITH_ARGS;
+ else
+ array_push($operators, new JSNode($this->t, JS_CALL));
+ }
+
+ ++$x->parenLevel;
+ break;
+
+ case OP_RIGHT_PAREN:
+ if ($this->t->scanOperand || $x->parenLevel == $pl)
+ break 2;
+
+ while (($tt = $this->reduce($operators, $operands)->type) != JS_GROUP &&
+ $tt != JS_CALL && $tt != JS_NEW_WITH_ARGS
+ )
+ {
+ continue;
+ }
+
+ if ($tt != JS_GROUP)
+ {
+ $n = end($operands);
+ if ($n->treeNodes[1]->type != OP_COMMA)
+ $n->treeNodes[1] = new JSNode($this->t, JS_LIST, $n->treeNodes[1]);
+ else
+ $n->treeNodes[1]->type = JS_LIST;
+ }
+
+ --$x->parenLevel;
+ break;
+
+ // Automatic semicolon insertion means we may scan across a newline
+ // and into the beginning of another statement. If so, break out of
+ // the while loop and let the t.scanOperand logic handle errors.
+ default:
+ break 2;
+ }
+ }
+
+ if ($x->hookLevel != $hl)
+ throw $this->t->newSyntaxError('Missing : after ?');
+
+ if ($x->parenLevel != $pl)
+ throw $this->t->newSyntaxError('Missing ) in parenthetical');
+
+ if ($x->bracketLevel != $bl)
+ throw $this->t->newSyntaxError('Missing ] in index expression');
+
+ if ($this->t->scanOperand)
+ throw $this->t->newSyntaxError('Missing operand');
+
+ // Resume default mode, scanning for operands, not operators.
+ $this->t->scanOperand = true;
+ $this->t->unget();
+
+ while (count($operators))
+ $this->reduce($operators, $operands);
+
+ return array_pop($operands);
+ }
+
+ private function ParenExpression($x)
+ {
+ $this->t->mustMatch(OP_LEFT_PAREN);
+ $n = $this->Expression($x);
+ $this->t->mustMatch(OP_RIGHT_PAREN);
+
+ return $n;
+ }
+
+ // Statement stack and nested statement handler.
+ private function nest($x, $node, $end = false)
+ {
+ array_push($x->stmtStack, $node);
+ $n = $this->statement($x);
+ array_pop($x->stmtStack);
+
+ if ($end)
+ $this->t->mustMatch($end);
+
+ return $n;
+ }
+
+ private function reduce(&$operators, &$operands)
+ {
+ $n = array_pop($operators);
+ $op = $n->type;
+ $arity = $this->opArity[$op];
+ $c = count($operands);
+ if ($arity == -2)
+ {
+ // Flatten left-associative trees
+ if ($c >= 2)
+ {
+ $left = $operands[$c - 2];
+ if ($left->type == $op)
+ {
+ $right = array_pop($operands);
+ $left->addNode($right);
+ return $left;
+ }
+ }
+ $arity = 2;
+ }
+
+ // Always use push to add operands to n, to update start and end
+ $a = array_splice($operands, $c - $arity);
+ for ($i = 0; $i < $arity; $i++)
+ $n->addNode($a[$i]);
+
+ // Include closing bracket or postfix operator in [start,end]
+ $te = $this->t->currentToken()->end;
+ if ($n->end < $te)
+ $n->end = $te;
+
+ array_push($operands, $n);
+
+ return $n;
+ }
+}
+
+class JSCompilerContext
+{
+ public $inFunction = false;
+ public $inForLoopInit = false;
+ public $ecmaStrictMode = false;
+ public $bracketLevel = 0;
+ public $curlyLevel = 0;
+ public $parenLevel = 0;
+ public $hookLevel = 0;
+
+ public $stmtStack = array();
+ public $funDecls = array();
+ public $varDecls = array();
+
+ public function __construct($inFunction)
+ {
+ $this->inFunction = $inFunction;
+ }
+}
+
+class JSNode
+{
+ private $type;
+ private $value;
+ private $lineno;
+ private $start;
+ private $end;
+
+ public $treeNodes = array();
+ public $funDecls = array();
+ public $varDecls = array();
+
+ public function __construct($t, $type=0)
+ {
+ if ($token = $t->currentToken())
+ {
+ $this->type = $type ? $type : $token->type;
+ $this->value = $token->value;
+ $this->lineno = $token->lineno;
+ $this->start = $token->start;
+ $this->end = $token->end;
+ }
+ else
+ {
+ $this->type = $type;
+ $this->lineno = $t->lineno;
+ }
+
+ if (($numargs = func_num_args()) > 2)
+ {
+ $args = func_get_args();;
+ for ($i = 2; $i < $numargs; $i++)
+ $this->addNode($args[$i]);
+ }
+ }
+
+ // we don't want to bloat our object with all kind of specific properties, so we use overloading
+ public function __set($name, $value)
+ {
+ $this->$name = $value;
+ }
+
+ public function __get($name)
+ {
+ if (isset($this->$name))
+ return $this->$name;
+
+ return null;
+ }
+
+ public function addNode($node)
+ {
+ $this->treeNodes[] = $node;
+ }
+}
+
+class JSTokenizer
+{
+ private $cursor = 0;
+ private $source;
+
+ public $tokens = array();
+ public $tokenIndex = 0;
+ public $lookahead = 0;
+ public $scanNewlines = false;
+ public $scanOperand = true;
+
+ public $filename;
+ public $lineno;
+
+ private $keywords = array(
+ 'break',
+ 'case', 'catch', 'const', 'continue',
+ 'debugger', 'default', 'delete', 'do',
+ 'else', 'enum',
+ 'false', 'finally', 'for', 'function',
+ 'if', 'in', 'instanceof',
+ 'new', 'null',
+ 'return',
+ 'switch',
+ 'this', 'throw', 'true', 'try', 'typeof',
+ 'var', 'void',
+ 'while', 'with'
+ );
+
+ private $opTypeNames = array(
+ ';' => 'SEMICOLON',
+ ',' => 'COMMA',
+ '?' => 'HOOK',
+ ':' => 'COLON',
+ '||' => 'OR',
+ '&&' => 'AND',
+ '|' => 'BITWISE_OR',
+ '^' => 'BITWISE_XOR',
+ '&' => 'BITWISE_AND',
+ '===' => 'STRICT_EQ',
+ '==' => 'EQ',
+ '=' => 'ASSIGN',
+ '!==' => 'STRICT_NE',
+ '!=' => 'NE',
+ '<<' => 'LSH',
+ '<=' => 'LE',
+ '<' => 'LT',
+ '>>>' => 'URSH',
+ '>>' => 'RSH',
+ '>=' => 'GE',
+ '>' => 'GT',
+ '++' => 'INCREMENT',
+ '--' => 'DECREMENT',
+ '+' => 'PLUS',
+ '-' => 'MINUS',
+ '*' => 'MUL',
+ '/' => 'DIV',
+ '%' => 'MOD',
+ '!' => 'NOT',
+ '~' => 'BITWISE_NOT',
+ '.' => 'DOT',
+ '[' => 'LEFT_BRACKET',
+ ']' => 'RIGHT_BRACKET',
+ '{' => 'LEFT_CURLY',
+ '}' => 'RIGHT_CURLY',
+ '(' => 'LEFT_PAREN',
+ ')' => 'RIGHT_PAREN',
+ '@*/' => 'CONDCOMMENT_END'
+ );
+
+ private $assignOps = array('|', '^', '&', '<<', '>>', '>>>', '+', '-', '*', '/', '%');
+ private $opRegExp;
+
+ public function __construct()
+ {
+ $this->opRegExp = '#^(' . implode('|', array_map('preg_quote', array_keys($this->opTypeNames))) . ')#';
+
+ // this is quite a hidden yet convenient place to create the defines for operators and keywords
+ foreach ($this->opTypeNames as $operand => $name)
+ define('OP_' . $name, $operand);
+
+ define('OP_UNARY_PLUS', 'U+');
+ define('OP_UNARY_MINUS', 'U-');
+
+ foreach ($this->keywords as $keyword)
+ define('KEYWORD_' . strtoupper($keyword), $keyword);
+ }
+
+ public function init($source, $filename = '', $lineno = 1)
+ {
+ $this->source = $source;
+ $this->filename = $filename ? $filename : '[inline]';
+ $this->lineno = $lineno;
+
+ $this->cursor = 0;
+ $this->tokens = array();
+ $this->tokenIndex = 0;
+ $this->lookahead = 0;
+ $this->scanNewlines = false;
+ $this->scanOperand = true;
+ }
+
+ public function getInput($chunksize)
+ {
+ if ($chunksize)
+ return substr($this->source, $this->cursor, $chunksize);
+
+ return substr($this->source, $this->cursor);
+ }
+
+ public function isDone()
+ {
+ return $this->peek() == TOKEN_END;
+ }
+
+ public function match($tt)
+ {
+ return $this->get() == $tt || $this->unget();
+ }
+
+ public function mustMatch($tt)
+ {
+ if (!$this->match($tt))
+ throw $this->newSyntaxError('Unexpected token; token ' . $tt . ' expected');
+
+ return $this->currentToken();
+ }
+
+ public function peek()
+ {
+ if ($this->lookahead)
+ {
+ $next = $this->tokens[($this->tokenIndex + $this->lookahead) & 3];
+ if ($this->scanNewlines && $next->lineno != $this->lineno)
+ $tt = TOKEN_NEWLINE;
+ else
+ $tt = $next->type;
+ }
+ else
+ {
+ $tt = $this->get();
+ $this->unget();
+ }
+
+ return $tt;
+ }
+
+ public function peekOnSameLine()
+ {
+ $this->scanNewlines = true;
+ $tt = $this->peek();
+ $this->scanNewlines = false;
+
+ return $tt;
+ }
+
+ public function currentToken()
+ {
+ if (!empty($this->tokens))
+ return $this->tokens[$this->tokenIndex];
+ }
+
+ public function get($chunksize = 1000)
+ {
+ while($this->lookahead)
+ {
+ $this->lookahead--;
+ $this->tokenIndex = ($this->tokenIndex + 1) & 3;
+ $token = $this->tokens[$this->tokenIndex];
+ if ($token->type != TOKEN_NEWLINE || $this->scanNewlines)
+ return $token->type;
+ }
+
+ $conditional_comment = false;
+
+ // strip whitespace and comments
+ while(true)
+ {
+ $input = $this->getInput($chunksize);
+
+ // whitespace handling; gobble up \r as well (effectively we don't have support for MAC newlines!)
+ $re = $this->scanNewlines ? '/^[ \r\t]+/' : '/^\s+/';
+ if (preg_match($re, $input, $match))
+ {
+ $spaces = $match[0];
+ $spacelen = strlen($spaces);
+ $this->cursor += $spacelen;
+ if (!$this->scanNewlines)
+ $this->lineno += substr_count($spaces, "\n");
+
+ if ($spacelen == $chunksize)
+ continue; // complete chunk contained whitespace
+
+ $input = $this->getInput($chunksize);
+ if ($input == '' || $input[0] != '/')
+ break;
+ }
+
+ // Comments
+ if (!preg_match('/^\/(?:\*(@(?:cc_on|if|elif|else|end))?(?:.|\n)*?\*\/|\/.*)/', $input, $match))
+ {
+ if (!$chunksize)
+ break;
+
+ // retry with a full chunk fetch; this also prevents breakage of long regular expressions (which will never match a comment)
+ $chunksize = null;
+ continue;
+ }
+
+ // check if this is a conditional (JScript) comment
+ if (!empty($match[1]))
+ {
+ //$match[0] = '/*' . $match[1];
+ $conditional_comment = true;
+ break;
+ }
+ else
+ {
+ $this->cursor += strlen($match[0]);
+ $this->lineno += substr_count($match[0], "\n");
+ }
+ }
+
+ if ($input == '')
+ {
+ $tt = TOKEN_END;
+ $match = array('');
+ }
+ elseif ($conditional_comment)
+ {
+ $tt = TOKEN_CONDCOMMENT_MULTILINE;
+ }
+ else
+ {
+ switch ($input[0])
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ if (preg_match('/^\d+\.\d*(?:[eE][-+]?\d+)?|^\d+(?:\.\d*)?[eE][-+]?\d+/', $input, $match))
+ {
+ $tt = TOKEN_NUMBER;
+ }
+ elseif (preg_match('/^0[xX][\da-fA-F]+|^0[0-7]*|^\d+/', $input, $match))
+ {
+ // this should always match because of \d+
+ $tt = TOKEN_NUMBER;
+ }
+ break;
+
+ case '"':
+ case "'":
+ if (preg_match('/^"(?:\\\\(?:.|\r?\n)|[^\\\\"\r\n])*"|^\'(?:\\\\(?:.|\r?\n)|[^\\\\\'\r\n])*\'/', $input, $match))
+ {
+ $tt = TOKEN_STRING;
+ }
+ else
+ {
+ if ($chunksize)
+ return $this->get(null); // retry with a full chunk fetch
+
+ throw $this->newSyntaxError('Unterminated string literal');
+ }
+ break;
+
+ case '/':
+ if ($this->scanOperand && preg_match('/^\/((?:\\\\.|\[(?:\\\\.|[^\]])*\]|[^\/])+)\/([gimy]*)/', $input, $match))
+ {
+ $tt = TOKEN_REGEXP;
+ break;
+ }
+ // fall through
+
+ case '|':
+ case '^':
+ case '&':
+ case '<':
+ case '>':
+ case '+':
+ case '-':
+ case '*':
+ case '%':
+ case '=':
+ case '!':
+ // should always match
+ preg_match($this->opRegExp, $input, $match);
+ $op = $match[0];
+ if (in_array($op, $this->assignOps) && $input[strlen($op)] == '=')
+ {
+ $tt = OP_ASSIGN;
+ $match[0] .= '=';
+ }
+ else
+ {
+ $tt = $op;
+ if ($this->scanOperand)
+ {
+ if ($op == OP_PLUS)
+ $tt = OP_UNARY_PLUS;
+ elseif ($op == OP_MINUS)
+ $tt = OP_UNARY_MINUS;
+ }
+ $op = null;
+ }
+ break;
+
+ case '.':
+ if (preg_match('/^\.\d+(?:[eE][-+]?\d+)?/', $input, $match))
+ {
+ $tt = TOKEN_NUMBER;
+ break;
+ }
+ // fall through
+
+ case ';':
+ case ',':
+ case '?':
+ case ':':
+ case '~':
+ case '[':
+ case ']':
+ case '{':
+ case '}':
+ case '(':
+ case ')':
+ // these are all single
+ $match = array($input[0]);
+ $tt = $input[0];
+ break;
+
+ case '@':
+ throw $this->newSyntaxError('Illegal token');
+ break;
+
+ case "\n":
+ if ($this->scanNewlines)
+ {
+ $match = array("\n");
+ $tt = TOKEN_NEWLINE;
+ }
+ else
+ throw $this->newSyntaxError('Illegal token');
+ break;
+
+ default:
+ // FIXME: add support for unicode and unicode escape sequence \uHHHH
+ if (preg_match('/^[$\w]+/', $input, $match))
+ {
+ $tt = in_array($match[0], $this->keywords) ? $match[0] : TOKEN_IDENTIFIER;
+ }
+ else
+ throw $this->newSyntaxError('Illegal token');
+ }
+ }
+
+ $this->tokenIndex = ($this->tokenIndex + 1) & 3;
+
+ if (!isset($this->tokens[$this->tokenIndex]))
+ $this->tokens[$this->tokenIndex] = new JSToken();
+
+ $token = $this->tokens[$this->tokenIndex];
+ $token->type = $tt;
+
+ if ($tt == OP_ASSIGN)
+ $token->assignOp = $op;
+
+ $token->start = $this->cursor;
+
+ $token->value = $match[0];
+ $this->cursor += strlen($match[0]);
+
+ $token->end = $this->cursor;
+ $token->lineno = $this->lineno;
+
+ return $tt;
+ }
+
+ public function unget()
+ {
+ if (++$this->lookahead == 4)
+ throw $this->newSyntaxError('PANIC: too much lookahead!');
+
+ $this->tokenIndex = ($this->tokenIndex - 1) & 3;
+ }
+
+ public function newSyntaxError($m)
+ {
+ return new Exception('Parse error: ' . $m . ' in file \'' . $this->filename . '\' on line ' . $this->lineno);
+ }
+}
+
+class JSToken
+{
+ public $type;
+ public $value;
+ public $start;
+ public $end;
+ public $lineno;
+ public $assignOp;
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Class Minify
+ * @package Minify
+ */
+
+/**
+ * Minify_Source
+ */
+require_once 'Minify/Source.php';
+
+/**
+ * Minify - Combines, minifies, and caches JavaScript and CSS files on demand.
+ *
+ * See README for usage instructions (for now).
+ *
+ * This library was inspired by {@link mailto:flashkot@mail.ru jscsscomp by Maxim Martynyuk}
+ * and by the article {@link http://www.hunlock.com/blogs/Supercharged_Javascript "Supercharged JavaScript" by Patrick Hunlock}.
+ *
+ * Requires PHP 5.1.0.
+ * Tested on PHP 5.1.6.
+ *
+ * @package Minify
+ * @author Ryan Grove <ryan@wonko.com>
+ * @author Stephen Clay <steve@mrclay.org>
+ * @copyright 2008 Ryan Grove, Stephen Clay. All rights reserved.
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://code.google.com/p/minify/
+ */
+class Minify {
+
+ const VERSION = '2.1.3';
+ const TYPE_CSS = 'text/css';
+ const TYPE_HTML = 'text/html';
+ // there is some debate over the ideal JS Content-Type, but this is the
+ // Apache default and what Yahoo! uses..
+ const TYPE_JS = 'application/x-javascript';
+
+ /**
+ * How many hours behind are the file modification times of uploaded files?
+ *
+ * If you upload files from Windows to a non-Windows server, Windows may report
+ * incorrect mtimes for the files. Immediately after modifying and uploading a
+ * file, use the touch command to update the mtime on the server. If the mtime
+ * jumps ahead by a number of hours, set this variable to that number. If the mtime
+ * moves back, this should not be needed.
+ *
+ * @var int $uploaderHoursBehind
+ */
+ public static $uploaderHoursBehind = 0;
+
+ /**
+ * If this string is not empty AND the serve() option 'bubbleCssImports' is
+ * NOT set, then serve() will check CSS files for @import declarations that
+ * appear too late in the combined stylesheet. If found, serve() will prepend
+ * the output with this warning.
+ *
+ * @var string $importWarning
+ */
+ public static $importWarning = "/* See http://code.google.com/p/minify/wiki/CommonProblems#@imports_can_appear_in_invalid_locations_in_combined_CSS_files */\n";
+
+ /**
+ * Specify a cache object (with identical interface as Minify_Cache_File) or
+ * a path to use with Minify_Cache_File.
+ *
+ * If not called, Minify will not use a cache and, for each 200 response, will
+ * need to recombine files, minify and encode the output.
+ *
+ * @param mixed $cache object with identical interface as Minify_Cache_File or
+ * a directory path, or null to disable caching. (default = '')
+ *
+ * @param bool $fileLocking (default = true) This only applies if the first
+ * parameter is a string.
+ *
+ * @return null
+ */
+ public static function setCache($cache = '', $fileLocking = true)
+ {
+ if (is_string($cache)) {
+ require_once 'Minify/Cache/File.php';
+ self::$_cache = new Minify_Cache_File($cache, $fileLocking);
+ } else {
+ self::$_cache = $cache;
+ }
+ }
+
+ /**
+ * Serve a request for a minified file.
+ *
+ * Here are the available options and defaults in the base controller:
+ *
+ * 'isPublic' : send "public" instead of "private" in Cache-Control
+ * headers, allowing shared caches to cache the output. (default true)
+ *
+ * 'quiet' : set to true to have serve() return an array rather than sending
+ * any headers/output (default false)
+ *
+ * 'encodeOutput' : set to false to disable content encoding, and not send
+ * the Vary header (default true)
+ *
+ * 'encodeMethod' : generally you should let this be determined by
+ * HTTP_Encoder (leave null), but you can force a particular encoding
+ * to be returned, by setting this to 'gzip' or '' (no encoding)
+ *
+ * 'encodeLevel' : level of encoding compression (0 to 9, default 9)
+ *
+ * 'contentTypeCharset' : appended to the Content-Type header sent. Set to a falsey
+ * value to remove. (default 'utf-8')
+ *
+ * 'maxAge' : set this to the number of seconds the client should use its cache
+ * before revalidating with the server. This sets Cache-Control: max-age and the
+ * Expires header. Unlike the old 'setExpires' setting, this setting will NOT
+ * prevent conditional GETs. Note this has nothing to do with server-side caching.
+ *
+ * 'rewriteCssUris' : If true, serve() will automatically set the 'currentDir'
+ * minifier option to enable URI rewriting in CSS files (default true)
+ *
+ * 'bubbleCssImports' : If true, all @import declarations in combined CSS
+ * files will be move to the top. Note this may alter effective CSS values
+ * due to a change in order. (default false)
+ *
+ * 'debug' : set to true to minify all sources with the 'Lines' controller, which
+ * eases the debugging of combined files. This also prevents 304 responses.
+ * @see Minify_Lines::minify()
+ *
+ * 'minifiers' : to override Minify's default choice of minifier function for
+ * a particular content-type, specify your callback under the key of the
+ * content-type:
+ * <code>
+ * // call customCssMinifier($css) for all CSS minification
+ * $options['minifiers'][Minify::TYPE_CSS] = 'customCssMinifier';
+ *
+ * // don't minify Javascript at all
+ * $options['minifiers'][Minify::TYPE_JS] = '';
+ * </code>
+ *
+ * 'minifierOptions' : to send options to the minifier function, specify your options
+ * under the key of the content-type. E.g. To send the CSS minifier an option:
+ * <code>
+ * // give CSS minifier array('optionName' => 'optionValue') as 2nd argument
+ * $options['minifierOptions'][Minify::TYPE_CSS]['optionName'] = 'optionValue';
+ * </code>
+ *
+ * 'contentType' : (optional) this is only needed if your file extension is not
+ * js/css/html. The given content-type will be sent regardless of source file
+ * extension, so this should not be used in a Groups config with other
+ * Javascript/CSS files.
+ *
+ * Any controller options are documented in that controller's setupSources() method.
+ *
+ * @param mixed instance of subclass of Minify_Controller_Base or string name of
+ * controller. E.g. 'Files'
+ *
+ * @param array $options controller/serve options
+ *
+ * @return mixed null, or, if the 'quiet' option is set to true, an array
+ * with keys "success" (bool), "statusCode" (int), "content" (string), and
+ * "headers" (array).
+ */
+ public static function serve($controller, $options = array())
+ {
+ if (is_string($controller)) {
+ // make $controller into object
+ $class = 'Minify_Controller_' . $controller;
+ if (! class_exists($class, false)) {
+ require_once "Minify/Controller/"
+ . str_replace('_', '/', $controller) . ".php";
+ }
+ $controller = new $class();
+ }
+
+ // set up controller sources and mix remaining options with
+ // controller defaults
+ $options = $controller->setupSources($options);
+ $options = $controller->analyzeSources($options);
+ self::$_options = $controller->mixInDefaultOptions($options);
+
+ // check request validity
+ if (! $controller->sources) {
+ // invalid request!
+ if (! self::$_options['quiet']) {
+ header(self::$_options['badRequestHeader']);
+ echo self::$_options['badRequestHeader'];
+ return;
+ } else {
+ list(,$statusCode) = explode(' ', self::$_options['badRequestHeader']);
+ return array(
+ 'success' => false
+ ,'statusCode' => (int)$statusCode
+ ,'content' => ''
+ ,'headers' => array()
+ );
+ }
+ }
+
+ self::$_controller = $controller;
+
+ if (self::$_options['debug']) {
+ self::_setupDebug($controller->sources);
+ self::$_options['maxAge'] = 0;
+ }
+
+ // determine encoding
+ if (self::$_options['encodeOutput']) {
+ if (self::$_options['encodeMethod'] !== null) {
+ // controller specifically requested this
+ $contentEncoding = self::$_options['encodeMethod'];
+ } else {
+ // sniff request header
+ require_once 'HTTP/Encoder.php';
+ // depending on what the client accepts, $contentEncoding may be
+ // 'x-gzip' while our internal encodeMethod is 'gzip'. Calling
+ // getAcceptedEncoding(false, false) leaves out compress and deflate as options.
+ list(self::$_options['encodeMethod'], $contentEncoding) = HTTP_Encoder::getAcceptedEncoding(false, false);
+ }
+ } else {
+ self::$_options['encodeMethod'] = ''; // identity (no encoding)
+ }
+
+ // check client cache
+ require_once 'HTTP/ConditionalGet.php';
+ $cgOptions = array(
+ 'lastModifiedTime' => self::$_options['lastModifiedTime']
+ ,'isPublic' => self::$_options['isPublic']
+ ,'encoding' => self::$_options['encodeMethod']
+ );
+ if (self::$_options['maxAge'] > 0) {
+ $cgOptions['maxAge'] = self::$_options['maxAge'];
+ }
+ $cg = new HTTP_ConditionalGet($cgOptions);
+ if ($cg->cacheIsValid) {
+ // client's cache is valid
+ if (! self::$_options['quiet']) {
+ $cg->sendHeaders();
+ return;
+ } else {
+ return array(
+ 'success' => true
+ ,'statusCode' => 304
+ ,'content' => ''
+ ,'headers' => $cg->getHeaders()
+ );
+ }
+ } else {
+ // client will need output
+ $headers = $cg->getHeaders();
+ unset($cg);
+ }
+
+ if (self::$_options['contentType'] === self::TYPE_CSS
+ && self::$_options['rewriteCssUris']) {
+ reset($controller->sources);
+ while (list($key, $source) = each($controller->sources)) {
+ if ($source->filepath
+ && !isset($source->minifyOptions['currentDir'])
+ && !isset($source->minifyOptions['prependRelativePath'])
+ ) {
+ $source->minifyOptions['currentDir'] = dirname($source->filepath);
+ }
+ }
+ }
+
+ // check server cache
+ if (null !== self::$_cache) {
+ // using cache
+ // the goal is to use only the cache methods to sniff the length and
+ // output the content, as they do not require ever loading the file into
+ // memory.
+ $cacheId = 'minify_' . self::_getCacheId();
+ $fullCacheId = (self::$_options['encodeMethod'])
+ ? $cacheId . '.gz'
+ : $cacheId;
+ // check cache for valid entry
+ $cacheIsReady = self::$_cache->isValid($fullCacheId, self::$_options['lastModifiedTime']);
+ if ($cacheIsReady) {
+ $cacheContentLength = self::$_cache->getSize($fullCacheId);
+ } else {
+ // generate & cache content
+ $content = self::_combineMinify();
+ self::$_cache->store($cacheId, $content);
+ if (function_exists('gzencode')) {
+ self::$_cache->store($cacheId . '.gz', gzencode($content, self::$_options['encodeLevel']));
+ }
+ }
+ } else {
+ // no cache
+ $cacheIsReady = false;
+ $content = self::_combineMinify();
+ }
+ if (! $cacheIsReady && self::$_options['encodeMethod']) {
+ // still need to encode
+ $content = gzencode($content, self::$_options['encodeLevel']);
+ }
+
+ // add headers
+ $headers['Content-Length'] = $cacheIsReady
+ ? $cacheContentLength
+ : strlen($content);
+ $headers['Content-Type'] = self::$_options['contentTypeCharset']
+ ? self::$_options['contentType'] . '; charset=' . self::$_options['contentTypeCharset']
+ : self::$_options['contentType'];
+ if (self::$_options['encodeMethod'] !== '') {
+ $headers['Content-Encoding'] = $contentEncoding;
+ }
+ if (self::$_options['encodeOutput']) {
+ $headers['Vary'] = 'Accept-Encoding';
+ }
+
+ if (! self::$_options['quiet']) {
+ // output headers & content
+ foreach ($headers as $name => $val) {
+ header($name . ': ' . $val);
+ }
+ if ($cacheIsReady) {
+ self::$_cache->display($fullCacheId);
+ } else {
+ echo $content;
+ }
+ } else {
+ return array(
+ 'success' => true
+ ,'statusCode' => 200
+ ,'content' => $cacheIsReady
+ ? self::$_cache->fetch($fullCacheId)
+ : $content
+ ,'headers' => $headers
+ );
+ }
+ }
+
+ /**
+ * Return combined minified content for a set of sources
+ *
+ * No internal caching will be used and the content will not be HTTP encoded.
+ *
+ * @param array $sources array of filepaths and/or Minify_Source objects
+ *
+ * @param array $options (optional) array of options for serve. By default
+ * these are already set: quiet = true, encodeMethod = '', lastModifiedTime = 0.
+ *
+ * @return string
+ */
+ public static function combine($sources, $options = array())
+ {
+ $cache = self::$_cache;
+ self::$_cache = null;
+ $options = array_merge(array(
+ 'files' => (array)$sources
+ ,'quiet' => true
+ ,'encodeMethod' => ''
+ ,'lastModifiedTime' => 0
+ ), $options);
+ $out = self::serve('Files', $options);
+ self::$_cache = $cache;
+ return $out['content'];
+ }
+
+ /**
+ * On IIS, create $_SERVER['DOCUMENT_ROOT']
+ *
+ * @param bool $unsetPathInfo (default false) if true, $_SERVER['PATH_INFO']
+ * will be unset (it is inconsistent with Apache's setting)
+ *
+ * @return null
+ */
+ public static function setDocRoot($unsetPathInfo = false)
+ {
+ if (isset($_SERVER['SERVER_SOFTWARE'])
+ && 0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/')
+ ) {
+ $_SERVER['DOCUMENT_ROOT'] = rtrim(substr(
+ $_SERVER['PATH_TRANSLATED']
+ ,0
+ ,strlen($_SERVER['PATH_TRANSLATED']) - strlen($_SERVER['SCRIPT_NAME'])
+ ), '\\');
+ if ($unsetPathInfo) {
+ unset($_SERVER['PATH_INFO']);
+ }
+ require_once 'Minify/Logger.php';
+ Minify_Logger::log("setDocRoot() set DOCUMENT_ROOT to \"{$_SERVER['DOCUMENT_ROOT']}\"");
+ }
+ }
+
+ /**
+ * @var mixed Minify_Cache_* object or null (i.e. no server cache is used)
+ */
+ private static $_cache = null;
+
+ /**
+ * @var Minify_Controller active controller for current request
+ */
+ protected static $_controller = null;
+
+ /**
+ * @var array options for current request
+ */
+ protected static $_options = null;
+
+ /**
+ * Set up sources to use Minify_Lines
+ *
+ * @param array $sources Minify_Source instances
+ *
+ * @return null
+ */
+ protected static function _setupDebug($sources)
+ {
+ foreach ($sources as $source) {
+ $source->minifier = array('Minify_Lines', 'minify');
+ $id = $source->getId();
+ $source->minifyOptions = array(
+ 'id' => (is_file($id) ? basename($id) : $id)
+ );
+ }
+ }
+
+ /**
+ * Combines sources and minifies the result.
+ *
+ * @return string
+ */
+ protected static function _combineMinify()
+ {
+ $type = self::$_options['contentType']; // ease readability
+
+ // when combining scripts, make sure all statements separated and
+ // trailing single line comment is terminated
+ $implodeSeparator = ($type === self::TYPE_JS)
+ ? "\n;"
+ : '';
+ // allow the user to pass a particular array of options to each
+ // minifier (designated by type). source objects may still override
+ // these
+ $defaultOptions = isset(self::$_options['minifierOptions'][$type])
+ ? self::$_options['minifierOptions'][$type]
+ : array();
+ // if minifier not set, default is no minification. source objects
+ // may still override this
+ $defaultMinifier = isset(self::$_options['minifiers'][$type])
+ ? self::$_options['minifiers'][$type]
+ : false;
+
+ if (Minify_Source::haveNoMinifyPrefs(self::$_controller->sources)) {
+ // all source have same options/minifier, better performance
+ // to combine, then minify once
+ foreach (self::$_controller->sources as $source) {
+ $pieces[] = $source->getContent();
+ }
+ $content = implode($implodeSeparator, $pieces);
+ if ($defaultMinifier) {
+ self::$_controller->loadMinifier($defaultMinifier);
+ $content = call_user_func($defaultMinifier, $content, $defaultOptions);
+ }
+ } else {
+ // minify each source with its own options and minifier, then combine
+ foreach (self::$_controller->sources as $source) {
+ // allow the source to override our minifier and options
+ $minifier = (null !== $source->minifier)
+ ? $source->minifier
+ : $defaultMinifier;
+ $options = (null !== $source->minifyOptions)
+ ? array_merge($defaultOptions, $source->minifyOptions)
+ : $defaultOptions;
+ if ($minifier) {
+ self::$_controller->loadMinifier($minifier);
+ // get source content and minify it
+ $pieces[] = call_user_func($minifier, $source->getContent(), $options);
+ } else {
+ $pieces[] = $source->getContent();
+ }
+ }
+ $content = implode($implodeSeparator, $pieces);
+ }
+
+ if ($type === self::TYPE_CSS && false !== strpos($content, '@import')) {
+ $content = self::_handleCssImports($content);
+ }
+
+ // do any post-processing (esp. for editing build URIs)
+ if (self::$_options['postprocessorRequire']) {
+ require_once self::$_options['postprocessorRequire'];
+ }
+ if (self::$_options['postprocessor']) {
+ $content = call_user_func(self::$_options['postprocessor'], $content, $type);
+ }
+ return $content;
+ }
+
+ /**
+ * Make a unique cache id for for this request.
+ *
+ * Any settings that could affect output are taken into consideration
+ *
+ * @return string
+ */
+ protected static function _getCacheId()
+ {
+ return md5(serialize(array(
+ Minify_Source::getDigest(self::$_controller->sources)
+ ,self::$_options['minifiers']
+ ,self::$_options['minifierOptions']
+ ,self::$_options['postprocessor']
+ ,self::$_options['bubbleCssImports']
+ )));
+ }
+
+ /**
+ * Bubble CSS @imports to the top or prepend a warning if an
+ * @import is detected not at the top.
+ */
+ protected static function _handleCssImports($css)
+ {
+ if (self::$_options['bubbleCssImports']) {
+ // bubble CSS imports
+ preg_match_all('/@import.*?;/', $css, $imports);\r
+ $css = implode('', $imports[0]) . preg_replace('/@import.*?;/', '', $css);
+ } else if ('' !== self::$importWarning) {
+ // remove comments so we don't mistake { in a comment as a block
+ $noCommentCss = preg_replace('@/\\*[\\s\\S]*?\\*/@', '', $css);
+ $lastImportPos = strrpos($noCommentCss, '@import');
+ $firstBlockPos = strpos($noCommentCss, '{');
+ if (false !== $lastImportPos
+ && false !== $firstBlockPos
+ && $firstBlockPos < $lastImportPos
+ ) {
+ // { appears before @import : prepend warning
+ $css = self::$importWarning . $css;
+ }
+ }
+ return $css;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_Build
+ * @package Minify
+ */
+
+require_once 'Minify/Source.php';
+
+/**
+ * Maintain a single last modification time for a group of Minify sources to
+ * allow use of far off Expires headers in Minify.
+ *
+ * <code>
+ * // 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)
+ * ));
+ * </code>
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_Build {
+
+ /**
+ * Last modification time of all files in the build
+ *
+ * @var int
+ */
+ public $lastModified = 0;
+
+ /**
+ * String to use as ampersand in uri(). Set this to '&' if
+ * you are not HTML-escaping URIs.
+ *
+ * @var string
+ */
+ public static $ampersand = '&';
+
+ /**
+ * Get a time-stamped URI
+ *
+ * <code>
+ * echo $b->uri('/site.js');
+ * // outputs "/site.js?1678242"
+ *
+ * echo $b->uri('/scriptaculous.js?load=effects');
+ * // outputs "/scriptaculous.js?load=effects&1678242"
+ * </code>
+ *
+ * @param string $uri
+ * @param boolean $forceAmpersand (default = false) Force the use of ampersand to
+ * append the timestamp to the URI.
+ * @return string
+ */
+ public function uri($uri, $forceAmpersand = false) {
+ $sep = ($forceAmpersand || strpos($uri, '?') !== false)
+ ? self::$ampersand
+ : '?';
+ return "{$uri}{$sep}{$this->lastModified}";
+ }
+
+ /**
+ * Create a build object
+ *
+ * @param array $sources array of Minify_Source objects and/or file paths
+ *
+ * @return null
+ */
+ public function __construct($sources)
+ {
+ $max = 0;
+ foreach ((array)$sources as $source) {
+ if ($source instanceof Minify_Source) {
+ $max = max($max, $source->lastModified);
+ } elseif (is_string($source)) {
+ if (0 === strpos($source, '//')) {
+ $source = $_SERVER['DOCUMENT_ROOT'] . substr($source, 1);
+ }
+ if (is_file($source)) {
+ $max = max($max, filemtime($source));
+ }
+ }
+ }
+ $this->lastModified = $max;
+ }
+}
--- /dev/null
+<?php\r
+/**\r
+ * Class Minify_CSS \r
+ * @package Minify\r
+ */\r
+\r
+/**\r
+ * Minify CSS\r
+ *\r
+ * This class uses Minify_CSS_Compressor and Minify_CSS_UriRewriter to \r
+ * minify CSS and rewrite relative URIs.\r
+ * \r
+ * @package Minify\r
+ * @author Stephen Clay <steve@mrclay.org>\r
+ * @author http://code.google.com/u/1stvamp/ (Issue 64 patch)\r
+ */\r
+class Minify_CSS {\r
+ \r
+ /**\r
+ * Minify a CSS string\r
+ * \r
+ * @param string $css\r
+ * \r
+ * @param array $options available options:\r
+ * \r
+ * 'preserveComments': (default true) multi-line comments that begin\r
+ * with "/*!" will be preserved with newlines before and after to\r
+ * enhance readability.\r
+ * \r
+ * 'prependRelativePath': (default null) if given, this string will be\r
+ * prepended to all relative URIs in import/url declarations\r
+ * \r
+ * 'currentDir': (default null) if given, this is assumed to be the\r
+ * directory of the current CSS file. Using this, minify will rewrite\r
+ * all relative URIs in import/url declarations to correctly point to\r
+ * the desired files. For this to work, the files *must* exist and be\r
+ * visible by the PHP process.\r
+ *\r
+ * 'symlinks': (default = array()) If the CSS file is stored in
+ * a symlink-ed directory, provide an array of link paths to
+ * target paths, where the link paths are within the document root. Because
+ * paths need to be normalized for this to work, use "//" to substitute
+ * the doc root in the link paths (the array keys). E.g.:
+ * <code>
+ * array('//symlink' => '/real/target/path') // unix
+ * array('//static' => 'D:\\staticStorage') // Windows
+ * </code>\r
+ * \r
+ * @return string\r
+ */\r
+ public static function minify($css, $options = array()) \r
+ {\r
+ require_once 'Minify/CSS/Compressor.php';\r
+ if (isset($options['preserveComments']) \r
+ && !$options['preserveComments']) {\r
+ $css = Minify_CSS_Compressor::process($css, $options);\r
+ } else {\r
+ require_once 'Minify/CommentPreserver.php';\r
+ $css = Minify_CommentPreserver::process(\r
+ $css\r
+ ,array('Minify_CSS_Compressor', 'process')\r
+ ,array($options)\r
+ );\r
+ }\r
+ if (! isset($options['currentDir']) && ! isset($options['prependRelativePath'])) {\r
+ return $css;\r
+ }\r
+ require_once 'Minify/CSS/UriRewriter.php';\r
+ if (isset($options['currentDir'])) {\r
+ return Minify_CSS_UriRewriter::rewrite(\r
+ $css\r
+ ,$options['currentDir']\r
+ ,isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT']\r
+ ,isset($options['symlinks']) ? $options['symlinks'] : array()\r
+ ); \r
+ } else {\r
+ return Minify_CSS_UriRewriter::prepend(\r
+ $css\r
+ ,$options['prependRelativePath']\r
+ );\r
+ }\r
+ }\r
+}\r
--- /dev/null
+<?php\r
+/**\r
+ * Class Minify_CSS_Compressor \r
+ * @package Minify\r
+ */\r
+\r
+/**\r
+ * Compress CSS\r
+ *\r
+ * This is a heavy regex-based removal of whitespace, unnecessary\r
+ * comments and tokens, and some CSS value minimization, where practical.\r
+ * Many steps have been taken to avoid breaking comment-based hacks, \r
+ * including the ie5/mac filter (and its inversion), but expect tricky\r
+ * hacks involving comment tokens in 'content' value strings to break\r
+ * minimization badly. A test suite is available.\r
+ * \r
+ * @package Minify\r
+ * @author Stephen Clay <steve@mrclay.org>\r
+ * @author http://code.google.com/u/1stvamp/ (Issue 64 patch)\r
+ */\r
+class Minify_CSS_Compressor {\r
+\r
+ /**\r
+ * Minify a CSS string\r
+ * \r
+ * @param string $css\r
+ * \r
+ * @param array $options (currently ignored)\r
+ * \r
+ * @return string\r
+ */\r
+ public static function process($css, $options = array())\r
+ {\r
+ $obj = new Minify_CSS_Compressor($options);\r
+ return $obj->_process($css);\r
+ }\r
+ \r
+ /**\r
+ * @var array options\r
+ */\r
+ protected $_options = null;\r
+ \r
+ /**\r
+ * @var bool Are we "in" a hack?\r
+ * \r
+ * I.e. are some browsers targetted until the next comment?\r
+ */\r
+ protected $_inHack = false;\r
+ \r
+ \r
+ /**\r
+ * Constructor\r
+ * \r
+ * @param array $options (currently ignored)\r
+ * \r
+ * @return null\r
+ */\r
+ private function __construct($options) {\r
+ $this->_options = $options;\r
+ }\r
+ \r
+ /**\r
+ * Minify a CSS string\r
+ * \r
+ * @param string $css\r
+ * \r
+ * @return string\r
+ */\r
+ protected function _process($css)\r
+ {\r
+ $css = str_replace("\r\n", "\n", $css);\r
+ \r
+ // preserve empty comment after '>'\r
+ // http://www.webdevout.net/css-hacks#in_css-selectors\r
+ $css = preg_replace('@>/\\*\\s*\\*/@', '>/*keep*/', $css);\r
+ \r
+ // preserve empty comment between property and value\r
+ // http://css-discuss.incutio.com/?page=BoxModelHack\r
+ $css = preg_replace('@/\\*\\s*\\*/\\s*:@', '/*keep*/:', $css);\r
+ $css = preg_replace('@:\\s*/\\*\\s*\\*/@', ':/*keep*/', $css);\r
+ \r
+ // apply callback to all valid comments (and strip out surrounding ws\r
+ $css = preg_replace_callback('@\\s*/\\*([\\s\\S]*?)\\*/\\s*@'\r
+ ,array($this, '_commentCB'), $css);\r
+\r
+ // remove ws around { } and last semicolon in declaration block\r
+ $css = preg_replace('/\\s*{\\s*/', '{', $css);\r
+ $css = preg_replace('/;?\\s*}\\s*/', '}', $css);\r
+ \r
+ // remove ws surrounding semicolons\r
+ $css = preg_replace('/\\s*;\\s*/', ';', $css);\r
+ \r
+ // remove ws around urls\r
+ $css = preg_replace('/\r
+ url\\( # url(\r
+ \\s*\r
+ ([^\\)]+?) # 1 = the URL (really just a bunch of non right parenthesis)\r
+ \\s*\r
+ \\) # )\r
+ /x', 'url($1)', $css);\r
+ \r
+ // remove ws between rules and colons\r
+ $css = preg_replace('/\r
+ \\s*\r
+ ([{;]) # 1 = beginning of block or rule separator \r
+ \\s*\r
+ ([\\*_]?[\\w\\-]+) # 2 = property (and maybe IE filter)\r
+ \\s*\r
+ :\r
+ \\s*\r
+ (\\b|[#\'"]) # 3 = first character of a value\r
+ /x', '$1$2:$3', $css);\r
+ \r
+ // remove ws in selectors\r
+ $css = preg_replace_callback('/\r
+ (?: # non-capture\r
+ \\s*\r
+ [^~>+,\\s]+ # selector part\r
+ \\s*\r
+ [,>+~] # combinators\r
+ )+\r
+ \\s*\r
+ [^~>+,\\s]+ # selector part\r
+ { # open declaration block\r
+ /x'\r
+ ,array($this, '_selectorsCB'), $css);\r
+ \r
+ // minimize hex colors\r
+ $css = preg_replace('/([^=])#([a-f\\d])\\2([a-f\\d])\\3([a-f\\d])\\4([\\s;\\}])/i'\r
+ , '$1#$2$3$4$5', $css);\r
+ \r
+ // remove spaces between font families\r
+ $css = preg_replace_callback('/font-family:([^;}]+)([;}])/'\r
+ ,array($this, '_fontFamilyCB'), $css);\r
+ \r
+ $css = preg_replace('/@import\\s+url/', '@import url', $css);\r
+ \r
+ // replace any ws involving newlines with a single newline\r
+ $css = preg_replace('/[ \\t]*\\n+\\s*/', "\n", $css);\r
+ \r
+ // separate common descendent selectors w/ newlines (to limit line lengths)\r
+ $css = preg_replace('/([\\w#\\.\\*]+)\\s+([\\w#\\.\\*]+){/', "$1\n$2{", $css);\r
+ \r
+ // Use newline after 1st numeric value (to limit line lengths).\r
+ $css = preg_replace('/\r
+ ((?:padding|margin|border|outline):\\d+(?:px|em)?) # 1 = prop : 1st numeric value\r
+ \\s+\r
+ /x'\r
+ ,"$1\n", $css);\r
+ \r
+ // prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/\r
+ $css = preg_replace('/:first-l(etter|ine)\\{/', ':first-l$1 {', $css);\r
+ \r
+ return trim($css);\r
+ }\r
+ \r
+ /**\r
+ * Replace what looks like a set of selectors \r
+ *\r
+ * @param array $m regex matches\r
+ * \r
+ * @return string\r
+ */\r
+ protected function _selectorsCB($m)\r
+ {\r
+ // remove ws around the combinators\r
+ return preg_replace('/\\s*([,>+~])\\s*/', '$1', $m[0]);\r
+ }\r
+ \r
+ /**\r
+ * Process a comment and return a replacement\r
+ * \r
+ * @param array $m regex matches\r
+ * \r
+ * @return string\r
+ */\r
+ protected function _commentCB($m)\r
+ {\r
+ $hasSurroundingWs = (trim($m[0]) !== $m[1]);\r
+ $m = $m[1]; \r
+ // $m is the comment content w/o the surrounding tokens, \r
+ // but the return value will replace the entire comment.\r
+ if ($m === 'keep') {\r
+ return '/**/';\r
+ }\r
+ if ($m === '" "') {\r
+ // component of http://tantek.com/CSS/Examples/midpass.html\r
+ return '/*" "*/';\r
+ }\r
+ if (preg_match('@";\\}\\s*\\}/\\*\\s+@', $m)) {\r
+ // component of http://tantek.com/CSS/Examples/midpass.html\r
+ return '/*";}}/* */';\r
+ }\r
+ if ($this->_inHack) {\r
+ // inversion: feeding only to one browser\r
+ if (preg_match('@\r
+ ^/ # comment started like /*/\r
+ \\s*\r
+ (\\S[\\s\\S]+?) # has at least some non-ws content\r
+ \\s*\r
+ /\\* # ends like /*/ or /**/\r
+ @x', $m, $n)) {\r
+ // end hack mode after this comment, but preserve the hack and comment content\r
+ $this->_inHack = false;\r
+ return "/*/{$n[1]}/**/";\r
+ }\r
+ }\r
+ if (substr($m, -1) === '\\') { // comment ends like \*/\r
+ // begin hack mode and preserve hack\r
+ $this->_inHack = true;\r
+ return '/*\\*/';\r
+ }\r
+ if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */\r
+ // begin hack mode and preserve hack\r
+ $this->_inHack = true;\r
+ return '/*/*/';\r
+ }\r
+ if ($this->_inHack) {\r
+ // a regular comment ends hack mode but should be preserved\r
+ $this->_inHack = false;\r
+ return '/**/';\r
+ }\r
+ // Issue 107: if there's any surrounding whitespace, it may be important, so \r
+ // replace the comment with a single space\r
+ return $hasSurroundingWs // remove all other comments\r
+ ? ' '\r
+ : '';\r
+ }\r
+ \r
+ /**\r
+ * Process a font-family listing and return a replacement\r
+ * \r
+ * @param array $m regex matches\r
+ * \r
+ * @return string \r
+ */\r
+ protected function _fontFamilyCB($m)\r
+ {\r
+ $m[1] = preg_replace('/\r
+ \\s*\r
+ (\r
+ "[^"]+" # 1 = family in double qutoes\r
+ |\'[^\']+\' # or 1 = family in single quotes\r
+ |[\\w\\-]+ # or 1 = unquoted family\r
+ )\r
+ \\s*\r
+ /x', '$1', $m[1]);\r
+ return 'font-family:' . $m[1] . $m[2];\r
+ }\r
+}\r
--- /dev/null
+<?php
+/**
+ * Class Minify_CSS_UriRewriter
+ * @package Minify
+ */
+
+/**
+ * Rewrite file-relative URIs as root-relative in CSS files
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_CSS_UriRewriter {
+
+ /**
+ * Defines which class to call as part of callbacks, change this
+ * if you extend Minify_CSS_UriRewriter
+ * @var string
+ */
+ protected static $className = 'Minify_CSS_UriRewriter';
+
+ /**
+ * rewrite() and rewriteRelative() append debugging information here
+ * @var string
+ */
+ public static $debugText = '';
+
+ /**
+ * Rewrite file relative URIs as root relative in CSS files
+ *
+ * @param string $css
+ *
+ * @param string $currentDir The directory of the current CSS file.
+ *
+ * @param string $docRoot The document root of the web site in which
+ * the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
+ *
+ * @param array $symlinks (default = array()) If the CSS file is stored in
+ * a symlink-ed directory, provide an array of link paths to
+ * target paths, where the link paths are within the document root. Because
+ * paths need to be normalized for this to work, use "//" to substitute
+ * the doc root in the link paths (the array keys). E.g.:
+ * <code>
+ * array('//symlink' => '/real/target/path') // unix
+ * array('//static' => 'D:\\staticStorage') // Windows
+ * </code>
+ *
+ * @return string
+ */
+ public static function rewrite($css, $currentDir, $docRoot = null, $symlinks = array())
+ {
+ self::$_docRoot = self::_realpath(
+ $docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT']
+ );
+ self::$_currentDir = self::_realpath($currentDir);
+ self::$_symlinks = array();
+
+ // normalize symlinks
+ foreach ($symlinks as $link => $target) {
+ $link = ($link === '//')
+ ? self::$_docRoot
+ : str_replace('//', self::$_docRoot . '/', $link);
+ $link = strtr($link, '/', DIRECTORY_SEPARATOR);
+ self::$_symlinks[$link] = self::_realpath($target);
+ }
+
+ self::$debugText .= "docRoot : " . self::$_docRoot . "\n"
+ . "currentDir : " . self::$_currentDir . "\n";
+ if (self::$_symlinks) {
+ self::$debugText .= "symlinks : " . var_export(self::$_symlinks, 1) . "\n";
+ }
+ self::$debugText .= "\n";
+
+ $css = self::_trimUrls($css);
+
+ // rewrite
+ $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
+ ,array(self::$className, '_processUriCB'), $css);
+ $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
+ ,array(self::$className, '_processUriCB'), $css);
+
+ return $css;
+ }
+
+ /**
+ * Prepend a path to relative URIs in CSS files
+ *
+ * @param string $css
+ *
+ * @param string $path The path to prepend.
+ *
+ * @return string
+ */
+ public static function prepend($css, $path)
+ {
+ self::$_prependPath = $path;
+
+ $css = self::_trimUrls($css);
+
+ // append
+ $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
+ ,array(self::$className, '_processUriCB'), $css);
+ $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
+ ,array(self::$className, '_processUriCB'), $css);
+
+ self::$_prependPath = null;
+ return $css;
+ }
+
+
+ /**
+ * @var string directory of this stylesheet
+ */
+ private static $_currentDir = '';
+
+ /**
+ * @var string DOC_ROOT
+ */
+ private static $_docRoot = '';
+
+ /**\r
+ * @var array directory replacements to map symlink targets back to their\r
+ * source (within the document root) E.g. '/var/www/symlink' => '/var/realpath'\r
+ */
+ private static $_symlinks = array();
+
+ /**
+ * @var string path to prepend
+ */
+ private static $_prependPath = null;
+
+ private static function _trimUrls($css)
+ {
+ return preg_replace('/
+ url\\( # url(
+ \\s*
+ ([^\\)]+?) # 1 = URI (assuming does not contain ")")
+ \\s*
+ \\) # )
+ /x', 'url($1)', $css);
+ }
+
+ private static function _processUriCB($m)
+ {
+ // $m matched either '/@import\\s+([\'"])(.*?)[\'"]/' or '/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
+ $isImport = ($m[0][0] === '@');
+ // determine URI and the quote character (if any)
+ if ($isImport) {
+ $quoteChar = $m[1];
+ $uri = $m[2];
+ } else {
+ // $m[1] is either quoted or not
+ $quoteChar = ($m[1][0] === "'" || $m[1][0] === '"')
+ ? $m[1][0]
+ : '';
+ $uri = ($quoteChar === '')
+ ? $m[1]
+ : substr($m[1], 1, strlen($m[1]) - 2);
+ }
+ // analyze URI
+ if ('/' !== $uri[0] // root-relative
+ && false === strpos($uri, '//') // protocol (non-data)
+ && 0 !== strpos($uri, 'data:') // data protocol
+ ) {
+ // URI is file-relative: rewrite depending on options
+ $uri = (self::$_prependPath !== null)
+ ? (self::$_prependPath . $uri)
+ : self::rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks);
+ }
+ return $isImport
+ ? "@import {$quoteChar}{$uri}{$quoteChar}"
+ : "url({$quoteChar}{$uri}{$quoteChar})";
+ }
+
+ /**
+ * Rewrite a file relative URI as root relative
+ *
+ * <code>
+ * Minify_CSS_UriRewriter::rewriteRelative(
+ * '../img/hello.gif'
+ * , '/home/user/www/css' // path of CSS file
+ * , '/home/user/www' // doc root
+ * );
+ * // returns '/img/hello.gif'
+ *
+ * // example where static files are stored in a symlinked directory
+ * Minify_CSS_UriRewriter::rewriteRelative(
+ * 'hello.gif'
+ * , '/var/staticFiles/theme'
+ * , '/home/user/www'
+ * , array('/home/user/www/static' => '/var/staticFiles')
+ * );
+ * // returns '/static/theme/hello.gif'
+ * </code>
+ *
+ * @param string $uri file relative URI
+ *
+ * @param string $realCurrentDir realpath of the current file's directory.
+ *
+ * @param string $realDocRoot realpath of the site document root.
+ *
+ * @param array $symlinks (default = array()) If the file is stored in
+ * a symlink-ed directory, provide an array of link paths to
+ * real target paths, where the link paths "appear" to be within the document
+ * root. E.g.:
+ * <code>
+ * array('/home/foo/www/not/real/path' => '/real/target/path') // unix
+ * array('C:\\htdocs\\not\\real' => 'D:\\real\\target\\path') // Windows
+ * </code>
+ *
+ * @return string
+ */
+ public static function rewriteRelative($uri, $realCurrentDir, $realDocRoot, $symlinks = array())
+ {
+ // prepend path with current dir separator (OS-independent)
+ $path = strtr($realCurrentDir, '/', DIRECTORY_SEPARATOR)
+ . DIRECTORY_SEPARATOR . strtr($uri, '/', DIRECTORY_SEPARATOR);
+
+ self::$debugText .= "file-relative URI : {$uri}\n"
+ . "path prepended : {$path}\n";
+
+ // "unresolve" a symlink back to doc root\r
+ foreach ($symlinks as $link => $target) {\r
+ if (0 === strpos($path, $target)) {\r
+ // replace $target with $link\r
+ $path = $link . substr($path, strlen($target));
+
+ self::$debugText .= "symlink unresolved : {$path}\n";\r
+
+ break;\r
+ }\r
+ }
+ // strip doc root
+ $path = substr($path, strlen($realDocRoot));
+
+ self::$debugText .= "docroot stripped : {$path}\n";
+
+ // fix to root-relative URI
+
+ $uri = strtr($path, '/\\', '//');
+
+ // remove /./ and /../ where possible
+ $uri = str_replace('/./', '/', $uri);
+ // inspired by patch from Oleg Cherniy
+ do {
+ $uri = preg_replace('@/[^/]+/\\.\\./@', '/', $uri, 1, $changed);
+ } while ($changed);
+
+ self::$debugText .= "traversals removed : {$uri}\n\n";
+
+ return $uri;
+ }
+
+ /**
+ * Get realpath with any trailing slash removed. If realpath() fails,
+ * just remove the trailing slash.
+ *
+ * @param string $path
+ *
+ * @return mixed path with no trailing slash
+ */
+ protected static function _realpath($path)
+ {
+ $realPath = realpath($path);
+ if ($realPath !== false) {
+ $path = $realPath;
+ }
+ return rtrim($path, '/\\');
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_Cache_APC
+ * @package Minify
+ */
+
+/**
+ * APC-based cache class for Minify
+ *
+ * <code>
+ * Minify::setCache(new Minify_Cache_APC());
+ * </code>
+ *
+ * @package Minify
+ * @author Chris Edwards
+ **/
+class Minify_Cache_APC {
+
+ /**
+ * Create a Minify_Cache_APC object, to be passed to
+ * Minify::setCache().
+ *
+ *
+ * @param int $expire seconds until expiration (default = 0
+ * meaning the item will not get an expiration date)
+ *
+ * @return null
+ */
+ public function __construct($expire = 0)
+ {
+ $this->_exp = $expire;
+ }
+
+ /**
+ * Write data to cache.
+ *
+ * @param string $id cache id
+ *
+ * @param string $data
+ *
+ * @return bool success
+ */
+ public function store($id, $data)
+ {
+ return apc_store($id, "{$_SERVER['REQUEST_TIME']}|{$data}", $this->_exp);
+ }
+
+ /**
+ * Get the size of a cache entry
+ *
+ * @param string $id cache id
+ *
+ * @return int size in bytes
+ */
+ public function getSize($id)
+ {
+ return $this->_fetch($id)
+ ? strlen($this->_data)
+ : false;
+ }
+
+ /**
+ * Does a valid cache entry exist?
+ *
+ * @param string $id cache id
+ *
+ * @param int $srcMtime mtime of the original source file(s)
+ *
+ * @return bool exists
+ */
+ public function isValid($id, $srcMtime)
+ {
+ return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
+ }
+
+ /**
+ * Send the cached content to output
+ *
+ * @param string $id cache id
+ */
+ public function display($id)
+ {
+ echo $this->_fetch($id)
+ ? $this->_data
+ : '';
+ }
+
+ /**
+ * Fetch the cached content
+ *
+ * @param string $id cache id
+ *
+ * @return string
+ */
+ public function fetch($id)
+ {
+ return $this->_fetch($id)
+ ? $this->_data
+ : '';
+ }
+
+ private $_exp = null;
+
+ // cache of most recently fetched id
+ private $_lm = null;
+ private $_data = null;
+ private $_id = null;
+
+ /**
+ * Fetch data and timestamp from apc, store in instance
+ *
+ * @param string $id
+ *
+ * @return bool success
+ */
+ private function _fetch($id)
+ {
+ if ($this->_id === $id) {
+ return true;
+ }
+ $ret = apc_fetch($id);
+ if (false === $ret) {
+ $this->_id = null;
+ return false;
+ }
+ list($this->_lm, $this->_data) = explode('|', $ret, 2);
+ $this->_id = $id;
+ return true;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_Cache_File
+ * @package Minify
+ */
+
+class Minify_Cache_File {
+
+ public function __construct($path = '', $fileLocking = false)
+ {
+ if (! $path) {
+ require_once 'Solar/Dir.php';
+ $path = rtrim(Solar_Dir::tmp(), DIRECTORY_SEPARATOR);
+ }\r
+ $this->_locking = $fileLocking;
+ $this->_path = $path;
+ }
+
+ /**
+ * Write data to cache.
+ *
+ * @param string $id cache id (e.g. a filename)
+ *
+ * @param string $data
+ *
+ * @return bool success
+ */
+ public function store($id, $data)
+ {
+ $flag = $this->_locking\r
+ ? LOCK_EX\r
+ : null;\r
+ if (is_file($this->_path . '/' . $id)) {\r
+ @unlink($this->_path . '/' . $id);\r
+ }\r
+ if (! @file_put_contents($this->_path . '/' . $id, $data, $flag)) {\r
+ return false;\r
+ }
+ // write control\r
+ if ($data !== $this->fetch($id)) {\r
+ @unlink($file);\r
+ return false;\r
+ }\r
+ return true;
+ }
+
+ /**
+ * Get the size of a cache entry
+ *
+ * @param string $id cache id (e.g. a filename)
+ *
+ * @return int size in bytes
+ */
+ public function getSize($id)
+ {
+ return filesize($this->_path . '/' . $id);
+ }
+
+ /**
+ * Does a valid cache entry exist?
+ *
+ * @param string $id cache id (e.g. a filename)
+ *
+ * @param int $srcMtime mtime of the original source file(s)
+ *
+ * @return bool exists
+ */
+ public function isValid($id, $srcMtime)
+ {
+ $file = $this->_path . '/' . $id;
+ return (is_file($file) && (filemtime($file) >= $srcMtime));
+ }
+
+ /**
+ * Send the cached content to output
+ *
+ * @param string $id cache id (e.g. a filename)
+ */
+ public function display($id)
+ {
+ if ($this->_locking) {\r
+ $fp = fopen($this->_path . '/' . $id, 'rb');\r
+ flock($fp, LOCK_SH);\r
+ fpassthru($fp);\r
+ flock($fp, LOCK_UN);\r
+ fclose($fp);\r
+ } else {\r
+ readfile($this->_path . '/' . $id); \r
+ }\r
+ }
+
+ /**
+ * Fetch the cached content
+ *
+ * @param string $id cache id (e.g. a filename)
+ *
+ * @return string
+ */
+ public function fetch($id)
+ {
+ if ($this->_locking) {\r
+ $fp = fopen($this->_path . '/' . $id, 'rb');\r
+ flock($fp, LOCK_SH);\r
+ $ret = stream_get_contents($fp);\r
+ flock($fp, LOCK_UN);\r
+ fclose($fp);\r
+ return $ret;\r
+ } else {\r
+ return file_get_contents($this->_path . '/' . $id);\r
+ }
+ }
+
+ /**
+ * Fetch the cache path used
+ *
+ * @return string
+ */
+ public function getPath()
+ {
+ return $this->_path;
+ }
+
+ private $_path = null;
+ private $_locking = null;\r
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_Cache_Memcache
+ * @package Minify
+ */
+
+/**
+ * Memcache-based cache class for Minify
+ *
+ * <code>
+ * // fall back to disk caching if memcache can't connect
+ * $memcache = new Memcache;
+ * if ($memcache->connect('localhost', 11211)) {
+ * Minify::setCache(new Minify_Cache_Memcache($memcache));
+ * } else {
+ * Minify::setCache();
+ * }
+ * </code>
+ **/
+class Minify_Cache_Memcache {
+
+ /**
+ * Create a Minify_Cache_Memcache object, to be passed to
+ * Minify::setCache().
+ *
+ * @param Memcache $memcache already-connected instance
+ *
+ * @param int $expire seconds until expiration (default = 0
+ * meaning the item will not get an expiration date)
+ *
+ * @return null
+ */
+ public function __construct($memcache, $expire = 0)
+ {
+ $this->_mc = $memcache;
+ $this->_exp = $expire;
+ }
+
+ /**
+ * Write data to cache.
+ *
+ * @param string $id cache id
+ *
+ * @param string $data
+ *
+ * @return bool success
+ */
+ public function store($id, $data)
+ {
+ return $this->_mc->set($id, "{$_SERVER['REQUEST_TIME']}|{$data}", 0, $this->_exp);
+ }
+
+
+ /**
+ * Get the size of a cache entry
+ *
+ * @param string $id cache id
+ *
+ * @return int size in bytes
+ */
+ public function getSize($id)
+ {
+ return $this->_fetch($id)
+ ? strlen($this->_data)
+ : false;
+ }
+
+ /**
+ * Does a valid cache entry exist?
+ *
+ * @param string $id cache id
+ *
+ * @param int $srcMtime mtime of the original source file(s)
+ *
+ * @return bool exists
+ */
+ public function isValid($id, $srcMtime)
+ {
+ return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
+ }
+
+ /**
+ * Send the cached content to output
+ *
+ * @param string $id cache id
+ */
+ public function display($id)
+ {
+ echo $this->_fetch($id)
+ ? $this->_data
+ : '';
+ }
+
+ /**
+ * Fetch the cached content
+ *
+ * @param string $id cache id
+ *
+ * @return string
+ */
+ public function fetch($id)
+ {
+ return $this->_fetch($id)
+ ? $this->_data
+ : '';
+ }
+
+ private $_mc = null;
+ private $_exp = null;
+
+ // cache of most recently fetched id
+ private $_lm = null;
+ private $_data = null;
+ private $_id = null;
+
+ /**
+ * Fetch data and timestamp from memcache, store in instance
+ *
+ * @param string $id
+ *
+ * @return bool success
+ */
+ private function _fetch($id)
+ {
+ if ($this->_id === $id) {
+ return true;
+ }
+ $ret = $this->_mc->get($id);
+ if (false === $ret) {
+ $this->_id = null;
+ return false;
+ }
+ list($this->_lm, $this->_data) = explode('|', $ret, 2);
+ $this->_id = $id;
+ return true;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_CommentPreserver
+ * @package Minify
+ */
+
+/**
+ * Process a string in pieces preserving C-style comments that begin with "/*!"
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_CommentPreserver {
+
+ /**
+ * String to be prepended to each preserved comment
+ *
+ * @var string
+ */
+ public static $prepend = "\n";
+
+ /**
+ * String to be appended to each preserved comment
+ *
+ * @var string
+ */
+ public static $append = "\n";
+
+ /**
+ * Process a string outside of C-style comments that begin with "/*!"
+ *
+ * On each non-empty string outside these comments, the given processor
+ * function will be called. The first "!" will be removed from the
+ * preserved comments, and the comments will be surrounded by
+ * Minify_CommentPreserver::$preprend and Minify_CommentPreserver::$append.
+ *
+ * @param string $content
+ * @param callback $processor function
+ * @param array $args array of extra arguments to pass to the processor
+ * function (default = array())
+ * @return string
+ */
+ public static function process($content, $processor, $args = array())
+ {
+ $ret = '';
+ while (true) {
+ list($beforeComment, $comment, $afterComment) = self::_nextComment($content);
+ if ('' !== $beforeComment) {
+ $callArgs = $args;
+ array_unshift($callArgs, $beforeComment);
+ $ret .= call_user_func_array($processor, $callArgs);
+ }
+ if (false === $comment) {
+ break;
+ }
+ $ret .= $comment;
+ $content = $afterComment;
+ }
+ return $ret;
+ }
+
+ /**
+ * Extract comments that YUI Compressor preserves.
+ *
+ * @param string $in input
+ *
+ * @return array 3 elements are returned. If a YUI comment is found, the
+ * 2nd element is the comment and the 1st and 2nd are the surrounding
+ * strings. If no comment is found, the entire string is returned as the
+ * 1st element and the other two are false.
+ */
+ private static function _nextComment($in)
+ {
+ if (
+ false === ($start = strpos($in, '/*!'))
+ || false === ($end = strpos($in, '*/', $start + 3))
+ ) {
+ return array($in, false, false);
+ }
+ $ret = array(
+ substr($in, 0, $start)
+ ,self::$prepend . '/*' . substr($in, $start + 3, $end - $start - 1) . self::$append
+ );
+ $endChars = (strlen($in) - $end - 2);
+ $ret[] = (0 === $endChars)
+ ? ''
+ : substr($in, -$endChars);
+ return $ret;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_Controller_Base
+ * @package Minify
+ */
+
+/**
+ * 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.
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+abstract class Minify_Controller_Base {
+
+ /**
+ * Setup controller sources and set an needed options for Minify::source
+ *
+ * You must override this method in your subclass controller to set
+ * $this->sources. If the request is NOT valid, make sure $this->sources
+ * is left an empty array. Then strip any controller-specific options from
+ * $options and return it. To serve files, $this->sources must be an array of
+ * Minify_Source objects.
+ *
+ * @param array $options controller and Minify options
+ *
+ * return array $options Minify::serve options
+ */
+ abstract public function setupSources($options);
+
+ /**
+ * Get default Minify options for this controller.
+ *
+ * Override in subclass to change defaults
+ *
+ * @return array options for Minify
+ */
+ public function getDefaultMinifyOptions() {
+ return array(
+ 'isPublic' => true
+ ,'encodeOutput' => function_exists('gzdeflate')
+ ,'encodeMethod' => null // determine later
+ ,'encodeLevel' => 9
+ ,'minifierOptions' => array() // no minifier options
+ ,'contentTypeCharset' => 'utf-8'
+ ,'maxAge' => 1800 // 30 minutes
+ ,'rewriteCssUris' => true
+ ,'bubbleCssImports' => false
+ ,'quiet' => false // serve() will send headers and output
+ ,'debug' => false
+
+ // if you override this, the response code MUST be directly after
+ // the first space.
+ ,'badRequestHeader' => 'HTTP/1.0 400 Bad Request'
+
+ // callback function to see/modify content of all sources
+ ,'postprocessor' => null
+ // file to require to load preprocessor
+ ,'postprocessorRequire' => null
+ );
+ }
+
+ /**
+ * Get default minifiers for this controller.
+ *
+ * Override in subclass to change defaults
+ *
+ * @return array minifier callbacks for common types
+ */
+ public function getDefaultMinifers() {
+ $ret[Minify::TYPE_JS] = array('JSMin', 'minify');
+ $ret[Minify::TYPE_CSS] = array('Minify_CSS', 'minify');
+ $ret[Minify::TYPE_HTML] = array('Minify_HTML', 'minify');
+ return $ret;
+ }
+
+ /**
+ * Load any code necessary to execute the given minifier callback.
+ *
+ * The controller is responsible for loading minification code on demand
+ * via this method. This built-in function will only load classes for
+ * static method callbacks where the class isn't already defined. It uses
+ * the PEAR convention, so, given array('Jimmy_Minifier', 'minCss'), this
+ * function will include 'Jimmy/Minifier.php'.
+ *
+ * If you need code loaded on demand and this doesn't suit you, you'll need
+ * to override this function in your subclass.
+ * @see Minify_Controller_Page::loadMinifier()
+ *
+ * @param callback $minifierCallback callback of minifier function
+ *
+ * @return null
+ */
+ public function loadMinifier($minifierCallback)
+ {
+ if (is_array($minifierCallback)
+ && is_string($minifierCallback[0])
+ && !class_exists($minifierCallback[0], false)) {
+
+ require str_replace('_', '/', $minifierCallback[0]) . '.php';
+ }
+ }
+
+ /**
+ * Is a user-given file within an allowable directory, existing,
+ * and having an extension js/css/html/txt ?
+ *
+ * This is a convenience function for controllers that have to accept
+ * user-given paths
+ *
+ * @param string $file full file path (already processed by realpath())
+ *
+ * @param array $safeDirs directories where files are safe to serve. Files can also
+ * be in subdirectories of these directories.
+ *
+ * @return bool file is safe
+ */
+ public static function _fileIsSafe($file, $safeDirs)
+ {
+ $pathOk = false;
+ foreach ((array)$safeDirs as $safeDir) {
+ if (strpos($file, $safeDir) === 0) {
+ $pathOk = true;
+ break;
+ }
+ }
+ $base = basename($file);
+ if (! $pathOk || ! is_file($file) || $base[0] === '.') {
+ return false;
+ }
+ list($revExt) = explode('.', strrev($base));
+ return in_array(strrev($revExt), array('js', 'css', 'html', 'txt'));
+ }
+
+ /**
+ * @var array instances of Minify_Source, which provide content and
+ * any individual minification needs.
+ *
+ * @see Minify_Source
+ */
+ public $sources = array();
+
+ /**
+ * Mix in default controller options with user-given options
+ *
+ * @param array $options user options
+ *
+ * @return array mixed options
+ */
+ public final function mixInDefaultOptions($options)
+ {
+ $ret = array_merge(
+ $this->getDefaultMinifyOptions(), $options
+ );
+ if (! isset($options['minifiers'])) {
+ $options['minifiers'] = array();
+ }
+ $ret['minifiers'] = array_merge(
+ $this->getDefaultMinifers(), $options['minifiers']
+ );
+ return $ret;
+ }
+
+ /**
+ * Analyze sources (if there are any) and set $options 'contentType'
+ * and 'lastModifiedTime' if they already aren't.
+ *
+ * @param array $options options for Minify
+ *
+ * @return array options for Minify
+ */
+ public final function analyzeSources($options = array())
+ {
+ if ($this->sources) {
+ if (! isset($options['contentType'])) {
+ $options['contentType'] = Minify_Source::getContentType($this->sources);
+ }
+ // last modified is needed for caching, even if setExpires is set
+ if (! isset($options['lastModifiedTime'])) {
+ $max = 0;
+ foreach ($this->sources as $source) {
+ $max = max($source->lastModified, $max);
+ }
+ $options['lastModifiedTime'] = $max;
+ }
+ }
+ return $options;
+ }
+
+ /**
+ * Send message to the Minify logger
+ * @param string $msg
+ * @return null
+ */
+ protected function log($msg) {
+ require_once 'Minify/Logger.php';
+ Minify_Logger::log($msg);
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_Controller_Files
+ * @package Minify
+ */
+
+require_once 'Minify/Controller/Base.php';
+
+/**
+ * Controller class for minifying a set of files
+ *
+ * E.g. the following would serve the minified Javascript for a site
+ * <code>
+ * Minify::serve('Files', array(
+ * 'files' => array(
+ * '//js/jquery.js'
+ * ,'//js/plugins.js'
+ * ,'/home/username/file.js'
+ * )
+ * ));
+ * </code>
+ *
+ * As a shortcut, the controller will replace "//" at the beginning
+ * of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'.
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_Controller_Files extends Minify_Controller_Base {
+
+ /**
+ * Set up file sources
+ *
+ * @param array $options controller and Minify options
+ * @return array Minify options
+ *
+ * Controller options:
+ *
+ * 'files': (required) array of complete file paths, or a single path
+ */
+ public function setupSources($options) {
+ // strip controller options
+
+ $files = $options['files'];
+ // if $files is a single object, casting will break it
+ if (is_object($files)) {
+ $files = array($files);
+ } elseif (! is_array($files)) {
+ $files = (array)$files;
+ }
+ unset($options['files']);
+
+ $sources = array();
+ foreach ($files as $file) {
+ if ($file instanceof Minify_Source) {
+ $sources[] = $file;
+ continue;
+ }
+ if (0 === strpos($file, '//')) {
+ $file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
+ }
+ $realPath = realpath($file);
+ if (is_file($realPath)) {
+ $sources[] = new Minify_Source(array(
+ 'filepath' => $realPath
+ ));
+ } else {
+ $this->log("The path \"{$file}\" could not be found (or was not a file)");
+ return $options;
+ }
+ }
+ if ($sources) {
+ $this->sources = $sources;
+ }
+ return $options;
+ }
+}
+
--- /dev/null
+<?php
+/**
+ * Class Minify_Controller_Groups
+ * @package Minify
+ */
+
+require_once 'Minify/Controller/Base.php';
+
+/**
+ * Controller class for serving predetermined groups of minimized sets, selected
+ * by PATH_INFO
+ *
+ * <code>
+ * Minify::serve('Groups', array(
+ * 'groups' => array(
+ * 'css' => array('//css/type.css', '//css/layout.css')
+ * ,'js' => array('//js/jquery.js', '//js/site.js')
+ * )
+ * ));
+ * </code>
+ *
+ * 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'] . '/'.
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_Controller_Groups extends Minify_Controller_Base {
+
+ /**
+ * Set up groups of files as sources
+ *
+ * @param array $options controller and Minify options
+ * @return array Minify options
+ *
+ * Controller options:
+ *
+ * 'groups': (required) array mapping PATH_INFO strings to arrays
+ * of complete file paths. @see Minify_Controller_Groups
+ */
+ public function setupSources($options) {
+ // strip controller options
+ $groups = $options['groups'];
+ unset($options['groups']);
+
+ // mod_fcgid places PATH_INFO in ORIG_PATH_INFO
+ $pi = isset($_SERVER['ORIG_PATH_INFO'])
+ ? substr($_SERVER['ORIG_PATH_INFO'], 1)
+ : (isset($_SERVER['PATH_INFO'])
+ ? substr($_SERVER['PATH_INFO'], 1)
+ : false
+ );
+ if (false === $pi || ! isset($groups[$pi])) {
+ // no PATH_INFO or not a valid group
+ $this->log("Missing PATH_INFO or no group set for \"$pi\"");
+ return $options;
+ }
+ $sources = array();
+
+ $files = $groups[$pi];
+ // if $files is a single object, casting will break it
+ if (is_object($files)) {
+ $files = array($files);
+ } elseif (! is_array($files)) {
+ $files = (array)$files;
+ }
+ foreach ($files as $file) {
+ if ($file instanceof Minify_Source) {
+ $sources[] = $file;
+ continue;
+ }
+ if (0 === strpos($file, '//')) {
+ $file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
+ }
+ $realPath = realpath($file);
+ if (is_file($realPath)) {
+ $sources[] = new Minify_Source(array(
+ 'filepath' => $realPath
+ ));
+ } else {
+ $this->log("The path \"{$file}\" could not be found (or was not a file)");
+ return $options;
+ }
+ }
+ if ($sources) {
+ $this->sources = $sources;
+ }
+ return $options;
+ }
+}
+
--- /dev/null
+<?php
+/**
+ * Class Minify_Controller_MinApp
+ * @package Minify
+ */
+
+require_once 'Minify/Controller/Base.php';
+
+/**
+ * Controller class for requests to /min/index.php
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_Controller_MinApp extends Minify_Controller_Base {
+
+ /**
+ * Set up groups of files as sources
+ *
+ * @param array $options controller and Minify options
+ * @return array Minify options
+ *
+ */
+ public function setupSources($options) {
+ // filter controller options
+ $cOptions = array_merge(
+ array(
+ 'allowDirs' => '//'
+ ,'groupsOnly' => false
+ ,'groups' => array()
+ ,'maxFiles' => 10
+ )
+ ,(isset($options['minApp']) ? $options['minApp'] : array())
+ );
+ unset($options['minApp']);
+ $sources = array();
+ if (isset($_GET['g'])) {
+ // try groups
+ if (! isset($cOptions['groups'][$_GET['g']])) {
+ $this->log("A group configuration for \"{$_GET['g']}\" was not set");
+ return $options;
+ }
+
+ $files = $cOptions['groups'][$_GET['g']];
+ // if $files is a single object, casting will break it
+ if (is_object($files)) {
+ $files = array($files);
+ } elseif (! is_array($files)) {
+ $files = (array)$files;
+ }
+ foreach ($files as $file) {
+ if ($file instanceof Minify_Source) {
+ $sources[] = $file;
+ continue;
+ }
+ if (0 === strpos($file, '//')) {
+ $file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
+ }
+ $file = realpath($file);
+ if (is_file($file)) {
+ $sources[] = new Minify_Source(array(
+ 'filepath' => $file
+ ));
+ } else {
+ $this->log("The path \"{$file}\" could not be found (or was not a file)");
+ return $options;
+ }
+ }
+ } elseif (! $cOptions['groupsOnly'] && isset($_GET['f'])) {
+ // try user files
+ // The following restrictions are to limit the URLs that minify will
+ // respond to. Ideally there should be only one way to reference a file.
+ if (// verify at least one file, files are single comma separated,
+ // and are all same extension
+ ! preg_match('/^[^,]+\\.(css|js)(?:,[^,]+\\.\\1)*$/', $_GET['f'])
+ // no "//"
+ || strpos($_GET['f'], '//') !== false
+ // no "\"
+ || strpos($_GET['f'], '\\') !== false
+ // no "./"
+ || preg_match('/(?:^|[^\\.])\\.\\//', $_GET['f'])
+ ) {
+ $this->log("GET param 'f' invalid (see MinApp.php line 63)");
+ return $options;
+ }
+ $files = explode(',', $_GET['f']);
+ if (count($files) > $cOptions['maxFiles'] || $files != array_unique($files)) {
+ $this->log("Too many or duplicate files specified");
+ return $options;
+ }
+ if (isset($_GET['b'])) {
+ // check for validity
+ if (preg_match('@^[^/]+(?:/[^/]+)*$@', $_GET['b'])
+ && false === strpos($_GET['b'], '..')
+ && $_GET['b'] !== '.') {
+ // valid base
+ $base = "/{$_GET['b']}/";
+ } else {
+ $this->log("GET param 'b' invalid (see MinApp.php line 84)");
+ return $options;
+ }
+ } else {
+ $base = '/';
+ }
+ $allowDirs = array();
+ foreach ((array)$cOptions['allowDirs'] as $allowDir) {
+ $allowDirs[] = realpath(str_replace('//', $_SERVER['DOCUMENT_ROOT'] . '/', $allowDir));
+ }
+ foreach ($files as $file) {
+ $path = $_SERVER['DOCUMENT_ROOT'] . $base . $file;
+ $file = realpath($path);
+ if (false === $file) {
+ $this->log("Path \"{$path}\" failed realpath()");
+ return $options;
+ } elseif (! parent::_fileIsSafe($file, $allowDirs)) {
+ $this->log("Path \"{$path}\" failed Minify_Controller_Base::_fileIsSafe()");
+ return $options;
+ } else {
+ $sources[] = new Minify_Source(array(
+ 'filepath' => $file
+ ));
+ }
+ }
+ }
+ if ($sources) {
+ $this->sources = $sources;
+ } else {
+ $this->log("No sources to serve");
+ }
+ return $options;
+ }
+}
--- /dev/null
+<?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
+ }
+}
+
--- /dev/null
+<?php
+/**
+ * Class Minify_Controller_Version1
+ * @package Minify
+ */
+
+require_once 'Minify/Controller/Base.php';
+
+/**
+ * Controller class for emulating version 1 of minify.php
+ *
+ * <code>
+ * Minify::serve('Version1');
+ * </code>
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_Controller_Version1 extends Minify_Controller_Base {
+
+ /**
+ * Set up groups of files as sources
+ *
+ * @param array $options controller and Minify options
+ * @return array Minify options
+ *
+ */
+ public function setupSources($options) {
+ self::_setupDefines();
+ if (MINIFY_USE_CACHE) {
+ $cacheDir = defined('MINIFY_CACHE_DIR')
+ ? MINIFY_CACHE_DIR
+ : '';
+ Minify::setCache($cacheDir);
+ }
+ $options['badRequestHeader'] = 'HTTP/1.0 404 Not Found';
+ $options['contentTypeCharset'] = MINIFY_ENCODING;
+
+ // The following restrictions are to limit the URLs that minify will
+ // respond to. Ideally there should be only one way to reference a file.
+ if (! isset($_GET['files'])
+ // verify at least one file, files are single comma separated,
+ // and are all same extension
+ || ! preg_match('/^[^,]+\\.(css|js)(,[^,]+\\.\\1)*$/', $_GET['files'], $m)
+ // no "//" (makes URL rewriting easier)
+ || strpos($_GET['files'], '//') !== false
+ // no "\"
+ || strpos($_GET['files'], '\\') !== false
+ // no "./"
+ || preg_match('/(?:^|[^\\.])\\.\\//', $_GET['files'])
+ ) {
+ return $options;
+ }
+ $extension = $m[1];
+
+ $files = explode(',', $_GET['files']);
+ if (count($files) > MINIFY_MAX_FILES) {
+ return $options;
+ }
+
+ // strings for prepending to relative/absolute paths
+ $prependRelPaths = dirname($_SERVER['SCRIPT_FILENAME'])
+ . DIRECTORY_SEPARATOR;
+ $prependAbsPaths = $_SERVER['DOCUMENT_ROOT'];
+
+ $sources = array();
+ $goodFiles = array();
+ $hasBadSource = false;
+
+ $allowDirs = isset($options['allowDirs'])
+ ? $options['allowDirs']
+ : MINIFY_BASE_DIR;
+
+ foreach ($files as $file) {
+ // prepend appropriate string for abs/rel paths
+ $file = ($file[0] === '/' ? $prependAbsPaths : $prependRelPaths) . $file;
+ // make sure a real file!
+ $file = realpath($file);
+ // don't allow unsafe or duplicate files
+ if (parent::_fileIsSafe($file, $allowDirs)
+ && !in_array($file, $goodFiles))
+ {
+ $goodFiles[] = $file;
+ $srcOptions = array(
+ 'filepath' => $file
+ );
+ $this->sources[] = new Minify_Source($srcOptions);
+ } else {
+ $hasBadSource = true;
+ break;
+ }
+ }
+ if ($hasBadSource) {
+ $this->sources = array();
+ }
+ if (! MINIFY_REWRITE_CSS_URLS) {
+ $options['rewriteCssUris'] = false;
+ }
+ return $options;
+ }
+
+ private static function _setupDefines()
+ {
+ $defaults = array(
+ 'MINIFY_BASE_DIR' => realpath($_SERVER['DOCUMENT_ROOT'])
+ ,'MINIFY_ENCODING' => 'utf-8'
+ ,'MINIFY_MAX_FILES' => 16
+ ,'MINIFY_REWRITE_CSS_URLS' => true
+ ,'MINIFY_USE_CACHE' => true
+ );
+ foreach ($defaults as $const => $val) {
+ if (! defined($const)) {
+ define($const, $val);
+ }
+ }
+ }
+}
+
--- /dev/null
+<?php
+/**
+ * Class Minify_HTML
+ * @package Minify
+ */
+
+/**
+ * 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.
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_HTML {
+
+ /**
+ * "Minify" an HTML page
+ *
+ * @param string $html
+ *
+ * @param array $options
+ *
+ * 'cssMinifier' : (optional) callback function to process content of STYLE
+ * elements.
+ *
+ * 'jsMinifier' : (optional) callback function to process content of SCRIPT
+ * elements. Note: the type attribute is ignored.
+ *
+ * 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If
+ * unset, minify will sniff for an XHTML doctype.
+ *
+ * @return string
+ */
+ public static function minify($html, $options = array()) {
+ $min = new Minify_HTML($html, $options);
+ return $min->process();
+ }
+
+
+ /**
+ * Create a minifier object
+ *
+ * @param string $html
+ *
+ * @param array $options
+ *
+ * 'cssMinifier' : (optional) callback function to process content of STYLE
+ * elements.
+ *
+ * 'jsMinifier' : (optional) callback function to process content of SCRIPT
+ * elements. Note: the type attribute is ignored.
+ *
+ * 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If
+ * unset, minify will sniff for an XHTML doctype.
+ *
+ * @return null
+ */
+ public function __construct($html, $options = array())
+ {
+ $this->_html = str_replace("\r\n", "\n", trim($html));
+ if (isset($options['xhtml'])) {
+ $this->_isXhtml = (bool)$options['xhtml'];
+ }
+ if (isset($options['cssMinifier'])) {
+ $this->_cssMinifier = $options['cssMinifier'];
+ }
+ if (isset($options['jsMinifier'])) {
+ $this->_jsMinifier = $options['jsMinifier'];
+ }
+ }
+
+
+ /**
+ * Minify the markeup given in the constructor
+ *
+ * @return string
+ */
+ public function process()
+ {
+ if ($this->_isXhtml === null) {
+ $this->_isXhtml = (false !== strpos($this->_html, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML'));
+ }
+
+ $this->_replacementHash = 'MINIFYHTML' . md5($_SERVER['REQUEST_TIME']);
+ $this->_placeholders = array();
+
+ // replace SCRIPTs (and minify) with placeholders
+ $this->_html = preg_replace_callback(
+ '/(\\s*)(<script\\b[^>]*?>)([\\s\\S]*?)<\\/script>(\\s*)/i'
+ ,array($this, '_removeScriptCB')
+ ,$this->_html);
+
+ // replace STYLEs (and minify) with placeholders
+ $this->_html = preg_replace_callback(
+ '/\\s*(<style\\b[^>]*?>)([\\s\\S]*?)<\\/style>\\s*/i'
+ ,array($this, '_removeStyleCB')
+ ,$this->_html);
+
+ // remove HTML comments (not containing IE conditional comments).
+ $this->_html = preg_replace_callback(
+ '/<!--([\\s\\S]*?)-->/'
+ ,array($this, '_commentCB')
+ ,$this->_html);
+
+ // replace PREs with placeholders
+ $this->_html = preg_replace_callback('/\\s*(<pre\\b[^>]*?>[\\s\\S]*?<\\/pre>)\\s*/i'
+ ,array($this, '_removePreCB')
+ ,$this->_html);
+
+ // replace TEXTAREAs with placeholders
+ $this->_html = preg_replace_callback(
+ '/\\s*(<textarea\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/i'
+ ,array($this, '_removeTextareaCB')
+ ,$this->_html);
+
+ // trim each line.
+ // @todo take into account attribute values that span multiple lines.
+ $this->_html = preg_replace('/^\\s+|\\s+$/m', '', $this->_html);
+
+ // remove ws around block/undisplayed elements
+ $this->_html = preg_replace('/\\s+(<\\/?(?:area|base(?:font)?|blockquote|body'
+ .'|caption|center|cite|col(?:group)?|dd|dir|div|dl|dt|fieldset|form'
+ .'|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta'
+ .'|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)'
+ .'|ul)\\b[^>]*>)/i', '$1', $this->_html);
+
+ // remove ws outside of all elements
+ $this->_html = preg_replace_callback(
+ '/>([^<]+)</'
+ ,array($this, '_outsideTagCB')
+ ,$this->_html);
+
+ // use newlines before 1st attribute in open tags (to limit line lengths)
+ $this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);
+
+ // fill placeholders
+ $this->_html = str_replace(
+ array_keys($this->_placeholders)
+ ,array_values($this->_placeholders)
+ ,$this->_html
+ );
+ return $this->_html;
+ }
+
+ protected function _commentCB($m)
+ {
+ return (0 === strpos($m[1], '[') || false !== strpos($m[1], '<!['))
+ ? $m[0]
+ : '';
+ }
+
+ protected function _reservePlace($content)
+ {
+ $placeholder = '%' . $this->_replacementHash . count($this->_placeholders) . '%';
+ $this->_placeholders[$placeholder] = $content;
+ return $placeholder;
+ }
+
+ protected $_isXhtml = null;
+ protected $_replacementHash = null;
+ protected $_placeholders = array();
+ protected $_cssMinifier = null;
+ protected $_jsMinifier = null;
+
+ protected function _outsideTagCB($m)
+ {
+ return '>' . preg_replace('/^\\s+|\\s+$/', ' ', $m[1]) . '<';
+ }
+
+ protected function _removePreCB($m)
+ {
+ return $this->_reservePlace($m[1]);
+ }
+
+ protected function _removeTextareaCB($m)
+ {
+ return $this->_reservePlace($m[1]);
+ }
+
+ protected function _removeStyleCB($m)
+ {
+ $openStyle = $m[1];
+ $css = $m[2];
+ // remove HTML comments
+ $css = preg_replace('/(?:^\\s*<!--|-->\\s*$)/', '', $css);
+
+ // remove CDATA section markers
+ $css = $this->_removeCdata($css);
+
+ // minify
+ $minifier = $this->_cssMinifier
+ ? $this->_cssMinifier
+ : 'trim';
+ $css = call_user_func($minifier, $css);
+
+ return $this->_reservePlace($this->_needsCdata($css)
+ ? "{$openStyle}/*<![CDATA[*/{$css}/*]]>*/</style>"
+ : "{$openStyle}{$css}</style>"
+ );
+ }
+
+ protected function _removeScriptCB($m)
+ {
+ $openScript = $m[2];
+ $js = $m[3];
+
+ // whitespace surrounding? preserve at least one space
+ $ws1 = ($m[1] === '') ? '' : ' ';
+ $ws2 = ($m[4] === '') ? '' : ' ';
+
+ // remove HTML comments (and ending "//" if present)
+ $js = preg_replace('/(?:^\\s*<!--\\s*|\\s*(?:\\/\\/)?\\s*-->\\s*$)/', '', $js);
+
+ // remove CDATA section markers
+ $js = $this->_removeCdata($js);
+
+ // minify
+ $minifier = $this->_jsMinifier
+ ? $this->_jsMinifier
+ : 'trim';
+ $js = call_user_func($minifier, $js);
+
+ return $this->_reservePlace($this->_needsCdata($js)
+ ? "{$ws1}{$openScript}/*<![CDATA[*/{$js}/*]]>*/</script>{$ws2}"
+ : "{$ws1}{$openScript}{$js}</script>{$ws2}"
+ );
+ }
+
+ protected function _removeCdata($str)
+ {
+ return (false !== strpos($str, '<![CDATA['))
+ ? str_replace(array('<![CDATA[', ']]>'), '', $str)
+ : $str;
+ }
+
+ protected function _needsCdata($str)
+ {
+ return ($this->_isXhtml && preg_match('/(?:[<&]|\\-\\-|\\]\\]>)/', $str));
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_ImportProcessor
+ * @package Minify
+ */
+
+/**
+ * Linearize a CSS/JS file by including content specified by CSS import
+ * declarations. In CSS files, relative URIs are fixed.
+ *
+ * @imports will be processed regardless of where they appear in the source
+ * files; i.e. @imports commented out or in string content will still be
+ * processed!
+ *
+ * This has a unit test but should be considered "experimental".
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_ImportProcessor {
+
+ public static $filesIncluded = array();
+
+ public static function process($file)
+ {
+ self::$filesIncluded = array();
+ self::$_isCss = (strtolower(substr($file, -4)) === '.css');
+ $obj = new Minify_ImportProcessor(dirname($file));
+ return $obj->_getContent($file);
+ }
+
+ // allows callback funcs to know the current directory
+ private $_currentDir = null;
+
+ // allows _importCB to write the fetched content back to the obj
+ private $_importedContent = '';
+
+ private static $_isCss = null;
+
+ private function __construct($currentDir)
+ {
+ $this->_currentDir = $currentDir;
+ }
+
+ private function _getContent($file)
+ {
+ $file = realpath($file);
+ if (! $file
+ || in_array($file, self::$filesIncluded)
+ || false === ($content = @file_get_contents($file))
+ ) {
+ // file missing, already included, or failed read
+ return '';
+ }
+ self::$filesIncluded[] = realpath($file);
+ $this->_currentDir = dirname($file);
+
+ // remove UTF-8 BOM if present
+ if (pack("CCC",0xef,0xbb,0xbf) === substr($content, 0, 3)) {
+ $content = substr($content, 3);
+ }
+ // ensure uniform EOLs
+ $content = str_replace("\r\n", "\n", $content);
+
+ // process @imports
+ $content = preg_replace_callback(
+ '/
+ @import\\s+
+ (?:url\\(\\s*)? # maybe url(
+ [\'"]? # maybe quote
+ (.*?) # 1 = URI
+ [\'"]? # maybe end quote
+ (?:\\s*\\))? # maybe )
+ ([a-zA-Z,\\s]*)? # 2 = media list
+ ; # end token
+ /x'
+ ,array($this, '_importCB')
+ ,$content
+ );
+
+ if (self::$_isCss) {
+ // rewrite remaining relative URIs
+ $content = preg_replace_callback(
+ '/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
+ ,array($this, '_urlCB')
+ ,$content
+ );
+ }
+
+ return $this->_importedContent . $content;
+ }
+
+ private function _importCB($m)
+ {
+ $url = $m[1];
+ $mediaList = preg_replace('/\\s+/', '', $m[2]);
+
+ if (strpos($url, '://') > 0) {
+ // protocol, leave in place for CSS, comment for JS
+ return self::$_isCss
+ ? $m[0]
+ : "/* Minify_ImportProcessor will not include remote content */";
+ }
+ if ('/' === $url[0]) {
+ // protocol-relative or root path
+ $url = ltrim($url, '/');
+ $file = realpath($_SERVER['DOCUMENT_ROOT']) . DIRECTORY_SEPARATOR
+ . strtr($url, '/', DIRECTORY_SEPARATOR);
+ } else {
+ // relative to current path
+ $file = $this->_currentDir . DIRECTORY_SEPARATOR
+ . strtr($url, '/', DIRECTORY_SEPARATOR);
+ }
+ $obj = new Minify_ImportProcessor(dirname($file));
+ $content = $obj->_getContent($file);
+ if ('' === $content) {
+ // failed. leave in place for CSS, comment for JS
+ return self::$_isCss
+ ? $m[0]
+ : "/* Minify_ImportProcessor could not fetch '{$file}' */";;
+ }
+ return (!self::$_isCss || preg_match('@(?:^$|\\ball\\b)@', $mediaList))
+ ? $content
+ : "@media {$mediaList} {\n{$content}\n}\n";
+ }
+
+ private function _urlCB($m)
+ {
+ // $m[1] is either quoted or not
+ $quote = ($m[1][0] === "'" || $m[1][0] === '"')
+ ? $m[1][0]
+ : '';
+ $url = ($quote === '')
+ ? $m[1]
+ : substr($m[1], 1, strlen($m[1]) - 2);
+ if ('/' !== $url[0]) {
+ if (strpos($url, '//') > 0) {
+ // probably starts with protocol, do not alter
+ } else {
+ // prepend path with current dir separator (OS-independent)
+ $path = $this->_currentDir
+ . DIRECTORY_SEPARATOR . strtr($url, '/', DIRECTORY_SEPARATOR);
+ // strip doc root
+ $path = substr($path, strlen(realpath($_SERVER['DOCUMENT_ROOT'])));
+ // fix to absolute URL
+ $url = strtr($path, '/\\', '//');
+ // remove /./ and /../ where possible
+ $url = str_replace('/./', '/', $url);
+ // inspired by patch from Oleg Cherniy
+ do {
+ $url = preg_replace('@/[^/]+/\\.\\./@', '/', $url, 1, $changed);
+ } while ($changed);
+ }
+ }
+ return "url({$quote}{$url}{$quote})";
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_Lines
+ * @package Minify
+ */
+
+/**
+ * Add line numbers in C-style comments for easier debugging of combined content
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ * @author Adam Pedersen (Issue 55 fix)
+ */
+class Minify_Lines {
+
+ /**
+ * Add line numbers in C-style comments
+ *
+ * This uses a very basic parser easily fooled by comment tokens inside
+ * strings or regexes, but, otherwise, generally clean code will not be
+ * mangled. URI rewriting can also be performed.
+ *
+ * @param string $content
+ *
+ * @param array $options available options:
+ *
+ * 'id': (optional) string to identify file. E.g. file name/path
+ *
+ * 'currentDir': (default null) if given, this is assumed to be the\r
+ * directory of the current CSS file. Using this, minify will rewrite\r
+ * all relative URIs in import/url declarations to correctly point to\r
+ * the desired files, and prepend a comment with debugging information about
+ * this process.
+ *
+ * @return string
+ */
+ public static function minify($content, $options = array())
+ {
+ $id = (isset($options['id']) && $options['id'])
+ ? $options['id']
+ : '';
+ $content = str_replace("\r\n", "\n", $content);
+ $lines = explode("\n", $content);
+ $numLines = count($lines);
+ // determine left padding
+ $padTo = strlen($numLines);
+ $inComment = false;
+ $i = 0;
+ $newLines = array();
+ while (null !== ($line = array_shift($lines))) {
+ if (('' !== $id) && (0 == $i % 50)) {
+ array_push($newLines, '', "/* {$id} */", '');
+ }
+ ++$i;
+ $newLines[] = self::_addNote($line, $i, $inComment, $padTo);
+ $inComment = self::_eolInComment($line, $inComment);
+ }
+ $content = implode("\n", $newLines) . "\n";
+
+ // check for desired URI rewriting
+ if (isset($options['currentDir'])) {
+ require_once 'Minify/CSS/UriRewriter.php';
+ Minify_CSS_UriRewriter::$debugText = '';
+ $content = Minify_CSS_UriRewriter::rewrite(
+ $content
+ ,$options['currentDir']
+ ,isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT']\r
+ ,isset($options['symlinks']) ? $options['symlinks'] : array()
+ );
+ $content = "/* Minify_CSS_UriRewriter::\$debugText\n\n"
+ . Minify_CSS_UriRewriter::$debugText . "*/\n"
+ . $content;
+ }
+
+ return $content;
+ }
+
+ /**
+ * Is the parser within a C-style comment at the end of this line?
+ *
+ * @param string $line current line of code
+ *
+ * @param bool $inComment was the parser in a comment at the
+ * beginning of the line?
+ *
+ * @return bool
+ */
+ private static function _eolInComment($line, $inComment)
+ {
+ while (strlen($line)) {
+ $search = $inComment
+ ? '*/'
+ : '/*';
+ $pos = strpos($line, $search);
+ if (false === $pos) {
+ return $inComment;
+ } else {
+ if ($pos == 0
+ || ($inComment
+ ? substr($line, $pos, 3)
+ : substr($line, $pos-1, 3)) != '*/*')
+ {
+ $inComment = ! $inComment;
+ }
+ $line = substr($line, $pos + 2);
+ }
+ }
+ return $inComment;
+ }
+
+ /**
+ * Prepend a comment (or note) to the given line
+ *
+ * @param string $line current line of code
+ *
+ * @param string $note content of note/comment
+ *
+ * @param bool $inComment was the parser in a comment at the
+ * beginning of the line?
+ *
+ * @param int $padTo minimum width of comment
+ *
+ * @return string
+ */
+ private static function _addNote($line, $note, $inComment, $padTo)
+ {
+ return $inComment
+ ? '/* ' . str_pad($note, $padTo, ' ', STR_PAD_RIGHT) . ' *| ' . $line
+ : '/* ' . str_pad($note, $padTo, ' ', STR_PAD_RIGHT) . ' */ ' . $line;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_Logger
+ * @package Minify
+ */
+
+/**
+ * Message logging class
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_Logger {
+
+ /**
+ * Set logger object.
+ *
+ * The object should have a method "log" that accepts a value as 1st argument and
+ * an optional string label as the 2nd.
+ *
+ * @param mixed $obj or a "falsey" value to disable
+ * @return null
+ */
+ public static function setLogger($obj = null) {
+ self::$_logger = $obj
+ ? $obj
+ : null;
+ }
+
+ /**
+ * Pass a message to the logger (if set)
+ *
+ * @param string $msg message to log
+ * @return null
+ */
+ public static function log($msg, $label = 'Minify') {
+ if (! self::$_logger) return;
+ self::$_logger->log($msg, $label);
+ }
+
+ /**
+ * @var mixed logger object (like FirePHP) or null (i.e. no logger available)
+ */
+ private static $_logger = null;
+}
--- /dev/null
+<?php
+/**
+ * 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).
+ * @link 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.
+ *
+ * @package Minify
+ */
+
+if (false === (@include 'class.JavaScriptPacker.php')) {
+ trigger_error(
+ 'The script "class.JavaScriptPacker.php" is required. Please see: http:'
+ .'//code.google.com/p/minify/source/browse/trunk/min/lib/Minify/Packer.php'
+ ,E_USER_ERROR
+ );
+}
+
+/**
+ * Minify Javascript using Dean Edward's Packer
+ *
+ * @package Minify
+ */
+class Minify_Packer {
+ public static function minify($code, $options = array())
+ {
+ // @todo: set encoding options based on $options :)
+ $packer = new JavascriptPacker($code, 'Normal', true, false);
+ return trim($packer->pack());
+ }
+}
--- /dev/null
+<?php
+/**
+ * Class Minify_Source
+ * @package Minify
+ */
+
+/**
+ * A content source to be minified by Minify.
+ *
+ * This allows per-source minification options and the mixing of files with
+ * content from other sources.
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_Source {
+
+ /**
+ * @var int time of last modification
+ */
+ public $lastModified = null;
+
+ /**
+ * @var callback minifier function specifically for this source.
+ */
+ public $minifier = null;
+
+ /**
+ * @var array minification options specific to this source.
+ */
+ public $minifyOptions = null;
+
+ /**
+ * @var string full path of file
+ */
+ public $filepath = null;
+
+ /**
+ * @var string HTTP Content Type (Minify requires one of the constants Minify::TYPE_*)
+ */
+ public $contentType = null;
+
+ /**
+ * Create a Minify_Source
+ *
+ * In the $spec array(), you can either provide a 'filepath' to an existing
+ * file (existence will not be checked!) or give 'id' (unique string for
+ * the content), 'content' (the string content) and 'lastModified'
+ * (unixtime of last update).
+ *
+ * As a shortcut, the controller will replace "//" at the beginning
+ * of a filepath with $_SERVER['DOCUMENT_ROOT'] . '/'.
+ *
+ * @param array $spec options
+ */
+ public function __construct($spec)
+ {
+ if (isset($spec['filepath'])) {
+ if (0 === strpos($spec['filepath'], '//')) {
+ $spec['filepath'] = $_SERVER['DOCUMENT_ROOT'] . substr($spec['filepath'], 1);
+ }
+ $segments = explode('.', $spec['filepath']);
+ $ext = strtolower(array_pop($segments));
+ switch ($ext) {
+ case 'js' : $this->contentType = 'application/x-javascript';
+ break;
+ case 'css' : $this->contentType = 'text/css';
+ break;
+ case 'htm' : // fallthrough
+ case 'html' : $this->contentType = 'text/html';
+ break;
+ }
+ $this->filepath = $spec['filepath'];
+ $this->_id = $spec['filepath'];
+ $this->lastModified = filemtime($spec['filepath'])
+ // offset for Windows uploaders with out of sync clocks
+ + round(Minify::$uploaderHoursBehind * 3600);
+ } elseif (isset($spec['id'])) {
+ $this->_id = 'id::' . $spec['id'];
+ if (isset($spec['content'])) {
+ $this->_content = $spec['content'];
+ } else {
+ $this->_getContentFunc = $spec['getContentFunc'];
+ }
+ $this->lastModified = isset($spec['lastModified'])
+ ? $spec['lastModified']
+ : time();
+ }
+ if (isset($spec['contentType'])) {
+ $this->contentType = $spec['contentType'];
+ }
+ if (isset($spec['minifier'])) {
+ $this->minifier = $spec['minifier'];
+ }
+ if (isset($spec['minifyOptions'])) {
+ $this->minifyOptions = $spec['minifyOptions'];
+ }
+ }
+
+ /**
+ * Get content
+ *
+ * @return string
+ */
+ public function getContent()
+ {
+ $content = (null !== $this->filepath)
+ ? file_get_contents($this->filepath)
+ : ((null !== $this->_content)
+ ? $this->_content
+ : call_user_func($this->_getContentFunc, $this->_id)
+ );
+ // remove UTF-8 BOM if present
+ return (pack("CCC",0xef,0xbb,0xbf) === substr($content, 0, 3))
+ ? substr($content, 3)
+ : $content;
+ }
+
+ /**
+ * Get id
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->_id;
+ }
+
+ /**
+ * Verifies a single minification call can handle all sources
+ *
+ * @param array $sources Minify_Source instances
+ *
+ * @return bool true iff there no sources with specific minifier preferences.
+ */
+ public static function haveNoMinifyPrefs($sources)
+ {
+ foreach ($sources as $source) {
+ if (null !== $source->minifier
+ || null !== $source->minifyOptions) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Get unique string for a set of sources
+ *
+ * @param array $sources Minify_Source instances
+ *
+ * @return string
+ */
+ public static function getDigest($sources)
+ {
+ foreach ($sources as $source) {
+ $info[] = array(
+ $source->_id, $source->minifier, $source->minifyOptions
+ );
+ }
+ return md5(serialize($info));
+ }
+
+ /**
+ * Get content type from a group of sources
+ *
+ * This is called if the user doesn't pass in a 'contentType' options
+ *
+ * @param array $sources Minify_Source instances
+ *
+ * @return string content type. e.g. 'text/css'
+ */
+ public static function getContentType($sources)
+ {
+ foreach ($sources as $source) {
+ if ($source->contentType !== null) {
+ return $source->contentType;
+ }
+ }
+ return 'text/plain';
+ }
+
+ protected $_content = null;
+ protected $_getContentFunc = null;
+ protected $_id = null;
+}
+
--- /dev/null
+<?php
+/**
+ * Class Minify_YUICompressor
+ * @package Minify
+ */
+
+/**
+ * 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.
+ *
+ * <code>
+ * 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)
+ * );
+ * </code>
+ *
+ * @todo unit tests, $options docs
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_YUICompressor {
+
+ /**
+ * Filepath of the YUI Compressor jar file. This must be set before
+ * calling minifyJs() or minifyCss().
+ *
+ * @var string
+ */
+ public static $jarFile = null;
+
+ /**
+ * Writable temp directory. This must be set before calling minifyJs()
+ * or minifyCss().
+ *
+ * @var string
+ */
+ public static $tempDir = null;
+
+ /**
+ * Filepath of "java" executable (may be needed if not in shell's PATH)
+ *
+ * @var string
+ */
+ public static $javaExecutable = 'java';
+
+ /**
+ * Minify a Javascript string
+ *
+ * @param string $js
+ *
+ * @param array $options (verbose is ignored)
+ *
+ * @see http://www.julienlecomte.net/yuicompressor/README
+ *
+ * @return string
+ */
+ public static function minifyJs($js, $options = array())
+ {
+ return self::_minify('js', $js, $options);
+ }
+
+ /**
+ * Minify a CSS string
+ *
+ * @param string $css
+ *
+ * @param array $options (verbose is ignored)
+ *
+ * @see http://www.julienlecomte.net/yuicompressor/README
+ *
+ * @return string
+ */
+ public static function minifyCss($css, $options = array())
+ {
+ return self::_minify('css', $css, $options);
+ }
+
+ private static function _minify($type, $content, $options)
+ {
+ self::_prepare();
+ if (! ($tmpFile = tempnam(self::$tempDir, 'yuic_'))) {
+ throw new Exception('Minify_YUICompressor : could not create temp file.');
+ }
+ file_put_contents($tmpFile, $content);
+ exec(self::_getCmd($options, $type, $tmpFile), $output);
+ unlink($tmpFile);
+ return implode("\n", $output);
+ }
+
+ private static function _getCmd($userOptions, $type, $tmpFile)
+ {
+ $o = array_merge(
+ array(
+ 'charset' => ''
+ ,'line-break' => 5000
+ ,'type' => $type
+ ,'nomunge' => false
+ ,'preserve-semi' => false
+ ,'disable-optimizations' => false
+ )
+ ,$userOptions
+ );
+ $cmd = self::$javaExecutable . ' -jar ' . escapeshellarg(self::$jarFile)
+ . " --type {$type}"
+ . (preg_match('/^[a-zA-Z\\-]+$/', $o['charset'])
+ ? " --charset {$o['charset']}"
+ : '')
+ . (is_numeric($o['line-break']) && $o['line-break'] >= 0
+ ? ' --line-break ' . (int)$o['line-break']
+ : '');
+ if ($type === 'js') {
+ foreach (array('nomunge', 'preserve-semi', 'disable-optimizations') as $opt) {
+ $cmd .= $o[$opt]
+ ? " --{$opt}"
+ : '';
+ }
+ }
+ return $cmd . ' ' . escapeshellarg($tmpFile);
+ }
+
+ private static function _prepare()
+ {
+ if (! is_file(self::$jarFile)
+ || ! is_dir(self::$tempDir)
+ || ! is_writable(self::$tempDir)
+ ) {
+ throw new Exception('Minify_YUICompressor : $jarFile and $tempDir must be set.');
+ }
+ }
+}
+
--- /dev/null
+<?php
+/**
+ *
+ * Utility class for static directory methods.
+ *
+ * @category Solar
+ *
+ * @package Solar
+ *
+ * @author Paul M. Jones <pmjones@solarphp.com>
+ *
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ *
+ * @version $Id: Dir.php 2926 2007-11-09 16:25:44Z pmjones $
+ *
+ */
+class Solar_Dir {
+
+ /**
+ *
+ * The OS-specific temporary directory location.
+ *
+ * @var string
+ *
+ */
+ protected static $_tmp;
+
+ /**
+ *
+ * Hack for [[php::is_dir() | ]] that checks the include_path.
+ *
+ * Use this to see if a directory exists anywhere in the include_path.
+ *
+ * {{code: php
+ * $dir = Solar_Dir::exists('path/to/dir')
+ * if ($dir) {
+ * $files = scandir($dir);
+ * } else {
+ * echo "Not found in the include-path.";
+ * }
+ * }}
+ *
+ * @param string $dir Check for this directory in the include_path.
+ *
+ * @return mixed If the directory exists in the include_path, returns the
+ * absolute path; if not, returns boolean false.
+ *
+ */
+ public static function exists($dir)
+ {
+ // no file requested?
+ $dir = trim($dir);
+ if (! $dir) {
+ return false;
+ }
+
+ // using an absolute path for the file?
+ // dual check for Unix '/' and Windows '\',
+ // or Windows drive letter and a ':'.
+ $abs = ($dir[0] == '/' || $dir[0] == '\\' || $dir[1] == ':');
+ if ($abs && is_dir($dir)) {
+ return $dir;
+ }
+
+ // using a relative path on the file
+ $path = explode(PATH_SEPARATOR, ini_get('include_path'));
+ foreach ($path as $base) {
+ // strip Unix '/' and Windows '\'
+ $target = rtrim($base, '\\/') . DIRECTORY_SEPARATOR . $dir;
+ if (is_dir($target)) {
+ return $target;
+ }
+ }
+
+ // never found it
+ return false;
+ }
+
+ /**
+ *
+ * "Fixes" a directory string for the operating system.
+ *
+ * Use slashes anywhere you need a directory separator. Then run the
+ * string through fixdir() and the slashes will be converted to the
+ * proper separator (for example '\' on Windows).
+ *
+ * Always adds a final trailing separator.
+ *
+ * @param string $dir The directory string to 'fix'.
+ *
+ * @return string The "fixed" directory string.
+ *
+ */
+ public static function fix($dir)
+ {
+ $dir = str_replace('/', DIRECTORY_SEPARATOR, $dir);
+ return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
+ }
+
+ /**
+ *
+ * Convenience method for dirname() and higher-level directories.
+ *
+ * @param string $file Get the dirname() of this file.
+ *
+ * @param int $up Move up in the directory structure this many
+ * times, default 0.
+ *
+ * @return string The dirname() of the file.
+ *
+ */
+ public static function name($file, $up = 0)
+ {
+ $dir = dirname($file);
+ while ($up --) {
+ $dir = dirname($dir);
+ }
+ return $dir;
+ }
+
+ /**
+ *
+ * Returns the OS-specific directory for temporary files.
+ *
+ * @param string $sub Add this subdirectory to the returned temporary
+ * directory name.
+ *
+ * @return string The temporary directory path.
+ *
+ */
+ public static function tmp($sub = '')
+ {
+ // find the tmp dir if needed
+ if (! Solar_Dir::$_tmp) {
+
+ // use the system if we can
+ if (function_exists('sys_get_temp_dir')) {
+ $tmp = sys_get_temp_dir();
+ } else {
+ $tmp = Solar_Dir::_tmp();
+ }
+
+ // remove trailing separator and save
+ Solar_Dir::$_tmp = rtrim($tmp, DIRECTORY_SEPARATOR);
+ }
+
+ // do we have a subdirectory request?
+ $sub = trim($sub);
+ if ($sub) {
+ // remove leading and trailing separators, and force exactly
+ // one trailing separator
+ $sub = trim($sub, DIRECTORY_SEPARATOR)
+ . DIRECTORY_SEPARATOR;
+ }
+
+ return Solar_Dir::$_tmp . DIRECTORY_SEPARATOR . $sub;
+ }
+
+ /**
+ *
+ * Returns the OS-specific temporary directory location.
+ *
+ * @return string The temp directory path.
+ *
+ */
+ protected static function _tmp()
+ {
+ // non-Windows system?
+ if (strtolower(substr(PHP_OS, 0, 3)) != 'win') {
+ $tmp = empty($_ENV['TMPDIR']) ? getenv('TMPDIR') : $_ENV['TMPDIR'];
+ if ($tmp) {
+ return $tmp;
+ } else {
+ return '/tmp';
+ }
+ }
+
+ // Windows 'TEMP'
+ $tmp = empty($_ENV['TEMP']) ? getenv('TEMP') : $_ENV['TEMP'];
+ if ($tmp) {
+ return $tmp;
+ }
+
+ // Windows 'TMP'
+ $tmp = empty($_ENV['TMP']) ? getenv('TMP') : $_ENV['TMP'];
+ if ($tmp) {
+ return $tmp;
+ }
+
+ // Windows 'windir'
+ $tmp = empty($_ENV['windir']) ? getenv('windir') : $_ENV['windir'];
+ if ($tmp) {
+ return $tmp;
+ }
+
+ // final fallback for Windows
+ return getenv('SystemRoot') . '\\temp';
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Utility functions for generating group URIs in HTML files
+ *
+ * Before including this file, /min/lib must be in your include_path.
+ *
+ * @package Minify
+ */
+
+require_once 'Minify/Build.php';
+
+
+/**
+ * Get a timestamped URI to a minified resource using the default Minify install
+ *
+ * <code>
+ * <link rel="stylesheet" type="text/css" href="<?php echo Minify_groupUri('css'); ?>" />
+ * <script type="text/javascript" src="<?php echo Minify_groupUri('js'); ?>"></script>
+ * </code>
+ *
+ * If you do not want ampersands as HTML entities, set Minify_Build::$ampersand = "&"
+ * before using this function.
+ *
+ * @param string $group a key from groupsConfig.php
+ * @param boolean $forceAmpersand (default false) Set to true if the RewriteRule
+ * directives in .htaccess are functional. This will remove the "?" from URIs, making them
+ * more cacheable by proxies.
+ * @return string
+ */
+function Minify_groupUri($group, $forceAmpersand = false)
+{
+ $path = $forceAmpersand
+ ? "/g={$group}"
+ : "/?g={$group}";
+ return _Minify_getBuild($group)->uri(
+ '/' . basename(dirname(__FILE__)) . $path
+ ,$forceAmpersand
+ );
+}
+
+
+/**
+ * Get the last modification time of the source js/css files used by Minify to
+ * build the page.
+ *
+ * If you're caching the output of Minify_groupUri(), you'll want to rebuild
+ * the cache if it's older than this timestamp.
+ *
+ * <code>
+ * // simplistic HTML cache system
+ * $file = '/path/to/cache/file';
+ * if (! file_exists($file) || filemtime($file) < Minify_groupsMtime(array('js', 'css'))) {
+ * // (re)build cache
+ * $page = buildPage(); // this calls Minify_groupUri() for js and css
+ * file_put_contents($file, $page);
+ * echo $page;
+ * exit();
+ * }
+ * readfile($file);
+ * </code>
+ *
+ * @param array $groups an array of keys from groupsConfig.php
+ * @return int Unix timestamp of the latest modification
+ */
+function Minify_groupsMtime($groups)
+{
+ $max = 0;
+ foreach ((array)$groups as $group) {
+ $max = max($max, _Minify_getBuild($group)->lastModified);
+ }
+ return $max;
+}
+
+/**
+ * @param string $group a key from groupsConfig.php
+ * @return Minify_Build
+ * @private
+ */
+function _Minify_getBuild($group)
+{
+ static $builds = array();
+ static $gc = false;
+ if (false === $gc) {
+ $gc = (require dirname(__FILE__) . '/groupsConfig.php');
+ }
+ if (! isset($builds[$group])) {
+ $builds[$group] = new Minify_Build($gc[$group]);
+ }
+ return $builds[$group];
+}
--- /dev/null
+<?php
+
+set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../min/lib'));
+require 'HTTP/ConditionalGet.php';
+
+// emulate regularly updating document
+$every = 20;
+$lastModified = round(time()/$every)*$every - $every;
+
+$cg = new HTTP_ConditionalGet(array(
+ 'lastModifiedTime' => $lastModified
+));
+if ($cg->cacheIsValid) {
+ $cg->sendHeaders();
+ // we're done
+ exit();
+}
+
+// generate content
+$title = 'Last-Modified is known : add Content-Length';
+$explain = '
+<p>Here, like <a href="./">the first example</a>, we know the Last-Modified time,
+but we also want to set the Content-Length to increase cacheability and allow
+HTTP persistent connections. Instead of sending headers immediately, we first
+generate our content, then use <code>setContentLength(strlen($content))</code>
+to add the header. Then finally call <code>sendHeaders()</code> and send the
+content.</p>
+<p><strong>Note:</strong> This is not required if your PHP config buffers all
+output and your script doesn\'t do any incremental flushing of the output
+buffer. PHP will generally set Content-Length for you if it can.</p>
+<p>This script emulates a document that changes every ' .$every. ' seconds.
+<br>This is version: ' . date('r', $lastModified) . '</p>
+';
+
+require '_include.php';
+$content = get_content(array(
+ 'title' => $title
+ ,'explain' => $explain
+));
+
+$cg->setContentLength(strlen($content));
+$cg->sendHeaders();
+send_slowly($content);
+
--- /dev/null
+<?php
+
+set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../min/lib'));
+require 'HTTP/ConditionalGet.php';
+
+// generate content first (not ideal)
+// emulate regularly updating document
+$every = 20;
+$lastModified = round(time()/$every)*$every - $every;
+$title = 'Last-Modified is unknown : use hash of content for ETag';
+$explain = '
+<p>When Last-Modified is unknown, you can still use ETags, but you need a short
+string that is unique for that content. In the worst case, you have to generate
+all the content first, <em>then</em> instantiate HTTP_ConditionalGet, setting
+the array key <code>contentHash</code> to the output of a hash function of the
+content. Since we have the full content, we might as well also use
+<code>setContentLength(strlen($content))</code> in the case where we need to
+send it.</p>
+<p>This script emulates a document that changes every ' .$every. ' seconds.
+<br>This is version: ' . date('r', $lastModified) . '</p>
+';
+require '_include.php';
+$content = get_content(array(
+ 'title' => $title
+ ,'explain' => $explain
+));
+
+$cg = new HTTP_ConditionalGet(array(
+ 'contentHash' => substr(md5($content), 7)
+));
+if ($cg->cacheIsValid) {
+ $cg->sendHeaders();
+ // we're done
+ exit();
+}
+$cg->setContentLength(strlen($content));
+$cg->sendHeaders();
+
+send_slowly($content);
+\r
--- /dev/null
+<?php
+
+set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../min/lib'));
+require 'HTTP/ConditionalGet.php';
+
+// emulate regularly updating document
+$every = 20;
+$lastModified = round(time()/$every)*$every - $every;
+
+require 'HTTP/Encoder.php';
+list($enc,) = HTTP_Encoder::getAcceptedEncoding();
+
+$cg = new HTTP_ConditionalGet(array(
+ 'lastModifiedTime' => $lastModified
+ ,'encoding' => $enc
+));
+$cg->sendHeaders();
+if ($cg->cacheIsValid) {
+ // we're done
+ exit();
+}
+
+// output encoded content
+
+$title = 'ConditionalGet + Encoder';
+$explain = '
+<p>Using ConditionalGet and Encoder is straightforward. First impliment the
+ConditionalGet, then if the cache is not valid, encode and send the content</p>
+<p>This script emulates a document that changes every ' .$every. ' seconds.
+<br>This is version: ' . date('r', $lastModified) . '</p>
+';
+require '_include.php';
+$content = get_content(array(
+ 'title' => $title
+ ,'explain' => $explain
+));
+
+$he = new HTTP_Encoder(array(
+ 'content' => get_content(array(
+ 'title' => $title
+ ,'explain' => $explain
+ ))
+));
+$he->encode();
+
+// usually you would just $he->sendAll(), but here we want to emulate slow
+// connection
+$he->sendHeaders();
+send_slowly($he->getContent());
--- /dev/null
+<?php
+
+set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../min/lib'));
+require 'HTTP/ConditionalGet.php';
+
+// far expires
+$cg = new HTTP_ConditionalGet(array(
+ 'maxAge' => 20
+ ,'lastModifiedTime' => filemtime(__FILE__)
+));
+$cg->sendHeaders();
+
+// generate, send content
+$title = 'Last-Modified + Expires';
+$explain = '
+<p>Here we set a static "lastModifiedTime" and "maxAge" to 20. The browser
+will consider this document fresh for 20 seconds, then revalidate its cache. After
+the 304 response, the cache will be good for another 20 seconds. Unless you force
+a reload, there will only be 304 responses for this page after the initial download.
+';
+
+require '_include.php';
+echo get_content(array(
+ 'title' => $title
+ ,'explain' => $explain
+));
+
--- /dev/null
+<?php
+
+function send_slowly($content)
+{
+ $half = ceil(strlen($content) / 2);
+ $content = str_split($content, $half);
+ while ($chunk = array_shift($content)) {
+ sleep(1);
+ echo $chunk;
+ ob_get_level() && ob_flush();
+ flush();
+ }
+}
+
+function get_content($data)
+{
+ ob_start();
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>HTTP_ConditionalGet : <?php echo $data['title']; ?></title>
+</head>
+<body>
+<h1>HTTP_ConditionalGet</h1>
+<h2><?php echo $data['title']; ?></h2>
+<?php echo $data['explain']; ?>
+<ul>
+ <li><a href="./">Last-Modified is known : simple usage</a></li>
+ <li><a href="2.php">Last-Modified is known : add Content-Length</a></li>
+ <li><a href="3.php">Last-Modified is unknown : use hash of content for ETag</a></li>
+ <li><a href="4.php">ConditionalGet + Encoder</a></li>
+ <li><a href="5.php">Last-Modified + Expires</a></li>
+</ul>
+<h2>Notes</h2>
+<h3>How to distinguish 200 and 304 responses</h3>
+<p>For these pages all 200 responses are sent in chunks a second apart, so you
+should notice that 304 responses are quicker. You can also use HTTP sniffers
+like <a href="http://www.fiddlertool.com/">Fiddler (win)</a> and
+<a href="http://livehttpheaders.mozdev.org/">LiveHTTPHeaders (Firefox add-on)</a>
+to verify headers and content being sent.</p>
+<h3>Browser notes</h3>
+<dl>
+ <dt>Opera</dt>
+ <dd>Opera has a couple behaviors against the HTTP spec: Manual refreshes (F5)
+ prevents the ETag/If-Modified-Since headers from being sent; it only sends
+ them when following a link or bookmark. Also, Opera will not honor the
+ <code>must-revalidate</code> Cache-Control value unless <code>max-age</code>
+ is set. To get Opera to follow the spec, ConditionalGet will send Opera max-age=0
+ (if one is not already set).</dd>
+ <dt>Safari</dt>
+ <dd>ETag validation is unsupported, but Safari supports HTTP/1.0 validation via
+ If-Modified-Since headers as long as the cache is explicitly marked
+ "public" or "private" ("private" is default in ConditionalGet).</dd>
+</dl>
+</body>
+</html>
+<?php
+ $content = ob_get_contents();
+ ob_end_clean();
+ return $content;
+}
+\r
--- /dev/null
+<?php
+
+set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../min/lib'));
+require 'HTTP/ConditionalGet.php';
+
+// emulate regularly updating document
+$every = 20;
+$lastModified = round(time()/$every)*$every - $every;
+
+$cg = new HTTP_ConditionalGet(array(
+ 'lastModifiedTime' => $lastModified
+));
+$cg->sendHeaders();
+if ($cg->cacheIsValid) {
+ // we're done
+ exit();
+}
+
+$title = 'Last-Modified is known : simple usage';
+$explain = '
+<p>If your content has not changed since a certain timestamp, set this via the
+the <code>lastModifiedTime</code> array key when instantiating HTTP_ConditionalGet.
+You can immediately call the method <code>sendHeaders()</code> to set the
+Last-Modified, ETag, and Cache-Control headers. The, if <code>cacheIsValid</code>
+property is false, you echo the content.</p>
+<p>This script emulates a document that changes every ' .$every. ' seconds.
+<br>This is version: ' . date('r', $lastModified) . '</p>
+';
+
+require '_include.php';
+
+echo send_slowly(get_content(array(
+ 'title' => $title
+ ,'explain' => $explain
+)));
+\r
--- /dev/null
+<?php
+ini_set('display_errors', 'on');
+
+set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../min/lib'));
+require 'HTTP/Encoder.php';
+
+if (!isset($_GET['test'])) {
+ $type = 'text/html';
+ ob_start();
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+"http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<title>HTTP_Encoder Test</title>
+<style type="text/css">
+@import "?test=2";
+#img {background:url("?test=1");}
+.green {background:#0f0;}
+p span {padding:0 .5em;}
+</style>
+</head>
+<body>
+<h1>HTTP_Encoder test</h1>
+<p><span class="green"> HTML </span></p>
+<p><span id="css"> CSS </span></p>
+<p><span id="js"> Javascript </span></p>
+<p><span id="img"> image </span></p>
+<script src="?test=3" type="text/javascript"></script>
+</body>
+</html>
+<?php
+ $content = ob_get_contents();
+ ob_end_clean();
+
+} elseif ($_GET['test'] == '1') {
+ $content = file_get_contents(dirname(__FILE__) . '/green.png');
+ $type = 'image/png';
+
+} elseif ($_GET['test'] == '2') {
+ $content = '#css {background:#0f0;}';
+ $type = 'text/css';
+
+} else {
+ $content = '
+window.onload = function(){
+ document.getElementById("js").className = "green";
+};
+ ';
+ $type = 'application/x-javascript';
+}
+
+$he = new HTTP_Encoder(array(
+ 'content' => $content
+ ,'type' => $type
+));
+$he->encode();
+$he->sendAll();
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+require dirname(__FILE__) . '/../min/config.php';
+
+set_include_path($min_libPath . PATH_SEPARATOR . get_include_path());
+
+// set cache path and doc root if configured
+$minifyCachePath = isset($min_cachePath)
+ ? $min_cachePath
+ : '';
+if ($min_documentRoot) {
+ $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
+}
+
+// default log to FirePHP
+require_once 'Minify/Logger.php';
+if ($min_errorLogger && true !== $min_errorLogger) { // custom logger
+ Minify_Logger::setLogger($min_errorLogger);
+} else {
+ require_once 'FirePHP.php';
+ Minify_Logger::setLogger(FirePHP::getInstance(true));
+}
+
+error_reporting(E_ALL | E_STRICT);
+ini_set('display_errors', 1);
+
+header('Content-Type: text/plain');
+
+$thisDir = dirname(__FILE__);
+
+/**
+ * pTest - PHP Unit Tester
+ * @param mixed $test Condition to test, evaluated as boolean
+ * @param string $message Descriptive message to output upon test
+ * @url http://www.sitepoint.com/blogs/2007/08/13/ptest-php-unit-tester-in-9-lines-of-code/
+ */
+function assertTrue($test, $message)
+{
+ static $count;
+ if (!isset($count)) $count = array('pass'=>0, 'fail'=>0, 'total'=>0);
+
+ $mode = $test ? 'pass' : 'fail';
+ $outMode = $test ? 'PASS' : '!FAIL';
+ printf("%s: %s (%d of %d tests run so far have %sed)\n",
+ $outMode, $message, ++$count[$mode], ++$count['total'], $mode);
+
+ return (bool)$test;
+}
+
+ob_start();
\ No newline at end of file
--- /dev/null
+
+/* block comments get removed */
+
+/*! YUI Compressor style comments are preserved */
+
+/* but all other comments are removed */
+
+/* comments that have any surrounding whitespace are replaced by a single space. */
+body{ background:#fff/*eef*/ url(/path/to/image.gif) repeat-y; }
--- /dev/null
+
+/* YUI Compressor style comments are preserved */
+body{background:#fff url(/path/to/image.gif) repeat-y}
\ No newline at end of file
--- /dev/null
+/* hide from ie5/mac \*/ a{}\r
+.foo {color:red}\r
+/* necessary comment */\r
+\r
+/* comment to attempt to confuse parser */\r
+\r
+/* feed to ie5/mac \*//*/\r
+@import "ie5mac.css";\r
+/* necessary comment */\r
+\r
+/* comment to attempt to confuse parser */\r
+\r
+/*/ hide from nav4 */\r
+.foo {display:block;}\r
+/* necessary comment */\r
+\r
+/* comment to attempt to confuse parser */\r
+\r
+/*/ feed to nav *//*/\r
+.foo {display:crazy;}\r
+/* necessary comment */\r
+\r
+/* hide props from various IE/win */\r
+div {\r
+ width: 140px; \r
+ width/* */:/**/100px; \r
+ width: /**/100px;\r
+}\r
+\r
+html>/**/body {}\r
+\r
+/* Tantek's box model hack */\r
+div { \r
+ width:400px; \r
+ voice-family: "\"}\""; \r
+ voice-family:inherit;\r
+ width:300px;\r
+}\r
+\r
+/* don't minimize hex colors in filters */\r
+div {\r
+ filter:chroma(color=#aabbcc);\r
+ filter:mask(color=#000000) shadow(color=#9BAD71, direction=135) chroma(color=#000000);\r
+}\r
+\r
+@media screen {\r
+ /* for IE 5.x-6, hidden from IE 5 Mac */ /*\*/\r
+ * html div#page {\r
+ height: 1%;\r
+ }\r
+ /**/ /* end hidden from IE 5 Mac */\r
+}\r
+\r
+foo { /* filters for IE */\r
+ _height : 20px;\r
+ *height : 15px;\r
+}\r
+\r
+/* http://tantek.com/CSS/Examples/midpass.html */\r
+@media tty {\r
+ i{content:"\";/*" "*/}} @import 'midpassafter.css'; /*";}\r
+}/* */\r
+\r
+/* leave at least 1 space between these pseudo elements and "{" for IE6: http://www.crankygeek.com/ie6pebug/ */\r
+p:first-letter {color:red;}\r
+p:first-line {color:red;}\r
--- /dev/null
+/*\*/a{}.foo{color:red}/**/ /*\*//*/@import "ie5mac.css";/**/ /*/*/.foo{display:block}/**/ /*/*//*/.foo{display:crazy}/**/ div{width:140px;width/**/:/**/100px;width:/**/100px}html>/**/body{}div{width:400px;voice-family:"\"}\"";voice-family:inherit;width:300px}div{filter:chroma(color=#aabbcc);filter:mask(color=#000000) shadow(color=#9BAD71, direction=135) chroma(color=#000000)}@media
+screen{/*\*/* html
+div#page{height:1%}/**/}foo{_height:20px;*height:15px}@media
+tty{i{content:"\";/*" "*/}}@import 'midpassafter.css';/*"}}/* */ p:first-letter {color:red}p:first-line {color:red}
\ No newline at end of file
--- /dev/null
+/*\r
+* DEFINITION DES STYLES DE TEXTE\r
+*/\r
+ /*-----------------------------------------------------------------------------------*/\r
+h1 {\r
+ color: #339933;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 14px;\r
+ font-weight: bold;\r
+ text-decoration: none;\r
+}\r
+\r
+h2 {\r
+ color: #339933;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ font-weight: bold;\r
+ text-decoration: none;\r
+}\r
+\r
+h1,h2,h3,h4,h5 {\r
+ margin: 0px;\r
+ padding: 0px;\r
+}\r
+\r
+.txt_10_noir {\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_10_noir:link,.txt_10_noir:visited,.txt_10_noir:active {\r
+ color: black;\r
+}\r
+\r
+.txt_10_noir:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_11_noir {\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_11_noir:link,.txt_11_noir:visited,.txt_11_noir:active {\r
+ color: black;\r
+}\r
+\r
+.txt_11_noir:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_12_noir {\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_12_noir:link,.txt_12_noir:visited,.txt_12_noir:active {\r
+ color: black;\r
+}\r
+\r
+.txt_12_noir:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_14_noir {\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 14px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_14_noir:link,.txt_14_noir:visited,.txt_14_noir:active {\r
+ color: black;\r
+}\r
+\r
+.txt_14_noir:hover {\r
+ color: red;\r
+}\r
+\r
+/*-----------------------------------------------------------------------------------*/\r
+.txt_10_gris {\r
+ color: grey;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_10_gris:link,.txt_10_gris:visited,.txt_10_gris:active {\r
+ color: grey;\r
+}\r
+\r
+.txt_10_gris:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_11_gris {\r
+ color: grey;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_11_gris:link,.txt_11_gris:visited,.txt_11_gris:active {\r
+ color: grey;\r
+}\r
+\r
+.txt_11_gris:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_12_gris {\r
+ color: grey;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_12_gris:link,.txt_12_gris:visited,.txt_12_gris:active {\r
+ color: grey;\r
+}\r
+\r
+.txt_12_gris:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_14_gris {\r
+ color: grey;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 14px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_14_gris:link,.txt_14_gris:visited,.txt_14_gris:active {\r
+ color: grey;\r
+}\r
+\r
+.txt_14_gris:hover {\r
+ color: red;\r
+}\r
+\r
+/*-----------------------------------------------------------------------------------*/\r
+.txt_10_blanc {\r
+ color: #FFFFFF;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_10_blanc:link,.txt_10_blanc:visited,.txt_10_blanc:active {\r
+ color: #FFFFFF;\r
+}\r
+\r
+.txt_10_blanc:hover {\r
+ color: #FF8800; /*ORANGE*/\r
+}\r
+\r
+.txt_11_blanc {\r
+ color: #FFFFFF;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_11_blanc:link,.txt_11_blanc:visited,.txt_11_blanc:active {\r
+ color: #FFFFFF;\r
+}\r
+\r
+.txt_11_blanc:hover {\r
+ color: #FF8800;\r
+}\r
+\r
+.txt_12_blanc {\r
+ color: #FFFFFF;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_12_blanc:link,.txt_12_blanc:visited,.txt_12_blanc:active {\r
+ color: #FFFFFF;\r
+}\r
+\r
+.txt_12_blanc:hover {\r
+ color: #FFAA00;\r
+}\r
+\r
+.txt_14_blanc {\r
+ color: #FFFFFF;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 14px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_14_blanc:link,.txt_14_blanc:visited,.txt_14_blanc:active {\r
+ color: #FFFFFF;\r
+}\r
+\r
+.txt_14_blanc:hover {\r
+ color: #FF8800;\r
+}\r
+\r
+/*-----------------------------------------------------------------------------------*/\r
+.txt_10_orange {\r
+ color: #FF8800;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_10_orange:link,.txt_10_orange:visited,.txt_10_orange:active {\r
+ color: #FF8800;\r
+}\r
+\r
+.txt_10_orange:hover {\r
+ color: darkblue\r
+}\r
+\r
+.txt_11_orange {\r
+ color: #FF8800;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_11_orange:link,.txt_11_orange:visited,.txt_11_orange:active {\r
+ color: #FF8800;\r
+}\r
+\r
+.txt_11_orange:hover {\r
+ color: darkblue;\r
+}\r
+\r
+.txt_12_orange {\r
+ color: #FF8800;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_12_orange:link,.txt_12_orange:visited,.txt_12_orange:active {\r
+ color: #FF8800;\r
+}\r
+\r
+.txt_12_orange:hover {\r
+ color: darkblue;\r
+}\r
+\r
+.txt_14_orange {\r
+ color: #FF8800;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 14px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_14_orange:link,.txt_14_orange:visited,.txt_14_orange:active {\r
+ color: #FF8800;\r
+}\r
+\r
+.txt_14_orange:hover {\r
+ color: darkblue;\r
+}\r
+\r
+/*-----------------------------------------------------------------------------------*/\r
+.txt_10_rouge {\r
+ color: red;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_10_rouge:link,.txt_10_rouge:visited,.txt_10_rouge:active {\r
+ color: red;\r
+}\r
+\r
+.txt_10_rouge:hover {\r
+ color: darkblue;\r
+}\r
+\r
+.txt_11_rouge {\r
+ color: red;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_11_rouge:link,.txt_11_rouge:visited,.txt_11_rouge:active {\r
+ color: red;\r
+}\r
+\r
+.txt_11_rouge:hover {\r
+ color: darkblue;\r
+}\r
+\r
+.txt_12_rouge {\r
+ color: red;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_12_rouge:link,.txt_12_rouge:visited,.txt_12_rouge:active {\r
+ color: red;\r
+}\r
+\r
+.txt_12_rouge:hover {\r
+ color: darkblue;\r
+}\r
+\r
+.txt_14_rouge {\r
+ color: red;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 14px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_14_rouge:link,.txt_14_rouge:visited,.txt_14_rouge:active {\r
+ color: red;\r
+}\r
+\r
+.txt_14_rouge:hover {\r
+ color: darkblue;\r
+}\r
+\r
+/*-----------------------------------------------------------------------------------*/\r
+.txt_10_bleu {\r
+ color: blue;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_10_bleu:link,.txt_10_bleu:visited,.txt_10_bleu:active {\r
+ color: blue;\r
+}\r
+\r
+.txt_10_bleu:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_11_bleu {\r
+ color: blue;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_11_bleu:link,.txt_11_bleu:visited,.txt_11_bleu:active {\r
+ color: blue;\r
+}\r
+\r
+.txt_11_bleu:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_12_bleu {\r
+ color: blue;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_12_bleu:link,.txt_12_bleu:visited,.txt_12_bleu:active {\r
+ color: blue;\r
+}\r
+\r
+.txt_12_bleu:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_14_bleu {\r
+ color: blue;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 14px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_14_bleu:link,.txt_14_bleu:visited,.txt_14_bleu:active {\r
+ color: blue;\r
+}\r
+\r
+.txt_14_bleu:hover {\r
+ color: red;\r
+}\r
+\r
+/*-----------------------------------------------------------------------------------*/\r
+.txt_10_bleu_f {\r
+ color: darkblue;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_10_bleu_f:link,.txt_10_bleu_f:visited,.txt_10_bleu_f:active {\r
+ color: darkblue;\r
+}\r
+\r
+.txt_10_bleu_f:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_11_bleu_f {\r
+ color: darkblue;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_11_bleu_f:link,.txt_11_bleu_f:visited,.txt_11_bleu_f:active {\r
+ color: darkblue;\r
+}\r
+\r
+.txt_11_bleu_f:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_12_bleu_f {\r
+ color: darkblue;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_12_bleu_f:link,.txt_12_bleu_f:visited,.txt_12_bleu_f:active {\r
+ color: darkblue;\r
+}\r
+\r
+.txt_12_bleu_f:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_14_bleu_f {\r
+ color: darkblue;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 14px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_14_bleu_f:link,.txt_14_bleu_f:visited,.txt_14_bleu_f:active {\r
+ color: darkblue;\r
+}\r
+\r
+.txt_14_bleu_f:hover {\r
+ color: red;\r
+}\r
+\r
+/*-----------------------------------------------------------------------------------*/\r
+.txt_10_vert_f {\r
+ color: darkgreen;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_10_vert_f:link,.txt_10_vert_f:visited,.txt_10_vert_f:active {\r
+ color: darkgreen;\r
+}\r
+\r
+.txt_10_vert_f:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_11_vert_f {\r
+ color: darkgreen;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_11_vert_f:link,.txt_11_vert_f:visited,.txt_11_vert_f:active {\r
+ color: darkgreen;\r
+}\r
+\r
+.txt_11_vert_f:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_12_vert_f {\r
+ color: darkgreen;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_12_vert_f:link,.txt_12_vertf:visited,.txt_12_vert_f:active {\r
+ color: darkgreen;\r
+}\r
+\r
+.txt_12_vert_f:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_14_vert_f {\r
+ color: darkgreen;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 14px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_14_vert_f:link,.txt_14_vert_f:visited,.txt_14_vert_f:active {\r
+ color: darkgreen;\r
+}\r
+\r
+.txt_14_vert_f:hover {\r
+ color: red;\r
+}\r
+\r
+/*-----------------------------------------------------------------------------------*/\r
+.txt_10_vert {\r
+ color: green;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_10_vert:link,.txt_10_vert:visited,.txt_10_vert:active {\r
+ color: green;\r
+}\r
+\r
+.txt_10_vert:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_11_vert {\r
+ color: green;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_11_vert:link,.txt_11_vert:visited,.txt_11_vert:active {\r
+ color: green;\r
+}\r
+\r
+.txt_11_vert:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_12_vert {\r
+ color: green;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_12_vert:link,.txt_12_vert:visited,.txt_12_vert:active {\r
+ color: green;\r
+}\r
+\r
+.txt_12_vert:hover {\r
+ color: red;\r
+}\r
+\r
+.txt_14_vert {\r
+ color: green;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 14px;\r
+ text-decoration: none;\r
+}\r
+\r
+.txt_14_vert:link,.txt_14_vert:visited,.txt_14_vert:active {\r
+ color: green;\r
+}\r
+\r
+.txt_14_vert:hover {\r
+ color: red;\r
+}\r
+\r
+/*-----------------------------------------------------------------------------------*/\r
+.fond_blanc {\r
+ background-color: #FFFFFF;\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.fond_gris_c, .fond_gris_c tr {\r
+ background-color: #FFFFFF;\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+ background-image: url(../images/fond_4.bmp);\r
+ background-repeat: repeat-x;\r
+}\r
+\r
+.fond_gris_c2, .fond_gris_c2 tr {\r
+ background-color: #FBFBFB;\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.fond_bleu_c, .fond_bleu_c tr {\r
+ background-color: #D9EEF9;\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+ background-image: url(../images/fond_1.bmp);\r
+}\r
+\r
+.fond_bleu_c2 {\r
+ background-color: #ECF4FF;\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.fond_bleu_f {\r
+ background-color: #003366;\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.fond_orange {\r
+ background-color: #FEEFE7;\r
+ color: darkgreen;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ font-weight: bold;\r
+ text-decoration: none;\r
+ background-image: url(../images/fond_3.jpg);\r
+}\r
+\r
+.fond_orange_2 {\r
+ background-color: #FFF8F4;\r
+ color: darkgreen;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ font-weight: bold;\r
+ text-decoration: none;\r
+ border: 1px solid orange;\r
+ border-collapse: collapse;\r
+}\r
+\r
+.vccDlgBody {\r
+ border: 3px solid #336699;\r
+ border-collapse: collapse;\r
+ color: black;\r
+ background-color: #EEFFEE;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+/* DEFINITION DES STYLES DE TABLEAUX */\r
+.bordure_0 {\r
+ border: 0px solid;\r
+ color: black;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.bordure_1_bleu {\r
+ border: 1px solid green;\r
+ border-collapse: collapse;\r
+ color: black;\r
+ background-color: #FFFFFF;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.bordure_3_bleu {\r
+ border: 3px solid #336699;\r
+ border-collapse: collapse;\r
+ color: black;\r
+ background-color: #FFFFFF;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 11px;\r
+ text-decoration: none;\r
+}\r
+\r
+.indent {\r
+ margin-left: 20px;\r
+}\r
+\r
+/* DEFINITION DES STYLES D'OBJETS DE FORMULAIRE */\r
+.Btn {\r
+ color: #003366;\r
+ text-align: center;\r
+ font-weight: bold;\r
+ background-color: #FFFFFF;\r
+ background-image: url(../images/ongletStyle1.jpg);\r
+ background-repeat: no-repeat;\r
+ background-position: center center;\r
+}\r
+\r
+.Btn:hover {\r
+ color: red;\r
+}\r
+\r
+.menu1h {\r
+ background-color: #003366;\r
+ color: white;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ font-weight: bold;\r
+ text-decoration: none;\r
+ border-top: 1px solid #003366;\r
+ border-bottom: 1px solid #003366;\r
+ border-left: 1px solid #003366;\r
+ border-right: 1px solid white;\r
+ border-collapse: collapse;\r
+ display: block;\r
+}\r
+\r
+.menu1h:hover {\r
+ background-color: white;\r
+ color: red;\r
+ border: 1px solid darkgreen;\r
+ border-collapse: collapse;\r
+}\r
+\r
+.menu1h_f {\r
+ background-color: #003366;\r
+ color: white;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ font-weight: bold;\r
+ text-decoration: none;\r
+ border: 1px solid #003366;\r
+ display: block;\r
+}\r
+\r
+.menu1h_f:hover {\r
+ background-color: white;\r
+ color: red;\r
+ border: 1px solid darkgreen;\r
+ border-collapse: collapse;\r
+}\r
+\r
+.menu1v {\r
+ background-color: #003366;\r
+ color: white;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ font-weight: bold;\r
+ text-decoration: none;\r
+ border: 1px solid #003366;\r
+ border-collapse: collapse;\r
+ display: block;\r
+}\r
+\r
+.menu1v:hover {\r
+ background-color: white;\r
+ color: red;\r
+ border: 1px solid darkgreen;\r
+ border-collapse: collapse;\r
+}\r
+\r
+.menu2v {\r
+ background-color: #5588BB;\r
+ color: white;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 12px;\r
+ font-weight: bold;\r
+ text-decoration: none;\r
+ border: 1px solid #4277AB;\r
+ border-collapse: collapse;\r
+ float: left;\r
+ display: block;\r
+}\r
+\r
+.menu2v:hover {\r
+ background-color: white;\r
+ color: red;\r
+ border: 1px solid darkgreen;\r
+ border-collapse: collapse;\r
+}\r
+\r
+.menuEDF {\r
+ background-color: #003366;\r
+ color: white;\r
+ font-family: Verdana, Arial, Lucida, Tahoma;\r
+ font-size: 10px;\r
+ text-decoration: none;\r
+}\r
+\r
+.menuEDF:hover {\r
+ color: #FF8800;\r
+}\r
+\r
+/*bouton bleu sur blanc*/\r
+.Bouton {\r
+ color: #003366;\r
+ text-align: center;\r
+ font-weight: bold;\r
+ /* Ricardo cursor: hand; */\r
+ cursor: pointer;\r
+ background-color: #FFFFFF;\r
+}\r
+\r
+input {\r
+ border: 2px solid green;\r
+ color: #003366;\r
+ background-color: #FFFFFF;\r
+ background-image: url(../images/fond_4.bmp);\r
+ background-repeat: repeat-x;\r
+}\r
+\r
+.disabled_input {\r
+ border: 1px solid gray;\r
+ color: grey;\r
+ background-color: #FFFFFF;\r
+ background-image: url(../images/fond_4.bmp);\r
+ background-repeat: repeat-x;\r
+}\r
+\r
+.input0 {\r
+ border: 0px;\r
+ color: #003366;\r
+ background-color: #FFFFFF;\r
+ background-image: url(../images/fond_4.bmp);\r
+}\r
+\r
+.input2 {\r
+ border: 1px solid green;\r
+ color: #003366;\r
+ background-color: #FFFFFF;\r
+ background-image: url(../images/fond_4.bmp);\r
+ background-repeat: repeat-x;\r
+}\r
+\r
+.input3 {\r
+ border: 1px solid black;\r
+ color: #003366;\r
+ background-color: #EEEEEE;\r
+ background-image: url();\r
+}\r
+\r
+.input4 {\r
+ border: 1px solid blue;\r
+ color: #003366;\r
+ background-color: #FFFFFF;\r
+ background-image: url(../images/fond_4.bmp);\r
+ background-repeat: repeat-x;\r
+}\r
+\r
+.input5 {\r
+ border: 1px solid darkblue;\r
+ color: #003366;\r
+ background-color: #FFFFFF;\r
+ background-image: url(../images/fond_4.bmp);\r
+ background-repeat: repeat-x;\r
+}\r
+\r
+.input_btn {\r
+ border: 0px;\r
+ /* cursor: hand; */\r
+ cursor: pointer;\r
+}\r
+\r
+textarea {\r
+ border: 2px solid green;\r
+ color: #003366;\r
+ background-color: #FFFFFF;\r
+ background-image: url(../images/fond_5.bmp);\r
+}\r
+\r
+.TEXTAREA3 {\r
+ border: 1px solid green;\r
+ color: #003366;\r
+ background-color: #FFFFFF;\r
+ background-image: url();\r
+}\r
+\r
+.TEXTAREA4 {\r
+ border: 1px solid green;\r
+ color: #003366;\r
+ background-color: #EEEEEE;\r
+ background-image: url();\r
+}\r
+\r
+.hand {\r
+ cursor: hand;\r
+ cursor: pointer;\r
+}
\ No newline at end of file
--- /dev/null
+h1{color:#393;font-family:Verdana,Arial,Lucida,Tahoma;font-size:14px;font-weight:bold;text-decoration:none}h2{color:#393;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;font-weight:bold;text-decoration:none}h1,h2,h3,h4,h5{margin:0px;padding:0px}.txt_10_noir{color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;text-decoration:none}.txt_10_noir:link,.txt_10_noir:visited,.txt_10_noir:active{color:black}.txt_10_noir:hover{color:red}.txt_11_noir{color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.txt_11_noir:link,.txt_11_noir:visited,.txt_11_noir:active{color:black}.txt_11_noir:hover{color:red}.txt_12_noir{color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;text-decoration:none}.txt_12_noir:link,.txt_12_noir:visited,.txt_12_noir:active{color:black}.txt_12_noir:hover{color:red}.txt_14_noir{color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:14px;text-decoration:none}.txt_14_noir:link,.txt_14_noir:visited,.txt_14_noir:active{color:black}.txt_14_noir:hover{color:red}.txt_10_gris{color:grey;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;text-decoration:none}.txt_10_gris:link,.txt_10_gris:visited,.txt_10_gris:active{color:grey}.txt_10_gris:hover{color:red}.txt_11_gris{color:grey;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.txt_11_gris:link,.txt_11_gris:visited,.txt_11_gris:active{color:grey}.txt_11_gris:hover{color:red}.txt_12_gris{color:grey;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;text-decoration:none}.txt_12_gris:link,.txt_12_gris:visited,.txt_12_gris:active{color:grey}.txt_12_gris:hover{color:red}.txt_14_gris{color:grey;font-family:Verdana,Arial,Lucida,Tahoma;font-size:14px;text-decoration:none}.txt_14_gris:link,.txt_14_gris:visited,.txt_14_gris:active{color:grey}.txt_14_gris:hover{color:red}.txt_10_blanc{color:#FFF;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;text-decoration:none}.txt_10_blanc:link,.txt_10_blanc:visited,.txt_10_blanc:active{color:#FFF}.txt_10_blanc:hover{color:#F80}.txt_11_blanc{color:#FFF;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.txt_11_blanc:link,.txt_11_blanc:visited,.txt_11_blanc:active{color:#FFF}.txt_11_blanc:hover{color:#F80}.txt_12_blanc{color:#FFF;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;text-decoration:none}.txt_12_blanc:link,.txt_12_blanc:visited,.txt_12_blanc:active{color:#FFF}.txt_12_blanc:hover{color:#FA0}.txt_14_blanc{color:#FFF;font-family:Verdana,Arial,Lucida,Tahoma;font-size:14px;text-decoration:none}.txt_14_blanc:link,.txt_14_blanc:visited,.txt_14_blanc:active{color:#FFF}.txt_14_blanc:hover{color:#F80}.txt_10_orange{color:#F80;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;text-decoration:none}.txt_10_orange:link,.txt_10_orange:visited,.txt_10_orange:active{color:#F80}.txt_10_orange:hover{color:darkblue}.txt_11_orange{color:#F80;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.txt_11_orange:link,.txt_11_orange:visited,.txt_11_orange:active{color:#F80}.txt_11_orange:hover{color:darkblue}.txt_12_orange{color:#F80;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;text-decoration:none}.txt_12_orange:link,.txt_12_orange:visited,.txt_12_orange:active{color:#F80}.txt_12_orange:hover{color:darkblue}.txt_14_orange{color:#F80;font-family:Verdana,Arial,Lucida,Tahoma;font-size:14px;text-decoration:none}.txt_14_orange:link,.txt_14_orange:visited,.txt_14_orange:active{color:#F80}.txt_14_orange:hover{color:darkblue}.txt_10_rouge{color:red;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;text-decoration:none}.txt_10_rouge:link,.txt_10_rouge:visited,.txt_10_rouge:active{color:red}.txt_10_rouge:hover{color:darkblue}.txt_11_rouge{color:red;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.txt_11_rouge:link,.txt_11_rouge:visited,.txt_11_rouge:active{color:red}.txt_11_rouge:hover{color:darkblue}.txt_12_rouge{color:red;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;text-decoration:none}.txt_12_rouge:link,.txt_12_rouge:visited,.txt_12_rouge:active{color:red}.txt_12_rouge:hover{color:darkblue}.txt_14_rouge{color:red;font-family:Verdana,Arial,Lucida,Tahoma;font-size:14px;text-decoration:none}.txt_14_rouge:link,.txt_14_rouge:visited,.txt_14_rouge:active{color:red}.txt_14_rouge:hover{color:darkblue}.txt_10_bleu{color:blue;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;text-decoration:none}.txt_10_bleu:link,.txt_10_bleu:visited,.txt_10_bleu:active{color:blue}.txt_10_bleu:hover{color:red}.txt_11_bleu{color:blue;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.txt_11_bleu:link,.txt_11_bleu:visited,.txt_11_bleu:active{color:blue}.txt_11_bleu:hover{color:red}.txt_12_bleu{color:blue;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;text-decoration:none}.txt_12_bleu:link,.txt_12_bleu:visited,.txt_12_bleu:active{color:blue}.txt_12_bleu:hover{color:red}.txt_14_bleu{color:blue;font-family:Verdana,Arial,Lucida,Tahoma;font-size:14px;text-decoration:none}.txt_14_bleu:link,.txt_14_bleu:visited,.txt_14_bleu:active{color:blue}.txt_14_bleu:hover{color:red}.txt_10_bleu_f{color:darkblue;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;text-decoration:none}.txt_10_bleu_f:link,.txt_10_bleu_f:visited,.txt_10_bleu_f:active{color:darkblue}.txt_10_bleu_f:hover{color:red}.txt_11_bleu_f{color:darkblue;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.txt_11_bleu_f:link,.txt_11_bleu_f:visited,.txt_11_bleu_f:active{color:darkblue}.txt_11_bleu_f:hover{color:red}.txt_12_bleu_f{color:darkblue;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;text-decoration:none}.txt_12_bleu_f:link,.txt_12_bleu_f:visited,.txt_12_bleu_f:active{color:darkblue}.txt_12_bleu_f:hover{color:red}.txt_14_bleu_f{color:darkblue;font-family:Verdana,Arial,Lucida,Tahoma;font-size:14px;text-decoration:none}.txt_14_bleu_f:link,.txt_14_bleu_f:visited,.txt_14_bleu_f:active{color:darkblue}.txt_14_bleu_f:hover{color:red}.txt_10_vert_f{color:darkgreen;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;text-decoration:none}.txt_10_vert_f:link,.txt_10_vert_f:visited,.txt_10_vert_f:active{color:darkgreen}.txt_10_vert_f:hover{color:red}.txt_11_vert_f{color:darkgreen;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.txt_11_vert_f:link,.txt_11_vert_f:visited,.txt_11_vert_f:active{color:darkgreen}.txt_11_vert_f:hover{color:red}.txt_12_vert_f{color:darkgreen;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;text-decoration:none}.txt_12_vert_f:link,.txt_12_vertf:visited,.txt_12_vert_f:active{color:darkgreen}.txt_12_vert_f:hover{color:red}.txt_14_vert_f{color:darkgreen;font-family:Verdana,Arial,Lucida,Tahoma;font-size:14px;text-decoration:none}.txt_14_vert_f:link,.txt_14_vert_f:visited,.txt_14_vert_f:active{color:darkgreen}.txt_14_vert_f:hover{color:red}.txt_10_vert{color:green;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;text-decoration:none}.txt_10_vert:link,.txt_10_vert:visited,.txt_10_vert:active{color:green}.txt_10_vert:hover{color:red}.txt_11_vert{color:green;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.txt_11_vert:link,.txt_11_vert:visited,.txt_11_vert:active{color:green}.txt_11_vert:hover{color:red}.txt_12_vert{color:green;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;text-decoration:none}.txt_12_vert:link,.txt_12_vert:visited,.txt_12_vert:active{color:green}.txt_12_vert:hover{color:red}.txt_14_vert{color:green;font-family:Verdana,Arial,Lucida,Tahoma;font-size:14px;text-decoration:none}.txt_14_vert:link,.txt_14_vert:visited,.txt_14_vert:active{color:green}.txt_14_vert:hover{color:red}.fond_blanc{background-color:#FFF;color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.fond_gris_c, .fond_gris_c
+tr{background-color:#FFF;color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none;background-image:url(../images/fond_4.bmp);background-repeat:repeat-x}.fond_gris_c2, .fond_gris_c2
+tr{background-color:#FBFBFB;color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.fond_bleu_c, .fond_bleu_c
+tr{background-color:#D9EEF9;color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none;background-image:url(../images/fond_1.bmp)}.fond_bleu_c2{background-color:#ECF4FF;color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.fond_bleu_f{background-color:#036;color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.fond_orange{background-color:#FEEFE7;color:darkgreen;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;font-weight:bold;text-decoration:none;background-image:url(../images/fond_3.jpg)}.fond_orange_2{background-color:#FFF8F4;color:darkgreen;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;font-weight:bold;text-decoration:none;border:1px
+solid orange;border-collapse:collapse}.vccDlgBody{border:3px
+solid #369;border-collapse:collapse;color:black;background-color:#EFE;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.bordure_0{border:0px
+solid;color:black;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.bordure_1_bleu{border:1px
+solid green;border-collapse:collapse;color:black;background-color:#FFF;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.bordure_3_bleu{border:3px
+solid #369;border-collapse:collapse;color:black;background-color:#FFF;font-family:Verdana,Arial,Lucida,Tahoma;font-size:11px;text-decoration:none}.indent{margin-left:20px}.Btn{color:#036;text-align:center;font-weight:bold;background-color:#FFF;background-image:url(../images/ongletStyle1.jpg);background-repeat:no-repeat;background-position:center center}.Btn:hover{color:red}.menu1h{background-color:#036;color:white;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;font-weight:bold;text-decoration:none;border-top:1px solid #036;border-bottom:1px solid #036;border-left:1px solid #036;border-right:1px solid white;border-collapse:collapse;display:block}.menu1h:hover{background-color:white;color:red;border:1px
+solid darkgreen;border-collapse:collapse}.menu1h_f{background-color:#036;color:white;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;font-weight:bold;text-decoration:none;border:1px
+solid #036;display:block}.menu1h_f:hover{background-color:white;color:red;border:1px
+solid darkgreen;border-collapse:collapse}.menu1v{background-color:#036;color:white;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;font-weight:bold;text-decoration:none;border:1px
+solid #036;border-collapse:collapse;display:block}.menu1v:hover{background-color:white;color:red;border:1px
+solid darkgreen;border-collapse:collapse}.menu2v{background-color:#58B;color:white;font-family:Verdana,Arial,Lucida,Tahoma;font-size:12px;font-weight:bold;text-decoration:none;border:1px
+solid #4277AB;border-collapse:collapse;float:left;display:block}.menu2v:hover{background-color:white;color:red;border:1px
+solid darkgreen;border-collapse:collapse}.menuEDF{background-color:#036;color:white;font-family:Verdana,Arial,Lucida,Tahoma;font-size:10px;text-decoration:none}.menuEDF:hover{color:#F80}.Bouton{color:#036;text-align:center;font-weight:bold;cursor:pointer;background-color:#FFF}input{border:2px
+solid green;color:#036;background-color:#FFF;background-image:url(../images/fond_4.bmp);background-repeat:repeat-x}.disabled_input{border:1px
+solid gray;color:grey;background-color:#FFF;background-image:url(../images/fond_4.bmp);background-repeat:repeat-x}.input0{border:0px;color:#036;background-color:#FFF;background-image:url(../images/fond_4.bmp)}.input2{border:1px
+solid green;color:#036;background-color:#FFF;background-image:url(../images/fond_4.bmp);background-repeat:repeat-x}.input3{border:1px
+solid black;color:#036;background-color:#EEE;background-image:url()}.input4{border:1px
+solid blue;color:#036;background-color:#FFF;background-image:url(../images/fond_4.bmp);background-repeat:repeat-x}.input5{border:1px
+solid darkblue;color:#036;background-color:#FFF;background-image:url(../images/fond_4.bmp);background-repeat:repeat-x}.input_btn{border:0px;cursor:pointer}textarea{border:2px
+solid green;color:#036;background-color:#FFF;background-image:url(../images/fond_5.bmp)}.TEXTAREA3{border:1px
+solid green;color:#036;background-color:#FFF;background-image:url()}.TEXTAREA4{border:1px
+solid green;color:#036;background-color:#EEE;background-image:url()}.hand{cursor:hand;cursor:pointer}
\ No newline at end of file
--- /dev/null
+@import "foo.css";\r
+@import 'bar/foo.css' print;\r
+@import '/css/foo.css'; /* abs, should not alter */\r
+@import 'http://foo.com/css/foo.css'; /* abs, should not alter */\r
+@import url(../foo.css) tv, projection;\r
+@import url("/css/foo.css"); /* abs, should not alter */\r
+@import url(/css2/foo.css); /* abs, should not alter */\r
+@import url(data:image/gif;base64,AAAA); /* data, should not alter */\r
+foo {background:url('bar/foo.png')}\r
+foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */\r
+foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */\r
+foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */
\ No newline at end of file
--- /dev/null
+@import "../foo.css";@import '../bar/foo.css' print;@import '/css/foo.css';@import 'http://foo.com/css/foo.css';@import url(../../foo.css) tv, projection;@import url("/css/foo.css");@import url(/css2/foo.css);@import url(data:image/gif;base64,AAAA);foo{background:url('../bar/foo.png')}foo{background:url('http://foo.com/css/foo.css')}foo{background:url("//foo.com/css/foo.css")}foo{background:url(data:image/gif;base64,AAAA)}
\ No newline at end of file
--- /dev/null
+@import "foo.css";
+@import 'bar/foo.css' print;
+@import '../bar/foo.css' print;
+@import '../../foo.css' print;
+@import '/css/foo.css'; /* abs, should not alter */
+@import 'http://foo.com/css/foo.css'; /* abs, should not alter */
+@import url(../foo.css) tv, projection;
+@import url("/css/foo.css"); /* abs, should not alter */
+@import url(/css2/foo.css); /* abs, should not alter */
+@import url(data:image/gif;base64,AAAA); /* data, should not alter */
+foo {background:url('bar/foo.png')}
+foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */
+foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */
+foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */
\ No newline at end of file
--- /dev/null
+@import "/_test_files/css/foo.css";@import '/_test_files/css/bar/foo.css' print;@import '/_test_files/bar/foo.css' print;@import '/foo.css' print;@import '/css/foo.css';@import 'http://foo.com/css/foo.css';@import url(/_test_files/foo.css) tv, projection;@import url("/css/foo.css");@import url(/css2/foo.css);@import url(data:image/gif;base64,AAAA);foo{background:url('/_test_files/css/bar/foo.png')}foo{background:url('http://foo.com/css/foo.css')}foo{background:url("//foo.com/css/foo.css")}foo{background:url(data:image/gif;base64,AAAA)}
\ No newline at end of file
--- /dev/null
+Test suite from http://search.cpan.org/~gtermars/CSS-Minifier-XS/
\ No newline at end of file
--- /dev/null
+/* http://www.w3.org/TR/css3-selectors/ */
+
+*\r
+E[foo]\r
+E[foo="bar"]\r
+E[foo~="bar"]\r
+E[foo^="bar"]\r
+E[foo$="bar"]\r
+E[foo*="bar"]\r
+E[hreflang|="en"]\r
+E:root\r
+E:nth-child(n)\r
+E:nth-last-child(n)\r
+E:nth-of-type(n)\r
+E:nth-last-of-type(n)\r
+E:first-child\r
+E:last-child\r
+E:first-of-type\r
+E:last-of-type\r
+E:only-child\r
+E:only-of-type\r
+E:empty\r
+E:link\r
+E:visited\r
+E:active\r
+E:hover\r
+E:focus\r
+E:target\r
+E:lang(fr)\r
+E:enabled\r
+E:disabled\r
+E:checked\r
+E::first-line\r
+E::first-letter\r
+E::selection\r
+E::before\r
+E::after\r
+E.warning#myid\r
+E:not(s)\r
+ > F
+ + F
+ ~ F {color: red;}
\ No newline at end of file
--- /dev/null
+*
+E[foo]
+E[foo="bar"]
+E[foo~="bar"]
+E[foo^="bar"]
+E[foo$="bar"]
+E[foo*="bar"]
+E[hreflang|="en"]
+E:root
+E:nth-child(n)
+E:nth-last-child(n)
+E:nth-of-type(n)
+E:nth-last-of-type(n)
+E:first-child
+E:last-child
+E:first-of-type
+E:last-of-type
+E:only-child
+E:only-of-type
+E:empty
+E:link
+E:visited
+E:active
+E:hover
+E:focus
+E:target
+E:lang(fr)
+E:enabled
+E:disabled
+E:checked
+E::first-line
+E::first-letter
+E::selection
+E::before
+E::after
+E.warning#myid
+E:not(s)>F+F~F{color:red}
\ No newline at end of file
--- /dev/null
+/* some CSS to try to exercise things in general */
+
+@import url( /more.css );
+
+ body, td, th {
+ font-family: Verdana , "Bitstream Vera Sans" , sans-serif ;
+
+ font-size : 12px;
+}
+
+.nav {
+ margin-left: 20%;
+}
+#main-nav {
+ background-color: red;
+ border: 1px solid #00ff77;
+}
+
+div#content
+h1 + p {
+ padding-top: 0;
+ margin-top: 0;
+}
+
+@media all and (min-width: 640px) {
+ #media-queries-1 { background-color: #0f0; }
+}
+
+@media screen and (max-width: 2000px) {
+ #media-queries-2 { background-color: #0f0; }
+}
\ No newline at end of file
--- /dev/null
+@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
+solid #0f7}div#content
+h1+p{padding-top:0;margin-top:0}@media all and (min-width: 640px){#media-queries-1{background-color:#0f0}}@media screen and (max-width: 2000px){#media-queries-2{background-color:#0f0}}
\ No newline at end of file
--- /dev/null
+/* Based on the original Style Sheet for the fisubsilver v2 Theme for phpBB version 2+\r
+Edited by Daz - http://www.forumimages.com - last updated 26-06-03 */\r
+/* The content of the posts (body of text) */\r
+/* General page style */\r
+\r
+\r
+\r
+ /* begin suggest post */\r
+ .float-l{\r
+ float: left;\r
+ }\r
+ \r
+ .form-suggest{\r
+ height:200px;\r
+ background:#DEE2D0;\r
+ vertical-align: top;\r
+ }\r
+ \r
+ .form-input input{\r
+ font-size: 10px;\r
+ }\r
+ \r
+ .hide{\r
+ display:none;\r
+ }\r
+ \r
+ .form-input textarea{\r
+ font-size: 11px;\r
+ width: 350px;\r
+ }\r
+ \r
+ .form-label{\r
+ font-size: 10px;\r
+ font-weight: bold;\r
+ line-height: 25px;\r
+ padding-right: 10px;\r
+ text-align: right;\r
+ width: 100px;\r
+ color: #39738F;\r
+ }\r
+ \r
+ .font-9{\r
+ font-size: 9px;\r
+ }\r
+ \r
+ .form-topic{\r
+ font-weight:bold;\r
+ \r
+ }\r
+ \r
+ .form-error{\r
+ color:red;\r
+ }\r
+ \r
+ .inline{\r
+ display: inline;\r
+ }\r
+ \r
+ .space-10{\r
+ clear: both;\r
+ font-size: 10px;\r
+ height: 10px;\r
+ line-height: 10px;\r
+ }\r
+ \r
+ .suggest-success{\r
+ color:green;\r
+ padding-left:10px;\r
+ font-size:11px;\r
+ font-weight:bold;\r
+ }\r
+ \r
+ .top{\r
+ vertical-align: top;\r
+ }\r
+ /* end suggest post */\r
+ \r
+table td{\r
+ padding:3px;\r
+} \r
+\r
+a:link,a:active,a:visited,a.postlink{\r
+ color: #006699;\r
+ text-decoration: none;\r
+}\r
+\r
+a:hover{\r
+ color: #DD6900;\r
+}\r
+\r
+a.admin:hover,a.mod:hover{\r
+ color: #DD6900;\r
+}\r
+\r
+a.but,a.but:hover,a.but:visited{\r
+ color: #000000;\r
+ text-decoration: none;\r
+}\r
+\r
+a.topictitle:visited{\r
+ color: #5493B4;\r
+}\r
+\r
+a.topictitle:hover{\r
+ color: #DD6900;\r
+}\r
+\r
+\r
+\r
+body{\r
+ color: #000000;\r
+ font: 11px Verdana,Arial,Helvetica,sans-serif;\r
+ margin: 0 10px 10px 10px;\r
+ padding: 0; \r
+ overflow:auto;\r
+}\r
+\r
+/* General font families for common tags */\r
+font,th,td,p{\r
+ font: 12px Verdana,Arial,Helvetica,sans-serif;\r
+}\r
+\r
+/* Form elements */\r
+form{\r
+ display: inline;\r
+}\r
+\r
+hr{\r
+ border: 0px solid #FFFFFF;\r
+ border-top-width: 1px;\r
+ height: 0px;\r
+}\r
+\r
+/* Gets rid of the need for border="0" on hyperlinked images */\r
+img{\r
+ border: 0 solid;\r
+}\r
+\r
+input{\r
+ font: 11px Verdana,Arial,Helvetica,sans-serif;\r
+}\r
+\r
+input.button,input.liteoption,.fakebut{\r
+ background: #FAFAFA;\r
+ border: 1px solid #000000;\r
+ font-size: 11px;\r
+}\r
+\r
+input.catbutton{\r
+ background: #FAFAFA;\r
+ border: 1px solid #000000;\r
+ font-size: 10px;\r
+}\r
+\r
+input.mainoption{\r
+ background: #FAFAFA;\r
+ border: 1px solid #000000;\r
+ font-size: 11px;\r
+ font-weight: bold;\r
+}\r
+\r
+input.post,textarea.post{\r
+ background: #FFFFFF;\r
+ border: 1px solid #000000;\r
+ font: 11px Verdana,Arial,Helvetica,sans-serif;\r
+ padding-bottom: 2px;\r
+ padding-left: 2px;\r
+}\r
+\r
+select{\r
+ background: #FFFFFF;\r
+ font: 11px Verdana,Arial,Helvetica,sans-serif;\r
+}\r
+\r
+table{\r
+ text-align: left;\r
+}\r
+\r
+td{\r
+ vertical-align: middle;\r
+}\r
+\r
+/* Category gradients*/\r
+td.cat{\r
+ background-color: #C2C6BA;\r
+ font-weight: bold;\r
+ height: 20px;\r
+ letter-spacing: 1px;\r
+ text-indent: 4px;\r
+}\r
+\r
+td.genmed,.genmed{\r
+ font-size: 11px;\r
+}\r
+\r
+/* This is for the table cell above the Topics,Post & Last posts on the index.php */\r
+td.rowpic{\r
+ background: #C2C6BA;\r
+}\r
+\r
+td.spacerow{\r
+ background: #E5E6E2;\r
+}\r
+\r
+/* Table Header cells */\r
+th{\r
+ background-color: #FADD31;\r
+ background-image: url(images/cellpic3.gif);\r
+ background-repeat: repeat-x;\r
+ color: #68685E;\r
+ font-size: 11px;\r
+ font-weight: bold;\r
+ line-height:16px;\r
+ height: 16px;\r
+ padding-left: 8px;\r
+ padding-right: 8px;\r
+ text-align: center;\r
+ white-space: nowrap;\r
+}\r
+\r
+/* Admin & Moderator Colours MODification */\r
+.admin,.mod{\r
+ font-size: 11px;\r
+ font-weight: bold;\r
+}\r
+\r
+.admin,a.admin,a.admin:visited{\r
+ color: #FFA34F;\r
+}\r
+\r
+/* This is the border line & background colour round the entire page */\r
+.bodyline{\r
+ background: #FFFFFF;\r
+ border: 1px solid #98AAB1;\r
+}\r
+\r
+.center{\r
+ text-align: center;\r
+}\r
+\r
+/* Code blocks */\r
+.code{\r
+ background: #FAFAFA;\r
+ border: 1px solid #D1D7DC;\r
+ color: #006600;\r
+ font: 12px Courier,"Courier New",sans-serif;\r
+ padding: 5px;\r
+}\r
+\r
+/* This is for the error messages that pop up */\r
+.errorline{\r
+ background: #E5E6E2;\r
+ border: 1px solid #8F8B8B;\r
+ color:#D92A2A;\r
+}\r
+\r
+.explaintitle{\r
+ color: #5C81B1;\r
+ font-size: 11px;\r
+ font-weight: bold;\r
+}\r
+\r
+/* This is the outline round the main forum tables */\r
+.forumline{\r
+ background: #FFFFFF;\r
+}\r
+\r
+/* General text */\r
+.gensmall{\r
+ font-size: 10px;\r
+}\r
+\r
+.h1-font{\r
+ color: #006699;\r
+ display: inline;\r
+ font: bold 13px Verdana, Arial, Helvetica, sans-serif;\r
+ margin: 0;\r
+ text-decoration: none;\r
+}\r
+\r
+.h2-font{\r
+ display: inline;\r
+ font-family: Verdana, Arial, Helvetica, sans-serif;\r
+ font-size: 11px;\r
+}\r
+\r
+.height1{\r
+ height: 1px;\r
+}\r
+\r
+.height22{\r
+ height: 22px;\r
+}\r
+\r
+.height25{\r
+ height: 25px;\r
+}\r
+\r
+.height28{\r
+ height: 28px;\r
+}\r
+\r
+.height30{\r
+ height: 30px;\r
+}\r
+\r
+.height40{\r
+ height: 40px;\r
+}\r
+\r
+/* This is the line in the posting page which shows the rollover\r
+help line. Colour value in row2 */\r
+.helpline{\r
+ border: 0 solid;\r
+ font-size: 10px;\r
+}\r
+\r
+.imgfolder{\r
+ margin: 1px 4px 1px 4px;\r
+}\r
+\r
+.imgspace{\r
+ margin-left: 1px;\r
+ margin-right: 2px;\r
+}\r
+\r
+/* Specify the space around images */\r
+.imgtopic,.imgicon{\r
+ margin-left: 3px;\r
+}\r
+\r
+.left{\r
+ text-align: left;\r
+}\r
+\r
+/* The largest text used in the index page title and toptic title etc. */\r
+.maintitle,h1,h2{\r
+ color: #5C81B1;\r
+ font: bold 20px/120% "Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;\r
+ text-decoration: none;\r
+}\r
+\r
+.maxwidth{\r
+ width: 100%;\r
+}\r
+\r
+.mod,a.mod,a.mod:visited{\r
+ color: #006600;\r
+}\r
+\r
+/* Name of poster in viewmsg.php and viewtopic.php and other places */\r
+.name{\r
+ font-size: 11px;\r
+ font-weight: bold;\r
+}\r
+\r
+/* Used for the navigation text,(Page 1,2,3 etc) and the navigation bar when in a forum */\r
+.nav{\r
+ font-size: 11px;\r
+ font-weight: bold;\r
+}\r
+\r
+.nowrap{\r
+ white-space: nowrap;\r
+}\r
+\r
+.postbody{\r
+ font-size: 12px;\r
+ line-height: 125%; \r
+}\r
+\r
+.postbody a{\r
+ text-decoration: underline;\r
+}\r
+\r
+/* Location,number of posts,post date etc */\r
+.postdetails{\r
+ color: #00396A;\r
+ font-size: 10px;\r
+}\r
+\r
+/* Quote blocks */\r
+.quote{\r
+ background: #F3F3EF;\r
+ border: 1px solid #C2C6BA;\r
+ color: #006699;\r
+ font-size: 11px;\r
+ line-height: 125%;\r
+}\r
+\r
+.right{\r
+ text-align: right;\r
+}\r
+\r
+/* Main table cell colours and backgrounds */\r
+.row1{\r
+ background: #F0F0EB;\r
+}\r
+\r
+.row2,.helpline{\r
+ background: #E5E6E2;\r
+}\r
+\r
+.row3{\r
+ background: #DBDBD4;\r
+}\r
+\r
+.subtitle,h2{\r
+ font: bold 18px/180% "Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;\r
+ text-decoration: none;\r
+}\r
+\r
+/* titles for the topics:could specify viewed link colour too */\r
+.topictitle {\r
+ color: #000000;\r
+ font-size: 11px;\r
+ font-weight: bold;\r
+}\r
+\r
+.underline{\r
+ text-decoration: underline;\r
+}\r
+\r
+.top{\r
+vertical-align:top;\r
+}\r
+\r
+.image-hspace{\r
+margin-right:3px;\r
+}\r
+\r
+.clear{\r
+clear:both;\r
+}
\ No newline at end of file
--- /dev/null
+.float-l{float:left}.form-suggest{height:200px;background:#DEE2D0;vertical-align:top}.form-input
+input{font-size:10px}.hide{display:none}.form-input
+textarea{font-size:11px;width:350px}.form-label{font-size:10px;font-weight:bold;line-height:25px;padding-right:10px;text-align:right;width:100px;color:#39738F}.font-9{font-size:9px}.form-topic{font-weight:bold}.form-error{color:red}.inline{display:inline}.space-10{clear:both;font-size:10px;height:10px;line-height:10px}.suggest-success{color:green;padding-left:10px;font-size:11px;font-weight:bold}.top{vertical-align:top}table
+td{padding:3px}a:link,a:active,a:visited,a.postlink{color:#069;text-decoration:none}a:hover{color:#DD6900}a.admin:hover,a.mod:hover{color:#DD6900}a.but,a.but:hover,a.but:visited{color:#000;text-decoration:none}a.topictitle:visited{color:#5493B4}a.topictitle:hover{color:#DD6900}body{color:#000;font:11px Verdana,Arial,Helvetica,sans-serif;margin:0
+10px 10px 10px;padding:0;overflow:auto}font,th,td,p{font:12px Verdana,Arial,Helvetica,sans-serif}form{display:inline}hr{border:0px
+solid #FFF;border-top-width:1px;height:0px}img{border:0
+solid}input{font:11px Verdana,Arial,Helvetica,sans-serif}input.button,input.liteoption,.fakebut{background:#FAFAFA;border:1px
+solid #000;font-size:11px}input.catbutton{background:#FAFAFA;border:1px
+solid #000;font-size:10px}input.mainoption{background:#FAFAFA;border:1px
+solid #000;font-size:11px;font-weight:bold}input.post,textarea.post{background:#FFF;border:1px
+solid #000;font:11px Verdana,Arial,Helvetica,sans-serif;padding-bottom:2px;padding-left:2px}select{background:#FFF;font:11px Verdana,Arial,Helvetica,sans-serif}table{text-align:left}td{vertical-align:middle}td.cat{background-color:#C2C6BA;font-weight:bold;height:20px;letter-spacing:1px;text-indent:4px}td.genmed,.genmed{font-size:11px}td.rowpic{background:#C2C6BA}td.spacerow{background:#E5E6E2}th{background-color:#FADD31;background-image:url(images/cellpic3.gif);background-repeat:repeat-x;color:#68685E;font-size:11px;font-weight:bold;line-height:16px;height:16px;padding-left:8px;padding-right:8px;text-align:center;white-space:nowrap}.admin,.mod{font-size:11px;font-weight:bold}.admin,a.admin,a.admin:visited{color:#FFA34F}.bodyline{background:#FFF;border:1px
+solid #98AAB1}.center{text-align:center}.code{background:#FAFAFA;border:1px
+solid #D1D7DC;color:#060;font:12px Courier,"Courier New",sans-serif;padding:5px}.errorline{background:#E5E6E2;border:1px
+solid #8F8B8B;color:#D92A2A}.explaintitle{color:#5C81B1;font-size:11px;font-weight:bold}.forumline{background:#FFF}.gensmall{font-size:10px}.h1-font{color:#069;display:inline;font:bold 13px Verdana,Arial,Helvetica,sans-serif;margin:0;text-decoration:none}.h2-font{display:inline;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px}.height1{height:1px}.height22{height:22px}.height25{height:25px}.height28{height:28px}.height30{height:30px}.height40{height:40px}.helpline{border:0
+solid;font-size:10px}.imgfolder{margin:1px
+4px 1px 4px}.imgspace{margin-left:1px;margin-right:2px}.imgtopic,.imgicon{margin-left:3px}.left{text-align:left}.maintitle,h1,h2{color:#5C81B1;font:bold 20px/120% "Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;text-decoration:none}.maxwidth{width:100%}.mod,a.mod,a.mod:visited{color:#060}.name{font-size:11px;font-weight:bold}.nav{font-size:11px;font-weight:bold}.nowrap{white-space:nowrap}.postbody{font-size:12px;line-height:125%}.postbody
+a{text-decoration:underline}.postdetails{color:#00396A;font-size:10px}.quote{background:#F3F3EF;border:1px
+solid #C2C6BA;color:#069;font-size:11px;line-height:125%}.right{text-align:right}.row1{background:#F0F0EB}.row2,.helpline{background:#E5E6E2}.row3{background:#DBDBD4}.subtitle,h2{font:bold 18px/180% "Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;text-decoration:none}.topictitle{color:#000;font-size:11px;font-weight:bold}.underline{text-decoration:underline}.top{vertical-align:top}.image-hspace{margin-right:3px}.clear{clear:both}
\ No newline at end of file
--- /dev/null
+/* test unusual, but valid strings in CSS */\r
+\r
+foo[attr="multiple spaces"] {\r
+ content: "Hello World!";\r
+}\r
+\r
+foo[attr="Hel\\r
+lo"] {\r
+ content: " \"World\"";\r
+}\r
--- /dev/null
+foo[attr="multiple spaces"]{content:"Hello World!"}foo[attr="Hel\
+lo"]{content:" \"World\""}
\ No newline at end of file
--- /dev/null
+/* from http://www.vladimirated.com/web-development-minify-css-using-php-and-cssmin-class */
+
+ #comments_inviter #close_me {
+ clear: both;
+ text-align: center;
+ border-top: 1px solid #eeeeee;
+ padding-top: 10px;
+ }
+
+ #comments_inviter #close_me span {
+ color: #108eed;
+ cursor: pointer;
+ font-weight: bold;
+ }
+
+ #comments_inviter img {
+ float: left;
+ margin-right: 3px;
+ margin-bottom: 10px;
+ }
+
+ #comments_inviter {
+ width: 200px;
+ background-color: #FFFFFF;
+ border: 4px solid #eeeeee;
+ font-size: 10px;
+ font-family: verdana;
+ padding: 10px;
+ color: #333333;
+ }
+
+ .one_com {
+ background-color: #FAFAFA;
+ padding: 10px;
+ margin-bottom: 20px;
+ border: 1px solid #EEEEEE;
+ }
+
+ .one_com .com_says, .one_com .com_det {
+ text-transform: lowercase;
+ color: #333333;
+ padding: 0px;
+ font-family: verdana;
+ margin: 0px;
+ font-size: 13px;
+ font-weight: bold;
+ }
+
+ .flvPlayer {
+ text-align: center;
+ border: 5px solid #dddddd;
+ width: 320px;
+ }
+
+ .one_com .com_det {
+ font-size: 10px;
+ font-weight: normal;
+ margin-bottom: 20px;
+ padding-bottom: 10px;
+ border-bottom: 8px solid #eeeeee;
+ }
+
+ .one_com .com_det a {
+ text-decoration: none;
+ }
+
+ .one_com .com_txt {
+ background-color: #ffffff;
+ margin-bottom: 10px;
+ border-bottom: 2px solid #eeeeee
+ }
+
+ .one_com .com_txt p {
+ font-family: verdana;
+ font-size: 13px;
+ color: #777777;
+ margin: 0px;
+ padding: 5px;
+ padding-bottom: 10px;
+ text-transform: lowercase;
+ }
+
+ .one_com .com_says a {
+ color: #333333;
+ }
+
+ .one_com .com_det a {
+ color: #333333;
+ }
+
+ .post_box .related_posts {
+
+ }
+
+ .post_box .related_posts p {
+ padding: 0px;
+ margin: 0px;
+ padding-bottom: 20px;
+ padding-left: 35px;
+ font-family: verdana;
+
+ }
+
+ .post_box .related_posts a {
+ color: #108eed;
+ }
+
+ .post_nav_2 p {
+
+ text-align: center;
+ color: #cccccc;
+ font-family: verdana;
+ }
+
+ .post_box .related_posts h3, #comments_box #respond, .comments_posted h3 {
+ padding: 0px;
+ margin: 0px;
+ font-size: 18px;
+ color: #FF8000;
+ padding-top: 30px;
+ margin-bottom: 20px;
+ width: 300px;
+ border-bottom: 5px solid #e0e0e0;
+ }
+
+ .comments_posted {
+
+ margin-bottom: 50px;
+
+ }
+
+ .comments_posted h3 {
+ padding: 0px;
+ margin: 0px;
+ margin-bottom: 20px;
+
+ }
+
+ .cmt_txtarea {
+ width: 300px;
+ height: 100px;
+
+ }
+
+ #comments_box #respond {
+
+ padding-top: 0px;
+ margin-bottom: 0px;
+
+ }
+
+ .pagetitle {
+ color: #65DA33;
+ text-align: center;
+ }
+
+ #searchform {
+ padding: 0px;
+ margin: 0px;
+ }
+
+ .si {
+ background-color: #FFFFEE;
+ border: 1px solid #e0e0e0;
+ }
+
+ #rightcol #r_news, #rightcol #linksbro, #rightcol #quick_tags {
+ margin-top: 30px;
+ padding-bottom: 10px;
+ }
+
+ #post_nav p {
+ padding: 0px;
+ margin: 0px;
+ padding-bottom: 5px;
+ }
+
+ #post_nav {
+ text-align: left;
+ padding-bottom: 15px;
+ }
+
+ #post_nav a, .post_nav_2 p a {
+ text-decoration: none;
+ font-family: Verdana;
+ font-size: 12px;
+ color: #108eed;
+ }
+
+ #post_nav a:hover, .post_nav_2 p a:hover {
+ text-decoration: underline;
+ color: #FF8000;
+ }
+
+ #rightcol #about {
+ padding-bottom: 10px;
+ }
+
+ #rightcol #r_news input {
+ color: #333333;
+ font-size: 12px;
+ }
+
+ #header {
+ height: 200px;
+ width: 100%;
+ background-image: url('images/header_bg.jpg');
+ background-repeat: x-repeat;
+ }
+
+ #header img {
+
+ float: right;
+ margin-right: -3px;
+ z-index: 100;
+
+ }
+
+ .tags {
+ text-transform: lowercase;
+ color: #333333;
+ font-family: arial;
+ font-size: 12px;
+ border-top: 2px dotted #EEEEEE;
+ width: 300px;
+ padding-top: 20px;
+ padding-bottom: 0px;
+ margin-top: 0px;
+ padding-left: 20px;
+ padding-right: 20px;
+ }
+
+ .tags a {
+ color: #108eed;
+ }
+
+ .tags p {
+ text-align: left;
+ margin: 0px;
+ padding: 0px;
+ }
+
+ blockquote strong {
+ font-family: verdana;
+ display: block;
+ margin-top: 10px;
+ color: #FF0000;
+ font-style: italic;
+ text-align: right;
+ }
+
+ blockquote {
+ margin: 0px;
+ background-color: #eeeeee;
+ border: 2px solid #dddddd;
+ padding: 24px;
+ padding-top: 10px;
+ padding-left: 60px;
+ padding-bottom: 10px;
+ font-size: 13px;
+ color: #333333;
+ margin-bottom: 30px;
+ margin-top: 10px;
+ }
+
+
+ html>body #header img { margin-right: 0px; }
+
+ #subscribe h3 {
+ color: #ff0000;
+ margin-top: 30px;
+ padding: 20px;
+ }
+
+ .post_actions a{
+ color: #108eed;
+ }
+
+ .post_actions {
+ border-top: 4px solid #DDDDDD;
+ border-bottom: 1px solid #EEEEEE;
+ text-align: center;
+ background-color: #FFFFDd;
+ color: #dddddd;
+ white-space: no-wrap;
+ padding-left: 20px;
+ padding-bottom: 5px;
+ text-transform: capitalize;
+ }
+
+ #subscribe td {
+ color: #333333;
+ font-size: 12px;
+ text-transform: lowercase;
+ }
+
+ #subscribe input {
+ font-size: 13px;
+ color: #333333;
+ }
+
+ .post_content {
+ font-size: 13px;
+ margin-top: 10px;
+ padding-bottom: 10px;
+ text-align: justify;
+ font-family: verdana;
+ }
+
+ .post_content p {
+ margin: 0px;
+ padding: 0px;
+ padding-bottom: 20px;
+ line-height: 20px;
+ }
+
+ #header h1 {
+ z-index: 200;
+ margin: 0px;
+ position: absolute;
+ float: left;
+ text-transform: lowercase;
+ padding: 0px;
+ font-size: 45px;
+ margin-top: 70px;
+ margin-left: 40px;
+
+ }
+
+ #header h1 a {
+ white-space: no-wrap;
+ text-decoration: none;
+ color: #FAFAFA;
+ display: block
+ }
+
+ #header h1 a:hover {
+ color: #FAFAFA;
+ border-bottom: 3px dotted #FAFAFA;
+ }
+
+ html>body #header h1 { margin-left: 60px; }
+
+ body {
+ margin: 0px;
+ padding: 0px;
+ height: 100%;
+ width: 100%;
+ font-family: 'Lucida Sans Unicode', 'Lucida Grande', Sans-Serif, Verdana, Arial;
+ font-size: 12px;
+ }
+
+ #leftcol {
+ float: left;
+ width: 200px;
+ margin-left: 0px;
+ margin-top: 17px;
+ color: #000;
+ padding: 3px;
+ height: 100%;
+ }
+
+ #leftcol .box_head h3 {
+ text-transform: uppercase;
+ padding: 0px;
+ margin: 0px;
+ font-family: georgia;
+ font-size: 18px;
+ color: #dddddd;
+ border-top: 4px solid #dddddd;
+ border-bottom: 4px solid #cccccc;
+ padding-left: 10px;
+ padding-top: 10px;
+ padding-bottom: 10px;
+ background-image: url('images/stripesbg.png');
+ margin-bottom: 10px;
+ }
+
+ #leftcol .box_head input {
+ text-transform: lowercase;
+ color: #333333;
+ }
+
+ #leftcol .box_head {
+ margin-left: 7px;
+ background-color: #ffefd4;
+ border-bottom: 2px solid #eeeeee;
+ padding-bottom: 20px;
+ margin-bottom: 30px;
+ }
+
+ #leftcol .box_head p a {
+ color: #0a2d4d;
+ display: block;
+ text-decoration: none;
+ border-bottom: 3px solid #fefefe;
+ padding-top: 20px;
+ text-transform: lowercase;
+ padding-bottom: 20px;
+ padding-left: 5px;
+ padding-right: 5px;
+ }
+
+ #leftcol .box_head p a:hover {
+ background-color: #fafafa;
+ border-bottom: 3px solid #eeeeee;
+ color: #000000;
+ }
+
+ #leftcol .box_head p {
+ text-align: left;
+ margin: 0px;
+ width: 170px;
+ padding-bottom: 0px;
+ padding-top: 0px;
+ font-size: 11px;
+ }
+
+ #rightcol {
+ position: absolute;
+ left: 77%;
+ top: 278px;
+ border: 3px solid #eeeeee;
+ width: 200px;
+ z-index: 3;
+ color: #333333;
+ padding: 10px;
+ text-transform: lowercase;
+
+ }
+
+ #rightcol p {
+ padding: 0px;
+ marging: 0px;
+ text-align: justify;
+ }
+
+ #rightcol #about img, #rightcol #linksbro img {
+ border: 5px solid #eeeeee;
+ }
+
+ #rightcol #about h3, #rightcol #r_news h3, #rightcol #linksbro h3, #rightcol #quick_tags h3 {
+ background-color: #fafafa;
+ border: 1px dotted #e0e0e0;
+ font-size: 14px;
+ color: #104bbc;
+ padding: 5px;
+ padding-top: 10px;
+ font-family: Arial;
+ padding-bottom: 10px;
+ }
+
+ #rightcol #about p a, #rightcol #r_news p a, #rightcol #linksbro p a {
+ color: #108eed;
+ }
+
+ #rightcol #about p, #rightcol #r_news p, #rightcol #linksbro p {
+ font-size: 12px;
+ text-align: left;
+ }
+
+ #content_warp {
+ margin: 20px 25% 0 215px;
+ padding: 3px;
+ color: #000;
+ background-color: #ededed;
+ }
+
+ #content {
+ margin: 5px;
+ background-color: #FFFFFF;
+ padding: 10px;
+ }
+
+
+ #footer {
+ width: 99%;
+ margin-top: 30px;
+ height: 98px;
+ background-color: #101b1d;
+ }
+
+ #footer td a {
+ color: #FF8000;
+ }
+
+ #footer td a img {
+ border: 2px solid #108eed;
+ }
+
+ #footer td p {
+ font-family: Verdana;
+ font-size: 10px;
+ color: #c0c0c0;
+ padding: 0px;
+ margin: 0px;
+ text-align: center;
+ padding-bottom: 10px;
+ }
+
+ .s_offer {
+ color: #65DA33;
+ font-size: 20px;
+ font-weight: bold;
+ font-style: normal;
+ }
+
+ .post_box {
+ text-transform: lowercase;
+ margin-bottom: 40px;
+ }
+
+ #newsletter_box {
+ text-transform: lowercase;
+ margin-bottom: 10px;
+ margin-top: 30px;
+ font-style: normal;
+ background-color: #ffffff;
+ border: 5px solid #dddddd;
+ }
+
+ #newsletter_head {
+ color: #EEEEEE;
+ font-family: Georgia;
+ background-image: url('images/stripesbg.png');
+ padding: 10px;
+ padding-left: 30px;
+ border-bottom: 5px solid #dddddd;
+ }
+
+ #newsletter_body {
+ color: #333333;
+ font-family: Verdana;
+ text-align: justify;
+ background-color: #FFFFFF;
+ padding: 10px;
+ font-size: 13px;
+ }
+
+ .s_offer {
+ color: #65DA33;
+ font-size: 26px;
+ font-weight: bold;
+ font-style: normal;
+ }
+
+ .post_title a {
+ color: #EEEEEE;
+ text-decoration: none;
+ }
+
+ .post_title a:hover {
+ color: #c0c0c0;
+ }
+
+ .post_title {
+ background-image: url('images/stripe_post.png');
+ text-transform: uppercase;
+ font-size: 18px;
+ font-family: georgia;
+ padding: 10px;
+ border-top: 4px solid #c0c0c0;
+ margin: 0px;
+ border-bottom: 2px solid #ffffdd;
+ }
+
+ .post_det {
+ text-transform: none;
+ margin: 0px;
+ border-top: 1px solid #f0f0f0;
+ padding: 0px;
+ padding-top: 5px;
+ color: #999999;
+ font-size: 10px;
+ font-family: verdana;
+ margin-bottom: 20px;
+ background-color: #eeeeee;
+ padding-bottom: 5px;
+ padding-left: 10px;
+ text-align: left;
+ border-bottom: 2px solid #dddddd;
+ }
+
+ .post_det a {
+ color: #999999;
+ text-decoration: none;
+ }
+
+
+ .subtle {
+ text-transform: lowercase;
+ font-size: 10px;
+ font-family: verdana;
+ color: #108eed;
+ text-align: justify;
+ }
+
+ #top_menu #navlist, #top_menu #navlist li {
+ padding:0px;
+ margin: 0px;
+ padding-top: 14px;
+ text-transform: lowercase;
+ padding-bottom: 17px;
+ padding-left: 30px;
+ border-left: 1px solid #65cdef;
+ }
+
+ #top_menu #navlist, #top_menu #navlist li #first {
+
+ border-left: 0px;
+
+ }
+
+ #top_menu #navlist {
+ padding-left: 30px;
+ background-color: #1dabd9;
+ border-top: 5px solid #0e96c3;
+ border-bottom: 5px solid #0e96c3;
+ }
+
+ #top_menu #navlist li {
+ color: #444444;
+ font-size: 10px;
+ display: inline;
+ list-style-type: none;
+ padding-right: 30px;
+ }
+
+ #top_menu #navlist li a {
+ text-decoration: none;
+ font-family: Verdana;
+ color: #fafafa;
+ font-size: 12px;
+ font-weight: bold;
+ }
+
+ #top_menu #navlist li a:hover {
+ color: #333333;
+ }
+
+ .post_content a {
+ color: #108eed;
+ }
+
+ ul#tagcloud { padding:0; margin:0; text-align:center; list-style:none; }
+ ul#tagcloud li { display:inline; font-size:70%; color:#ccc; background: none; padding: 0;}
+ ul#tagcloud li a, ul#tagcloud li a:link { text-decoration:none; }
+ ul#tagcloud li a:hover { text-decoration:underline; }
+ ul#tagcloud li.t1 a { color:#797979; font-size: 120%; }
+ ul#tagcloud li.t2 a { color:#6d6d6d; font-size: 160%; }
+ ul#tagcloud li.t3 a { color:#616161; font-size: 190%; }
+ ul#tagcloud li.t4 a { color:#555555; font-size: 210%; }
+ ul#tagcloud li.t5 a { color:#484848; font-size: 230%; }
+ ul#tagcloud li.t6 a { color:#3c3c3c; font-size: 250%; }
+ ul#tagcloud li.t7 a { color:#303030; font-size: 270%; }
+ ul#tagcloud li.t8 a { color:#242424; font-size: 290%; }
+ ul#tagcloud li.t9 a { color:#181818; font-size: 310%; }
+ ul#tagcloud li.t10 a { color:#0c0c0c; font-size: 330%; }
\ No newline at end of file
--- /dev/null
+#comments_inviter
+#close_me{clear:both;text-align:center;border-top:1px solid #eee;padding-top:10px}#comments_inviter #close_me
+span{color:#108eed;cursor:pointer;font-weight:bold}#comments_inviter
+img{float:left;margin-right:3px;margin-bottom:10px}#comments_inviter{width:200px;background-color:#FFF;border:4px
+solid #eee;font-size:10px;font-family:verdana;padding:10px;color:#333}.one_com{background-color:#FAFAFA;padding:10px;margin-bottom:20px;border:1px
+solid #EEE}.one_com .com_says, .one_com
+.com_det{text-transform:lowercase;color:#333;padding:0px;font-family:verdana;margin:0px;font-size:13px;font-weight:bold}.flvPlayer{text-align:center;border:5px
+solid #ddd;width:320px}.one_com
+.com_det{font-size:10px;font-weight:normal;margin-bottom:20px;padding-bottom:10px;border-bottom:8px solid #eee}.one_com .com_det
+a{text-decoration:none}.one_com
+.com_txt{background-color:#fff;margin-bottom:10px;border-bottom:2px solid #eee}.one_com .com_txt
+p{font-family:verdana;font-size:13px;color:#777;margin:0px;padding:5px;padding-bottom:10px;text-transform:lowercase}.one_com .com_says
+a{color:#333}.one_com .com_det
+a{color:#333}.post_box
+.related_posts{}.post_box .related_posts
+p{padding:0px;margin:0px;padding-bottom:20px;padding-left:35px;font-family:verdana}.post_box .related_posts
+a{color:#108eed}.post_nav_2
+p{text-align:center;color:#ccc;font-family:verdana}.post_box .related_posts h3, #comments_box #respond, .comments_posted
+h3{padding:0px;margin:0px;font-size:18px;color:#FF8000;padding-top:30px;margin-bottom:20px;width:300px;border-bottom:5px solid #e0e0e0}.comments_posted{margin-bottom:50px}.comments_posted
+h3{padding:0px;margin:0px;margin-bottom:20px}.cmt_txtarea{width:300px;height:100px}#comments_box
+#respond{padding-top:0px;margin-bottom:0px}.pagetitle{color:#65DA33;text-align:center}#searchform{padding:0px;margin:0px}.si{background-color:#FFE;border:1px
+solid #e0e0e0}#rightcol #r_news, #rightcol #linksbro, #rightcol
+#quick_tags{margin-top:30px;padding-bottom:10px}#post_nav
+p{padding:0px;margin:0px;padding-bottom:5px}#post_nav{text-align:left;padding-bottom:15px}#post_nav a, .post_nav_2 p
+a{text-decoration:none;font-family:Verdana;font-size:12px;color:#108eed}#post_nav a:hover, .post_nav_2 p a:hover{text-decoration:underline;color:#FF8000}#rightcol
+#about{padding-bottom:10px}#rightcol #r_news
+input{color:#333;font-size:12px}#header{height:200px;width:100%;background-image:url('images/header_bg.jpg');background-repeat:x-repeat}#header
+img{float:right;margin-right: -3px;z-index:100}.tags{text-transform:lowercase;color:#333;font-family:arial;font-size:12px;border-top:2px dotted #EEE;width:300px;padding-top:20px;padding-bottom:0px;margin-top:0px;padding-left:20px;padding-right:20px}.tags
+a{color:#108eed}.tags
+p{text-align:left;margin:0px;padding:0px}blockquote
+strong{font-family:verdana;display:block;margin-top:10px;color:#F00;font-style:italic;text-align:right}blockquote{margin:0px;background-color:#eee;border:2px
+solid #ddd;padding:24px;padding-top:10px;padding-left:60px;padding-bottom:10px;font-size:13px;color:#333;margin-bottom:30px;margin-top:10px}html>body #header
+img{margin-right:0px}#subscribe
+h3{color:#f00;margin-top:30px;padding:20px}.post_actions
+a{color:#108eed}.post_actions{border-top:4px solid #DDD;border-bottom:1px solid #EEE;text-align:center;background-color:#FFD;color:#ddd;white-space:no-wrap;padding-left:20px;padding-bottom:5px;text-transform:capitalize}#subscribe
+td{color:#333;font-size:12px;text-transform:lowercase}#subscribe
+input{font-size:13px;color:#333}.post_content{font-size:13px;margin-top:10px;padding-bottom:10px;text-align:justify;font-family:verdana}.post_content
+p{margin:0px;padding:0px;padding-bottom:20px;line-height:20px}#header
+h1{z-index:200;margin:0px;position:absolute;float:left;text-transform:lowercase;padding:0px;font-size:45px;margin-top:70px;margin-left:40px}#header h1
+a{white-space:no-wrap;text-decoration:none;color:#FAFAFA;display:block}#header h1 a:hover{color:#FAFAFA;border-bottom:3px dotted #FAFAFA}html>body #header
+h1{margin-left:60px}body{margin:0px;padding:0px;height:100%;width:100%;font-family:'Lucida Sans Unicode','Lucida Grande',Sans-Serif,Verdana,Arial;font-size:12px}#leftcol{float:left;width:200px;margin-left:0px;margin-top:17px;color:#000;padding:3px;height:100%}#leftcol .box_head
+h3{text-transform:uppercase;padding:0px;margin:0px;font-family:georgia;font-size:18px;color:#ddd;border-top:4px solid #ddd;border-bottom:4px solid #ccc;padding-left:10px;padding-top:10px;padding-bottom:10px;background-image:url('images/stripesbg.png');margin-bottom:10px}#leftcol .box_head
+input{text-transform:lowercase;color:#333}#leftcol
+.box_head{margin-left:7px;background-color:#ffefd4;border-bottom:2px solid #eee;padding-bottom:20px;margin-bottom:30px}#leftcol .box_head p
+a{color:#0a2d4d;display:block;text-decoration:none;border-bottom:3px solid #fefefe;padding-top:20px;text-transform:lowercase;padding-bottom:20px;padding-left:5px;padding-right:5px}#leftcol .box_head p a:hover{background-color:#fafafa;border-bottom:3px solid #eee;color:#000}#leftcol .box_head
+p{text-align:left;margin:0px;width:170px;padding-bottom:0px;padding-top:0px;font-size:11px}#rightcol{position:absolute;left:77%;top:278px;border:3px
+solid #eee;width:200px;z-index:3;color:#333;padding:10px;text-transform:lowercase}#rightcol
+p{padding:0px;marging:0px;text-align:justify}#rightcol #about img, #rightcol #linksbro
+img{border:5px
+solid #eee}#rightcol #about h3, #rightcol #r_news h3, #rightcol #linksbro h3, #rightcol #quick_tags
+h3{background-color:#fafafa;border:1px
+dotted #e0e0e0;font-size:14px;color:#104bbc;padding:5px;padding-top:10px;font-family:Arial;padding-bottom:10px}#rightcol #about p a, #rightcol #r_news p a, #rightcol #linksbro p
+a{color:#108eed}#rightcol #about p, #rightcol #r_news p, #rightcol #linksbro
+p{font-size:12px;text-align:left}#content_warp{margin:20px
+25% 0 215px;padding:3px;color:#000;background-color:#ededed}#content{margin:5px;background-color:#FFF;padding:10px}#footer{width:99%;margin-top:30px;height:98px;background-color:#101b1d}#footer td
+a{color:#FF8000}#footer td a
+img{border:2px
+solid #108eed}#footer td
+p{font-family:Verdana;font-size:10px;color:#c0c0c0;padding:0px;margin:0px;text-align:center;padding-bottom:10px}.s_offer{color:#65DA33;font-size:20px;font-weight:bold;font-style:normal}.post_box{text-transform:lowercase;margin-bottom:40px}#newsletter_box{text-transform:lowercase;margin-bottom:10px;margin-top:30px;font-style:normal;background-color:#fff;border:5px
+solid #ddd}#newsletter_head{color:#EEE;font-family:Georgia;background-image:url('images/stripesbg.png');padding:10px;padding-left:30px;border-bottom:5px solid #ddd}#newsletter_body{color:#333;font-family:Verdana;text-align:justify;background-color:#FFF;padding:10px;font-size:13px}.s_offer{color:#65DA33;font-size:26px;font-weight:bold;font-style:normal}.post_title
+a{color:#EEE;text-decoration:none}.post_title a:hover{color:#c0c0c0}.post_title{background-image:url('images/stripe_post.png');text-transform:uppercase;font-size:18px;font-family:georgia;padding:10px;border-top:4px solid #c0c0c0;margin:0px;border-bottom:2px solid #ffd}.post_det{text-transform:none;margin:0px;border-top:1px solid #f0f0f0;padding:0px;padding-top:5px;color:#999;font-size:10px;font-family:verdana;margin-bottom:20px;background-color:#eee;padding-bottom:5px;padding-left:10px;text-align:left;border-bottom:2px solid #ddd}.post_det
+a{color:#999;text-decoration:none}.subtle{text-transform:lowercase;font-size:10px;font-family:verdana;color:#108eed;text-align:justify}#top_menu #navlist, #top_menu #navlist
+li{padding:0px;margin:0px;padding-top:14px;text-transform:lowercase;padding-bottom:17px;padding-left:30px;border-left:1px solid #65cdef}#top_menu #navlist, #top_menu #navlist li
+#first{border-left:0px}#top_menu
+#navlist{padding-left:30px;background-color:#1dabd9;border-top:5px solid #0e96c3;border-bottom:5px solid #0e96c3}#top_menu #navlist
+li{color:#444;font-size:10px;display:inline;list-style-type:none;padding-right:30px}#top_menu #navlist li
+a{text-decoration:none;font-family:Verdana;color:#fafafa;font-size:12px;font-weight:bold}#top_menu #navlist li a:hover{color:#333}.post_content
+a{color:#108eed}ul#tagcloud{padding:0;margin:0;text-align:center;list-style:none}ul#tagcloud
+li{display:inline;font-size:70%;color:#ccc;background:none;padding:0}ul#tagcloud li a, ul#tagcloud li a:link{text-decoration:none}ul#tagcloud li a:hover{text-decoration:underline}ul#tagcloud li.t1
+a{color:#797979;font-size:120%}ul#tagcloud li.t2
+a{color:#6d6d6d;font-size:160%}ul#tagcloud li.t3
+a{color:#616161;font-size:190%}ul#tagcloud li.t4
+a{color:#555;font-size:210%}ul#tagcloud li.t5
+a{color:#484848;font-size:230%}ul#tagcloud li.t6
+a{color:#3c3c3c;font-size:250%}ul#tagcloud li.t7
+a{color:#303030;font-size:270%}ul#tagcloud li.t8
+a{color:#242424;font-size:290%}ul#tagcloud li.t9
+a{color:#181818;font-size:310%}ul#tagcloud li.t10
+a{color:#0c0c0c;font-size:330%}
\ No newline at end of file
--- /dev/null
+@import "/_test_files/css_uriRewriter/foo.css";
+@import '/_test_files/css_uriRewriter/bar/foo.css' print;
+@import '/_test_files/bar/foo.css' print;
+@import '/foo.css' print;
+@import '/css/foo.css'; /* abs, should not alter */
+@import 'http://foo.com/css/foo.css'; /* abs, should not alter */
+@import url(/_test_files/foo.css) tv, projection;
+@import url("/css/foo.css"); /* abs, should not alter */
+@import url(/css2/foo.css); /* abs, should not alter */
+@import url(data:image/gif;base64,AAAA); /* data, should not alter */
+foo {background:url('/_test_files/css_uriRewriter/bar/foo.png')}
+foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */
+foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */
+foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */
\ No newline at end of file
--- /dev/null
+@import "foo.css";
+@import 'bar/foo.css' print;
+@import '../bar/foo.css' print;
+@import '../../foo.css' print;
+@import '/css/foo.css'; /* abs, should not alter */
+@import 'http://foo.com/css/foo.css'; /* abs, should not alter */
+@import url(../foo.css) tv, projection;
+@import url("/css/foo.css"); /* abs, should not alter */
+@import url(/css2/foo.css); /* abs, should not alter */
+@import url(data:image/gif;base64,AAAA); /* data, should not alter */
+foo {background:url('bar/foo.png')}
+foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */
+foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */
+foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */
\ No newline at end of file
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
+<head>
+ <!-- comments get removed -->
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
+ <meta name="author" content="Dave Shea" />
+ <!-- also whitespace around block or undisplayed elements -->
+ <meta name="keywords" content="design, css, cascading, style, sheets, xhtml, graphic design, w3c, web standards, visual, display" />
+ <meta name="description" content="A demonstration of what can be accomplished visually through CSS-based design." />
+ <meta name="robots" content="all" />
+ <title>css Zen Garden: The Beauty in CSS Design</title>
+
+ <!-- to correct the unsightly Flash of Unstyled Content. http://www.bluerobot.com/web/css/fouc.asp -->
+ <script type="text/javascript"><!--
+// js comment inside SCRIPT element
+var is = {
+ ie: navigator.appName == 'Microsoft Internet Explorer',
+ java: navigator.javaEnabled(),
+ ns: navigator.appName == 'Netscape',
+ ua: navigator.userAgent.toLowerCase(),
+ version: parseFloat(navigator.appVersion.substr(21)) ||
+ parseFloat(navigator.appVersion),
+ win: navigator.platform == 'Win32'
+}
+is.mac = is.ua.indexOf('mac') >= 0;
+if (is.ua.indexOf('opera') >= 0) {
+ is.ie = is.ns = false;
+ is.opera = true;
+}
+if (is.ua.indexOf('gecko') >= 0) {
+ is.ie = is.ns = false;
+ is.gecko = true;
+}
+// --></script>
+<script type="text/javascript">
+ //<![CDATA[
+ var i = 0;
+ while (++i < 10)
+ {
+ // ...
+ }
+ //]]>
+</script>
+<script type="text/javascript">
+ /* <![CDATA[ */ i = 1; /* ]]> */
+</script>
+<script type="text/javascript">
+ (i < 1); /* CDATA needed */
+</script>
+ <!--[if IE 6]>
+ <style type="text/css">
+/*! copyright: you'll need CDATA for this < & */
+body {background:white;}
+ </style>
+ <![endif]-->
+ <style type="text/css" title="currentStyle" media="screen">
+ @import "/001/001.css";
+/*\*/ css hack {} /* */
+/* normal CSS comment */
+/*/*/ css hack {} /* */
+css hack {
+ display/**/:/**/none;
+ display:none;
+}
+ </style>
+ <link
+ rel="Shortcut Icon"
+ type="image/x-icon"
+ href="http://www.csszengarden.com/favicon.ico" />
+ <link
+ rel="alternate"
+ type="application/rss+xml"
+ title="RSS"
+ href="http://www.csszengarden.com/zengarden.xml" />
+</head>
+<body id="css-zen-garden">
+<!--[if !IE]>--><p>Browser != IE</p><!--<![endif]-->
+<div id="container">
+ <div id="pageHeader">
+ <h1><span>css Zen Garden</span></h1>
+ <h2><span>The Beauty of <acronym title="Cascading Style Sheets">CSS</acronym> \r
+Design</span></h2>
+ </div>
+ <pre>
+ White space is important here!
+ </pre>
+ <div id="quickSummary">
+ <p class="p1"><span>A demonstration of what can be accomplished visually through <acronym title="Cascading Style Sheets">CSS</acronym>-based design. Select any style sheet from the list to load it into this page.</span></p>
+ <p class="p2"><span>Download the sample <a href="/zengarden-sample.html" title="This page's source HTML code, not to be modified.">html file</a> and <a href="/zengarden-sample.css" title="This page's sample CSS, the file you may modify.">css file</a></span></p>
+ </div>
+ <textarea name="comment" id="comment" rows="6" class="maxwidth" cols="80">66666
+
+1234567890</textarea>
+</div>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html
+xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" ><head><meta
+http-equiv="content-type" content="text/html; charset=iso-8859-1" /><meta
+name="author" content="Dave Shea" /><meta
+name="keywords" content="design, css, cascading, style, sheets, xhtml, graphic design, w3c, web standards, visual, display" /><meta
+name="description" content="A demonstration of what can be accomplished visually through CSS-based design." /><meta
+name="robots" content="all" /><title>css Zen Garden: The Beauty in CSS Design</title> <script type="text/javascript">var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
+is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
+if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}</script> <script type="text/javascript">/*<![CDATA[*/var i=0;while(++i<10)
+{}/*]]>*/</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">/*<![CDATA[*/(i<1);/*]]>*/</script> <!--[if IE 6]><style type="text/css">/*<![CDATA[*/
+/* copyright: you'll need CDATA for this < & */
+body{background:white}/*]]>*/</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*/css
+hack{}/**/ /*/*/css
+hack{}/**/css
+hack{display/**/:/**/none;display:none}</style><link
+rel="Shortcut Icon"
+type="image/x-icon"
+href="http://www.csszengarden.com/favicon.ico" /><link
+rel="alternate"
+type="application/rss+xml"
+title="RSS"
+href="http://www.csszengarden.com/zengarden.xml" /></head><body
+id="css-zen-garden"> <!--[if !IE]>--><p>Browser != IE</p><!--<![endif]--><div
+id="container"><div
+id="pageHeader"><h1><span>css Zen Garden</span></h1><h2><span>The Beauty of <acronym
+title="Cascading Style Sheets">CSS</acronym> Design</span></h2></div><pre>
+ White space is important here!
+ </pre><div
+id="quickSummary"><p
+class="p1"><span>A demonstration of what can be accomplished visually through <acronym
+title="Cascading Style Sheets">CSS</acronym>-based design. Select any style sheet from the list to load it into this page.</span></p><p
+class="p2"><span>Download the sample <a
+href="/zengarden-sample.html" title="This page's source HTML code, not to be modified.">html file</a> and <a
+href="/zengarden-sample.css" title="This page's sample CSS, the file you may modify.">css file</a></span></p></div><textarea name="comment" id="comment" rows="6" class="maxwidth" cols="80">66666
+
+1234567890</textarea></div></body></html>
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+ <!-- comments get removed -->
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
+ <meta name="author" content="Dave Shea">
+ <!-- also whitespace around block or undisplayed elements -->
+ <meta name="keywords" content="design, css, cascading, style, sheets, xhtml, graphic design, w3c, web standards, visual, display">
+ <meta name="description" content="A demonstration of what can be accomplished visually through CSS-based design.">
+ <meta name="robots" content="all">
+ <title>css Zen Garden: The Beauty in CSS Design</title>
+
+ <!-- to correct the unsightly Flash of Unstyled Content. http://www.bluerobot.com/web/css/fouc.asp -->
+ <script type="text/javascript"><!--
+// js comment inside SCRIPT element
+var is = {
+ ie: navigator.appName == 'Microsoft Internet Explorer',
+ java: navigator.javaEnabled(),
+ ns: navigator.appName == 'Netscape',
+ ua: navigator.userAgent.toLowerCase(),
+ version: parseFloat(navigator.appVersion.substr(21)) ||
+ parseFloat(navigator.appVersion),
+ win: navigator.platform == 'Win32'
+}
+is.mac = is.ua.indexOf('mac') >= 0;
+if (is.ua.indexOf('opera') >= 0) {
+ is.ie = is.ns = false;
+ is.opera = true;
+}
+if (is.ua.indexOf('gecko') >= 0) {
+ is.ie = is.ns = false;
+ is.gecko = true;
+}
+// --></script>
+<script type="text/javascript">
+ var i = 0;
+ while (++i < 10)
+ {
+ // ...
+ }
+</script>
+<script type="text/javascript">
+i = 1;
+</script>
+<script type="text/javascript">
+ (i < 1);
+</script>
+ <!--[if IE 6]>
+ <style type="text/css">
+/*! copyright: you'll need CDATA for this < & */
+body {background:white;}
+ </style>
+ <![endif]-->
+ <style type="text/css" title="currentStyle" media="screen">
+ @import "/001/001.css";
+/*\*/ css hack {} /* */
+/* normal CSS comment */
+/*/*/ css hack {} /* */
+css hack {
+ display/**/:/**/none;
+ display:none;
+}
+ </style>
+ <link
+ rel="Shortcut Icon"
+ type="image/x-icon"
+ href="http://www.csszengarden.com/favicon.ico">
+ <link
+ rel="alternate"
+ type="application/rss+xml"
+ title="RSS"
+ href="http://www.csszengarden.com/zengarden.xml">
+</head>
+<body id="css-zen-garden">
+<!--[if !IE]>--><p>Browser != IE</p><!--<![endif]-->
+<div id="container">
+ <div id="pageHeader">
+ <h1><span>css Zen Garden</span></h1>
+ <h2><span>The Beauty of <acronym title="Cascading Style Sheets">CSS</acronym> \r
+Design</span></h2>
+ </div>
+ <pre>
+ White space is important here!
+ </pre>
+ <div id="quickSummary">
+ <p class="p1"><span>A demonstration of what can be accomplished visually through <acronym title="Cascading Style Sheets">CSS</acronym>-based design. Select any style sheet from the list to load it into this page.</span></p>
+ <p class="p2"><span>Download the sample <a href="/zengarden-sample.html" title="This page's source HTML code, not to be modified.">html file</a> and <a href="/zengarden-sample.css" title="This page's sample CSS, the file you may modify.">css file</a></span></p>
+ </div>
+ <textarea name="comment" id="comment" rows="6" class="maxwidth" cols="80">66666
+
+1234567890</textarea>
+Preserve at least 1 char of whitespace near <script type="text/javascript"></script>scripts in case of document.write().
+</div>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html
+lang="en"><head><meta
+http-equiv="content-type" content="text/html; charset=iso-8859-1"><meta
+name="author" content="Dave Shea"><meta
+name="keywords" content="design, css, cascading, style, sheets, xhtml, graphic design, w3c, web standards, visual, display"><meta
+name="description" content="A demonstration of what can be accomplished visually through CSS-based design."><meta
+name="robots" content="all"><title>css Zen Garden: The Beauty in CSS Design</title> <script type="text/javascript">var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
+is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
+if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}</script> <script type="text/javascript">var i=0;while(++i<10)
+{}</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">(i<1);</script> <!--[if IE 6]><style type="text/css">
+/* copyright: you'll need CDATA for this < & */
+body{background:white}</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*/css
+hack{}/**/ /*/*/css
+hack{}/**/css
+hack{display/**/:/**/none;display:none}</style><link
+rel="Shortcut Icon"
+type="image/x-icon"
+href="http://www.csszengarden.com/favicon.ico"><link
+rel="alternate"
+type="application/rss+xml"
+title="RSS"
+href="http://www.csszengarden.com/zengarden.xml"></head><body
+id="css-zen-garden"> <!--[if !IE]>--><p>Browser != IE</p><!--<![endif]--><div
+id="container"><div
+id="pageHeader"><h1><span>css Zen Garden</span></h1><h2><span>The Beauty of <acronym
+title="Cascading Style Sheets">CSS</acronym> Design</span></h2></div><pre>
+ White space is important here!
+ </pre><div
+id="quickSummary"><p
+class="p1"><span>A demonstration of what can be accomplished visually through <acronym
+title="Cascading Style Sheets">CSS</acronym>-based design. Select any style sheet from the list to load it into this page.</span></p><p
+class="p2"><span>Download the sample <a
+href="/zengarden-sample.html" title="This page's source HTML code, not to be modified.">html file</a> and <a
+href="/zengarden-sample.css" title="This page's sample CSS, the file you may modify.">css file</a></span></p></div><textarea name="comment" id="comment" rows="6" class="maxwidth" cols="80">66666
+
+1234567890</textarea>Preserve at least 1 char of whitespace near <script type="text/javascript"></script>scripts in case of document.write().</div></body></html>
\ No newline at end of file
--- /dev/null
+/* @import url('bad.css' ) bad; */
+adjacent2 foo { background: red url(/red.gif); }
+adjacent2 bar { background: url('../green.gif') }
\ No newline at end of file
--- /dev/null
+@import url( adjacent.css ) all;
+@import '../input.css';
+tv foo { background: red url(/red.gif); }
+tv bar { background: url('../green.gif') }
\ No newline at end of file
--- /dev/null
+@import url(../css/styles.css);
+@import url(http://example.com/hello.css);
+adjacent foo { background: red url(/red.gif); }
+adjacent bar { background: url('../green.gif') }
\ No newline at end of file
--- /dev/null
+@import url( adjacent.css ) screen;
+@import "1/tv.css" tv, projection;
+input foo { background: red url(/red.gif); }
+input bar { background: url('../green.gif') }
\ No newline at end of file
--- /dev/null
+@media screen {
+/* some CSS to try to exercise things in general */
+
+@import url(/more.css);
+
+ body, td, th {
+ font-family: Verdana , "Bitstream Vera Sans" , sans-serif ;
+
+ font-size : 12px;
+}
+
+.nav {
+ margin-left: 20%;
+}
+#main-nav {
+ background-color: red;
+ border: 1px solid #00ff77;
+}
+
+div#content
+h1 + p {
+ padding-top: 0;
+ margin-top: 0;
+}
+
+@media all and (min-width: 640px) {
+ #media-queries-1 { background-color: #0f0; }
+}
+
+@media screen and (max-width: 2000px) {
+ #media-queries-2 { background-color: #0f0; }
+}
+@import url(http://example.com/hello.css);
+adjacent foo { background: red url(/red.gif); }
+adjacent bar { background: url('%TEST_FILES_URI%/green.gif') }
+}
+
+@media tv,projection {
+/* @import url('%TEST_FILES_URI%/importProcessor/1/bad.css') bad; */
+adjacent2 foo { background: red url(/red.gif); }
+adjacent2 bar { background: url('%TEST_FILES_URI%/importProcessor/green.gif') }
+@import '../input.css';
+tv foo { background: red url(/red.gif); }
+tv bar { background: url('%TEST_FILES_URI%/importProcessor/green.gif') }
+}
+
+input foo { background: red url(/red.gif); }
+input bar { background: url('%TEST_FILES_URI%/green.gif') }
\ No newline at end of file
--- /dev/null
+/*! is.js
+
+ (c) 2001 Douglas Crockford
+ 2001 June 3
+*/
+
+// is
+
+// The -is- object is used to identify the browser. Every browser edition
+// identifies itself, but there is no standard way of doing it, and some of
+// the identification is deceptive. This is because the authors of web
+// browsers are liars. For example, Microsoft's IE browsers claim to be
+// Mozilla 4. Netscape 6 claims to be version 5.
+
+var is = {
+ ie: navigator.appName == 'Microsoft Internet Explorer',
+ java: navigator.javaEnabled(),
+ ns: navigator.appName == 'Netscape',
+ ua: navigator.userAgent.toLowerCase(),
+ version: parseFloat(navigator.appVersion.substr(21)) ||
+ parseFloat(navigator.appVersion),
+ win: navigator.platform == 'Win32'
+}
+/*!*
+ * preserve this comment, too
+ */
+is.mac = is.ua.indexOf('mac') >= 0;
+if (is.ua.indexOf('opera') >= 0) {
+ is.ie = is.ns = false;
+ is.opera = true;
+}
+if (is.ua.indexOf('gecko') >= 0) {
+ is.ie = is.ns = false;
+ is.gecko = true;
+}
+
+/*@cc_on
+ /*@if (@_win32)
+ if (is.ie && is.win)
+ document.write("PASS: IE/win honored conditional comment.<br>");
+ @else @*/
+ if (is.ie && is.win)
+ document.write("FAIL: IE/win did not honor multi-line conditional comment.<br>");
+ else
+ document.write("PASS: Non-IE/win browser ignores multi-line conditional comment.<br>");
+ /*@end
+@*/
+
+var recognizesCondComm = true;
+//@cc_on/*
+recognizesCondComm = false;
+//@cc_on*/
+
+if ((is.ie && is.win) == recognizesCondComm)
+ document.write("PASS: IE/win honored single-line conditional comment.<br>");
+else
+ document.write("FAIL: Non-IE/win browser did not ignore single-line conditional comment.<br>");
--- /dev/null
+/* is.js
+
+ (c) 2001 Douglas Crockford
+ 2001 June 3
+*/
+var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
+/**
+ * preserve this comment, too
+ */
+is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
+if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}/*@cc_on
+ /*@if (@_win32)
+ if (is.ie && is.win)
+ document.write("PASS: IE/win honored conditional comment.<br>");
+ @else @*/if(is.ie&&is.win)
+document.write("FAIL: IE/win did not honor multi-line conditional comment.<br>");else
+document.write("PASS: Non-IE/win browser ignores multi-line conditional comment.<br>");/*@end
+@*/var recognizesCondComm=true;//@cc_on/*
+recognizesCondComm=false;//@cc_on*/
+if((is.ie&&is.win)==recognizesCondComm)
+document.write("PASS: IE/win honored single-line conditional comment.<br>");else
+document.write("FAIL: Non-IE/win browser did not ignore single-line conditional comment.<br>");
\ No newline at end of file
--- /dev/null
+/* is.js
+
+ (c) 2001 Douglas Crockford
+ 2001 June 3
+*/
+var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
+/**
+ * preserve this comment, too
+ */
+is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
+if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}/*@cc_on
+ /*@if (@_win32)
+ if (is.ie && is.win)
+ document.write("PASS: IE/win honored conditional comment.<br>");
+ @else @*/if(is.ie&&is.win)
+document.write("FAIL: IE/win did not honor multi-line conditional comment.<br>");else
+document.write("PASS: Non-IE/win browser ignores multi-line conditional comment.<br>");/*@end
+@*/var recognizesCondComm=true;//@cc_on/*
+recognizesCondComm=false;//@cc_on*/
+if((is.ie&&is.win)==recognizesCondComm)
+document.write("PASS: IE/win honored single-line conditional comment.<br>");else
+document.write("FAIL: Non-IE/win browser did not ignore single-line conditional comment.<br>");
\ No newline at end of file
--- /dev/null
+var isWin;
+/*@cc_on
+ @if (@_win32)
+ isWin = true;
+ @else @*/ isWin = false;
+ /*@end
+@*/
+
+isWin = /*@cc_on!*/!1;
+
+var recognizesCondComm = true;
+//@cc_on/*
+recognizesCondComm = false;
+//@cc_on*/
--- /dev/null
+var isWin;
+/*@cc_on
+ @if (@_win32)
+ isWin = true;
+ @else @*/
+ isWin = false;
+ /*@end
+@*/
+
+var recognizesCondComm = true;
+//@cc_on/*
+recognizesCondComm = false;
+//@cc_on*/
\ No newline at end of file
--- /dev/null
+
+function testIssue74() {
+ return /'/;
+}
--- /dev/null
+function testIssue74(){return /'/;}
\ No newline at end of file
--- /dev/null
+function testIssue74(){return /'/}
\ No newline at end of file
--- /dev/null
+(function(){
+/*!
+ * jQuery 1.2.3 - New Wave Javascript
+ *
+ * Copyright (c) 2008 John Resig (jquery.com)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * $Date: 2008-02-06 00:21:25 -0500 (Wed, 06 Feb 2008) $
+ * $Rev: 4663 $
+ */
+
+// Map over jQuery in case of overwrite
+if ( window.jQuery )
+ var _jQuery = window.jQuery;
+
+var jQuery = window.jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.prototype.init( selector, context );
+};
+
+// Map over the $ in case of overwrite
+if ( window.$ )
+ var _$ = window.$;
+
+// Map the jQuery namespace to the '$' one
+window.$ = jQuery;
+
+// A simple way to check for HTML strings or ID strings
+// (both of which we optimize for)
+var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;
+
+// Is it a simple selector
+var isSimple = /^.[^:#\[\.]*$/;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ // Make sure that a selection was provided
+ selector = selector || document;
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this[0] = selector;
+ this.length = 1;
+ return this;
+
+ // Handle HTML strings
+ } else if ( typeof selector == "string" ) {
+ // Are we dealing with HTML string or an ID?
+ var match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] )
+ selector = jQuery.clean( [ match[1] ], context );
+
+ // HANDLE: $("#id")
+ else {
+ var elem = document.getElementById( match[3] );
+
+ // Make sure an element was located
+ if ( elem )
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id != match[3] )
+ return jQuery().find( selector );
+
+ // Otherwise, we inject the element directly into the jQuery object
+ else {
+ this[0] = elem;
+ this.length = 1;
+ return this;
+ }
+
+ else
+ selector = [];
+ }
+
+ // HANDLE: $(expr, [context])
+ // (which is just equivalent to: $(content).find(expr)
+ } else
+ return new jQuery( context ).find( selector );
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) )
+ return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
+
+ return this.setArray(
+ // HANDLE: $(array)
+ selector.constructor == Array && selector ||
+
+ // HANDLE: $(arraylike)
+ // Watch for when an array-like object, contains DOM nodes, is passed in as the selector
+ (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) ||
+
+ // HANDLE: $(*)
+ [ selector ] );
+ },
+
+ // The current version of jQuery being used
+ jquery: "1.2.3",
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ // The number of elements contained in the matched element set
+ length: 0,
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == undefined ?
+
+ // Return a 'clean' array
+ jQuery.makeArray( this ) :
+
+ // Return just the object
+ this[ num ];
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ Array.prototype.push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ var ret = -1;
+
+ // Locate the position of the desired element
+ this.each(function(i){
+ if ( this == elem )
+ ret = i;
+ });
+
+ return ret;
+ },
+
+ attr: function( name, value, type ) {
+ var options = name;
+
+ // Look for the case where we're accessing a style value
+ if ( name.constructor == String )
+ if ( value == undefined )
+ return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined;
+
+ else {
+ options = {};
+ options[ name ] = value;
+ }
+
+ // Check to see if we're setting style values
+ return this.each(function(i){
+ // Set all the styles
+ for ( name in options )
+ jQuery.attr(
+ type ?
+ this.style :
+ this,
+ name, jQuery.prop( this, options[ name ], type, i, name )
+ );
+ });
+ },
+
+ css: function( key, value ) {
+ // ignore negative width and height values
+ if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
+ value = undefined;
+ return this.attr( key, value, "curCSS" );
+ },
+
+ text: function( text ) {
+ if ( typeof text != "object" && text != null )
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+
+ var ret = "";
+
+ jQuery.each( text || this, function(){
+ jQuery.each( this.childNodes, function(){
+ if ( this.nodeType != 8 )
+ ret += this.nodeType != 1 ?
+ this.nodeValue :
+ jQuery.fn.text( [ this ] );
+ });
+ });
+
+ return ret;
+ },
+
+ wrapAll: function( html ) {
+ if ( this[0] )
+ // The elements to wrap the target around
+ jQuery( html, this[0].ownerDocument )
+ .clone()
+ .insertBefore( this[0] )
+ .map(function(){
+ var elem = this;
+
+ while ( elem.firstChild )
+ elem = elem.firstChild;
+
+ return elem;
+ })
+ .append(this);
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function(){
+ jQuery( this ).contents().wrapAll( html );
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function(){
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, false, function(elem){
+ if (this.nodeType == 1)
+ this.appendChild( elem );
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, true, function(elem){
+ if (this.nodeType == 1)
+ this.insertBefore( elem, this.firstChild );
+ });
+ },
+
+ before: function() {
+ return this.domManip(arguments, false, false, function(elem){
+ this.parentNode.insertBefore( elem, this );
+ });
+ },
+
+ after: function() {
+ return this.domManip(arguments, false, true, function(elem){
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ },
+
+ end: function() {
+ return this.prevObject || jQuery( [] );
+ },
+
+ find: function( selector ) {
+ var elems = jQuery.map(this, function(elem){
+ return jQuery.find( selector, elem );
+ });
+
+ return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
+ jQuery.unique( elems ) :
+ elems );
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function(){
+ if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var clone = this.cloneNode(true),
+ container = document.createElement("div");
+ container.appendChild(clone);
+ return jQuery.clean([container.innerHTML])[0];
+ } else
+ return this.cloneNode(true);
+ });
+
+ // Need to set the expando to null on the cloned set if it exists
+ // removeData doesn't work here, IE removes it from the original as well
+ // this is primarily for IE but the data expando shouldn't be copied over in any browser
+ var clone = ret.find("*").andSelf().each(function(){
+ if ( this[ expando ] != undefined )
+ this[ expando ] = null;
+ });
+
+ // Copy the events from the original to the clone
+ if ( events === true )
+ this.find("*").andSelf().each(function(i){
+ if (this.nodeType == 3)
+ return;
+ var events = jQuery.data( this, "events" );
+
+ for ( var type in events )
+ for ( var handler in events[ type ] )
+ jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
+ });
+
+ // Return the cloned set
+ return ret;
+ },
+
+ filter: function( selector ) {
+ return this.pushStack(
+ jQuery.isFunction( selector ) &&
+ jQuery.grep(this, function(elem, i){
+ return selector.call( elem, i );
+ }) ||
+
+ jQuery.multiFilter( selector, this ) );
+ },
+
+ not: function( selector ) {
+ if ( selector.constructor == String )
+ // test special case where just one selector is passed in
+ if ( isSimple.test( selector ) )
+ return this.pushStack( jQuery.multiFilter( selector, this, true ) );
+ else
+ selector = jQuery.multiFilter( selector, this );
+
+ var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
+ return this.filter(function() {
+ return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
+ });
+ },
+
+ add: function( selector ) {
+ return !selector ? this : this.pushStack( jQuery.merge(
+ this.get(),
+ selector.constructor == String ?
+ jQuery( selector ).get() :
+ selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ?
+ selector : [selector] ) );
+ },
+
+ is: function( selector ) {
+ return selector ?
+ jQuery.multiFilter( selector, this ).length > 0 :
+ false;
+ },
+
+ hasClass: function( selector ) {
+ return this.is( "." + selector );
+ },
+
+ val: function( value ) {
+ if ( value == undefined ) {
+
+ if ( this.length ) {
+ var elem = this[0];
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type == "select-one";
+
+ // Nothing was selected
+ if ( index < 0 )
+ return null;
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ if ( option.selected ) {
+ // Get the specifc value for the option
+ value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
+
+ // We don't need an array for one selects
+ if ( one )
+ return value;
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+
+ // Everything else, we just grab the value
+ } else
+ return (this[0].value || "").replace(/\r/g, "");
+
+ }
+
+ return undefined;
+ }
+
+ return this.each(function(){
+ if ( this.nodeType != 1 )
+ return;
+
+ if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
+ this.checked = (jQuery.inArray(this.value, value) >= 0 ||
+ jQuery.inArray(this.name, value) >= 0);
+
+ else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = value.constructor == Array ?
+ value :
+ [ value ];
+
+ jQuery( "option", this ).each(function(){
+ this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
+ jQuery.inArray( this.text, values ) >= 0);
+ });
+
+ if ( !values.length )
+ this.selectedIndex = -1;
+
+ } else
+ this.value = value;
+ });
+ },
+
+ html: function( value ) {
+ return value == undefined ?
+ (this.length ?
+ this[0].innerHTML :
+ null) :
+ this.empty().append( value );
+ },
+
+ replaceWith: function( value ) {
+ return this.after( value ).remove();
+ },
+
+ eq: function( i ) {
+ return this.slice( i, i + 1 );
+ },
+
+ slice: function() {
+ return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function(elem, i){
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ },
+
+ data: function( key, value ){
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value == null ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data == undefined && this.length )
+ data = jQuery.data( this[0], key );
+
+ return data == null && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
+ jQuery.data( this, key, value );
+ });
+ },
+
+ removeData: function( key ){
+ return this.each(function(){
+ jQuery.removeData( this, key );
+ });
+ },
+
+ domManip: function( args, table, reverse, callback ) {
+ var clone = this.length > 1, elems;
+
+ return this.each(function(){
+ if ( !elems ) {
+ elems = jQuery.clean( args, this.ownerDocument );
+
+ if ( reverse )
+ elems.reverse();
+ }
+
+ var obj = this;
+
+ if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )
+ obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") );
+
+ var scripts = jQuery( [] );
+
+ jQuery.each(elems, function(){
+ var elem = clone ?
+ jQuery( this ).clone( true )[0] :
+ this;
+
+ // execute all scripts after the elements have been injected
+ if ( jQuery.nodeName( elem, "script" ) ) {
+ scripts = scripts.add( elem );
+ } else {
+ // Remove any inner scripts for later evaluation
+ if ( elem.nodeType == 1 )
+ scripts = scripts.add( jQuery( "script", elem ).remove() );
+
+ // Inject the elements into the document
+ callback.call( obj, elem );
+ }
+ });
+
+ scripts.each( evalScript );
+ });
+ }
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.prototype.init.prototype = jQuery.prototype;
+
+function evalScript( i, elem ) {
+ if ( elem.src )
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+
+ else
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+
+ if ( elem.parentNode )
+ elem.parentNode.removeChild( elem );
+}
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
+
+ // Handle a deep copy situation
+ if ( target.constructor == Boolean ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target != "object" && typeof target != "function" )
+ target = {};
+
+ // extend jQuery itself if only one argument is passed
+ if ( length == 1 ) {
+ target = this;
+ i = 0;
+ }
+
+ for ( ; i < length; i++ )
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null )
+ // Extend the base object
+ for ( var name in options ) {
+ // Prevent never-ending loop
+ if ( target === options[ name ] )
+ continue;
+
+ // Recurse if we're merging object values
+ if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )
+ target[ name ] = jQuery.extend( target[ name ], options[ name ] );
+
+ // Don't bring in undefined values
+ else if ( options[ name ] != undefined )
+ target[ name ] = options[ name ];
+
+ }
+
+ // Return the modified object
+ return target;
+};
+
+var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};
+
+// exclude the following css properties to add px
+var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep )
+ window.jQuery = _jQuery;
+
+ return jQuery;
+ },
+
+ // See test/unit/core.js for details concerning this function.
+ isFunction: function( fn ) {
+ return !!fn && typeof fn != "string" && !fn.nodeName &&
+ fn.constructor != Array && /function/i.test( fn + "" );
+ },
+
+ // check if an element is in a (or is an) XML document
+ isXMLDoc: function( elem ) {
+ return elem.documentElement && !elem.body ||
+ elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
+ },
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ data = jQuery.trim( data );
+
+ if ( data ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+ if ( jQuery.browser.msie )
+ script.text = data;
+ else
+ script.appendChild( document.createTextNode( data ) );
+
+ head.appendChild( script );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
+ },
+
+ cache: {},
+
+ data: function( elem, name, data ) {
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ];
+
+ // Compute a unique ID for the element
+ if ( !id )
+ id = elem[ expando ] = ++uuid;
+
+ // Only generate the data cache if we're
+ // trying to access or manipulate it
+ if ( name && !jQuery.cache[ id ] )
+ jQuery.cache[ id ] = {};
+
+ // Prevent overriding the named cache with undefined values
+ if ( data != undefined )
+ jQuery.cache[ id ][ name ] = data;
+
+ // Return the named cache data, or the ID for the element
+ return name ?
+ jQuery.cache[ id ][ name ] :
+ id;
+ },
+
+ removeData: function( elem, name ) {
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ];
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( jQuery.cache[ id ] ) {
+ // Remove the section of cache data
+ delete jQuery.cache[ id ][ name ];
+
+ // If we've removed all the data, remove the element's cache
+ name = "";
+
+ for ( name in jQuery.cache[ id ] )
+ break;
+
+ if ( !name )
+ jQuery.removeData( elem );
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ // Clean up the element expando
+ try {
+ delete elem[ expando ];
+ } catch(e){
+ // IE has trouble directly removing the expando
+ // but it's ok with using removeAttribute
+ if ( elem.removeAttribute )
+ elem.removeAttribute( expando );
+ }
+
+ // Completely remove the data cache
+ delete jQuery.cache[ id ];
+ }
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ if ( args ) {
+ if ( object.length == undefined ) {
+ for ( var name in object )
+ if ( callback.apply( object[ name ], args ) === false )
+ break;
+ } else
+ for ( var i = 0, length = object.length; i < length; i++ )
+ if ( callback.apply( object[ i ], args ) === false )
+ break;
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( object.length == undefined ) {
+ for ( var name in object )
+ if ( callback.call( object[ name ], name, object[ name ] ) === false )
+ break;
+ } else
+ for ( var i = 0, length = object.length, value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
+ }
+
+ return object;
+ },
+
+ prop: function( elem, value, type, i, name ) {
+ // Handle executable functions
+ if ( jQuery.isFunction( value ) )
+ value = value.call( elem, i );
+
+ // Handle passing in a number to a CSS property
+ return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
+ value + "px" :
+ value;
+ },
+
+ className: {
+ // internal only, use addClass("class")
+ add: function( elem, classNames ) {
+ jQuery.each((classNames || "").split(/\s+/), function(i, className){
+ if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )
+ elem.className += (elem.className ? " " : "") + className;
+ });
+ },
+
+ // internal only, use removeClass("class")
+ remove: function( elem, classNames ) {
+ if (elem.nodeType == 1)
+ elem.className = classNames != undefined ?
+ jQuery.grep(elem.className.split(/\s+/), function(className){
+ return !jQuery.className.has( classNames, className );
+ }).join(" ") :
+ "";
+ },
+
+ // internal only, use is(".class")
+ has: function( elem, className ) {
+ return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
+ }
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options )
+ elem.style[ name ] = old[ name ];
+ },
+
+ css: function( elem, name, force ) {
+ if ( name == "width" || name == "height" ) {
+ var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
+
+ function getWH() {
+ val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
+ var padding = 0, border = 0;
+ jQuery.each( which, function() {
+ padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ });
+ val -= Math.round(padding + border);
+ }
+
+ if ( jQuery(elem).is(":visible") )
+ getWH();
+ else
+ jQuery.swap( elem, props, getWH );
+
+ return Math.max(0, val);
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret;
+
+ // A helper method for determining if an element's values are broken
+ function color( elem ) {
+ if ( !jQuery.browser.safari )
+ return false;
+
+ var ret = document.defaultView.getComputedStyle( elem, null );
+ return !ret || ret.getPropertyValue("color") == "";
+ }
+
+ // We need to handle opacity special in IE
+ if ( name == "opacity" && jQuery.browser.msie ) {
+ ret = jQuery.attr( elem.style, "opacity" );
+
+ return ret == "" ?
+ "1" :
+ ret;
+ }
+ // Opera sometimes will give the wrong display answer, this fixes it, see #2037
+ if ( jQuery.browser.opera && name == "display" ) {
+ var save = elem.style.outline;
+ elem.style.outline = "0 solid black";
+ elem.style.outline = save;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( name.match( /float/i ) )
+ name = styleFloat;
+
+ if ( !force && elem.style && elem.style[ name ] )
+ ret = elem.style[ name ];
+
+ else if ( document.defaultView && document.defaultView.getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( name.match( /float/i ) )
+ name = "float";
+
+ name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
+
+ var getComputedStyle = document.defaultView.getComputedStyle( elem, null );
+
+ if ( getComputedStyle && !color( elem ) )
+ ret = getComputedStyle.getPropertyValue( name );
+
+ // If the element isn't reporting its values properly in Safari
+ // then some display: none elements are involved
+ else {
+ var swap = [], stack = [];
+
+ // Locate all of the parent display: none elements
+ for ( var a = elem; a && color(a); a = a.parentNode )
+ stack.unshift(a);
+
+ // Go through and make them visible, but in reverse
+ // (It would be better if we knew the exact display type that they had)
+ for ( var i = 0; i < stack.length; i++ )
+ if ( color( stack[ i ] ) ) {
+ swap[ i ] = stack[ i ].style.display;
+ stack[ i ].style.display = "block";
+ }
+
+ // Since we flip the display style, we have to handle that
+ // one special, otherwise get the value
+ ret = name == "display" && swap[ stack.length - 1 ] != null ?
+ "none" :
+ ( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || "";
+
+ // Finally, revert the display styles back
+ for ( var i = 0; i < swap.length; i++ )
+ if ( swap[ i ] != null )
+ stack[ i ].style.display = swap[ i ];
+ }
+
+ // We should always get a number back from opacity
+ if ( name == "opacity" && ret == "" )
+ ret = "1";
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(/\-(\w)/g, function(all, letter){
+ return letter.toUpperCase();
+ });
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
+ // Remember the original values
+ var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ elem.style.left = ret || 0;
+ ret = elem.style.pixelLeft + "px";
+
+ // Revert the changed values
+ elem.style.left = style;
+ elem.runtimeStyle.left = runtimeStyle;
+ }
+ }
+
+ return ret;
+ },
+
+ clean: function( elems, context ) {
+ var ret = [];
+ context = context || document;
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if (typeof context.createElement == 'undefined')
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+
+ jQuery.each(elems, function(i, elem){
+ if ( !elem )
+ return;
+
+ if ( elem.constructor == Number )
+ elem = elem.toString();
+
+ // Convert html string into DOM nodes
+ if ( typeof elem == "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
+ return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
+ all :
+ front + "></" + tag + ">";
+ });
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
+
+ var wrap =
+ // option or optgroup
+ !tags.indexOf("<opt") &&
+ [ 1, "<select multiple='multiple'>", "</select>" ] ||
+
+ !tags.indexOf("<leg") &&
+ [ 1, "<fieldset>", "</fieldset>" ] ||
+
+ tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
+ [ 1, "<table>", "</table>" ] ||
+
+ !tags.indexOf("<tr") &&
+ [ 2, "<table><tbody>", "</tbody></table>" ] ||
+
+ // <thead> matched above
+ (!tags.indexOf("<td") || !tags.indexOf("<th")) &&
+ [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
+
+ !tags.indexOf("<col") &&
+ [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
+
+ // IE can't serialize <link> and <script> tags normally
+ jQuery.browser.msie &&
+ [ 1, "div<div>", "</div>" ] ||
+
+ [ 0, "", "" ];
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( wrap[0]-- )
+ div = div.lastChild;
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( jQuery.browser.msie ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j )
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( /^\s/.test( elem ) )
+ div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
+
+ }
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
+ return;
+
+ if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
+ ret.push( elem );
+
+ else
+ ret = jQuery.merge( ret, elem );
+
+ });
+
+ return ret;
+ },
+
+ attr: function( elem, name, value ) {
+ // don't set attributes on text and comment nodes
+ if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
+ return undefined;
+
+ var fix = jQuery.isXMLDoc( elem ) ?
+ {} :
+ jQuery.props;
+
+ // Safari mis-reports the default selected property of a hidden option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name == "selected" && jQuery.browser.safari )
+ elem.parentNode.selectedIndex;
+
+ // Certain attributes only work when accessed via the old DOM 0 way
+ if ( fix[ name ] ) {
+ if ( value != undefined )
+ elem[ fix[ name ] ] = value;
+
+ return elem[ fix[ name ] ];
+
+ } else if ( jQuery.browser.msie && name == "style" )
+ return jQuery.attr( elem.style, "cssText", value );
+
+ else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method") )
+ return elem.getAttributeNode( name ).nodeValue;
+
+ // IE elem.getAttribute passes even for style
+ else if ( elem.tagName ) {
+
+ if ( value != undefined ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
+ throw "type property can't be changed";
+
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) )
+ return elem.getAttribute( name, 2 );
+
+ return elem.getAttribute( name );
+
+ // elem is actually elem.style ... set the style
+ } else {
+ // IE actually uses filters for opacity
+ if ( name == "opacity" && jQuery.browser.msie ) {
+ if ( value != undefined ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ elem.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
+ (parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
+ }
+
+ return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() :
+ "";
+ }
+
+ name = name.replace(/-([a-z])/ig, function(all, letter){
+ return letter.toUpperCase();
+ });
+
+ if ( value != undefined )
+ elem[ name ] = value;
+
+ return elem[ name ];
+ }
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( /^\s+|\s+$/g, "" );
+ },
+
+ makeArray: function( array ) {
+ var ret = [];
+
+ // Need to use typeof to fight Safari childNodes crashes
+ if ( typeof array != "array" )
+ for ( var i = 0, length = array.length; i < length; i++ )
+ ret.push( array[ i ] );
+ else
+ ret = array.slice( 0 );
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ for ( var i = 0, length = array.length; i < length; i++ )
+ if ( array[ i ] == elem )
+ return i;
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ // We have to loop this way because IE & Opera overwrite the length
+ // expando of getElementsByTagName
+
+ // Also, we need to make sure that the correct elements are being returned
+ // (IE returns comment nodes in a '*' query)
+ if ( jQuery.browser.msie ) {
+ for ( var i = 0; second[ i ]; i++ )
+ if ( second[ i ].nodeType != 8 )
+ first.push( second[ i ] );
+
+ } else
+ for ( var i = 0; second[ i ]; i++ )
+ first.push( second[ i ] );
+
+ return first;
+ },
+
+ unique: function( array ) {
+ var ret = [], done = {};
+
+ try {
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ var id = jQuery.data( array[ i ] );
+
+ if ( !done[ id ] ) {
+ done[ id ] = true;
+ ret.push( array[ i ] );
+ }
+ }
+
+ } catch( e ) {
+ ret = array;
+ }
+
+ return ret;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ )
+ if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) )
+ ret.push( elems[ i ] );
+
+ return ret;
+ },
+
+ map: function( elems, callback ) {
+ var ret = [];
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ var value = callback( elems[ i ], i );
+
+ if ( value !== null && value != undefined ) {
+ if ( value.constructor != Array )
+ value = [ value ];
+
+ ret = ret.concat( value );
+ }
+ }
+
+ return ret;
+ }
+});
+
+var userAgent = navigator.userAgent.toLowerCase();
+
+// Figure out what browser is being used
+jQuery.browser = {
+ version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
+ safari: /webkit/.test( userAgent ),
+ opera: /opera/.test( userAgent ),
+ msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
+ mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
+};
+
+var styleFloat = jQuery.browser.msie ?
+ "styleFloat" :
+ "cssFloat";
+
+jQuery.extend({
+ // Check to see if the W3C box model is being used
+ boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
+
+ props: {
+ "for": "htmlFor",
+ "class": "className",
+ "float": styleFloat,
+ cssFloat: styleFloat,
+ styleFloat: styleFloat,
+ innerHTML: "innerHTML",
+ className: "className",
+ value: "value",
+ disabled: "disabled",
+ checked: "checked",
+ readonly: "readOnly",
+ selected: "selected",
+ maxlength: "maxLength",
+ selectedIndex: "selectedIndex",
+ defaultValue: "defaultValue",
+ tagName: "tagName",
+ nodeName: "nodeName"
+ }
+});
+
+jQuery.each({
+ parent: function(elem){return elem.parentNode;},
+ parents: function(elem){return jQuery.dir(elem,"parentNode");},
+ next: function(elem){return jQuery.nth(elem,2,"nextSibling");},
+ prev: function(elem){return jQuery.nth(elem,2,"previousSibling");},
+ nextAll: function(elem){return jQuery.dir(elem,"nextSibling");},
+ prevAll: function(elem){return jQuery.dir(elem,"previousSibling");},
+ siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},
+ children: function(elem){return jQuery.sibling(elem.firstChild);},
+ contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}
+}, function(name, fn){
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = jQuery.map( this, fn );
+
+ if ( selector && typeof selector == "string" )
+ ret = jQuery.multiFilter( selector, ret );
+
+ return this.pushStack( jQuery.unique( ret ) );
+ };
+});
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function(name, original){
+ jQuery.fn[ name ] = function() {
+ var args = arguments;
+
+ return this.each(function(){
+ for ( var i = 0, length = args.length; i < length; i++ )
+ jQuery( args[ i ] )[ original ]( this );
+ });
+ };
+});
+
+jQuery.each({
+ removeAttr: function( name ) {
+ jQuery.attr( this, name, "" );
+ if (this.nodeType == 1)
+ this.removeAttribute( name );
+ },
+
+ addClass: function( classNames ) {
+ jQuery.className.add( this, classNames );
+ },
+
+ removeClass: function( classNames ) {
+ jQuery.className.remove( this, classNames );
+ },
+
+ toggleClass: function( classNames ) {
+ jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );
+ },
+
+ remove: function( selector ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
+ // Prevent memory leaks
+ jQuery( "*", this ).add(this).each(function(){
+ jQuery.event.remove(this);
+ jQuery.removeData(this);
+ });
+ if (this.parentNode)
+ this.parentNode.removeChild( this );
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ jQuery( ">*", this ).remove();
+
+ // Remove any remaining nodes
+ while ( this.firstChild )
+ this.removeChild( this.firstChild );
+ }
+}, function(name, fn){
+ jQuery.fn[ name ] = function(){
+ return this.each( fn, arguments );
+ };
+});
+
+jQuery.each([ "Height", "Width" ], function(i, name){
+ var type = name.toLowerCase();
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ return this[0] == window ?
+ // Opera reports document.body.client[Width/Height] properly in both quirks and standards
+ jQuery.browser.opera && document.body[ "client" + name ] ||
+
+ // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
+ jQuery.browser.safari && window[ "inner" + name ] ||
+
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :
+
+ // Get document width or height
+ this[0] == document ?
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]),
+ Math.max(document.body["offset" + name], document.documentElement["offset" + name])
+ ) :
+
+ // Get or set width or height on the element
+ size == undefined ?
+ // Get width or height on the element
+ (this.length ? jQuery.css( this[0], type ) : null) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, size.constructor == String ? size : size + "px" );
+ };
+});
+
+var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
+ "(?:[\\w*_-]|\\\\.)" :
+ "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
+ quickChild = new RegExp("^>\\s*(" + chars + "+)"),
+ quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
+ quickClass = new RegExp("^([#.]?)(" + chars + "*)");
+
+jQuery.extend({
+ expr: {
+ "": function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},
+ "#": function(a,i,m){return a.getAttribute("id")==m[2];},
+ ":": {
+ // Position Checks
+ lt: function(a,i,m){return i<m[3]-0;},
+ gt: function(a,i,m){return i>m[3]-0;},
+ nth: function(a,i,m){return m[3]-0==i;},
+ eq: function(a,i,m){return m[3]-0==i;},
+ first: function(a,i){return i==0;},
+ last: function(a,i,m,r){return i==r.length-1;},
+ even: function(a,i){return i%2==0;},
+ odd: function(a,i){return i%2;},
+
+ // Child Checks
+ "first-child": function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},
+ "last-child": function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},
+ "only-child": function(a){return !jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},
+
+ // Parent Checks
+ parent: function(a){return a.firstChild;},
+ empty: function(a){return !a.firstChild;},
+
+ // Text Check
+ contains: function(a,i,m){return (a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},
+
+ // Visibility
+ visible: function(a){return "hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},
+ hidden: function(a){return "hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},
+
+ // Form attributes
+ enabled: function(a){return !a.disabled;},
+ disabled: function(a){return a.disabled;},
+ checked: function(a){return a.checked;},
+ selected: function(a){return a.selected||jQuery.attr(a,"selected");},
+
+ // Form elements
+ text: function(a){return "text"==a.type;},
+ radio: function(a){return "radio"==a.type;},
+ checkbox: function(a){return "checkbox"==a.type;},
+ file: function(a){return "file"==a.type;},
+ password: function(a){return "password"==a.type;},
+ submit: function(a){return "submit"==a.type;},
+ image: function(a){return "image"==a.type;},
+ reset: function(a){return "reset"==a.type;},
+ button: function(a){return "button"==a.type||jQuery.nodeName(a,"button");},
+ input: function(a){return /input|select|textarea|button/i.test(a.nodeName);},
+
+ // :has()
+ has: function(a,i,m){return jQuery.find(m[3],a).length;},
+
+ // :header
+ header: function(a){return /h\d/i.test(a.nodeName);},
+
+ // :animated
+ animated: function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}
+ }
+ },
+
+ // The regular expressions that power the parsing engine
+ parse: [
+ // Match: [@value='test'], [@foo]
+ /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
+
+ // Match: :contains('foo')
+ /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
+
+ // Match: :even, :last-chlid, #id, .class
+ new RegExp("^([:.#]*)(" + chars + "+)")
+ ],
+
+ multiFilter: function( expr, elems, not ) {
+ var old, cur = [];
+
+ while ( expr && expr != old ) {
+ old = expr;
+ var f = jQuery.filter( expr, elems, not );
+ expr = f.t.replace(/^\s*,\s*/, "" );
+ cur = not ? elems = f.r : jQuery.merge( cur, f.r );
+ }
+
+ return cur;
+ },
+
+ find: function( t, context ) {
+ // Quickly handle non-string expressions
+ if ( typeof t != "string" )
+ return [ t ];
+
+ // check to make sure context is a DOM element or a document
+ if ( context && context.nodeType != 1 && context.nodeType != 9)
+ return [ ];
+
+ // Set the correct context (if none is provided)
+ context = context || document;
+
+ // Initialize the search
+ var ret = [context], done = [], last, nodeName;
+
+ // Continue while a selector expression exists, and while
+ // we're no longer looping upon ourselves
+ while ( t && last != t ) {
+ var r = [];
+ last = t;
+
+ t = jQuery.trim(t);
+
+ var foundToken = false;
+
+ // An attempt at speeding up child selectors that
+ // point to a specific element tag
+ var re = quickChild;
+ var m = re.exec(t);
+
+ if ( m ) {
+ nodeName = m[1].toUpperCase();
+
+ // Perform our own iteration and filter
+ for ( var i = 0; ret[i]; i++ )
+ for ( var c = ret[i].firstChild; c; c = c.nextSibling )
+ if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName) )
+ r.push( c );
+
+ ret = r;
+ t = t.replace( re, "" );
+ if ( t.indexOf(" ") == 0 ) continue;
+ foundToken = true;
+ } else {
+ re = /^([>+~])\s*(\w*)/i;
+
+ if ( (m = re.exec(t)) != null ) {
+ r = [];
+
+ var merge = {};
+ nodeName = m[2].toUpperCase();
+ m = m[1];
+
+ for ( var j = 0, rl = ret.length; j < rl; j++ ) {
+ var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
+ for ( ; n; n = n.nextSibling )
+ if ( n.nodeType == 1 ) {
+ var id = jQuery.data(n);
+
+ if ( m == "~" && merge[id] ) break;
+
+ if (!nodeName || n.nodeName.toUpperCase() == nodeName ) {
+ if ( m == "~" ) merge[id] = true;
+ r.push( n );
+ }
+
+ if ( m == "+" ) break;
+ }
+ }
+
+ ret = r;
+
+ // And remove the token
+ t = jQuery.trim( t.replace( re, "" ) );
+ foundToken = true;
+ }
+ }
+
+ // See if there's still an expression, and that we haven't already
+ // matched a token
+ if ( t && !foundToken ) {
+ // Handle multiple expressions
+ if ( !t.indexOf(",") ) {
+ // Clean the result set
+ if ( context == ret[0] ) ret.shift();
+
+ // Merge the result sets
+ done = jQuery.merge( done, ret );
+
+ // Reset the context
+ r = ret = [context];
+
+ // Touch up the selector string
+ t = " " + t.substr(1,t.length);
+
+ } else {
+ // Optimize for the case nodeName#idName
+ var re2 = quickID;
+ var m = re2.exec(t);
+
+ // Re-organize the results, so that they're consistent
+ if ( m ) {
+ m = [ 0, m[2], m[3], m[1] ];
+
+ } else {
+ // Otherwise, do a traditional filter check for
+ // ID, class, and element selectors
+ re2 = quickClass;
+ m = re2.exec(t);
+ }
+
+ m[2] = m[2].replace(/\\/g, "");
+
+ var elem = ret[ret.length-1];
+
+ // Try to do a global search by ID, where we can
+ if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
+ // Optimization for HTML document case
+ var oid = elem.getElementById(m[2]);
+
+ // Do a quick check for the existence of the actual ID attribute
+ // to avoid selecting by the name attribute in IE
+ // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
+ if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
+ oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
+
+ // Do a quick check for node name (where applicable) so
+ // that div#foo searches will be really fast
+ ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
+ } else {
+ // We need to find all descendant elements
+ for ( var i = 0; ret[i]; i++ ) {
+ // Grab the tag name being searched for
+ var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];
+
+ // Handle IE7 being really dumb about <object>s
+ if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
+ tag = "param";
+
+ r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
+ }
+
+ // It's faster to filter by class and be done with it
+ if ( m[1] == "." )
+ r = jQuery.classFilter( r, m[2] );
+
+ // Same with ID filtering
+ if ( m[1] == "#" ) {
+ var tmp = [];
+
+ // Try to find the element with the ID
+ for ( var i = 0; r[i]; i++ )
+ if ( r[i].getAttribute("id") == m[2] ) {
+ tmp = [ r[i] ];
+ break;
+ }
+
+ r = tmp;
+ }
+
+ ret = r;
+ }
+
+ t = t.replace( re2, "" );
+ }
+
+ }
+
+ // If a selector string still exists
+ if ( t ) {
+ // Attempt to filter it
+ var val = jQuery.filter(t,r);
+ ret = r = val.r;
+ t = jQuery.trim(val.t);
+ }
+ }
+
+ // An error occurred with the selector;
+ // just return an empty set instead
+ if ( t )
+ ret = [];
+
+ // Remove the root context
+ if ( ret && context == ret[0] )
+ ret.shift();
+
+ // And combine the results
+ done = jQuery.merge( done, ret );
+
+ return done;
+ },
+
+ classFilter: function(r,m,not){
+ m = " " + m + " ";
+ var tmp = [];
+ for ( var i = 0; r[i]; i++ ) {
+ var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
+ if ( !not && pass || not && !pass )
+ tmp.push( r[i] );
+ }
+ return tmp;
+ },
+
+ filter: function(t,r,not) {
+ var last;
+
+ // Look for common filter expressions
+ while ( t && t != last ) {
+ last = t;
+
+ var p = jQuery.parse, m;
+
+ for ( var i = 0; p[i]; i++ ) {
+ m = p[i].exec( t );
+
+ if ( m ) {
+ // Remove what we just matched
+ t = t.substring( m[0].length );
+
+ m[2] = m[2].replace(/\\/g, "");
+ break;
+ }
+ }
+
+ if ( !m )
+ break;
+
+ // :not() is a special case that can be optimized by
+ // keeping it out of the expression list
+ if ( m[1] == ":" && m[2] == "not" )
+ // optimize if only one selector found (most common case)
+ r = isSimple.test( m[3] ) ?
+ jQuery.filter(m[3], r, true).r :
+ jQuery( r ).not( m[3] );
+
+ // We can get a big speed boost by filtering by class here
+ else if ( m[1] == "." )
+ r = jQuery.classFilter(r, m[2], not);
+
+ else if ( m[1] == "[" ) {
+ var tmp = [], type = m[3];
+
+ for ( var i = 0, rl = r.length; i < rl; i++ ) {
+ var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
+
+ if ( z == null || /href|src|selected/.test(m[2]) )
+ z = jQuery.attr(a,m[2]) || '';
+
+ if ( (type == "" && !!z ||
+ type == "=" && z == m[5] ||
+ type == "!=" && z != m[5] ||
+ type == "^=" && z && !z.indexOf(m[5]) ||
+ type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
+ (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
+ tmp.push( a );
+ }
+
+ r = tmp;
+
+ // We can get a speed boost by handling nth-child here
+ } else if ( m[1] == ":" && m[2] == "nth-child" ) {
+ var merge = {}, tmp = [],
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
+ !/\D/.test(m[3]) && "0n+" + m[3] || m[3]),
+ // calculate the numbers (first)n+(last) including if they are negative
+ first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0;
+
+ // loop through all the elements left in the jQuery object
+ for ( var i = 0, rl = r.length; i < rl; i++ ) {
+ var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
+
+ if ( !merge[id] ) {
+ var c = 1;
+
+ for ( var n = parentNode.firstChild; n; n = n.nextSibling )
+ if ( n.nodeType == 1 )
+ n.nodeIndex = c++;
+
+ merge[id] = true;
+ }
+
+ var add = false;
+
+ if ( first == 0 ) {
+ if ( node.nodeIndex == last )
+ add = true;
+ } else if ( (node.nodeIndex - last) % first == 0 && (node.nodeIndex - last) / first >= 0 )
+ add = true;
+
+ if ( add ^ not )
+ tmp.push( node );
+ }
+
+ r = tmp;
+
+ // Otherwise, find the expression to execute
+ } else {
+ var fn = jQuery.expr[ m[1] ];
+ if ( typeof fn == "object" )
+ fn = fn[ m[2] ];
+
+ if ( typeof fn == "string" )
+ fn = eval("false||function(a,i){return " + fn + ";}");
+
+ // Execute it against the current filter
+ r = jQuery.grep( r, function(elem, i){
+ return fn(elem, i, m, r);
+ }, not );
+ }
+ }
+
+ // Return an array of filtered elements (r)
+ // and the modified expression string (t)
+ return { r: r, t: t };
+ },
+
+ dir: function( elem, dir ){
+ var matched = [];
+ var cur = elem[dir];
+ while ( cur && cur != document ) {
+ if ( cur.nodeType == 1 )
+ matched.push( cur );
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function(cur,result,dir,elem){
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] )
+ if ( cur.nodeType == 1 && ++num == result )
+ break;
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType == 1 && (!elem || n != elem) )
+ r.push( n );
+ }
+
+ return r;
+ }
+});
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code orignated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function(elem, types, handler, data) {
+ if ( elem.nodeType == 3 || elem.nodeType == 8 )
+ return;
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( jQuery.browser.msie && elem.setInterval != undefined )
+ elem = window;
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid )
+ handler.guid = this.guid++;
+
+ // if data is passed, bind to handler
+ if( data != undefined ) {
+ // Create temporary function pointer to original handler
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = function() {
+ // Pass arguments and context to original handler
+ return fn.apply(this, arguments);
+ };
+
+ // Store data in unique handler
+ handler.data = data;
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ handler.guid = fn.guid;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
+ handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
+ // returned undefined or false
+ var val;
+
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ if ( typeof jQuery == "undefined" || jQuery.event.triggered )
+ return val;
+
+ val = jQuery.event.handle.apply(arguments.callee.elem, arguments);
+
+ return val;
+ });
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events seperated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ jQuery.each(types.split(/\s+/), function(index, type) {
+ // Namespaced event handlers
+ var parts = type.split(".");
+ type = parts[0];
+ handler.type = parts[1];
+
+ // Get the current list of functions bound to this event
+ var handlers = events[type];
+
+ // Init the event handler queue
+ if (!handlers) {
+ handlers = events[type] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
+ // Bind the global event handler to the element
+ if (elem.addEventListener)
+ elem.addEventListener(type, handle, false);
+ else if (elem.attachEvent)
+ elem.attachEvent("on" + type, handle);
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[handler.guid] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ jQuery.event.global[type] = true;
+ });
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ guid: 1,
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function(elem, types, handler) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType == 3 || elem.nodeType == 8 )
+ return;
+
+ var events = jQuery.data(elem, "events"), ret, index;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types == undefined || (typeof types == "string" && types.charAt(0) == ".") )
+ for ( var type in events )
+ this.remove( elem, type + (types || "") );
+ else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events seperated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ jQuery.each(types.split(/\s+/), function(index, type){
+ // Namespaced event handlers
+ var parts = type.split(".");
+ type = parts[0];
+
+ if ( events[type] ) {
+ // remove the given handler for the given type
+ if ( handler )
+ delete events[type][handler.guid];
+
+ // remove all handlers for the given type
+ else
+ for ( handler in events[type] )
+ // Handle the removal of namespaced events
+ if ( !parts[1] || events[type][handler].type == parts[1] )
+ delete events[type][handler];
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[type] ) break;
+ if ( !ret ) {
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem) === false ) {
+ if (elem.removeEventListener)
+ elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
+ else if (elem.detachEvent)
+ elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
+ }
+ ret = null;
+ delete events[type];
+ }
+ }
+ });
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) break;
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) handle.elem = null;
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ trigger: function(type, data, elem, donative, extra) {
+ // Clone the incoming data, if any
+ data = jQuery.makeArray(data || []);
+
+ if ( type.indexOf("!") >= 0 ) {
+ type = type.slice(0, -1);
+ var exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[type] )
+ jQuery("*").add([window, document]).trigger(type, data);
+
+ // Handle triggering a single element
+ } else {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType == 3 || elem.nodeType == 8 )
+ return undefined;
+
+ var val, ret, fn = jQuery.isFunction( elem[ type ] || null ),
+ // Check to see if we need to provide a fake event, or not
+ event = !data[0] || !data[0].preventDefault;
+
+ // Pass along a fake event
+ if ( event )
+ data.unshift( this.fix({ type: type, target: elem }) );
+
+ // Enforce the right trigger type
+ data[0].type = type;
+ if ( exclusive )
+ data[0].exclusive = true;
+
+ // Trigger the event
+ if ( jQuery.isFunction( jQuery.data(elem, "handle") ) )
+ val = jQuery.data(elem, "handle").apply( elem, data );
+
+ // Handle triggering native .onfoo handlers
+ if ( !fn && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
+ val = false;
+
+ // Extra functions don't get the custom event object
+ if ( event )
+ data.shift();
+
+ // Handle triggering of extra function
+ if ( extra && jQuery.isFunction( extra ) ) {
+ // call the extra function and tack the current return value on the end for possible inspection
+ ret = extra.apply( elem, val == null ? data : data.concat( val ) );
+ // if anything is returned, give it precedence and have it overwrite the previous value
+ if (ret !== undefined)
+ val = ret;
+ }
+
+ // Trigger the native events (except for clicks on links)
+ if ( fn && donative !== false && val !== false && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+ }
+
+ this.triggered = false;
+ }
+
+ return val;
+ },
+
+ handle: function(event) {
+ // returned undefined or false
+ var val;
+
+ // Empty object is for triggered events with no data
+ event = jQuery.event.fix( event || window.event || {} );
+
+ // Namespaced event handlers
+ var parts = event.type.split(".");
+ event.type = parts[0];
+
+ var handlers = jQuery.data(this, "events") && jQuery.data(this, "events")[event.type], args = Array.prototype.slice.call( arguments, 1 );
+ args.unshift( event );
+
+ for ( var j in handlers ) {
+ var handler = handlers[j];
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ args[0].handler = handler;
+ args[0].data = handler.data;
+
+ // Filter the functions by class
+ if ( !parts[1] && !event.exclusive || handler.type == parts[1] ) {
+ var ret = handler.apply( this, args );
+
+ if ( val !== false )
+ val = ret;
+
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+ }
+
+ // Clean up added properties in IE to prevent memory leak
+ if (jQuery.browser.msie)
+ event.target = event.preventDefault = event.stopPropagation =
+ event.handler = event.data = null;
+
+ return val;
+ },
+
+ fix: function(event) {
+ // store a copy of the original event object
+ // and clone to set read-only properties
+ var originalEvent = event;
+ event = jQuery.extend({}, originalEvent);
+
+ // add preventDefault and stopPropagation since
+ // they will not work on the clone
+ event.preventDefault = function() {
+ // if preventDefault exists run it on the original event
+ if (originalEvent.preventDefault)
+ originalEvent.preventDefault();
+ // otherwise set the returnValue property of the original event to false (IE)
+ originalEvent.returnValue = false;
+ };
+ event.stopPropagation = function() {
+ // if stopPropagation exists run it on the original event
+ if (originalEvent.stopPropagation)
+ originalEvent.stopPropagation();
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ originalEvent.cancelBubble = true;
+ };
+
+ // Fix target property, if necessary
+ if ( !event.target )
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType == 3 )
+ event.target = originalEvent.target.parentNode;
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement )
+ event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
+ event.which = event.charCode || event.keyCode;
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey )
+ event.metaKey = event.ctrlKey;
+
+ // Add which for click: 1 == left; 2 == middle; 3 == right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button )
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+
+ return event;
+ },
+
+ special: {
+ ready: {
+ setup: function() {
+ // Make sure the ready event is setup
+ bindReady();
+ return;
+ },
+
+ teardown: function() { return; }
+ },
+
+ mouseenter: {
+ setup: function() {
+ if ( jQuery.browser.msie ) return false;
+ jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler);
+ return true;
+ },
+
+ teardown: function() {
+ if ( jQuery.browser.msie ) return false;
+ jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler);
+ return true;
+ },
+
+ handler: function(event) {
+ // If we actually just moused on to a sub-element, ignore it
+ if ( withinElement(event, this) ) return true;
+ // Execute the right handlers by setting the event type to mouseenter
+ arguments[0].type = "mouseenter";
+ return jQuery.event.handle.apply(this, arguments);
+ }
+ },
+
+ mouseleave: {
+ setup: function() {
+ if ( jQuery.browser.msie ) return false;
+ jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler);
+ return true;
+ },
+
+ teardown: function() {
+ if ( jQuery.browser.msie ) return false;
+ jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler);
+ return true;
+ },
+
+ handler: function(event) {
+ // If we actually just moused on to a sub-element, ignore it
+ if ( withinElement(event, this) ) return true;
+ // Execute the right handlers by setting the event type to mouseleave
+ arguments[0].type = "mouseleave";
+ return jQuery.event.handle.apply(this, arguments);
+ }
+ }
+ }
+};
+
+jQuery.fn.extend({
+ bind: function( type, data, fn ) {
+ return type == "unload" ? this.one(type, data, fn) : this.each(function(){
+ jQuery.event.add( this, type, fn || data, fn && data );
+ });
+ },
+
+ one: function( type, data, fn ) {
+ return this.each(function(){
+ jQuery.event.add( this, type, function(event) {
+ jQuery(this).unbind(event);
+ return (fn || data).apply( this, arguments);
+ }, fn && data);
+ });
+ },
+
+ unbind: function( type, fn ) {
+ return this.each(function(){
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+
+ trigger: function( type, data, fn ) {
+ return this.each(function(){
+ jQuery.event.trigger( type, data, this, true, fn );
+ });
+ },
+
+ triggerHandler: function( type, data, fn ) {
+ if ( this[0] )
+ return jQuery.event.trigger( type, data, this[0], false, fn );
+ return undefined;
+ },
+
+ toggle: function() {
+ // Save reference to arguments for access in closure
+ var args = arguments;
+
+ return this.click(function(event) {
+ // Figure out which function to execute
+ this.lastToggle = 0 == this.lastToggle ? 1 : 0;
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[this.lastToggle].apply( this, arguments ) || false;
+ });
+ },
+
+ hover: function(fnOver, fnOut) {
+ return this.bind('mouseenter', fnOver).bind('mouseleave', fnOut);
+ },
+
+ ready: function(fn) {
+ // Attach the listeners
+ bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady )
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ else
+ // Add the function to the wait list
+ jQuery.readyList.push( function() { return fn.call(this, jQuery); } );
+
+ return this;
+ }
+});
+
+jQuery.extend({
+ isReady: false,
+ readyList: [],
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( jQuery.readyList ) {
+ // Execute all of them
+ jQuery.each( jQuery.readyList, function(){
+ this.apply( document );
+ });
+
+ // Reset the list of functions
+ jQuery.readyList = null;
+ }
+
+ // Trigger any bound ready events
+ jQuery(document).triggerHandler("ready");
+ }
+ }
+});
+
+var readyBound = false;
+
+function bindReady(){
+ if ( readyBound ) return;
+ readyBound = true;
+
+ // Mozilla, Opera (see further below for it) and webkit nightlies currently support this event
+ if ( document.addEventListener && !jQuery.browser.opera)
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
+
+ // If IE is used and is not in a frame
+ // Continually check to see if the document is ready
+ if ( jQuery.browser.msie && window == top ) (function(){
+ if (jQuery.isReady) return;
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( arguments.callee, 0 );
+ return;
+ }
+ // and execute any waiting functions
+ jQuery.ready();
+ })();
+
+ if ( jQuery.browser.opera )
+ document.addEventListener( "DOMContentLoaded", function () {
+ if (jQuery.isReady) return;
+ for (var i = 0; i < document.styleSheets.length; i++)
+ if (document.styleSheets[i].disabled) {
+ setTimeout( arguments.callee, 0 );
+ return;
+ }
+ // and execute any waiting functions
+ jQuery.ready();
+ }, false);
+
+ if ( jQuery.browser.safari ) {
+ var numStyles;
+ (function(){
+ if (jQuery.isReady) return;
+ if ( document.readyState != "loaded" && document.readyState != "complete" ) {
+ setTimeout( arguments.callee, 0 );
+ return;
+ }
+ if ( numStyles === undefined )
+ numStyles = jQuery("style, link[rel=stylesheet]").length;
+ if ( document.styleSheets.length != numStyles ) {
+ setTimeout( arguments.callee, 0 );
+ return;
+ }
+ // and execute any waiting functions
+ jQuery.ready();
+ })();
+ }
+
+ // A fallback to window.onload, that will always work
+ jQuery.event.add( window, "load", jQuery.ready );
+}
+
+jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
+ "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
+ "submit,keydown,keypress,keyup,error").split(","), function(i, name){
+
+ // Handle event binding
+ jQuery.fn[name] = function(fn){
+ return fn ? this.bind(name, fn) : this.trigger(name);
+ };
+});
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function(event, elem) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+ // Traverse up the tree
+ while ( parent && parent != elem ) try { parent = parent.parentNode; } catch(error) { parent = elem; }
+ // Return true if we actually just moused on to a sub-element
+ return parent == elem;
+};
+
+// Prevent memory leaks in IE
+// And prevent errors on refresh with events like mouseover in other browsers
+// Window isn't included so as not to unbind existing unload events
+jQuery(window).bind("unload", function() {
+ jQuery("*").add(document).unbind();
+});
+jQuery.fn.extend({
+ load: function( url, params, callback ) {
+ if ( jQuery.isFunction( url ) )
+ return this.bind("load", url);
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ callback = callback || function(){};
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params )
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else {
+ params = jQuery.param( params );
+ type = "POST";
+ }
+
+ var self = this;
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ complete: function(res, status){
+ // If successful, inject the HTML into all the matched elements
+ if ( status == "success" || status == "notmodified" )
+ // See if a selector was specified
+ self.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("<div/>")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))
+
+ // Locate the specified elements
+ .find(selector) :
+
+ // If not, just inject the full result
+ res.responseText );
+
+ self.each( callback, [res.responseText, status, res] );
+ }
+ });
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function(){
+ return jQuery.nodeName(this, "form") ?
+ jQuery.makeArray(this.elements) : this;
+ })
+ .filter(function(){
+ return this.name && !this.disabled &&
+ (this.checked || /select|textarea/i.test(this.nodeName) ||
+ /text|hidden|password/i.test(this.type));
+ })
+ .map(function(i, elem){
+ var val = jQuery(this).val();
+ return val == null ? null :
+ val.constructor == Array ?
+ jQuery.map( val, function(val, i){
+ return {name: elem.name, value: val};
+ }) :
+ {name: elem.name, value: val};
+ }).get();
+ }
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
+ jQuery.fn[o] = function(f){
+ return this.bind(o, f);
+ };
+});
+
+var jsc = (new Date).getTime();
+
+jQuery.extend({
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was ommited
+ if ( jQuery.isFunction( data ) ) {
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get(url, null, callback, "script");
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ post: function( url, data, callback, type ) {
+ if ( jQuery.isFunction( data ) ) {
+ callback = data;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ global: true,
+ type: "GET",
+ timeout: 0,
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ data: null,
+ username: null,
+ password: null,
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+
+ ajax: function( s ) {
+ var jsonp, jsre = /=\?(&|$)/g, status, data;
+
+ // Extend the settings, but re-extend 's' so that it can be
+ // checked again later (in the test suite, specifically)
+ s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data != "string" )
+ s.data = jQuery.param(s.data);
+
+ // Handle JSONP Parameter Callbacks
+ if ( s.dataType == "jsonp" ) {
+ if ( s.type.toLowerCase() == "get" ) {
+ if ( !s.url.match(jsre) )
+ s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ } else if ( !s.data || !s.data.match(jsre) )
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
+ jsonp = "jsonp" + jsc++;
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data )
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = function(tmp){
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+ try{ delete window[ jsonp ]; } catch(e){}
+ if ( head )
+ head.removeChild( script );
+ };
+ }
+
+ if ( s.dataType == "script" && s.cache == null )
+ s.cache = false;
+
+ if ( s.cache === false && s.type.toLowerCase() == "get" ) {
+ var ts = (new Date()).getTime();
+ // try replacing _= if it is there
+ var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && s.type.toLowerCase() == "get" ) {
+ s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
+
+ // IE likes to send both get and post data, prevent this
+ s.data = null;
+ }
+
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ )
+ jQuery.event.trigger( "ajaxStart" );
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( (!s.url.indexOf("http") || !s.url.indexOf("//")) && s.dataType == "script" && s.type.toLowerCase() == "get" ) {
+ var head = document.getElementsByTagName("head")[0];
+ var script = document.createElement("script");
+ script.src = s.url;
+ if (s.scriptCharset)
+ script.charset = s.scriptCharset;
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ var done = false;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function(){
+ if ( !done && (!this.readyState ||
+ this.readyState == "loaded" || this.readyState == "complete") ) {
+ done = true;
+ success();
+ complete();
+ head.removeChild( script );
+ }
+ };
+ }
+
+ head.appendChild(script);
+
+ // We handle everything using the script element injection
+ return undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
+ var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
+
+ // Open the socket
+ xml.open(s.type, s.url, s.async, s.username, s.password);
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data )
+ xml.setRequestHeader("Content-Type", s.contentType);
+
+ // Set the If-Modified-Since header, if ifModified mode.
+ if ( s.ifModified )
+ xml.setRequestHeader("If-Modified-Since",
+ jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+
+ // Set the Accepts header for the server, depending on the dataType
+ xml.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e){}
+
+ // Allow custom headers/mimetypes
+ if ( s.beforeSend )
+ s.beforeSend(xml);
+
+ if ( s.global )
+ jQuery.event.trigger("ajaxSend", [xml, s]);
+
+ // Wait for a response to come back
+ var onreadystatechange = function(isTimeout){
+ // The transfer is complete and the data is available, or the request timed out
+ if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
+ requestDone = true;
+
+ // clear poll interval
+ if (ival) {
+ clearInterval(ival);
+ ival = null;
+ }
+
+ status = isTimeout == "timeout" && "timeout" ||
+ !jQuery.httpSuccess( xml ) && "error" ||
+ s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
+ "success";
+
+ if ( status == "success" ) {
+ // Watch for, and catch, XML document parse errors
+ try {
+ // process the data (runs the xml through httpData regardless of callback)
+ data = jQuery.httpData( xml, s.dataType );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status == "success" ) {
+ // Cache Last-Modified header, if ifModified mode.
+ var modRes;
+ try {
+ modRes = xml.getResponseHeader("Last-Modified");
+ } catch(e) {} // swallow exception thrown by FF if header is not available
+
+ if ( s.ifModified && modRes )
+ jQuery.lastModified[s.url] = modRes;
+
+ // JSONP handles its own success callback
+ if ( !jsonp )
+ success();
+ } else
+ jQuery.handleError(s, xml, status);
+
+ // Fire the complete handlers
+ complete();
+
+ // Stop memory leaks
+ if ( s.async )
+ xml = null;
+ }
+ };
+
+ if ( s.async ) {
+ // don't attach the handler to the request, just poll it instead
+ var ival = setInterval(onreadystatechange, 13);
+
+ // Timeout checker
+ if ( s.timeout > 0 )
+ setTimeout(function(){
+ // Check to see if the request is still happening
+ if ( xml ) {
+ // Cancel the request
+ xml.abort();
+
+ if( !requestDone )
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xml.send(s.data);
+ } catch(e) {
+ jQuery.handleError(s, xml, null, e);
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async )
+ onreadystatechange();
+
+ function success(){
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success )
+ s.success( data, status );
+
+ // Fire the global callback
+ if ( s.global )
+ jQuery.event.trigger( "ajaxSuccess", [xml, s] );
+ }
+
+ function complete(){
+ // Process result
+ if ( s.complete )
+ s.complete(xml, status);
+
+ // The request was completed
+ if ( s.global )
+ jQuery.event.trigger( "ajaxComplete", [xml, s] );
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active )
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xml;
+ },
+
+ handleError: function( s, xml, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) s.error( xml, status, e );
+
+ // Fire the global callback
+ if ( s.global )
+ jQuery.event.trigger( "ajaxError", [xml, s, e] );
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( r ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !r.status && location.protocol == "file:" ||
+ ( r.status >= 200 && r.status < 300 ) || r.status == 304 || r.status == 1223 ||
+ jQuery.browser.safari && r.status == undefined;
+ } catch(e){}
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xml, url ) {
+ try {
+ var xmlRes = xml.getResponseHeader("Last-Modified");
+
+ // Firefox always returns 200. check Last-Modified date
+ return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
+ jQuery.browser.safari && xml.status == undefined;
+ } catch(e){}
+ return false;
+ },
+
+ httpData: function( r, type ) {
+ var ct = r.getResponseHeader("content-type");
+ var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
+ var data = xml ? r.responseXML : r.responseText;
+
+ if ( xml && data.documentElement.tagName == "parsererror" )
+ throw "parsererror";
+
+ // If the type is "script", eval it in global context
+ if ( type == "script" )
+ jQuery.globalEval( data );
+
+ // Get the JavaScript object, if JSON is used.
+ if ( type == "json" )
+ data = eval("(" + data + ")");
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a ) {
+ var s = [];
+
+ // If an array was passed in, assume that it is an array
+ // of form elements
+ if ( a.constructor == Array || a.jquery )
+ // Serialize the form elements
+ jQuery.each( a, function(){
+ s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
+ });
+
+ // Otherwise, assume that it's an object of key/value pairs
+ else
+ // Serialize the key/values
+ for ( var j in a )
+ // If the value is an array then the key names need to be repeated
+ if ( a[j] && a[j].constructor == Array )
+ jQuery.each( a[j], function(){
+ s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
+ });
+ else
+ s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );
+
+ // Return the resulting serialization
+ return s.join("&").replace(/%20/g, "+");
+ }
+
+});
+jQuery.fn.extend({
+ show: function(speed,callback){
+ return speed ?
+ this.animate({
+ height: "show", width: "show", opacity: "show"
+ }, speed, callback) :
+
+ this.filter(":hidden").each(function(){
+ this.style.display = this.oldblock || "";
+ if ( jQuery.css(this,"display") == "none" ) {
+ var elem = jQuery("<" + this.tagName + " />").appendTo("body");
+ this.style.display = elem.css("display");
+ // handle an edge condition where css is - div { display:none; } or similar
+ if (this.style.display == "none")
+ this.style.display = "block";
+ elem.remove();
+ }
+ }).end();
+ },
+
+ hide: function(speed,callback){
+ return speed ?
+ this.animate({
+ height: "hide", width: "hide", opacity: "hide"
+ }, speed, callback) :
+
+ this.filter(":visible").each(function(){
+ this.oldblock = this.oldblock || jQuery.css(this,"display");
+ this.style.display = "none";
+ }).end();
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ){
+ return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
+ this._toggle( fn, fn2 ) :
+ fn ?
+ this.animate({
+ height: "toggle", width: "toggle", opacity: "toggle"
+ }, fn, fn2) :
+ this.each(function(){
+ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
+ });
+ },
+
+ slideDown: function(speed,callback){
+ return this.animate({height: "show"}, speed, callback);
+ },
+
+ slideUp: function(speed,callback){
+ return this.animate({height: "hide"}, speed, callback);
+ },
+
+ slideToggle: function(speed, callback){
+ return this.animate({height: "toggle"}, speed, callback);
+ },
+
+ fadeIn: function(speed, callback){
+ return this.animate({opacity: "show"}, speed, callback);
+ },
+
+ fadeOut: function(speed, callback){
+ return this.animate({opacity: "hide"}, speed, callback);
+ },
+
+ fadeTo: function(speed,to,callback){
+ return this.animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ return this[ optall.queue === false ? "each" : "queue" ](function(){
+ if ( this.nodeType != 1)
+ return false;
+
+ var opt = jQuery.extend({}, optall);
+ var hidden = jQuery(this).is(":hidden"), self = this;
+
+ for ( var p in prop ) {
+ if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
+ return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
+
+ if ( p == "height" || p == "width" ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+ }
+
+ if ( opt.overflow != null )
+ this.style.overflow = "hidden";
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function(name, val){
+ var e = new jQuery.fx( self, opt, name );
+
+ if ( /toggle|show|hide/.test(val) )
+ e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+ else {
+ var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
+ start = e.cur(true) || 0;
+
+ if ( parts ) {
+ var end = parseFloat(parts[2]),
+ unit = parts[3] || "px";
+
+ // We need to compute starting value
+ if ( unit != "px" ) {
+ self.style[ name ] = (end || 1) + unit;
+ start = ((end || 1) / e.cur(true)) * start;
+ self.style[ name ] = start + unit;
+ }
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if ( parts[1] )
+ end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
+
+ e.custom( start, end, unit );
+ } else
+ e.custom( start, val, "" );
+ }
+ });
+
+ // For JS strict compliance
+ return true;
+ });
+ },
+
+ queue: function(type, fn){
+ if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
+ fn = type;
+ type = "fx";
+ }
+
+ if ( !type || (typeof type == "string" && !fn) )
+ return queue( this[0], type );
+
+ return this.each(function(){
+ if ( fn.constructor == Array )
+ queue(this, type, fn);
+ else {
+ queue(this, type).push( fn );
+
+ if ( queue(this, type).length == 1 )
+ fn.apply(this);
+ }
+ });
+ },
+
+ stop: function(clearQueue, gotoEnd){
+ var timers = jQuery.timers;
+
+ if (clearQueue)
+ this.queue([]);
+
+ this.each(function(){
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- )
+ if ( timers[i].elem == this ) {
+ if (gotoEnd)
+ // force the next step to be the last
+ timers[i](true);
+ timers.splice(i, 1);
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if (!gotoEnd)
+ this.dequeue();
+
+ return this;
+ }
+
+});
+
+var queue = function( elem, type, array ) {
+ if ( !elem )
+ return undefined;
+
+ type = type || "fx";
+
+ var q = jQuery.data( elem, type + "queue" );
+
+ if ( !q || array )
+ q = jQuery.data( elem, type + "queue",
+ array ? jQuery.makeArray(array) : [] );
+
+ return q;
+};
+
+jQuery.fn.dequeue = function(type){
+ type = type || "fx";
+
+ return this.each(function(){
+ var q = queue(this, type);
+
+ q.shift();
+
+ if ( q.length )
+ q[0].apply( this );
+ });
+};
+
+jQuery.extend({
+
+ speed: function(speed, easing, fn) {
+ var opt = speed && speed.constructor == Object ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && easing.constructor != Function && easing
+ };
+
+ opt.duration = (opt.duration && opt.duration.constructor == Number ?
+ opt.duration :
+ { slow: 600, fast: 200 }[opt.duration]) || 400;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function(){
+ if ( opt.queue !== false )
+ jQuery(this).dequeue();
+ if ( jQuery.isFunction( opt.old ) )
+ opt.old.apply( this );
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+ timerId: null,
+
+ fx: function( elem, options, prop ){
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig )
+ options.orig = {};
+ }
+
+});
+
+jQuery.fx.prototype = {
+
+ // Simple function for setting a style value
+ update: function(){
+ if ( this.options.step )
+ this.options.step.apply( this.elem, [ this.now, this ] );
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( this.prop == "height" || this.prop == "width" )
+ this.elem.style.display = "block";
+ },
+
+ // Get the current size
+ cur: function(force){
+ if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
+ return this.elem[ this.prop ];
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function(from, to, unit){
+ this.startTime = (new Date()).getTime();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+ this.update();
+
+ var self = this;
+ function t(gotoEnd){
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ jQuery.timers.push(t);
+
+ if ( jQuery.timerId == null ) {
+ jQuery.timerId = setInterval(function(){
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ )
+ if ( !timers[i]() )
+ timers.splice(i--, 1);
+
+ if ( !timers.length ) {
+ clearInterval( jQuery.timerId );
+ jQuery.timerId = null;
+ }
+ }, 13);
+ }
+ },
+
+ // Simple 'show' function
+ show: function(){
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
+ this.options.show = true;
+
+ // Begin the animation
+ this.custom(0, this.cur());
+
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ if ( this.prop == "width" || this.prop == "height" )
+ this.elem.style[this.prop] = "1px";
+
+ // Start by showing the element
+ jQuery(this.elem).show();
+ },
+
+ // Simple 'hide' function
+ hide: function(){
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
+ this.options.hide = true;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function(gotoEnd){
+ var t = (new Date()).getTime();
+
+ if ( gotoEnd || t > this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ var done = true;
+ for ( var i in this.options.curAnim )
+ if ( this.options.curAnim[i] !== true )
+ done = false;
+
+ if ( done ) {
+ if ( this.options.display != null ) {
+ // Reset the overflow
+ this.elem.style.overflow = this.options.overflow;
+
+ // Reset the display
+ this.elem.style.display = this.options.display;
+ if ( jQuery.css(this.elem, "display") == "none" )
+ this.elem.style.display = "block";
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide )
+ this.elem.style.display = "none";
+
+ // Reset the properties, if the item has been hidden or shown
+ if ( this.options.hide || this.options.show )
+ for ( var p in this.options.curAnim )
+ jQuery.attr(this.elem.style, p, this.options.orig[p]);
+ }
+
+ // If a callback was provided, execute it
+ if ( done && jQuery.isFunction( this.options.complete ) )
+ // Execute the complete function
+ this.options.complete.apply( this.elem );
+
+ return false;
+ } else {
+ var n = t - this.startTime;
+ this.state = n / this.options.duration;
+
+ // Perform the easing function, defaults to swing
+ this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+
+ // Perform the next step of the animation
+ this.update();
+ }
+
+ return true;
+ }
+
+};
+
+jQuery.fx.step = {
+ scrollLeft: function(fx){
+ fx.elem.scrollLeft = fx.now;
+ },
+
+ scrollTop: function(fx){
+ fx.elem.scrollTop = fx.now;
+ },
+
+ opacity: function(fx){
+ jQuery.attr(fx.elem.style, "opacity", fx.now);
+ },
+
+ _default: function(fx){
+ fx.elem.style[ fx.prop ] = fx.now + fx.unit;
+ }
+};
+// The Offset Method
+// Originally By Brandon Aaron, part of the Dimension Plugin
+// http://jquery.com/plugins/project/dimensions
+jQuery.fn.offset = function() {
+ var left = 0, top = 0, elem = this[0], results;
+
+ if ( elem ) with ( jQuery.browser ) {
+ var parent = elem.parentNode,
+ offsetChild = elem,
+ offsetParent = elem.offsetParent,
+ doc = elem.ownerDocument,
+ safari2 = safari && parseInt(version) < 522 && !/adobeair/i.test(userAgent),
+ fixed = jQuery.css(elem, "position") == "fixed";
+
+ // Use getBoundingClientRect if available
+ if ( elem.getBoundingClientRect ) {
+ var box = elem.getBoundingClientRect();
+
+ // Add the document scroll offsets
+ add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
+ box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
+
+ // IE adds the HTML element's border, by default it is medium which is 2px
+ // IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; }
+ // IE 7 standards mode, the border is always 2px
+ // This border/offset is typically represented by the clientLeft and clientTop properties
+ // However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS
+ // Therefore this method will be off by 2px in IE while in quirksmode
+ add( -doc.documentElement.clientLeft, -doc.documentElement.clientTop );
+
+ // Otherwise loop through the offsetParents and parentNodes
+ } else {
+
+ // Initial element offsets
+ add( elem.offsetLeft, elem.offsetTop );
+
+ // Get parent offsets
+ while ( offsetParent ) {
+ // Add offsetParent offsets
+ add( offsetParent.offsetLeft, offsetParent.offsetTop );
+
+ // Mozilla and Safari > 2 does not include the border on offset parents
+ // However Mozilla adds the border for table or table cells
+ if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 )
+ border( offsetParent );
+
+ // Add the document scroll offsets if position is fixed on any offsetParent
+ if ( !fixed && jQuery.css(offsetParent, "position") == "fixed" )
+ fixed = true;
+
+ // Set offsetChild to previous offsetParent unless it is the body element
+ offsetChild = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent;
+ // Get next offsetParent
+ offsetParent = offsetParent.offsetParent;
+ }
+
+ // Get parent scroll offsets
+ while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
+ // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
+ if ( !/^inline|table.*$/i.test(jQuery.css(parent, "display")) )
+ // Subtract parent scroll offsets
+ add( -parent.scrollLeft, -parent.scrollTop );
+
+ // Mozilla does not add the border for a parent that has overflow != visible
+ if ( mozilla && jQuery.css(parent, "overflow") != "visible" )
+ border( parent );
+
+ // Get next parent
+ parent = parent.parentNode;
+ }
+
+ // Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild
+ // Mozilla doubles body offsets with a non-absolutely positioned offsetChild
+ if ( (safari2 && (fixed || jQuery.css(offsetChild, "position") == "absolute")) ||
+ (mozilla && jQuery.css(offsetChild, "position") != "absolute") )
+ add( -doc.body.offsetLeft, -doc.body.offsetTop );
+
+ // Add the document scroll offsets if position is fixed
+ if ( fixed )
+ add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
+ Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
+ }
+
+ // Return an object with top and left properties
+ results = { top: top, left: left };
+ }
+
+ function border(elem) {
+ add( jQuery.curCSS(elem, "borderLeftWidth", true), jQuery.curCSS(elem, "borderTopWidth", true) );
+ }
+
+ function add(l, t) {
+ left += parseInt(l) || 0;
+ top += parseInt(t) || 0;
+ }
+
+ return results;
+};
+})();
--- /dev/null
+var MrClay = window.MrClay || {};\r
+\r
+/**\r
+ * Simplified access to/manipulation of the query string\r
+ * \r
+ * Based on: http://adamv.com/dev/javascript/files/querystring.js\r
+ * Design pattern: http://www.litotes.demon.co.uk/js_info/private_static.html#wConst\r
+ */\r
+MrClay.QueryString = function(){\r
+ /**\r
+ * @static\r
+ * @private\r
+ */\r
+ var parse = function(str) {\r
+ var assignments = str.split('&')\r
+ ,obj = {}\r
+ ,propValue;\r
+ for (var i = 0, l = assignments.length; i < l; ++i) {\r
+ propValue = assignments[i].split('=');\r
+ if (propValue.length > 2\r
+ || -1 != propValue[0].indexOf('+')\r
+ || propValue[0] == ''\r
+ ) {\r
+ continue;\r
+ }\r
+ if (propValue.length == 1) {\r
+ propValue[1] = propValue[0];\r
+ }\r
+ obj[unescape(propValue[0])] = unescape(propValue[1].replace(/\+/g, ' '));\r
+ }\r
+ return obj;\r
+ };\r
+ \r
+ /**\r
+ * Constructor (MrClay.QueryString becomes this)\r
+ *\r
+ * @param mixed A window object, a query string, or empty (default current window)\r
+ */\r
+ function construct_(spec) {\r
+ spec = spec || window;\r
+ if (typeof spec == 'object') {\r
+ // get querystring from window\r
+ this.window = spec;\r
+ spec = spec.location.search.substr(1);\r
+ } else {\r
+ this.window = window;\r
+ }\r
+ this.vars = parse(spec);\r
+ }\r
+ \r
+ /**\r
+ * Reload the window\r
+ *\r
+ * @static\r
+ * @public\r
+ * @param object vars Specify querystring vars only if you wish to replace them\r
+ * @param object window_ window to be reloaded (current window by default)\r
+ */\r
+ construct_.reload = function(vars, window_) {\r
+ window_ = window_ || window;\r
+ vars = vars || (new MrClay.QueryString(window_)).vars;\r
+ var l = window_.location\r
+ ,currUrl = l.href\r
+ ,s = MrClay.QueryString.toString(vars)\r
+ ,newUrl = l.protocol + '//' + l.hostname + l.pathname\r
+ + (s ? '?' + s : '') + l.hash;\r
+ if (currUrl == newUrl) {\r
+ l.reload();\r
+ } else {\r
+ l.assign(newUrl);\r
+ }\r
+ };\r
+ \r
+ /**\r
+ * Get the value of a querystring var\r
+ *\r
+ * @static\r
+ * @public\r
+ * @param string key\r
+ * @param mixed default_ value to return if key not found\r
+ * @param object window_ window to check (current window by default)\r
+ * @return mixed\r
+ */\r
+ construct_.get = function(key, default_, window_) {\r
+ window_ = window_ || window;\r
+ return (new MrClay.QueryString(window_)).get(key, default_);\r
+ };\r
+ \r
+ /**\r
+ * Reload the page setting one or multiple querystring vars\r
+ *\r
+ * @static\r
+ * @public\r
+ * @param mixed key object of query vars/values, or a string key for a single\r
+ * assignment\r
+ * @param mixed null for multiple settings, the value to assign for single\r
+ * @param object window_ window to reload (current window by default)\r
+ */\r
+ construct_.set = function(key, value, window_) {\r
+ window_ = window_ || window;\r
+ (new MrClay.QueryString(window_)).set(key, value).reload();\r
+ };\r
+ \r
+ /**\r
+ * Convert an object of query vars/values to a querystring\r
+ *\r
+ * @static\r
+ * @public\r
+ * @param object query vars/values\r
+ * @return string\r
+ */\r
+ construct_.toString = function(vars) {\r
+ var pieces = [];\r
+ for (var prop in vars) {\r
+ pieces.push(escape(prop) + '=' + escape(vars[prop]));\r
+ }\r
+ return pieces.join('&');\r
+ };\r
+ \r
+ /**\r
+ * @public\r
+ */\r
+ construct_.prototype.reload = function() {\r
+ MrClay.QueryString.reload(this.vars, this.window);\r
+ return this;\r
+ };\r
+ \r
+ /**\r
+ * @public\r
+ */\r
+ construct_.prototype.get = function(key, default_) {\r
+ if (typeof default_ == 'undefined') {\r
+ default_ = null;\r
+ }\r
+ return (this.vars[key] == null)\r
+ ? default_\r
+ : this.vars[key];\r
+ };\r
+ \r
+ /**\r
+ * @public\r
+ */\r
+ construct_.prototype.set = function(key, value) {\r
+ var obj = {};\r
+ if (typeof key == 'string') {\r
+ obj[key] = value;\r
+ } else {\r
+ obj = key;\r
+ }\r
+ for (var prop in obj) {\r
+ if (obj[prop] == null) {\r
+ delete this.vars[prop];\r
+ } else {\r
+ this.vars[prop] = obj[prop];\r
+ }\r
+ }\r
+ return this;\r
+ };\r
+ \r
+ /**\r
+ * @public\r
+ */\r
+ construct_.prototype.toString = function() {\r
+ return QueryString.toString(this.vars);\r
+ };\r
+ \r
+ return construct_;\r
+}(); // define and execute
\ No newline at end of file
--- /dev/null
+// http://mrclay.org/\r
+(function(){\r
+ var\r
+ reMailto = /^mailto:my_name_is_(\S+)_and_the_domain_is_(\S+)$/,\r
+ reRemoveTitleIf = /^my name is/,\r
+ oo = window.onload,\r
+ fixHrefs = function() {\r
+ var i = 0, l, m;\r
+ while (l = document.links[i++]) {\r
+ // require phrase in href property\r
+ if (m = l.href.match(reMailto)) {\r
+ l.href = 'mailto:' + m[1] + '@' + m[2];\r
+ if (reRemoveTitleIf.test(l.title)) {\r
+ l.title = '';\r
+ }\r
+ }\r
+ }\r
+ };\r
+ // end var\r
+ window.onload = function() {\r
+ oo && oo();\r
+ fixHrefs();\r
+ };\r
+})();
\ No newline at end of file
--- /dev/null
+\r
+// end in comment
\ No newline at end of file
--- /dev/null
+function h() {\r
+ \r
+}
\ No newline at end of file
--- /dev/null
+/* this { is a } comment */
+
+@import "/1.css";
+
+selector {
+ property: value;
+}
--- /dev/null
+/* this { is a } comment */
+
+@import "/2.css";
+
+selector2 {
+ property: value;
+}
--- /dev/null
+@import "/1.css";@import "/2.css";selector{property:value}selector2{property:value}
\ No newline at end of file
--- /dev/null
+var triggerBug = {_default: "*/*"};\r
+var essentialFunctionality = true;\r
--- /dev/null
+
+/* email.js */
+
+/* 1 */ // http://mrclay.org/
+/* 2 */ (function(){
+/* 3 */ var
+/* 4 */ reMailto = /^mailto:my_name_is_(\S+)_and_the_domain_is_(\S+)$/,
+/* 5 */ reRemoveTitleIf = /^my name is/,
+/* 6 */ oo = window.onload,
+/* 7 */ fixHrefs = function() {
+/* 8 */ var i = 0, l, m;
+/* 9 */ while (l = document.links[i++]) {
+/* 10 */ // require phrase in href property
+/* 11 */ if (m = l.href.match(reMailto)) {
+/* 12 */ l.href = 'mailto:' + m[1] + '@' + m[2];
+/* 13 */ if (reRemoveTitleIf.test(l.title)) {
+/* 14 */ l.title = '';
+/* 15 */ }
+/* 16 */ }
+/* 17 */ }
+/* 18 */ };
+/* 19 */ // end var
+/* 20 */ window.onload = function() {
+/* 21 */ oo && oo();
+/* 22 */ fixHrefs();
+/* 23 */ };
+/* 24 */ })();
+
+;
+/* lines_bugs.js */
+
+/* 1 */ var triggerBug = {_default: "*/*"};
+/* 2 */ var essentialFunctionality = true;
+/* 3 */
+
+;
+/* QueryString.js */
+
+/* 1 */ var MrClay = window.MrClay || {};
+/* 2 */
+/* 3 */ /**
+/* 4 *| * Simplified access to/manipulation of the query string
+/* 5 *| *
+/* 6 *| * Based on: http://adamv.com/dev/javascript/files/querystring.js
+/* 7 *| * Design pattern: http://www.litotes.demon.co.uk/js_info/private_static.html#wConst
+/* 8 *| */
+/* 9 */ MrClay.QueryString = function(){
+/* 10 */ /**
+/* 11 *| * @static
+/* 12 *| * @private
+/* 13 *| */
+/* 14 */ var parse = function(str) {
+/* 15 */ var assignments = str.split('&')
+/* 16 */ ,obj = {}
+/* 17 */ ,propValue;
+/* 18 */ for (var i = 0, l = assignments.length; i < l; ++i) {
+/* 19 */ propValue = assignments[i].split('=');
+/* 20 */ if (propValue.length > 2
+/* 21 */ || -1 != propValue[0].indexOf('+')
+/* 22 */ || propValue[0] == ''
+/* 23 */ ) {
+/* 24 */ continue;
+/* 25 */ }
+/* 26 */ if (propValue.length == 1) {
+/* 27 */ propValue[1] = propValue[0];
+/* 28 */ }
+/* 29 */ obj[unescape(propValue[0])] = unescape(propValue[1].replace(/\+/g, ' '));
+/* 30 */ }
+/* 31 */ return obj;
+/* 32 */ };
+/* 33 */
+/* 34 */ /**
+/* 35 *| * Constructor (MrClay.QueryString becomes this)
+/* 36 *| *
+/* 37 *| * @param mixed A window object, a query string, or empty (default current window)
+/* 38 *| */
+/* 39 */ function construct_(spec) {
+/* 40 */ spec = spec || window;
+/* 41 */ if (typeof spec == 'object') {
+/* 42 */ // get querystring from window
+/* 43 */ this.window = spec;
+/* 44 */ spec = spec.location.search.substr(1);
+/* 45 */ } else {
+/* 46 */ this.window = window;
+/* 47 */ }
+/* 48 */ this.vars = parse(spec);
+/* 49 */ }
+/* 50 */
+
+/* QueryString.js */
+
+/* 51 */ /**
+/* 52 *| * Reload the window
+/* 53 *| *
+/* 54 *| * @static
+/* 55 *| * @public
+/* 56 *| * @param object vars Specify querystring vars only if you wish to replace them
+/* 57 *| * @param object window_ window to be reloaded (current window by default)
+/* 58 *| */
+/* 59 */ construct_.reload = function(vars, window_) {
+/* 60 */ window_ = window_ || window;
+/* 61 */ vars = vars || (new MrClay.QueryString(window_)).vars;
+/* 62 */ var l = window_.location
+/* 63 */ ,currUrl = l.href
+/* 64 */ ,s = MrClay.QueryString.toString(vars)
+/* 65 */ ,newUrl = l.protocol + '//' + l.hostname + l.pathname
+/* 66 */ + (s ? '?' + s : '') + l.hash;
+/* 67 */ if (currUrl == newUrl) {
+/* 68 */ l.reload();
+/* 69 */ } else {
+/* 70 */ l.assign(newUrl);
+/* 71 */ }
+/* 72 */ };
+/* 73 */
+/* 74 */ /**
+/* 75 *| * Get the value of a querystring var
+/* 76 *| *
+/* 77 *| * @static
+/* 78 *| * @public
+/* 79 *| * @param string key
+/* 80 *| * @param mixed default_ value to return if key not found
+/* 81 *| * @param object window_ window to check (current window by default)
+/* 82 *| * @return mixed
+/* 83 *| */
+/* 84 */ construct_.get = function(key, default_, window_) {
+/* 85 */ window_ = window_ || window;
+/* 86 */ return (new MrClay.QueryString(window_)).get(key, default_);
+/* 87 */ };
+/* 88 */
+/* 89 */ /**
+/* 90 *| * Reload the page setting one or multiple querystring vars
+/* 91 *| *
+/* 92 *| * @static
+/* 93 *| * @public
+/* 94 *| * @param mixed key object of query vars/values, or a string key for a single
+/* 95 *| * assignment
+/* 96 *| * @param mixed null for multiple settings, the value to assign for single
+/* 97 *| * @param object window_ window to reload (current window by default)
+/* 98 *| */
+/* 99 */ construct_.set = function(key, value, window_) {
+/* 100 */ window_ = window_ || window;
+
+/* QueryString.js */
+
+/* 101 */ (new MrClay.QueryString(window_)).set(key, value).reload();
+/* 102 */ };
+/* 103 */
+/* 104 */ /**
+/* 105 *| * Convert an object of query vars/values to a querystring
+/* 106 *| *
+/* 107 *| * @static
+/* 108 *| * @public
+/* 109 *| * @param object query vars/values
+/* 110 *| * @return string
+/* 111 *| */
+/* 112 */ construct_.toString = function(vars) {
+/* 113 */ var pieces = [];
+/* 114 */ for (var prop in vars) {
+/* 115 */ pieces.push(escape(prop) + '=' + escape(vars[prop]));
+/* 116 */ }
+/* 117 */ return pieces.join('&');
+/* 118 */ };
+/* 119 */
+/* 120 */ /**
+/* 121 *| * @public
+/* 122 *| */
+/* 123 */ construct_.prototype.reload = function() {
+/* 124 */ MrClay.QueryString.reload(this.vars, this.window);
+/* 125 */ return this;
+/* 126 */ };
+/* 127 */
+/* 128 */ /**
+/* 129 *| * @public
+/* 130 *| */
+/* 131 */ construct_.prototype.get = function(key, default_) {
+/* 132 */ if (typeof default_ == 'undefined') {
+/* 133 */ default_ = null;
+/* 134 */ }
+/* 135 */ return (this.vars[key] == null)
+/* 136 */ ? default_
+/* 137 */ : this.vars[key];
+/* 138 */ };
+/* 139 */
+/* 140 */ /**
+/* 141 *| * @public
+/* 142 *| */
+/* 143 */ construct_.prototype.set = function(key, value) {
+/* 144 */ var obj = {};
+/* 145 */ if (typeof key == 'string') {
+/* 146 */ obj[key] = value;
+/* 147 */ } else {
+/* 148 */ obj = key;
+/* 149 */ }
+/* 150 */ for (var prop in obj) {
+
+/* QueryString.js */
+
+/* 151 */ if (obj[prop] == null) {
+/* 152 */ delete this.vars[prop];
+/* 153 */ } else {
+/* 154 */ this.vars[prop] = obj[prop];
+/* 155 */ }
+/* 156 */ }
+/* 157 */ return this;
+/* 158 */ };
+/* 159 */
+/* 160 */ /**
+/* 161 *| * @public
+/* 162 *| */
+/* 163 */ construct_.prototype.toString = function() {
+/* 164 */ return QueryString.toString(this.vars);
+/* 165 */ };
+/* 166 */
+/* 167 */ return construct_;
+/* 168 */ }(); // define and execute
+
+;
+/* before.js */
+
+/* 1 */ /*! is.js
+/* 2 *|
+/* 3 *| (c) 2001 Douglas Crockford
+/* 4 *| 2001 June 3
+/* 5 *| */
+/* 6 */
+/* 7 */ // is
+/* 8 */
+/* 9 */ // The -is- object is used to identify the browser. Every browser edition
+/* 10 */ // identifies itself, but there is no standard way of doing it, and some of
+/* 11 */ // the identification is deceptive. This is because the authors of web
+/* 12 */ // browsers are liars. For example, Microsoft's IE browsers claim to be
+/* 13 */ // Mozilla 4. Netscape 6 claims to be version 5.
+/* 14 */
+/* 15 */ var is = {
+/* 16 */ ie: navigator.appName == 'Microsoft Internet Explorer',
+/* 17 */ java: navigator.javaEnabled(),
+/* 18 */ ns: navigator.appName == 'Netscape',
+/* 19 */ ua: navigator.userAgent.toLowerCase(),
+/* 20 */ version: parseFloat(navigator.appVersion.substr(21)) ||
+/* 21 */ parseFloat(navigator.appVersion),
+/* 22 */ win: navigator.platform == 'Win32'
+/* 23 */ }
+/* 24 */ /*!*
+/* 25 *| * preserve this comment, too
+/* 26 *| */
+/* 27 */ is.mac = is.ua.indexOf('mac') >= 0;
+/* 28 */ if (is.ua.indexOf('opera') >= 0) {
+/* 29 */ is.ie = is.ns = false;
+/* 30 */ is.opera = true;
+/* 31 */ }
+/* 32 */ if (is.ua.indexOf('gecko') >= 0) {
+/* 33 */ is.ie = is.ns = false;
+/* 34 */ is.gecko = true;
+/* 35 */ }
+/* 36 */
+/* 37 */ /*@cc_on
+/* 38 *| /*@if (@_win32)
+/* 39 *| if (is.ie && is.win)
+/* 40 *| document.write("PASS: IE/win honored conditional comment.<br>");
+/* 41 *| @else @*/
+/* 42 */ if (is.ie && is.win)
+/* 43 */ document.write("FAIL: IE/win did not honor multi-line conditional comment.<br>");
+/* 44 */ else
+/* 45 */ document.write("PASS: Non-IE/win browser ignores multi-line conditional comment.<br>");
+/* 46 */ /*@end
+/* 47 *| @*/
+/* 48 */
+/* 49 */ var recognizesCondComm = true;
+/* 50 */ //@cc_on/*
+
+/* before.js */
+
+/* 51 *| recognizesCondComm = false;
+/* 52 *| //@cc_on*/
+/* 53 */
+/* 54 */ if ((is.ie && is.win) == recognizesCondComm)
+/* 55 */ document.write("PASS: IE/win honored single-line conditional comment.<br>");
+/* 56 */ else
+/* 57 */ document.write("FAIL: Non-IE/win browser did not ignore single-line conditional comment.<br>");
+/* 58 */
--- /dev/null
+@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
+solid #0f7}div#content
+h1+p{padding-top:0;margin-top:0}@media all and (min-width: 640px){#media-queries-1{background-color:#0f0}}@media screen and (max-width: 2000px){#media-queries-2{background-color:#0f0}}
+/* YUI Compressor style comments are preserved */
+body{background:#fff url(/path/to/image.gif) repeat-y}
\ No newline at end of file
--- /dev/null
+(function(){var\r
+reMailto=/^mailto:my_name_is_(\S+)_and_the_domain_is_(\S+)$/,reRemoveTitleIf=/^my name is/,oo=window.onload,fixHrefs=function(){var i=0,l,m;while(l=document.links[i++]){if(m=l.href.match(reMailto)){l.href='mailto:'+m[1]+'@'+m[2];if(reRemoveTitleIf.test(l.title)){l.title='';}}}};window.onload=function(){oo&&oo();fixHrefs();};})();;var MrClay=window.MrClay||{};MrClay.QueryString=function(){var parse=function(str){var assignments=str.split('&'),obj={},propValue;for(var i=0,l=assignments.length;i<l;++i){propValue=assignments[i].split('=');if(propValue.length>2||-1!=propValue[0].indexOf('+')||propValue[0]==''){continue;}\r
+if(propValue.length==1){propValue[1]=propValue[0];}\r
+obj[unescape(propValue[0])]=unescape(propValue[1].replace(/\+/g,' '));}\r
+return obj;};function construct_(spec){spec=spec||window;if(typeof spec=='object'){this.window=spec;spec=spec.location.search.substr(1);}else{this.window=window;}\r
+this.vars=parse(spec);}\r
+construct_.reload=function(vars,window_){window_=window_||window;vars=vars||(new MrClay.QueryString(window_)).vars;var l=window_.location,currUrl=l.href,s=MrClay.QueryString.toString(vars),newUrl=l.protocol+'//'+l.hostname+l.pathname\r
++(s?'?'+s:'')+l.hash;if(currUrl==newUrl){l.reload();}else{l.assign(newUrl);}};construct_.get=function(key,default_,window_){window_=window_||window;return(new MrClay.QueryString(window_)).get(key,default_);};construct_.set=function(key,value,window_){window_=window_||window;(new MrClay.QueryString(window_)).set(key,value).reload();};construct_.toString=function(vars){var pieces=[];for(var prop in vars){pieces.push(escape(prop)+'='+escape(vars[prop]));}\r
+return pieces.join('&');};construct_.prototype.reload=function(){MrClay.QueryString.reload(this.vars,this.window);return this;};construct_.prototype.get=function(key,default_){if(typeof default_=='undefined'){default_=null;}\r
+return(this.vars[key]==null)?default_:this.vars[key];};construct_.prototype.set=function(key,value){var obj={};if(typeof key=='string'){obj[key]=value;}else{obj=key;}\r
+for(var prop in obj){if(obj[prop]==null){delete this.vars[prop];}else{this.vars[prop]=obj[prop];}}\r
+return this;};construct_.prototype.toString=function(){return QueryString.toString(this.vars);};return construct_;}();
\ No newline at end of file
--- /dev/null
+<?php
+require_once '_inc.php';
+
+require_once 'HTTP/ConditionalGet.php';
+
+function test_HTTP_ConditionalGet()
+{
+ global $thisDir;
+
+ $lmTime = time() - 900;
+ $gmtTime = gmdate('D, d M Y H:i:s \G\M\T', $lmTime);
+
+ $tests = array(
+ array(
+ 'desc' => 'client has valid If-Modified-Since'
+ ,'inm' => null
+ ,'ims' => $gmtTime
+ ,'exp' => array(
+ 'Vary' => 'Accept-Encoding'
+ ,'Last-Modified' => $gmtTime
+ ,'ETag' => "\"pri{$lmTime}\""
+ ,'Cache-Control' => 'max-age=0, private'
+ ,'_responseCode' => 'HTTP/1.0 304 Not Modified'
+ ,'isValid' => true
+ )
+ )
+ ,array(
+ 'desc' => 'client has valid If-Modified-Since with trailing semicolon'
+ ,'inm' => null
+ ,'ims' => $gmtTime . ';'
+ ,'exp' => array(
+ 'Vary' => 'Accept-Encoding'
+ ,'Last-Modified' => $gmtTime
+ ,'ETag' => "\"pri{$lmTime}\""
+ ,'Cache-Control' => 'max-age=0, private'
+ ,'_responseCode' => 'HTTP/1.0 304 Not Modified'
+ ,'isValid' => true
+ )
+ )
+ ,array(
+ 'desc' => 'client has valid ETag (non-encoded version)'
+ ,'inm' => "\"badEtagFoo\", \"pri{$lmTime}\""
+ ,'ims' => null
+ ,'exp' => array(
+ 'Vary' => 'Accept-Encoding'
+ ,'Last-Modified' => $gmtTime
+ ,'ETag' => "\"pri{$lmTime}\""
+ ,'Cache-Control' => 'max-age=0, private'
+ ,'_responseCode' => 'HTTP/1.0 304 Not Modified'
+ ,'isValid' => true
+ )
+ )
+ ,array(
+ 'desc' => 'client has valid ETag (gzip version)'
+ ,'inm' => "\"badEtagFoo\", \"pri{$lmTime};gz\""
+ ,'ims' => null
+ ,'exp' => array(
+ 'Vary' => 'Accept-Encoding'
+ ,'Last-Modified' => $gmtTime
+ ,'ETag' => "\"pri{$lmTime};gz\""
+ ,'Cache-Control' => 'max-age=0, private'
+ ,'_responseCode' => 'HTTP/1.0 304 Not Modified'
+ ,'isValid' => true
+ )
+ )
+ ,array(
+ 'desc' => 'no conditional get'
+ ,'inm' => null
+ ,'ims' => null
+ ,'exp' => array(
+ 'Vary' => 'Accept-Encoding'
+ ,'Last-Modified' => $gmtTime
+ ,'ETag' => "\"pri{$lmTime};gz\""
+ ,'Cache-Control' => 'max-age=0, private'
+ ,'isValid' => false
+ )
+ )
+ ,array(
+ 'desc' => 'client has invalid ETag'
+ ,'inm' => '"pri' . ($lmTime - 300) . '"'
+ ,'ims' => null
+ ,'exp' => array(
+ 'Vary' => 'Accept-Encoding'
+ ,'Last-Modified' => $gmtTime
+ ,'ETag' => "\"pri{$lmTime};gz\""
+ ,'Cache-Control' => 'max-age=0, private'
+ ,'isValid' => false
+ )
+ )
+ ,array(
+ 'desc' => 'client has invalid If-Modified-Since'
+ ,'inm' => null
+ ,'ims' => gmdate('D, d M Y H:i:s \G\M\T', $lmTime - 300)
+ ,'exp' => array(
+ 'Vary' => 'Accept-Encoding'
+ ,'Last-Modified' => $gmtTime
+ ,'ETag' => "\"pri{$lmTime};gz\""
+ ,'Cache-Control' => 'max-age=0, private'
+ ,'isValid' => false
+ )
+ )
+ );
+
+ foreach ($tests as $test) {
+ // setup env
+ if (null === $test['inm']) {
+ unset($_SERVER['HTTP_IF_NONE_MATCH']);
+ } else {
+ $_SERVER['HTTP_IF_NONE_MATCH'] = get_magic_quotes_gpc()
+ ? addslashes($test['inm'])
+ : $test['inm'];
+ }
+ if (null === $test['ims']) {
+ unset($_SERVER['HTTP_IF_MODIFIED_SINCE']);
+ } else {
+ $_SERVER['HTTP_IF_MODIFIED_SINCE'] = $test['ims'];
+ }
+ $exp = $test['exp'];
+
+ $cg = new HTTP_ConditionalGet(array(
+ 'lastModifiedTime' => $lmTime
+ ,'encoding' => 'x-gzip'
+ ));
+ $ret = $cg->getHeaders();
+ $ret['isValid'] = $cg->cacheIsValid;
+
+ $passed = assertTrue($exp == $ret, 'HTTP_ConditionalGet : ' . $test['desc']);
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n--- INM = {$test['inm']} / IMS = {$test['ims']}\n";
+ echo "Expected = " . preg_replace('/\\s+/', ' ', var_export($exp, 1)) . "\n";
+ echo "Returned = " . preg_replace('/\\s+/', ' ', var_export($ret, 1)) . "\n\n";
+ }
+ }
+}
+
+test_HTTP_ConditionalGet();
\ No newline at end of file
--- /dev/null
+<?php
+require_once '_inc.php';
+
+require_once 'HTTP/Encoder.php';
+
+function test_HTTP_Encoder()
+{
+ global $thisDir;
+
+ HTTP_Encoder::$encodeToIe6 = true;
+ $methodTests = array(
+ array(
+ 'ua' => 'Any browser'
+ ,'ae' => 'compress, x-gzip'
+ ,'exp' => array('gzip', 'x-gzip')
+ ,'desc' => 'recognize "x-gzip" as gzip'
+ )
+ ,array(
+ 'ua' => 'Any browser'
+ ,'ae' => 'compress, x-gzip;q=0.5'
+ ,'exp' => array('gzip', 'x-gzip')
+ ,'desc' => 'gzip w/ non-zero q'
+ )
+ ,array(
+ 'ua' => 'Any browser'
+ ,'ae' => 'compress, x-gzip;q=0'
+ ,'exp' => array('compress', 'compress')
+ ,'desc' => 'gzip w/ zero q'
+ )
+ ,array(
+ 'ua' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'
+ ,'ae' => 'gzip, deflate'
+ ,'exp' => array('', '')
+ ,'desc' => 'IE6 w/o "enhanced security"'
+ )
+ ,array(
+ 'ua' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'
+ ,'ae' => 'gzip, deflate'
+ ,'exp' => array('gzip', 'gzip')
+ ,'desc' => 'IE6 w/ "enhanced security"'
+ )
+ ,array(
+ 'ua' => 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.01)'
+ ,'ae' => 'gzip, deflate'
+ ,'exp' => array('', '')
+ ,'desc' => 'IE5.5'
+ )
+ ,array(
+ 'ua' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 9.25'
+ ,'ae' => 'gzip,deflate'
+ ,'exp' => array('gzip', 'gzip')
+ ,'desc' => 'Opera identifying as IE6'
+ )
+ );
+ foreach ($methodTests as $test) {
+ $_SERVER['HTTP_USER_AGENT'] = $test['ua'];
+ $_SERVER['HTTP_ACCEPT_ENCODING'] = $test['ae'];
+ $exp = $test['exp'];
+ $ret = HTTP_Encoder::getAcceptedEncoding();
+ $passed = assertTrue($exp == $ret, 'HTTP_Encoder : ' . $test['desc']);
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n--- AE | UA = {$test['ae']} | {$test['ua']}\n";
+ echo "Expected = " . preg_replace('/\\s+/', ' ', var_export($exp, 1)) . "\n";
+ echo "Returned = " . preg_replace('/\\s+/', ' ', var_export($ret, 1)) . "\n\n";
+ }
+ }
+ HTTP_Encoder::$encodeToIe6 = false;
+ $methodTests = array(
+ array(
+ 'ua' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'
+ ,'ae' => 'gzip, deflate'
+ ,'exp' => array('', '')
+ ,'desc' => 'IE6 w/ "enhanced security"'
+ )
+ );
+ foreach ($methodTests as $test) {
+ $_SERVER['HTTP_USER_AGENT'] = $test['ua'];
+ $_SERVER['HTTP_ACCEPT_ENCODING'] = $test['ae'];
+ $exp = $test['exp'];
+ $ret = HTTP_Encoder::getAcceptedEncoding();
+ $passed = assertTrue($exp == $ret, 'HTTP_Encoder : ' . $test['desc']);
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n--- AE | UA = {$test['ae']} | {$test['ua']}\n";
+ echo "Expected = " . preg_replace('/\\s+/', ' ', var_export($exp, 1)) . "\n";
+ echo "Returned = " . preg_replace('/\\s+/', ' ', var_export($ret, 1)) . "\n\n";
+ }
+ }
+
+ if (! function_exists('gzdeflate')) {
+ echo "!WARN: HTTP_Encoder : Zlib support is not present in PHP. Encoding cannot be performed/tested.\n";
+ return;
+ }
+
+ // test compression of varied content (HTML,JS, & CSS)
+ $variedContent = file_get_contents($thisDir . '/_test_files/html/before.html')
+ . file_get_contents($thisDir . '/_test_files/css/subsilver.css')
+ . file_get_contents($thisDir . '/_test_files/js/jquery-1.2.3.js');
+ $variedLength = strlen($variedContent);
+
+ $encodingTests = array(
+ array('method' => 'deflate', 'inv' => 'gzinflate', 'exp' => 32157)
+ ,array('method' => 'gzip', 'inv' => '_gzdecode', 'exp' => 32175)
+ ,array('method' => 'compress', 'inv' => 'gzuncompress', 'exp' => 32211)
+ );
+
+ foreach ($encodingTests as $test) {
+ $e = new HTTP_Encoder(array(
+ 'content' => $variedContent
+ ,'method' => $test['method']
+ ));
+ $e->encode(9);
+ $ret = strlen($e->getContent());
+
+ // test uncompression
+ $roundTrip = @call_user_func($test['inv'], $e->getContent());
+ $desc = "HTTP_Encoder : {$test['method']} : uncompress possible";
+ $passed = assertTrue($variedContent == $roundTrip, $desc);
+
+ // test expected compressed size
+ $desc = "HTTP_Encoder : {$test['method']} : compressed to "
+ . sprintf('%4.2f%% of original', $ret/$variedLength*100);
+ $passed = assertTrue(abs($ret - $test['exp']) < 100, $desc);
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n--- {$test['method']}: expected bytes: "
+ , "{$test['exp']}. Returned: {$ret} "
+ , "(off by ". abs($ret - $test['exp']) . " bytes)\n\n";
+ }
+ }
+
+ $_SERVER['HTTP_ACCEPT_ENCODING'] = 'identity';
+ $he = new HTTP_Encoder(array(
+ 'content' => 'Hello'
+ ));
+ $he->encode();
+ $headers = $he->getHeaders();
+ assertTrue(isset($headers['Vary']), 'HTTP_Encoder : Vary always sent');
+}
+
+test_HTTP_Encoder();
+
+function _gzdecode($data)
+{
+ $filename = $error = '';
+ return _phpman_gzdecode($data, $filename, $error);
+}
+
+// http://www.php.net/manual/en/function.gzdecode.php#82930
+function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
+{
+ $len = strlen($data);
+ if ($len < 18 || strcmp(substr($data,0,2),"\x1f\x8b")) {
+ $error = "Not in GZIP format.";
+ return null; // Not GZIP format (See RFC 1952)
+ }
+ $method = ord(substr($data,2,1)); // Compression method
+ $flags = ord(substr($data,3,1)); // Flags
+ if ($flags & 31 != $flags) {
+ $error = "Reserved bits not allowed.";
+ return null;
+ }
+ // NOTE: $mtime may be negative (PHP integer limitations)
+ $mtime = unpack("V", substr($data,4,4));
+ $mtime = $mtime[1];
+ $xfl = substr($data,8,1);
+ $os = substr($data,8,1);
+ $headerlen = 10;
+ $extralen = 0;
+ $extra = "";
+ if ($flags & 4) {
+ // 2-byte length prefixed EXTRA data in header
+ if ($len - $headerlen - 2 < 8) {
+ return false; // invalid
+ }
+ $extralen = unpack("v",substr($data,8,2));
+ $extralen = $extralen[1];
+ if ($len - $headerlen - 2 - $extralen < 8) {
+ return false; // invalid
+ }
+ $extra = substr($data,10,$extralen);
+ $headerlen += 2 + $extralen;
+ }
+ $filenamelen = 0;
+ $filename = "";
+ if ($flags & 8) {
+ // C-style string
+ if ($len - $headerlen - 1 < 8) {
+ return false; // invalid
+ }
+ $filenamelen = strpos(substr($data,$headerlen),chr(0));
+ if ($filenamelen === false || $len - $headerlen - $filenamelen - 1 < 8) {
+ return false; // invalid
+ }
+ $filename = substr($data,$headerlen,$filenamelen);
+ $headerlen += $filenamelen + 1;
+ }
+ $commentlen = 0;
+ $comment = "";
+ if ($flags & 16) {
+ // C-style string COMMENT data in header
+ if ($len - $headerlen - 1 < 8) {
+ return false; // invalid
+ }
+ $commentlen = strpos(substr($data,$headerlen),chr(0));
+ if ($commentlen === false || $len - $headerlen - $commentlen - 1 < 8) {
+ return false; // Invalid header format
+ }
+ $comment = substr($data,$headerlen,$commentlen);
+ $headerlen += $commentlen + 1;
+ }
+ $headercrc = "";
+ if ($flags & 2) {
+ // 2-bytes (lowest order) of CRC32 on header present
+ if ($len - $headerlen - 2 < 8) {
+ return false; // invalid
+ }
+ $calccrc = crc32(substr($data,0,$headerlen)) & 0xffff;
+ $headercrc = unpack("v", substr($data,$headerlen,2));
+ $headercrc = $headercrc[1];
+ if ($headercrc != $calccrc) {
+ $error = "Header checksum failed.";
+ return false; // Bad header CRC
+ }
+ $headerlen += 2;
+ }
+ // GZIP FOOTER
+ $datacrc = unpack("V",substr($data,-8,4));
+ $datacrc = sprintf('%u',$datacrc[1] & 0xFFFFFFFF);
+ $isize = unpack("V",substr($data,-4));
+ $isize = $isize[1];
+ // decompression:
+ $bodylen = $len-$headerlen-8;
+ if ($bodylen < 1) {
+ // IMPLEMENTATION BUG!
+ return null;
+ }
+ $body = substr($data,$headerlen,$bodylen);
+ $data = "";
+ if ($bodylen > 0) {
+ switch ($method) {
+ case 8:
+ // Currently the only supported compression method:
+ $data = gzinflate($body,$maxlength);
+ break;
+ default:
+ $error = "Unknown compression method.";
+ return false;
+ }
+ } // zero-byte body content is allowed
+ // Verifiy CRC32
+ $crc = sprintf("%u",crc32($data));
+ $crcOK = $crc == $datacrc;
+ $lenOK = $isize == strlen($data);
+ if (!$lenOK || !$crcOK) {
+ $error = ( $lenOK ? '' : 'Length check FAILED. ') . ( $crcOK ? '' : 'Checksum FAILED.');
+ return false;
+ }
+ return $data;
+}
\ No newline at end of file
--- /dev/null
+<?php
+require_once '_inc.php';
+
+require_once 'JSMin.php';
+
+function test_JSMin()
+{
+ global $thisDir;
+
+ $src = file_get_contents($thisDir . '/_test_files/js/before.js');
+ $minExpected = file_get_contents($thisDir . '/_test_files/js/before.min.js');
+ $minOutput = JSMin::minify($src);
+
+ $passed = assertTrue($minExpected == $minOutput, 'JSMin : Overall');
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Output: " .strlen($minOutput). " bytes\n\n{$minOutput}\n\n";
+ echo "---Expected: " .strlen($minExpected). " bytes\n\n{$minExpected}\n\n";
+ echo "---Source: " .strlen($src). " bytes\n\n{$src}\n\n\n";
+ }
+
+ $src = file_get_contents($thisDir . '/_test_files/js/issue74.js');
+ $minExpected = file_get_contents($thisDir . '/_test_files/js/issue74.min.js');
+ $minOutput = JSMin::minify($src);
+
+ $passed = assertTrue($minExpected == $minOutput, 'JSMin : Quotes in RegExp literals (Issue 74)');
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Output: " .strlen($minOutput). " bytes\n\n{$minOutput}\n\n";
+ echo "---Expected: " .strlen($minExpected). " bytes\n\n{$minExpected}\n\n";
+ echo "---Source: " .strlen($src). " bytes\n\n{$src}\n\n\n";
+
+ test_JSMin_exception('"Hello'
+ ,'Unterminated String'
+ ,'JSMin_UnterminatedStringException'
+ ,"Unterminated String: '\"Hello'");
+ test_JSMin_exception("return /regexp\n}"
+ ,'Unterminated RegExp'
+ ,'JSMin_UnterminatedRegExpException'
+ ,"Unterminated RegExp: '/regexp\n'");
+ test_JSMin_exception("/* Comment "
+ ,'Unterminated Comment'
+ ,'JSMin_UnterminatedCommentException'
+ ,"Unterminated Comment: '/* Comment '");
+ }
+}
+
+function test_JSMin_exception($js, $label, $expClass, $expMessage) {
+ $eClass = $eMsg = '';
+ try {
+ JSMin::minify($js);
+ } catch (Exception $e) {
+ $eClass = get_class($e);
+ $eMsg = $e->getMessage();
+ }
+ $passed = assertTrue($eClass === $expClass && $eMsg === $expMessage,
+ 'JSMin : throw on ' . $label);
+ if (! $passed && __FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n ---" , $e, "\n\n";
+ }
+}
+
+test_JSMin();
--- /dev/null
+<?php
+require_once '_inc.php';
+
+require_once 'JSMinPlus.php';
+
+function test_JSMinPlus()
+{
+ global $thisDir;
+
+ $src = file_get_contents($thisDir . '/_test_files/js/condcomm.js');
+ $minExpected = file_get_contents($thisDir . '/_test_files/js/condcomm.min_plus.js');
+
+ $minOutput = JSMinPlus::minify($src);
+
+ $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Conditional Comments');
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Output: " .strlen($minOutput). " bytes\n\n{$minOutput}\n\n";
+ echo "---Expected: " .strlen($minExpected). " bytes\n\n{$minExpected}\n\n";
+ echo "---Source: " .strlen($src). " bytes\n\n{$src}\n\n\n";
+ }
+
+ return;
+
+
+ $src = file_get_contents($thisDir . '/_test_files/js/before.js');
+ $minExpected = file_get_contents($thisDir . '/_test_files/js/before.min_plus.js');
+ $minOutput = JSMinPlus::minify($src);
+
+ $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Overall');
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Output: " .strlen($minOutput). " bytes\n\n{$minOutput}\n\n";
+ echo "---Expected: " .strlen($minExpected). " bytes\n\n{$minExpected}\n\n";
+ echo "---Source: " .strlen($src). " bytes\n\n{$src}\n\n\n";
+ }
+
+ $src = file_get_contents($thisDir . '/_test_files/js/issue74.js');
+ $minExpected = file_get_contents($thisDir . '/_test_files/js/issue74.min_plus.js');
+ $minOutput = JSMinPlus::minify($src);
+
+ $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Quotes in RegExp literals (Issue 74)');
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Output: " .strlen($minOutput). " bytes\n\n{$minOutput}\n\n";
+ echo "---Expected: " .strlen($minExpected). " bytes\n\n{$minExpected}\n\n";
+ echo "---Source: " .strlen($src). " bytes\n\n{$src}\n\n\n";
+ /*
+ test_JSMin_exception('"Hello'
+ ,'Unterminated String'
+ ,'JSMin_UnterminatedStringException'
+ ,"Unterminated String: '\"Hello'");
+ test_JSMin_exception("return /regexp\n}"
+ ,'Unterminated RegExp'
+ ,'JSMin_UnterminatedRegExpException'
+ ,"Unterminated RegExp: '/regexp\n'");
+ test_JSMin_exception("/* Comment "
+ ,'Unterminated Comment'
+ ,'JSMin_UnterminatedCommentException'
+ ,"Unterminated Comment: '/* Comment '");
+ //*/
+ }
+}
+
+/*function test_JSMin_exception($js, $label, $expClass, $expMessage) {
+ $eClass = $eMsg = '';
+ try {
+ JSMin::minify($js);
+ } catch (Exception $e) {
+ $eClass = get_class($e);
+ $eMsg = $e->getMessage();
+ }
+ $passed = assertTrue($eClass === $expClass && $eMsg === $expMessage,
+ 'JSMin : throw on ' . $label);
+ if (! $passed && __FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n ---" , $e, "\n\n";
+ }
+}//*/
+
+test_JSMinPlus();
--- /dev/null
+<?php
+
+// currently these only test serve() when passed the 'quiet' options
+
+require_once '_inc.php';
+require_once 'Minify.php';
+
+function test_Minify()
+{
+ global $thisDir;
+
+ $minifyTestPath = dirname(__FILE__) . '/_test_files/minify';
+ $thisFileActive = (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME']));
+ $tomorrow = $_SERVER['REQUEST_TIME'] + 86400;
+ $lastModified = $_SERVER['REQUEST_TIME'] - 86400;
+
+ // Test 304 response
+
+ // simulate conditional headers
+ $_SERVER['HTTP_IF_NONE_MATCH'] = "\"{$lastModified}pub\"";
+ $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s \G\M\T', $lastModified);
+
+ $expected = array (
+ 'success' => true
+ ,'statusCode' => 304
+ ,'content' => '',
+ 'headers' => array(
+ 'Expires' => gmdate('D, d M Y H:i:s \G\M\T', $_SERVER['REQUEST_TIME'] + 1800),
+ 'Vary' => 'Accept-Encoding',
+ 'Last-Modified' => gmdate('D, d M Y H:i:s \G\M\T', $lastModified),
+ 'ETag' => "\"pub{$lastModified}\"",
+ 'Cache-Control' => 'max-age=1800, public',
+ '_responseCode' => 'HTTP/1.0 304 Not Modified',
+ )
+ );
+ $output = Minify::serve('Files', array(
+ 'files' => $thisDir . '/_test_files/css/styles.css' // controller casts to array
+ ,'quiet' => true
+ ,'lastModifiedTime' => $lastModified
+ ,'encodeOutput' => false
+ ));
+ $passed = assertTrue($expected === $output, 'Minify : 304 response');
+ if ($thisFileActive) {
+ echo "\nOutput: " .var_export($output, 1). "\n\n";
+ if (! $passed) {
+ echo "\n\n\n\n---Expected: " .var_export($expected, 1). "\n\n";
+ }
+ }
+
+ assertTrue(
+ ! class_exists('Minify_CSS', false)
+ && ! class_exists('Minify_Cache', false)
+ ,'Minify : cache, and minifier classes aren\'t loaded for 304s'
+ );
+
+ // Test minifying JS and serving with Expires header
+
+ $content = preg_replace('/\\r\\n?/', "\n", file_get_contents($minifyTestPath . '/minified.js'));
+ $lastModified = max(
+ filemtime($minifyTestPath . '/email.js')
+ ,filemtime($minifyTestPath . '/QueryString.js')
+ );
+ $expected = array(
+ 'success' => true
+ ,'statusCode' => 200
+ // JSMin always converts to \n line endings
+ ,'content' => $content
+ ,'headers' => array (
+ 'Expires' => gmdate('D, d M Y H:i:s \G\M\T', $tomorrow),
+ 'Vary' => 'Accept-Encoding',
+ 'Last-Modified' => gmdate('D, d M Y H:i:s \G\M\T', $lastModified),
+ 'ETag' => "\"pub{$lastModified}\"",
+ 'Cache-Control' => 'max-age=86400, public',
+ 'Content-Length' => strlen($content),
+ 'Content-Type' => 'application/x-javascript; charset=utf-8',
+ )
+ );
+ $output = Minify::serve('Files', array(
+ 'files' => array(
+ $minifyTestPath . '/email.js'
+ ,$minifyTestPath . '/QueryString.js'
+ )
+ ,'quiet' => true
+ ,'maxAge' => 86400
+ ,'encodeOutput' => false
+ ));
+
+ $passed = assertTrue($expected === $output, 'Minify : JS and Expires');
+ if ($thisFileActive) {
+ echo "\nOutput: " .var_export($output, 1). "\n\n";
+ if (! $passed) {
+ echo "\n\n\n\n---Expected: " .var_export($expected, 1). "\n\n";
+ }
+ }
+
+ // test for Issue 73
+ Minify::setCache(null);
+
+ $expected = ";function h(){}";
+ $output = Minify::serve('Files', array(
+ 'files' => array(
+ $minifyTestPath . '/issue73_1.js'
+ ,$minifyTestPath . '/issue73_2.js'
+ )
+ ,'quiet' => true
+ ,'encodeOutput' => false
+ ));
+ $output = $output['content'];
+
+ $passed = assertTrue($expected === $output, 'Minify : Issue 73');
+ if ($thisFileActive) {
+ if (! $passed) {
+ echo "\n---Output : " .var_export($output, 1). "\n";
+ echo "---Expected: " .var_export($expected, 1). "\n\n";
+ }
+ }
+
+ // test for Issue 89
+ $expected = file_get_contents($minifyTestPath . '/issue89_out.min.css');
+ $output = Minify::serve('Files', array(
+ 'files' => array(
+ $minifyTestPath . '/issue89_1.css'
+ ,$minifyTestPath . '/issue89_2.css'
+ )
+ ,'quiet' => true
+ ,'encodeOutput' => false
+ ,'bubbleCssImports' => true
+ ));
+ $output = $output['content'];
+ $passed = assertTrue($expected === $output, 'Minify : Issue 89 : bubbleCssImports');
+ if ($thisFileActive) {
+ if (! $passed) {
+ echo "\n---Output : " .var_export($output, 1). "\n";
+ echo "---Expected: " .var_export($expected, 1). "\n\n";
+ }
+ }
+
+ $output = Minify::serve('Files', array(
+ 'files' => array(
+ $minifyTestPath . '/issue89_1.css'
+ ,$minifyTestPath . '/issue89_2.css'
+ )
+ ,'quiet' => true
+ ,'encodeOutput' => false
+ ));
+ $output = $output['content'];
+ $passed = assertTrue(0 === strpos($output, Minify::$importWarning), 'Minify : Issue 89 : detect invalid imports');
+ if ($thisFileActive) {
+ if (! $passed) {
+ echo "\n---Output : " .var_export($output, 1). "\n";
+ echo "---Expected: " .var_export($expected, 1). "\n\n";
+ }
+ }
+
+ $output = Minify::serve('Files', array(
+ 'files' => array(
+ $minifyTestPath . '/issue89_1.css'
+ )
+ ,'quiet' => true
+ ,'encodeOutput' => false
+ ));
+ $output = $output['content'];
+ $passed = assertTrue(false === strpos($output, Minify::$importWarning), 'Minify : Issue 89 : don\'t warn about valid imports');
+ if ($thisFileActive) {
+ if (! $passed) {
+ echo "\n---Output : " .var_export($output, 1). "\n";
+ echo "---Expected: " .var_export($expected, 1). "\n\n";
+ }
+ }
+
+ // Test minifying CSS and responding with Etag/Last-Modified
+
+ Minify::setCache(null);
+
+ // don't allow conditional headers
+ unset($_SERVER['HTTP_IF_NONE_MATCH'], $_SERVER['HTTP_IF_MODIFIED_SINCE']);
+
+ $expectedContent = file_get_contents($minifyTestPath . '/minified.css');
+
+ $expected = array(
+ 'success' => true
+ ,'statusCode' => 200
+ ,'content' => $expectedContent
+ ,'headers' => array (
+ 'Vary' => 'Accept-Encoding',
+ 'Last-Modified' => gmdate('D, d M Y H:i:s \G\M\T', $lastModified),
+ 'ETag' => "\"pub{$lastModified}\"",
+ 'Cache-Control' => 'max-age=0, public',
+ 'Content-Length' => strlen($expectedContent),
+ 'Content-Type' => 'text/css; charset=utf-8',
+ )
+ );
+ $output = Minify::serve('Files', array(
+ 'files' => array(
+ $thisDir . '/_test_files/css/styles.css'
+ ,$thisDir . '/_test_files/css/comments.css'
+ )
+ ,'quiet' => true
+ ,'lastModifiedTime' => $lastModified
+ ,'encodeOutput' => false
+ ,'maxAge' => false
+ ));
+
+ $passed = assertTrue($expected === $output, 'Minify : CSS and Etag/Last-Modified');
+ if ($thisFileActive) {
+ echo "\nOutput: " .var_export($output, 1). "\n\n";
+ if (! $passed) {
+ echo "\n\n\n\n---Expected: " .var_export($expected, 1). "\n\n";
+ }
+ }
+}
+
+test_Minify();
--- /dev/null
+<?php
+require_once '_inc.php';
+
+require_once 'Minify/Build.php';
+
+function test_Minify_Build()
+{
+ global $thisDir;
+
+ $file1 = $thisDir . '/_test_files/css/paths_prepend.css';
+ $file2 = $thisDir . '/_test_files/css/styles.css';
+ $maxTime = max(filemtime($file1), filemtime($file2));
+
+ $b = new Minify_Build($file1);
+ assertTrue($b->lastModified == filemtime($file1)
+ ,'Minify_Build : single file path');
+
+ $b = new Minify_Build(array($file1, $file2));
+ assertTrue($maxTime == $b->lastModified
+ ,'Minify_Build : multiple file paths');
+
+ require_once 'Minify.php';
+ $b = new Minify_Build(array(
+ $file1
+ ,new Minify_Source(array('filepath' => $file2))
+ ));
+
+ assertTrue($maxTime == $b->lastModified
+ ,'Minify_Build : file path and a Minify_Source');
+ assertTrue($b->uri('/path') == "/path?{$maxTime}"
+ ,'Minify_Build : uri() with no querystring');
+ assertTrue($b->uri('/path?hello') == "/path?hello&{$maxTime}"
+ ,'Minify_Build : uri() with existing querystring');
+}
+
+test_Minify_Build();
\ No newline at end of file
--- /dev/null
+<?php
+require_once '_inc.php';
+
+require_once 'Minify/CSS.php';
+
+function test_CSS()
+{
+ global $thisDir;
+
+ $cssPath = dirname(__FILE__) . '/_test_files/css';
+
+ // build test file list
+ $d = dir($cssPath);
+ while (false !== ($entry = $d->read())) {
+ if (preg_match('/^([\w\\-]+)\.css$/', $entry, $m)) {
+ $list[] = $m[1];
+ }
+ }
+ $d->close();
+
+ foreach ($list as $item) {
+
+ $options = array();
+ if ($item === 'paths_prepend') {
+ $options = array('prependRelativePath' => '../');
+ } elseif ($item === 'paths_rewrite') {
+ $options = array('currentDir' => $thisDir . '/_test_files/css');
+ $tempDocRoot = $_SERVER['DOCUMENT_ROOT'];
+ $_SERVER['DOCUMENT_ROOT'] = $thisDir;
+ }
+
+ $src = file_get_contents($cssPath . "/{$item}.css");
+ $minExpected = file_get_contents($cssPath . "/{$item}.min.css");
+ $minOutput = Minify_CSS::minify($src, $options);
+
+ // reset doc root as configured
+ if ($item === 'paths_rewrite') {
+ $_SERVER['DOCUMENT_ROOT'] = $tempDocRoot;
+ }
+
+ $passed = assertTrue($minExpected === $minOutput, 'Minify_CSS : ' . $item);
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Output: " .strlen($minOutput). " bytes\n\n{$minOutput}\n\n";
+ if (!$passed) {
+ echo "---Expected: " .strlen($minExpected). " bytes\n\n{$minExpected}\n\n";
+ echo "---Source: " .strlen($src). " bytes\n\n{$src}\n\n\n";
+ }
+ }
+ }
+}
+
+test_CSS();
--- /dev/null
+<?php
+
+require_once '_inc.php';
+
+require_once 'Minify/CSS/UriRewriter.php';
+
+function test_Minify_CSS_UriRewriter()
+{
+ global $thisDir;
+
+ Minify_CSS_UriRewriter::$debugText = '';
+ $in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css');
+ $expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp.css');
+ $actual = Minify_CSS_UriRewriter::rewrite(
+ $in
+ ,$thisDir . '/_test_files/css_uriRewriter' // currentDir
+ ,$thisDir // use DOCUMENT_ROOT = '/full/path/to/min_unit_tests'
+ );
+
+ $passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter');
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Input:\n\n{$in}\n";
+ echo "\n---Output: " .strlen($actual). " bytes\n\n{$actual}\n\n";
+ if (!$passed) {
+ echo "---Expected: " .strlen($expected). " bytes\n\n{$expected}\n\n\n";
+ }
+
+ // show debugging only when test run directly
+ echo "--- Minify_CSS_UriRewriter::\$debugText\n\n"
+ , Minify_CSS_UriRewriter::$debugText;
+ }
+
+ Minify_CSS_UriRewriter::$debugText = '';
+ $in = '../../../../assets/skins/sam/sprite.png';
+ $exp = '/yui/assets/skins/sam/sprite.png';
+ $actual = Minify_CSS_UriRewriter::rewriteRelative(
+ $in
+ ,'sf_root_dir\web\yui\menu\assets\skins\sam'
+ ,'sf_root_dir\web'
+ );
+
+ $passed = assertTrue($exp === $actual, 'Minify_CSS_UriRewriter : Issue 99');
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Input:\n\n{$in}\n";
+ echo "\n---Output: " .strlen($actual). " bytes\n\n{$actual}\n\n";
+ if (!$passed) {
+ echo "---Expected: " .strlen($exp). " bytes\n\n{$exp}\n\n\n";
+ }
+
+ // show debugging only when test run directly
+ echo "--- Minify_CSS_UriRewriter::\$debugText\n\n"
+ , Minify_CSS_UriRewriter::$debugText;
+ }
+}
+
+test_Minify_CSS_UriRewriter();
\ No newline at end of file
--- /dev/null
+<?php
+require_once '_inc.php';
+
+require_once 'Minify/Cache/APC.php';
+
+function test_Minify_Cache_APC()
+{
+ $prefix = 'Minify_Cache_APC : ';
+ if (! function_exists('apc_store')) {
+ return;
+ }
+ $data = str_repeat(md5('testing'), 160);
+ $id = 'Minify_test_cache';
+
+ $cache = new Minify_Cache_APC();
+
+ assertTrue(true === $cache->store($id, $data), $prefix . 'store');
+
+ assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize');
+
+ assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
+
+ ob_start();
+ $cache->display($id);
+ $displayed = ob_get_contents();
+ ob_end_clean();
+
+ assertTrue($data === $displayed, $prefix . 'display');
+
+ assertTrue($data === $cache->fetch($id), $prefix . 'fetch');
+}
+
+test_Minify_Cache_APC();
\ No newline at end of file
--- /dev/null
+<?php
+require_once '_inc.php';
+
+require_once 'Minify/Cache/File.php';
+
+function test_Minify_Cache_File()
+{
+ global $minifyCachePath;
+
+ $data = str_repeat(md5(time()), 160);
+ $id = 'Minify_test_cache_noLock';
+ $prefix = 'Minify_Cache_File : ';
+
+ $cache = new Minify_Cache_File($minifyCachePath);
+
+ echo "NOTE: Minify_Cache_File : path is set to: '" . $cache->getPath() . "'.\n";
+
+ assertTrue(true === $cache->store($id, $data), $prefix . 'store');
+
+ assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize');
+
+ assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
+
+ ob_start();
+ $cache->display($id);
+ $displayed = ob_get_contents();
+ ob_end_clean();
+
+ assertTrue($data === $displayed, $prefix . 'display');
+
+ assertTrue($data === $cache->fetch($id), $prefix . 'fetch');\r
+ \r
+ // test with locks\r
+ \r
+ $id = 'Minify_test_cache_withLock';\r
+ $cache = new Minify_Cache_File($minifyCachePath, true);\r
+ \r
+ assertTrue(true === $cache->store($id, $data), $prefix . 'store w/ lock');\r
+ \r
+ assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize');\r
+ \r
+ assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');\r
+ \r
+ ob_start();\r
+ $cache->display($id);\r
+ $displayed = ob_get_contents();\r
+ ob_end_clean();\r
+ \r
+ assertTrue($data === $displayed, $prefix . 'display w/ lock');\r
+ \r
+ assertTrue($data === $cache->fetch($id), $prefix . 'fetch w/ lock');
+}
+
+test_Minify_Cache_File();
\ No newline at end of file
--- /dev/null
+<?php
+require_once '_inc.php';
+
+require_once 'Minify/Cache/Memcache.php';
+
+function test_Minify_Cache_Memcache()
+{
+ $prefix = 'Minify_Cache_Memcache : ';
+ if (! function_exists('memcache_set')) {
+ return;
+ }
+ $mc = new Memcache;
+ if (! @$mc->connect('localhost', 11211)) {
+ return;
+ }
+
+ $data = str_repeat(md5('testing'), 160);
+ $id = 'Minify_test_cache';
+
+ $cache = new Minify_Cache_Memcache($mc);
+
+ assertTrue(true === $cache->store($id, $data), $prefix . 'store');
+
+ assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize');
+
+ assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
+
+ ob_start();
+ $cache->display($id);
+ $displayed = ob_get_contents();
+ ob_end_clean();
+
+ assertTrue($data === $displayed, $prefix . 'display');
+
+ assertTrue($data === $cache->fetch($id), $prefix . 'fetch');
+}
+
+test_Minify_Cache_Memcache();
\ No newline at end of file
--- /dev/null
+<?php
+
+require_once '_inc.php';
+
+require_once 'Minify/CommentPreserver.php';
+
+function test_Minify_CommentPreserver()
+{
+ global $thisDir;
+
+ $inOut = array(
+ '/*!*/' => "\n/**/\n"
+ ,'/*!*/a' => "\n/**/\n1A"
+ ,'a/*!*//*!*/b' => "2A\n/**/\n\n/**/\n3B"
+ ,'a/*!*/b/*!*/' => "4A\n/**/\n5B\n/**/\n"
+ );
+
+ foreach ($inOut as $in => $expected) {
+ $actual = Minify_CommentPreserver::process($in, '_test_MCP_processor');
+ $passed = assertTrue($expected === $actual, 'Minify_CommentPreserver');
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Output: " .strlen($actual). " bytes\n\n{$actual}\n\n";
+ if (!$passed) {
+ echo "---Expected: " .strlen($expected). " bytes\n\n{$expected}\n\n\n";
+ }
+ }
+ }
+}
+
+function _test_MCP_processor($content, $options = array())
+{
+ static $callCount = 0;
+ ++$callCount;
+ return $callCount . strtoupper($content);
+}
+
+test_Minify_CommentPreserver();
\ No newline at end of file
--- /dev/null
+<?php
+require_once '_inc.php';
+
+require_once 'Minify/HTML.php';
+require_once 'Minify/CSS.php';
+require_once 'JSMin.php';
+
+function test_HTML()
+{
+ global $thisDir;
+
+ $src = file_get_contents($thisDir . '/_test_files/html/before.html');
+ $minExpected = file_get_contents($thisDir . '/_test_files/html/before.min.html');
+
+ $time = microtime(true);
+ $minOutput = Minify_HTML::minify($src, array(
+ 'cssMinifier' => array('Minify_CSS', 'minify')
+ ,'jsMinifier' => array('JSMin', 'minify')
+ ));
+ $time = microtime(true) - $time;
+
+ $passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ if ($passed) {
+ echo "\n---Source: ", strlen($src), " bytes\n"
+ , "---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
+ } else {
+ echo "\n---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n"
+ , "---Expected: ", strlen($minExpected), " bytes\n\n{$minExpected}\n\n"
+ , "---Source: ", strlen($src), " bytes\n\n{$src}\n\n\n";
+ }
+ }
+
+ $src = file_get_contents($thisDir . '/_test_files/html/before2.html');
+ $minExpected = file_get_contents($thisDir . '/_test_files/html/before2.min.html');
+
+ $time = microtime(true);
+ $minOutput = Minify_HTML::minify($src, array(
+ 'cssMinifier' => array('Minify_CSS', 'minify')
+ ,'jsMinifier' => array('JSMin', 'minify')
+ ));
+ $time = microtime(true) - $time;
+
+ $passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ if ($passed) {
+ echo "\n---Source: ", strlen($src), " bytes\n"
+ , "---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
+ } else {
+ echo "\n---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n"
+ , "---Expected: ", strlen($minExpected), " bytes\n\n{$minExpected}\n\n"
+ , "---Source: ", strlen($src), " bytes\n\n{$src}\n\n\n";
+ }
+ }
+}
+
+test_HTML();
--- /dev/null
+<?php
+
+require_once '_inc.php';
+
+require_once 'Minify/ImportProcessor.php';
+
+function test_Minify_ImportProcessor()
+{
+ global $thisDir;
+
+ $linDir = $thisDir . '/_test_files/importProcessor';
+
+ $testFilesUri = substr(
+ realpath($thisDir . '/_test_files')
+ ,strlen(realpath($_SERVER['DOCUMENT_ROOT']))
+ );
+ $testFilesUri = str_replace('\\', '/', $testFilesUri);
+
+ $expected = str_replace(
+ '%TEST_FILES_URI%'
+ ,$testFilesUri
+ ,file_get_contents($linDir . '/output.css')
+ );
+
+ $actual = Minify_ImportProcessor::process($linDir . '/input.css');
+
+ $passed = assertTrue($expected === $actual, 'ImportProcessor');
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Output: " .strlen($actual). " bytes\n\n{$actual}\n\n";
+ if (!$passed) {
+ echo "---Expected: " .strlen($expected). " bytes\n\n{$expected}\n\n\n";
+ }
+ }
+
+ $expectedIncludes = array (\r
+ realpath($linDir . '/input.css')\r
+ ,realpath($linDir . '/adjacent.css')\r
+ ,realpath($linDir . '/../css/styles.css')\r
+ ,realpath($linDir . '/1/tv.css')\r
+ ,realpath($linDir . '/1/adjacent.css')\r
+ );
+
+ $passed = assertTrue($expectedIncludes === Minify_ImportProcessor::$filesIncluded
+ , 'ImportProcessor : included right files in right order');
+}
+
+test_Minify_ImportProcessor();
\ No newline at end of file
--- /dev/null
+<?php
+
+require_once '_inc.php';
+require_once 'Minify.php';
+
+function test_Lines()
+{
+ global $thisDir;
+
+ $exp = file_get_contents("{$thisDir}/_test_files/minify/lines_output.js");
+
+ Minify::setCache(null); // no cache
+
+ $ret = Minify::serve('Files', array(
+ 'debug' => true
+ ,'quiet' => true
+ ,'encodeOutput' => false
+ ,'files' => array(
+ "{$thisDir}/_test_files/minify/email.js"
+ ,"{$thisDir}/_test_files/minify/lines_bugs.js"
+ ,"{$thisDir}/_test_files/minify/QueryString.js"
+ ,"{$thisDir}/_test_files/js/before.js"
+ )
+ ));
+
+ $passed = assertTrue($exp === $ret['content'], 'Minify_Lines');
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ echo "\n---Output: " .strlen($ret['content']). " bytes\n\n{$ret['content']}\n\n";
+ if (!$passed) {
+ echo "---Expected: " .strlen($exp). " bytes\n\n{$exp}\n\n\n";
+ }
+ }
+}
+
+test_Lines();
\ No newline at end of file
--- /dev/null
+<?php
+
+require 'test_Minify.php';
+require 'test_Minify_Build.php';
+require 'test_Minify_Cache_APC.php';
+require 'test_Minify_Cache_File.php';
+require 'test_Minify_Cache_Memcache.php';
+require 'test_Minify_CSS.php';
+require 'test_Minify_CSS_UriRewriter.php';
+require 'test_Minify_CommentPreserver.php';
+require 'test_Minify_HTML.php';
+require 'test_Minify_ImportProcessor.php';
+require 'test_Minify_Lines.php';
+require 'test_HTTP_Encoder.php';
+require 'test_HTTP_ConditionalGet.php';
+require 'test_JSMin.php';
+require 'test_environment.php';
--- /dev/null
+<?php
+
+if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ // called directly
+ if (isset($_GET['getOutputCompression'])) {
+ echo (int)ini_get('zlib.output_compression');
+ exit();
+ }
+ if (isset($_GET['hello'])) {
+ // try to disable (may not work)
+ ini_set('zlib.output_compression', '0');
+ echo 'World!';
+ exit();
+ }
+}
+
+require_once '_inc.php';
+
+function test_environment()
+{
+ global $thisDir;
+
+ // check DOCROOT
+ $noSlash = assertTrue(
+ 0 === preg_match('@[\\\\/]$@', $_SERVER['DOCUMENT_ROOT'])
+ ,'environment : DOCUMENT_ROOT should not end in trailing slash'
+ );
+ $isRealPath = assertTrue(false !== realpath($_SERVER['DOCUMENT_ROOT'])
+ ,'environment : DOCUMENT_ROOT should pass realpath()'
+ );
+ $containsThisFile = assertTrue(
+ 0 === strpos(realpath(__FILE__), realpath($_SERVER['DOCUMENT_ROOT']))
+ ,'environment : DOCUMENT_ROOT should contain this test file'
+ );
+ if (! $noSlash || ! $isRealPath || ! $containsThisFile) {
+ echo "\nDOCUMENT_ROOT is set to: '{$_SERVER['DOCUMENT_ROOT']}'. If you "
+ . "cannot modify this, consider setting \$min_documentRoot in config.php\n\n";
+ }
+ if (isset($_SERVER['SUBDOMAIN_DOCUMENT_ROOT'])) {
+ echo "\n!NOTE: environment : \$_SERVER['SUBDOMAIN_DOCUMENT_ROOT'] is set. "
+ . "You may need to set \$min_documentRoot to this in config.php\n";
+ }
+ if (realpath(__FILE__) !== realpath($_SERVER['DOCUMENT_ROOT'] . '/min_unit_tests/test_environment.php')) {
+ echo "!NOTE: environment : /min_unit_tests/ is not directly inside DOCUMENT_ROOT\n";
+ }
+
+ $thisUrl = 'http://'
+ . $_SERVER['HTTP_HOST'] // avoid redirects when SERVER_NAME doesn't match
+ . ('80' === $_SERVER['SERVER_PORT'] ? '' : ":{$_SERVER['SERVER_PORT']}")
+ . dirname($_SERVER['REQUEST_URI'])
+ . '/test_environment.php';
+
+ $oc = @file_get_contents($thisUrl . '?getOutputCompression=1');
+
+ if (false === $oc || ! preg_match('/^[01]$/', $oc)) {
+ echo "!WARN: environment : Local HTTP request failed. Testing cannot continue.\n";
+ return;
+ }
+ if ('1' === $oc) {
+ echo "!WARN: environment : zlib.output_compression is enabled in php.ini"
+ . " or .htaccess.\n";
+ }
+
+ $fp = fopen($thisUrl . '?hello=1', 'r', false, stream_context_create(array(
+ 'http' => array(
+ 'method' => "GET",
+ 'header' => "Accept-Encoding: deflate, gzip\r\n"
+ )
+ )));
+
+ $meta = stream_get_meta_data($fp);
+
+ $passed = true;
+ foreach ($meta['wrapper_data'] as $i => $header) {
+ if ((preg_match('@^Content-Length: (\\d+)$@i', $header, $m) && $m[1] !== '6')
+ || preg_match('@^Content-Encoding:@i', $header, $m)
+ ) {
+ $passed = false;
+ break;
+ }
+ }
+ if ($passed && stream_get_contents($fp) !== 'World!') {
+ $passed = false;
+ }
+ assertTrue(
+ $passed
+ ,'environment : PHP/server does not auto-HTTP-encode content'
+ );
+ fclose($fp);
+
+ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
+ if (! $passed) {
+ echo "\nReturned content should be 6 bytes and not HTTP encoded.\n"
+ . "Headers returned by: {$thisUrl}?hello=1\n\n";
+ var_export($meta['wrapper_data']);
+ }
+ }
+}
+
+test_environment();
--- /dev/null
+<!DOCTYPE html>
+<html><title>Test before.min.js</title></html>
+<h1>Test before.min.js</h1>
+<script src="_test_files/js/before.min.js" type="text/javascript"></script>
\ No newline at end of file
--- /dev/null
+<?php
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+
+// We bundle the minify library...
+set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/minify/min/lib');
+
+class MinifyAction extends Action
+{
+ const TYPE_CSS = 'text/css';
+ const TYPE_HTML = 'text/html';
+ // there is some debate over the ideal JS Content-Type, but this is the
+ // Apache default and what Yahoo! uses..
+ const TYPE_JS = 'application/x-javascript';
+
+ const cacheKey = 'minify';
+
+ var $file;
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ $this->v = $args['v'];
+
+ $f = $this->arg('f');
+ if(isset($f)) {
+ $this->file = INSTALLDIR.'/'.$f;
+ if(file_exists($this->file)) {
+ return true;
+ } else {
+ $this->clientError(_('f parameter is not a valid path'),404);
+ return false;
+ }
+ }else{
+ $this->clientError(_('f parameter is required'),500);
+ return false;
+ }
+ }
+
+ function etag()
+ {
+ if(isset($this->v)) {
+ return "\"" . crc32($this->file . $this->v) . "\"";
+ }else{
+ $stat = stat($this->file);
+ return '"' . $stat['ino'] . '-' . $stat['size'] . '-' . $stat['mtime'] . '"';
+ }
+ }
+
+ function lastModified()
+ {
+ return filemtime($this->file);
+ }
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ $c = common_memcache();
+ if (!empty($c)) {
+ $out = $c->get(common_cache_key(self::cacheKey . ':' . $this->file));
+ }
+ if(empty($out)) {
+ $out = $this->minify($this->file);
+ }
+ if (!empty($c)) {
+ $c->set(common_cache_key(self::cacheKey . ':' . $this->file), $out);
+ }
+
+ $sec = session_cache_expire() * 60;
+ header('Cache-Control: public, max-age=' . $sec);
+ header('Pragma: public');
+ $this->raw($out);
+ }
+
+ function minify($file)
+ {
+ $info = pathinfo($file);
+ switch(strtolower($info['extension'])){
+ case 'js':
+ require_once('JSMin.php');
+ $out = JSMin::minify(file_get_contents($file));
+ header('Content-Type: ' . self::TYPE_JS);
+ break;
+ case 'css':
+ require_once('Minify/CSS.php');
+ $options = array();
+ $options['currentDir'] = dirname($file);
+ $options['docRoot'] = INSTALLDIR;
+ $out = Minify_CSS::minify(file_get_contents($file),$options);
+ header('Content-Type: ' . self::TYPE_CSS);
+ break;
+ default:
+ $this->clientError(_('File type not supported'),500);
+ return false;
+ }
+ return $out;
+ }
+}
+