##############################################################
## MOD Title: Topic Preview
## MOD Author: kvfb97 < info@kvfb97.co.uk > (Robert Dougan) http://www.kvfb97.co.uk
## MOD Description: This MOD will add a topic preview box to the viewforum.php page
##                  when you roll over a topic name. It shows bbcode and emotions
##					within the preview with the option to be able to change them
##					within the ACP, aswell as the length and with of the preview box.
## MOD Version: 0.5
##
## Translation Spanish: ThE KuKa - http://www.phpbb-es.com
##
## Installation Level: Easy
## Installation Time: 10 Minutes
## Files To Edit: admin/admin_board.php
## 				  viewforum.php
##				  templates/subSilver/viewforum_body.tpl
##			    templates/subSilver/overall_header.tpl
##			    templates/subSilver/admin/board_config_body.tpl
##				  language/lang_english/lang_main.php
##				  language/lang_english/lang_admin.php
##				  language/lang_spanish/lang_main.php
##				  language/lang_spanish/lang_admin.php
## Included Files: overlib.js
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:
## Tested with phpBB 2.0.19
## Homepage of this MOD: http://www.kvfb97.co.uk
## Compatable with EasyMOD beta (0.3.0)
##
## This MOD use Overlib 4.21 (C) by Erik Bosrup. View more info in overlib.js 
##############################################################
## MOD History:
##
##   2005-12-27 - Version 0.0.1
##      - First version of this MOD
##
##   2005-12-28 - Version 0.2
##      - Fixed a issue with announcements.
##      - Edited the install file and where the overlib.js file is now placed.
##      - Adding upgrading files, and install instructions for other styles.
##      - Added 'Topic Preview' into the lang_main file (thanks to Bicet ;o))
##
##   2005-12-28 - Version 0.3
##      - Added <br /> tags
##
##   2005-12-28 - Version 0.4
##      - Error with '
##
##   2005-12-28 - Version 0.5
##      - Fixed the install file.
##		- Added settings that you can change within your board config (lenght, width,
##		  allow smiles, allow bbcode)
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
# 
#-----[ COPY ]------------------------------------------------ 
# Debe ejecutar topic_preview_db_update.php y despues borrarlo.
#
copy overlib.js to templates/overlib.js
copy topic_preview_db_update.php to topic_preview_db_update.php

#
#-----[ OPEN ]------------------------------------------ 
# 
admin/admin_board.php

# 
#-----[ FIND ]------------------------------------------ 
#
$smtp_no = ( !$new['smtp_delivery'] ) ? "checked=\"checked\"" : "";

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

//
// Topic Preview MOD (kvfb97.co.uk)
//
$tp_smiles_yes = ( $new['tp_smiles'] ) ? "checked=\"checked\"" : "";
$tp_smiles_no = ( !$new['tp_smiles'] ) ? "checked=\"checked\"" : "";
$tp_bbcode_yes = ( $new['tp_bbcode'] ) ? "checked=\"checked\"" : "";
$tp_bbcode_no = ( !$new['tp_bbcode'] ) ? "checked=\"checked\"" : "";
//
// Topic Preview MOD (kvfb97.co.uk)
//

# 
#-----[ FIND ]------------------------------------------ 
#
	"SESSION_LENGTH" => $new['session_length'], 

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
	//
	// Topic Preview MOD (kvfb97.co.uk)
	//
	"L_TOPIC_PREVIEW_SETTINGS" => $lang['topic_preview_settings'],
	"L_TP_LENGTH" => $lang['tp_length'],
	"L_TP_LENGTH_EXPLAIN" => $lang['tp_length_explain'],
	"L_TP_WIDTH" => $lang['tp_width'],
	"L_TP_WIDTH_EXPLAIN" => $lang['tp_width_explain'],
	"L_TP_SMILES" => $lang['tp_smiles'],
	"L_TP_SMILES_EXPLAIN" => $lang['tp_smiles_explain'],
	"L_TP_BBCODE" => $lang['tp_bbcode'],
	"L_TP_BBCODE_EXPLAIN" => $lang['tp_bbcode_explain'],
	
	"TP_LENGTH" => $new['tp_length'],
	"TP_WIDTH" => $new['tp_width'],
	"TP_SMILES_YES" => $tp_smiles_yes,
	"TP_SMILES_NO" => $tp_smiles_no,
	"TP_BBCODE_YES" => $tp_bbcode_yes,
	"TP_BBCODE_NO" => $tp_bbcode_no,
	//
	// Topic Preview MOD (kvfb97.co.uk)
	//

#
#-----[ OPEN ]------------------------------------------ 
# 
viewforum.php

# 
#-----[ FIND ]------------------------------------------ 
# 
include($phpbb_root_path . 'common.'.$phpEx);
	
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);

# 
#-----[ FIND ]------------------------------------------ 
#
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
# 
#-----[ IN-LINE FIND ]------------------------------------------ 
#
p.post_username

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
#
, pt.*
 
# 
#-----[ FIND ]------------------------------------------ 
# 
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
	
# 
#-----[ IN-LINE FIND ]------------------------------------------ 
#
, " . USERS_TABLE . " u2

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
#
, " . POSTS_TEXT_TABLE . " pt

# 
#-----[ FIND ]------------------------------------------ 
# 
		AND t.topic_type = " . POST_ANNOUNCE . "

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
		AND pt.post_id = t.topic_first_post_id

# 
#-----[ FIND ]------------------------------------------ 
# 
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
	
# 
#-----[ IN-LINE FIND ]------------------------------------------ 
#
, p2.post_time

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
#
, pt.*
 
# 
#-----[ FIND ]------------------------------------------ 
# 
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
	
# 
#-----[ IN-LINE FIND ]------------------------------------------ 
#
, " . USERS_TABLE . " u2

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
#
, " . POSTS_TEXT_TABLE . " pt

# 
#-----[ FIND ]------------------------------------------ 
# 
		AND t.topic_type <> " . POST_ANNOUNCE . "

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
		AND pt.post_id = t.topic_first_post_id

# 
#-----[ FIND ]------------------------------------------ 
# 
	'L_AUTHOR' => $lang['Author'],
	
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
	//
	// Topic Preview MOD (kvfb97.co.uk)
	//
	'L_TOPIC_PREVIEW' => $lang['Topic_Preview'],
	'TP_WIDTH' => $board_config['tp_width'],
	//
	// Topic Preview MOD (kvfb97.co.uk)
	//

# 
#-----[ FIND ]------------------------------------------ 
# 
		$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
	
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
		//
		// Topic Preview MOD (kvfb97.co.uk)
		//
		$bbcode_uid = $topic_rowset[$i]['bbcode_uid'];
		$topic_preview = $topic_rowset[$i]['post_text'];
		$topic_preview_lenght = $board_config['tp_length'];
		
		if($board_config['tp_bbcode'] == '1')
		{
			$topic_preview = bbencode_second_pass($topic_preview, $bbcode_uid);
		}
		else
		{
			$topic_preview = preg_replace('/\:(([a-z0-9]:)?)' . $bbcode_uid . '/s', '', $topic_preview);
		}
		$topic_preview = make_clickable($topic_preview);
		if($board_config['tp_smiles'] == '1')
		{
			$topic_preview = smilies_pass($topic_preview);
		}
		$topic_preview = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>'.$topic_preview.'<'), 1, -1));
		$topic_preview = substr($topic_preview, 0, $topic_preview_lenght).'...';
		$topic_preview = str_replace('"', '&quot;', $topic_preview);
		$topic_preview = str_replace("\r\n", "<br/>", $topic_preview);
		$topic_preview = str_replace("\n", "<br/>", $topic_preview);
		$topic_preview = str_replace("'", "\'", $topic_preview);
		//
		// Topic Preview MOD (kvfb97.co.uk)
		//

# 
#-----[ FIND ]------------------------------------------ 
# 
			'LAST_POST_AUTHOR' => $last_post_author, 
			'LAST_POST_IMG' => $last_post_url,
	
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
			//
			// Topic Preview MOD (kvfb97.co.uk)
			//
			'TOPIC_PREVIEW' => $topic_preview,
			//
			// Topic Preview MOD (kvfb97.co.uk)
			//

#
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_english/lang_main.php

# 
#-----[ FIND ]------------------------------------------ 
# 
//
// That's all, Folks!
// -------------------------------------------------

?>
	
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
//
// Topic Preview MOD (kvfb97.co.uk)
//
$lang['Topic_Preview'] = 'Topic Preview:';
//
// Topic Preview MOD (kvfb97.co.uk)
//

#
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_english/lang_admin.php

# 
#-----[ FIND ]------------------------------------------ 
# 
//
// That's all Folks!
// -------------------------------------------------

?>
	
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
//
// Topic Preview MOD (kvfb97.co.uk)
//
$lang['topic_preview_settings'] = 'Topic Preview Settings';
$lang['tp_length'] = 'Topic Preview Length';
$lang['tp_length_explain'] = 'The wlength you want your topic preview to be.';
$lang['tp_width'] = 'Topic Preview Width';
$lang['tp_width_explain'] = 'The width you want your topic preview box to be.';
$lang['tp_smiles'] = 'Enable Smiles';
$lang['tp_smiles_explain'] = 'Chose Yes if you would like to show smiles in your topic preview, otherwise chose No.';
$lang['tp_bbcode'] = 'Enable BBcode';
$lang['tp_bbcode_explain'] = 'Chose Yes if you would like to show bbcode in your topic preview, otherwise chose No.';
//
// Topic Preview MOD (kvfb97.co.uk)
//

#
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_spanish/lang_main.php

# 
#-----[ FIND ]------------------------------------------ 
# 
//
// That's all, Folks!
// -------------------------------------------------

?>
	
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
//
// Topic Preview MOD (kvfb97.co.uk)
//
$lang['Topic_Preview'] = 'Visualizar Tema:';
//
// Topic Preview MOD (kvfb97.co.uk)
//

#
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_spanish/lang_admin.php

# 
#-----[ FIND ]------------------------------------------ 
# 
//
// That's all Folks!
// -------------------------------------------------

?>
	
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
//
// Topic Preview MOD (kvfb97.co.uk)
//
$lang['topic_preview_settings'] = 'Ajustes de Visualizar Tema';
$lang['tp_length'] = 'Longitud de Visualizar Tema';
$lang['tp_length_explain'] = 'La longitud que quisieras que tu visualizacin previa del Tema.';
$lang['tp_width'] = 'Anchura de Visualizar Tema';
$lang['tp_width_explain'] = 'La anchura que quisieras que tu caja de la visualizacin previa del Tema.';
$lang['tp_smiles'] = 'Activar Smiles';
$lang['tp_smiles_explain'] = 'Elija Si si quiere mostrar los Smiles en su Visualizacin Previa del Tema, o elija No.';
$lang['tp_bbcode'] = 'Activar BBcode';
$lang['tp_bbcode_explain'] = 'Elija Si si quiere mostrar los BBCode en su Visualizacin Previa del Tema, o elija No.';
//
// Topic Preview MOD (kvfb97.co.uk)
//

# 
#-----[ OPEN ]------------------------------------------ 
# Como usar este MOD en otros estilos puede verlo en el directorio /contrib 
#
templates/subSilver/viewforum_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
#
<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>

# 
#-----[ IN-LINE FIND ]------------------------------------------ 
#
class="topictitle"

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
#
 onmouseover="return overlib('<table class=forumline><tr><td class=row2><span class=gensmall><b>{L_TOPIC_PREVIEW}</b></span></td></tr><tr><td class=row1><span class=gensmall>{topicrow.TOPIC_PREVIEW}</span></td></tr></table>', WIDTH, {TP_WIDTH})" onmouseout="return nd();"

# 
#-----[ OPEN ]------------------------------------------ 
# Esto debe hacerlo en TODOS los estilos.
#
templates/subSilver/overall_header.tpl

# 
#-----[ FIND ]------------------------------------------ 
# 
</head>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
<script language="JavaScript" src="templates/overlib.js"></script>
<!-- OVERLIB STUFF !-->

# 
#-----[ OPEN ]------------------------------------------ 
# Esto debe hacerlo en TODOS los estilos.
#
templates/subSilver/admin/board_config_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
# 
	<tr>
		<th class="thHead" colspan="2">{L_COOKIE_SETTINGS}</th>
	</tr>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
	<tr>
		<th class="thHead" colspan="2">{L_TOPIC_PREVIEW_SETTINGS}</th>
	</tr>
	<tr>
		<td class="row1">{L_TP_LENGTH}<br /><span class="gensmall">{L_TP_LENGTH_EXPLAIN}</span></td>
		<td class="row2"><input class="post" type="text" name="tp_length" value="{TP_LENGTH}" /></td>
	</tr>
	<tr>
		<td class="row1">{L_TP_WIDTH}<br /><span class="gensmall">{L_TP_WIDTH_EXPLAIN}</span></td>
		<td class="row2"><input class="post" type="text" name="tp_width" value="{TP_WIDTH}" /></td>
	</tr>
	<tr>
		<td class="row1">{L_TP_SMILES}<br /><span class="gensmall">{L_TP_SMILES_EXPLAIN}</span></td>
		<td class="row2"><input type="radio" name="tp_smiles" value="1" {TP_SMILES_YES} /> {L_YES}&nbsp;&nbsp;<input type="radio" name="tp_smiles" value="0" {TP_SMILES_NO} /> {L_NO}</td>
	</tr>
	<tr>
		<td class="row1">{L_TP_BBCODE}<br /><span class="gensmall">{L_TP_BBCODE_EXPLAIN}</span></td>
		<td class="row2"><input type="radio" name="tp_bbcode" value="1" {TP_BBCODE_YES} /> {L_YES}&nbsp;&nbsp;<input type="radio" name="tp_bbcode" value="0" {TP_BBCODE_NO} /> {L_NO}</td>
	</tr>

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM