~ubuntu-branches/debian/sid/ampache/sid

« back to all changes in this revision

Viewing changes to lib/class/xmldata.class.php

  • Committer: Package Import Robot
  • Author(s): Charlie Smotherman
  • Date: 2013-08-27 13:19:48 UTC
  • mfrom: (1.2.9)
  • Revision ID: package-import@ubuntu.com-20130827131948-1czew0zxn6u70dtv
Tags: 3.6-rzb2752+dfsg-1
* New upsteam snapshot.  Contains important bug fixes to the installer.
* Correct typo in ampache-common.postrm.
* Remove courtousy copy of php-getid3, during repack.  Closes: #701526
* Update package to use dh_linktree to make the needed sym links to the
  needed system libs that were removed during repack.
* Update debian/rules to reflect upstreams removing/moving of modules.
* Update debian/ampache-common.install to reflect upstreams removal of files.
* Updated to use new apache2.4 API. Closes: #669756
* Updated /debian/po/de.po thx David Prévot for the patch.  Closes:  #691963
* M3U import is now ordered, fixed upstream.  Closes: #684984
* Text input area has been resized so IPv6 addresses will now fit, fixed
  upstream.  Closes:  #716230
* Added ampache-common.preinst to make sure that the courtousy copies of code
  dirs are empty so dh_linktree can do it's magic on upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
3
 
/**
4
 
 * xmlData Class
5
 
 *
6
 
 *
7
 
 * LICENSE: GNU General Public License, version 2 (GPLv2)
8
 
 * Copyright (c) 2001 - 2011 Ampache.org All Rights Reserved
9
 
 *
10
 
 * This program is free software; you can redistribute it and/or
11
 
 * modify it under the terms of the GNU General Public License
12
 
 * as published by the Free Software Foundation; version 2
13
 
 * of the License.
14
 
 *
15
 
 * This program is distributed in the hope that it will be useful,
16
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 * GNU General Public License for more details.
19
 
 *
20
 
 * You should have received a copy of the GNU General Public License
21
 
 * along with this program; if not, write to the Free Software
22
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23
 
 *
24
 
 * @package     Ampache
25
 
 * @copyright   2001 - 2011 Ampache.org
26
 
 * @license     http://opensource.org/licenses/gpl-2.0 GPLv2
27
 
 * @link        http://www.ampache.org/
28
 
 */
29
 
 
30
 
/**
31
 
 * xmlData Class
32
 
 *
33
 
 * This class takes care of all of the xml document stuff in Ampache these
34
 
 * are all static calls
35
 
 *
36
 
 * @package     Ampache
37
 
 * @copyright   2001 - 2011 Ampache.org
38
 
 * @license     http://opensource.org/licenses/gpl-2.0 GPLv2
39
 
 * @link        http://www.ampache.org/
40
 
 */
41
 
class xmlData {
42
 
 
43
 
        // This is added so that we don't pop any webservers
44
 
        private static $limit = '5000';
45
 
        private static $offset = '0';
46
 
        private static $type = '';
47
 
 
48
 
        /**
49
 
         * constructor
50
 
         *
51
 
         * We don't use this, as its really a static class
52
 
         */
53
 
        private function __construct() {
54
 
 
55
 
                // Rien a faire
56
 
 
57
 
        } // constructor
58
 
 
59
 
        /**
60
 
         * set_offset
61
 
         *
62
 
         * This takes an int and changes the offset
63
 
         *
64
 
         * @param       integer $offset (description here...)
65
 
         * @return      void
66
 
         */
67
 
        public static function set_offset($offset) {
68
 
 
69
 
                $offset = intval($offset);
70
 
                self::$offset = $offset;
71
 
 
72
 
        } // set_offset
73
 
 
74
 
        /**
75
 
         * set_limit
76
 
         *
77
 
         * This sets the limit for any ampache transactions
78
 
         *
79
 
         * @param       integer $limit  (description here...)
80
 
         * @return      void
81
 
         */
82
 
        public static function set_limit($limit) {
83
 
 
84
 
                if (!$limit) { return false; }
85
 
 
86
 
                $limit = intval($limit);
87
 
                self::$limit = $limit;
88
 
 
89
 
        } // set_limit
90
 
 
91
 
        /**
92
 
         * set_type
93
 
         *
94
 
         * This sets the type of xmlData we are working on
95
 
         *
96
 
         * @param       string  $type   xmlData type
97
 
         * @return      void
98
 
         */
99
 
        public static function set_type($type) {
100
 
 
101
 
                if (!in_array($type,array('rss','xspf','itunes'))) { return false; }
102
 
 
103
 
                self::$type = $type;
104
 
 
105
 
        } // set_type
106
 
 
107
 
        /**
108
 
         * error
109
 
         *
110
 
         * This generates a standard XML Error message
111
 
         * nothing fancy here...
112
 
         *
113
 
         * @param       integer $code   Error code
114
 
         * @param       string  $string Error message
115
 
         * @return      string  return error message xml
116
 
         */
117
 
        public static function error($code,$string) {
118
 
 
119
 
                $string = self::_header() . "\t<error code=\"$code\"><![CDATA[$string]]></error>" . self::_footer();
120
 
                return $string;
121
 
 
122
 
        } // error
123
 
 
124
 
        /**
125
 
         * single_string
126
 
         *
127
 
         * This takes two values, first the key second the string
128
 
         *
129
 
         * @param       string  $key    (description here...)
130
 
         * @param       string  $string xml data
131
 
         * @return      string  return xml
132
 
         */
133
 
        public static function single_string($key,$string) {
134
 
 
135
 
                $final = self::_header() . "\t<$key><![CDATA[$string]]></$key>" . self::_footer();
136
 
 
137
 
                return $final;
138
 
 
139
 
        } // single_string
140
 
 
141
 
        /**
142
 
         * header
143
 
         *
144
 
         * This returns the header
145
 
         *
146
 
         * @see _header()
147
 
         * @return      string  return xml
148
 
         */
149
 
        public static function header() {
150
 
 
151
 
                return self::_header();
152
 
 
153
 
        } // header
154
 
 
155
 
        /**
156
 
         * footer
157
 
         *
158
 
         * This returns the footer
159
 
         *
160
 
         * @see _footer()
161
 
         * @return      string  return xml      
162
 
         */
163
 
        public static function footer() {
164
 
 
165
 
                return self::_footer();
166
 
 
167
 
        } // footer
168
 
 
169
 
        /**
170
 
         * tags_string
171
 
         *
172
 
         * This returns the formatted 'tags' string for an xml document
173
 
         *
174
 
         */
175
 
        private static function tags_string($tags) {
176
 
 
177
 
                $string = '';
178
 
 
179
 
                if (is_array($tags)) {
180
 
 
181
 
                        foreach ($tags as $tag_id => $data) {
182
 
                                $tag = new Tag($tag_id);
183
 
                                $string .= "\t<tag id=\"" . $tag->id . 
184
 
                                        '" count="' . count($data['users']) . 
185
 
                                        '"><![CDATA[' . $tag->name . "]]></tag>\n";
186
 
                        }
187
 
                }
188
 
 
189
 
                return $string;
190
 
 
191
 
        } // tags_string
192
 
 
193
 
        /**
194
 
         * keyed_array
195
 
         *
196
 
         * This will build an xml document from a key'd array,
197
 
         *
198
 
         * @param       array   $array  (description here...)
199
 
         * @param       boolean $callback       (description here...)
200
 
         * @return      string  return xml
201
 
         */
202
 
        public static function keyed_array($array,$callback='') {
203
 
 
204
 
                $string = '';
205
 
 
206
 
                // Foreach it
207
 
                foreach ($array as $key=>$value) {
208
 
                        $attribute = '';
209
 
                        // See if the key has attributes
210
 
                        if (is_array($value) AND isset($value['<attributes>'])) { 
211
 
                                $attribute = ' ' . $value['<attributes>']; 
212
 
                                $key = $value['value']; 
213
 
                        } 
214
 
 
215
 
                        // If it's an array, run again
216
 
                        if (is_array($value)) {
217
 
                                $value = self::keyed_array($value,1);
218
 
                                $string .= "<$key$attribute>\n$value\n</$key>\n";
219
 
                        }
220
 
                        else {
221
 
                                $string .= "\t<$key$attribute><![CDATA[$value]]></$key>\n";
222
 
                        }
223
 
 
224
 
                } // end foreach
225
 
 
226
 
                if (!$callback) {
227
 
                        $string = self::_header() . $string . self::_footer();
228
 
                }
229
 
 
230
 
                return $string;
231
 
 
232
 
        } // keyed_array
233
 
 
234
 
        /**
235
 
         * tags
236
 
         *
237
 
         * This returns tags to the user, in a pretty xml document with the information
238
 
         *
239
 
         * @param       array   $tags   (description here...)
240
 
         * @return      string  return xml
241
 
         */
242
 
        public static function tags($tags) {
243
 
 
244
 
                if (count($tags) > self::$limit OR self::$offset > 0) {
245
 
                        $tags = array_splice($tags,self::$offset,self::$limit);
246
 
                }
247
 
 
248
 
                $string = '';
249
 
 
250
 
                foreach ($tags as $tag_id) {
251
 
                        $tag = new Tag($tag_id);
252
 
                        $counts = $tag->count();
253
 
                        $string .= "<tag id=\"$tag_id\">\n" .
254
 
                                        "\t<name><![CDATA[$tag->name]]></name>\n" .
255
 
                                        "\t<albums>" . intval($counts['album']) . "</albums>\n" .
256
 
                                        "\t<artists>" . intval($counts['artist']) . "</artists>\n" .
257
 
                                        "\t<songs>" . intval($counts['song']) . "</songs>\n" .
258
 
                                        "\t<videos>" . intval($counts['video']) . "</videos>\n" .
259
 
                                        "\t<playlists>" . intval($count['playlist']) . "</playlists>\n" .
260
 
                                        "\t<stream>" . intval($count['live_stream']) . "</stream>\n" .
261
 
                                        "</tag>\n";
262
 
                } // end foreach
263
 
 
264
 
                $final = self::_header() . $string . self::_footer();
265
 
 
266
 
                return $final;
267
 
 
268
 
        } // tags
269
 
 
270
 
        /**
271
 
         * artists
272
 
         *
273
 
         * This takes an array of artists and then returns a pretty xml document with the information
274
 
         * we want
275
 
         *
276
 
         * @param       array   $artists        (description here...)
277
 
         * @return      string  return xml
278
 
         */
279
 
        public static function artists($artists) {
280
 
 
281
 
                if (count($artists) > self::$limit OR self::$offset > 0) {
282
 
                        $artists = array_splice($artists,self::$offset,self::$limit);
283
 
                }
284
 
 
285
 
                $string = '';
286
 
 
287
 
                Rating::build_cache('artist',$artists);
288
 
 
289
 
                foreach ($artists as $artist_id) {
290
 
                        $artist = new Artist($artist_id);
291
 
                        $artist->format();
292
 
 
293
 
                        $rating = new Rating($artist_id,'artist');
294
 
                        $tag_string = self::tags_string($artist->tags);
295
 
 
296
 
                        $string .= "<artist id=\"$artist->id\">\n" .
297
 
                                        "\t<name><![CDATA[$artist->f_full_name]]></name>\n" .
298
 
                                        $tag_string .
299
 
                                        "\t<albums>$artist->albums</albums>\n" .
300
 
                                        "\t<songs>$artist->songs</songs>\n" .
301
 
                                        "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" .
302
 
                                        "\t<rating>" . $rating->rating . "</rating>\n" .
303
 
                                        "</artist>\n";
304
 
                } // end foreach artists
305
 
 
306
 
                $final = self::_header() . $string . self::_footer();
307
 
 
308
 
                return $final;
309
 
 
310
 
        } // artists
311
 
 
312
 
        /**
313
 
         * albums
314
 
         *
315
 
         * This echos out a standard albums XML document, it pays attention to the limit
316
 
         *
317
 
         * @param       array   $albums (description here...)
318
 
         * @return      string  return xml
319
 
         */
320
 
        public static function albums($albums) {
321
 
 
322
 
                if (count($albums) > self::$limit OR self::$offset > 0) {
323
 
                        $albums = array_splice($albums,self::$offset,self::$limit);
324
 
                }
325
 
 
326
 
                Rating::build_cache('album',$albums);
327
 
 
328
 
                foreach ($albums as $album_id) {
329
 
                        $album = new Album($album_id);
330
 
                        $album->format();
331
 
 
332
 
                        $rating = new Rating($album_id,'album');
333
 
 
334
 
                        // Build the Art URL, include session
335
 
                        $art_url = Config::get('web_path') . '/image.php?id=' . $album->id . '&auth=' . scrub_out($_REQUEST['auth']);
336
 
 
337
 
                        $string .= "<album id=\"$album->id\">\n" .
338
 
                                        "\t<name><![CDATA[$album->name]]></name>\n";
339
 
 
340
 
                        // Do a little check for artist stuff
341
 
                        if ($album->artist_count != 1) {
342
 
                                $string .= "\t<artist id=\"0\"><![CDATA[Various]]></artist>\n";
343
 
                        }
344
 
                        else {
345
 
                                $string .= "\t<artist id=\"$album->artist_id\"><![CDATA[$album->artist_name]]></artist>\n";
346
 
                        }
347
 
 
348
 
                        $string .= "\t<year>$album->year</year>\n" .
349
 
                                        "\t<tracks>$album->song_count</tracks>\n" .
350
 
                                        "\t<disk>$album->disk</disk>\n" .
351
 
                                        self::tags_string($album->tags) .
352
 
                                        "\t<art><![CDATA[$art_url]]></art>\n" .
353
 
                                        "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" .
354
 
                                        "\t<rating>" . $rating->rating . "</rating>\n" .
355
 
                                        "</album>\n";
356
 
                } // end foreach
357
 
 
358
 
                $final = self::_header() . $string . self::_footer();
359
 
 
360
 
                return $final;
361
 
 
362
 
        } // albums
363
 
 
364
 
        /**
365
 
         * playlists
366
 
         *
367
 
         * This takes an array of playlist ids and then returns a nice pretty XML document
368
 
         *
369
 
         * @param       array   $playlists      (description here...)
370
 
         * @return      string  return xml
371
 
         */
372
 
        public static function playlists($playlists) {
373
 
 
374
 
                if (count($playlists) > self::$limit OR self::$offset > 0) {
375
 
                        $playlists = array_slice($playlists,self::$offset,self::$limit);
376
 
                }
377
 
 
378
 
                $string = '';
379
 
 
380
 
                // Foreach the playlist ids
381
 
                foreach ($playlists as $playlist_id) {
382
 
                        $playlist = new Playlist($playlist_id);
383
 
                        $playlist->format();
384
 
                        $item_total = $playlist->get_song_count();
385
 
 
386
 
                        // Build this element
387
 
                        $string .= "<playlist id=\"$playlist->id\">\n" .
388
 
                                "\t<name><![CDATA[$playlist->name]]></name>\n" .
389
 
                                "\t<owner><![CDATA[$playlist->f_user]]></owner>\n" .
390
 
                                "\t<items>$item_total</items>\n" .
391
 
                                "\t<type>$playlist->type</type>\n" .
392
 
                                "</playlist>\n";
393
 
 
394
 
 
395
 
                } // end foreach
396
 
 
397
 
                // Build the final and then send her off
398
 
                $final = self::_header() . $string . self::_footer();
399
 
 
400
 
                return $final;
401
 
 
402
 
        } // playlists
403
 
 
404
 
        /**
405
 
         * songs
406
 
         *
407
 
         * This returns an xml document from an array of song ids spiffy isn't it!
408
 
         *
409
 
         * @param       array   $songs  (description here...)
410
 
         * @return      string  return xml
411
 
         */
412
 
        public static function songs($songs) {
413
 
 
414
 
                if (count($songs) > self::$limit OR self::$offset > 0) {
415
 
                        $songs = array_slice($songs,self::$offset,self::$limit);
416
 
                }
417
 
 
418
 
                Song::build_cache($songs);
419
 
                Stream::set_session($_REQUEST['auth']);
420
 
 
421
 
                // Foreach the ids!
422
 
                foreach ($songs as $song_id) {
423
 
                        $song = new Song($song_id);
424
 
 
425
 
                        // If the song id is invalid/null
426
 
                        if (!$song->id) { continue; }
427
 
 
428
 
                        $tag_string = self::tags_string(Tag::get_top_tags('song', $song_id));
429
 
                        $rating = new Rating($song_id, 'song');
430
 
                        $art_url = Art::url($song->album, 'album', $_REQUEST['auth']);
431
 
 
432
 
                        $string .= "<song id=\"$song->id\">\n" .
433
 
                                "\t<title><![CDATA[$song->title]]></title>\n" .
434
 
                                "\t<artist id=\"" . $song->artist . 
435
 
                                        '"><![CDATA[' . $song->get_artist_name() .
436
 
                                        "]]></artist>\n" .
437
 
                                "\t<album id=\"" . $song->album . 
438
 
                                        '"><![CDATA[' . $song->get_album_name().
439
 
                                        "]]></album>\n" .
440
 
                                $tag_string .
441
 
                                "\t<track>$song->track</track>\n" .
442
 
                                "\t<time>$song->time</time>\n" .
443
 
                                "\t<year>$song->year</year>\n" .
444
 
                                "\t<bitrate>$song->bitrate</bitrate>\n".
445
 
                                "\t<mode>$song->mode</mode>\n".
446
 
                                "\t<mime>$song->mime</mime>\n" .
447
 
                                "\t<url><![CDATA[" . Song::play_url($song->id) . "]]></url>\n" .
448
 
                                "\t<size>$song->size</size>\n".
449
 
                                "\t<mbid>$song->mbid</mbid>\n".
450
 
                                "\t<album_mbid>$song->album_mbid</album_mbid>\n".
451
 
                                "\t<artist_mbid>$song->artist_mbid</artist_mbid>\n".
452
 
                                "\t<art><![CDATA[" . $art_url . "]]></art>\n" .
453
 
                                "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" .
454
 
                                "\t<rating>" . $rating->rating . "</rating>\n" .
455
 
                                "</song>\n";
456
 
 
457
 
                } // end foreach
458
 
 
459
 
                $final = self::_header() . $string . self::_footer();
460
 
 
461
 
                return $final;
462
 
 
463
 
        } // songs
464
 
 
465
 
        /**
466
 
         * videos
467
 
         *
468
 
         * This builds the xml document for displaying video objects
469
 
         *
470
 
         * @param       array   $videos (description here...)
471
 
         * @return      string  return xml
472
 
         */
473
 
        public static function videos($videos) {
474
 
 
475
 
                if (count($videos) > self::$limit OR self::$offset > 0) {
476
 
                        $videos = array_slice($videos,self::$offset,self::$limit);
477
 
                }
478
 
 
479
 
                $string = '';
480
 
 
481
 
                foreach ($videos as $video_id) {
482
 
                        $video = new Video($video_id);
483
 
                        $video->format();
484
 
 
485
 
                        $string .= "<video id=\"$video->id\">\n" .
486
 
                                        "\t<title><![CDATA[$video->title]]></title>\n" .
487
 
                                        "\t<mime><![CDATA[$video->mime]]></mime>\n" .
488
 
                                        "\t<resolution>$video->f_resolution</resolution>\n" .
489
 
                                        "\t<size>$video->size</size>\n" .
490
 
                                        self::tags_string($video->tags) .
491
 
                                        "\t<url><![CDATA[" . Video::play_url($video->id) . "]]></url>\n" .
492
 
                                        "</video>\n";
493
 
 
494
 
                } // end foreach
495
 
 
496
 
                $final = self::_header() . $string . self::_footer();
497
 
 
498
 
                return $final;
499
 
 
500
 
        } // videos
501
 
 
502
 
        /**
503
 
         * democratic
504
 
         *
505
 
         * This handles creating an xml document for democratic items, this can be a little complicated
506
 
         * due to the votes and all of that
507
 
         *
508
 
         * @param       array   $object_ids     Object IDs
509
 
         * @return      string  return xml
510
 
         */
511
 
        public static function democratic($object_ids=array()) {
512
 
 
513
 
                if (!is_array($object_ids)) { $object_ids = array(); }
514
 
 
515
 
                $democratic = Democratic::get_current_playlist();
516
 
 
517
 
                $string = '';
518
 
 
519
 
                foreach ($object_ids as $row_id=>$data) {
520
 
                        $song = new $data['object_type']($data['object_id']);
521
 
                        $song->format();
522
 
 
523
 
                        //FIXME: This is duplicate code and so wrong, functions need to be improved
524
 
                        $tag_string = '';
525
 
 
526
 
                        $tag = new Tag($song->tags['0']);
527
 
                        $song->genre = $tag->id;
528
 
                        $song->f_genre = $tag->name;
529
 
 
530
 
                        $tag_string = self::tags_string($song->tags);
531
 
 
532
 
                        $rating = new Rating($song_id,'song');
533
 
 
534
 
                        $art_url = Art::url($song->album, 'album', $_REQUEST['auth']);
535
 
 
536
 
                        $string .= "<song id=\"$song->id\">\n" .
537
 
                                        "\t<title><![CDATA[$song->title]]></title>\n" .
538
 
                                        "\t<artist id=\"$song->artist\"><![CDATA[$song->f_artist_full]]></artist>\n" .
539
 
                                        "\t<album id=\"$song->album\"><![CDATA[$song->f_album_full]]></album>\n" .
540
 
                                        "\t<genre id=\"$song->genre\"><![CDATA[$song->f_genre]]></genre>\n" .
541
 
                                        $tag_string .
542
 
                                        "\t<track>$song->track</track>\n" .
543
 
                                        "\t<time>$song->time</time>\n" .
544
 
                                        "\t<mime>$song->mime</mime>\n" .
545
 
                                        "\t<url><![CDATA[" . Song::play_url($song->id) . "]]></url>\n" .
546
 
                                        "\t<size>$song->size</size>\n" .
547
 
                                        "\t<art><![CDATA[" . $art_url . "]]></art>\n" .
548
 
                                        "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" .
549
 
                                        "\t<rating>" . $rating->rating . "</rating>\n" .
550
 
                                        "\t<vote>" . $democratic->get_vote($row_id) . "</vote>\n" .
551
 
                                        "</song>\n";
552
 
 
553
 
                } // end foreach
554
 
 
555
 
                $final = self::_header() . $string . self::_footer();
556
 
 
557
 
                return $final;
558
 
 
559
 
        } // democratic
560
 
 
561
 
        /**
562
 
         * rss_feed
563
 
         *
564
 
         * (description here...)
565
 
         *
566
 
         * @param       array   $data   (descriptiong here...)
567
 
         * @param       string  $title  RSS feed title
568
 
         * @param       string  $description    (not use yet?)
569
 
         * @param       string  $date   publish date
570
 
         * @return      string  RSS feed xml
571
 
         */
572
 
        public static function rss_feed($data,$title,$description,$date) {
573
 
 
574
 
                $string = "\t<title>$title</title>\n\t<link>" . Config::get('web_path') . "</link>\n\t" .
575
 
                        "<pubDate>" . date("r",$date) . "</pubDate>\n";
576
 
 
577
 
                // Pass it to the keyed array xml function
578
 
                foreach ($data as $item) {
579
 
                        // We need to enclose it in an item tag
580
 
                        $string .= self::keyed_array(array('item'=>$item),1);
581
 
                }
582
 
 
583
 
                $final = self::_header() . $string . self::_footer();
584
 
 
585
 
                return $final;
586
 
 
587
 
        } // rss_feed
588
 
 
589
 
        /**
590
 
         * _header
591
 
         *
592
 
         * this returns a standard header, there are a few types
593
 
         * so we allow them to pass a type if they want to
594
 
         *
595
 
         * @return      string  Header xml tag.
596
 
         */
597
 
        private static function _header() {
598
 
 
599
 
                switch (self::$type) {
600
 
                        case 'xspf':
601
 
                                $header = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" .
602
 
                                                "<playlist version = \"1\" xmlns=\"http://xspf.org/ns/0/\">\n " .
603
 
                                                "<title>Ampache XSPF Playlist</title>\n" .
604
 
                                                "<creator>" . scrub_out(Config::get('site_title')) . "</creator>\n" .
605
 
                                                "<annotation>" . scrub_out(Config::get('site_title')) . "</annotation>\n" .
606
 
                                                "<info>". Config::get('web_path') ."</info>\n" .
607
 
                                                "<trackList>\n";
608
 
                        break;
609
 
                        case 'itunes':
610
 
                                $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" .
611
 
                                "<!-- XML Generated by Ampache v." .  Config::get('version') . " -->\n";
612
 
                                "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"\n" .
613
 
                                "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" .
614
 
                                "<plist version=\"1.0\">\n" .
615
 
                                "<dict>\n" .
616
 
                                "       <key>Major Version</key><integer>1</integer>\n" .
617
 
                                "       <key>Minor Version</key><integer>1</integer>\n" .
618
 
                                "       <key>Application Version</key><string>7.0.2</string>\n" .
619
 
                                "       <key>Features</key><integer>1</integer>\n" .
620
 
                                "       <key>Show Content Ratings</key><true/>\n" .
621
 
                                "       <key>Tracks</key>\n" .
622
 
                                "       <dict>\n";
623
 
                        break;
624
 
                        case 'rss':
625
 
                                $header = "<?xml version=\"1.0\" encoding=\"" . Config::get('site_charset') . "\" ?>\n " .
626
 
                                        "<!-- RSS Generated by Ampache v." . Config::get('version') . " on " . date("r",time()) . "-->\n" .
627
 
                                        "<rss version=\"2.0\">\n<channel>\n";
628
 
                        break;
629
 
                        default:
630
 
                                $header = "<?xml version=\"1.0\" encoding=\"" . Config::get('site_charset') . "\" ?>\n<root>\n";
631
 
                        break;
632
 
                } // end switch
633
 
 
634
 
                return $header;
635
 
 
636
 
        } // _header
637
 
 
638
 
        /**
639
 
         * _footer
640
 
         *
641
 
         * this returns the footer for this document, these are pretty boring
642
 
         *
643
 
         * @return      string  Footer xml tag.
644
 
         */
645
 
        private static function _footer() {
646
 
 
647
 
                switch (self::$type) {
648
 
                        case 'itunes':
649
 
                                $footer = "\t\t</dict>\t\n</dict>\n</plist>\n";
650
 
                        break;
651
 
                        case 'xspf':
652
 
                                $footer = "</trackList>\n</playlist>\n";
653
 
                        break;
654
 
                        case 'rss':
655
 
                                $footer = "\n</channel>\n</rss>\n";
656
 
                        break;
657
 
                        default:
658
 
                                $footer = "\n</root>\n";
659
 
                        break;
660
 
                } // end switch on type
661
 
 
662
 
 
663
 
                return $footer;
664
 
 
665
 
        } // _footer
666
 
 
667
 
} // xmlData
668
 
 
669
 
?>