=======================================================================================================================================
Modification Title: BB Code: YouTube Player v1.2

Modification Author(s): Tularis, John Briggs

Modification Contributor: Tanner Ferguson, Curuncula

Modification Description: This modification will allow the use of inserting YouTube video within posts by means of BB Code.

Modification Copyright:  2007-2008 XMBMods.com. All rights reserved.

Modification Compatibility: XMB 1.9.8 SP3

Updated for 1.9.8 by: WormHole @ XMB Garage

Modification Install Note: Before adding this modification to your forum you should back up all files related to this modification.

Modification License Note: This modification is released under the GPL v3 License. A copy is provided with this software package.

Modification Author Note:
This modification is developed and released for use with XMB 1.9.8 SP3 which is provided by XMBGarage.com.

=======================================================================================================================================
=======
Step 1:
=======

=======================
Edit File: lang/English.lang.php
=======================

==========
Find Code:
==========

?>

===============
Add Code Above:
===============

// BB Code: YouTube Player Mod Begin
$lang['bbcode_help_youtube'] = "YouTube tag\\nAdds a YouTube movie.\\nUsage: [youtube]your YouTubemovie-id[/youtube]";
$lang['bbcode_prompt_youtube'] = "Please enter the YouTube movie-id of the movie you would like to link to.";
$lang['cb_insert_youtube'] = "Insert YouTube Movie Id";
// BB Code: YouTube Player Mod End

=======================================================================================================================================
=======
Step 2:
=======

=========================
Edit File: include/functions.inc.php
=========================

==========
Find Code:
==========

    $patterns[] = "#\[email=([^\"'<>]*?){1}([^\"]*?)\](.*?)\[/email\]#Smi";
    $replacements[] = '<a href="mailto:\1\2">\3</a>';

===============
Add Code Below:
===============

    // BB Code: YouTube Player Mod Begin
    $patterns[] = "#\[youtube]([a-zA-Z0-9_-]+)\[/youtube\]#Smi";
    $replacements[] = '<object width="425" height="350" class="youtube"><param name="movie" value="http://www.youtube.com/v/\1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/\1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
    // BB Code: YouTube Player Mod End

=======================================================================================================================================
=======
Step 3:
=======

===================================
Go To Administration Panel -> Templates -> css
===================================

==========
Find Code:
==========

.status_Member, .status_Banned {
    text-decoration: none;
    font-weight: normal;
    color: $tabletext;
    font-family: Verdana;
    font-size: 10px;
}

===============
Add Code Below:
===============

.youtube {
    background-color: transparent;
    border: none;
}

=======================================================================================================================================
=======
Step 4:
=======

=============================================
Go To Administration Panel -> Templates -> functions_bbcode
=============================================

==========
Find Code:
==========

var bbcode_prompt_underline = "$lang[bbcode_prompt_underline]";

===============
Add Code Below:
===============

var bbcode_help_youtube = "$lang[bbcode_help_youtube]";
var bbcode_prompt_youtube = "$lang[bbcode_prompt_youtube]";

=======================================================================================================================================
=======
Step 5:
=======

=================================================
Go To Administration Panel -> Templates -> functions_bbcodeinsert
=================================================

==========
Find Code:
==========

<a href="javascript:list()"><img src="$imgdir/bb_list.gif" border="0" width="23" height="22" alt="$lang[cb_insert_list]" /></a></td>

==================
Replace Code With:
==================

<a href="javascript:list()"><img src="$imgdir/bb_list.gif" border="0" width="23" height="22" alt="$lang[cb_insert_list]" /></a>
<a href="javascript:youtube()"><img src="$THEME[imgdir]/bb_youtube.gif" border="0" width="23" height="22" alt="$lang[cb_insert_youtube]" /></a></td>

=======================================================================================================================================
=======
Step 6:
=======

=====================
Edit File: js/bbcodefns-ie.js
=====================

==========
Find Code:
==========

function storeCaret(textEl) {

===============
Add Code Above:
===============

// BB Code: YouTube Player Mod Begin
function youtube() {
    if (helpmode) {
        alert(bbcode_help_youtube);
    } else if (advmode) {
        AddText('', '', "[youtube] [/youtube]", messageElement);
    } else {
        txt=prompt(bbcode_prompt_youtube,"movie-id");
        if (txt!=null) {
            AddText('', '', "\r[youtube]"+txt+"[/youtube]", messageElement);
        }
    }
}
// BB Code: YouTube Player Mod End

=======================================================================================================================================
=======
Step 7:
=======

========================
Edit File: js/bbcodefns-mozilla.js
========================

==========
Find Code:
==========

function storeCaret() {

===============
Add Code Above:
===============

// BB Code: YouTube Player Mod Begin
function youtube() {
    if (helpmode) {
        alert(bbcode_help_youtube);
    } else if (advmode) {
        if (hasSelection(messageElement)) {
            wrapText("\r\n"+'[youtube]', '[/youtube]'+"\r\n", messageElement);
        } else {
            AddText("\r\n"+'[youtube]', '[/youtube]'+"\r\n", ' ', messageElement);
        }
    } else {
        if (hasSelection(messageElement)) {
            text = prompt(bbcode_prompt_youtube, fetchSelection(messageElement));
            if (text == fetchSelection(messageElement)) {
                wrapText("\r\n"+'[youtube]', '[/youtube]'+"\r\n", messageElement);
            } else {
                AddText("\r\n"+'[youtube]', '[/youtube]'+"\r\n", text, messageElement);
            }
        } else {
            text = prompt(bbcode_prompt_youtube,"movie-id");
            AddText("\r\n"+'[youtube]', '[/youtube]'+"\r\n", text, messageElement);
        }
    }
}
// BB Code: YouTube Player Mod End

=======================================================================================================================================
=======
Step 8:
=======

========================
Edit File: js/bbcodefns-opera.js
========================

==========
Find Code:
==========

function storeCaret(textEl) {

===============
Add Code Below:
===============

// BB Code: YouTube Player Mod Begin
function youtube() {
    if (helpmode) {
        alert(bbcode_help_youtube);
    } else if (advmode) {
        AddText('', '', "[youtube] [/youtube]", messageElement);
    } else {
        txt=prompt(bbcode_prompt_youtube,"movie-id");
        if (txt!=null) {
            AddText('', '', "[youtube]"+txt+"[/youtube]", messageElement);
        }
    }
}
// BB Code: YouTube Player Mod End

=======================================================================================================================================
=======
Step 9:
=======

Upload provided generic image "bb_youtube.gif" to all your theme folders.

=======================================================================================================================================
Enjoy!