Seite 1 von 1

suche: MOD zum Nutzen des BBCode:color innerhalb d. code-tag

Verfasst: 15.09.2008 22:31
von altmar
Hallo allerseits,
ich bräuchte Eure Hilfe! Wir haben unser Board vor kurzem von der Version 2.x auf die Version 3.0.2 gehoben nud auch einige Mods bereits eingespielt.
So weit so gut.
Nur leider fehlt uns ein wichtiger Mod, den wir unter der 2er Version intensiv genutzt haben: Die Anzeige von farbigem Text innerhalb der BBCode:code-tags.
Nun stehen wir wieder vor dem Problem, dass die code-tags ja alle BBCodes, die innerhalb des Bereiches stehen, ignorieren.
Der alte Mod von BrotherTank (Greg) bestand in einer Änderung in der includes/bbcode.php - und zwar in der function bbencode_first_pass_pda(...).
Hier mal auszugsweise die Änderung:
#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php

#
#-----[ FIND ]------------------------------------------
#
if ($mark_lowest_level && ($curr_nesting_depth == 1))
{
if ($open_tag[0] == '

Code: Alles auswählen

')
							{
#
#-----[ AFTER, ADD ]------------------------------------------
#
								// colours between [code] start
								$between_tags = preg_replace("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "!color=\\1~$uid!\\2!/color~$uid!", $between_tags);
								// colours between [code] end
#
#-----[ FIND ]------------------------------------------
#
						else
						{
							if ($open_tag[0] == '[code]')
							{
#
#-----[ AFTER, ADD ]------------------------------------------
#
								// colours between [code] start
								$between_tags = preg_replace("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "!color=\\1~$uid!\\2!/color~$uid!", $between_tags);
								// colours between [code] end
#
#-----[ FIND ]------------------------------------------
#
	return $text;

} // bbencode_first_pass_pda()
#
#-----[ BEFORE, ADD ]------------------------------------------
#
	// colours between [code] start
	$text = preg_replace("/\!color=(\#[0-9A-F]{6}|[a-z]+)~$uid\!/si","[color=\\1:$uid]" , $text);
	$text = str_replace("!/color~$uid!", "[/color:$uid]", $text);
	// colours between [code] end
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM[/quote]
Nun ist in der Version 3.0.2 vieles anders - ich vermute mal, dass die Änderungen dort ebenfalls in der bbcode.php durchgeführt werden müssten - und zwar wahrscheinlich in dem Bereich der function bbcode_cache_init():
[quote]                                case 8:
                                        $this->bbcode_cache[$bbcode_id] = array(
                                                'preg' => array(
                                                        '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#ise'   => "\$this->bbcode_second_pass_code('\$1', '\$2')",
                                                )
                                        );
                                break;[/quote]
Nur leider bin ich kein php-Spezi...
Hat einer von Euch die Änderung vielleicht sogar schon umgesetzt?

Vielen Dank und viele Grüße,
Martin

Verfasst: 15.09.2008 23:39
von 4seven
da müsste sich wer ranmachen. da die syntax und die dateien sich ja ein wenig verändert haben. als erstes bräuchte man den kompletten 'alten' mod bzw. einen link dahin :wink:

Verfasst: 15.09.2008 23:44
von altmar
Moin,
den "kompletten" alten Mod habe ich oben gepostet.
Die Zeilen davor waren "nur" Kommentare:
##############################################################
## MOD Title: BBcode Colours in Code
## MOD Author: BrotherTank < brothertank@sympatico.ca > (Greg)
## MOD Description: Allows one to use the [color] and [/color]
## commands inside of a

Code: Alles auswählen

 section. This allows
##                  greater flexibility when posting code segments
##                  WITHOUT loosing the formatting!
##
##
## MOD Version: 1.0.0
##
## Installation Level: Easy
## Installation Time: ~10 Minutes
## Files To Edit: bbcode.php
##
## Included Files: N/A
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ 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/
##############################################################
## MOD History:
##
## Mar 17, 2004 - Version 1.0.0
##  - Initial Release - only one needed!
##
##############################################################
## Author Notes:
##
##  Thanks to those that didn't want to help out.  I have no real php programming knowledge
##  and I achieved this mod with only 4 lines of code!  I hope everyone finds this
##  modification usefull as the members do in my forums!
##
##  All 4 additions go inside the "function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_new, $mark_lowest_level, $func, $open_regexp_replace = false)"
##
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php

#
#-----[ FIND ]------------------------------------------
#
						if ($mark_lowest_level && ($curr_nesting_depth == 1))
						{
							if ($open_tag[0] == '[code]')
							{
#
#-----[ AFTER, ADD ]------------------------------------------
#
								// colours between [code] start
								$between_tags = preg_replace("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "!color=\\1~$uid!\\2!/color~$uid!", $between_tags);
								// colours between [code] end
#
#-----[ FIND ]------------------------------------------
#
						else
						{
							if ($open_tag[0] == '[code]')
							{
#
#-----[ AFTER, ADD ]------------------------------------------
#
								// colours between [code] start
								$between_tags = preg_replace("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "!color=\\1~$uid!\\2!/color~$uid!", $between_tags);
								// colours between [code] end
#
#-----[ FIND ]------------------------------------------
#
	return $text;

} // bbencode_first_pass_pda()
#
#-----[ BEFORE, ADD ]------------------------------------------
#
	// colours between [code] start
	$text = preg_replace("/\!color=(\#[0-9A-F]{6}|[a-z]+)~$uid\!/si","[color=\\1:$uid]" , $text);
	$text = str_replace("!/color~$uid!", "[/color:$uid]", $text);
	// colours between [code] end
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM[/quote]

Es wäre [b]super[/b], wenn das einer hinbekommen würde...

Viele Grüße,
Martin

Verfasst: 30.09.2008 12:42
von 4seven
hab mal einige tests gemacht, allerdings nicht ausreichend zeit, mich damit intensiv zu beschäftigen.
es sieht auf den ersten blick machbar aus, ist aber bei näherer betrachtung etwas tricky, da die bbcode.php syntax im 3er ziemlich anders ist. ich hoffe, das jemand anders mehr erfolg (und zeit) hat.

Verfasst: 30.09.2008 13:05
von altmar
Hallo,
vielen Dank für Deinen Versuch!!

Viele Grüße,
Martin

Verfasst: 06.10.2008 17:52
von altmar
Hallo allerseits,
hat denn vielleicht noch jemand eine Idee? Es wäre wirklich super, wenn das hinzubekommen wäre, da wir bei uns im (alten) Board davon regen Gebrauch gemacht haben...

Viele Grüße,
Martin

Verfasst: 06.10.2008 19:40
von test_nick
Ich bräuchte auch mal sowas!

Verfasst: 24.10.2008 09:33
von altmar
Prima - bin ich ja doch nicht alleine...
Aber leider scheint noch keiner so etwas im Einsatz zu haben mit der aktuellen phpBB-Version :cry:

Viele Grüße,
Martin

Verfasst: 22.12.2008 22:57
von altmar
So,
ein Kollege von mir war so nett, sich damit zu beschäftigen - anbei seine Lösung:
Änderungen in der Datei message_parser.php unter ./includes.
Ersetze in der function bbcode_parse_code($stx, &$code)
am Ende die Zeile

Code: Alles auswählen

return "[code=$stx:" . $this->bbcode_uid . ']' . $code . '[/code:' . $this->bbcode_uid . ']';
durch

Code: Alles auswählen

$rc = "[code=$stx:" . $this->bbcode_uid . ']' . $code . '[/code:' . $this->bbcode_uid . ']';
$rc = preg_replace('/([color=)(#[A-F0-9]+)(])/', '[color=$2]', $rc);
$rc = preg_replace('/[\/color]/', '[/color]', $rc);
return $rc;
(das ist für den Fall, daß speziell php-Code eingefügt wird - phpBB behandelt das speziell, weil dann php-syntax-highlighting gemacht wird)
sowie kurz darauf

Code: Alles auswählen

return '[code:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($code) . '[/code:' . $this->bbcode_uid . ']';
durch

Code: Alles auswählen

$rc = '[code:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($code) . '[/code:' . $this->bbcode_uid . ']';
$rc = preg_replace('/([color=)(#[A-F0-9]+)(])/', '[color=$2]', $rc);
$rc = preg_replace('/[\/color]/', '[/color]', $rc);
return $rc;
(allgemeiner Fall).
Viele Grüße,
Martin