Writing to XML Playlist
Posted: Tue Dec 23, 2008 11:40 pm
Hi,
I had a drupal flash mp3 module created for me. It is not working correctly. Basically I submit a form with the song name, uploaded file, and the album the song goes to. The flash player is then supposed to display the album and song title and play the uploaded file when clicked on.
The player displays the album name and song name, but won't play the uploaded file. The first place I checked was the xml playlist. For url"" it prints
So I checked the function to write to the xml(the variable for the uploaded file is fmp_song_name)
The variable name comes back empty when I echo it.
I have searched the module file for where the fmp_song_name is defined. It is very confusing how the programmer did it.
I looked through the mysql database and noticed the module was not writing a value to the fmp_song_name entry in the mysql table. The other variables have their values correct in the database.
From what I can tell the programmer tried to upload the file to the default Drupal file system and then move it to a different directory. The problem is the way he coded makes it not work and also makes it hard to figure out how to edit.
Below I will paste the entire module code. I have searched all over the internet, in several forums, and the php manual. I am not a programmer and am just trying to get this thing to work.
Thanks for any help
I had a drupal flash mp3 module created for me. It is not working correctly. Basically I submit a form with the song name, uploaded file, and the album the song goes to. The flash player is then supposed to display the album and song title and play the uploaded file when clicked on.
The player displays the album name and song name, but won't play the uploaded file. The first place I checked was the xml playlist. For url"" it prints
Code: Select all
<?xml version="1.0" ?>
<songs>
<album name="New">
<song display="Wow" url="" />
</album>
</songs>Code: Select all
function write_xml()
{
$sql="select fmp_albums.fmp_album_name from fmp_albums";
$to_write="<?xml version=\"1.0\" ?>\n\t<songs>";
/* when I post this, the beginning ' gets stripped off the beginning of the xml block..
so make sure it is there when you put it back in your script */
$result = db_query($sql);
while($dept = db_fetch_object($result))
{
$to_write .= "\n\n\t\t".'<album name="'.$dept->fmp_album_name.'">';
$song_sql="select fmp_songs.fmp_song_name, fmp_songs.fmp_song_title from fmp_songs where fmp_songs.fmp_album_id=(select fmp_albums.fmp_album_id from fmp_albums where fmp_albums.fmp_album_name='".$dept->fmp_album_name."')";
//$song_sql="select * from fmp_songs,fmp_albums where fmp_songs.fmp_album_id=fmp_albums.fmp_album_id";
$result_song = db_query($song_sql);
while($album_song = db_fetch_object($result_song))
{
$to_write .="\n\t\t\t".'<song display="'.$album_song->fmp_song_title.'" url="'.$album_song->fmp_song_name.'" />';
echo 'Song: '.$album_song->fmp_song_name;
}
$to_write .= "\n\t\t".'</album>';
}
$to_write .= "\n\n\t".'</songs>';
echo $to_write;
$myFile = 'modules/music_player/songlist.xml';
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $to_write);
fclose($fh);
}
I have searched the module file for where the fmp_song_name is defined. It is very confusing how the programmer did it.
I looked through the mysql database and noticed the module was not writing a value to the fmp_song_name entry in the mysql table. The other variables have their values correct in the database.
From what I can tell the programmer tried to upload the file to the default Drupal file system and then move it to a different directory. The problem is the way he coded makes it not work and also makes it hard to figure out how to edit.
Below I will paste the entire module code. I have searched all over the internet, in several forums, and the php manual. I am not a programmer and am just trying to get this thing to work.
Code: Select all
<?php
// $Id$
// Module code start
function fmp_manager_help($section = '', $arg) {
$output = '';
switch ($section) {
case "admin/help#fmp_manager":
return $output = '<p>'. t("Manage your albums"). '</p>';
case 'admin/fmp_manager':
return $output = '<p>'. t("Simply manage your Songs.<br/><br/>") . l(t('Add new song'), "admin/fmp_manager/add", array(), $destination) .'</p>'.write_xml();
case 'admin/fmp_albums':
return $output = '<p>'. t("Create new album (s) [To add songs under any album, please follow 'Manage your songs' link.]<br/><br/>") . l(t('Add New Album'), "admin/fmp_albums/add", array(), $destination) .'</p>'.write_xml();
}
}
/**
* Valid permissions for this module
* @return array An array of valid permissions for the fmp_manager module
*/
function fmp_manager_perm() {
return array('administer fmp_manager' , 'access fmp_manager');
} // function fmp_manager_perm()
function fmp_manager_menu() {
//Menu for admin user
$items['admin/fmp_manager'] = array(
'title' => 'Manage your songs',
'description' => 'Administer fmp_manager',
'page callback' => 'fmp_manager_admin',
'access arguments' => array('administer fmp_manager'),
);
$items['admin/fmp_manager/add'] = array(
'title' => 'Add fmp_manager',
'page callback' => 'drupal_get_form',
'page arguments' => array('fmp_manager_edit'),
'access arguments' => array('administer fmp_manager'),
'type' => MENU_LOCAL_TASK
);
$items['admin/fmp_manager/edit/%'] = array(
'title' => t('Edit fmp_manager'),
'page callback' => 'drupal_get_form',
'page arguments' => array('fmp_manager_edit',3),
'access arguments' => array('administer fmp_manager'),
'type' => MENU_CALLBACK
);
$items['admin/fmp_manager/delete/%'] = array(
'title' => t('Delete fmp_manager'),
'page callback' => 'drupal_get_form',
//'page callback' => 'fmp_manager_delete_confirm',
'page arguments' => array('fmp_manager_delete_confirm',3),
'access arguments' => array('administer fmp_manager'),
'type' => MENU_CALLBACK
);
//Menu for all user
$items['fmp_manager'] = array(
'title' => t('Music Player'),
'page callback' => 'fmp_manager_browse',
//'page arguments' => array(1),
'access arguments' => array('access fmp_manager'),
);
// Sub fmp_manager section
$items['admin/fmp_albums'] = array(
'title' => 'Manage your albums',
'description' => 'Your albums',
'page callback' => 'fmp_albums_overview',
'access arguments' => array('administer fmp_manager'),
);
$items['admin/fmp_albums/add'] = array(
'title' => 'Add New Album',
'page callback' => 'drupal_get_form',
'page arguments' => array('fmp_albums_edit'),
'access arguments' => array('administer fmp_manager'),
'type' => MENU_LOCAL_TASK
);
$items['admin/fmp_albums/edit/%'] = array(
'title' => t('Edit the album'),
'page callback' => 'drupal_get_form',
'page arguments' => array('fmp_albums_edit',3),
'access arguments' => array('administer fmp_manager'),
'type' => MENU_CALLBACK
);
$items['admin/fmp_albums/delete'] = array(
'title' => t('Delete Album'),
'page callback' => 'drupal_get_form',
'page arguments' => array('fmp_albums_delete_confirm',3),
'access arguments' => array('administer fmp_manager'),
'type' => MENU_CALLBACK
);
return $items;
}
function fmp_manager_edit($edit = 0, $cid= 0) {
if ($cid) {
$alias = fmp_manager_load($cid);
drupal_set_title('Edit song details');
$output = fmp_manager_form($alias);
}
else {
drupal_set_title('Add new song');
$output = fmp_manager_form($cid);
}
return $output;
}
function fmp_albums_edit($edit=0, $sbid = 0) {
if ($sbid) {
$alias = fmp_albums_load($sbid);
//pr($alias);
drupal_set_title('Edit the album');
$output = fmp_albums_form($alias);
}
else {
drupal_set_title('Add New Album');
$output = fmp_albums_form();
}
return $output;
}
/**
* Return a form for creating or editing a fmp_manager.
*/
function fmp_manager_form($edit = '') {
//pr($edit);
if ($edit == ''){
$form['#prefix'] = '<p></p>';
}
$form['fmp_song_title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#size' => 60,
'#maxlength' => 255,
'#required' => true,
'#default_value' => $edit['fmp_song_title'],
);
$form['file'] = array(
'#type' => 'file',
'#title' => t('Select Song'),
'#size' => 40,
);
$form['fmp_album_id'] = array(
'#type' => 'select',
'#title' => t('Select Album'),
'#required' => true,
'#options' => get_fmp_albums_list(),
'#default_value' => $edit['fmp_album_id'],
);
if($edit['fmp_song_id']) {
$form['fmp_song_id'] = array('#type' => 'hidden', '#value' => $edit['fmp_song_id']);
$form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
} else {
$form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
}
$form['#attributes'] = array('enctype' => "multipart/form-data");
$form['#redirect'] = array('admin/fmp_manager', 'destination=fmp_manager');
$form['#submit'] = array('fmp_manager_form_submit');
return $form;
}
/**
* Return a form for creating or editing a sub fmp_manager category.
*/
function fmp_albums_form($edit = '') {
if ($edit == ''){
$form['#prefix'] = '<p></p>';
}
$form['fmp_album_name'] = array(
'#type' => 'textfield',
'#title' => t('Album name'),
'#required' => true,
'#size' => 60,
'#maxlength' => 255,
'#default_value' => $edit['fmp_album_name'],
);
if ($edit['fmp_album_id']) {
$form['id'] = array('#type' => 'hidden', '#value' => $edit['fmp_album_id']);
$form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
} else {
$form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
}
$form['#submit'] = array('fmp_albums_form_submit');
$form['#redirect'] = array('admin/fmp_albums', 'destination=fmp_albums');
return $form;
}
/**
* Menu callback; presents an overview of all fmp_managers.
*/
function fmp_manager_admin() {
return fmp_manager_overview();
}
/** Menu callback; confirms deleting fmp_manager **/
function fmp_manager_delete_confirm($frm=null,$did=0) {
$fmp_manager = fmp_manager_load($did);
//pr($fmp_manager);
if (user_access('administer fmp_manager')) {
$form['fmp_song_id'] = array('#type' => 'value', '#value' => $did);
$form['#submit'] = array('fmp_manager_delete_confirm_submit');
$form['#redirect'] = array('admin/fmp_manager', 'destination=fmp_manager');
$output = confirm_form(
$form,
t('Are you sure you want to delete the song "'.$fmp_manager['fmp_song_title'] .'"?'),
isset($_GET['destination']) ? $_GET['destination'] : 'admin/fmp_manager',
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
return $output;
}
/**
* Menu callback; confirms deleting fmp_manager
**/
function fmp_albums_delete_confirm($frm = null, $cid) {
$fmp_manager = fmp_albums_load($cid);
//pr($cid);
if (user_access('administer fmp_manager')) {
$form['pcid'] = array('#type' => 'value', '#value' => $cid);
$form['#submit'] = array('fmp_albums_delete_confirm_submit');
$form['#redirect'] = array('admin/fmp_albums', 'destination=fmp_albums');
$output = confirm_form(
$form,
t('Are you sure you want to delete the album "'.$fmp_manager['sub_dept_name'] .'"?'),
isset($_GET['destination']) ? $_GET['destination'] : 'admin/fmp_albums',
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
return $output;
}
function fmp_manager_delete_confirm_submit($form_id, $form_values) {
if ($form_values['values']['confirm']) {
fmp_manager_delete($form_values['values']['fmp_song_id']);
return true;
}
}
function fmp_albums_delete_confirm_submit($form_id, $form_values) {
if ($form_values['values']['confirm']) {
fmp_albums_delete($form_values['values']['pcid']);
return true;
}
}
/**
* Post-confirmation; delete a fmp_manager.
*/
function fmp_manager_delete($did = 0) {
$sql="select s.fmp_song_name FROM {fmp_songs s} WHERE fmp_song_id = $did";
$result = db_query($sql);
while($l = db_fetch_object($result)) {
$location=$l->fmp_song_name;
}
$file = "modules/music_player/songs/".$location;
$folder = "modules/music_player/songs";
$dir=dir("./$folder/.");
$found=false;
while($filename=$dir->read()) {
if($filename==$location){
$found=true;
}
}
if($found){
unlink($file);
}
$dir->close();
if(db_query('DELETE FROM {fmp_songs} WHERE fmp_song_id = %d', $did)) {
drupal_set_message(t('Song has been deleted.'), 'warning');
} else {
drupal_set_message(t('Their was an error deleting the song. Please try agin later.'), 'error');
}
}
/**
* Post-confirmation; delete a sub fmp_manager.
*/
function fmp_albums_delete($sbid = 0) {
if(db_query('DELETE FROM {fmp_albums} WHERE fmp_album_id = %d', $sbid)) {
drupal_set_message(t('Album has been deleted successfully.'), 'warning');
} else {
drupal_set_message(t('There was an error deleting the album. Please try agin later.'), 'error');
}
}
/**
* Fetch a specific fmp_manager from the database.
*/
function fmp_manager_load($did) {
return db_fetch_array(db_query('SELECT * FROM {fmp_songs} d WHERE d.fmp_song_id= %d', $did));
}
function fmp_manager_load_from_shortname($sName) {
//printf('SELECT * FROM {fmp_manager} d WHERE d.dept_id= %d', $did);
return db_fetch_array(db_query('SELECT * FROM {fmp_manager} d WHERE d.short_name= "%s"', $sName));
}
/**
* Fetch a specific sub fmp_manager from the database.
*/
function fmp_albums_load($sbid) {
return db_fetch_array(db_query('SELECT * FROM {fmp_albums} pc where fmp_album_id=%s',$sbid));
}
/**
* Save a fmp_manager to the database.
*/
function fmp_manager_form_submit($form_id, $form_values) {
global $user;
// pr($form_values);
/*
$validators = array(
'file_validate_is_image' => array(),
'file_validate_image_resolution' => array('85x85')),
'file_validate_size' => array(30 * 1024),
);
if ($file = file_save_upload('picture_upload',$validators)) {
// All that validation is taken care of... but image was saved using
// file_save_upload() and was added to the files table as a
// temporary file. We'll make a copy and let the garbage collector
// delete the original upload.
$info = image_get_info($file->filepath);
//$dest= '../../music_player/songs/'.$info['name'].$info['extension'];
file_copy($file, $dest, FILE_EXISTS_REPLACE);
};
*/
// pr("<br />");
$validators = array(
'file_validate_extensions' => array('mp3','wav','mpeg','aac'),
);
if($file = file_save_upload('file',$validators,'songs',$replace = FILE_EXISTS_RENAME)){
//pr($file);
$updateFile = $file->filepath;
}else{
//pr('error');
}
//pr($_FILES);
//pr($file);
if($form_values['values']['fmp_song_id']) {
//update
db_query("UPDATE {fmp_songs} SET
fmp_song_title = '%s', fmp_song_name = '%s', fmp_album_id = '%d'
WHERE fmp_song_id = %d"
, $form_values['values']['fmp_song_title'], $file->filepath, $form_values['values']['fmp_album_id']
, $form_values['values']['fmp_song_id']
);
drupal_set_message('Song has been updated. ', 'status');
} else {
//insert
$file_location = $file->filepath;
$pieces = explode("music_player/songs", $file_location);
$temp = $pieces[1];
$p = explode("./", $temp);
$location = $p[1];
$query = db_query("INSERT INTO {fmp_songs}
(fmp_song_title, fmp_song_name, fmp_album_id,create_date)
VALUES ('%s', '%s','%s','%d')"
, $form_values['values']['fmp_song_title'], $location, $form_values['values']['fmp_album_id']
, time()
);
if($query) {
drupal_set_message('New song added successfully', 'status');
} else {
drupal_set_message('There was an error in saving your entry. Please try again later. ', 'error');
}
}
return 'admin/fmp_manager';
}
/**
* Save a sub fmp_manager to the database.
*/
function fmp_albums_form_submit($form_id, $form_values) {
global $user;
if($form_values['values']['id']) {
//update
db_query("UPDATE {fmp_albums} SET
fmp_album_name = '%s'
WHERE fmp_album_id = %d"
, $form_values['values']['fmp_album_name'], $form_values['values']['id']
);
drupal_set_message('Album has been updated. ', 'status');
} else {
//insert
$query = db_query("INSERT INTO {fmp_albums}
(fmp_album_name)
VALUES ('%s')"
, $form_values['values']['fmp_album_name']
);
if($query) {
drupal_set_message('Album has been created successfully', 'status');
} else {
drupal_set_message('There was an error in saving your entry. Please try again later. ', 'error');
}
}
return 'admin/fmp_albums';
}
/**
* Return a listing of all fmp_manager.
*/
function fmp_manager_overview() {
global $user;
//$sql = "SELECT * FROM {fmp_songs}";
$sql = "select fmp_songs.fmp_song_id,fmp_songs.fmp_song_title,fmp_albums.fmp_album_name from fmp_songs,fmp_albums where(fmp_songs.fmp_album_id=fmp_albums.fmp_album_id)";
//$order_clause = " ORDER BY C.create_date DESC";
$order_clause = " ORDER BY fmp_song_id ASC";
$header = array(
array('data' => t('File Name'), 'field' => 'fmp_song_title'),
array('data' => t('Album')),
array('data' => t('Operations'), 'colspan' => '3')
);
$sql .= tablesort_sql($header);
/*if(!preg_match("/ORDER BY/", $sql)) {
$sql .= $order_clause;
}*/
$result = pager_query($sql, 20);
$destination = drupal_get_destination();
while ($data = db_fetch_object($result)) {
$rows[] = array(
l(t(check_plain($data->fmp_song_title)),"admin/fmp_manager"),
check_plain($data->fmp_album_name),
l(t('edit'), "admin/fmp_manager/edit/$data->fmp_song_id", array(), $destination),
l(t('delete'), "admin/fmp_manager/delete/$data->fmp_song_id", array(), $destination),
);
}
if (!$rows) {
$rows[] = array(array('data' => t('No songs added yet.'), 'colspan' => '9'));
}
$output = theme('table', $header, $rows);
$output .= theme('pager', NULL, 20, 0);
return $output;
}
function fmp_albums_overview() {
global $user;
$sql = "SELECT * FROM {fmp_albums} pc";
$order_clause = " ORDER BY pc.fmp_album_name ASC";
$header = array(
array('data' => t('Album name'), 'field' => 'fmp_album_name'),
array('data' => t('Operations'), 'colspan' => '3'));
$sql .= tablesort_sql($header);
if(!preg_match("/ORDER BY/", $sql)) {
$sql .= $order_clause;
}
$result = pager_query($sql, 20);
$destination = drupal_get_destination();
while ($data = db_fetch_object($result)) {
$rows[] = array(
check_plain($data->fmp_album_name),
check_plain($data->department_name),
l(t('edit'), "admin/fmp_albums/edit/$data->fmp_album_id", array(), $destination),
l(t('delete'), "admin/fmp_albums/delete/$data->fmp_album_id", array(), $destination)
);
}
if (!$rows) {
$rows[] = array(array('data' => t('You have not created any albums yet.'), 'colspan' => '9'));
}
$output = theme('table', $header, $rows);
$output .= theme('pager', NULL, 20, 0);
return $output;
}
/**
* Return a listing of all fmp_manager.
*/
function fmp_manager_browse($shortname = '') {
global $user;
drupal_set_title('Music Player ');
$output = '';
$modulepath = drupal_get_path('module', 'fmp_manager');
$flashPlayerPath = $GLOBALS['base_url'].'/'.$modulepath;
$output.='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="600" height="300" title="Music player">';
$output.= '<param name="movie" value="'.$flashPlayerPath.'/music1.swf" />
<param name="xmlPath" value="'.$flashPlayerPath.'" />
<param name="xmlName" value="'.$flashPlayerPath.'" />
<param name="quality" value="high" />
<embed src="'.$flashPlayerPath.'/music1.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="300"></embed>
</object>';
// pr($fmp_managerArray);
// $output = theme('fmp_manager',$fmp_managerArray);
//pr($shortname);
return $output;
}
function fmp_manager_browse_p2($shortname = '') {
global $user;
drupal_set_title('Player 2');
$output = '';
$modulepath = drupal_get_path('module', 'fmp_manager');
$flashPlayerPath = $GLOBALS['base_url'].'/'.$modulepath;
$output.='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="600" height="300" title="flash media player">';
$output.= '<param name="movie" value="'.$flashPlayerPath.'/fmp_sampleSix.swf" />
<param name="xmlPath" value="'.$flashPlayerPath.'" />
<param name="xmlName" value="'.$flashPlayerPath.'" />
<param name="quality" value="high" />
<embed src="'.$flashPlayerPath.'/fmp_sampleSix.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="300"></embed>
</object>';
// pr($fmp_managerArray);
// $output = theme('fmp_manager',$fmp_managerArray);
//pr($shortname);
return $output;
}
function fmp_manager_browse_p3($shortname = '') {
global $user;
drupal_set_title('Player 3');
$output = '';
$modulepath = drupal_get_path('module', 'fmp_manager');
$flashPlayerPath = $GLOBALS['base_url'].'/'.$modulepath;
$output.='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="600" height="300" title="flash media player">';
$output.= '<param name="movie" value="'.$flashPlayerPath.'/fmp_sampleThree.swf" />
<param name="xmlPath" value="'.$flashPlayerPath.'" />
<param name="xmlName" value="'.$flashPlayerPath.'" />
<param name="quality" value="high" />
<embed src="'.$flashPlayerPath.'/fmp_sampleThree.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="300"></embed>
</object>';
// pr($fmp_managerArray);
// $output = theme('fmp_manager',$fmp_managerArray);
//pr($shortname);
return $output;
}
function fmp_manager_browse_p4($shortname = '') {
global $user;
drupal_set_title('Player 4');
$output = '';
$modulepath = drupal_get_path('module', 'fmp_manager');
$flashPlayerPath = $GLOBALS['base_url'].'/'.$modulepath;
$output.='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="600" height="300" title="flash media player">';
$output.= '<param name="movie" value="'.$flashPlayerPath.'/fmp_sampleFour.swf" />
<param name="xmlPath" value="'.$flashPlayerPath.'" />
<param name="xmlName" value="'.$flashPlayerPath.'" />
<param name="quality" value="high" />
<embed src="'.$flashPlayerPath.'/fmp_sampleFour.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="300"></embed>
</object>';
// pr($fmp_managerArray);
// $output = theme('fmp_manager',$fmp_managerArray);
//pr($shortname);
return $output;
}
function fmp_manager_browse_p5($shortname = '') {
global $user;
drupal_set_title('Player 5');
$output = '';
$modulepath = drupal_get_path('module', 'fmp_manager');
$flashPlayerPath = $GLOBALS['base_url'].'/'.$modulepath;
$output.='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="600" height="300" title="flash media player">';
$output.= '<param name="movie" value="'.$flashPlayerPath.'/fmp_sampleFive.swf" />
<param name="xmlPath" value="'.$flashPlayerPath.'" />
<param name="xmlName" value="'.$flashPlayerPath.'" />
<param name="quality" value="high" />
<embed src="'.$flashPlayerPath.'/fmp_sampleFive.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="300"></embed>
</object>';
// pr($fmp_managerArray);
// $output = theme('fmp_manager',$fmp_managerArray);
//pr($shortname);
return $output;
}
function fmp_manager_browse_p6($shortname = '') {
global $user;
drupal_set_title('Player 6');
$output = '';
$modulepath = drupal_get_path('module', 'fmp_manager');
$flashPlayerPath = $GLOBALS['base_url'].'/'.$modulepath;
$output.='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="600" height="300" title="flash media player">';
$output.= '<param name="movie" value="'.$flashPlayerPath.'/fmp_sampleTwo.swf" />
<param name="xmlPath" value="'.$flashPlayerPath.'" />
<param name="xmlName" value="'.$flashPlayerPath.'" />
<param name="quality" value="high" />
<embed src="'.$flashPlayerPath.'/fmp_sampleTwo.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="300"></embed>
</object>';
// pr($fmp_managerArray);
// $output = theme('fmp_manager',$fmp_managerArray);
//pr($shortname);
return $output;
}
function get_fmp_albums_list(){
$dept_list = array();
$dept_list[''] = '';
$result = db_query("SELECT * FROM {fmp_albums}");
while($dept = db_fetch_object($result)) {
$dept_list[$dept->fmp_album_id] = $dept->fmp_album_name;
}
return $dept_list;
}
function pr($data)
{
echo "<pre>";
print_r($data);
echo "</pre>";
}
function write_xml()
{
$sql="select fmp_albums.fmp_album_name from fmp_albums";
$to_write="<?xml version=\"1.0\" ?>\n\t<songs>";
/* when I post this, the beginning ' gets stripped off the beginning of the xml block..
so make sure it is there when you put it back in your script */
$result = db_query($sql);
while($dept = db_fetch_object($result))
{
$to_write .= "\n\n\t\t".'<album name="'.$dept->fmp_album_name.'">';
$song_sql="select fmp_songs.fmp_song_name, fmp_songs.fmp_song_title from fmp_songs where fmp_songs.fmp_album_id=(select fmp_albums.fmp_album_id from fmp_albums where fmp_albums.fmp_album_name='".$dept->fmp_album_name."')";
//$song_sql="select * from fmp_songs,fmp_albums where fmp_songs.fmp_album_id=fmp_albums.fmp_album_id";
$result_song = db_query($song_sql);
while($album_song = db_fetch_object($result_song))
{
$to_write .="\n\t\t\t".'<song display="'.$album_song->fmp_song_title.'" url="'.$album_song->fmp_song_name.'" />';
echo 'Song: '.$album_song->fmp_song_name;
}
$to_write .= "\n\t\t".'</album>';
}
$to_write .= "\n\n\t".'</songs>';
echo $to_write;
$myFile = 'modules/music_player/songlist.xml';
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $to_write);
fclose($fh);
}
Thanks for any help