Hola amigos de phperos, pues vengo a pedir su ayuda para lograr colorear los codigos php, les dejo el class, lo que pido porfavor, esque me agregen la funcion para colorearlo:
<?php
class bbcode
{
function __construct() {
array(
"EMOTICONS_DIR" => "/img/emoticons/"
);
}
// Enviar todo el texto que se analiza aquí!
function coverpass($text)
{
//Comprueba si hay algún BBcode
$istag = strrpos($text, "]");
if($istag != 0)
{
$text = $this->parsetags($text); // Yup, Parse Them
}
return nl2br($text);
}
function parsetags($text)
{
// Aka haremos todo para que muestre, ejemplo de uso:
//$text = str_replace("[algo]", "Continuara...", $text);
######## BBcodes Importantes! ########
$text = preg_replace("(\[b\](.+?)\[\/b\])is", '<span style="font-weight:bold;">$1</span>', $text); // Bold
$text = preg_replace("(\[i\](.+?)\[\/i\])is", '<i>$1</i>', $text); // Italics
$text = preg_replace("(\[u\](.+?)\[\/u\])is", '<u>$1</u>', $text); // Underline
$text = preg_replace("(\[s\](.+?)\[\/s\])is", '<span class="bbcode_strikethrough">$1</span>', $text); // Strike through
$text = preg_replace("(\[o\](.+?)\[\/o\])is", '<span class="bbcode_overline">$1</span>', $text); // Overline
$text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])", '<span style="font-family: $1;">$2</span>', $text); // Font
$text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is", '<span style="color: $1">$2</span>', $text); // Color
$text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is", '<span style="font-size: $1px">$2</span>', $text); // Font-Size
$text = preg_replace("/\[list\](.+?)\[\/list\]/is", '<ul>$1</ul>', $text); // List
$text = str_replace("[*]", "<li>", $text); // List-Item
######## //Codigo de code y citar ########
$text = preg_replace("(\[code\](.+?)\[\/code\])is", '<code>$1</code>', $text); // Code
$text = preg_replace("(\[citar\](.+?)\[\/citar\])is", '<blockquote><div class="cita">Cita:</div><br><div class="citacuerpo">$1<br></div></blockquote>', $text); // Quote
######## //Permitir imagenes, links, mails, videos????? ########
$permitir_imagenes = true;
$permitir_links = true;
$permitir_mails = true;
$permitir_youtube = true;
######## //Permitir imagenes, links, mails, videos????? ########
// Se permite imagenes?
if($permitir_imagenes == true)
{
$text = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src="$1" class="bbcode_img" />', $text); // Image
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '<img src="$3" class="bbcode_img" height="$2" width="$1" />', $text); //Image with width and height
}
else
{
$text = preg_replace("/\[img\](.+?)\[\/img\]/", 'El administrador ha bloqueado las imágenes!', $text); // Image
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", 'El administrador ha bloqueado las imágenes!', $text); //Image with width and height
}
// Se permite links?
if($permitir_links == true)
{
$text = preg_replace("/\[url\]([ a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\']*)\[\/url\]/", '<a target="_blank" rel="nofollow" href="$1" class="bbcode_a">$1</a>', $text); // Url
$text = preg_replace("(\[url\=([ a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\']*)\](.+?)\[/url\])", '<a target="_blank" rel="nofollow" href="$1" class="bbcode_a">$2</a>', $text); // Url with text
}
else
{
$text = preg_replace("/\[url\]([ a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\']*)\[\/url\]/", 'El administrador ha bloqueado los links!', $text); // Url
$text = preg_replace("(\[url\=([ a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\']*)\](.+?)\[/url\])", 'El administrador ha bloqueado los links!', $text); // Url with text
}
// Se permite emails?
if($permitir_mails == true)
{
$text = preg_replace("(\[mail\]([ a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\' a-zA-Z0-9\.@]*)\[/mail\])", '<a href="mailto:$1" class="bbcode_a">$1</a>', $text); // Mail
$text = preg_replace("/\[mail\=([ a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\' a-zA-Z0-9\.@]*)\](.+?)\[\/mail\]/", '<a href="mailto:$1" class="bbcode_a">$2</a>', $text); // Mail with text
}
else
{
$text = preg_replace("(\[mail\]([ a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\' a-zA-Z0-9\.@]*)\[/mail\])", 'El administrador ha bloqueado los correo links!', $text); // Mail
$text = preg_replace("/\[mail\=([ a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\' a-zA-Z0-9\.@]*)\](.+?)\[\/mail\]/", 'El administrador ha bloqueado los links!', $text); // Mail with text
}
// Se permite videos?
if($permitir_youtube == true)
{
$youtube_replacement = '<object style="width:425px; height:350px;">
<param name="movie" value="http://www.youtube.com/v/$1"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/$1" wmode="transparent" type="application/x-shockwave-flash" style="width:425px; height:350px;"></embed>
</object>';
$text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", $youtube_replacement, $text); // YouTube
$youtube_replacement = '<object style="width:$1px; height:$2px;">
<param name="movie" value="http://www.youtube.com/v/$3"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/$3" wmode="transparent" type="application/x-shockwave-flash" style="width:$1px; height:$2px;"></embed>
</object>';
$text = preg_replace("/\[youtube=([0-9]*)x([0-9]*)\](.+?)\[\/youtube\]/", $youtube_replacement, $text); // YouTube with width/height
$googlevid_replacement = '<object style="width:400px; height:326px;">
<param name="movie" value=http://video.google.com/googleplayer.swf?docId=$1"></param>
<embed src="http://video.google.com/googleplayer.swf?docId=$1" wmode="transparent" style="width:400px; height:326px;"
id="VideoPlayback" type="application/x-shockwave-flash" flashvars=""></embed>';
$text = preg_replace("/\[googlevid\](.+?)\[\/googlevid\]/", $googlevid_replacement, $text); // Google Video
$googlevid_replacement = '<object style="width:$1px; height:$2px;">
<param name="movie" value=http://video.google.com/googleplayer.swf?docId=$3"></param>
<embed src="http://video.google.com/googleplayer.swf?docId=$3" wmode="transparent" style="width:$1px; height:$2px;"
id="VideoPlayback" type="application/x-shockwave-flash" flashvars=""></embed>';
$text = preg_replace("/\[googlevid=([0-9]*)x([0-9]*)\](.+?)\[\/googlevid\]/", $googlevid_replacement, $text); // Google Video tamaño
}
else
{
$text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", 'El administrador ha bloqueado los videos!', $text); // YouTube
$text = preg_replace("/\[youtube=([0-9]*)x([0-9]*)\](.+?)\[\/youtube\]/", 'El administrador ha bloqueado los videos!', $text); // YouTube Video tamaño
$text = preg_replace("/\[googlevid\](.+?)\[\/googlevid\]/", 'El administrador ha bloqueado los videos!', $text); // Google Video
$text = preg_replace("/\[googlevid=([0-9]*)x([0-9]*)\](.+?)\[\/googlevid\]/", 'El administrador ha bloqueado los videos!', $text); // Google tamañ
}
return $text;
}
}
?>
como veran ya tengo la funcion [*//code][*///code]
me poddrian hacer el favor de agregar [*//php][*///php] y que lo coloree porfavor, gracias por su atención.
Saludos