Ver Mensaje Individual
  #7 (permalink)  
Antiguo 23/03/2012, 16:55
Avatar de weissbier
weissbier
 
Fecha de Ingreso: febrero-2012
Ubicación: Nella mia casa
Mensajes: 31
Antigüedad: 12 años, 3 meses
Puntos: 1
Respuesta: Rodear elemento con HTMLpurifier

jejeje, también es cierto. Bueno, dejaré un bloque completo eliminando las zonas que son prescindibles:

Código PHP:
     //Incluyendo la libreria
       
include(dirname($_SERVER['DOCUMENT_ROOT']) . "/gen_includes/simple_html_dom.php");
    
//Control images on callback
        
function contCallback($element){
        global 
$bdgen;
           
//For tables
           
if ($element->tag=='table'){           
           
$element->outertext "<div style='border:1px solid #333;'>" $element->outertext "</div>";
           }
           
//For IMGS
           
if ($element->tag=='img'){
              
$img_src=$element->src;
              
//[...] Fragmento excluido
           
}
        }
        function 
callback_yt($url){
        global 
$bdgen;
          
parse_strparse_url$url[1], PHP_URL_QUERY ), $url_vars);
          
//register this video (if is not)
            //[...] Fragmento excluido
          
return '<div class="img"><div class="img_opt">Reclamar v&iacute;deo (Opci&oacute;n a&uacute;n no disponible)</div><iframe class="video" src="http://www.youtube.com/embed/' $url_vars['v'] . '" frameborder="0" allowfullscreen></iframe></div>';
        }
        
//HTML DOM parser
        
$html=str_get_html($cont_data['cont']);
        
$html->set_callback('contCallback');
        
$replace_on_fly=preg_replace_callback('/\[YOUTUBE\](.+)\[\/YOUTUBE\]/U','callback_yt',$html);
        
$replace_on_fly=preg_replace('/xK\[([A-Z0-9]+)\]/','<img class="xinl" src="http://woording.com/images/xTras/kb/$1.jpg" />',$replace_on_fly);
        
$replace_on_fly=preg_replace('/xB\[([A-Z]+)\]/','<img class="xinl" src="http://woording.com/images/xTras/bullets/$1.png" />',$replace_on_fly);
          
$pat=array('</p>','<p> </p><div class="img">');
          
$rep=array('</p> ' PHP_EOL,'<div class="img">');
        
$replace_on_fly=str_replace($pat,$rep,$replace_on_fly);
        echo 
$replace_on_fly;
        
?> 
Gracias de antemano, un saludo.