Index: ui.lib.php
===================================================================
--- ui.lib.php (revision 674)
+++ ui.lib.php (working copy)
@@ -1292,26 +1292,99 @@
* creates a XML document form it for use
* primarly by the ajax mojo
*/
-function xml_from_array($array,$callback=0) {
+function xml_from_array($array,$callback=0,$type='') {
+ switch ($type) {
- foreach ($array as $key=>$value) {
- if (is_numeric($key)) { $key = 'item'; }
- if (is_array($value)) {
- $value = xml_from_array($value,1);
- $string .= "\t$value\n";
+ 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_numeric($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";
+ }
+ }
+
+ }
+
+ return $string;
+ break;
+ default:
+ foreach ($array as $key=>$value) {
+ if (is_numeric($key)) { $key = 'item'; }
+ if (is_array($value)) {
+ $value = xml_from_array($value,1);
+ $string .= "\t$value\n";
+ }
+ else {
+ /* We need to escape the value */
+ $string .= "\t\n";
+ }
+ // end foreach elements
+ }
+ if (!$callback) {
+ $string = "\n\n" . $string . "\n";
}
- else {
- /* We need to escape the value */
- $string .= "\t\n";
- }
- } // end foreach elements
- if (!$callback) {
- $string = "\n\n" . $string . "\n";
+ return $string;
+ break;
}
+} // xml_from_array
- return $string;
+/**
+ * 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;
+ default:
+ $header = "\n";
+ return $header;
+ break;
+ }
+} //xml_get_header
-} // xml_from_array
+/**
+ * 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;
+ default:
+ break;
+ }
+} //xml_get_footer
+
+
?>