aa6b4293f41af47991df9f4aa33603088d907574
4 * transforme un raccourci de ressource en un lien minimaliste
9 define('_EXTRAIRE_RESSOURCES', ',' . '<"?(https?://|[^\s][\w -]+\.[\w -]+)[^<]*>' . ',UimsS');
12 /* pipeline pour typo */
13 function tw_post_typo($t) {
14 if (strpos($t, '<') !== false) {
15 $t = preg_replace_callback(_EXTRAIRE_RESSOURCES
, 'tw_traiter_ressources', $t);
21 /* pipeline pour propre */
22 function tw_pre_liens($t) {
23 if (strpos($t, '<') !== false) {
24 $t = preg_replace_callback(_EXTRAIRE_RESSOURCES
, 'tw_traiter_ressources', $t);
26 // echapper les autoliens eventuellement inseres (en une seule fois)
27 if (strpos($t, "<html>") !== false) {
28 $t = echappe_html($t);
35 function tw_traiter_ressources($r) {
38 include_spip('inc/lien');
39 $url = explode(' ', trim($r[0], '<>'));
41 # <http://url/absolue>
42 if (preg_match(',^https?://,i', $url)) {
43 $html = PtoBR(propre("<span class='ressource spip_out'><[->" . $url . "]></span>"));
46 if (false !== strpos($url, '/')) {
47 $html = PtoBR(propre("<span class='ressource spip_in'><[->" . $url . "]></span>"));
52 preg_match(',\.([^.]+)$,', $url, $regs)
53 and file_exists($f = _DIR_IMG
. $regs[1] . '/' . $url)
55 $html = PtoBR(propre("<span class='ressource spip_in'><[" . $url . "->" . $f . "]></span>"));
57 $html = PtoBR(propre("<span class='ressource'><" . $url . "></span>"));
62 return '<html>' . $html . '</html>';