##############################################################
##
## MOD Title:   bbGeSHi - a better syntax highlighter
## MOD Author:  DarrenSW <darren@phpportalen.net> (Darren J) http://www.phpportalen.net
## MOD Description:
##   Replaces phpBB's own highlighter with GeSHi syntax highlighter.
##
##   Use it like this
##       [code=SYNTAX_NAME]...[/code]
##   Or
##       [SYNTAX_NAME]...[/SYNTAX_NAME]
##
##   This MOD uses a modified version of the latest stable* GeSHi release 1.0.7.20.
##   GeSHi and information about it can be found at http://qbnz.com/highlighter/
##
##   * as of 14 July 2007
##
## MOD Version: 0.7.5
##
##############################################################
#
#-----[ COPY ]------------------------------------------
#
COPY bbGeSHi.css      TO  phpbb_root_path/styles/prosilver/theme/bbGeSHi.css
#
#-----[ OPEN ]------------------------------------------
#
includes/geshi.php
#
#-----[ FIND ]------------------------------------------
#
                        //$attr = ' style="' . $this->line_style2 . '"';
                        $attrs['style'][] = $this->line_style2;
#
#-----[ REPLACE WITH ]------------------------------------------
#
                        //$attr = ' style="' . $this->line_style2 . '"';
                        $attrs['style'][] = $this->line_style2;
                        $attrs['class'][] = 'li2';
#
#-----[ FIND ]------------------------------------------
#
                        //$attr = ' style="' . $this->line_style1 . '"';
                        $attrs['style'][] = $this->line_style1;
#
#-----[ REPLACE WITH ]------------------------------------------
#
                        //$attr = ' style="' . $this->line_style1 . '"';
                        $attrs['style'][] = $this->line_style1;
                        $attrs['class'][] = 'li1';
#
#-----[ OPEN ]------------------------------------------
#
includes/message_parser.php
#
#-----[ FIND ]-------------------------------------------------
#
		// This array holds all bbcode data. BBCodes will be processed in this
		// order, so it is important to keep [code] in first position and
		// [quote] in second position.
		$this->bbcodes = array(
#
#-----[ REPLACE WITH ]-------------------------------------------------
#
		// This array holds all bbcode data. BBCodes will be processed in this
		// order, so it is important to keep [code] in first position and
		// [quote] in second position.
		$this->bbcodes = array(
			'geshi'			=> array('bbcode_id' => 99,	'regexp' => array('#\[(abap|actionscript|ada|apache|applescript|asm|asp|autoit|bash|blitzbasic|bnf|c|caddcl|cadlisp|cfdg|cfm|cpp-qt|cpp|csharp|css|c_mac|d|delphi|diff|div|dos|dot|eiffel|fortran|freebasic|genero|gml|groovy|haskell|html|html4strict|idl|ini|inno|io|java|java5|js|latex|lisp|lua|m68k|matlab|mirc|mpasm|mysql|nsis|objc|ocaml-brief|ocaml|oobas|oracle8|pascal|per|perl|php-brief|php|plsql|python|qbasic|rails|reg|robots|ruby|sas|scheme|sdlbasic|smalltalk|smarty|sql|tcl|text|thinbasic|tsql|vb|vbnet|vhdl|visualfoxpro|winbatch|xml|xpp|xsl|z80)\](.+\[/(abap|actionscript|ada|apache|applescript|asm|asp|autoit|bash|blitzbasic|bnf|c|caddcl|cadlisp|cfdg|cfm|cpp-qt|cpp|csharp|css|c_mac|d|delphi|diff|div|dos|dot|eiffel|fortran|freebasic|genero|gml|groovy|haskell|html|html4strict|idl|ini|inno|io|java|java5|js|latex|lisp|lua|m68k|matlab|mirc|mpasm|mysql|nsis|objc|ocaml-brief|ocaml|oobas|oracle8|pascal|per|perl|php-brief|php|plsql|python|qbasic|rails|reg|robots|ruby|sas|scheme|sdlbasic|smalltalk|smarty|sql|tcl|text|thinbasic|tsql|vb|vbnet|vhdl|visualfoxpro|winbatch|xml|xpp|xsl|z80)\])#ise' => "\$this->bbcode_geshi('[\$1]', '\$2')")),
#
#-----[ FIND ]-------------------------------------------------
#
'flash'			=> array('bbcode_id' => 11,	'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')")),
'geshi'			=> array('bbcode_id' => 99,	'regexp' => array('#\[(abap|actionscript|ada|apache|applescript|asm|asp|autoit|bash|blitzbasic|bnf|c|caddcl|cadlisp|cfdg|cfm|cpp-qt|cpp|csharp|css|c_mac|d|delphi|diff|div|dos|dot|eiffel|fortran|freebasic|genero|gml|groovy|haskell|html|html4strict|idl|ini|inno|io|java|java5|javascript|js|latex|lisp|lua|m68k|matlab|mirc|mpasm|mysql|nsis|objc|ocaml-brief|ocaml|oobas|oracle8|pascal|per|perl|php-brief|php|plsql|python|qbasic|rails|reg|robots|ruby|sas|scheme|sdlbasic|smalltalk|smarty|sql|tcl|text|thinbasic|tsql|vb|vbnet|vhdl|visualfoxpro|winbatch|xml|xpp|xsl|z80)\](.+\[/(abap|actionscript|ada|apache|applescript|asm|asp|autoit|bash|blitzbasic|bnf|c|caddcl|cadlisp|cfdg|cfm|cpp-qt|cpp|csharp|css|c_mac|d|delphi|diff|div|dos|dot|eiffel|fortran|freebasic|genero|gml|groovy|haskell|html|html4strict|idl|ini|inno|io|java|java5|javascript|js|latex|lisp|lua|m68k|matlab|mirc|mpasm|mysql|nsis|objc|ocaml-brief|ocaml|oobas|oracle8|pascal|per|perl|php-brief|php|plsql|python|qbasic|rails|reg|robots|ruby|sas|scheme|sdlbasic|smalltalk|smarty|sql|tcl|text|thinbasic|tsql|vb|vbnet|vhdl|visualfoxpro|winbatch|xml|xpp|xsl|z80)\])#ise' => "\$this->bbcode_geshi('[\$1]', '\$2')"))
#
#-----[ REPLACE WITH ]------------------------------------------
#
'flash'			=> array('bbcode_id' => 11,	'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')"))
#
#-----[ FIND ]---------------------------------------------------
#
	function bbcode_parse_geshi($stx, &$code){
		$code = $this->bbcode_highlight($code, $stx);
		return "[$stx:" . $this->bbcode_uid . ']' . $code . '[/' . $stx . ':' . $this->bbcode_uid . ']';
	}
#
#-----[ REPLACE WITH ]------------------------------------------
#
	function bbcode_parse_geshi($stx, &$code){
		$code = $this->bbcode_highlight($code, $stx);
		$code = str_replace('[code', '&#91;code', $code);
		return "[$stx:" . $this->bbcode_uid . ']' . $code . '[/' . $stx . ':' . $this->bbcode_uid . ']';
	}
#
#-----[ FIND ]---------------------------------------------------
#
	function bbcode_highlight($code, $stx)
	{
		$code = str_replace(array('&lt;', '&gt;'), array('<', '>'), $code);
		$code = htmlspecialchars_decode($code);

		$geshi = new GeSHi($code, $stx);

		$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);

		$line1 = 'padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;';
		$line2 = 'padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;';
		$geshi->set_line_style($line1, $line2);
		
		$geshi->set_header_type(GESHI_HEADER_DIV);
		$geshi->set_tab_width(4);
		$geshi->set_overall_id("{CB}");

		$result = $geshi->parse_code();
		return $result;
	}
#
#-----[ REPLACE WITH ]------------------------------------------
#
	function bbcode_highlight($code, $stx)
	{
		$code = str_replace(array('&lt;', '&gt;'), array('<', '>'), $code);
		$code = htmlspecialchars_decode($code);

		$geshi = new GeSHi($code, $stx);

		$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);
		$geshi->set_header_type(GESHI_HEADER_DIV);
		$geshi->set_tab_width(4);
		$geshi->set_overall_id("{CB}");

		$result = $geshi->parse_code();
		return $result;
	}
#
#-----[ OPEN ]--------------------------------------------------
#
languages/en/common.php
#
#-----[ FIND ]--------------------------------------------------
#
	'LINE_NUMBERS'				=> 'Line number On/Off',
#
#-----[ AFTER, ADD ]--------------------------------------------------
#
	'EXPAND_CODE'				=> 'Expand/Contract',
#
#-----[ OPEN ]--------------------------------------------------
#
styles/prosilver/template/bbcode.html
#
#-----[ FIND ]---------------------------------------------------
#
<!-- BEGIN code_open --><dl class="codebox"><dt class="right"><a href="#" onclick="linenumberOnOff('{CB}'); return false;">{L_LINE_NUMBERS}</a> | <a href="#" onclick="selectCode(this); return false;">{L_SELECT_ALL_CODE}</a> | ?</dt><dd><!-- END code_open -->
<!-- BEGIN code_close --></dd></dl><!-- END code_close -->
#
#-----[ REPLACE WITH ]------------------------------------------
#
<!-- BEGIN code_open --><div class="codebox"><div class="codeheader"><a href="#" onclick="linenumberOnOff('{CB}'); return false;">{L_LINE_NUMBERS}</a> | <a href="#" onclick="expandCode('{CB}'); return false;">{L_EXPAND_CODE}</a> | <a href="#" onclick="selectCode(this); return false;">{L_SELECT_ALL_CODE}</a></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><!-- END code_open -->
<!-- BEGIN code_close --></div></div><!-- END code_close -->
#
#-----[ OPEN ]--------------------------------------------------
#
styles/prosilver/template/forum_fn.js
#
#-----[ FIND ]---------------------------------------------------
#
	var e = a.parentNode.parentNode.getElementsByTagName('DIV')[0];
#
#-----[ REPLACE WITH ]------------------------------------------
#
	var e = a.parentNode.parentNode.getElementsByTagName('DIV')[1];
#
#-----[ FIND ]---------------------------------------------------
#
function linenumberOnOff(id){
	var parent = document.getElementById(id);
	var holder = parent.parentNode;

	if (parent.firstChild.nodeName == "OL"){
		var show = 'hide';
	} else if (parent.firstChild.nodeName == "DL"){
		var show = 'show';
	}

	if (show == 'hide'){
		var child = parent.getElementsByTagName("ol");

		var children = child[0].childNodes;

		var replacement = document.createElement("div");
		replacement.setAttribute("id", id);
		replacement.setAttribute("class", parent.getAttribute("class"));
		replacement.setAttribute("className", parent.getAttribute("className"));
		replacement.setAttribute("style", parent.getAttribute("style"));
		

		var dl = document.createElement("dl");
		var dt = document.createElement("dt");
		dt.setAttribute("style", "display: none;");

		dl.appendChild(dt);

		for (var b = 0; b <= children.length - 1; b++){
			if (children[b].nodeType == 1){
				var row = document.createElement("dd");

				row.setAttribute("class", children[b].getAttribute("class"));
				row.setAttribute("className", children[b].getAttribute("className"));
				row.setAttribute("style", children[b].getAttribute("style") + "; border-left: none;");

				var rowdata = children[b].childNodes;

				for (var c = 0; c <= rowdata.length - 1; c++){
					row.appendChild(rowdata[c].cloneNode(true));
				}

				dl.appendChild(row);
			}
		}

		replacement.appendChild(dl);
		holder.replaceChild(replacement, parent);
	} else {
		var replacement = document.createElement("div");
		replacement.setAttribute("id", id);
		replacement.setAttribute("class", parent.getAttribute("class"));
		replacement.setAttribute("className", parent.getAttribute("className"));
		replacement.setAttribute("style", parent.getAttribute("style"));

		var list = document.createElement("ol");

		var dds = parent.getElementsByTagName("dd");

		for (var b = 0; b <= dds.length -1; b++){
			var row = document.createElement("li");
			row.setAttribute("class", dds[b].getAttribute("class"));
			row.setAttribute("className", dds[b].getAttribute("className"));
			row.setAttribute("style", dds[b].getAttribute("style") + "; border-left: 1px solid #999;");

			var rowdata = dds[b].childNodes;

			for (var c = 0; c <= rowdata.length - 1; c++){
				row.appendChild(rowdata[c].cloneNode(true));
			}

			list.appendChild(row);
		}

		replacement.appendChild(list);
		holder.replaceChild(replacement, parent);
	}
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
function linenumberOnOff(id){
	var parent = document.getElementById(id);
	var holder = parent.parentNode;

	if (parent.firstChild.nodeName == "OL"){
		var show = 'hide';
	} else if (parent.firstChild.nodeName == "DIV"){
		var show = 'show';
	}

	if (show == 'hide'){
		var child = parent.getElementsByTagName("ol");

		var children = child[0].childNodes;

		var replacement = document.createElement("div");
		replacement.setAttribute("id", id);
		replacement.setAttribute("class", parent.getAttribute("class"));
		replacement.setAttribute("className", parent.getAttribute("className"));
		replacement.setAttribute("style", parent.getAttribute("style"));
		
		for (var b = 0; b <= children.length - 1; b++){
			if (children[b].nodeType == 1){
				var row = document.createElement("div");

				row.setAttribute("class", children[b].getAttribute("class"));
				row.setAttribute("className", children[b].getAttribute("className"));
				row.setAttribute("style", children[b].getAttribute("style") + "; border-left: none;");
				row.style.cssText = 'border-left: none;';

				var rowdata = children[b].childNodes;

				for (var c = 0; c <= rowdata.length - 1; c++){
					row.appendChild(rowdata[c].cloneNode(true));
				}

				replacement.appendChild(row);
			}
		}
		
		holder.replaceChild(replacement, parent);
	} else {
		var replacement = document.createElement("div");
		replacement.setAttribute("id", id);
		replacement.setAttribute("class", parent.getAttribute("class"));
		replacement.setAttribute("className", parent.getAttribute("className"));
		replacement.setAttribute("style", parent.getAttribute("style"));

		var list = document.createElement("ol");

		var dds = parent.getElementsByTagName("div");

		for (var b = 0; b <= dds.length -1; b++){
			var row = document.createElement("li");
			row.setAttribute("class", dds[b].getAttribute("class"));
			row.setAttribute("className", dds[b].getAttribute("className"));
			row.setAttribute("style", dds[b].getAttribute('style') + "; border-left: 1px solid #999;");

			var rowdata = dds[b].childNodes;

			for (var c = 0; c <= rowdata.length - 1; c++){
				row.appendChild(rowdata[c].cloneNode(true));
			}

			list.appendChild(row);
		}

		replacement.appendChild(list);
		holder.replaceChild(replacement, parent);
	}
}

function expandCode(id){
	var parent = document.getElementById(id);

	if (parent.style.display === 'block' || parent.style.display === ''){
		parent.style.display = 'none';
	} else {
		parent.style.display = 'block';
	}
}
#
#-----[ OPEN ]------------------------------------------
#
styles/prosilver/theme/colours.css
#
#-----[ FIND ]------------------------------------------
#
dt.right {
#
#-----[ REPLACE WITH ]------------------------------------------
#
div.codeheader {
#
#-----[ OPEN ]------------------------------------------
#
styles/prosilver/theme/common.css
#
#-----[ FIND ]------------------------------------------
#
.clear {
	display: block;
	clear: both;
	font-size: 1px;
	line-height: 1px;
	background: transparent;
}

.codebox dd div ol {
	list-style-position: outside;
	margin-top: 0;
	margin-bottom: 0;
	padding: 0;
}

dt.right {
	text-align: right;
	padding-right: 10px;
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
.clear {
	display: block;
	clear: both;
	font-size: 1px;
	line-height: 1px;
	background: transparent;
}
#
#-----[ OPEN ]------------------------------------------
#
styles/prosilver/theme/stylesheet.css
#
#-----[ FIND ]------------------------------------------
#
@import url("colours.css");
#
#-----[ AFTER, ADD ]------------------------------------------
#
@import url("bbGeSHi.css");
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#