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