X-Git-Url: http://git.cyclocoop.org/?p=lhc%2Fweb%2Fclavette_www.git;a=blobdiff_plain;f=www%2Fplugins-dist%2Ftextwheel%2Finc%2Ftextwheel.php;h=089d9dcebf542e3bd314f3bbad0aa7f2fc469a2f;hp=23acd7e17e493410f52c1557639c4e1485006be2;hb=cc641eb476987612f6d6df1a5417c1c5582a8ab8;hpb=7d84a490677fb716a1fd4df260f8eab35f6a8506 diff --git a/www/plugins-dist/textwheel/inc/textwheel.php b/www/plugins-dist/textwheel/inc/textwheel.php index 23acd7e..089d9dc 100644 --- a/www/plugins-dist/textwheel/inc/textwheel.php +++ b/www/plugins-dist/textwheel/inc/textwheel.php @@ -3,7 +3,7 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2014 * + * Copyright (c) 2001-2016 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -86,17 +86,15 @@ class SPIPTextWheelRuleset extends TextWheelRuleSet { $key = 'tw-'.md5(_WHEELS_VERSION."-".serialize($ruleset).$callback.$class._DIR_RACINE); # lecture du cache - include_spip('memoization_options'); - if (!function_exists('cache_get')) include_spip('inc/memoization-mini'); if ((!defined('_VAR_MODE') OR _VAR_MODE!='recalcul') - AND $cacheruleset = cache_get($key)) + AND $cacheruleset = tw_cache_get($key)) return $cacheruleset; # calcul de la wheel $ruleset = parent::loader($ruleset, $callback, $class); # ecriture du cache - cache_set($key, $ruleset); + tw_cache_set($key, $ruleset); return $ruleset; } @@ -109,4 +107,36 @@ function tw_trig_purger($quoi){ return $quoi; } -?> + +/** + * Lire une valeur en cache + * memoization minimale + * (utilise le plugin memoization si disponible) + * + * @param string $key + * @return mixed + */ +function tw_cache_get($key) { + if (function_exists('cache_get')){ + return cache_get($key); + } + return @unserialize(file_get_contents(_DIR_CACHE."wheels/".$key.".txt")); +} + +/** + * Ecrire une valeur en cache + * memoization minimale + * (utilise le plugin memoization si disponible) + * + * @param string $key + * @param mixed $value + * @param int|null $ttl + * @return bool + */ +function tw_cache_set($key, $value, $ttl=null) { + if (function_exists('cache_set')){ + return cache_set($key, $value, $ttl); + } + $dir = sous_repertoire(_DIR_CACHE,"wheels/"); + return ecrire_fichier($dir.$key.".txt", serialize($value)); +}