#########################################################
## MOD Title:  Drop Down Smilie MOD - EM Friendly
## MOD Author:       radmanics <radmanics@dial.pipex.com> (David Race) http://members.lycos.co.uk/coolcodesportal/
## MOD Description:  Makes a select, drop down box, which contains a list of all the smilies
##		 			 installed on you board. When you select a smiley, it appears next to the box.
##					 The smiliey code is then inserted to the like normal (by clicking on it)
## 
## MOD Version: 1.1.7
## 
## Installation Level:  Easy 
## Installation Time:   5-10 minutes
## Files To Edit: 4     
## 		 		  posting.php
##				  privmsg.php
##				  language/lang_english/main_lang.php
##				  templates/subSilver/posting_body.tpl
##
## Included Files: 1
## 				   images/smilies/null.gif  (needs to be add, is included)
#########################################################
## Layout Files:	Part 2a
##			Part 2b
##			Part 2c
##			Part 2d
######################################################### 
## Security Disclaimer: This MOD Cannot Be Posted To Or Added At Any Non-Official phpBB Sites 
#########################################################
## Notes: This MOD is inspired (and some of it is modified code) of the UBB
##	  version. It uses the smiliy's name in the select box though.
##	  Be careful not to alter ANY of the javascript unless you know what
##	  you are doing, and have a good reason for it, other wise the MOD wont
##	  work AT ALL!!!! so be careful :)
#########################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
#########################################################
# 
#-----[ DIY INSTRUCTIONS ] -------- 
# 
Before installing this MOD, you will need to modify the URL in the code
that modifies the privmsg.php file below.  Search for You will need to modify this URL
# 
#-----[ COPY ] -------- 
# 
copy null.gif to images/smilies/null.gif
# 
#-----[ OPEN ] -------- 
# 
posting.php 
# 
#-----[ FIND ]---- 
# 
include($phpbb_root_path . 'includes/functions_post.'.$phpEx); 
# 
#---[ AFTER, ADD ]---- 
#
 
//this needs to be a relative path and not a global URL (ie: http://phpbb.com/phpBB/images....etc)
$board_root_path = "phpbb/images/smiles/"; //needs trailing slash 

# 
#----- [ FIND ] ---- 
# 
//
// Check and set various parameters
# 
#-----[ BEFORE, ADD ] ---- 
# 
//
//Drop Down Smilie List MOD (c) radmanics 2002
//

//user vars
$smilie_path = $smilies_root_path;
$null_path = $smilies_root_path . "null.gif";

$sql = "SELECT DISTINCT emoticon, code, smile_url FROM " . SMILIES_TABLE;
if(!$result = $db->sql_query($sql))
{
	message_die(GENERAL_ERROR, "Couldn't obtain smilie data", "", __LINE__, __FILE__, $sql);
}

$num = $db->sql_numrows($result);

$row = $db->sql_fetchrowset($result);

$smilie_data = array();

for ( $k = 0; $k < $num; $k++ )
{
	$smilie_data[$k]['name'] = $row['emoticon'];
	$smilie_data[$k]['url'] = $smilie_path . $row['smile_url'];
	$smilie_data[$k]['code'] = $row['code'];
	$smilie_block .= "<option value='" . $smilie_data[$k]['url'] . "' id=' " .$smilie_data[$k]['code'] ." '>" . $smilie_data[$k]['name'] . "</option>";
}

$temp = $smilie_block;
$smilie_block = "<option value='$nul_path' selected>----Select A Smilie----</option>";
$smilie_block .= $temp;

//end MOD

# 
#-----[ FIND ] ---- 
# 
'L_STYLES_TIP' => $lang['Styles_tip'],
#
#----- [ AFTER, ADD ] -----
#

	'L_SMILIES' => "Smilies",
	'SMILIE_BLOCK' => $smilie_block,
	'SMILIE_NULL' => "http://path/to/phpbb/images/smiles/null.gif",

# 
#-----[ FIND ] ---- 
#
'S_POST_ACTION' => append_sid("posting.$phpEx"),
#
#----- [ AFTER, ADD ] -----
#

	'S_SMILEY_BLOCK' => $smilie_block,
	'S_SMILEY_NULL' => "images/smiles/null.gif",
#
#-----[ OPEN ] ----
#
privmsg.php
# 
#-----[ FIND ]---- 
# 
include($phpbb_root_path . 'includes/functions_post.'.$phpEx); 
# 
#---[ AFTER, ADD ]---- 
# You will need to modify this URL
$board_root_path = "http://www./path/to/phpbb/images/smiles/"; //needs trailing slash 
#
#-----[ FIND ] ----
#
// Start main
// 
# 
#-----[ AFTER, ADD ] ---- 
# 

//
//Drop Down Smilie List MOD (c) radmanics 2002
//

//user vars
$smilie_path = $smilies_root_path;
$null_path = $smilies_root_path . "null.gif";

$sql = "SELECT DISTINCT emoticon, code, smile_url FROM " . SMILIES_TABLE;
if(!$result = $db->sql_query($sql))
{
	message_die(GENERAL_ERROR, "Couldn't obtain smilie data", "", __LINE__, __FILE__, $sql);
}

$num = $db->sql_numrows($result);

$row = $db->sql_fetchrowset($result);

$smilie_data = array();

for ( $k = 0; $k < $num; $k++ )
{
	$smilie_data[$k]['name'] = $row['emoticon'];
	$smilie_data[$k]['url'] = $smilie_path . $row['smile_url'];
	$smilie_data[$k]['code'] = $row['code'];
	$smilie_block .= "<option value='" . $smilie_data[$k]['url'] . "' id=' " .$smilie_data[$k]['code'] ." '>" . $smilie_data[$k]['name'] . "</option>";
}

$temp = $smilie_block;
$smilie_block = "<option value='$nul_path' selected>----Select A Smilie----</option>";
$smilie_block .= $temp;

//end MOD

#
#-----[ FIND ] ----
#
'L_STYLES_TIP' => $lang['Styles_tip'],
#
#-----[ AFTER, ADD ] ----
#

		'L_SMILIES' => $lang['Smilies'],
		'L_S_CODE_TIP' => $lang['Smiley_tip'],
		'L_SMILEY_CODE' => $lang['Smiley_code'],

#
#-----[ FIND ] ----
#
'S_POST_ACTION' => append_sid("privmsg.$phpEx"),
#
#-----[ AFTER, ADD ] ----
#

		'S_SMILEY_BLOCK' => $smilie_block,
		'S_SMILEY_NULL' => "images/smiles/null.gif",

#
#-----[ OPEN ] ----
#
language/lang_english/lang_main.php
#
#-----[ FIND ] ----
#
?>
#
#-----[ BEFORE, ADD ] ----
//smilies drop down box MOD (c) radmanics 2002
$lang['Smilies'] = "Smilies";
$lang['Smiley_tip'] = "Tip: Use the box to quickly find a smiley, then add it by clicking on the it";
$lang['Smiley_code'] = "The smiley code for this simley is: ";

# 
#---- [ OPEN ] -------- 
# 
templates/subSilver/posting_body.tpl 
# 
#----- [ FIND ] ---- 
#
function bbfontstyle
# 
#---- [ BEFORE, ADD ] ---- 
# 

//Drop Down Smilie MOD (c) radmanics 2002

//this is the function to change the image, taken from phpBB2.0.0 smilie admin pannel
function update_smiley(newimage)
{
	document.smiley_image.src = "{S_SMILEY_BASEDIR}/" + newimage;
}

//this is the function to add the smiley code, taken and modified from the UBB version.
function emoticon_drop(text) {
  emoticon_code = "" + text;
  current_msg = document.post.message.value;

  document.post.message.value = current_msg+emoticon_code;
  document.post.message.focus();
  return;
}

function emoticon_code_help(help) {
	document.post.emoticon_code_box.value = "{L_SMILEY_CODE}" + help;
}

//end MOD

# 
# --- [ FIND ] ---- 
# 
<!-- END switch_smilies_extra -->
# 
# --- [ FIND ] ---- 
# 
</tr>

#
#-----[ AFTER, ADD ] -----
#
		<tr> 
		   <td><span class="gensmall"> 
		       <select name='smile_url' onchange="update_smiley(this.options[selectedIndex].value);" onmouseover="emoticon_code_help(this.options[selectedIndex].id)";>{S_SMILEY_BLOCK}</select><img name="smiley_image" src="{S_SMILEY_NULL}" border="0" onclick="emoticon_drop(document.post.smile_url.options[document.post.smile_url.selectedIndex].id)" onmouseover="emoticon_code_help(document.post.smile_url.options[document.post.smile_url.selectedIndex].id)">
		   	   <br /><input type="text" name="emoticon_code_box" size="45" maxlength="100" style="width:450px; font-size:10px" class="helpline" value="{L_S_CODE_TIP}" /> </span>
		   </td>
		</tr>
# 
#-----[ SAVE/CLOSE ALL FILES ]-------------------------------- 
# 
# EoM

