Overview
Comment:+ Réécriture et correction du remplacement des URLs + Ajout de référence arrière dans les regexp de la syntaxe SPIP
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5fa9dd46390f988fcee0135a6420ec0a02f21686
User & Date: bohwaz on 2012-03-22 21:41:08
Other Links: manifest | tags
References
2020-12-08
23:25 Wiki page "Changelog/0.9" artifact: b9c916b4d1 user: bohwaz
Context
2012-04-03
01:05
fix [c94f57b5f8] + précisions et suppression de la colonne ville dans la liste des membres check-in: 3817c1fa22 user: bohwaz tags: trunk
2012-03-22
21:41
+ Réécriture et correction du remplacement des URLs + Ajout de référence arrière dans les regexp de la syntaxe SPIP check-in: 5fa9dd4639 user: bohwaz tags: trunk
2012-03-11
23:58
Fixed [877f4fc1e7] (liste des adhérents avec un nom accentué) check-in: 1484069bbe user: bohwaz tags: trunk
Changes

Modified include/lib.utils.php from [602345e4ee] to [f9207dda8d].

304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
        $str = preg_replace('![^[:ascii:]]+!', '', $str);

        return $str;
    }

    static public function htmlLinksOnUrls($str)
    {
        preg_match_all('!(^|[\s>])((ftp|http|https)://([^\s<]+))!u', $str, $match, PREG_SET_ORDER);

        foreach ($match as &$m)
        {
            $text = ($m[3] == 'http') ? $m[4] : $m[2];
            $text = isset($text[51]) ? substr($text, 0, 50) . '...' : $text;
            $str = str_replace($m[0], $m[1].'<a href="'.$m[2].'" onclick="window.open(this.href); return false;">'.$text.'</a>', $str);
        }

        return $str;
    }

    static public function htmlGarbage2xhtml($str)
    {
        if (!self::$g2x)
        {
            require_once GARRADIN_ROOT . '/include/lib.garbage2xhtml.php';
            self::$g2x = new garbage2xhtml;
            self::$g2x->core_attributes = array('class', 'id', 'title');
        }

        return self::$g2x->process($str);
    }

    static public function htmlSpip($str)
    {
        // Intertitres
        $str = preg_replace('!(^|[^\\\\])\{{3}(\V*)\}{3}!', '$1<h3>$2</h3>', $str);

        // Gras
        $str = preg_replace('!(^|[^\\\\])\{{2}(\V*)\}{2}!', '$1<strong>$2</strong>', $str);

        // Italique
        $str = preg_replace('!(^|[^\\\\])\{(\V*)\}!', '$1<em>$2</em>', $str);

        // Espaces typograhiques
        $str = preg_replace('/\h*([?!;:»])(\s+|$)/u', '&nbsp;$1$2', $str);
        $str = preg_replace('/(^|\s+)([«])\h*/u', '$1$2&nbsp;', $str);

        // Liens
        $str = preg_replace('!(^|[^\\\\])\[([^-]+)->([^\]]+)\]!', '$1<a href="$3">$2</a>', $str);
        $str = preg_replace('!(^|[^\\\\])\[([^\]]+)\]!', '$1<a href="$2">$2</a>', $str);

        return $str;
    }

    static public function mail($to, $subject, $content, $additional_headers = array())
    {
        // Création du contenu du message







<
|
|
<
|
|
<
<
|
|

















|


|


|






|
|







304
305
306
307
308
309
310

311
312

313
314


315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
        $str = preg_replace('![^[:ascii:]]+!', '', $str);

        return $str;
    }

    static public function htmlLinksOnUrls($str)
    {

        return preg_replace_callback('!(?<=\s)((?:(ftp|https?|file|ed2k|ircs?)://|(magnet|mailto|data|tel|fax|geo|sips?|xmpp):)([^\s<]+))!',
            function ($match) {

                $proto = $match[2] ?: $match[3];
                $text = ($proto == 'http' || $proto == 'mailto') ? $match[4] : $match[1];


                return '<a class="'.$proto.'" href="'.htmlspecialchars($match[1], ENT_QUOTES, 'UTF-8').'">'.htmlspecialchars($text, ENT_QUOTES, 'UTF-8').'</a>';
            }, $str);
    }

    static public function htmlGarbage2xhtml($str)
    {
        if (!self::$g2x)
        {
            require_once GARRADIN_ROOT . '/include/lib.garbage2xhtml.php';
            self::$g2x = new garbage2xhtml;
            self::$g2x->core_attributes = array('class', 'id', 'title');
        }

        return self::$g2x->process($str);
    }

    static public function htmlSpip($str)
    {
        // Intertitres
        $str = preg_replace('/(?<!\\\\)\{{3}(\V*)\}{3}/', '<h3>$1</h3>', $str);

        // Gras
        $str = preg_replace('/(?<!\\\\)\{{2}(\V*)\}{2}/', '<strong>$1</strong>', $str);

        // Italique
        $str = preg_replace('/(?<!\\\\)\{(\V*)\}/', '<em>$1</em>', $str);

        // Espaces typograhiques
        $str = preg_replace('/\h*([?!;:»])(\s+|$)/u', '&nbsp;$1$2', $str);
        $str = preg_replace('/(^|\s+)([«])\h*/u', '$1$2&nbsp;', $str);

        // Liens
        $str = preg_replace('/(?<!\\\\)\[([^-]+)->([^\]]+)\]/', '<a href="$2">$1</a>', $str);
        $str = preg_replace('/(?<!\\\\)\[([^\]]+)\]/', '<a href="$2">$1</a>', $str);

        return $str;
    }

    static public function mail($to, $subject, $content, $additional_headers = array())
    {
        // Création du contenu du message