Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SPIPTextWheelRuleSet utilise find_in_path pour trouver les fichier de…

… règles, ce qui permet la surcharge classique dans SPIP. Pas de wheels/ dans le chemin des noms de règle, c'est implicite
  • Loading branch information...
commit e2d708b55a4da5163edc5ccba2a6feeead3d9d7d 1 parent d903d98
Cédric MORIN authored
Showing with 26 additions and 10 deletions.
  1. +23 −7 tw_texte.php
  2. +3 −3 wheels/spip/spip.yaml
30 tw_texte.php
View
@@ -10,14 +10,30 @@
# usage: php wheels/spip.php
require_once _DIR_PLUGIN_TW.'engine/textwheel.php';
-$GLOBALS['spip_wheels']['raccourcis'] = array('wheels/spip/spip.yaml','wheels/spip/spip-paragrapher.yaml');
+$GLOBALS['spip_wheels']['raccourcis'] = array('spip/spip.yaml','spip/spip-paragrapher.yaml');
if (test_espace_prive ())
- $GLOBALS['spip_wheels']['raccourcis'][] = 'wheels/spip/ecrire.yaml';
+ $GLOBALS['spip_wheels']['raccourcis'][] = 'spip/ecrire.yaml';
-$GLOBALS['spip_wheels']['interdire_scripts'] = array('wheels/spip/interdire-scripts.yaml');
-$GLOBALS['spip_wheels']['echappe_js'] = array('wheels/spip/echappe-js.yaml');
+$GLOBALS['spip_wheels']['interdire_scripts'] = array('spip/interdire-scripts.yaml');
+$GLOBALS['spip_wheels']['echappe_js'] = array('spip/echappe-js.yaml');
+class SPIPTextWheelRuleset extends TextWheelRuleSet {
+ protected function findFile(&$file, $path=''){
+ static $default_path;
+
+ // absolute file path ?
+ if (file_exists($file))
+ return $file;
+
+ // file embed with texwheels, relative to calling ruleset
+ if ($path AND file_exists($f = $path.$file))
+ return $f;
+
+ return find_in_path($file,'wheels/');
+ }
+}
+
function traiter_raccourcis_ruleset() {
# memoization
# grml: memoization/xcache ne sait pas stocker des objets
@@ -27,7 +43,7 @@ function traiter_raccourcis_ruleset() {
AND $ruleset = cache_get($key))
return $ruleset;
- $ruleset = new TextWheelRuleSet($GLOBALS['spip_wheels']['raccourcis']);
+ $ruleset = new SPIPTextWheelRuleset($GLOBALS['spip_wheels']['raccourcis']);
if (isset($GLOBALS['debut_intertitre']) AND $rule=$ruleset->getRule('intertitres')){
$rule->replace[0] = preg_replace(',<[^>]*>,Uims',$GLOBALS['debut_intertitre'],$rule->replace[0]);
$rule->replace[1] = preg_replace(',<[^>]*>,Uims',$GLOBALS['fin_intertitre'],$rule->replace[1]);
@@ -112,7 +128,7 @@ function tw_echappe_js($t) {
static $wheel = null;
if (!isset($wheel))
$wheel = new $GLOBALS['textWheel'](
- new TextWheelRuleSet($GLOBALS['spip_wheels']['echappe_js'])
+ new SPIPTextWheelRuleset($GLOBALS['spip_wheels']['echappe_js'])
);
return $wheel->text($t);
@@ -143,7 +159,7 @@ function tw_interdire_scripts($arg) {
if (isset($dejavu[$GLOBALS['filtrer_javascript']][$arg])) return $dejavu[$GLOBALS['filtrer_javascript']][$arg];
if (!isset($wheel)){
- $ruleset = new TextWheelRuleSet($GLOBALS['spip_wheels']['interdire_scripts']);
+ $ruleset = new SPIPTextWheelRuleset($GLOBALS['spip_wheels']['interdire_scripts']);
// Pour le js, trois modes : parano (-1), prive (0), ok (1)
// desactiver la regle echappe-js si besoin
if ($GLOBALS['filtrer_javascript']==1
6 wheels/spip/spip.yaml
View
@@ -41,7 +41,7 @@ lignes-vides:
tableaux:
type: all
# included subwheel with relative filepath
- replace: wheels/spip/spip-tableaux.yaml
+ replace: spip/spip-tableaux.yaml
is_wheel: Y
if_str: "\n|"
priority: -30 # avant les raccourcis
@@ -50,7 +50,7 @@ listes:
if_str: "\n-"
is_wheel: Y
type: all
- replace: wheels/spip/spip-listes.yaml
+ replace: spip/spip-listes.yaml
priority: -20 # avant !paragraphes
echappe-tags:
@@ -157,7 +157,7 @@ poesie:
# poesie|poetry
# utilise une callback
match: ",<poe(sie|try)>(.*)</poe\1>,UimsS"
- replace: wheels/spip/spip-poesie.yaml
+ replace: spip/spip-poesie.yaml
pick_match: 2
is_wheel: Y
if_str: '<poe'
Please sign in to comment.
Something went wrong with that request. Please try again.