Kod: Tümünü seç
###############################################################################################
## MOD İSMİ: Visual Basic Syntax Highlighter BBCode
## MOD VERSİYONU: 1.0.1
##
## YAPIMCISI: AvisSoft < tapan@maxvb.com > (Tapan Bhanot) http://www.maxvb.com
## AÇIKLAMASI: This mod creates a new BBCode, "[vb]your_code[/vb]". It simply
## takes the code and uses a custom highlighting function and makes a pretty, color
## coded presentation of your code. The function has several enhancements which makes
## it more intelligent like:
##
## * Case Detection of Reserved Keywords.
## * Improved algorithm.
## * More keywords supported than any other vb code tag available.
## * Advanced Variable Detection.
##
## Compatibility Issues & Notes:
## This mod has been tested on a moded phpbb 2.0.10 and is working fine. You can check
## the mod in action at http://www.maxvb.com and no issues have been found till now.
##
## Installation Level: Easy
## Installation Time: 5-10 Minutes
##
## Files To Edit: posting.php
## includes/bbcode.php
## language/lang_YOUR_LANGUAGE/lang_main.php
## templates/YOUR_TEMPLATE_NAME/bbcode.tpl
## templates/YOUR_TEMPLATE_NAME/posting_body.tpl
## templates/YOUR_TEMPLATE_NAME/overall_header.tpl
##
## Included Files: N/A
###############################################################################################
## This MOD is released under the GPL License.
## Intellectual Property is retained by the MOD Author(s) listed above
###############################################################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/
###############################################################################################
##
## Author Note:
## Large chunks of VB code within the tags will signigicantly slow down the page,
## since the custom function has to do a lot of search and replacing. But overall the
## mod is stable and does not really slows down the bb.
##
###############################################################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
###############################################################################################
#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------
#
$bbcode_tpl['code_open'] = str_replace('{L_CODE}', $lang['Code'], $bbcode_tpl['code_open']);
#
#-----[ AFTER, ADD ]------------------------------------------
#
$bbcode_tpl['vb_open'] = str_replace('{L_VB}', $lang['VBCode'], $bbcode_tpl['vb_open']); // VB MOD
#
#-----[ FIND ]------------------------------------------
#
// [code] and
$text = bbencode_second_pass_code($text, $uid, $bbcode_tpl);
#
#-----[ AFTER, ADD ]------------------------------------------
#
// VB MOD
// [VB] and [/VB] for posting PHP code in your posts.
$text = bbencode_second_pass_vb($text, $uid, $bbcode_tpl);
#
#-----[ FIND ]------------------------------------------
#
//
Kod: Tümünü seç
and
$text = bbencode_first_pass_pda($text, $uid, '
Kod: Tümünü seç
', '
#
#-----[ AFTER, ADD ]------------------------------------------
#
// VB MOD
// [VB] and [/VB] for posting PHP code in your posts.
$text = bbencode_first_pass_pda($text, $uid, '[vb]', '[/vb]', '', true, '');
#
#-----[ FIND ]------------------------------------------
#
} // bbencode_second_pass_code()
#
#-----[ AFTER, ADD ]------------------------------------------
#
/*
* Visual Basic Syntax Highlighter BBCode
* ======================================
* vb_highlight_string($str)
* - All parameters required
* - Returns a string
*
* Takes a string and color codes it to VB's syntax.
* BEWARE! This CAN and WILL slow down page generation times! At least with large chunks of code.
*
* NOTE: DO NOT REORDER UNLESS YOU KNOW WHAT YOU'RE DOING
*/
function vb_highlight_string($str)
{
// VB Words Color
$color['comment'] = '#008800';
$color['default'] = '#000000';
$color['reserved'] = '#000088';
$color['string'] = '#000000';
// VB Words Array
$vb=array("#Const","#If","Abs","Add","Alias","And","Any","AppActivate","Array","As","Asc","Atn","Base","Beep",
"Boolean","Byte","ByVal","CBool","CByte","CCur","CDBl","CDate","CDec","CInt","CLng","CSng","CStr","CVErr","CVar",
"Call","Case","ChDir","ChDrive","Chr","Clear","Close","Collection","Command","Compare","Const","Cos","CreateObject",
"CurDir","Currency","DDB","Date","DateAdd","DateDiff","DatePart","DateSerial","DateValue","Day","Debug","Declare",
"DefBool","DefByte","DefCur","DefDate","DefDbl","DefDec","DefInt","DefLng","DefObj","DefSng","DefStr","DefVar",
"DeleteSetting","Dim","Dir","Do","DoEvents","Double","EOF","Each","Else","ElseIf","End","Endif","Environ",
"Eqv","Erase","Err","Error","Exit","Exp","Explicit","False","FV","FileAttr","FileCopy","FileDateTime","FileLen",
"Filelen","Fix","For","Format","Function","Get","GetAllSettings","GetAttr","GetObject","GetSetting","Global","GoSub",
"GoTo","Hex","Hour","IIR","IPmt","If","Imp","In","InStr","Input #","Int","Integer","Is","IsArray","IsDate",
"IsEmpty","IsError","IsMissing","IsNull","IsNumeric","IsObject","Item","Kill","LBound","LCase","LOF","LSet","LTrim",
"Left","Len","Let","Lib","Like","Line Input #","Loc","Lock","Log","Long","Loop","MIRR","Me","Mid","Minute","MkDir",
"Mod","Module","Month","MsgBox","NPV","NPer","Name","New","Next","Not","Now","Object","Oct","On","Open","Option","Or",
"PPmt","PV","Pmt","Print","Print #","Private","Property","Public","Put","QBColor","RGB","RSet","RTrim","Raise",
"Randomize","Rate","ReDim","Remove","Reset","Resume","Return","Right","RmDir","Rnd","SLN","SYD","SaveSetting",
"Second","Seek","Select","SendKeys","Set","SetAttr","Sgn","Shell","Sin","Single","Space","Spc","Sqr","Static","Step",
"Stop","Str","StrComp","StrConv","String","Sub","Switch","Tab","Tan","Then","Time","TimeSerial","TimeValue","Timer",
"To","Trim","True", "Type","TypeName","UBound","UCase","Unlock","Until","Val","VarType","Variant","Weekday","Wend",
"While","Width #","With","Write #","Xor","Year","Optional","InStrRev","Replace","Split","Join");
$val = "";
$gretext = "";
$lines = explode("\n", $str);
if (count($lines) == "1") {
// Green highlighting for 1 line only!
$quoteplace = substr($lines[0], 0, 1);
if ($quoteplace == "'")
{
$beforequote = substr($lines[0], 0, $quoteplace);
$afterquote="<font class=\"vbcode\" color=\"#007F00\">".substr($lines[0],$quoteplace)."</font>";
$codebit=$beforequote;
$gretext .= $beforequote . $afterquote;
$afterquote = "";
$codebit = $lines[0];
}
else
{
$gretext .= $lines[0];
}
}
else
{
// Green highlighting for multiple lines!
while (list($brr, $line) = each($lines))
{
if (substr(trim($line), 0, 1) == "'")
{
$line = "<font class=\"vbcode\" color=\"#007F00\">$line</font>";
$gretext .= $line;
}
else
{
$quoteplace = strrpos($line, "'");
if ($quoteplace > 0)
{
$beforequote = substr($line, 0, $quoteplace);
$afterquote="<font class=\"vbcode\" color=\"#007F00\">".substr($line,$quoteplace)."</font>";
$codebit=$beforequote;
$gretext .= $beforequote . $afterquote;
$afterquote = "";
$codebit = $line;
}
else
{
$afterquote = "";
$codebit = $line;
$gretext .= $line;
}
}
}
}
$str = $gretext;
// Do some magic
$str = eregi_replace ("\n", " || ", $str);
$str = eregi_replace ("\r", " || ", $str);
// Split Word by Word
$words = explode(" ", $str);
$found = "";
$newtext = "";
for ($y = 0; $y < count($words); $y++) {
$getuserword = $words[$y];
for ($x = 0; $x < count($vb); $x++) {
$getvbword = $vb[$x];
if (strtolower($getvbword) == strtolower($getuserword))
{
$found = "true";
$newtext .= " " . eregi_replace ($vb[$x], '<font class="vbcode" color="' . $color['reserved'] . '">' . $vb[$x] . '</font>', $words[$y]);
}
}
if ($found == "")
{
// Finally We give Up!
$newtext .= " " . $words[$y];
}
$found = "";
}
// Remove magic and some stuff we done earlier
$newtext = str_replace(' || ', '<br>', $newtext);
// Start VB Output
return trim($newtext);
}
/*
* VB MOD
* Does second-pass bbencoding of the [vb] tags. This includes
* running htmlspecialchars() over the text contained between
* any pair of [vb] tags that are at the first level of
* nesting. Tags at the first level of nesting are indicated
* by this format: [vb:1:$uid] ... [/vb:1:$uid]
* Other tags are in this format: [vb:$uid] ... [/vb:$uid]
*
* Original code/function by phpBB Group
* Modified by JW Frazier / Fubonis < php@fubonis.com >
*/
function bbencode_second_pass_vb($text, $uid, $bbcode_tpl)
{
global $lang;
$html_entities_match = array("#<#", "#>#");
$html_entities_replace = array("<", ">");
$code_start_html = $bbcode_tpl['vb_open'];
$code_end_html = $bbcode_tpl['vb_close'];
// First, do all the 1st-level matches. These need an htmlspecialchars() run,
// so they have to be handled differently.
$match_count = preg_match_all("#\[vb:1:$uid\](.*?)\[/vb:1:$uid\]#si", $text, $matches);
for ($i = 0; $i < $match_count; $i++)
{
$before_replace = $matches[1][$i];
$after_replace = $matches[1][$i];
$after_replace = preg_replace($html_entities_match, $html_entities_replace, $after_replace);
// Replace 2 spaces with " " so non-tabbed code indents without making huge long lines.
$after_replace = str_replace(" ", " ", $after_replace);
// now Replace 2 spaces with " " to catch odd #s of spaces.
$after_replace = str_replace(" ", " ", $after_replace);
// Replace tabs with " " so tabbed code indents sorta right without making huge long lines.
$after_replace = str_replace("\t", " ", $after_replace);
$str_to_match = "[vb:1:$uid]" . $before_replace . "[/vb:1:$uid]";
$replacement = $code_start_html;
$after_replace = vb_highlight_string($after_replace);
$replacement .= $after_replace;
$replacement .= $code_end_html;
$text = str_replace($str_to_match, $replacement, $text);
}
// Now, do all the non-first-level matches. These are simple.
$text = str_replace("[vb:$uid]", $code_start_html, $text);
$text = str_replace("[/vb:$uid]", $code_end_html, $text);
return $text;
} // bbencode_second_pass_vb()
#
#-----[ OPEN ]------------------------------------------
#
templates/YOUR_TEMPLATE_NAME/bbcode.tpl
#
#-----[ FIND ]------------------------------------------
#
<!-- END email -->
#
#-----[ AFTER, ADD ]------------------------------------------
#
<!-- BEGIN vb_open -->
</span>
<blockquote>
<span class="genmed">visual basic code:</span>
<hr>
<span class="vbcode">
<BASEFONT FACE="Courier New" SIZE="2">
<!-- END vb_open -->
<!-- BEGIN vb_close -->
</BASEFONT>
</span>
<hr>
</blockquote>
<span class="postbody">
<!-- END vb_close -->
#
#-----[ OPEN ]------------------------------------------
#
templates/YOUR_TEMPLATE_NAME/posting_body.tpl
#
#-----[ FIND ]------------------------------------------
#
f_help = "{L_BBCODE_F_HELP}";
#
#-----[ AFTER, ADD ]------------------------------------------
#
v_help = "{L_BBCODE_V_HELP}";
#
#-----[ FIND ]------------------------------------------
#
bbtags = new Array('','','','','','','[quote]','[/quote]','
Kod: Tümünü seç
','
- ','
- ','
#
#-----[ REPLACE WITH ]------------------------------------------
#
bbtags = new Array('','','','','','','[quote]','[/quote]','
Kod: Tümünü seç
','
- ','
- ','
#
#-----[ FIND ]------------------------------------------
#
<td><span class="genmed">
<input type="button" class="button" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onClick="bbstyle(16)" onMouseOver="helpline('w')" />
</span></td>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<td><span class="genmed">
<input type="button" class="button" accesskey="h" name="addbbcode18" value="VB" style="width: 40px" onClick="bbstyle(18)" onMouseOver="helpline('h')" />
</span></td>
#
#-----[ FIND ]------------------------------------------
#
<select name="addbbcode18" onChange="bbfontstyle('[color=' + this.form.addbbcode18.options[this.form.addbbcode18.selectedIndex].value + ']', '[/color]');this.selectedIndex=0;" onMouseOver="helpline('s')">
#
#-----[ REPLACE WITH ]------------------------------------------
#
<select name="addbbcode20" onChange="bbfontstyle('[color=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/color]');this.selectedIndex=0;" onMouseOver="helpline('s')">
#
#-----[ FIND ]------------------------------------------
#
<select name="addbbcode20" onChange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">
#
#-----[ REPLACE WITH ]------------------------------------------
#
<select name="addbbcode22" onChange="bbfontstyle('[size=' + this.form.addbbcode22.options[this.form.addbbcode22.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">
#
#-----[ ACTION: OPEN ]------------------------------------------
#
/language/lang_YOUR_LANGUAGE/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
$lang['bbcode_f_help'] = 'Font size: [size=x-small]small text[/size]';
#
#-----[ AFTER, ADD]------------------------------------------
#
$lang['bbcode_v_help'] = 'VB syntax highlighter. [vb]VB code[/vb] (alt+h)'; // VB MOD
#
#-----[ ACTION: OPEN ]------------------------------------------
#
posting.php
#
#-----[ FIND ]------------------------------------------
#
'L_BBCODE_F_HELP' => $lang['bbcode_f_help'],
#
#-----[ AFTER, ADD]------------------------------------------
#
'L_BBCODE_V_HELP' => $lang['bbcode_v_help'], // VB MOD
#
#-----[ ACTION: OPEN ]------------------------------------------
#
# Just edit whichever you use for css. I use subSilver.css
# instead of overall_header.tpl. If you use subSilver.css then
# specify subSilver.css instead of overall_header.tpl
templates/YOUR_TEMPLATE_NAME/overall_header.tpl
#
#-----[ FIND ]------------------------------------------
#
/* Quote & Code blocks */
.code {
...
...
...
}
#
#-----[ AFTER, ADD]------------------------------------------
#
.vbcode {
font-family: 'Courier New'; font-size: 12px;
}
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
[/code]