############################################################## 
## MOD Title:          Upgrade to BBCodes & smilies enhancement 1.2.0
## MOD Author:         -=ET=- < N/A > (N/A) http://www.golfexpert.net/phpbb
## MOD Description:    This MOD will allow you to upgrade your
##                     BBCodes & smilies enhancement MOD from 1.1.0
##                     to 1.2.0
## MOD Version:        1.0.0
## 
## Installation Level: Easy
## Installation Time:  5 Minutes (1mn by EasyMOD)
## Files To Edit:
##      posting.php
##      privmsg.php
##      language/lang_english/lang_main.php
##      templates/subSilver/posting_body.tpl
##      templates/subSilver/posting_smilies.tpl
## Included Files:     N/A
## 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: 
##
## BBCodes & smilies enhancement 1.1.0 needs to be already installed!!!
##
## The rest of the author notes are on the full install MOD
## in the root dir of this MOD archive!
##
############################################################## 
## MOD History: 
## 
##   2005-05-26 - Version 1.0.0
##      - Initial release
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 
# 
#-----[ OPEN ]------------------------------------------------ 
#
posting.php

# 
#-----[ FIND ]------------------------------------------------ 
#
// Start add - BBCodes & smilies enhancement MOD
'L_BBCODE_URL' => $lang['bbcode_url'],
'L_BBCODE_URL_TITLE' => $lang['bbcode_url_title'],
'L_BBCODE_URL_EMPTY' => $lang['bbcode_url_empty'],
'L_BBCODE_URL_TITLE_EMPTY' => $lang['bbcode_url_title_empty'],
'L_BBCODE_URL_ERRORS' => $lang['bbcode_url_errors'],
// End add - BBCodes & smilies enhancement MOD

# 
#-----[ REPLACE WITH ]----------------------------------------
#
// Start add - BBCodes & smilies enhancement MOD
'L_BBCODE_URL' => $lang['bbcode_url'],
'L_BBCODE_URL_TITLE' => $lang['bbcode_url_title'],
'L_BBCODE_URL_EMPTY' => $lang['bbcode_url_empty'],
'L_BBCODE_URL_ERRORS' => $lang['bbcode_url_errors'],
// End add - BBCodes & smilies enhancement MOD
# 
#-----[ OPEN ]------------------------------------------------ 
#
privmsg.php

# 
#-----[ FIND ]------------------------------------------------ 
#
# NOTE: this is a search by part(s) of code line(s)!
# The original line(s) to find is(are) longer and must look like this (if no MOD has already modify them):
#
# 'L_BBCODE_W_HELP' => $lang['bbcode_w_help'],
#
'L_BBCODE_W_HELP' =>

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

// Start add - BBCodes & smilies enhancement MOD
'L_BBCODE_URL' => $lang['bbcode_url'],
'L_BBCODE_URL_TITLE' => $lang['bbcode_url_title'],
'L_BBCODE_URL_EMPTY' => $lang['bbcode_url_empty'],
'L_BBCODE_URL_ERRORS' => $lang['bbcode_url_errors'],
// End add - BBCodes & smilies enhancement MOD

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

# 
#-----[ FIND ]------------------------------------------------ 
#
// Start add - BBCodes & smilies enhancement MOD
$lang['bbcode_url'] = 'Enter the URL (eg. http://www.phpbb.com)';
$lang['bbcode_url_title'] = 'Enter the title of the link';
$lang['bbcode_url_empty'] = 'You didn\'t enter any url';
$lang['bbcode_url_title_empty'] = 'You didn\'t enter any title for the link';
$lang['bbcode_url_errors'] = 'Error!';
// End add - BBCodes & smilies enhancement MOD

# 
#-----[ REPLACE WITH ]----------------------------------------
#
// Start add - BBCodes & smilies enhancement MOD
$lang['bbcode_url'] = 'Enter the URL (eg. http://www.phpbb.com)';
$lang['bbcode_url_title'] = 'Enter the title of the link';
$lang['bbcode_url_empty'] = 'You didn\'t enter any url';
$lang['bbcode_url_errors'] = 'Error!';
// End add - BBCodes & smilies enhancement MOD
# 
#-----[ OPEN ]------------------------------------------------ 
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]------------------------------------------------
#
// Shows the help messages in the helpline window

#
#-----[ BEFORE, ADD ]-----------------------------------------
#
# This instruction and this code is copyright (C) TerraFrost
# http://www.frostjedi.com
#

// Start add - BBCodes & smilies enhancement MOD
var baseHeight;
window.onload = initInsertions;

function initInsertions() {
	document.post.message.focus();
	if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
}
// End add - BBCodes & smilies enhancement MOD

# 
#-----[ FIND ]------------------------------------------------ 
#
# NOTE: this is a search by part(s) of code line(s)!
# The original line(s) to find is(are) longer and must look like this (if no MOD has already modify them):
#
# caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
#
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == 
txtarea.focus();

# 
#-----[ BEFORE, ADD ]-----------------------------------------
#
# The baseHeight test is copyright (C) TerraFrost
# http://www.frostjedi.com
#

// Start add - BBCodes & smilies enhancement MOD
		if (baseHeight != txtarea.caretPos.boundingHeight) {
			txtarea.focus();
			storeCaret(txtarea);
		}
// End add - BBCodes & smilies enhancement MOD

# 
#-----[ FIND ]------------------------------------------------ 
#
// Start add - BBCodes & smilies enhancement MOD
	} else
	if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0))
	{ 
		mozInsert(txtarea, text, "");
		return;
// End add - BBCodes & smilies enhancement MOD

# 
#-----[ REPLACE WITH ]----------------------------------------
#
// Start add - BBCodes & smilies enhancement MOD
	} else
	if ((txtarea.selectionEnd | txtarea.selectionEnd == 0) && (txtarea.selectionStart | txtarea.selectionStart == 0))
	{ 
		mozInsert(txtarea, text, "");
		return;
// End add - BBCodes & smilies enhancement MOD
# 
#-----[ FIND ]------------------------------------------------ 
#
// Start add - BBCodes & smilies enhancement MOD
			if (txtarea.createTextRange && txtarea.caretPos) {
				var caretPos = txtarea.caretPos;
				var text = bbopen + bbclose;
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
			} else
// End add - BBCodes & smilies enhancement MOD

# 
#-----[ REPLACE WITH ]----------------------------------------
#
# The baseHeight test is copyright (C) TerraFrost
# http://www.frostjedi.com
#
// Start add - BBCodes & smilies enhancement MOD
			if (txtarea.createTextRange && txtarea.caretPos) {
				if (baseHeight != txtarea.caretPos.boundingHeight) {
					txtarea.focus();
					storeCaret(txtarea);
				}
				var caretPos = txtarea.caretPos;
				var text = bbopen + bbclose;
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
			} else
// End add - BBCodes & smilies enhancement MOD
# 
#-----[ FIND ]------------------------------------------------ 
#
// Start replacement - BBCodes & smilies enhancement MOD
	else if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0))
	{
		mozInsert(txtarea, bbopen, bbclose);
// End replacement - BBCodes & smilies enhancement MOD

# 
#-----[ REPLACE WITH ]----------------------------------------
#
// Start replacement - BBCodes & smilies enhancement MOD
	else if ((txtarea.selectionEnd | txtarea.selectionEnd == 0) && (txtarea.selectionStart | txtarea.selectionStart == 0))
	{
		mozInsert(txtarea, bbopen, bbclose);
// End replacement - BBCodes & smilies enhancement MOD
# 
#-----[ FIND ]------------------------------------------------ 
#
// Start add - BBCodes & smilies enhancement MOD
			if (txtarea.createTextRange && txtarea.caretPos) {
				var caretPos = txtarea.caretPos;
				var text = bbtags[butnumber + 1];
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
			} else
			if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0))
			{ 
				mozInsert(txtarea, bbtags[butnumber + 1], "");
			} else
// End add - BBCodes & smilies enhancement MOD

# 
#-----[ REPLACE WITH ]----------------------------------------
#
# The baseHeight test is copyright (C) TerraFrost
# http://www.frostjedi.com
#
// Start add - BBCodes & smilies enhancement MOD
			if (txtarea.createTextRange && txtarea.caretPos) {
				if (baseHeight != txtarea.caretPos.boundingHeight) {
					txtarea.focus();
					storeCaret(txtarea);
				}
				var caretPos = txtarea.caretPos;
				var text = bbtags[butnumber + 1];
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
			} else
			if ((txtarea.selectionEnd | txtarea.selectionEnd == 0) && (txtarea.selectionStart | txtarea.selectionStart == 0))
			{ 
				mozInsert(txtarea, bbtags[butnumber + 1], "");
			} else
// End add - BBCodes & smilies enhancement MOD
# 
#-----[ FIND ]------------------------------------------------ 
#
// Start add - BBCodes & smilies enhancement MOD
				if (txtarea.createTextRange && txtarea.caretPos) {
					var caretPos = txtarea.caretPos;
					var text = bbtags[butnumber + 1];
					caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
				} else
				if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0))
				{ 
					mozInsert(txtarea, bbtags[butnumber + 1], "");
				} else
// End add - BBCodes & smilies enhancement MOD

# 
#-----[ REPLACE WITH ]----------------------------------------
#
# The baseHeight test is copyright (C) TerraFrost
# http://www.frostjedi.com
#
// Start add - BBCodes & smilies enhancement MOD
				if (txtarea.createTextRange && txtarea.caretPos) {
					if (baseHeight != txtarea.caretPos.boundingHeight) {
						txtarea.focus();
						storeCaret(txtarea);
					}
					var caretPos = txtarea.caretPos;
					var text = bbtags[butnumber + 1];
					caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
				} else
				if ((txtarea.selectionEnd | txtarea.selectionEnd == 0) && (txtarea.selectionStart | txtarea.selectionStart == 0))
				{ 
					mozInsert(txtarea, bbtags[butnumber + 1], "");
				} else
// End add - BBCodes & smilies enhancement MOD
# 
#-----[ FIND ]------------------------------------------------ 
#
// Start add - BBCodes & smilies enhancement MOD
			if (txtarea.createTextRange && txtarea.caretPos) {
				var caretPos = txtarea.caretPos;
				var text = bbtags[15];
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
			} else
			if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0))
			{ 
				mozInsert(txtarea, bbtags[15], "");
			} else
// End add - BBCodes & smilies enhancement MOD

# 
#-----[ REPLACE WITH ]----------------------------------------
#
# The baseHeight test is copyright (C) TerraFrost
# http://www.frostjedi.com
#
// Start add - BBCodes & smilies enhancement MOD
			if (txtarea.createTextRange && txtarea.caretPos) {
				if (baseHeight != txtarea.caretPos.boundingHeight) {
					txtarea.focus();
					storeCaret(txtarea);
				}
				var caretPos = txtarea.caretPos;
				var text = bbtags[15];
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
			} else
			if ((txtarea.selectionEnd | txtarea.selectionEnd == 0) && (txtarea.selectionStart | txtarea.selectionStart == 0))
			{ 
				mozInsert(txtarea, bbtags[15], "");
			} else
// End add - BBCodes & smilies enhancement MOD
# 
#-----[ FIND ]------------------------------------------------ 
#
// Start add - BBCodes & smilies enhancement MOD
		if (bbnumber == 16) {
			var errors = '';
			var url = prompt("{L_BBCODE_URL}", "http://");
			var title = prompt("{L_BBCODE_URL_TITLE}", "");
			if (!url) {
				errors += "\n" + "{L_BBCODE_URL_EMPTY}";
			}
			if (!title) {
				errors += "\n" + "{L_BBCODE_URL_TITLE_EMPTY}";
			}
			if (errors) {
				alert("{L_BBCODE_URL_ERRORS}" + "\n" + errors);
				return;
			}

			var text = "[url=" + url + "]" + title + "[/url]";
			if (txtarea.createTextRange && txtarea.caretPos) {
				var caretPos = txtarea.caretPos;
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
			} else
			if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0))
			{ 
				mozInsert(txtarea, text, "");
			} else txtarea.value += text;
		} else {
			var text = bbtags[bbnumber];
			if (txtarea.createTextRange && txtarea.caretPos) {
				var caretPos = txtarea.caretPos;
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
			} else
			if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0))
			{ 
				mozInsert(txtarea, bbtags[bbnumber], "");
			} else
// End add - BBCodes & smilies enhancement MOD

# 
#-----[ REPLACE WITH ]----------------------------------------
#
# The baseHeight test is copyright (C) TerraFrost
# http://www.frostjedi.com
#
// Start add - BBCodes & smilies enhancement MOD
		if (bbnumber == 16) {
			var url = prompt("{L_BBCODE_URL}", "http://");

			if (url == null) {
				return;
			} else if (!url) {
				alert("{L_BBCODE_URL_ERRORS}" + "\n" + "\n" + "{L_BBCODE_URL_EMPTY}");
				return;
			} else {
				var title = prompt("{L_BBCODE_URL_TITLE}", "");

				if (title == null) {
					return;
				} else if (!title) {
					var text = "[url]" + url + "[/url]";
				} else {
					var text = "[url=" + url + "]" + title + "[/url]";
				}
			}

			if (txtarea.createTextRange && txtarea.caretPos) {
				if (baseHeight != txtarea.caretPos.boundingHeight) {
					txtarea.focus();
					storeCaret(txtarea);
				}
				var caretPos = txtarea.caretPos;
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
			} else
			if ((txtarea.selectionEnd | txtarea.selectionEnd == 0) && (txtarea.selectionStart | txtarea.selectionStart == 0))
			{ 
				mozInsert(txtarea, text, "");
			} else txtarea.value += text;
		} else {
			var text = bbtags[bbnumber];
			if (txtarea.createTextRange && txtarea.caretPos) {
				if (baseHeight != txtarea.caretPos.boundingHeight) {
					txtarea.focus();
					storeCaret(txtarea);
				}
				var caretPos = txtarea.caretPos;
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
			} else
			if ((txtarea.selectionEnd | txtarea.selectionEnd == 0) && (txtarea.selectionStart | txtarea.selectionStart == 0))
			{ 
				mozInsert(txtarea, bbtags[bbnumber], "");
			} else
// End add - BBCodes & smilies enhancement MOD
# 
#-----[ OPEN ]------------------------------------------------ 
#
templates/subSilver/posting_smilies.tpl

# 
#-----[ FIND ]------------------------------------------------ 
#
// Start replacement - BBCodes & smilies enhancement MOD
function emoticon(text) {
	var txtarea = opener.document.forms['post'].message;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		txtarea.focus();
	} else
	if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0))
	{ 
		mozInsert(txtarea, text, "");
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

function mozInsert(txtarea, openTag, closeTag)
{
        if (txtarea.selectionEnd > txtarea.value.length) { txtarea.selectionEnd = txtarea.value.length; } 
       
        var startPos = txtarea.selectionStart; 
        var endPos = txtarea.selectionEnd+openTag.length; 
       
        txtarea.value=txtarea.value.slice(0,startPos)+openTag+txtarea.value.slice(startPos); 
        txtarea.value=txtarea.value.slice(0,endPos)+closeTag+txtarea.value.slice(endPos); 
         
        txtarea.selectionStart = startPos+openTag.length; 
        txtarea.selectionEnd = endPos; 
        txtarea.focus(); 
}
// End replacement - BBCodes & smilies enhancement MOD

# 
#-----[ REPLACE WITH ]----------------------------------------
#
# The baseHeight test is copyright (C) TerraFrost
# http://www.frostjedi.com
#
// Start replacement - BBCodes & smilies enhancement MOD
function emoticon(text) {
	var txtarea = opener.document.forms['post'].message;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		if (opener.baseHeight != txtarea.caretPos.boundingHeight) {
			txtarea.focus();
			opener.storeCaret(txtarea);
		}
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		txtarea.focus();
	} else
	if ((txtarea.selectionEnd | txtarea.selectionEnd == 0) && (txtarea.selectionStart | txtarea.selectionStart == 0))
	{ 
		mozInsert(txtarea, text, "");
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

function mozInsert(txtarea, openTag, closeTag)
{
        if (txtarea.selectionEnd > txtarea.value.length) { txtarea.selectionEnd = txtarea.value.length; } 
       
        var startPos = txtarea.selectionStart; 
        var endPos = txtarea.selectionEnd+openTag.length; 
       
        txtarea.value=txtarea.value.slice(0,startPos)+openTag+txtarea.value.slice(startPos); 
        txtarea.value=txtarea.value.slice(0,endPos)+closeTag+txtarea.value.slice(endPos); 
         
        txtarea.selectionStart = startPos+openTag.length; 
        txtarea.selectionEnd = endPos; 
        txtarea.focus(); 
}
// End replacement - BBCodes & smilies enhancement MOD
# 
#-----[ SAVE/CLOSE ALL FILES ]-------------------------------- 
# 
# EoM