/**
  * Substitutes smilie tags like :) or ;) with corresponding <img> tags.
  * The smilie tags and there image equivalents are loaded from database.
  *
  * @author  Björn Detert <*****@*****.**>
  * @version 20. 9. 2006
  * @param   string $text   The text to be parsed
  * @param   object $parent The calling object (regulary of type tx_mmforum_pi1), so this
  *                         object inherits all configuration and language options from the
  *                         calling object.
  * @param   array  $conf   The calling plugin's configuration vars
  * @return  string         The parsed string
  */
 function generate_smilies($text, $parent, $conf)
 {
     $res = $this->databaseHandle->exec_SELECTquery('code,smile_url', 'tx_mmforum_smilies', 'deleted=0', '', 'LENGTH(code) DESC');
     while ($row = $this->databaseHandle->sql_fetch_assoc($res)) {
         $uploadPath = 'uploads/tx_mmforum/' . $row['smile_url'];
         if (!file_exists($uploadPath)) {
             if (substr($conf['postparser.']['bb_code_path_smilie'], 0, 4) == 'EXT:') {
                 $smiliepath = tx_mmforum_tools::generateSiteRelExtPath($conf['postparser.']['bb_code_path_smilie'] . $row['smile_url']);
             } else {
                 $smiliepath = $conf['postparser.']['bb_code_path_smilie'] . $row['smile_url'];
             }
         } else {
             $smiliepath = $uploadPath;
         }
         $smilieimage = '<img src="' . $smiliepath . '" alt="' . $row['smile_url'] . '" />';
         #$text 			= 	str_replace(' '.$row['code'].' ',$smilieimage,$text);
         $text = str_replace($row['code'], $smilieimage, $text);
     }
     return $text;
 }