[PLUGINS] +crayons et enluminures
[ptitvelo/web/www.git] / www / plugins / crayons / crayons.js_fonctions.php
1 <?php
2
3 if (!defined("_ECRIRE_INC_VERSION")) return;
4
5 //
6 // Les crayons ont leur propre copie du pack de Dean Edwards
7 // pour compatibilite avec SPIP < [9717]
8 //
9
10 function pack_cQuery($chemin) {
11 $flux = spip_file_get_contents($chemin);
12 $flux = str_replace('jQuery', 'cQuery', $flux);
13 $flux = str_replace('cQuery.spip', 'jQuery.spip', $flux);
14
15 // On ne compacte PAS deux fois (c'est inutile et en plus ca bugge)
16 if (!strlen($flux)
17 // mode debug des crayons
18 OR _request('debug_crayons')
19 // le vieil auto_compress_js
20 OR ($GLOBALS['meta']['auto_compress_js'] == 'oui'
21 AND @file_exists(_DIR_RESTREINT.'inc/compacte_js.php'))
22 // ou l'espace prive
23 OR !function_exists('test_espace_prive')
24 OR test_espace_prive())
25 return $flux;
26
27 include_spip('lib/JavaScriptPacker/class.JavaScriptPacker');
28 $packer = new JavaScriptPacker($flux, 0, true, false);
29
30 // en cas d'echec (?) renvoyer l'original
31 if (strlen($t = $packer->pack()))
32 return $t;
33
34 // erreur
35 spip_log('erreur de pack_js');
36 return $flux;
37 }
38
39 ?>