From 896f539afcc65bd41b820b5bb1cf22bfea49b923 Mon Sep 17 00:00:00 2001 From: Christian Lefebvre <christian_lefebvre@laposte.net> Date: Wed, 17 Jan 2007 22:42:50 +0000 Subject: [PATCH] autodoc --- ecrire/inc/compacte_js.php | 22 ++++++++++++++++++++++ ecrire/inc/filtres.php | 1 + 2 files changed, 23 insertions(+) diff --git a/ecrire/inc/compacte_js.php b/ecrire/inc/compacte_js.php index 849e1125d8..9633cf2fb8 100644 --- a/ecrire/inc/compacte_js.php +++ b/ecrire/inc/compacte_js.php @@ -56,6 +56,7 @@ class SourceMap { * @param string generic source code * @param array array with nested array with code rules */ +// http://doc.spip.org/@getMap function getMap(&$source, &$delimeters) { # "unsigned" integer variables @@ -150,6 +151,7 @@ class SourceMap { return $tempMap; } +// http://doc.spip.org/@__endCharNoSlash function __endCharNoSlash(&$source, $position, &$find, &$len) { $temp = strlen($find); do { @@ -159,6 +161,7 @@ class SourceMap { return $position + $temp; } +// http://doc.spip.org/@__charNoSlash function __charNoSlash(&$source, &$position) { $next = 1; $len = $position - $next; while($len > 0 && $source{$len} === '\\') $len = $position - (++$next); @@ -193,11 +196,13 @@ class BaseConvert { var $base, $baseLength; +// http://doc.spip.org/@BaseConvert function BaseConvert($base) { $this->base = &$base; $this->baseLength = strlen($base); } +// http://doc.spip.org/@toBase function toBase($num) { $module = 0; $result = ''; while($num) { @@ -207,6 +212,7 @@ class BaseConvert { return $result !== '' ? $result : $this->base{0}; } +// http://doc.spip.org/@fromBase function fromBase($str) { $pos = 0; $len = strlen($str) - 1; $result = 0; while($pos < $len) @@ -306,6 +312,7 @@ class JavaScriptCompressor { * public constructor * creates a new BaseConvert class variable (base 36) */ +// http://doc.spip.org/@JavaScriptCompressor function JavaScriptCompressor() { $this->__SourceMap = new SourceMap(); $this->__BC = new BaseConvert('0123456789abcdefghijklmnopqrstuvwxyz'); @@ -324,6 +331,7 @@ class JavaScriptCompressor { * compress JavaScript removing comments and somespaces (on by default) * @param mixed view example and notes on class comments */ +// http://doc.spip.org/@getClean function getClean($jsSource) { return $this->__commonInitMethods($jsSource, false); } @@ -334,20 +342,24 @@ class JavaScriptCompressor { * compress JavaScript replaceing words and removing comments and some spaces * @param mixed view example and notes on class comments */ +// http://doc.spip.org/@getPacked function getPacked($jsSource) { return $this->__commonInitMethods($jsSource, true); } /** 'private' methods, any comment sorry */ +// http://doc.spip.org/@__addCleanCode function __addCleanCode($str) { return preg_replace($this->__cleanFinder, $this->__cleanReplacer, trim($str)); } +// http://doc.spip.org/@__addClean function __addClean(&$arr, &$str, &$start, &$end, $clean) { if($clean) array_push($arr, $this->__addCleanCode(substr($str, $start, $end - $start))); else array_push($arr, substr($str, $start, $end - $start)); } +// http://doc.spip.org/@__clean function __clean(&$str) { $len = strlen($str); $type = ''; @@ -368,6 +380,7 @@ class JavaScriptCompressor { } return preg_replace("/(\n)+/", "\n", trim(implode('', $clean))); } +// http://doc.spip.org/@__commonInitMethods function __commonInitMethods(&$jsSource, $packed) { $header = ''; $this->__startTime = $this->__getTime(); @@ -387,6 +400,7 @@ class JavaScriptCompressor { $this->__setStats(); return $header.$this->__sources; } +// http://doc.spip.org/@__getHeader function __getHeader() { return implode('', array( '/* ',$this->__getScriptNames(),'JavaScriptCompressor ',$this->version,' [www.devpro.it], ', @@ -394,6 +408,7 @@ class JavaScriptCompressor { " */\r\n" )); } +// http://doc.spip.org/@__getScriptNames function __getScriptNames() { $a = 0; $result = array(); @@ -406,6 +421,7 @@ class JavaScriptCompressor { $result[$a] .= ' with '; return $a < 0 ? '' : implode(', ', $result); } +// http://doc.spip.org/@__getSize function __getSize($size, $dec = 2) { $toEval = ''; $type = array('bytes', 'Kb', 'Mb', 'Gb'); @@ -424,6 +440,7 @@ class JavaScriptCompressor { } return $fSize; } +// http://doc.spip.org/@__getTime function __getTime($startTime = null) { list($usec, $sec) = explode(' ', microtime()); $newtime = (float)$usec + (float)$sec; @@ -431,12 +448,14 @@ class JavaScriptCompressor { $newtime = number_format(($newtime - $startTime), 3); return $newtime; } +// http://doc.spip.org/@__pack function __pack(&$str) { $container = array(); $str = preg_replace("/(\w+)/e", '$this->__BC->toBase($this->__wordsParser("\\1",$container));', $this->__clean($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(",")));'; } +// http://doc.spip.org/@__setStats function __setStats() { $this->stats = implode(' ', array( $this->__getSize($this->__sourceLength), @@ -447,6 +466,7 @@ class JavaScriptCompressor { 'seconds' )); } +// http://doc.spip.org/@__sourceManager function __sourceManager(&$jsSource) { $b = count($jsSource); $this->__sources = array(); @@ -466,10 +486,12 @@ class JavaScriptCompressor { } $this->__totalSources = count($this->__sources); } +// http://doc.spip.org/@__sourcePusher function __sourcePusher(&$code, $name) { $this->__sourceLength += strlen($code); array_push($this->__sources, array('code'=>$code, 'name'=>$name)); } +// http://doc.spip.org/@__wordsParser function __wordsParser($str, &$d) { if(is_null($key = array_shift($key = array_keys($d,$str)))) $key = array_push($d, $str) - 1; diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index 30a74525c8..7e60f0363e 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -1886,6 +1886,7 @@ function compacte_js($flux) { // dans _DIR_VAR/cache_$format/ // Si c'est un flux on le renvoit compacte // Si on ne sait pas compacter, on renvoie ce qu'on a recu +// http://doc.spip.org/@compacte function compacte($source, $format = null) { if (!$format AND preg_match(',\.(js|css)$,', $source, $r)) $format = $r[1]; -- GitLab