Modification Name: BB Code: iFrame Function v1.0

Modification Author: GuldantheWarlock (GuldantheWarlock@xmbgarage.com)

Original Code by: Unknown

Last Updated: 03/02/10

Modification Description:
This modification will allow you to use a BB Code iFrame function in posts.
This modification will insert a web page via an iFrame in your posts.

Supported Version: XMB 1.9.8 SP3

Notes:

This modification is released under the GPL. You should have recieved a copy of it with this software package.

Please backup your files before installing this modification. Neither XMBGarage nor the author can be held responsible if your board stops functioning properly due to you installing this modification.

=======================================================================================================
=======
Step 1:
=======
=======================
Edit File: include/functions.php
=======================
==========
Find Code:
==========

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

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

    // BB Code: iFrame Function Mod Begin
    $patterns[] = '#\[iframe\](http[s]?|ftp[s]?){1}://([:a-z\\./_\-0-9%~]+){1}(\?[a-z=_\-0-9&;~]*)?\[/iframe\]#mi';
    $replacements[] = '<IFRAME src="\1://\2\3" frameborder="0" width="600" height="500"></IFRAME>';
    // BB Code: iFrame Function Mod End

=======================================================================================================
=======
Step 2:
=======
=====================
Edit File: js/bbcodefns-ie.js
=====================
==========
Find Code:
==========

function storeCaret(textEl) {

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

// BB Code: iFrame Function Mod Begin
function iframe() {
    if (helpmode) {
        alert(bbcode_help_iframe);
    } else if (advmode) {
        AddText('', '', "[iframe] [/iframe]", messageElement);
    } else {
        var txt = prompt(bbcode_prompt_iframe, "http://");
        if (txt != null) {
            AddText('', '', "[iframe]"+txt+"[/iframe]", messageElement);
        }
    }
}
// BB Code: iFrame Function Mod End

=======================================================================================================
=======
Step 3:
=======
========================
Edit File: js/bbcodefns-mozilla.js
========================
==========
Find Code:
==========

function storeCaret() {

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

// BB Code: iFrame Function Mod Begin
function iframe() {
    if (helpmode) {
        alert(bbcode_help_iframe);
    } else if (advmode) {
        if (hasSelection(messageElement)) {
            wrapText('[iframe]', '[/iframe]', messageElement);
        } else {
            AddText('[iframe]', '[/iframe]', ' ', messageElement);
        }

    } else {
        if (hasSelection(messageElement)) {
            var text = prompt(bbcode_prompt_iframe, fetchSelection(messageElement));
            if (text == fetchSelection(messageElement)) {
                wrapText('[iframe]', '[/iframe]', messageElement);
            } else {
                AddText('[iframe]', '[/iframe]', text, messageElement);
            }
        } else {
            var text = prompt(bbcode_prompt_iframe, 'http://');
            AddText('[iframe]', '[/iframe]', text, messageElement);
        }
    }
}
// BB Code: iFrame Function Mod End

=======================================================================================================
=======
Step 4:
=======
========================
Edit File: js/bbcodefns-opera.js
========================
==========
Find Code:
==========

function storeCaret(textEl) {

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

// BB Code: iFrame Function Mod Begin
function iframe() {
    if (helpmode) {
        alert(bbcode_help_iframe);
    } else if (advmode) {
        AddText('', '', "[iframe] [/iframe]", messageElement);
    } else {
        var txt = prompt(bbcode_prompt_iframe, "http://");
        if (txt != null) {
            AddText('', '', "[iframe]"+txt+"[/iframe]", messageElement);
        }
    }
}
// BB Code: iFrame Function Mod End

=======================================================================================================
=======
Step 4:
=======
==============================
Go to Administration Panel -> Templates
==============================
=========================
Edit Template: functions_bbcode
=========================
==========
Find Code:
==========

var bbcode_help_code = "$lang[bbcode_help_code]";
var bbcode_prompt_code = "$lang[bbcode_prompt_code]";

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

var bbcode_help_iframe = "$lang[bbcode_help_iframe]";
var bbcode_prompt_iframe = "$lang[bbcode_prompt_iframe]";

=======================================================================================================
=======
Step 5:
=======
==============================
Go to Administration Panel -> Templates
==============================
============================
Edit Template: 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:iframe()"><img src="$THEME[imgdir]/bb_iframe.gif" border="0" width="23" height="22" alt="$lang[cb_insert_iframe]" /></a></td>

=======================================================================================================
=======
Step 6:
=======
=======================
Edit File: lang/English.lang.php
=======================
=======================
Add To End Of File Above ?>
=======================

// BB Code: iFrame Function Mod Begin
$lang['bbcode_prompt_iframe'] = "Please enter the URL for the iFrame";
$lang['bbcode_help_iframe'] = "iFrame Tag\\nInserts a webpage into the post.Usage: [iframe]http://www.anywhere.com[/iframe]";
$lang['cb_insert_iframe'] = "Insert iFrame URL";
// BB Code: iFrame Function Mod End

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

Upload bb_iframe.gif from the 'Contents' folder to all your theme directories.

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