I was trying to add a class="smileys" to the code like this:

function smileys_filter_process($text) {
  $text = ' '. $text .' ';

  $list = _smileys_list();
  foreach ($list as $smiley) {
    $acronyms = explode(" ", $smiley->acronyms);
    $alt = str_replace('\\', '\\\\', drupal_specialchars($smiley->description));
    foreach ($acronyms as $a) {
      if ($smiley->standalone)
        $text = eregi_replace("([ ,\.\?!:\(\)\r\n\<\>])". preg_quote($a) ."([ ,\.\?!:\(\)\r\n\<\>])", "\\1<img src=\"". ($smiley->image) ."\" title=\"". $alt ."\" alt=\"". $alt ."\"  class="smileys" />\\2", $text);
      else
        $text = eregi_replace(preg_quote($a), '<img src="/'. ($smiley->image) .'" title="'. $alt .'" alt="'. $alt .'"  class="smileys" />', $text);
    }
  }
  $text = substr($text, 1, -1);

  return $text;
}

but i get this error message:

Parse error: parse error in /Library/WebServer/Documents/creativebits/modules/smileys/smileys.module on line 90

What am I doing wrong? It must be syntax error...:? Tx!

Comments

davidblewett’s picture

You have to escape the " character. Otherwise, the PHP parser thinks it's the end of the string. Use \" instead of just " when you're inserting a quotation mark into a string.

http://www.dawninglight.net

iraszl’s picture

Thanks so much!
---
http://creativebits.org

iraszl’s picture

Not so big of an improvement, but here it goes anyway. Smiley.module with CSS support:

download here

and here is the CSS you need to insert into you style.css:
.smileys { margin-bottom: -.2em; }

for example what this CSS does is moves the smileys below the line of text, so that the smileys fit into the text block nicer.

---
http://creativebits.org