You are here

function smileys_filter_process in Smileys 5

Same name and namespace in other branches
  1. 6 smileys.module \smileys_filter_process()
1 call to smileys_filter_process()
smileys_filter in ./smileys.module
Implementation of hook_filter().

File

./smileys.module, line 182

Code

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