summaryrefslogtreecommitdiffstats
path: root/lib/class/browse.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-31 04:31:42 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-31 04:31:42 +0000
commit652474071e711585fec6b8495b3f22a927c9672e (patch)
tree38186cbd08376625d484d8f8f99e5b2513520c32 /lib/class/browse.class.php
parentd48a431606385a618a31eb007b1527c8d8dd075d (diff)
downloadampache-652474071e711585fec6b8495b3f22a927c9672e.tar.gz
ampache-652474071e711585fec6b8495b3f22a927c9672e.tar.bz2
ampache-652474071e711585fec6b8495b3f22a927c9672e.zip
added paging on all song displays
Diffstat (limited to 'lib/class/browse.class.php')
-rw-r--r--lib/class/browse.class.php59
1 files changed, 54 insertions, 5 deletions
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php
index 375afe8a..a5ea13b2 100644
--- a/lib/class/browse.class.php
+++ b/lib/class/browse.class.php
@@ -31,6 +31,8 @@ class Browse {
// Public static vars that are cached
public static $sql;
+ public static $start = '0';
+ public static $total_objects;
/**
* constructor
@@ -121,6 +123,29 @@ class Browse {
} // set_sort
/**
+ * set_start
+ * This sets the start point for our show functions
+ */
+ public static function set_start($start) {
+
+ self::$start = intval($start);
+
+ } // set_start
+
+ /**
+ * get_saved
+ * This looks in the session for the saved
+ * stuff and returns what it finds
+ */
+ public static function get_saved() {
+
+ $objects = $_SESSION['browse']['save'];
+
+ return $objects;
+
+ } // get_saved
+
+ /**
* get_objects
* This gets an array of the ids of the objects that we are
* currently browsing by it applies the sql and logic based
@@ -136,15 +161,15 @@ class Browse {
$results = array();
while ($data = Dba::fetch_assoc($db_results)) {
- // If we've hit our offset limit
- if (count($results) >= $GLOBALS['user']->prefs['offset_limit']) { return $results; }
-
// Make sure that this object passes the logic filter
if (self::logic_filter($data['id'])) {
$results[] = $data['id'];
}
} // end while
-
+
+ // Save what we've found and then return it
+ self::save_objects($results);
+
return $results;
} // get_objects
@@ -340,7 +365,17 @@ class Browse {
* and requires the correct template based on the
* type that we are currently browsing
*/
- public static function show_objects($object_ids) {
+ public static function show_objects($object_ids='') {
+
+ $object_ids = $object_ids ? $object_ids : self::get_saved();
+
+ // Reset the total items
+ self::$total_objects = count($object_ids);
+
+ // Limit is based on the users preferences
+ $limit = $GLOBALS['user']->prefs['offset_limit'] ? $GLOBALS['user']->prefs['offset_limit'] : '25';
+
+ $object_ids = array_slice($object_ids,self::$start,$limit);
switch ($_SESSION['browse']['type']) {
case 'song':
@@ -380,4 +415,18 @@ class Browse {
} // show_object
+ /**
+ * save_objects
+ * This takes the full array of object ides, often passed into show and then
+ * if nessecary it saves them into the session
+ */
+ public static function save_objects($object_ids) {
+
+ // save these objects
+ $_SESSION['browse']['save'] = $object_ids;
+ self::$total_objects = count($object_ids);
+ return true;
+
+ } // save_objects
+
} // browse