diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2013-01-26 03:00:32 -0500 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2013-01-26 03:38:46 -0500 |
commit | ef4d3660605efc7f1328d4533b0f4bfb6c1107e2 (patch) | |
tree | e4377fb129a899e65aaaf421f8c97098aecaedd5 /lib/ui.lib.php | |
parent | 8a750c3e875d590d351c3042570a134fcdf03e5d (diff) | |
download | ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.tar.gz ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.tar.bz2 ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.zip |
Cosmetics: death to tabs
The refactoring I've been doing has reminded me of my strong preference
for spaces, and I feel inclined to impose my will on the tree.
Diffstat (limited to 'lib/ui.lib.php')
-rw-r--r-- | lib/ui.lib.php | 698 |
1 files changed, 349 insertions, 349 deletions
diff --git a/lib/ui.lib.php b/lib/ui.lib.php index a72c4c70..1ac4159d 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * This contains functions that are generic, and display information @@ -29,22 +29,22 @@ * * shows a confirmation of an action * - * @param string $title The Title of the message - * @param string $text The details of the message - * @param string $next_url Where to go next - * @param integer $cancel T/F show a cancel button that uses return_referrer() - * @return void + * @param string $title The Title of the message + * @param string $text The details of the message + * @param string $next_url Where to go next + * @param integer $cancel T/F show a cancel button that uses return_referrer() + * @return void */ function show_confirmation($title,$text,$next_url,$cancel=0,$form_name='confirmation') { - if (substr_count($next_url,Config::get('web_path'))) { - $path = $next_url; - } - else { - $path = Config::get('web_path') . "/$next_url"; - } + if (substr_count($next_url,Config::get('web_path'))) { + $path = $next_url; + } + else { + $path = Config::get('web_path') . "/$next_url"; + } - require Config::get('prefix') . '/templates/show_confirmation.inc.php'; + require Config::get('prefix') . '/templates/show_confirmation.inc.php'; } // show_confirmation @@ -56,21 +56,21 @@ function show_confirmation($title,$text,$next_url,$cancel=0,$form_name='confirma */ function return_referer() { - $referer = $_SERVER['HTTP_REFERER']; - if (substr($referer, -1)=='/'){ - $file = 'index.php'; - } - else { - $file = basename($referer); - /* Strip off the filename */ - $referer = substr($referer,0,strlen($referer)-strlen($file)); - } + $referer = $_SERVER['HTTP_REFERER']; + if (substr($referer, -1)=='/'){ + $file = 'index.php'; + } + else { + $file = basename($referer); + /* Strip off the filename */ + $referer = substr($referer,0,strlen($referer)-strlen($file)); + } - if (substr($referer,strlen($referer)-6,6) == 'admin/') { - $file = 'admin/' . $file; - } + if (substr($referer,strlen($referer)-6,6) == 'admin/') { + $file = 'admin/' . $file; + } - return $file; + return $file; } // return_referer @@ -81,96 +81,96 @@ function return_referer() { * information. It returns an array of information about what they are currently * doing. * Possible array elements - * ['title'] Text name for the page - * ['page'] actual page name - * ['section'] name of the section we are in, admin, browse etc (submenu) + * ['title'] Text name for the page + * ['page'] actual page name + * ['section'] name of the section we are in, admin, browse etc (submenu) */ function get_location() { - $location = array(); - - if (strlen($_SERVER['PHP_SELF'])) { - $source = $_SERVER['PHP_SELF']; - } - else { - $source = $_SERVER['REQUEST_URI']; - } - - /* Sanatize the $_SERVER['PHP_SELF'] variable */ - $source = str_replace(Config::get('raw_web_path'), "", $source); - $location['page'] = preg_replace("/^\/(.+\.php)\/?.*/","$1",$source); - - switch ($location['page']) { - case 'index.php': - $location['title'] = T_('Home'); - break; - case 'upload.php': - $location['title'] = T_('Upload'); - break; - case 'localplay.php': - $location['title'] = T_('Local Play'); - break; - case 'randomplay.php': - $location['title'] = T_('Random Play'); - break; - case 'playlist.php': - $location['title'] = T_('Playlist'); - break; - case 'search.php': - $location['title'] = T_('Search'); - break; - case 'preferences.php': - $location['title'] = T_('Preferences'); - break; - case 'admin/index.php': - $location['title'] = T_('Admin-Catalog'); - $location['section'] = 'admin'; - break; - case 'admin/catalog.php': - $location['title'] = T_('Admin-Catalog'); - $location['section'] = 'admin'; - break; - case 'admin/users.php': - $location['title'] = T_('Admin-User Management'); - $location['section'] = 'admin'; - break; - case 'admin/mail.php': - $location['title'] = T_('Admin-Mail Users'); - $location['section'] = 'admin'; - break; - case 'admin/access.php': - $location['title'] = T_('Admin-Manage Access Lists'); - $location['section'] = 'admin'; - break; - case 'admin/preferences.php': - $location['title'] = T_('Admin-Site Preferences'); - $location['section'] = 'admin'; - break; - case 'admin/modules.php': - $location['title'] = T_('Admin-Manage Modules'); - $location['section'] = 'admin'; - break; - case 'browse.php': - $location['title'] = T_('Browse Music'); - $location['section'] = 'browse'; - break; - case 'albums.php': - $location['title'] = T_('Albums'); - $location['section'] = 'browse'; - break; - case 'artists.php': - $location['title'] = T_('Artists'); - $location['section'] = 'browse'; - break; - case 'stats.php': - $location['title'] = T_('Statistics'); - break; - default: - $location['title'] = ''; - break; - } // switch on raw page location - - return $location; + $location = array(); + + if (strlen($_SERVER['PHP_SELF'])) { + $source = $_SERVER['PHP_SELF']; + } + else { + $source = $_SERVER['REQUEST_URI']; + } + + /* Sanatize the $_SERVER['PHP_SELF'] variable */ + $source = str_replace(Config::get('raw_web_path'), "", $source); + $location['page'] = preg_replace("/^\/(.+\.php)\/?.*/","$1",$source); + + switch ($location['page']) { + case 'index.php': + $location['title'] = T_('Home'); + break; + case 'upload.php': + $location['title'] = T_('Upload'); + break; + case 'localplay.php': + $location['title'] = T_('Local Play'); + break; + case 'randomplay.php': + $location['title'] = T_('Random Play'); + break; + case 'playlist.php': + $location['title'] = T_('Playlist'); + break; + case 'search.php': + $location['title'] = T_('Search'); + break; + case 'preferences.php': + $location['title'] = T_('Preferences'); + break; + case 'admin/index.php': + $location['title'] = T_('Admin-Catalog'); + $location['section'] = 'admin'; + break; + case 'admin/catalog.php': + $location['title'] = T_('Admin-Catalog'); + $location['section'] = 'admin'; + break; + case 'admin/users.php': + $location['title'] = T_('Admin-User Management'); + $location['section'] = 'admin'; + break; + case 'admin/mail.php': + $location['title'] = T_('Admin-Mail Users'); + $location['section'] = 'admin'; + break; + case 'admin/access.php': + $location['title'] = T_('Admin-Manage Access Lists'); + $location['section'] = 'admin'; + break; + case 'admin/preferences.php': + $location['title'] = T_('Admin-Site Preferences'); + $location['section'] = 'admin'; + break; + case 'admin/modules.php': + $location['title'] = T_('Admin-Manage Modules'); + $location['section'] = 'admin'; + break; + case 'browse.php': + $location['title'] = T_('Browse Music'); + $location['section'] = 'browse'; + break; + case 'albums.php': + $location['title'] = T_('Albums'); + $location['section'] = 'browse'; + break; + case 'artists.php': + $location['title'] = T_('Artists'); + $location['section'] = 'browse'; + break; + case 'stats.php': + $location['title'] = T_('Statistics'); + break; + default: + $location['title'] = ''; + break; + } // switch on raw page location + + return $location; } // get_location @@ -180,7 +180,7 @@ function get_location() { */ function show_preference_box($preferences) { - require Config::get('prefix') . '/templates/show_preference_box.inc.php'; + require Config::get('prefix') . '/templates/show_preference_box.inc.php'; } // show_preference_box @@ -190,37 +190,37 @@ function show_preference_box($preferences) { * hella long). It's used by the Edit page and takes a $name and a $album_id */ function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0) { - // Generate key to use for HTML element ID - static $id_cnt; - if ($song_id) { - $key = "album_select_$song_id"; - } else { - $key = "album_select_c" . ++$id_cnt; - } + // Generate key to use for HTML element ID + static $id_cnt; + if ($song_id) { + $key = "album_select_$song_id"; + } else { + $key = "album_select_c" . ++$id_cnt; + } - // Added ID field so we can easily observe this element - echo "<select name=\"$name\" id=\"$key\">\n"; + // Added ID field so we can easily observe this element + echo "<select name=\"$name\" id=\"$key\">\n"; - $sql = "SELECT `id`, `name`, `prefix` FROM `album` ORDER BY `name`"; - $db_results = Dba::read($sql); + $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\""; - } + 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<option value=\"" . $r['id'] . "\" $selected>" . scrub_out($album_name) . "</option>\n"; + echo "\t<option value=\"" . $r['id'] . "\" $selected>" . scrub_out($album_name) . "</option>\n"; - } // end while + } // end while - if ($allow_add) { - // Append additional option to the end with value=-1 - echo "\t<option value=\"-1\">" . T_('Add New') . "...</option>\n"; - } + if ($allow_add) { + // Append additional option to the end with value=-1 + echo "\t<option value=\"-1\">" . T_('Add New') . "...</option>\n"; + } - echo "</select>\n"; + echo "</select>\n"; } // show_album_select @@ -230,36 +230,36 @@ function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0) { * 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; - } + // 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 "<select name=\"$name\" id=\"$key\">\n"; + echo "<select name=\"$name\" id=\"$key\">\n"; - $sql = "SELECT `id`, `name`, `prefix` FROM `artist` ORDER BY `name`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id`, `name`, `prefix` FROM `artist` ORDER BY `name`"; + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { - $selected = ''; - $artist_name = trim($r['prefix'] . " " . $r['name']); - if ($r['id'] == $artist_id) { - $selected = "selected=\"selected\""; - } + while ($r = Dba::fetch_assoc($db_results)) { + $selected = ''; + $artist_name = trim($r['prefix'] . " " . $r['name']); + if ($r['id'] == $artist_id) { + $selected = "selected=\"selected\""; + } - echo "\t<option value=\"" . $r['id'] . "\" $selected>" . scrub_out($artist_name) . "</option>\n"; + echo "\t<option value=\"" . $r['id'] . "\" $selected>" . scrub_out($artist_name) . "</option>\n"; - } // end while + } // end while - if ($allow_add) { - // Append additional option to the end with value=-1 - echo "\t<option value=\"-1\">Add New...</option>\n"; - } + if ($allow_add) { + // Append additional option to the end with value=-1 + echo "\t<option value=\"-1\">Add New...</option>\n"; + } - echo "</select>\n"; + echo "</select>\n"; } // show_artist_select @@ -270,22 +270,22 @@ function show_artist_select($name='artist', $artist_id=0, $allow_add=0, $song_id */ function show_catalog_select($name='catalog',$catalog_id=0,$style='') { - echo "<select name=\"$name\" style=\"$style\">\n"; + echo "<select name=\"$name\" style=\"$style\">\n"; - $sql = "SELECT `id`, `name` FROM `catalog` ORDER BY `name`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id`, `name` FROM `catalog` ORDER BY `name`"; + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { - $selected = ''; - if ($r['id'] == $catalog_id) { - $selected = "selected=\"selected\""; - } + while ($r = Dba::fetch_assoc($db_results)) { + $selected = ''; + if ($r['id'] == $catalog_id) { + $selected = "selected=\"selected\""; + } - echo "\t<option value=\"" . $r['id'] . "\" $selected>" . scrub_out($r['name']) . "</option>\n"; + echo "\t<option value=\"" . $r['id'] . "\" $selected>" . scrub_out($r['name']) . "</option>\n"; - } // end while + } // end while - echo "</select>\n"; + echo "</select>\n"; } // show_catalog_select @@ -296,24 +296,24 @@ function show_catalog_select($name='catalog',$catalog_id=0,$style='') { */ function show_user_select($name,$selected='',$style='') { - echo "<select name=\"$name\" style=\"$style\">\n"; - echo "\t<option value=\"\">" . T_('All') . "</option>\n"; + echo "<select name=\"$name\" style=\"$style\">\n"; + echo "\t<option value=\"\">" . T_('All') . "</option>\n"; - $sql = "SELECT `id`,`username`,`fullname` FROM `user` ORDER BY `fullname`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id`,`username`,`fullname` FROM `user` ORDER BY `fullname`"; + $db_results = Dba::read($sql); - while ($row = Dba::fetch_assoc($db_results)) { - $select_txt = ''; - if ($row['id'] == $selected) { - $select_txt = 'selected="selected"'; - } - // If they don't have a full name, revert to the username - $row['fullname'] = $row['fullname'] ? $row['fullname'] : $row['username']; + while ($row = Dba::fetch_assoc($db_results)) { + $select_txt = ''; + if ($row['id'] == $selected) { + $select_txt = 'selected="selected"'; + } + // If they don't have a full name, revert to the username + $row['fullname'] = $row['fullname'] ? $row['fullname'] : $row['username']; - echo "\t<option value=\"" . $row['id'] . "\" $select_txt>" . scrub_out($row['fullname']) . "</option>\n"; - } // end while users + echo "\t<option value=\"" . $row['id'] . "\" $select_txt>" . scrub_out($row['fullname']) . "</option>\n"; + } // end while users - echo "</select>\n"; + echo "</select>\n"; } // show_user_select @@ -323,22 +323,22 @@ function show_user_select($name,$selected='',$style='') { */ function show_playlist_select($name,$selected='',$style='') { - echo "<select name=\"$name\" style=\"$style\">\n"; - echo "\t<option value=\"\">" . T_('None') . "</option>\n"; + echo "<select name=\"$name\" style=\"$style\">\n"; + echo "\t<option value=\"\">" . T_('None') . "</option>\n"; - $sql = "SELECT `id`,`name` FROM `playlist` ORDER BY `name`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id`,`name` FROM `playlist` ORDER BY `name`"; + $db_results = Dba::read($sql); - while ($row = Dba::fetch_assoc($db_results)) { - $select_txt = ''; - if ($row['id'] == $selected) { - $select_txt = 'selected="selected"'; - } - // If they don't have a full name, revert to the username - echo "\t<option value=\"" . $row['id'] . "\" $select_txt>" . scrub_out($row['name']) . "</option>\n"; - } // end while users + while ($row = Dba::fetch_assoc($db_results)) { + $select_txt = ''; + if ($row['id'] == $selected) { + $select_txt = 'selected="selected"'; + } + // If they don't have a full name, revert to the username + echo "\t<option value=\"" . $row['id'] . "\" $select_txt>" . scrub_out($row['name']) . "</option>\n"; + } // end while users - echo "</select>\n"; + echo "</select>\n"; } // show_playlist_select @@ -350,93 +350,93 @@ function show_playlist_select($name,$selected='',$style='') { */ 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</$key>\n"; - } - else { - if ($key == "key"){ - $string .= "\t\t<$key>$value</$key>\n"; - } elseif (is_int($value)) { - $string .= "\t\t\t<key>$key</key><integer>$value</integer>\n"; - } elseif ($key == "Date Added") { - $string .= "\t\t\t<key>$key</key><date>$value</date>\n"; - } elseif (is_string($value)) { - /* We need to escape the value */ - $string .= "\t\t\t<key>$key</key><string><![CDATA[$value]]></string>\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</$key>\n"; - } - else { - if ($key == "key"){ - $string .= "\t\t<$key>$value</$key>\n"; - } elseif (is_numeric($value)) { - $string .= "\t\t\t<$key>$value</$key>\n"; - } elseif (is_string($value)) { - /* We need to escape the value */ - $string .= "\t\t\t<$key><![CDATA[$value]]></$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<content div=\"$key\">$value</content>\n"; - } - else { - /* We need to escape the value */ - $string .= "\t<content div=\"$key\"><![CDATA[$value]]></content>\n"; - } - // end foreach elements - } - if (!$callback) { - $string = '<?xml version="1.0" encoding="utf-8" ?>' . - "\n<root>\n" . $string . "</root>\n"; - } - - // Remove invalid XML characters. - // See http://www.w3.org/TR/2006/REC-xml-20060816/#charsets - $clean = preg_replace('/[^\x{9}\x{a}\x{d}\x{20}-\x{d7ff}\x{e000}-\x{fffd}\x{10000}-\x{10ffff}]|[\x{7f}-\x{84}\x{86}-\x{9f}\x{fdd0}-\x{fddf}\x{1fffe}-\x{1ffff}\x{2fffe}-\x{2ffff}\x{3fffe}-\x{3ffff}\x{4fffe}-\x{4ffff}\x{5fffe}-\x{5ffff}\x{6fffe}-\x{6ffff}\x{7fffe}-\x{7ffff}\x{8fffe}-\x{8ffff}\x{9fffe}-\x{9ffff}\x{afffe}-\x{affff}\x{bfffe}-\x{bffff}\x{cfffe}-\x{cffff}\x{dfffe}-\x{dffff}\x{efffe}-\x{effff}\x{ffffe}-\x{fffff}\x{10fffe}-\x{10ffff}]/u', '', $string); - - if ($clean) { - return $clean; - } - else { - debug_event('xml_from_array', 'Charset cleanup failed, generated XML may be invalid', 1); - return $string; - } - break; - } + $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</$key>\n"; + } + else { + if ($key == "key"){ + $string .= "\t\t<$key>$value</$key>\n"; + } elseif (is_int($value)) { + $string .= "\t\t\t<key>$key</key><integer>$value</integer>\n"; + } elseif ($key == "Date Added") { + $string .= "\t\t\t<key>$key</key><date>$value</date>\n"; + } elseif (is_string($value)) { + /* We need to escape the value */ + $string .= "\t\t\t<key>$key</key><string><![CDATA[$value]]></string>\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</$key>\n"; + } + else { + if ($key == "key"){ + $string .= "\t\t<$key>$value</$key>\n"; + } elseif (is_numeric($value)) { + $string .= "\t\t\t<$key>$value</$key>\n"; + } elseif (is_string($value)) { + /* We need to escape the value */ + $string .= "\t\t\t<$key><![CDATA[$value]]></$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<content div=\"$key\">$value</content>\n"; + } + else { + /* We need to escape the value */ + $string .= "\t<content div=\"$key\"><![CDATA[$value]]></content>\n"; + } + // end foreach elements + } + if (!$callback) { + $string = '<?xml version="1.0" encoding="utf-8" ?>' . + "\n<root>\n" . $string . "</root>\n"; + } + + // Remove invalid XML characters. + // See http://www.w3.org/TR/2006/REC-xml-20060816/#charsets + $clean = preg_replace('/[^\x{9}\x{a}\x{d}\x{20}-\x{d7ff}\x{e000}-\x{fffd}\x{10000}-\x{10ffff}]|[\x{7f}-\x{84}\x{86}-\x{9f}\x{fdd0}-\x{fddf}\x{1fffe}-\x{1ffff}\x{2fffe}-\x{2ffff}\x{3fffe}-\x{3ffff}\x{4fffe}-\x{4ffff}\x{5fffe}-\x{5ffff}\x{6fffe}-\x{6ffff}\x{7fffe}-\x{7ffff}\x{8fffe}-\x{8ffff}\x{9fffe}-\x{9ffff}\x{afffe}-\x{affff}\x{bfffe}-\x{bffff}\x{cfffe}-\x{cffff}\x{dfffe}-\x{dffff}\x{efffe}-\x{effff}\x{ffffe}-\x{fffff}\x{10fffe}-\x{10ffff}]/u', '', $string); + + if ($clean) { + return $clean; + } + else { + debug_event('xml_from_array', 'Charset cleanup failed, generated XML may be invalid', 1); + return $string; + } + break; + } } // xml_from_array /** @@ -444,38 +444,38 @@ function xml_from_array($array, $callback = false, $type = '') { * This takes the type and returns the correct xml header */ function xml_get_header($type){ - switch ($type){ - case 'itunes': - $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . - "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"\n" . - "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" . - "<plist version=\"1.0\">\n" . - "<dict>\n" . - " <key>Major Version</key><integer>1</integer>\n" . - " <key>Minor Version</key><integer>1</integer>\n" . - " <key>Application Version</key><string>7.0.2</string>\n" . - " <key>Features</key><integer>1</integer>\n" . - " <key>Show Content Ratings</key><true/>\n" . - " <key>Tracks</key>\n" . - " <dict>\n"; - return $header; - break; - case 'xspf': - $header = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" . - "<!-- XML Generated by Ampache v." . Config::get('version') . " -->"; - "<playlist version = \"1\" xmlns=\"http://xspf.org/ns/0/\">\n ". - "<title>Ampache XSPF Playlist</title>\n" . - "<creator>" . Config::get('site_title') . "</creator>\n" . - "<annotation>" . Config::get('site_title') . "</annotation>\n" . - "<info>". Config::get('web_path') ."</info>\n" . - "<trackList>\n\n\n\n"; - return $header; - break; - default: - $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; - return $header; - break; - } + switch ($type){ + case 'itunes': + $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . + "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"\n" . + "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" . + "<plist version=\"1.0\">\n" . + "<dict>\n" . + " <key>Major Version</key><integer>1</integer>\n" . + " <key>Minor Version</key><integer>1</integer>\n" . + " <key>Application Version</key><string>7.0.2</string>\n" . + " <key>Features</key><integer>1</integer>\n" . + " <key>Show Content Ratings</key><true/>\n" . + " <key>Tracks</key>\n" . + " <dict>\n"; + return $header; + break; + case 'xspf': + $header = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" . + "<!-- XML Generated by Ampache v." . Config::get('version') . " -->"; + "<playlist version = \"1\" xmlns=\"http://xspf.org/ns/0/\">\n ". + "<title>Ampache XSPF Playlist</title>\n" . + "<creator>" . Config::get('site_title') . "</creator>\n" . + "<annotation>" . Config::get('site_title') . "</annotation>\n" . + "<info>". Config::get('web_path') ."</info>\n" . + "<trackList>\n\n\n\n"; + return $header; + break; + default: + $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + return $header; + break; + } } //xml_get_header /** @@ -483,22 +483,22 @@ function xml_get_header($type){ * This takes the type and returns the correct xml footer */ function xml_get_footer($type){ - switch ($type){ - case 'itunes': - $footer = " </dict>\n" . - "</dict>\n" . - "</plist>\n"; - return $footer; - break; - case 'xspf': - $footer = " </trackList>\n" . - "</playlist>\n"; - return $footer; - break; - default: - - break; - } + switch ($type){ + case 'itunes': + $footer = " </dict>\n" . + "</dict>\n" . + "</plist>\n"; + return $footer; + break; + case 'xspf': + $footer = " </trackList>\n" . + "</playlist>\n"; + return $footer; + break; + default: + + break; + } } // xml_get_footer /** @@ -507,9 +507,9 @@ function xml_get_footer($type){ */ function toggle_visible($element) { - echo '<script type="text/javascript">'; - echo "toggleVisible('$element');"; - echo "</script>\n"; + echo '<script type="text/javascript">'; + echo "toggleVisible('$element');"; + echo "</script>\n"; } // toggle_visible @@ -520,14 +520,14 @@ function toggle_visible($element) { */ function print_bool($value) { - if ($value) { - $string = '<span class="item_on">' . T_('On') . '</span>'; - } - else { - $string = '<span class="item_off">' . T_('Off') . '</span>'; - } + if ($value) { + $string = '<span class="item_on">' . T_('On') . '</span>'; + } + else { + $string = '<span class="item_off">' . T_('Off') . '</span>'; + } - return $string; + return $string; } // print_bool @@ -538,12 +538,12 @@ function print_bool($value) { */ function show_now_playing() { - Stream::gc(); - Stream::gc_now_playing(); + Stream::gc(); + 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'; + $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 |