Page 1 of 1

Selsames Verhalten der Smiley-Funktion im Guestbook

Posted: Thu Sep 14, 2006 4:57 pm
by Grega
Ich habe beim Guestbook 1.1.2 in der Datei class.Guestbook.php (lib/classes/module/) die Ersetz-Funktion für die Smileys um einige Smileys erweitert. Ist ja nicht sonderlich schwer. Nun gibt es allerdings das ungewollte Phänomen, dass mein img1 anders dargestellt wird, als alle anderen. Zunächst der Code (ab ungefähr Zeile 1047, wo die Funktion InsertSmileys beginnt:

Code: Select all

function InsertSmiley($text, $root_url)
    {
    
        if ($this->SmileysModuleIsInstalled())
        {
            $mi = &$this->getModuleInstance('Smileys');
            return $mi->ReplaceSmileys($text);
        }
        
        $base = $root_url . '/modules/' . $this->GetName() . '/images/smileys/default';

        $img1 = '<img src="' . $base . '/' . 'biggrin.gif"'    . ' alt="breites grinsen" />';
        $img2 = '<img src="' . $base . '/' . 'confused.gif"'    . ' alt="verwirrt" />';
        $img3 = '<img src="' . $base . '/' . 'cool.gif"' . ' alt="cool" />';
        $img4 = '<img src="' . $base . '/' . 'cry.gif"'    . ' alt="weinen" />';
        $img5 = '<img src="' . $base . '/' . 'eek.gif"'     . ' alt="erschrocken" />';
        $img6 = '<img src="' . $base . '/' . 'evil.gif"'  . ' alt="böse" />';
        $img7 = '<img src="' . $base . '/' . 'lol.gif"'      . ' alt="laut lachen" />';
        $img8 = '<img src="' . $base . '/' . 'zunge.gif"'  . ' alt="zunge rausstrecken" />';
        $img9 = '<img src="' . $base . '/' . 'rolleyes.gif"'  . ' alt="augen verdrehen" />';
        $img10 = '<img src="' . $base . '/' . 'sad.gif"'  . ' alt="traurig" />';
        $img11 = '<img src="' . $base . '/' . 'smile.gif"'  . ' alt="lächeln" />';
        $img12 = '<img src="' . $base . '/' . 'wink.gif"'  . ' alt="zwinckern" />';

        $text = str_replace(':D', $img1, $text);
        $text = str_replace(':-D', $img1, $text);
        $text = str_replace(':/', $img2, $text);
        $text = str_replace(':-/', $img2, $text);
        $text = str_replace('8)', $img3, $text);
        $text = str_replace('8-)', $img3, $text);
        $text = str_replace('=(', $img4, $text);
        $text = str_replace('=-(', $img4, $text);
        $text = str_replace(':o', $img5, $text);
        $text = str_replace(':-o', $img5, $text);
        $text = str_replace('X(', $img6, $text);
        $text = str_replace('x(', $img6, $text);
        $text = str_replace('X-(', $img6, $text);
        $text = str_replace('x-(', $img6, $text);
        $text = str_replace(':lol:', $img7, $text);
        $text = str_replace(':P', $img8, $text);
        $text = str_replace(':-P', $img8, $text);
        $text = str_replace(':p', $img8, $text);
        $text = str_replace(':-p', $img8, $text);
        $text = str_replace(':roll:', $img9, $text);
        $text = str_replace(':(', $img10, $text);
        $text = str_replace(':-(', $img10, $text);
        $text = str_replace(':)', $img11, $text);
        $text = str_replace(':-)', $img11, $text);
        $text = str_replace(';)', $img12, $text);
        $text = str_replace(';-)', $img12, $text);

        return $text;
    }
Also nur ganz einfach mehr Smileys eingefügt. So und was passiert bei der Ausgabe im Gästebuch? Hier der HTML-Code für die ersten beiden Smileys:

Code: Select all

<img src="http<img src="http://www.myurl.tld/modules/Guestbook/images/smileys/default/confused.gif" alt="verwirrt" />/www.myurl.tld/modules/Guestbook/images/smileys/default/biggrin.gif" alt="breites grinsen" /><br />
<img src="http<img src="http://www.myurl.tld/modules/Guestbook/images/smileys/default/confused.gif" alt="verwirrt" />/www.myurl.tld/modules/Guestbook/images/smileys/default/biggrin.gif" alt="breites grinsen" /><br />
<img src="http://www.myurl.tld/modules/Guestbook/images/smileys/default/confused.gif" alt="verwirrt" /><br />
<img src="http://www.myurl.tld/modules/Guestbook/images/smileys/default/confused.gif" alt="verwirrt" />
Sehr seltsam. Doppelpunkt-D und Doppelpunkt-Bindestrich-D werden zwar erkannt, aber der Ersatz-String ist falsch. Bei dem ersten Bild (breites grinsen) "stottert" er. Woran kann das bloß liegen? Habe $img1 in $img0 umbenannt, habe auch mal ein $img0 mit Dummy-Text vor $img1 geschrieben - beides ergab das gleiche Fehlverhalten. Jemand eine Idee, warum er stottert und den Pfad doppelt angibt?

G

Re: Selsames Verhalten der Smiley-Funktion im Guestbook

Posted: Fri Sep 15, 2006 5:56 am
by cyberman
Sieht fast so aus, als ob es ein Problem wäre, mehrere Zeichenkombinationen mit dem gleichen Smiley zu ersetzen ...

Nutzt du das Smiley-Modul?

http://dev.cmsmadesimple.org/projects/smileys/