Hola e encontrado un codigo para un sistema de noticias y poder poner bbcode pero nose como implantarlo para que cuando aga clic en la imagen aparezca en el textarea.
<?PHP
function bbcode($texto) {
$texto = str_replace("\n","<br>",$texto); //Saltos de Linea
$texto = str_replace("[b]","<b>",$texto); //Negrita
$texto = str_replace("[/b]","</b>",$texto); //Negrita
$texto = str_replace("[i]","<i>",$texto); //Italic
$texto = str_replace("[/i]","</i>",$texto); //Italic
$texto = str_replace("[u]","<u>",$texto); //Subrayado
$texto = str_replace("[/u]","</u>",$texto); //Subrayado
$texto = eregi_replace("\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]",'<a href="\\1">\\2</a>', $texto); //URLS dentro de la pagina
$texto = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a target=\"_blank\" href=\"\\1\">\\1</a>", $texto); //URLS fuera de la pagina
$texto = eregi_replace("\\[imgl=([^\\[]*)\\]([^\\[]*)\\[/imgl\\]",'<a href="\\1" rel=\"lightbox\">\\2</a>', $texto); //Lightbox
$texto = eregi_replace("\\[img\\]([^\\[]*)\\[/img\\]",'<img src="\\1">', $texto); //Imagenes
$texto = eregi_replace("\\[quote\\]([^\\[]*)\\[/quote\\]",'<div class=\"css_title\">Cita<div class=\"css\">\\1</div></div>', $texto); // citas
// Pone el texto como una cita. Formato: [cita]La calidad nunca es un accidente; siempre es el resultado de un esfuerzo de la inteligencia[/cita]
$texto = eregi_replace("\\[cita\\]([^\\[]*)\\[/cita\\]",'<div class=\"css_title\">Cita<div class=\"css\">\\1</div></div>', $texto);
$texto = eregi_replace("\\[php\\]([^\\[]*)\\[/php\\]","\n<div class=\"css_title\">Código PHP\n<div class=\"css\">\\1</div></div>", $texto); //codigos en PHP
// Texto rojo --> [rojo]Texto[/rojo]
$texto = eregi_replace("\\[rojo\\]([^\\[]*)\\[/rojo\\]","<font color=\"#FF0000\">\\1</font>", $texto);
// Texto azul --> [azul]Texto[/azul]
$texto = eregi_replace("\\[azul\\]([^\\[]*)\\[/azul\\]","<font color=\"#0000FF\">\\1</font>", $texto);
// Texto verde --> [verde]Texto[/verde]
$texto = eregi_replace("\\[verde\\]([^\\[]*)\\[/verde\\]","<font color=\"#009900\">\\1</font>", $texto);
// Texto naranja --> [naranja]Texto[/naranja]
$texto = eregi_replace("\\[naranja\\]([^\\[]*)\\[/naranja\\]","<font color=\"#FF9933\">\\1</font>", $texto);
// Texto violeta --> [violeta]Texto[/violeta]
$texto = eregi_replace("\\[violeta\\]([^\\[]*)\\[/violeta\\]","<font color=\"#CC00FF\">\\1</font>", $texto);
return $texto;
}
function filtro_palabras($texto) {
$palabras = array("tonto", "feo", "*****", "mierda", "*****", "*****");
$division = explode(" ", $texto);
foreach ($division as $key => $valor) {
foreach ($palabras as $palabra) {
if (strtolower($valor) == $palabra) {
$division[$key] = "[CENSURADO]";
}
}
}
$texto = implode(" ",$division);
return $texto;
}
?>
Podriais echar una mano? Saludos.