boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

B2 Pseudo Smilies Hack

 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
Benjy



Joined: 25 Jan 2002
Posts: 108
Location: Paris, France

PostPosted: Mon Apr 08, 2002 8:50 pm    Post subject: B2 Pseudo Smilies Hack Reply with quote

Why "pseudo"?
Because in fact it just puts a direct link to your smilies, it doesn't replace a ": )" to Smile

So if you are still interested, here are the instructions:

1. Edit <B2_root>\b2-include\b2quicktags.js and add at the end:
Code:
function smilie(path2smilie) {
   smilie2insert='<img alt="" src="' + path2smilie + '" />';
   if ((parseInt(navigator.appVersion) >= 4) && (navigator.appName == "Microsoft Internet Explorer"))
      theSelection = document.selection.createRange().text; // Get text selection
   if (theSelection) {
      // Add tags around selection
      document.selection.createRange().text = theSelection + smilie2insert + ' ';
      document.post.content.focus();
      theSelection = '';
      return;
   }
   document.post.content.value += ' ' + smilie2insert + ' ';
   document.post.content.focus();
}


2. Edit <B2_root>\b2-include\b2edit.form.php and replace (around line 92):
Code:
<textarea rows="9" cols="40" style="width:100%" name="content" tabindex="4" wrap="virtual"><?php echo $content ?></textarea>

with
Code:
<!--SMILIES HACK BEGIN-->
<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>
<td valign="top" width="90%"><textarea rows="9" cols="40" style="width:100%" name="content" tabindex="4" wrap="virtual"><?php echo $content ?></textarea></td>
<td valign="top">
<?php
$dir2open="b2-img/smilies";      //dir 2 preview smilies
$dir2include="b2/b2-img/smilies";   //dir 2 include smilies
$nbrcol=4;            //columns for the smilies
$handle=opendir($dir2open);
echo "<table>\n";
echo "<tr>\n";
$i=0;
while ($file = readdir($handle)) {
        if ($file != "." and $file !=".." and eregi("\.gif$",$file)) {
           if ($i==$nbrcol) {
              echo "</tr><tr>\n";
              $i=0;
           }
           echo "<td><img src=\"$dir2open/$file\" onClick=\"smilie('$siteurl/$dir2include/$file')\" style=\"cursor:hand\"></td>\n";
           $i++;
        }
}
echo "</tr>\n";
echo "</table>\n";
closedir($handle);
?>
</td>
</tr></table>
<!--SMILIES HACK END-->

Don't forget to make $dir2open, $dir2include and $nbrcol suit your needs.
They represent:
$dir2open > you'll most likely not change it, it's the path from b2edit.php to the path where are the smilies
$dir2include > the path from your b2.php (or whatever you call it) to the path where are the smilies
$nbrcol > number of columns of the table including the smilies

Also, my code searches the path for .gif files only, but replacing "and eregi("\.gif$",$file)" in the if condition with "and (eregi("\.gif$",$file) or eregi("\.jpg$",$file))" will allow you to see also the jpeg files (for example).

The only "bug" of this hack is that (at least for me), as $dir2open and $dir2include are different, the images don't show up in the preview in the admin area. Apart from this, it works! Very Happy



And my news page: http://www.newcomics.fr.st

UPDATE: works with 0.6pre2.

Benjy.


Last edited by Benjy on Tue May 14, 2002 7:23 pm; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
dodo



Joined: 25 Jan 2002
Posts: 35

PostPosted: Thu Apr 11, 2002 6:56 am    Post subject: awesome Reply with quote

awesome job there.. just a small note
to keep b2 xml-compliant, i edited your javascript code a little bit
just updated the code line to
Code:

smilie2insert='<img alt="" src="' + path2smilie + '" />';


thanks for the hack!!
_________________
http://pure-essence.net

b2 rocks
Back to top
View user's profile Send private message Visit poster's website
Benjy



Joined: 25 Jan 2002
Posts: 108
Location: Paris, France

PostPosted: Thu Apr 11, 2002 9:42 am    Post subject: Reply with quote

Well, yes, sorry I didn't think about XML :p
Btw thx, I update my post right now!

Benjy.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
identityless



Joined: 25 Jan 2002
Posts: 22

PostPosted: Thu Apr 11, 2002 7:30 pm    Post subject: Reply with quote

this is great!
Back to top
View user's profile Send private message Visit poster's website
nessahead



Joined: 12 Mar 2002
Posts: 312
Location: Los Angeles, CA

PostPosted: Thu Apr 11, 2002 11:35 pm    Post subject: Reply with quote

Just installed this puppy and it went smoothly =) Thanks!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
lornaly



Joined: 20 Apr 2002
Posts: 2

PostPosted: Wed Apr 24, 2002 1:06 pm    Post subject: Cool hack Reply with quote

I add this hack today the only thing is that i have to replace "b2/b2-img/smilies" to ./b2-img/smilies manually in the text area. btw i can see the smilies in my admin area Very Happy good work
Back to top
View user's profile Send private message Visit poster's website
Benjy



Joined: 25 Jan 2002
Posts: 108
Location: Paris, France

PostPosted: Wed Apr 24, 2002 10:16 pm    Post subject: Reply with quote

Just change your
Code:
$dir2include="./b2/b2-img/smilies";
to
Code:
$dir2include="./b2-img/smilies";
The variable is meant for this Cool

Benjy.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
lornaly



Joined: 20 Apr 2002
Posts: 2

PostPosted: Thu Apr 25, 2002 11:11 am    Post subject: thanks Reply with quote

Very Happy I did that yesterday, thanks!
Back to top
View user's profile Send private message Visit poster's website
nessahead



Joined: 12 Mar 2002
Posts: 312
Location: Los Angeles, CA

PostPosted: Fri May 03, 2002 10:04 pm    Post subject: Reply with quote

Ok, I totally didn't realize that your hack gets its list of smilies from the files that are in the smilied directory! I can replace them and add or subtract as I want and there's no code to modify! Duh me =P

Anyhow, you rock! An even better hack than I thought at first =)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Benjy



Joined: 25 Jan 2002
Posts: 108
Location: Paris, France

PostPosted: Sat May 04, 2002 11:17 pm    Post subject: Reply with quote

Thx again Very Happy

Benjy.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Benjy



Joined: 25 Jan 2002
Posts: 108
Location: Paris, France

PostPosted: Tue May 14, 2002 7:20 pm    Post subject: Reply with quote

UPDATE!

Changed
Code:
$dir2open="./b2-img/smilies";      //dir 2 preview smilies
$dir2include="./b2/b2-img/smilies";   //dir 2 include smilies
to
Code:
$dir2open="b2-img/smilies";      //dir 2 preview smilies
$dir2include="b2/b2-img/smilies";   //dir 2 include smilies
(removed the "./")
and
Code:
           echo "<td><img src=\"$dir2open/$file\" onClick=\"smilie('$dir2include/$file')\" style=\"cursor:hand\"></td>\n";
to
Code:
           echo "<td><img src=\"$dir2open/$file\" onClick=\"smilie('$siteurl/$dir2include/$file')\" style=\"cursor:hand\"></td>\n";
(added $siteurl/ so that smilies display well, even in the preview )
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
maka



Joined: 09 May 2002
Posts: 4
Location: Oklahoma

PostPosted: Wed May 22, 2002 4:46 pm    Post subject: this is cool, but... Reply with quote

i'm using this and love it, but i've got so many smilies that i decided to move them to below the textedit area...still it's a huge bunch of smilies and they take a little while to load...i'm wondering if it would be possible to just have a pop-up window with all the smilies in it that would still accomplish this? (send the <img> tag code back to the b2edit or else copy it to the clipboard maybe?)

here's the code for the alternate placement of the smilies

Code:

<!--SMILIES HACK BEGIN-->
<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>
<td valign="top" width="90%"><textarea rows="9" cols="40" style="width:100%" name="content" tabindex="4" wrap="virtual"><?php echo $content ?></textarea></td>
</tr><tr><td valign="top">
<?php
$dir2open="./b2-img/smilies";      //dir 2 preview smilies
$dir2include="./b2-img/smilies";   //dir 2 include smilies
$nbrcol=24;            //columns for the smilies
$handle=opendir($dir2open);
echo "<table>\n";
echo "<tr>\n";
$i=0;
while ($file = readdir($handle)) {
        if ($file != "." and $file !=".." and eregi("\.gif$",$file)) {
           if ($i==$nbrcol) {
              echo "</tr><tr>\n";
              $i=0;
           }
           echo "<td><img src=\"$dir2open/$file\" onClick=\"smilie('$dir2include/$file')\" style=\"cursor:hand\"></td>\n";
           $i++;
        }
}
echo "</tr>\n";
echo "</table>\n";
closedir($handle);
?>
</td>
</tr></table>
<!--SMILIES HACK END-->

_________________
Love & Light....
Maka, single stay-at-home bad-ass crunchy mama
to Daystar (fsbc 6/23/91),
to Griffin (uhb 7/11/99),
and to many other babies never held in arms!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Benjy



Joined: 25 Jan 2002
Posts: 108
Location: Paris, France

PostPosted: Wed May 22, 2002 10:13 pm    Post subject: Reply with quote

Of course it is possible!
Problem is I don't have much time right now, but I'll do it ASAP Smile

Benjy.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
maka



Joined: 09 May 2002
Posts: 4
Location: Oklahoma

PostPosted: Thu May 23, 2002 2:23 am    Post subject: thanks! Reply with quote

thanks benjy!! i'll be watching for it!
_________________
Love & Light....
Maka, single stay-at-home bad-ass crunchy mama
to Daystar (fsbc 6/23/91),
to Griffin (uhb 7/11/99),
and to many other babies never held in arms!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Benjy



Joined: 25 Jan 2002
Posts: 108
Location: Paris, France

PostPosted: Fri May 24, 2002 4:09 pm    Post subject: v1.3 Reply with quote

http://www.tidakada.com/board/viewtopic.php?t=560

Benjy. Smile
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group