Title: BB Code: Hidden Text v1.0

Original Code by: John

Description: This modification will allow you to enter hidden text in a post via bbcode. It will not be viewable until a member replies to the post.

Compatability: 1.9.8 Engage Final SP3

Updated for 1.9.8 by: WormHole @ XMB Garage

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

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

Author Note: You downloaded this modification from XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com for support.

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

        $message = implode("", $messagearray);

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

        // BB Code: Hidden Text Mod Begin
        global $xmbuser, $table_posts, $tid, $lang;
        $query= $db->query("SELECT count(author) FROM ".X_PREFIX."posts WHERE tid='$tid' and author='$xmbuser'");
        $num = $db->result($query,0);
        if ($num==0) {
            $message = eregi_replace("\\[hide\\]([^\\[]*)\\[/hide\\]","<div class='hidden'>[<strong>$lang[textdetect]</strong>]</div>", $message);
        }else{
            $message = eregi_replace("\\[hide\\]([^\\[]*)\\[/hide\\]","<div class='hidden'>[<strong>$lang[textstart]</strong>]</div><br />\\1<br /><br /><div class='hidden'>[<strong>$lang[textend]</strong>]</div>", $message);
        }
        // BB Code: Hidden Text Mod End

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

function storeCaret(textEl) {

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

// BB Code: Hidden Text Mod Begin
function hide() {
    if (helpmode) {
        alert(bbcode_help_hide);
    } else if (advmode) {
        AddText('', '', "[hide]"+document.selection.createRange().text+"[/hide]", messageElement);
    } else {
        txt=prompt(bbcode_prompt_hide,"Text");
        if (txt!=null) {
            AddText('', '', "[hide]"+txt+"[/hide]", messageElement);
        }
    }
}
// BB Code: Hidden Text Mod End

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

function storeCaret(textEl) {

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

// BB Code: Hidden Text Mod Begin
function hide() {
    if (helpmode) {
        alert(bbcode_help_hide);
    } else if (advmode) {
        AddText('', '', "[hide]"+document.selection.createRange().text+"[/hide]", messageElement);
    } else {
        txt=prompt(bbcode_prompt_hide,"Text");
        if (txt!=null) {
            AddText('', '', "[hide]"+txt+"[/hide]", messageElement);
        }
    }
}
// BB Code: Hidden Text Mod End

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

function storeCaret() {

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

// BB Code: Hidden Text Mod Begin
function hide() {
    if (helpmode) {
        alert(bbcode_help_hide);

    } else if(advmode) {
        if (hasSelection(messageElement)) {
            wrapText('[hide]', '[/hide]', messageElement);
        } else {
            AddText('[hide]', '[/hide]', ' ', messageElement);
        }

    } else {
        if (hasSelection(messageElement)) {
            text = prompt(bbcode_prompt_hide, fetchSelection(messageElement));
            if (text == fetchSelection(messageElement)) {
                wrapText('[hide]', '[/hide]', messageElement);
            } else {
                AddText('[hide]', '[/hide]', text, messageElement);
            }
        } else {
            text = prompt(bbcode_prompt_hide, 'Hidden Text');
            AddText('[hide]', '[/hide]', text, messageElement);
        }
    }
}
// BB Code: Hidden Text Mod End

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

// BB Code: Hidden Text Mod Begin
$lang['bbcode_help_hide'] = "Hide Tag\\nMakes the enlosed text hidden.\\nUsage: [hide]This is some hidden text[/hide]";
$lang['bbcode_prompt_hide'] = "Please enter the text that should be hidden.";
$lang['cb_insert_hide'] = "Insert Hidden text";
$lang['textdetect'] = "Hidden Text Detected. You have to post a reply to see it";
$lang['textstart'] = "Start Hidden Text";
$lang['textend'] = "End Hidden Text";
// BB Code: Hidden Text Mod End

=======================================================================================================================================
=======
Step 6:
=======
==============================
Go to administration panel -> Templates
==============================
=========================
Edit Template: functions_bbcode
=========================
==========
Find Code:
==========

var messageElement;

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

var bbcode_help_hide = "$lang[bbcode_help_hide]";
var bbcode_prompt_hide = "$lang[bbcode_prompt_hide]";

=======================================================================================================================================
=======
Step 7:
=======
==============================
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:hide()"><img src="$THEME[imgdir]/bb_hide.gif" border="0" width="23" height="22" alt="$lang[cb_insert_hide]" /></a></td>

=======================================================================================================================================
=======
Step 8:
=======
==============================
Go to administration panel -> Templates
==============================
===============
Edit Template: css
===============
==========
Find Code:
==========

/*]]>*/
</style>

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

.hidden {
    color: #FF0000;
    font-family: $font;
    font-size: $fontsize;
    font-weight: normal;
    table-layout: fixed;
}

=======================================================================================================================================

======
Step 9:
======
===============
Edit File: post.php
===============
==========
Find Code:
==========

    global $imgdir, $bbinsert, $altbg1, $altbg2, $lang, $SETTINGS, $spelling_lang;

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

    global $imgdir, $bbinsert, $altbg1, $altbg2, $lang, $SETTINGS, $spelling_lang, $THEME;

=======================================================================================================================================

========
Step 10:
========

Upload the "bb_hide.gif" located in the Contents folder to your theme directory

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