summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/class/ajax.class.php2
-rw-r--r--lib/class/random.class.php48
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