Ver Mensaje Individual
  #9 (permalink)  
Antiguo 18/03/2009, 01:46
gtuxyco
 
Fecha de Ingreso: febrero-2009
Mensajes: 7
Antigüedad: 17 años, 7 meses
Puntos: 0
Respuesta: PHP generar XML apartir de Recordset MYSQL

Bueno aqui esta el codigo del modulo de joomla que estaba haciendo... es para poner un reproductor a los videos de el componete de seyret
Logro hacer el bucle para crear el XML... pero ahora que lo puse en el modulo siempre me da
Notice: Undefined variable: xml in /www/Final/modules/mod_seyretyoutube/mod_seyretyoutube.php on line 84
Código PHP:
<?php
//--------------------------------------------------------//
//No acceso directo
defined('_JEXEC') or die('Direct Access to this location is not allowed.');

//Get parametros de la configuracion del modulo(XML file)
        // Tamaño
$width =  $params->get('width', '');
$height = $params->get('height', '');
        
// Logo y skin
if ($params->get('logo_url')){
    
$logo_url = $params->get('logo_url', '');
    
$logo = '&logo='.$logo_url;
}
$skin_variant = $params->get('skin_variant', '');

if (
$params->get('skin_variant')){
    
$skin_variant = $params->get('skin_variant', '');
    
$skin = "modules/mod_seyretyoutube/skin/".$skin_variant.'.swf';
}
        
// Playlist
$playlist_position = $params->get('playlist_position', '');        
$playlist_url = "modules/mod_seyretyoutube/video.xml";
$video      = $playlist_url.'&playlist='.$playlist_position; 
$orderby = $params->get('orderby', 'addeddate'); //ordenar por
$limit     = $params->get('limit', '6'); // tamaño lista
                    // repetir
if ($params->get('playlist_repeat')){
    
$playlist_repeat = $params->get('playlist_repeat', '');
    
$repeat = '&'.$playlist_repeat;
}                     
// aleatorio
if ($params->get('playlist_shuffle')){
    
$playlist_shuffle = $params->get('playlist_shuffle', '');
    
$shuffle = '&'.$playlist_shuffle;
}
                    
// Automatico 
if ($params->get('autostart')){
    
$autostart = "&autostart=true";
}
// Parametros de flash
$count   = $params->get( 'count', '');
$version = $params->get( 'version', '');

// Conexion a la base de datos
$db     = &JFactory::getDBO();
$query  = "SELECT id, title, itemcomment, videoservercode, picturelink FROM jos_seyret_items WHERE videoservertype = 'youtube'ORDER BY ".$orderby." DESC LIMIT ".$limit."";
$result = $db->Query($query);

$url    = 'index.php?option=com_seyret?task=videodirectlink&id=';
//Partes del XML
        //inicio
$xmlinicio = "
<playlist version='1' xmlns='hxxp://xspforg/ns/0/'>
  <title>Generated Playlist from a MySQL DataBase</title>
  <info>$url</info>
    <trackList>
"
;
        
// Bucle para la lista
while($data_array =  mysql_fetch_array($result))
{
$vcode   = $data_array['videoservercode'];
$vidlink = file_get_contents("/components/com_seyret/video.php?id=".$vcode);
$xml    .=  <<<END
    <track>
      <title>
{$data_array['title']}</title>
      <location>$vidlink.flv</location>
      <image>
{$data_array['picturelink']}</image>
      <annotation>
{$data_array['itemcomment']}</annotation>
      <info>
{$url}{$data_array['id']}</info>
    </track>
END;
}
        
//Fin
$xmlcerrar = "
    </trackList>
</playlist>

"
;

// Crea el archivo XML
$name_file="video.xml";
$file=fopen($name_file,"w+");
fwrite ($file,$xmlinicio);
fwrite ($file,$xml);
fwrite ($file,$xmlcerrar);
fclose($file);


//---------------------------------------------------------//
?>

<style type="text/css">
    #copyright {display:none;} 
</style>
<div id="videoplayer<?php echo $count ?>"><a href="hxxp://wwwmacromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
<script type="text/javascript" src="<?php echo JURI::base();;?>modules/mod_seyretyoutube/swfobject.js"></script>
<script type="text/javascript">
    var s1 = new SWFObject("<?php echo JURI::base();;?>modules/mod_seyretyoutube/jwplayer.swf","ply<?php echo $count ?>","<?php echo $width ?>","<?php echo $height ?>","<?php echo $version ?>","#FFFFFF");
    s1.addParam("allowfullscreen","true");
    s1.addParam("allowscriptaccess","always");
    s1.addVariable("skin", "<?php echo JURI::base();;?><?php echo $skin ?>");
    s1.addParam('wmode','opaque');
    s1.addParam("flashvars","file=<?php echo JURI::base();;?><?php echo $video ?><?php echo $preview ?><?php echo $logo ?><?php echo $link ?><?php echo $repeat ?><?php echo $shuffle ?><?php echo $autostart ?>");
    s1.write("videoplayer<?php echo $count ?>");
</script>