Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [MOD] Smiley support script  (Read 6615 times)

4Sandrix

  • Hero Member
  • *****
  • Karma: -13
  • Posts: 597
    • http://fedrick.deviantart.com
[MOD] Smiley support script
« on: July 12, 2006, 04:36:11 pm »

Maybe this is not a mod but  I did this simple smiley support script and I wanned to mod it for sNews.
Unfortunatly with no results. Could you help me with this?

code:
Code: [Select]
<?php
function bb_smilies ($text)
{
   
$smiliesDir "http://www.yourdomain.com/smilies/"// location from the smilies
   
$smilies = array(':)'    =>    "icon_smile.gif"       ,
                    
':-)'   =>    "icon_smile.gif"       ,

                    
':('    =>    "icon_sad.gif"         ,
                    
':-('   =>    "icon_sad.gif"         ,

                    
':S'    =>    "icon_confused.gif"    ,
                    
':s'    =>    "icon_confused.gif"    ,
                    
':-S'   =>    "icon_confused.gif"    ,
                    
':-s'   =>    "icon_confused.gif"    ,

                    
':D'    =>    "icon_biggrin.gif"     ,
                    
':d'    =>    "icon_biggrin.gif"     ,
                    
':-D'   =>    "icon_biggrin.gif"     ,
                    
':-d'   =>    "icon_biggrin.gif"     ,

                    
':O'    =>    "icon_surprised.gif"   ,
                    
':o'    =>    "icon_surprised.gif"   ,
                    
':-O'   =>    "icon_surprised.gif"   ,
                    
':-o'   =>    "icon_surprised.gif"   ,

                    
':|'    =>    "icon_neutral.gif"     ,
                    
':-|'   =>    "icon_neutral.gif"     ,
                    
':P'    =>    "icon_razz.gif"        ,
                    
':p'    =>    "icon_razz.gif"        ,
                    
':-P'   =>    "icon_razz.gif"        ,
                    
':-p'   =>    "icon_razz.gif"        ,

                    
'(6)'   =>    "icon_twisted.gif"     ,

                    
':@'    =>    "icon_mad.gif"         ,
                    
':-@'   =>    "icon_mad.gif"         ,

                    
':$'    =>    "icon_redface.gif"     ,
                    
':-$'   =>    "icon_redface.gif"     ,

                    
'(H)'   =>    "icon_cool.gif"        ,
                    
'(h)'   =>    "icon_cool.gif"        ,

                    
';)'    =>    "icon_wink.gif"        ,
                    
';-)'   =>    "icon_wink.gif"        ,

                    
':\'('  =>    "icon_cry.gif"         ,
                    
':-\'(' =>    "icon_cry.gif"         ,

                    
'8)'    =>    "icon_rolleyes.gif"    ,
                    
'8-)'   =>    "icon_rolleyes.gif"    ,

                    
':A'    =>    "icon_evil.gif"        ,
                    
':a'    =>    "icon_evil.gif"        ,
                    
':-A'   =>    "icon_evil.gif"        ,
                    
':-a'   =>    "icon_evil.gif"        ,

                    
':L'    =>    "icon_lol.gif"         ,
                    
':l'    =>    "icon_lol.gif"         ,
                    
':-L'   =>    "icon_lol.gif"         ,
                    
':-l'   =>    "icon_lol.gif"         ,

                    
':X'    =>    "icon_eek.gif"         ,
                    
':x'    =>    "icon_eek.gif"         ,
                    
':-X'   =>    "icon_eek.gif"         ,
                    
':-x'   =>    "icon_eek.gif"         ,

                    
'(Y)'   =>    "icon_yes.gif"         ,
                    
'(y)'   =>    "icon_yes.gif"         ,
                    
'(N)'   =>    "icon_no.gif"          ,
                    
'(n)'   =>    "icon_no.gif"          ,

                    
'(})'   =>    "icon_arrow.gif"       ,
                    
':}'    =>    "icon_arrow.gif"       ,
                    
'(!)'   =>    "icon_exclaim.gif"     ,
                    
'(?)'   =>    "icon_question.gif"    ,
                    
'(%)'   =>    "icon_idea.gif"        ,

                    
'(mr)'  =>    "icon_mrgreen.gif"     ,
                    
':-#'   =>    "icon_silent.gif"      ,
                    
'(cyc)' =>    "icon_cyclops.gif"     ,
                    
'(sick)'=>    "icon_sick.gif"
                   
);

                    foreach (
$smilies AS $find => $character)
                    {
                       
$text str_replace(htmlentities($find), "<img src=\""$smiliesDir $character ."\" alt=\"\" />"$text);
                    }
return 
$text;
}
?>
Usage:
Code: [Select]
<?php

$text 
"This is a example text :) with some smilies (mr)";

print 
bb_smilies($text);

?>
« Last Edit: August 22, 2007, 09:38:29 pm by 4Sandrix »
Logged
I'm kind of like Han Solo always strokin' my own Wookiee
I'm the root of all that's evil yeah but you can call me Cookie

4Sandrix

  • Hero Member
  • *****
  • Karma: -13
  • Posts: 597
    • http://fedrick.deviantart.com
[MOD] Smiley support script
« Reply #1 on: July 13, 2006, 11:55:05 am »

bakercad  thaaaank you, you are my hero , thaaaaaaaanks. aam could you mod it for comments to? Thanks anyway, thank you very much!
P.S. Note for Luka: Could you rename this thread to [MOD]Smiles for Snews? thx :)
Logged
I'm kind of like Han Solo always strokin' my own Wookiee
I'm the root of all that's evil yeah but you can call me Cookie

4Sandrix

  • Hero Member
  • *****
  • Karma: -13
  • Posts: 597
    • http://fedrick.deviantart.com
[MOD] Smiley support script
« Reply #2 on: July 13, 2006, 02:24:10 pm »

« Last Edit: August 22, 2007, 09:40:05 pm by 4Sandrix »
Logged
I'm kind of like Han Solo always strokin' my own Wookiee
I'm the root of all that's evil yeah but you can call me Cookie

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
[MOD] Smiley support script
« Reply #3 on: February 13, 2007, 11:36:41 pm »

is it possible someone can update this MOD to work with 1.5?
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
[MOD] Smiley support script
« Reply #4 on: February 14, 2007, 10:25:16 am »

Function already is good to go as is for 1.5.*

To enable smilies in Comments (inside function comment() ):
Code: [Select]
// Original code : case ($tag == 'comment'): echo $r['comment']; break;
case ($tag == 'comment'): echo bb_smilies( $r['comment'] ); break;
To enable smilies in Articles (inside function center() ):
Code: [Select]
// Original code : file_include(str_replace('[break]', '', $text), $shorten);
file_include( bb_smilies( str_replace('[break]', '', $text) ), $shorten);
Article part suggested here I didn't tested as I have modified center() function and don't use stock file_include() function. Note that described approach for articles ignore possibility that there are any smilies in included or even inserted articles (if You are going to use hidden articles and insert mods).

Hope, this helps.
« Last Edit: September 24, 2007, 04:45:50 pm by codetwist »
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
[MOD] Smiley support script
« Reply #5 on: February 15, 2007, 12:14:57 am »

Quote from: codetwist
Note that described approach for articles ignore possibility that there are any smilies in included or even inserted articles (if You are going to use hidden articles and insert mods).
Actually I am going to include these MODs, however my main reason for wanting smilie is for commenting, so all should be good to go!
Thank you very much for your update! :D
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future