CSS bbcode tag einbauen
Verfasst: 10.01.2007 18:22
Hallo,
ich habe im Internet eine Funktion gefunden diese den text im CSS Syntax anzeigen laesst.
Nur funktioniert das einbauen in der bbcode.php nicht richtig.
so sieht die ganze function aus.
$after_replace <<< das müsste doch die variable sein in der, der Inhalt ist, wie z.b. (.classe { bla; }). Wenn ich die ich $after_replace direkt bei $replacement .= hin mache wird mir alles angazeigt (im Forum), wenn ich es aber über diese Funktion laufen lasse gibt es zwar keine Fehlermeldung, aber es wird nix angezeigt.
Naja ich hoffe mir kann jemand auf die Sprünge helfen.
ich habe im Internet eine Funktion gefunden diese den text im CSS Syntax anzeigen laesst.
Nur funktioniert das einbauen in der bbcode.php nicht richtig.
so sieht die ganze function aus.
Code: Alles auswählen
function bbencode_second_pass_css($text, $uid, $bbcode_tpl)
{
global $lang;
$code_start_html = $bbcode_tpl['css_open'];
$code_end_html = $bbcode_tpl['css_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("#\[css:1:$uid\](.*?)\[/css:1:$uid\]#si", $text, $matches);
for ($i = 0; $i < $match_count; $i++)
{
$before_replace = $matches[1][$i];
$after_replace = $matches[1][$i];
$str = $after_replace;
function cssHightlight($str){
$tab = " "; // left Tab width
$str = htmlentities($str);
$str = str_replace("\t", $tab, $str);
$endText = "<pre>";
// Kommentare
$commentArr = split('\*/', $str);
array_splice($commentArr, -1,1);
for($x=0; $x<count($commentArr); $x++){
$comm1 = split('/\*', $commentArr[$x]);
$str = str_replace($comm1[1], "<code class='comment'>".$comm1[1]."</code>", $str);
}
// -------------
$temp_arr = split('}',$str);
array_splice($temp_arr,-1,1);
for($i=0;$i<count($temp_arr);$i++){
$temp1_arr = split('{',$temp_arr[$i]); //split style name and property string
$endText .= "<code class='attr'>".$temp1_arr[0]."</code><code class='klammer'>{</code>\n".$tab;
if(strstr($temp1_arr[1],';')){
$temp1_arr[1]=trim($temp1_arr[1]);
if(strrpos($temp1_arr[1],";")==(strlen($temp1_arr[1])-1)){
$temp1_arr[1]= substr($temp1_arr[1],0,strlen($temp1_arr[1])-1);
}
$temp2_arr = split(';',$temp1_arr[1]); //split properties
$prop_arr = array();
for($j=0;$j<count($temp2_arr);$j++){
$temp3_arr = split(':',$temp2_arr[$j]); //split property name and value
$endText .= "<code class='defined'>".$temp3_arr[0]."</code><code class='construct'>:</code>";
$endText .= "<code class='value'>".$temp3_arr[1]."</code><code class='construct'>;</code>";
}
}
$endText .= "\n<code class='klammer'>}</code>";
}
$endText = str_replace("/*", "<code class='comment'>/*</code>", $endText);
$endText = str_replace("*/", "<code class='comment'>*/</code>", $endText);
return $endText."</pre>";
}
$str_to_match = "[css:1:$uid]" . $before_replace . "[/css:1:$uid]";
$replacement = $code_start_html;
$replacement .= cssHightlight($str);
$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("[css:$uid]", $code_start_html, $text);
$text = str_replace("[/css:$uid]", $code_end_html, $text);
return $text;
} // bbencode_second_pass_css()
Naja ich hoffe mir kann jemand auf die Sprünge helfen.
