Changeset 2006 for trunk/modules/media/libraries/JavaScriptPacker.php
- Timestamp:
- 02/09/2008 12:23:27 AM (11 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/media/libraries/JavaScriptPacker.php
r1766 r2006 1 1 <?php 2 /* 7 December 2006. version 1.0 3 * 2 /** 3 * @package Media Module 4 * 5 * $Id$ 6 * 7 * 7 December 2006. version 1.0 8 * 4 9 * This is the php version of the Dean Edwards JavaScript 's Packer, 5 10 * Based on : 6 * 11 * 7 12 * ParseMaster, version 1.0.2 (2005-08-19) Copyright 2005, Dean Edwards 8 13 * a multi-pattern parser. 9 14 * KNOWN BUG: erroneous behavior when using escapeChar with a replacement 10 15 * value that is a function 11 * 16 * 12 17 * packer, version 2.0.2 (2005-08-19) Copyright 2004-2005, Dean Edwards 13 * 18 * 14 19 * License: http://creativecommons.org/licenses/LGPL/2.1/ 15 * 20 * 16 21 * Ported to PHP by Nicolas Martin. 17 * 22 * 18 23 * ---------------------------------------------------------------------- 19 * 24 * 20 25 * examples of usage : 21 26 * $myPacker = new JavaScriptPacker($script, 62, true, false); 22 27 * $packed = $myPacker->pack(); 23 * 28 * 24 29 * or 25 * 30 * 26 31 * $myPacker = new JavaScriptPacker($script, 'Normal', true, false); 27 32 * $packed = $myPacker->pack(); 28 * 33 * 29 34 * or (default values) 30 * 35 * 31 36 * $myPacker = new JavaScriptPacker($script); 32 37 * $packed = $myPacker->pack(); 33 * 34 * 38 * 39 * 35 40 * params of the constructor : 36 41 * $script: the JavaScript to pack, string. … … 43 48 * in the script, boolean. 44 49 * default: false. 45 * 50 * 46 51 * The pack() method return the compressed JavasScript, as a string. 47 * 52 * 48 53 * see http://dean.edwards.name/packer/usage/ for more information. 49 * 54 * 50 55 * Notes : 51 56 * # need PHP 5 . Tested with PHP 5.1.2 52 * 57 * 53 58 * # The packed result may be different than with the Dean Edwards 54 59 * version, but with the same length. The reason is that the PHP … … 58 63 * ECMAScript standard). So the encoded keywords order can be 59 64 * different in the two results. 60 * 65 * 61 66 * # Be careful with the 'High ASCII' Level encoding if you use 62 * UTF-8 in your files... 67 * UTF-8 in your files... 63 68 */ 64 69 … … 87 92 $_encoding = $this->LITERAL_ENCODING[$_encoding]; 88 93 $this->_encoding = min((int)$_encoding, 95); 89 $this->_fastDecode = $_fastDecode; 94 $this->_fastDecode = $_fastDecode; 90 95 $this->_specialChars = $_specialChars; 91 96 } … … 253 258 // the ECMAscript standard does not guarantee this behaviour, 254 259 // and thus not all browsers (e.g. Mozilla versions dating back to at 255 // least 2003) respect this. 260 // least 2003) respect this. 256 261 usort($unsorted, array(&$this, '_sortWords')); 257 262 $j = 0; … … 434 439 if (defined('self::JSFUNCTION'.$aName)) 435 440 return constant('self::JSFUNCTION'.$aName); 436 else 441 else 437 442 return ''; 438 443 } … … 530 535 return ($charCode < _encoding ? \'\' : arguments.callee($charCode / _encoding)) + 531 536 String.fromCharCode($charCode % _encoding + 161); 532 }'; 537 }'; 533 538 534 539 }
