X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fplugins-dist%2Ftextwheel%2Finc%2Fressource.php;h=aa6b4293f41af47991df9f4aa33603088d907574;hb=4f443dce95ff6f8221c189880a70c74ce1c1f238;hp=d56dc5fbb00e35911cbda2b9de54a4dc01c15796;hpb=4a628e9b277d3617535f99d663ca79fa2e891177;p=lhc%2Fweb%2Fwww.git diff --git a/www/plugins-dist/textwheel/inc/ressource.php b/www/plugins-dist/textwheel/inc/ressource.php index d56dc5fb..aa6b4293 100644 --- a/www/plugins-dist/textwheel/inc/ressource.php +++ b/www/plugins-dist/textwheel/inc/ressource.php @@ -6,37 +6,58 @@ * */ -define('_EXTRAIRE_RESSOURCES', ',' . '<"?(https?://|[^\s][\w -]+\.[\w -]+)[^<]*>'.',UimsS'); +define('_EXTRAIRE_RESSOURCES', ',' . '<"?(https?://|[^\s][\w -]+\.[\w -]+)[^<]*>' . ',UimsS'); -function traiter_ressources($r) { - $html = null; - if ($ressource = charger_fonction('ressource', 'inc', true)) { - $html = $ressource($r[0]); +/* pipeline pour typo */ +function tw_post_typo($t) { + if (strpos($t, '<') !== false) { + $t = preg_replace_callback(_EXTRAIRE_RESSOURCES, 'tw_traiter_ressources', $t); + } + + return $t; +} + +/* pipeline pour propre */ +function tw_pre_liens($t) { + if (strpos($t, '<') !== false) { + $t = preg_replace_callback(_EXTRAIRE_RESSOURCES, 'tw_traiter_ressources', $t); + + // echapper les autoliens eventuellement inseres (en une seule fois) + if (strpos($t, "") !== false) { + $t = echappe_html($t); + } } - if (is_null($html)) { - include_spip('inc/lien'); - $url = explode(' ', trim($r[0], '<>')); - $url = $url[0]; - # - if (preg_match(',^https?://,i', $url)) - $html = PtoBR(propre("<[->".$url."]>")); - # - else if (false !== strpos($url, '/')) - $html = PtoBR(propre("<[->".$url."]>")); - # + return $t; +} + +function tw_traiter_ressources($r) { + $html = null; + + include_spip('inc/lien'); + $url = explode(' ', trim($r[0], '<>')); + $url = $url[0]; + # + if (preg_match(',^https?://,i', $url)) { + $html = PtoBR(propre("<[->" . $url . "]>")); + } # + else { + if (false !== strpos($url, '/')) { + $html = PtoBR(propre("<[->" . $url . "]>")); + } # else { - preg_match(',\.([^.]+)$,', $url, $regs); - if (file_exists($f = _DIR_IMG.$regs[1].'/'.$url)) { - $html = PtoBR(propre("<[".$url."->".$f."]>")); + + if ( + preg_match(',\.([^.]+)$,', $url, $regs) + and file_exists($f = _DIR_IMG . $regs[1] . '/' . $url) + ) { + $html = PtoBR(propre("<[" . $url . "->" . $f . "]>")); } else { - $html = PtoBR(propre("<".$url.">")); + $html = PtoBR(propre("<" . $url . ">")); } } } - return ''.$html.''; + return '' . $html . ''; } - -?>