\n"; $sql = "SELECT `id`, `name`, `prefix` FROM `album` ORDER BY `name`"; $db_results = Dba::read($sql); while ($r = Dba::fetch_assoc($db_results)) { $selected = ''; $album_name = trim($r['prefix'] . " " . $r['name']); if ($r['id'] == $album_id) { $selected = "selected=\"selected\""; } echo "\t\n"; } // end while if ($allow_add) { // Append additional option to the end with value=-1 echo "\t\n"; } echo "\n"; } // show_album_select /** * show_artist_select * This is the same as show_album_select except it's *gasp* for artists! How * inventive! */ function show_artist_select($name='artist', $artist_id=0, $allow_add=0, $song_id=0) { // Generate key to use for HTML element ID static $id_cnt; if ($song_id) { $key = "artist_select_$song_id"; } else { $key = "artist_select_c" . ++$id_cnt; } echo "\n"; } // show_artist_select /** * show_catalog_select * Yet another one of these buggers. this shows a drop down of all of your * catalogs. */ function show_catalog_select($name='catalog',$catalog_id=0,$style='') { echo "\n"; } // show_catalog_select /** * show_user_select * This one is for users! shows a select/option statement so you can pick a user * to blame */ function show_user_select($name,$selected='',$style='') { echo "\n"; } // show_user_select /** * show_playlist_select * This one is for playlists! */ function show_playlist_select($name,$selected='',$style='') { echo "\n"; } // show_playlist_select // FIXME: This should probably go in XML_Data /** * xml_from_array * This takes a one dimensional array and creates a XML document from it. For * use primarily by the ajax mojo. */ function xml_from_array($array, $callback = false, $type = '') { $string = ''; // If we weren't passed an array then return if (!is_array($array)) { return $string; } // The type is used for the different XML docs we pass switch ($type) { case 'itunes': foreach ($array as $key=>$value) { if (is_array($value)) { $value = xml_from_array($value,1,$type); $string .= "\t\t<$key>\n$value\t\t\n"; } else { if ($key == "key"){ $string .= "\t\t<$key>$value\n"; } elseif (is_int($value)) { $string .= "\t\t\t$key$value\n"; } elseif ($key == "Date Added") { $string .= "\t\t\t$key$value\n"; } elseif (is_string($value)) { /* We need to escape the value */ $string .= "\t\t\t$key\n"; } } } // end foreach return $string; break; case 'xspf': foreach ($array as $key=>$value) { if (is_array($value)) { $value = xml_from_array($value,1,$type); $string .= "\t\t<$key>\n$value\t\t\n"; } else { if ($key == "key"){ $string .= "\t\t<$key>$value\n"; } elseif (is_numeric($value)) { $string .= "\t\t\t<$key>$value\n"; } elseif (is_string($value)) { /* We need to escape the value */ $string .= "\t\t\t<$key>\n"; } } } // end foreach return $string; break; default: foreach ($array as $key => $value) { // No numeric keys if (is_numeric($key)) { $key = 'item'; } if (is_array($value)) { // Call ourself $value = xml_from_array($value, true); $string .= "\t$value\n"; } else { /* We need to escape the value */ $string .= "\t\n"; } // end foreach elements } if (!$callback) { $string = '' . "\n\n" . $string . "\n"; } return UI::clean_utf8($string); break; } } // xml_from_array /** * xml_get_header * This takes the type and returns the correct xml header */ function xml_get_header($type){ switch ($type){ case 'itunes': $header = "\n" . "\n" . "\n" . "\n" . " Major Version1\n" . " Minor Version1\n" . " Application Version7.0.2\n" . " Features1\n" . " Show Content Ratings\n" . " Tracks\n" . " \n"; return $header; break; case 'xspf': $header = "\n" . ""; "\n ". "Ampache XSPF Playlist\n" . "" . Config::get('site_title') . "\n" . "" . Config::get('site_title') . "\n" . "". Config::get('web_path') ."\n" . "\n\n\n\n"; return $header; break; default: $header = "\n"; return $header; break; } } //xml_get_header /** * xml_get_footer * This takes the type and returns the correct xml footer */ function xml_get_footer($type){ switch ($type){ case 'itunes': $footer = " \n" . "\n" . "\n"; return $footer; break; case 'xspf': $footer = " \n" . "\n"; return $footer; break; default: break; } } // xml_get_footer /** * toggle_visible * This is identical to the javascript command that it actually calls */ function toggle_visible($element) { echo '\n"; } // toggle_visible /** * print_bool * This function takes a boolean value and then prints out a friendly text * message. */ function print_bool($value) { if ($value) { $string = '' . T_('On') . ''; } else { $string = '' . T_('Off') . ''; } return $string; } // print_bool /** * show_now_playing * This shows the now playing templates and does some garbage collecion * this should really be somewhere else */ function show_now_playing() { Session::gc(null); Stream::gc_now_playing(); $web_path = Config::get('web_path'); $results = Stream::get_now_playing(); require_once Config::get('prefix') . '/templates/show_now_playing.inc.php'; } // show_now_playing ?>