[geeklog-devel] New function for lib-common

Tony Bibbs tony at tonybibbs.com
Thu May 15 14:34:53 EDT 2003


Is a DB table really needed?  I think a section in a config file would be 
best suited for this.  I'm just saying this from the ever growing DB bloat 
we have.  I"m fine either way but if you can figure out an easy way to 
support this via a config file that would be great.

--Tony

 On Tue, 13 May 2003, 
Blaine Lang wrote:

> I've used emoticons in a few of my projects and I'm working on a new plugin that also supports them. I've reworked the function that I'm now pretty happy with. We also have had requests to add support for emoticons and smilies in the core GL story and comment engine. Not really a key requirement for business use but the basic ones are handy.
> 
> Anyway, my new function uses a table for the mappings of emoticons to images and will be easy to extend - just need to now create a admin module. You can have multiple emoticons map to the same image as in :) and :-) to the smile image.
> 
> Any concerns in adding this function to CVS?
> - need to update lib-databases
> - add a new config parm $_CONF['SMILE_PATH']
> - update the 1.3.8 updgrade SQL script
> 
> Blaine
> 
> The function is shown below
> ---------------
> /**
> * Replace emoticons in string with formated HTML of smilies.
> * Emoticon mapping to images are defined in a the table.
> * This function will replace all the emoticons in the past string. 
> * @param   string  $text  The text
> * @return    string  The text, possibly with emoticons replaced with the HTML img tags for the smilie image.
> */
> function COM_replaceEmoticons( $text ) {
>     global $_CONF, $_TABLES;
> 
>     $arr_smilies = array();
>     $sql = DB_query("SELECT code,smile_url from {$_TABLES['smilies']}");
>     while ( list($key,$icon) = DB_fetchARRAY($sql)) {
>         $arr_smilies[$key] = $icon;
>     }
> 
>     foreach ($arr_smilies as $key => $icon) {
>         $text = str_replace($key,'<img src='.$_CONF['SMILE_PATH']. $icon . ' BORDER="0">',$text);
>     }
>    
>     return $text;
> 
> }
> 
> 
> 

-- 
Tony Bibbs          "I guess you have to remember that those who don't
tony at tonybibbs.com  hunt or fish often see those of us who do as      
                    harmlessly strange and sort of amusing. When you  
                    think about it, that might be a fair assessment." 
                    --Unknown





More information about the geeklog-devel mailing list