wdrożenia PrestaShop Powiększenie zdjęć moduł

wyjątki dla strip_tags

  • 1 Odpowiedzi
  • 2371 Wyświetleń

0 użytkowników i 1 Gość przegląda ten wątek.

*

Offline Sethinet

  • Nowy
  • *
  • 7
  • 0
wyjątki dla strip_tags
« dnia: Wrzesień 21, 2009, 01:49:55 pm »
Witam, ponieważ w krótkich opisach muszę dopuścić kilka znaczników html potrzebuję drobnej modyfikacji.

Dokonałem zmian w pliku: tools\smarty\plugins\modifier.strip_tags.php

do następującej postaci:

function smarty_modifier_strip_tags($string, $replace_with_space = true,
$allowed = "<i><b><br><span>")
{
    if ($replace_with_space)
        return preg_replace('!<[^>]*?>!', ' ', $string);
    else
        return strip_tags($string, $allowed);
}

Jednak nie przynosi to pożądanego efektu,

bardzo proszę o pomoc, dość pilna sprawa.

Pozdrawiam,

*

Offline Sethinet

  • Nowy
  • *
  • 7
  • 0
Odp: wyjątki dla strip_tags
« Odpowiedź #1 dnia: Wrzesień 21, 2009, 04:24:10 pm »
Problem rozwiązany, poniżej wklejam nową zawartość dla pliku modifier.strip_tags.php może komuś się przyda:

function smarty_modifier_strip_tags($string) {
    switch(func_num_args()) {
        case 1:
            $replace_with_space = true;
            break;
        case 2:
            $arg = func_get_arg(1);
            if($arg === 1 || $arg === true || $arg === '1' || $arg === 'true') {
                // for full legacy support || $arg === 'false' should be included
                $replace_with_space = true;
                $allowable_tags = '';
            } elseif($arg === 0 || $arg === false || $arg === '0' || $arg === 'false') {
                // for full legacy support || $arg === 'false' should be removed
                $replace_with_space = false;
                $allowable_tags = '';
            } else {
                $replace_with_space = true;
                $allowable_tags = $arg;
            }
            break;
        case 3:
            $replace_with_space = func_get_arg(1);
            $allowable_tags = func_get_arg(2);
            break;
    }

    if($replace_with_space) {
        $string = preg_replace('!(<[^>]*?>)!', '$1 ', $string);
    }

    $string = strip_tags($string, $allowable_tags);

    if($replace_with_space) {
        $string = preg_replace('!(<[^>]*?>) !', '$1', $string);
    }

    return $string;
}

/* vim: set expandtab: */

?>


przykład wykorzystania:

strip_tags:'<b><i>'