[SPIP] +2.1.12
[velocampus/web/www.git] / www / plugins / auto / couteau_suisse / couteau_suisse / outils / spip_cache_action_rapide.php
1 <?php
2
3 // module inclu dans la description de l'outil en page de configuration
4 // ici, un bouton : "vider le cache"
5
6 include_spip('inc/invalideur');
7 include_spip('inc/actions');
8
9 // Compatibilite SPIP < 2.0
10 if(!defined('_SPIP19300')) {
11 function taille_du_cache() {
12 $cpt = spip_fetch_array(spip_query("SELECT SUM(taille) AS n FROM spip_caches WHERE type='t'"));
13 return $cpt['n'];
14 }
15 /* function redirige_action_post($action, $arg, $ret, $gra, $corps, $att='') {
16 $r = _DIR_RESTREINT_ABS . generer_url_ecrire($ret, $gra, true, true);
17 return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
18 }*/
19 }
20
21 function spip_cache_action_rapide() {
22 include_spip('inc/texte'); // pour attribut_html()
23 if ($n = taille_du_cache())
24 $info = _T('taille_cache_octets', array('octets' => taille_en_octets($n)));
25 else
26 $info = _T('taille_cache_vide');
27 // <legend> : pour la description de l'outil inactif
28 // syntaxe : ajax_action_auteur($action, $id, $script, $args='', $corps=false, $args_ajax='', $fct_ajax='')
29 // on envoie une action 'action_rapide' car 'purger' n'existe pas (encore?) en exec/
30 return ajax_action_auteur('action_rapide', 'cache', 'admin_couteau_suisse', "arg=spip_cache|description_outil&cmd=descrip#cs_action_rapide",
31 "\n<fieldset class='cs_hidden'><legend>"._T('bouton_vider_cache')."</legend></fieldset><div style='text-align: center; padding:0.4em;'>$info<br /><input class='fondo' type='submit' value=\""
32 . attribut_html(_T('bouton_vider_cache')) . '" /></div>')
33 // bouton d'acualisation
34 . ajax_action_auteur('action_rapide', 'actualise', 'admin_couteau_suisse', "arg=spip_cache|description_outil&cmd=descrip#cs_action_rapide",
35 "\n<div class='cs_sobre'><input class='cs_sobre' type='submit' value=\" ["
36 . attribut_html(_T('couteauprive:rss_actualiser')).']" /></div>');
37
38 /* // appel direct vers SPIP, sans ajax :
39 return redirige_action_post('purger', 'cache', 'admin_couteau_suisse', "cmd=descrip&outil=spip_cache#cs_infos",
40 "\n<div style='text-align: center; padding:0.4em;'><input class='fondo' type='submit' value=\"" .
41 attribut_html(_T('bouton_vider_cache')) . "\" />&nbsp;($info)</div>"); */
42 }
43
44 // fonction {$outil}_{$arg}_action() appelee par action/action_rapide.php
45 function spip_cache_cache_action() {
46 // purger le cache de SPIP...
47 // $arg doit obligatoirement etre 'cache' sinon SPIP se fache !
48 $purger = charger_fonction('purger', 'action');
49 $purger();
50 }
51 // fonction {$outil}_{$arg}_action() appelee par action/action_rapide.php
52 function spip_cache_actualise_action() {
53 // actualiser le calcul du cache de SPIP...
54 // rien a faire :-)
55 }
56
57 ?>