Hello

September 02, 2010, 05:02:12 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
What sNews Is: - sNews is a simple, basic, customizable CMS tool suitable for developers with beginner-to-advanced PHP skills. It is also useful to have a good working knowledge of how to work with, set up and manage MySQL databases. sNews is not - geared towards the end-user who knows little or nothing about building and developing PHP-MySQL based websites.
News: Try sNews 1.7 DEMO
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [MOD] Smiley support script  (Read 4635 times)
4Sandrix
Hero Member
*****

Karma: -12
Posts: 613



WWW
« 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:
<?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:
<?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
bakercad
Administrator
ULTIMATE member
******

Karma: 105
Posts: 1654



WWW
« Reply #1 on: July 13, 2006, 05:23:31 AM »

UPDATED: to include smilies in comments as well

I tested this briefly & it worked fine for me...

NOTE: I changed the function a bit for the $smiliesDir variable.  I'm assuming that the smilies directory is in the main snews directory.

TO ADD SMILIES IN POSTS

In the snews.php file right after the line error_reporting (E_ALL ^ E_NOTICE);

add this:
Code:
function bb_smilies($text)
{
   $smiliesDir = s('website')."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;
}
Next find this line:
Code:
echo substr(stripslashes($fulltext), 0, $shorten);
and replace it with this:
Code:
echo bb_smilies(substr(stripslashes($fulltext), 0, $shorten));
TO ADD SMILIES IN COMMENTS

in the comments function find the line
Code:
echo "<div class='comments'><p>" .cleanXSS($r['comment']). "</p>";
and replace with:
Code:
echo "<div class='comments'><p>" .bb_smilies(cleanXSS($r['comment'])). "</p>";
« Last Edit: August 24, 2007, 03:58:57 PM by bakercad » Logged

4Sandrix
Hero Member
*****

Karma: -12
Posts: 613



WWW
« Reply #2 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 Smiley
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
bakercad
Administrator
ULTIMATE member
******

Karma: 105
Posts: 1654



WWW
« Reply #3 on: July 13, 2006, 02:18:40 PM »

PLEASE NOTE THAT I'VE UPDATED MY FIRST POST IN THIS THREAD TO INCLUDE THIS AS WELL

in the comments function find the line
Code:
echo "

" .cleanXSS($r['comment']). "

";
and replace with:
Code:
echo "

" .bb_smilies(cleanXSS($r['comment'])). "

";
If you could, can you give a url to where you got this script.  I plan on using it as well & would like the smilie images.  Thanks!
Logged

4Sandrix
Hero Member
*****

Karma: -12
Posts: 613



WWW
« Reply #4 on: July 13, 2006, 02:24:10 PM »

here you go:
http://rapidshare.de/files/25729317/smilies.rar.html

thanks again Smiley
« 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
Thread Moderator
ULTIMATE member
*****

Karma: 37
Posts: 1456


currently MIA


« Reply #5 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: 955


« Reply #6 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:
// 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:
// 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
Thread Moderator
ULTIMATE member
*****

Karma: 37
Posts: 1456


currently MIA


« Reply #7 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! Cheesy
Logged

my apologies to the sNews crew, but I will be MIA for the forseeable future
Pages: [1]
  Print  
 
Jump to:  

English Steel 1.6 © Saxon North Technologies
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!