################################################################# 
## Mod Title: Extended Quote Tag
## Mod Version: 1.0.0
## Author: Acyd Burn < acyd.burn@gmx.de > - Meik Sievertsen - http://www.opentools.de/
## Description: 
##		This Mod adds an extended functionality on the [quote] BBCode Tag.
##		You are able to view the Post from which the User quoted and you have the ability
##		to quote directly from the Topic Review Window.
##		To let this Mod recognise the Post, the Quote Tag has this extended systax (old syntax works):
##			[quote=p="<post_id>"][/quote]
##			[quote="<Username>";p="<post_id>"][/quote]
##		After the Message got parsed you will see an additional Link:
##			Quote (View Post):
##			Username wrote (View Post):
##		Within the Topic Review Window a Quote Button is added to each Post.
##		After clicking on this Button the Quote is added to the current Post Area.
##		
##		This Version is Tested with phpBB 2.0.3.
##
## Revision History:
##
##		2002-11-23 - Version 1.0.0
## 
## Installation Level: moderate
## Installation Time: 5-10 Minutes 
## Files To Edit: posting.php, includes/bbcode.php, includes/topic_review.php, language/lang_english/lang_main.php,
##		templates/subSilver/bbcode.tpl, templates/subSilver/posting_topic_review.tpl, templates/subSilver/viewtopic_body.tpl
## Included Files: show_post.php, post_review.tpl
##
############################################################## 
## This MOD is released under the GPL License.
############################################################## 
## Please Check the following Sites for the latest version of this MOD:
##
## http://www.phpbb.com/mods/downloads/
## http://www.opentools.de/board (Download Forum)
## 
## For Security Purposes:
## If you want to add this Mod into ANY Mods Database, please ask me before you do so.
## If anyone ask me if it's safe to use, i will have a list of sites where it's available/downloadable from.
## Downloading this MOD from sites not on my list could cause malicious code to enter into your phpBB Forum.
## As an additional service, i will inform those sites when a new Version comes out.
##
## phpBB will not offer support for MOD's not offered in their MOD-Database, located at: http://www.phpbb.com/mods/downloads/
##
## Please Note that you get FULL support on http://www.opentools.de, http://www.phpbbhacks.com and http://www.phpbb.com from
## me (the Mod Author). 
##
############################################################## 
## Author Notes: 
##
## This Mod does not require Database Changes.
## Many Thanks to dhn for requesting this Mod and for the Discussion on it.
##
################################################################# 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
################################################################# 

#
# Here starts the Installation, follow the steps very close.
#

#
# Copy all files to their respective Location:
#
# show_post.php				-> show_post.php
# post_review.tpl			-> templates/subSilver/post_review.tpl
#

# 
#-----[ OPEN ]--------------------------------------------- 
# 
posting.php

#
#-----[ FIND ]---------------------------------------------
# around line 784
			$message = '[quote="' . $quote_username . '"]' . $message . '[/quote]';

# 
#-----[ REPLACE WITH ]---------------------------------------
# 
//			$message = '[quote="' . $quote_username . '"]' . $message . '[/quote]';
			$message = '[quote="' . $quote_username . '";p="' . $post_id . '"]' . $message . '[/quote]';

# 
#-----[ OPEN ]--------------------------------------------- 
# 
includes/bbcode.php

#
#-----[ FIND ]---------------------------------------------
# around line 91
	$bbcode_tpl['quote_username_open'] = str_replace('{USERNAME}', '\\1', $bbcode_tpl['quote_username_open']);

# 
#-----[ AFTER, ADD ]--------------------------------------- 
# 
	$bbcode_tpl['quote_post_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_post_open']);
	$temp_url = append_sid('show_post.php?p=\\1');
	$bbcode_tpl['quote_post_open'] = str_replace('{U_VIEW_POST}', '<a href="#_somewhat" onClick="javascript:open_postreview( \'' . $temp_url . '\' );" class="genmed">' . $lang['View_post'] . '</a>', $bbcode_tpl['quote_post_open']);

	$bbcode_tpl['quote_username_post_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_username_post_open']);
	$bbcode_tpl['quote_username_post_open'] = str_replace('{L_WROTE}', $lang['wrote'], $bbcode_tpl['quote_username_post_open']);
	$bbcode_tpl['quote_username_post_open'] = str_replace('{USERNAME}', '\\1', $bbcode_tpl['quote_username_post_open']);
	$temp_url = append_sid('show_post.php?p=\\2');
	$bbcode_tpl['quote_username_post_open'] = str_replace('{U_VIEW_POST}', '<a href="#_somewhat" onClick="javascript:open_postreview( \'' . $temp_url . '\' );" class="genmed">' . $lang['View_post'] . '</a>', $bbcode_tpl['quote_username_post_open']);

#
#-----[ FIND ]---------------------------------------------
# around line 182
	// [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
	$text = str_replace("[quote:$uid]", $bbcode_tpl['quote_open'], $text);
	$text = str_replace("[/quote:$uid]", $bbcode_tpl['quote_close'], $text);

# 
#-----[ AFTER, ADD ]--------------------------------------- 
# 
	// opening a quote with an pre-defined post entry
	$text = preg_replace("/\[quote:$uid=p=\"([0-9]+)\"\]/si", $bbcode_tpl['quote_post_open'], $text);
	
	// opening a username quote with an pre-defined post entry
	$text = preg_replace("/\[quote:$uid=(?:\"?([^\"]*)\"?);p=(?:\"?([0-9]+)\"?)\]/si", $bbcode_tpl['quote_username_post_open'], $text);

#
#-----[ FIND ]---------------------------------------------
# around line 269
	$text = bbencode_first_pass_pda($text, $uid, '/\[quote=(\\\\"[^"]*?\\\\")\]/is', '[/quote]', '', false, '', "[quote:$uid=\\1]");

# 
#-----[ AFTER, ADD ]--------------------------------------- 
# 
	// [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff with an pre-defined post entry
	$text = bbencode_first_pass_pda($text, $uid, '/\[quote=p=(\\\\"[0-9]+\\\\")\]/is', '[/quote]', '', false, '', "[quote:$uid=p=\\1]");

	$text = bbencode_first_pass_pda($text, $uid, '/\[quote=(\\\\"[^"]*?\\\\");p=(\\\\"[0-9]+\\\\")\]/is', '[/quote]', '', false, '', "[quote:$uid=\\1;p=\\2]");

# 
#-----[ OPEN ]--------------------------------------------- 
# 
includes/topic_review.php

#
#-----[ FIND ]---------------------------------------------
# around line 151
			$message = $row['post_text'];
			$bbcode_uid = $row['bbcode_uid'];

# 
#-----[ AFTER, ADD ]--------------------------------------- 
# 
			$plain_message = $row['post_text'];
			$plain_message = preg_replace('/\:(([a-z0-9]:)?)' . $bbcode_uid . '/s', '', $plain_message);
			$plain_message = str_replace('<', '&lt;', $plain_message);
			$plain_message = str_replace('>', '&gt;', $plain_message);
			$plain_message = str_replace('<br />', "\n", $plain_message);

			$orig_word = array();
			$replacement_word = array();
			obtain_word_list($orig_word, $replace_word);

			if ( !empty($orig_word) )
			{
				$plain_message = ( !empty($plain_message) ) ? preg_replace($orig_word, $replace_word, $plain_message) : '';
			}
			$plain_message = addslashes($plain_message);
			$plain_message = str_replace("\n", "\\n", $plain_message);

#
#-----[ FIND ]---------------------------------------------
# around line 214
				'MESSAGE' => $message,

# 
#-----[ AFTER, ADD ]--------------------------------------- 
# 
				'U_POST_ID' => $row['post_id'],
				'PLAIN_MESSAGE' => str_replace(chr(13), '', $plain_message), 

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

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

# 
#-----[ BEFORE, ADD ]--------------------------------------- 
# 
$lang['View_post'] = 'View Post';
$lang['Post_review'] = 'Post Review';
$lang['View_next_post'] = 'View next Post';
$lang['View_previous_post'] = 'View previous Post';
$lang['No_newer_posts'] = 'There are no newer posts in this forum';
$lang['No_older_posts'] = 'There are no older posts in this forum';

# 
#-----[ OPEN ]--------------------------------------------- 
# 
templates/subSilver/bbcode.tpl

#
#-----[ FIND ]---------------------------------------------
# around line 22
	  <td class="quote"><!-- END quote_open -->

# 
#-----[ AFTER, ADD ]--------------------------------------- 
# 
<!-- BEGIN quote_username_post_open --></span>
<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
<tr> 
	  <td><span class="genmed"><b>{USERNAME} {L_WROTE} ({U_VIEW_POST}):</b></span></td>
	</tr>
	<tr>
	  <td class="quote"><!-- END quote_username_post_open -->
<!-- BEGIN quote_post_open --></span>
<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
<tr> 
	  <td><span class="genmed"><b>{L_QUOTE} ({U_VIEW_POST}):</b></span></td>
	</tr>
	<tr>
	  <td class="quote"><!-- END quote_post_open -->

# 
#-----[ OPEN ]--------------------------------------------- 
# 
templates/subSilver/posting_topic_review.tpl

#
#-----[ FIND ]---------------------------------------------
# around line 1
<!-- BEGIN switch_inline_mode -->

# 
#-----[ BEFORE, ADD ]--------------------------------------- 
# 
<script language="JavaScript" type="text/javascript">
<!--

message = new Array();
<!-- BEGIN postrow -->
message[{postrow.U_POST_ID}] = "[quote=\"{postrow.POSTER_NAME}\";p=\"{postrow.U_POST_ID}\"]\n{postrow.PLAIN_MESSAGE}\n[/quote]";
<!-- END postrow -->

function addquote(post_id) {

	window.parent.document.post.message.value += message[post_id];
	window.parent.document.post.message.focus();
	return;
}

//-->
</script>

#
#-----[ FIND ]---------------------------------------------
# around line 37
				<td width="100%"><img src="{postrow.MINI_POST_IMG}" width="12" height="9" alt="{postrow.L_MINI_POST_ALT}" title="{postrow.L_MINI_POST_ALT}" border="0" /><span class="postdetails">{L_POSTED}: {postrow.POST_DATE}<span class="gen">&nbsp;</span>&nbsp;&nbsp;&nbsp;{L_POST_SUBJECT}: {postrow.POST_SUBJECT}</span></td>

# 
#-----[ AFTER, ADD ]--------------------------------------- 
# 
				<td valign="top" align="right" nowrap="nowrap"><span class="genmed"><input type="button" class="button" name="addquote" value="Quote" style="width: 50px" onClick="addquote({postrow.U_POST_ID});" /></span></td>

# 
#-----[ OPEN ]--------------------------------------------- 
# 
templates/subSilver/viewtopic_body.tpl

#
#-----[ FIND ]---------------------------------------------
# around line 1
<table width="100%" cellspacing="2" cellpadding="2" border="0">
  <tr> 
	<td align="left" valign="bottom" colspan="2"><a class="maintitle" href="{U_VIEW_TOPIC}">{TOPIC_TITLE}</a><br />

# 
#-----[ BEFORE, ADD ]--------------------------------------- 
# 
<script language="Javascript" type="text/javascript">
<!--
	function open_postreview(ref)
	{
		height = screen.height / 3;
		width = screen.width / 2;
		window.open(ref, '_phpbbpostreview', 'HEIGHT=' + height + ',WIDTH=' + width + ',resizable=yes,scrollbars=yes');
		return;
	}
//-->
</script>

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

#EOM