Esta es mi clase
Cita:
<?php
class Tracks
{
private $Artist;
private $List;
private $ Directory;
public function __construct($directory,$artist)
{
$this->Artist=$artist;
$this-> Directory =$directory;
}
private function set_GenerateList()
{
$artist=str_replace("_"," ",$this->Artist);
$artist=strtoupper($artist);
$this->List="<config>\n";
$this->List.="\t<auto_start>true</auto_start>\n";
$this->List.="\t<player_skin>./skin.swf</player_skin>\n";
$this->List.="\t<main_title>mi reproductor</main_title>\n";
$this->List.="\t<playlist_title>$artist</playlist_title>\n";
$this->List.="\t<title_text>DURACION</title_text>\n";
$this->List.="\t<pan_labels>I,D</pan_labels>\n";
$this->List.="\t<scroller_speed>3</scroller_speed>\n";
$this->List.="\t<scroller_marquee_content>#TRACK_NAME# </scroller_marquee_content>\n";
$this->List.="\t<repeat_is_enabled>false</repeat_is_enabled>\n";
$this->List.="\t<suffle_is_enabled>false</suffle_is_enabled>\n";
$this->List.="\t<default_volume>100</default_volume>\n";
$this->List.="\t<default_pan>0</default_pan>\n";
$this->List.="\t<play_list>\n";
if ($mus = opendir("$this-> Directory /$this->Artist"))
{
$i=1;
while (false !== ($tracks = readdir($mus)))
{
if($tracks!=="." && $tracks!=="..")
{
$track=substr($tracks,0,-4);
$this->List.="\t\t<item>$this-> Directory /$this->Artist/$tracks; $track</item>\n";
$i++;
}
}
closedir($mus);
}
else
{
$this->List.="\t\t<item>null;hubo problemas: las causas pueden ser</item>\n";
$this->List.="\t\t<item>null;grupo o artista no existe o</item>\n";
$this->List.="\t\t<item>null;no hay album de dicho grupo o artista </item>\n";
}
$this->List.="\t</play_list>\n";
$this->List.="</config>";
return $this->List;
}
public function write_Tracks($file_writable)
{
$list=$this->set_GenerateList();
$file_xml = "$this->Directory/$file_writable";
if(file_exists($file_xml))
{
if (is_writable($file_xml))
{
if (!$gestor = fopen($file_xml, 'w+'))
{
exit;
}
if (fwrite($gestor, $list) === false)
{
exit;
}
fclose($gestor);
}
else
{
throw new Exception("No se puede escribir en el archivo");
}
}
else
{
throw new Exception("No existe Archivo");
}
}
}
?>
Luego para la instanciación hago lo siguiente.<?php
class Tracks
{
private $Artist;
private $List;
private $ Directory;
public function __construct($directory,$artist)
{
$this->Artist=$artist;
$this-> Directory =$directory;
}
private function set_GenerateList()
{
$artist=str_replace("_"," ",$this->Artist);
$artist=strtoupper($artist);
$this->List="<config>\n";
$this->List.="\t<auto_start>true</auto_start>\n";
$this->List.="\t<player_skin>./skin.swf</player_skin>\n";
$this->List.="\t<main_title>mi reproductor</main_title>\n";
$this->List.="\t<playlist_title>$artist</playlist_title>\n";
$this->List.="\t<title_text>DURACION</title_text>\n";
$this->List.="\t<pan_labels>I,D</pan_labels>\n";
$this->List.="\t<scroller_speed>3</scroller_speed>\n";
$this->List.="\t<scroller_marquee_content>#TRACK_NAME# </scroller_marquee_content>\n";
$this->List.="\t<repeat_is_enabled>false</repeat_is_enabled>\n";
$this->List.="\t<suffle_is_enabled>false</suffle_is_enabled>\n";
$this->List.="\t<default_volume>100</default_volume>\n";
$this->List.="\t<default_pan>0</default_pan>\n";
$this->List.="\t<play_list>\n";
if ($mus = opendir("$this-> Directory /$this->Artist"))
{
$i=1;
while (false !== ($tracks = readdir($mus)))
{
if($tracks!=="." && $tracks!=="..")
{
$track=substr($tracks,0,-4);
$this->List.="\t\t<item>$this-> Directory /$this->Artist/$tracks; $track</item>\n";
$i++;
}
}
closedir($mus);
}
else
{
$this->List.="\t\t<item>null;hubo problemas: las causas pueden ser</item>\n";
$this->List.="\t\t<item>null;grupo o artista no existe o</item>\n";
$this->List.="\t\t<item>null;no hay album de dicho grupo o artista </item>\n";
}
$this->List.="\t</play_list>\n";
$this->List.="</config>";
return $this->List;
}
public function write_Tracks($file_writable)
{
$list=$this->set_GenerateList();
$file_xml = "$this->Directory/$file_writable";
if(file_exists($file_xml))
{
if (is_writable($file_xml))
{
if (!$gestor = fopen($file_xml, 'w+'))
{
exit;
}
if (fwrite($gestor, $list) === false)
{
exit;
}
fclose($gestor);
}
else
{
throw new Exception("No se puede escribir en el archivo");
}
}
else
{
throw new Exception("No existe Archivo");
}
}
}
?>
Cita:
Espero que me den alguna ayuda o al menos una idea, también estaba pensando en hacer alguna clase que me borrara solo el archivo XML de la cache de IE, no sé si esa idea sea estrambótica o es posible hacerlo, ya que si lo elimino de su caché entonces obligatoriamente el IE tendría que preguntar al servidor si existe el archivo XML ( cosa que está ahí, actualizado de acuerdo al artista seleccionado”). <?php
include("libs/CLTracks.php");
if(isset($_GET['artist']))
{
$artist=strip_tags($_GET['artist']);
}
else
{
$artist="artista_por_defecto";
}
try
{
$List = new Tracks("carp_audios",$artist);
$List->write_Tracks("pistas.xml");
}
catch(Exception $e)
{
echo $e->getMessage();
}
include("themes/theme01.php");
?>
include("libs/CLTracks.php");
if(isset($_GET['artist']))
{
$artist=strip_tags($_GET['artist']);
}
else
{
$artist="artista_por_defecto";
}
try
{
$List = new Tracks("carp_audios",$artist);
$List->write_Tracks("pistas.xml");
}
catch(Exception $e)
{
echo $e->getMessage();
}
include("themes/theme01.php");
?>