From 9c28ed5ad1adf15f868d181b9cfca26a801550ad Mon Sep 17 00:00:00 2001 From: Paul Arthur Date: Fri, 25 Jan 2013 19:54:11 -0500 Subject: Consistently use _ in two-word class names --- lib/class/xmldata.class.php | 659 -------------------------------------------- 1 file changed, 659 deletions(-) delete mode 100644 lib/class/xmldata.class.php (limited to 'lib/class/xmldata.class.php') diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php deleted file mode 100644 index 96003964..00000000 --- a/lib/class/xmldata.class.php +++ /dev/null @@ -1,659 +0,0 @@ -" . self::_footer(); - return $string; - - } // error - - /** - * single_string - * - * This takes two values, first the key second the string - * - * @param string $key (description here...) - * @param string $string xml data - * @return string return xml - */ - public static function single_string($key,$string) { - - $final = self::_header() . "\t<$key>" . self::_footer(); - - return $final; - - } // single_string - - /** - * header - * - * This returns the header - * - * @see _header() - * @return string return xml - */ - public static function header() { - - return self::_header(); - - } // header - - /** - * footer - * - * This returns the footer - * - * @see _footer() - * @return string return xml - */ - public static function footer() { - - return self::_footer(); - - } // footer - - /** - * tags_string - * - * This returns the formatted 'tags' string for an xml document - * - */ - private static function tags_string($tags) { - - $string = ''; - - if (is_array($tags)) { - - foreach ($tags as $tag_id => $data) { - $tag = new Tag($tag_id); - $string .= "\tid . - '" count="' . count($data['users']) . - '">name . "]]>\n"; - } - } - - return $string; - - } // tags_string - - /** - * keyed_array - * - * This will build an xml document from a key'd array, - * - * @param array $array (description here...) - * @param boolean $callback (description here...) - * @return string return xml - */ - public static function keyed_array($array,$callback='') { - - $string = ''; - - // Foreach it - foreach ($array as $key=>$value) { - $attribute = ''; - // See if the key has attributes - if (is_array($value) AND isset($value[''])) { - $attribute = ' ' . $value['']; - $key = $value['value']; - } - - // If it's an array, run again - if (is_array($value)) { - $value = self::keyed_array($value,1); - $string .= "<$key$attribute>\n$value\n\n"; - } - else { - $string .= "\t<$key$attribute>\n"; - } - - } // end foreach - - if (!$callback) { - $string = self::_header() . $string . self::_footer(); - } - - return $string; - - } // keyed_array - - /** - * tags - * - * This returns tags to the user, in a pretty xml document with the information - * - * @param array $tags (description here...) - * @return string return xml - */ - public static function tags($tags) { - - if (count($tags) > self::$limit OR self::$offset > 0) { - $tags = array_splice($tags,self::$offset,self::$limit); - } - - $string = ''; - - foreach ($tags as $tag_id) { - $tag = new Tag($tag_id); - $counts = $tag->count(); - $string .= "\n" . - "\tname]]>\n" . - "\t" . intval($counts['album']) . "\n" . - "\t" . intval($counts['artist']) . "\n" . - "\t" . intval($counts['song']) . "\n" . - "\t" . intval($counts['video']) . "\n" . - "\t" . intval($count['playlist']) . "\n" . - "\t" . intval($count['live_stream']) . "\n" . - "\n"; - } // end foreach - - $final = self::_header() . $string . self::_footer(); - - return $final; - - } // tags - - /** - * artists - * - * This takes an array of artists and then returns a pretty xml document with the information - * we want - * - * @param array $artists (description here...) - * @return string return xml - */ - public static function artists($artists) { - - if (count($artists) > self::$limit OR self::$offset > 0) { - $artists = array_splice($artists,self::$offset,self::$limit); - } - - $string = ''; - - Rating::build_cache('artist',$artists); - - foreach ($artists as $artist_id) { - $artist = new Artist($artist_id); - $artist->format(); - - $rating = new Rating($artist_id,'artist'); - $tag_string = self::tags_string($artist->tags); - - $string .= "id\">\n" . - "\tf_full_name]]>\n" . - $tag_string . - "\t$artist->albums\n" . - "\t$artist->songs\n" . - "\t" . $rating->get_user_rating() . "\n" . - "\t" . $rating->get_user_rating() . "\n" . - "\t" . $rating->get_average_rating() . "\n" . - "\n"; - } // end foreach artists - - $final = self::_header() . $string . self::_footer(); - - return $final; - - } // artists - - /** - * albums - * - * This echos out a standard albums XML document, it pays attention to the limit - * - * @param array $albums (description here...) - * @return string return xml - */ - public static function albums($albums) { - - if (count($albums) > self::$limit OR self::$offset > 0) { - $albums = array_splice($albums,self::$offset,self::$limit); - } - - Rating::build_cache('album',$albums); - - foreach ($albums as $album_id) { - $album = new Album($album_id); - $album->format(); - - $rating = new Rating($album_id,'album'); - - // Build the Art URL, include session - $art_url = Config::get('web_path') . '/image.php?id=' . $album->id . '&auth=' . scrub_out($_REQUEST['auth']); - - $string .= "id\">\n" . - "\tname]]>\n"; - - // Do a little check for artist stuff - if ($album->artist_count != 1) { - $string .= "\t\n"; - } - else { - $string .= "\tartist_id\">artist_name]]>\n"; - } - - $string .= "\t$album->year\n" . - "\t$album->song_count\n" . - "\t$album->disk\n" . - self::tags_string($album->tags) . - "\t\n" . - "\t" . $rating->get_user_rating() . "\n" . - "\t" . $rating->get_user_rating() . "\n" . - "\t" . $rating->get_average_rating() . "\n" . - "\n"; - } // end foreach - - $final = self::_header() . $string . self::_footer(); - - return $final; - - } // albums - - /** - * playlists - * - * This takes an array of playlist ids and then returns a nice pretty XML document - * - * @param array $playlists (description here...) - * @return string return xml - */ - public static function playlists($playlists) { - - if (count($playlists) > self::$limit OR self::$offset > 0) { - $playlists = array_slice($playlists,self::$offset,self::$limit); - } - - $string = ''; - - // Foreach the playlist ids - foreach ($playlists as $playlist_id) { - $playlist = new Playlist($playlist_id); - $playlist->format(); - $item_total = $playlist->get_song_count(); - - // Build this element - $string .= "id\">\n" . - "\tname]]>\n" . - "\tf_user]]>\n" . - "\t$item_total\n" . - "\t$playlist->type\n" . - "\n"; - - - } // end foreach - - // Build the final and then send her off - $final = self::_header() . $string . self::_footer(); - - return $final; - - } // playlists - - /** - * songs - * - * This returns an xml document from an array of song ids. - * (Spiffy isn't it!) - */ - public static function songs($songs) { - - if (count($songs) > self::$limit OR self::$offset > 0) { - $songs = array_slice($songs, self::$offset, self::$limit); - } - - Song::build_cache($songs); - Stream::set_session($_REQUEST['auth']); - - // Foreach the ids! - foreach ($songs as $song_id) { - $song = new Song($song_id); - - // If the song id is invalid/null - if (!$song->id) { continue; } - - $tag_string = self::tags_string(Tag::get_top_tags('song', $song_id)); - $rating = new Rating($song_id, 'song'); - $art_url = Art::url($song->album, 'album', $_REQUEST['auth']); - - $string .= "id\">\n" . - "\t<![CDATA[$song->title]]>\n" . - "\tartist . - '">get_artist_name() . - "]]>\n" . - "\talbum . - '">get_album_name(). - "]]>\n" . - $tag_string . - "\t$song->track\n" . - "\t\n" . - "\t$song->year\n" . - "\t$song->bitrate\n". - "\t$song->mode\n". - "\t$song->mime\n" . - "\tid) . "]]>\n" . - "\t$song->size\n". - "\t$song->mbid\n". - "\t$song->album_mbid\n". - "\t$song->artist_mbid\n". - "\t\n" . - "\t" . $rating->get_user_rating() . "\n" . - "\t" . $rating->get_user_rating() . "\n" . - "\t" . $rating->get_average_rating() . "\n" . - "\n"; - - } // end foreach - - return self::_header() . $string . self::_footer(); - - } // songs - - /** - * videos - * - * This builds the xml document for displaying video objects - * - * @param array $videos (description here...) - * @return string return xml - */ - public static function videos($videos) { - - if (count($videos) > self::$limit OR self::$offset > 0) { - $videos = array_slice($videos,self::$offset,self::$limit); - } - - $string = ''; - - foreach ($videos as $video_id) { - $video = new Video($video_id); - $video->format(); - - $string .= "\n"; - - } // end foreach - - $final = self::_header() . $string . self::_footer(); - - return $final; - - } // videos - - /** - * democratic - * - * This handles creating an xml document for democratic items, this can be a little complicated - * due to the votes and all of that - * - * @param array $object_ids Object IDs - * @return string return xml - */ - public static function democratic($object_ids=array()) { - - if (!is_array($object_ids)) { $object_ids = array(); } - - $democratic = Democratic::get_current_playlist(); - - $string = ''; - - foreach ($object_ids as $row_id=>$data) { - $song = new $data['object_type']($data['object_id']); - $song->format(); - - //FIXME: This is duplicate code and so wrong, functions need to be improved - $tag_string = ''; - - $tag = new Tag($song->tags['0']); - $song->genre = $tag->id; - $song->f_genre = $tag->name; - - $tag_string = self::tags_string($song->tags); - - $rating = new Rating($song_id,'song'); - - $art_url = Art::url($song->album, 'album', $_REQUEST['auth']); - - $string .= "id\">\n" . - "\t<![CDATA[$song->title]]>\n" . - "\tartist\">f_artist_full]]>\n" . - "\talbum\">f_album_full]]>\n" . - "\tgenre\">f_genre]]>\n" . - $tag_string . - "\t$song->track\n" . - "\t\n" . - "\t$song->mime\n" . - "\tid) . "]]>\n" . - "\t$song->size\n" . - "\t\n" . - "\t" . $rating->get_user_rating() . "\n" . - "\t" . $rating->get_user_rating() . "\n" . - "\t" . $rating->get_average_rating() . "\n" . - "\t" . $democratic->get_vote($row_id) . "\n" . - "\n"; - - } // end foreach - - $final = self::_header() . $string . self::_footer(); - - return $final; - - } // democratic - - /** - * rss_feed - * - * (description here...) - * - * @param array $data (descriptiong here...) - * @param string $title RSS feed title - * @param string $description (not use yet?) - * @param string $date publish date - * @return string RSS feed xml - */ - public static function rss_feed($data,$title,$description,$date) { - - $string = "\t$title\n\t" . Config::get('web_path') . "\n\t" . - "" . date("r",$date) . "\n"; - - // Pass it to the keyed array xml function - foreach ($data as $item) { - // We need to enclose it in an item tag - $string .= self::keyed_array(array('item'=>$item),1); - } - - $final = self::_header() . $string . self::_footer(); - - return $final; - - } // rss_feed - - /** - * _header - * - * this returns a standard header, there are a few types - * so we allow them to pass a type if they want to - * - * @return string Header xml tag. - */ - private static function _header() { - - switch (self::$type) { - case 'xspf': - $header = "\n" . - "\n " . - "Ampache XSPF Playlist\n" . - "" . scrub_out(Config::get('site_title')) . "\n" . - "" . scrub_out(Config::get('site_title')) . "\n" . - "". Config::get('web_path') ."\n" . - "\n"; - break; - case 'itunes': - $header = "\n" . - "\n"; - "\n" . - "\n" . - "\n" . - " Major Version1\n" . - " Minor Version1\n" . - " Application Version7.0.2\n" . - " Features1\n" . - " Show Content Ratings\n" . - " Tracks\n" . - " \n"; - break; - case 'rss': - $header = "\n " . - "\n" . - "\n\n"; - break; - default: - $header = "\n\n"; - break; - } // end switch - - return $header; - - } // _header - - /** - * _footer - * - * this returns the footer for this document, these are pretty boring - * - * @return string Footer xml tag. - */ - private static function _footer() { - - switch (self::$type) { - case 'itunes': - $footer = "\t\t\t\n\n\n"; - break; - case 'xspf': - $footer = "\n\n"; - break; - case 'rss': - $footer = "\n\n\n"; - break; - default: - $footer = "\n\n"; - break; - } // end switch on type - - - return $footer; - - } // _footer - -} // xmlData - -?> -- cgit