summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-11-21 06:53:20 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-11-21 06:53:20 +0000
commit8d914e47c9ecb0c99f63ba50936a09e2184eaf84 (patch)
tree31302f42d5399ed10af3c75c7faad5ed3b0d0bbe /lib
parent794036ac1f462f302ce71e64132d981f69023e09 (diff)
downloadampache-8d914e47c9ecb0c99f63ba50936a09e2184eaf84.tar.gz
ampache-8d914e47c9ecb0c99f63ba50936a09e2184eaf84.tar.bz2
ampache-8d914e47c9ecb0c99f63ba50936a09e2184eaf84.zip
additional xml methods songs & album_songs, also implemented catalog add speed improvement from Karl Hungus
Diffstat (limited to 'lib')
-rw-r--r--lib/class/catalog.class.php18
-rw-r--r--lib/class/xmldata.class.php33
2 files changed, 46 insertions, 5 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index a6dabbbe..76289677 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -380,6 +380,12 @@ class Catalog {
Error::add('catalog_add',_('Error: Unable to open') . ' ' . $path);
}
+ /* Change the dir so is_dir works correctly */
+ if (!chdir($path)) {
+ debug_event('read',"Unable to chdir $path",'2','ampache-catalog');
+ Error::add('catalog_add',_('Error: Unable to change to directory') . ' ' . $path);
+ }
+
/* Recurse through this dir and create the files array */
while ( false !== ( $file = readdir($handle) ) ) {
@@ -388,11 +394,6 @@ class Catalog {
debug_event('read',"Starting work on $file inside $path",'5','ampache-catalog');
- /* Change the dir so is_dir works correctly */
- if (!chdir($path)) {
- debug_event('read',"Unable to chdir $path",'2','ampache-catalog');
- Error::add('catalog_add',_('Error: Unable to change to directory') . ' ' . $path);
- }
/* Create the new path */
$full_file = $path.$slash_type.$file;
@@ -411,6 +412,13 @@ class Catalog {
/* If it's a dir run this function again! */
if (is_dir($full_file)) {
$this->add_files($full_file,$options);
+
+ /* Change the dir so is_dir works correctly */
+ if (!chdir($path)) {
+ debug_event('read',"Unable to chdir $path",'2','ampache-catalog');
+ Error::add('catalog_add',_('Error: Unable to change to directory') . ' ' . $path);
+ }
+
/* Skip to the next file */
continue;
} //it's a directory
diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php
index ba1bec3f..d63d9bfc 100644
--- a/lib/class/xmldata.class.php
+++ b/lib/class/xmldata.class.php
@@ -166,6 +166,39 @@ class xmlData {
} // genres
/**
+ * 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) {
+ $songs = array_slice($songs,0,self::$limit);
+ }
+
+ // Foreach the ids!
+ foreach ($songs as $song_id) {
+ $song = new Song($song_id);
+ $song->format();
+
+ $string .= "<song id=\"$song->id\">\n" .
+ "\t<title><![CDATA[$song->title]]></title>\n" .
+ "\t<artist id=\"$song->artist\"><![CDATA[$song->f_artist_full]]></artist>\n" .
+ "\t<album id=\"$song->album\"><![CDATA[$song->f_album_full]]></album>\n" .
+ "\t<genre id=\"$song->genre\"><![CDATA[$song->genre]]></genre>\n" .
+ "\t<track>$song->track</track>\n" .
+ "\t<time>$song->time</time>\n" .
+ "\t<url></url>\n" .
+ "</song>\n";
+
+ } // end foreach
+
+ $final = self::_header() . $string . self::_footer();
+
+ return $final;
+
+ } // songs
+
+ /**
* _header
* this returns a standard header, there are a few types
* so we allow them to pass a type if they want to