Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/03/2009, 14:53
Avatar de Lynxcraft
Lynxcraft
 
Fecha de Ingreso: noviembre-2007
Ubicación: yecla murcia
Mensajes: 1.346
Antigüedad: 16 años, 5 meses
Puntos: 51
class BBcodes

Hola de nuevo sigo teniendo algunas dudas con respecto a ciertas cosas,,me doy cuenta con esto que soy un novato completamente XDXDXD

bueno la cuestión es la siguiente me descargue el código Geshin ahora lo quiero implementar utilizando un bbcodde asi que he creado esta clase

Código PHP:
<?php 
class BBCODE{
    public function 
__constructor(){
        
    }
    public function 
BBGeshi($texto,$tipo,$title=''){
        if (
is_readable('include/geshi.php')) {
            
$path 'include/';
            } elseif (
is_readable('geshi.php')) {
                
$path 'include/';
                } else {
                    die(
'Could not find geshi.php - make sure it is in your include path!');
                    }
                    require 
$path 'geshi.php';
   
       
$texto stripslashes($texto);
    
    if (!
strlen(trim($texto))) {
        
$tipo preg_replace('#[^a-zA-Z0-9\-_]#'''$tipo);
        
$texto implode('', @file($path 'geshi/' $tipo'.php'));
        
$tipo 'php';
    } else {
        
$fill_source true;
    }

            
$geshi = new GeSHi($texto$tipo);
            
$geshi->set_header_type(GESHI_HEADER_PRE_VALID);
            
$geshi->enable_classes();
            
$geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS5);
            
$geshi->set_overall_style('font: normal normal 90% monospace; color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;'false);
            
$geshi->set_line_style('color: #003030;''font-weight: bold; color: #006060;'true);
            
$geshi->set_code_style('color: #000020;'true);
            
$geshi->set_link_styles(GESHI_LINK'color: #000060;');
            
$geshi->set_link_styles(GESHI_HOVER'background-color: #f0f000;');
            
$geshi->set_header_content($title);
            
$geshi->set_header_content_style('font-family: sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
            
$geshi->set_footer_content('Analizado en <TIME> segundos ha <SPEED>, GeSHi <VERSION>');
            
$geshi->set_footer_content_style('font-family: sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;');
            return 
$geshi->parse_code();
            }

    public function 
get($texto){
        
        
$a = array(
                   
"/\[i\](.*?)\[\/i\]/is",
                   
"/\[b\](.*?)\[\/b\]/is",
                   
"/\[u\](.*?)\[\/u\]/is",
                   
"/\[img\](.*?)\[\/img\]/is",
                   
"/\[url=(.*?)\](.*?)\[\/url\]/is"
                  
                   
);
        
$b = array(
                   
"<i>$1</i>",
                   
"<b>$1</b>",
                   
"<u>$1</u>",
                   
"<img src=\"$1\" />",
                   
"<a href=\"$1\" target=\"_blank\">$2</a>"
                   
                   
);
        
        
$texto preg_replace"/\[php\](.*?)\[\/php\]/is",self :: BBGeshi "{"$1"}",'php','PHP') , $texto);
        
        
$texto preg_replace($a$b$texto);
        
$texto =stripslashes$texto);
        return 
$texto;
        
//
    
}
}
cuando coloco esto en esta linea

$texto = preg_replace( "/\[php\](.*?)\[\/php\]/is",self :: BBGeshi ( "\"$1\"",'php','PHP') , $texto);

funciona casi bien lo único es que me devuelve en código con unas comillas mas o menos así
Código PHP:
"
<?php
echo "HOLA";
?>
"
lo he colocado de todas las formas que se me ha ocurrido y no funciona siempre me tira error solo con esto funciona medio bien "\"$1\"" XDXD no se alguna sugerencia de como programar esto gracias XD
__________________
Sobran las ideas cuando faltan ganas de trabajar en ellas
Lynxcraft