Skip to content
Extraits de code Groupes Projets
Valider 896f539a rédigé par Christian Lefebvre's avatar Christian Lefebvre
Parcourir les fichiers

autodoc

parent 88a1f4e6
Branches
Étiquettes
Aucune requête de fusion associée trouvée
...@@ -56,6 +56,7 @@ class SourceMap { ...@@ -56,6 +56,7 @@ class SourceMap {
* @param string generic source code * @param string generic source code
* @param array array with nested array with code rules * @param array array with nested array with code rules
*/ */
// http://doc.spip.org/@getMap
function getMap(&$source, &$delimeters) { function getMap(&$source, &$delimeters) {
# "unsigned" integer variables # "unsigned" integer variables
...@@ -150,6 +151,7 @@ class SourceMap { ...@@ -150,6 +151,7 @@ class SourceMap {
return $tempMap; return $tempMap;
} }
// http://doc.spip.org/@__endCharNoSlash
function __endCharNoSlash(&$source, $position, &$find, &$len) { function __endCharNoSlash(&$source, $position, &$find, &$len) {
$temp = strlen($find); $temp = strlen($find);
do { do {
...@@ -159,6 +161,7 @@ class SourceMap { ...@@ -159,6 +161,7 @@ class SourceMap {
return $position + $temp; return $position + $temp;
} }
// http://doc.spip.org/@__charNoSlash
function __charNoSlash(&$source, &$position) { function __charNoSlash(&$source, &$position) {
$next = 1; $len = $position - $next; $next = 1; $len = $position - $next;
while($len > 0 && $source{$len} === '\\') $len = $position - (++$next); while($len > 0 && $source{$len} === '\\') $len = $position - (++$next);
...@@ -193,11 +196,13 @@ class BaseConvert { ...@@ -193,11 +196,13 @@ class BaseConvert {
var $base, $baseLength; var $base, $baseLength;
// http://doc.spip.org/@BaseConvert
function BaseConvert($base) { function BaseConvert($base) {
$this->base = &$base; $this->base = &$base;
$this->baseLength = strlen($base); $this->baseLength = strlen($base);
} }
// http://doc.spip.org/@toBase
function toBase($num) { function toBase($num) {
$module = 0; $result = ''; $module = 0; $result = '';
while($num) { while($num) {
...@@ -207,6 +212,7 @@ class BaseConvert { ...@@ -207,6 +212,7 @@ class BaseConvert {
return $result !== '' ? $result : $this->base{0}; return $result !== '' ? $result : $this->base{0};
} }
// http://doc.spip.org/@fromBase
function fromBase($str) { function fromBase($str) {
$pos = 0; $len = strlen($str) - 1; $result = 0; $pos = 0; $len = strlen($str) - 1; $result = 0;
while($pos < $len) while($pos < $len)
...@@ -306,6 +312,7 @@ class JavaScriptCompressor { ...@@ -306,6 +312,7 @@ class JavaScriptCompressor {
* public constructor * public constructor
* creates a new BaseConvert class variable (base 36) * creates a new BaseConvert class variable (base 36)
*/ */
// http://doc.spip.org/@JavaScriptCompressor
function JavaScriptCompressor() { function JavaScriptCompressor() {
$this->__SourceMap = new SourceMap(); $this->__SourceMap = new SourceMap();
$this->__BC = new BaseConvert('0123456789abcdefghijklmnopqrstuvwxyz'); $this->__BC = new BaseConvert('0123456789abcdefghijklmnopqrstuvwxyz');
...@@ -324,6 +331,7 @@ class JavaScriptCompressor { ...@@ -324,6 +331,7 @@ class JavaScriptCompressor {
* compress JavaScript removing comments and somespaces (on by default) * compress JavaScript removing comments and somespaces (on by default)
* @param mixed view example and notes on class comments * @param mixed view example and notes on class comments
*/ */
// http://doc.spip.org/@getClean
function getClean($jsSource) { function getClean($jsSource) {
return $this->__commonInitMethods($jsSource, false); return $this->__commonInitMethods($jsSource, false);
} }
...@@ -334,20 +342,24 @@ class JavaScriptCompressor { ...@@ -334,20 +342,24 @@ class JavaScriptCompressor {
* compress JavaScript replaceing words and removing comments and some spaces * compress JavaScript replaceing words and removing comments and some spaces
* @param mixed view example and notes on class comments * @param mixed view example and notes on class comments
*/ */
// http://doc.spip.org/@getPacked
function getPacked($jsSource) { function getPacked($jsSource) {
return $this->__commonInitMethods($jsSource, true); return $this->__commonInitMethods($jsSource, true);
} }
/** 'private' methods, any comment sorry */ /** 'private' methods, any comment sorry */
// http://doc.spip.org/@__addCleanCode
function __addCleanCode($str) { function __addCleanCode($str) {
return preg_replace($this->__cleanFinder, $this->__cleanReplacer, trim($str)); return preg_replace($this->__cleanFinder, $this->__cleanReplacer, trim($str));
} }
// http://doc.spip.org/@__addClean
function __addClean(&$arr, &$str, &$start, &$end, $clean) { function __addClean(&$arr, &$str, &$start, &$end, $clean) {
if($clean) if($clean)
array_push($arr, $this->__addCleanCode(substr($str, $start, $end - $start))); array_push($arr, $this->__addCleanCode(substr($str, $start, $end - $start)));
else else
array_push($arr, substr($str, $start, $end - $start)); array_push($arr, substr($str, $start, $end - $start));
} }
// http://doc.spip.org/@__clean
function __clean(&$str) { function __clean(&$str) {
$len = strlen($str); $len = strlen($str);
$type = ''; $type = '';
...@@ -368,6 +380,7 @@ class JavaScriptCompressor { ...@@ -368,6 +380,7 @@ class JavaScriptCompressor {
} }
return preg_replace("/(\n)+/", "\n", trim(implode('', $clean))); return preg_replace("/(\n)+/", "\n", trim(implode('', $clean)));
} }
// http://doc.spip.org/@__commonInitMethods
function __commonInitMethods(&$jsSource, $packed) { function __commonInitMethods(&$jsSource, $packed) {
$header = ''; $header = '';
$this->__startTime = $this->__getTime(); $this->__startTime = $this->__getTime();
...@@ -387,6 +400,7 @@ class JavaScriptCompressor { ...@@ -387,6 +400,7 @@ class JavaScriptCompressor {
$this->__setStats(); $this->__setStats();
return $header.$this->__sources; return $header.$this->__sources;
} }
// http://doc.spip.org/@__getHeader
function __getHeader() { function __getHeader() {
return implode('', array( return implode('', array(
'/* ',$this->__getScriptNames(),'JavaScriptCompressor ',$this->version,' [www.devpro.it], ', '/* ',$this->__getScriptNames(),'JavaScriptCompressor ',$this->version,' [www.devpro.it], ',
...@@ -394,6 +408,7 @@ class JavaScriptCompressor { ...@@ -394,6 +408,7 @@ class JavaScriptCompressor {
" */\r\n" " */\r\n"
)); ));
} }
// http://doc.spip.org/@__getScriptNames
function __getScriptNames() { function __getScriptNames() {
$a = 0; $a = 0;
$result = array(); $result = array();
...@@ -406,6 +421,7 @@ class JavaScriptCompressor { ...@@ -406,6 +421,7 @@ class JavaScriptCompressor {
$result[$a] .= ' with '; $result[$a] .= ' with ';
return $a < 0 ? '' : implode(', ', $result); return $a < 0 ? '' : implode(', ', $result);
} }
// http://doc.spip.org/@__getSize
function __getSize($size, $dec = 2) { function __getSize($size, $dec = 2) {
$toEval = ''; $toEval = '';
$type = array('bytes', 'Kb', 'Mb', 'Gb'); $type = array('bytes', 'Kb', 'Mb', 'Gb');
...@@ -424,6 +440,7 @@ class JavaScriptCompressor { ...@@ -424,6 +440,7 @@ class JavaScriptCompressor {
} }
return $fSize; return $fSize;
} }
// http://doc.spip.org/@__getTime
function __getTime($startTime = null) { function __getTime($startTime = null) {
list($usec, $sec) = explode(' ', microtime()); list($usec, $sec) = explode(' ', microtime());
$newtime = (float)$usec + (float)$sec; $newtime = (float)$usec + (float)$sec;
...@@ -431,12 +448,14 @@ class JavaScriptCompressor { ...@@ -431,12 +448,14 @@ class JavaScriptCompressor {
$newtime = number_format(($newtime - $startTime), 3); $newtime = number_format(($newtime - $startTime), 3);
return $newtime; return $newtime;
} }
// http://doc.spip.org/@__pack
function __pack(&$str) { function __pack(&$str) {
$container = array(); $container = array();
$str = preg_replace("/(\w+)/e", '$this->__BC->toBase($this->__wordsParser("\\1",$container));', $this->__clean($str)); $str = preg_replace("/(\w+)/e", '$this->__BC->toBase($this->__wordsParser("\\1",$container));', $this->__clean($str));
$str = str_replace("\n", '\n', addslashes($str)); $str = str_replace("\n", '\n', addslashes($str));
return 'eval(function(A,G){return A.replace(/(\\w+)/g,function(a,b){return G[parseInt(b,36)]})}("'.$str.'","'.implode(',', $container).'".split(",")));'; return 'eval(function(A,G){return A.replace(/(\\w+)/g,function(a,b){return G[parseInt(b,36)]})}("'.$str.'","'.implode(',', $container).'".split(",")));';
} }
// http://doc.spip.org/@__setStats
function __setStats() { function __setStats() {
$this->stats = implode(' ', array( $this->stats = implode(' ', array(
$this->__getSize($this->__sourceLength), $this->__getSize($this->__sourceLength),
...@@ -447,6 +466,7 @@ class JavaScriptCompressor { ...@@ -447,6 +466,7 @@ class JavaScriptCompressor {
'seconds' 'seconds'
)); ));
} }
// http://doc.spip.org/@__sourceManager
function __sourceManager(&$jsSource) { function __sourceManager(&$jsSource) {
$b = count($jsSource); $b = count($jsSource);
$this->__sources = array(); $this->__sources = array();
...@@ -466,10 +486,12 @@ class JavaScriptCompressor { ...@@ -466,10 +486,12 @@ class JavaScriptCompressor {
} }
$this->__totalSources = count($this->__sources); $this->__totalSources = count($this->__sources);
} }
// http://doc.spip.org/@__sourcePusher
function __sourcePusher(&$code, $name) { function __sourcePusher(&$code, $name) {
$this->__sourceLength += strlen($code); $this->__sourceLength += strlen($code);
array_push($this->__sources, array('code'=>$code, 'name'=>$name)); array_push($this->__sources, array('code'=>$code, 'name'=>$name));
} }
// http://doc.spip.org/@__wordsParser
function __wordsParser($str, &$d) { function __wordsParser($str, &$d) {
if(is_null($key = array_shift($key = array_keys($d,$str)))) if(is_null($key = array_shift($key = array_keys($d,$str))))
$key = array_push($d, $str) - 1; $key = array_push($d, $str) - 1;
......
...@@ -1886,6 +1886,7 @@ function compacte_js($flux) { ...@@ -1886,6 +1886,7 @@ function compacte_js($flux) {
// dans _DIR_VAR/cache_$format/ // dans _DIR_VAR/cache_$format/
// Si c'est un flux on le renvoit compacte // Si c'est un flux on le renvoit compacte
// Si on ne sait pas compacter, on renvoie ce qu'on a recu // Si on ne sait pas compacter, on renvoie ce qu'on a recu
// http://doc.spip.org/@compacte
function compacte($source, $format = null) { function compacte($source, $format = null) {
if (!$format AND preg_match(',\.(js|css)$,', $source, $r)) if (!$format AND preg_match(',\.(js|css)$,', $source, $r))
$format = $r[1]; $format = $r[1];
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter