diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-08-19 08:50:35 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-08-19 08:50:35 +0000 |
commit | bc36b9d282aff16dfc794819919897103c94b9bd (patch) | |
tree | 1d3cec755afbf08a595c4164d47a219b2dfa7ed3 /lib | |
parent | d560bb1c7b7e675ad72af0731df18757bf9d5700 (diff) | |
download | ampache-bc36b9d282aff16dfc794819919897103c94b9bd.tar.gz ampache-bc36b9d282aff16dfc794819919897103c94b9bd.tar.bz2 ampache-bc36b9d282aff16dfc794819919897103c94b9bd.zip |
added some basic random functionality, need to make the advanced page
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/ajax.class.php | 2 | ||||
-rw-r--r-- | lib/class/random.class.php | 48 |
2 files changed, 49 insertions, 1 deletions
diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php index e8496e75..2139959e 100644 --- a/lib/class/ajax.class.php +++ b/lib/class/ajax.class.php @@ -122,7 +122,7 @@ class Ajax { } // If we pass a source put it in the ID - $string = "<span id=\"$source\" $class_txt>$text</span>\n"; + $string = "<div id=\"$source\" $class_txt>$text</div>\n"; $string .= self::observe($source,'click',$ajax_string); diff --git a/lib/class/random.class.php b/lib/class/random.class.php index 58be0463..b2081539 100644 --- a/lib/class/random.class.php +++ b/lib/class/random.class.php @@ -39,6 +39,54 @@ class Random { } // constructor /** + * album + * This returns the ID of a random album, nothing special + */ + public static function album() { + + $sql = "SELECT `id` FROM `album` ORDER BY RAND() LIMIT 1"; + $db_results = Dba::query($sql); + + $results = Dba::fetch_assoc($db_results); + + return $results['id']; + + } // album + + /** + * artist + * This returns the ID of a random artist, nothing special here for now + */ + public static function artist() { + + $sql = "SELECT `id` FROM `artist` ORDER BY RAND() LIMIT 1"; + $db_results = Dba::query($sql); + + $results = Dba::fetch_assoc($db_results); + + return $results['id']; + + } // artist + + /** + * playlist + * This returns a random Playlist with songs little bit of extra + * logic require + */ + public static function playlist() { + + $sql = "SELECT `playlist`.`id` FROM `playlist` LEFT JOIN `playlist_data` " . + " ON `playlist`.`id`=`playlist_data`.`playlist` WHERE `playlist_data`.`object_id` IS NOT NULL " . + " ORDER BY RAND()"; + $db_results = Dba::query($sql); + + $results = Dba::fetch_assoc($db_results); + + return $results['id']; + + } // playlist + + /** * play_url * This generates a random play url based on the passed type * and returns it |