Solution for AUTOMATIC SCRIPT TABBING inside forum posts.
Release date: November 12, 2005.
Last update: March 17, 2008.
miniBB version: 2.0 RC6 (tested on but may work on earlier releases as well)
SQL server: [Not required]
Author: Sergei Larionov (minibb.com).


This is a solution for automatic code tabbing in miniBB posts. It adds a new BBcode
[script]....[/script] - everything in between these tags will be tabbed automatically
based on { ... } so called "begin" and "end" programming language constructs.

$post_word_maxlength (the variable from the setup_options.php file used to determine the maximum word
length) based wordwrapping will be applied to everything inside the tabbed script paragraph. Lines longer
than the $post_word_maxlength value will be splitted!

PS The algorithm is simple - it adds spaces/tabs once a { symbol is found on the line and deducts spaces
once the } symbol is found. Of course, the algorithm could be more precise and complicated, but we wanted
it simple. Any suggestions on how to make this thing more "intelligent" without dramatical performance
decrease are welcome.


==INSTALLATION & SETUP==

1) Edit bb_plugins.php file, at the top of the file pasting the code provided under bb_plugins.code.txt.

!!Note: in the function above $GLOBALS['post_word_maxlength'] is used to split long text lines, ie for
for so called wordwrapping - so the value of this variable will affect the amount of wordwrapping in your 
tabbed script paragraph.

2) Modify the file bb_codes.php file adding the codes provided under bb_codes.encode.txt and bb_codes.decode.txt. The code under bb_codes.encode.txt should be pasted in the function enCodeBB before the line which says

$msg=preg_replace($pattern, $replacement, $msg);

The code under bb_codes.decode.txt should be pasted in the function deCodeBB before the aforementioned line.

3) Now it's time to edit the board's CSS file and add the jscript class there - which as you can see we're using
to separate the code in posts. Example of such CSS class could be found under css.code.txt.

Add it anywhere in the bb_default_style.css file or any other CSS file you're using in the main forums directory.
You can add it to the very bottom of the file for example.

4) Now we need to make appropriate button in the main_post_form.html template.

Open the main_post_form.html template and add the javascript/HTML code provided under main_post_form.code.txt; most likely it should be added in the place where other BB buttons are coming.

5) Copy the button_script.gif icon from the solution archive to your forums/img directory.


==FINALLY==
Enjoy using miniBB! Our live forums will help you in any question regarding it:
http://www.minibb.com/forums/11_3823_0.html
