summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/flag.php20
-rw-r--r--admin/index.php8
-rw-r--r--admin/shout.php10
-rw-r--r--admin/users.php14
-rw-r--r--albums.php1
-rw-r--r--batch.php4
-rw-r--r--browse.php51
-rw-r--r--democratic.php9
-rwxr-xr-xdocs/CHANGELOG1
-rw-r--r--lib/class/api.class.php81
-rw-r--r--lib/class/art.class.php36
-rw-r--r--lib/class/browse.class.php137
-rw-r--r--lib/class/query.class.php571
-rw-r--r--lib/class/update.class.php23
-rw-r--r--localplay.php8
-rw-r--r--search.php7
-rw-r--r--server/ajax.server.php23
-rw-r--r--server/browse.ajax.php43
-rw-r--r--server/democratic.ajax.php73
-rw-r--r--server/flag.ajax.php10
-rw-r--r--server/localplay.ajax.php26
-rw-r--r--server/playlist.ajax.php10
-rw-r--r--server/random.ajax.php7
-rw-r--r--server/tag.ajax.php19
-rw-r--r--templates/browse_filters.inc.php70
-rw-r--r--templates/list_header.inc.php15
-rw-r--r--templates/show_album.inc.php14
-rw-r--r--templates/show_album_row.inc.php2
-rw-r--r--templates/show_albums.inc.php16
-rw-r--r--templates/show_artist.inc.php11
-rw-r--r--templates/show_index.inc.php2
-rw-r--r--templates/show_manage_catalogs.inc.php11
-rw-r--r--templates/show_now_playing_row.inc.php2
-rw-r--r--templates/show_playlist.inc.php10
-rw-r--r--templates/show_random.inc.php9
-rw-r--r--templates/show_random_albums.inc.php2
-rw-r--r--templates/show_search_options.inc.php4
-rw-r--r--templates/show_songs.inc.php10
-rw-r--r--templates/sidebar_home.inc.php49
39 files changed, 750 insertions, 669 deletions
diff --git a/admin/flag.php b/admin/flag.php
index 1d419421..8eaf310a 100644
--- a/admin/flag.php
+++ b/admin/flag.php
@@ -293,19 +293,23 @@ switch ($_REQUEST['action']) {
break;
case 'show_disabled':
$disabled = Flag::get_disabled();
- Browse::set_type('song');
- Browse::set_static_content(1);
- Browse::save_objects($disabled);
- Browse::show_objects($disabled);
+ $browse = new Browse();
+ $browse->set_type('song');
+ $browse->set_static_content(true);
+ $browse->save_objects($disabled);
+ $browse->show_objects($disabled);
+ $browse->store();
break;
default:
case 'show_flagged':
$flagged = Flag::get_all();
Flag::build_cache($flagged);
- Browse::set_type('flagged');
- Browse::set_static_content(1);
- Browse::save_objects($flagged);
- Browse::show_objects($flagged);
+ $browse = new Browse();
+ $browse->set_type('flagged');
+ $browse->set_static_content(true);
+ $browse->save_objects($flagged);
+ $browse->show_objects($flagged);
+ $browse->store();
break;
} // end switch
diff --git a/admin/index.php b/admin/index.php
index ccb77661..db0427bc 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -33,8 +33,12 @@ switch ($_REQUEST['action']) {
default:
// Show Catalogs
$catalog_ids = Catalog::get_catalogs();
- Browse::set_type('catalog');
- Browse::show_objects($catalog_ids);
+ $browse = new Browse();
+ $browse->set_type('catalog');
+ $browse->set_static_content(true);
+ $browse->save_objects($catalog_ids);
+ $browse->show_objects($catalog_ids);
+ $browse->store();
break;
}
diff --git a/admin/shout.php b/admin/shout.php
index b88ab1c1..55c6093f 100644
--- a/admin/shout.php
+++ b/admin/shout.php
@@ -48,10 +48,12 @@ switch ($_REQUEST['action']) {
show_confirmation(_('Shoutbox Post Deleted'),'',Config::get('web_path').'/admin/shout.php');
break;
default:
- Browse::set_type('shoutbox');
- Browse::set_simple_browse(1);
- $shoutbox_ids = Browse::get_objects();
- Browse::show_objects($shoutbox_ids);
+ $browse = new Browse();
+ $browse->set_type('shoutbox');
+ $browse->set_simple_browse(true);
+ $shoutbox_ids = $browse->get_objects();
+ $browse->show_objects($shoutbox_ids);
+ $browse->store();
break;
} // end switch on action
diff --git a/admin/users.php b/admin/users.php
index e9e52564..eb675c5a 100644
--- a/admin/users.php
+++ b/admin/users.php
@@ -193,12 +193,14 @@ switch ($_REQUEST['action']) {
require_once Config::get('prefix') . '/templates/show_user_preferences.inc.php';
break;
default:
- Browse::reset_filters();
- Browse::set_type('user');
- Browse::set_simple_browse(1);
- Browse::set_sort('name','ASC');
- $user_ids = Browse::get_objects();
- Browse::show_objects($user_ids);
+ $browse = new Browse();
+ $browse->reset_filters();
+ $browse->set_type('user');
+ $browse->set_simple_browse(1);
+ $browse->set_sort('name','ASC');
+ $user_ids = $browse->get_objects();
+ $browse->show_objects($user_ids);
+ $browse->store();
break;
} // end switch on action
diff --git a/albums.php b/albums.php
index 34eb2e67..a976ffbe 100644
--- a/albums.php
+++ b/albums.php
@@ -173,7 +173,6 @@ switch ($_REQUEST['action']) {
case 'show':
$album = new Album($_REQUEST['album']);
$album->format();
- Browse::reset_filters();
require Config::get('prefix') . '/templates/show_album.inc.php';
break;
diff --git a/batch.php b/batch.php
index 275a77a8..5256c2da 100644
--- a/batch.php
+++ b/batch.php
@@ -53,7 +53,9 @@ switch ($_REQUEST['action']) {
$name = $artist->name;
break;
case 'browse':
- $media_ids = Browse::get_saved();
+ $id = scrub_in($_REQUEST['browse_id']);
+ $browse = new Browse($id);
+ $media_ids = $browse->get_saved();
$name = 'Batch-' . date("dmY",time());
default:
// Rien a faire
diff --git a/browse.php b/browse.php
index 616f2588..3ffaf5b9 100644
--- a/browse.php
+++ b/browse.php
@@ -25,15 +25,17 @@
* Browse By Page
* This page shows the browse menu, which allows you to browse by many different
* fields including genre, artist, album, catalog, ???
- * this page also handles the actuall browse action
+ * This page also handles the actual browse action
*
*/
/* Base Require */
require_once 'lib/init.php';
-// This page is a little wonky we don't want the sidebar until we know what type we're dealing with
-// so we've got a little switch here that creates the type.. this feels hackish...
+// This page is a little wonky we don't want the sidebar until we know what
+// type we're dealing with so we've got a little switch here that creates the
+// type.. this feels hackish...
+$browse = new Browse();
switch ($_REQUEST['action']) {
case 'tag':
case 'file':
@@ -43,9 +45,8 @@ switch ($_REQUEST['action']) {
case 'live_stream':
case 'video':
case 'song':
- Browse::set_type($_REQUEST['action']);
- Browse::reset();
- Browse::set_simple_browse(true);
+ $browse->set_type($_REQUEST['action']);
+ $browse->set_simple_browse(true);
break;
} // end switch
@@ -55,51 +56,53 @@ switch($_REQUEST['action']) {
case 'file':
break;
case 'album':
- Browse::set_sort('name','ASC');
- Browse::show_objects();
+ $browse->set_sort('name','ASC');
+ $browse->show_objects();
break;
case 'tag':
- Browse::set_sort('count','ASC');
+ $browse->set_sort('count','ASC');
// This one's a doozy
- Browse::set_simple_browse(0);
- Browse::save_objects(Tag::get_tags(Config::get('offset_limit'),array()));
- $keys = array_keys(Browse::get_saved());
+ $browse->set_simple_browse(false);
+ $browse->save_objects(Tag::get_tags(Config::get('offset_limit'),array()));
+ $object_ids = $browse->get_saved();
+ $keys = array_keys($object_ids);
Tag::build_cache($keys);
- $object_ids = Browse::get_saved();
show_box_top(_('Tag Cloud'),$class);
require_once Config::get('prefix') . '/templates/show_tagcloud.inc.php';
show_box_bottom();
require_once Config::get('prefix') . '/templates/browse_content.inc.php';
break;
case 'artist':
- Browse::set_sort('name','ASC');
- Browse::show_objects();
+ $browse->set_sort('name','ASC');
+ $browse->show_objects();
break;
case 'song':
- Browse::set_sort('title','ASC');
- Browse::show_objects();
+ $browse->set_sort('title','ASC');
+ $browse->show_objects();
break;
case 'live_stream':
- Browse::set_sort('name','ASC');
- Browse::show_objects();
+ $browse->set_sort('name','ASC');
+ $browse->show_objects();
break;
case 'catalog':
break;
case 'playlist':
- Browse::set_sort('type','ASC');
- Browse::set_filter('playlist_type','1');
- Browse::show_objects();
+ $browse->set_sort('type','ASC');
+ $browse->set_filter('playlist_type','1');
+ $browse->show_objects();
break;
case 'video':
- Browse::set_sort('title','ASC');
- Browse::show_objects();
+ $browse->set_sort('title','ASC');
+ $browse->show_objects();
break;
default:
break;
} // end Switch $action
+$browse->store();
+
/* Show the Footer */
show_footer();
?>
diff --git a/democratic.php b/democratic.php
index 76279c66..41c50e6d 100644
--- a/democratic.php
+++ b/democratic.php
@@ -114,10 +114,11 @@ switch ($_REQUEST['action']) {
$objects = $democratic->get_items();
Song::build_cache($democratic->object_ids);
Democratic::build_vote_cache($democratic->vote_ids);
- Browse::set_type('democratic');
- Browse::reset();
- Browse::set_static_content(1);
- Browse::show_objects($objects);
+ $browse = new Browse();
+ $browse->set_type('democratic');
+ $browse->set_static_content(true);
+ $browse->show_objects($objects);
+ $browse->store();
break;
} // end switch on action
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index b65c2cc5..fdd274aa 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,7 @@
--------------------------------------------------------------------------
v.3.6-Alpha1
+ - Changed Browse from a singleton to multiple instances
- Fixed setting access levels for plugin passwords
- Fixed handling of unusual characters in passwords
- Fixed support for requesting different thumbnail sizes
diff --git a/lib/class/api.class.php b/lib/class/api.class.php
index 4fef01d4..821ad6f6 100644
--- a/lib/class/api.class.php
+++ b/lib/class/api.class.php
@@ -22,13 +22,16 @@
/**
* API Class
- * This handles functions relating to the API written for ampache, initially this is very focused
- * on providing functionality for Amarok so it can integrate with Ampache
+ * This handles functions relating to the API written for ampache, initially
+ * this is very focused on providing functionality for Amarok so it can
+ * integrate with Ampache.
*/
class Api {
public static $version = '350001';
+ private static $browse = null;
+
/**
* constructor
* This really isn't anything to do here, so it's private
@@ -40,6 +43,16 @@ class Api {
} // constructor
/**
+ * _auto_init
+ * Automatically called when this class is loaded.
+ */
+ public static function _auto_init() {
+ if (is_null(self::$browse)) {
+ self::$browse = new Browse();
+ }
+ }
+
+ /**
* set_filter
* This is a play on the browse function, it's different as we expose
* the filters in a slightly different and vastly simpler way to the
@@ -55,29 +68,29 @@ class Api {
// Check for a range, if no range default to gt
if (strpos($value,'/')) {
$elements = explode('/',$value);
- Browse::set_filter('add_lt',strtotime($elements['1']));
- Browse::set_filter('add_gt',strtotime($elements['0']));
+ self::$browse->set_filter('add_lt',strtotime($elements['1']));
+ self::$browse->set_filter('add_gt',strtotime($elements['0']));
}
else {
- Browse::set_filter('add_gt',strtotime($value));
+ self::$browse->set_filter('add_gt',strtotime($value));
}
break;
case 'update':
// Check for a range, if no range default to gt
if (strpos($value,'/')) {
$elements = explode('/',$value);
- Browse::set_filter('update_lt',strtotime($elements['1']));
- Browse::set_filter('update_gt',strtotime($elements['0']));
+ self::$browse->set_filter('update_lt',strtotime($elements['1']));
+ self::$browse->set_filter('update_gt',strtotime($elements['0']));
}
else {
- Browse::set_filter('update_gt',strtotime($value));
+ self::$browse->set_filter('update_gt',strtotime($value));
}
break;
case 'alpha_match':
- Browse::set_filter('alpha_match',$value);
+ self::$browse->set_filter('alpha_match',$value);
break;
case 'exact_match':
- Browse::set_filter('exact_match',$value);
+ self::$browse->set_filter('exact_match',$value);
break;
default:
// Rien a faire
@@ -242,9 +255,9 @@ class Api {
*/
public static function artists($input) {
- Browse::reset_filters();
- Browse::set_type('artist');
- Browse::set_sort('name','ASC');
+ self::$browse->reset_filters();
+ self::$browse->set_type('artist');
+ self::$browse->set_sort('name','ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
@@ -255,7 +268,7 @@ class Api {
xmlData::set_offset($input['offset']);
xmlData::set_limit($input['limit']);
- $artists = Browse::get_objects();
+ $artists = self::$browse->get_objects();
// echo out the resulting xml document
ob_end_clean();
echo xmlData::artists($artists);
@@ -315,15 +328,15 @@ class Api {
*/
public static function albums($input) {
- Browse::reset_filters();
- Browse::set_type('album');
- Browse::set_sort('name','ASC');
+ self::$browse->reset_filters();
+ self::$browse->set_type('album');
+ self::$browse->set_sort('name','ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
Api::set_filter('add',$input['add']);
Api::set_filter('update',$input['update']);
- $albums = Browse::get_objects();
+ $albums = self::$browse->get_objects();
// Set the offset
xmlData::set_offset($input['offset']);
@@ -368,13 +381,13 @@ class Api {
*/
public static function tags($input) {
- Browse::reset_filters();
- Browse::set_type('tag');
- Browse::set_sort('name','ASC');
+ self::$browse->reset_filters();
+ self::$browse->set_type('tag');
+ self::$browse->set_sort('name','ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
- $tags = Browse::get_objects();
+ $tags = self::$browse->get_objects();
// Set the offset
xmlData::set_offset($input['offset']);
@@ -451,16 +464,16 @@ class Api {
*/
public static function songs($input) {
- Browse::reset_filters();
- Browse::set_type('song');
- Browse::set_sort('title','ASC');
+ self::$browse->reset_filters();
+ self::$browse->set_type('song');
+ self::$browse->set_sort('title','ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
Api::set_filter('add',$input['add']);
Api::set_filter('update',$input['update']);
- $songs = Browse::get_objects();
+ $songs = self::$browse->get_objects();
// Set the offset
xmlData::set_offset($input['offset']);
@@ -506,14 +519,14 @@ class Api {
*/
public static function playlists($input) {
- Browse::reset_filters();
- Browse::set_type('playlist');
- Browse::set_sort('name','ASC');
+ self::$browse->reset_filters();
+ self::$browse->set_type('playlist');
+ self::$browse->set_sort('name','ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
- $playlist_ids = Browse::get_objects();
+ $playlist_ids = self::$browse->get_objects();
xmlData::set_offset($input['offset']);
xmlData::set_limit($input['limit']);
@@ -586,14 +599,14 @@ class Api {
*/
public static function videos($input) {
- Browse::reset_filters();
- Browse::set_type('video');
- Browse::set_sort('title','ASC');
+ self::$browse->reset_filters();
+ self::$browse->set_type('video');
+ self::$browse->set_sort('title','ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
- $video_ids = Browse::get_objects();
+ $video_ids = self::$browse->get_objects();
xmlData::set_offset($input['offset']);
xmlData::set_limit($input['limit']);
diff --git a/lib/class/art.class.php b/lib/class/art.class.php
index cdf77cc1..ddb74539 100644
--- a/lib/class/art.class.php
+++ b/lib/class/art.class.php
@@ -36,6 +36,7 @@ class Art extends database_object {
public $thumb;
public $thumb_mime;
+ private static $enabled;
/**
* Constructor
@@ -50,6 +51,41 @@ class Art extends database_object {
} // constructor
/**
+ * _auto_init
+ * Called on creation of the class
+ */
+ public static function _auto_init() {
+ self::$enabled = make_bool($_SESSION['art_enabled']);
+ }
+
+ /**
+ * is_enabled
+ * Checks whether the user currently wants art
+ */
+ public static function is_enabled() {
+ if (self::$enabled || (Config::get('bandwidth') > 25)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * set_enabled
+ * Changes the value of enabled
+ */
+ public static function set_enabled($value = null) {
+ if (is_null($value)) {
+ self::$enabled = self::$enabled ? false : true;
+ }
+ else {
+ self::$enabled = make_bool($value);
+ }
+
+ $_SESSION['art_enabled'] = self::$enabled;
+ }
+
+ /**
* validate_type
* This validates the type
*/
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php
index 17408a37..7b8a75d9 100644
--- a/lib/class/browse.class.php
+++ b/lib/class/browse.class.php
@@ -29,40 +29,14 @@
*/
class Browse extends Query {
- // Public static vars that are cached
- public static $sql;
- public static $start;
- public static $offset;
- public static $total_objects;
- public static $type;
-
- // Boolean if this is a simple browse method (use different paging code)
- public static $simple_browse;
-
- // Static Content, this is defaulted to false, if set to true then when we can't
- // apply any filters that would change the result set.
- public static $static_content = false;
- private static $_cache = array();
-
-
- /**
- * constructor
- * This should never be called
- */
- private function __construct() {
-
- // Rien a faire
-
- } // __construct
-
/**
* set_simple_browse
* This sets the current browse object to a 'simple' browse method
* which means use the base query provided and expand from there
*/
- public static function set_simple_browse($value) {
+ public function set_simple_browse($value) {
- parent::set_is_simple($value);
+ $this->set_is_simple($value);
} // set_simple_browse
@@ -70,9 +44,9 @@ class Browse extends Query {
* add_supplemental_object
* Legacy function, need to find a better way to do that
*/
- public static function add_supplemental_object($class,$uid) {
+ public function add_supplemental_object($class, $uid) {
- $_SESSION['browse']['supplemental'][$class] = intval($uid);
+ $_SESSION['browse']['supplemental'][$this->id][$class] = intval($uid);
return true;
@@ -80,12 +54,12 @@ class Browse extends Query {
/**
* get_supplemental_objects
- * This returns an array of 'class','id' for additional objects that need to be
- * created before we start this whole browsing thing
+ * This returns an array of 'class','id' for additional objects that
+ * need to be created before we start this whole browsing thing.
*/
- public static function get_supplemental_objects() {
+ public function get_supplemental_objects() {
- $objects = $_SESSION['browse']['supplemental'];
+ $objects = $_SESSION['browse']['supplemental'][$this->id];
if (!is_array($objects)) { $objects = array(); }
@@ -94,73 +68,57 @@ class Browse extends Query {
} // get_supplemental_objects
/**
- * is_enabled
- * This checks if the specified function/feature
- * of browsing is enabled, not sure if this is the best
- * way to go about it, but hey. Returns boolean t/f
- */
- public static function is_enabled($item) {
-
- switch ($item) {
- case 'show_art':
- if (Browse::get_filter('show_art')) {
- return true;
- }
- if (Config::get('bandwidth') > 25) {
- return true;
- }
- break;
- } // end switch
-
- return false;
-
- } // is_enabled
-
- /**
* show_objects
* This takes an array of objects
* and requires the correct template based on the
* type that we are currently browsing
*/
- public static function show_objects($object_ids=false) {
+ public function show_objects($object_ids = null) {
- if (parent::is_simple()) {
- $object_ids = parent::get_saved();
+ if ($this->is_simple() || ! is_array($object_ids)) {
+ $object_ids = $this->get_saved();
}
else {
- $object_ids = is_array($object_ids) ? $object_ids : parent::get_saved();
- parent::save_objects($object_ids);
+ $this->save_objects($object_ids);
}
- // Reset the total items
- self::$total_objects = parent::get_total($object_ids);
-
- // Limit is based on the users preferences if this is not a simple browse because we've got too much here
- if (count($object_ids) > parent::get_start() AND !parent::is_simple()) {
- $object_ids = array_slice($object_ids,parent::get_start(),parent::get_offset(),TRUE);
+ // Limit is based on the user's preferences if this is not a
+ // simple browse because we've got too much here
+ if ((count($object_ids) > $this->get_start()) &&
+ ! $this->is_simple() &&
+ ! $this->is_static_content()) {
+ $object_ids = array_slice(
+ $object_ids,
+ $this->get_start(),
+ $this->get_offset(),
+ true
+ );
}
// Load any additional object we need for this
- $extra_objects = self::get_supplemental_objects();
+ $extra_objects = $this->get_supplemental_objects();
+ $browse = $this;
foreach ($extra_objects as $class_name => $id) {
${$class_name} = new $class_name($id);
}
// Format any matches we have so we can show them to the masses
- if ($filter_value = parent::get_filter('alpha_match')) {
+ if ($filter_value = $this->get_filter('alpha_match')) {
$match = ' (' . $filter_value . ')';
}
- elseif ($filter_value = parent::get_filter('starts_with')) {
+ elseif ($filter_value = $this->get_filter('starts_with')) {
$match = ' (' . $filter_value . ')';
}
+ $type = $this->get_type();
+
// Set the correct classes based on type
- $class = "box browse_".self::$type;
+ $class = "box browse_" . $type;
Ajax::start_container('browse_content');
// Switch on the type of browsing we're doing
- switch (parent::get_type()) {
+ switch ($type) {
case 'song':
show_box_top(_('Songs') . $match, $class);
Song::build_cache($object_ids);
@@ -241,45 +199,34 @@ class Browse extends Query {
// Rien a faire
break;
} // end switch on type
+ echo '<script type="text/javascript">ajaxPut("' . Config::get('ajax_url') . '?page=browse&action=get_filters&browse_id=' . $this->id . '","");</script>';
Ajax::end_container();
} // show_object
/**
- * _auto_init
- * this function reloads information back from the session
- * it is called on creation of the class
- */
- public static function _auto_init() {
-
- $offset = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
- parent::set_offset($offset);
-
- } // _auto_init
-
- /**
* set_filter_from_request
* //FIXME
*/
- public static function set_filter_from_request($r) {
- foreach($r as $k=>$v) {
+ public function set_filter_from_request($request) {
+ foreach($request as $key => $value) {
//reinterpret v as a list of int
- $vl = explode(',', $v);
- $ok = 1;
- foreach($vl as $i) {
- if (!is_numeric($i)) {
- $ok = 0;
+ $list = explode(',', $value);
+ $ok = true;
+ foreach($list as $item) {
+ if (!is_numeric($item)) {
+ $ok = false;
break;
}
}
if ($ok) {
- if (sizeof($vl) == 1) {
- self::set_filter($k, $vl[0]);
+ if (sizeof($list) == 1) {
+ $this->set_filter($key, $list[0]);
}
}
else {
- self::set_filter($k, $vl);
+ $this->set_filter($key, $list);
}
}
} // set_filter_from_request
diff --git a/lib/class/query.class.php b/lib/class/query.class.php
index 109cef1f..112f7a07 100644
--- a/lib/class/query.class.php
+++ b/lib/class/query.class.php
@@ -23,67 +23,78 @@
/**
* Query Class
* This handles all of the sql/filtering for the ampache database
- * this was seperated out from browse, to accomodate Dynamic Playlists
+ * this was seperated out from browse to accomodate Dynamic Playlists
*/
class Query {
- // Public static vars that are cached
- public static $sql;
- public static $start;
- public static $offset;
- public static $total_objects;
- public static $type;
+ public $id;
- // Static Content, this is defaulted to false, if set to true then when we can't
- // apply any filters that would change the result set.
- public static $static_content = false;
-
- // Private cache information
- private static $_cache = array();
- private static $_state = array();
+ protected $_state = array();
+ protected $_cache;
/**
* constructor
- * This should never be called
+ * This should be called
*/
- private function __construct() {
+ public function __construct($id = null) {
+ $sid = Dba::escape(session_id());
+
+ if (is_null($id)) {
+ $this->reset();
+ $data = Dba::escape(serialize($this->_state));
+
+ $sql = "INSERT INTO `tmp_browse` (`sid`, `data`) " .
+ "VALUES('$sid', '$data')";
+ $db_results = Dba::write($sql);
+ $this->id = Dba::insert_id();
+ return true;
+ }
+
+ $this->id = $id;
- // Rien a faire
+ $sql = "SELECT `data` FROM `tmp_browse` " .
+ "WHERE `id`='$id' AND `sid`='$sid'";
+
+ $db_results = Dba::read($sql);
+
+ if ($results = Dba::fetch_assoc($db_results)) {
+ $this->_state = unserialize($results['data']);
+
+ }
- } // __construct
+ Error::add('browse', _('Browse not found or expired, try reloading the page'));
+ return false;
+ }
/**
* set_filter
- * This saves the filter data we pass it into the session
- * This is done here so that it's easy to modify where the data
- * is saved should I change my mind in the future. It also makes
- * a single point for whitelist tweaks etc
+ * This saves the filter data we pass it.
*/
- public static function set_filter($key,$value) {
+ public function set_filter($key, $value) {
switch ($key) {
case 'show_art':
- if (self::get_filter($key)) {
- unset(self::$_state['filter'][self::$type][$key]);
+ if ($this->get_filter($key, $id)) {
+ unset($this->_state['filter'][$key]);
}
else {
- self::$_state['filter'][self::$type][$key] = 1;
+ $this->_state['filter'][$key] = true;
}
break;
case 'tag':
if (is_array($value)) {
- self::$_state['filter'][self::$type][$key] = $value;
+ $this->_state['filter'][$key] = $value;
}
elseif (is_numeric($value)) {
- self::$_state['filter'][self::$type][$key] = array($value);
+ $this->_state['filter'][$key] = array($value);
}
else {
- self::$_state['filter'][self::$type][$key] = array();
+ $this->_state['filter'][$key] = array();
}
break;
case 'artist':
case 'album':
- self::$_state['filter'][self::$type][$key] = $value;
+ $this->_state['filter'][$key] = $value;
break;
case 'min_count':
case 'unplayed':
@@ -94,18 +105,18 @@ class Query {
case 'add_gt':
case 'update_lt':
case 'update_gt':
- self::$_state['filter'][self::$type][$key] = intval($value);
+ $this->_state['filter'][$key] = intval($value);
break;
case 'exact_match':
case 'alpha_match':
case 'starts_with':
- if (self::$static_content) { return false; }
- self::$_state['filter'][self::$type][$key] = $value;
+ if ($this->is_static_content($id)) { return false; }
+ $this->_state['filter'][$key] = $value;
break;
case 'playlist_type':
- // They must be content managers to turn this off
- if (self::$_state['filter'][self::$type][$key] AND Access::check('interface','50')) { unset(self::$_state['filter'][self::$type][$key]); }
- else { self::$_state['filter'][self::$type][$key] = '1'; }
+ // Must be a content manager to turn this off
+ if ($this->_state['filter'][$key] AND Access::check('interface','50')) { unset($this->_state['filter'][$key]); }
+ else { $this->_state['filter'][$key] = '1'; }
break;
default:
// Rien a faire
@@ -114,8 +125,8 @@ class Query {
} // end switch
// If we've set a filter we need to reset the totals
- self::reset_total();
- self::set_start(0);
+ $this->reset_total($id);
+ $this->set_start(0, $id);
return true;
@@ -123,18 +134,20 @@ class Query {
/**
* reset
- * Reset everything, this should only be called when we are starting fresh
+ * Reset everything, this should only be called when we are starting
+ * fresh
*/
- public static function reset() {
-
- self::reset_base();
- self::reset_filters();
- self::reset_total();
- self::reset_join();
- self::reset_select();
- self::reset_having();
- self::set_is_simple(0);
- self::set_start(0);
+ public function reset() {
+
+ $this->reset_base();
+ $this->reset_filters();
+ $this->reset_total();
+ $this->reset_join();
+ $this->reset_select();
+ $this->reset_having();
+ $this->set_is_simple(false);
+ $this->set_start(0);
+ $this->set_offset(Config::get('offset_limit') ? Config::get('offset_limit') : '25');
} // reset
@@ -142,9 +155,9 @@ class Query {
* reset_base
* this resets the base string
*/
- public static function reset_base() {
+ public function reset_base() {
- self::$_state['base'][self::$type] = NULL;
+ $this->_state['base'] = NULL;
} // reset_base
@@ -152,9 +165,9 @@ class Query {
* reset_select
* This resets the select fields that we've added so far
*/
- public static function reset_select() {
+ public function reset_select() {
- self::$_state['select'][self::$type] = array();
+ $this->_state['select'] = array();
} // reset_select
@@ -162,9 +175,9 @@ class Query {
* reset_having
* Null out the having clause
*/
- public static function reset_having() {
+ public function reset_having() {
- unset(self::$_state['having'][self::$type]);
+ unset($this->_state['having']);
} // reset_having
@@ -172,9 +185,9 @@ class Query {
* reset_join
* clears the joins if there are any
*/
- public static function reset_join() {
+ public function reset_join() {
- unset(self::$_state['join'][self::$type]);
+ unset($this->_state['join']);
} // reset_join
@@ -182,9 +195,9 @@ class Query {
* reset_filter
* This is a wrapper function that resets the filters
*/
- public static function reset_filters() {
+ public function reset_filters() {
- self::$_state['filter'] = array();
+ $this->_state['filter'] = array();
} // reset_filters
@@ -192,9 +205,9 @@ class Query {
* reset_total
* This resets the total for the browse type
*/
- public static function reset_total() {
+ public function reset_total() {
- unset(self::$_state['total'][self::$type]);
+ unset($this->_state['total']);
} // reset_total
@@ -202,10 +215,11 @@ class Query {
* get_filter
* returns the specified filter value
*/
- public static function get_filter($key) {
+ public function get_filter($key) {
// Simple enough, but if we ever move this crap
- return self::$_state['filter'][self::$type][$key];
+ // If we ever move this crap what?
+ return $this->_state['filter'][$key];
} // get_filter
@@ -213,9 +227,9 @@ class Query {
* get_start
* This returns the current value of the start
*/
- public static function get_start() {
+ public function get_start() {
- return self::$start;
+ return $this->_state['start'];
} // get_start
@@ -223,33 +237,44 @@ class Query {
* get_offset
* This returns the current offset
*/
- public static function get_offset() {
-
- return self::$offset;
+ public function get_offset() {
+ if ($this->is_static_content()) {
+ return $this->get_total();
+ }
+ return $this->_state['offset'];
} // get_offset
/**
+ * set_total
+ * This sets the total number of objects
+ */
+ public function set_total($total) {
+ $this->_state['total'] = $total;
+ }
+
+ /**
* get_total
- * This returns the toal number of obejcts for this current sort type. If it's already cached used it!
- * if they pass us an array then use that!
+ * This returns the total number of objects for this current sort type.
+ * If it's already cached used it. if they pass us an array then use
+ * that.
*/
- public static function get_total($objects=false) {
+ public function get_total($objects = null) {
// If they pass something then just return that
- if (is_array($objects) and !self::is_simple()) {
+ if (is_array($objects) and !$this->is_simple()) {
return count($objects);
}
// See if we can find it in the cache
- if (isset(self::$_state['total'][self::$type])) {
- return self::$_state['total'][self::$type];
+ if (isset($this->_state['total'])) {
+ return $this->_state['total'];
}
- $db_results = Dba::read(self::get_sql(false));
+ $db_results = Dba::read($this->get_sql(false));
$num_rows = Dba::num_rows($db_results);
- self::$_state['total'][self::$type] = $num_rows;
+ $this->_state['total'] = $num_rows;
return $num_rows;
@@ -257,12 +282,13 @@ class Query {
/**
* get_allowed_filters
- * This returns an array of the allowed filters based on the type of object we are working
- * with, this is used to display the 'filter' sidebar stuff, must be called post browse stuff
+ * This returns an array of the allowed filters based on the type of
+ * object we are working with, this is used to display the 'filter'
+ * sidebar stuff.
*/
- public static function get_allowed_filters() {
+ public static function get_allowed_filters($type) {
- switch (self::$type) {
+ switch ($type) {
case 'album':
$valid_array = array('add_lt','add_gt','update_lt','update_gt','show_art',
'starts_with','exact_match','alpha_match');
@@ -301,7 +327,7 @@ class Query {
* we do this here so we only have to maintain a single whitelist
* and if I want to change the location I only have to do it here
*/
- public static function set_type($type) {
+ public function set_type($type) {
switch($type) {
case 'user':
@@ -319,8 +345,8 @@ class Query {
case 'live_stream':
case 'democratic':
// Set it
- self::$type = $type;
- self::load_start();
+ $this->_state['type'] = $type;
+ $this->set_base_sql(true);
break;
default:
// Rien a faire
@@ -332,9 +358,9 @@ class Query {
* get_type
* This returns the type of the browse we currently are using
*/
- public static function get_type() {
+ public function get_type() {
- return self::$type;
+ return $this->_state['type'];
} // get_type
@@ -342,9 +368,9 @@ class Query {
* set_sort
* This sets the current sort(s)
*/
- public static function set_sort($sort,$order='') {
+ public function set_sort($sort,$order='') {
- switch (self::get_type()) {
+ switch ($this->get_type()) {
case 'playlist_song':
case 'song':
$valid_array = array('title','year','track','time','album','artist');
@@ -376,27 +402,27 @@ class Query {
} // end switch
// If it's not in our list, smeg off!
- if (!in_array($sort,$valid_array)) {
+ if (!in_array($sort, $valid_array)) {
return false;
}
if ($order) {
$order = ($order == 'DESC') ? 'DESC' : 'ASC';
- self::$_state['sort'][self::$type] = array();
- self::$_state['sort'][self::$type][$sort] = $order;
+ $this->_state['sort'] = array();
+ $this->_state['sort'][$sort] = $order;
}
- elseif (self::$_state['sort'][self::$type][$sort] == 'DESC') {
+ elseif ($this->_state['sort'][$sort] == 'DESC') {
// Reset it till I can figure out how to interface the hotness
- self::$_state['sort'][self::$type] = array();
- self::$_state['sort'][self::$type][$sort] = 'ASC';
+ $this->_state['sort'] = array();
+ $this->_state['sort'][$sort] = 'ASC';
}
else {
// Reset it till I can figure out how to interface the hotness
- self::$_state['sort'][self::$type] = array();
- self::$_state['sort'][self::$type][$sort] = 'DESC';
+ $this->_state['sort'] = array();
+ $this->_state['sort'][$sort] = 'DESC';
}
- self::resort_objects();
+ $this->resort_objects();
} // set_sort
@@ -404,20 +430,21 @@ class Query {
* set_offset
* This sets the current offset of this query
*/
- public static function set_offset($offset) {
+ public function set_offset($offset) {
- self::$offset = abs($offset);
+ $this->_state['offset'] = abs($offset);
} // set_offset
/**
* set_select
- * This appends more information to the select part of the SQL statement, we're going to move to the
- * %%SELECT%% style queries, as I think it's the only way to do this....
+ * This appends more information to the select part of the SQL
+ * statement, we're going to move to the %%SELECT%% style queries, as I
+ * think it's the only way to do this...
*/
- public static function set_select($field) {
+ public function set_select($field) {
- self::$_state['select'][self::$type][] = $field;
+ $this->_state['select'][] = $field;
} // set_select
@@ -425,19 +452,20 @@ class Query {
* set_join
* This sets the joins for the current browse object
*/
- public static function set_join($type,$table,$source,$dest,$priority=100) {
+ public function set_join($type, $table, $source, $dest, $priority) {
- self::$_state['join'][self::$type][$priority][$table] = strtoupper($type) . ' JOIN ' . $table . ' ON ' . $source . '=' . $dest;
+ $this->_state['join'][$priority][$table] = strtoupper($type) . ' JOIN ' . $table . ' ON ' . $source . '=' . $dest;
} // set_join
/**
* set_having
- * This sets the "HAVING" part of the query, we can only have one.. god this is ugly
+ * This sets the "HAVING" part of the query, we can only have one..
+ * god this is ugly
*/
- public static function set_having($condition) {
+ public function set_having($condition) {
- self::$_state['having'][self::$type] = $condition;
+ $this->_state['having'] = $condition;
} // set_having
@@ -447,12 +475,14 @@ class Query {
* We need to store this in the session so that it can be pulled
* back, if they hit the back button
*/
- public static function set_start($start) {
+ public function set_start($start) {
- if (!self::$static_content) {
- self::$_state[self::$type]['start'] = intval($start);
+
+ $start = intval($start);
+
+ if (!$this->is_static_content()) {
+ $this->_state['start'] = $start;
}
- self::$start = intval($start);
} // set_start
@@ -461,10 +491,10 @@ class Query {
* This sets the current browse object to a 'simple' browse method
* which means use the base query provided and expand from there
*/
- public static function set_is_simple($value) {
+ public function set_is_simple($value) {
$value = make_bool($value);
- self::$_state['simple'][self::$type] = $value;
+ $this->_state['simple'] = $value;
} // set_is_simple
@@ -474,66 +504,58 @@ class Query {
* should be static, if they are then content filtering/altering
* methods will be skipped
*/
- public static function set_static_content($value) {
+ public function set_static_content($value) {
$value = make_bool($value);
- self::$static_content = $value;
- // We want to start at 0 it's static
+ // We want to start at 0 if it's static
if ($value) {
- self::set_start('0');
+ $this->set_start('0');
}
- self::$_state[self::$type]['static'] = $value;
+ $this->_state['static'] = $value;
} // set_static_content
+ public function is_static_content() {
+ return $this->_state['static'];
+ }
+
/**
* is_simple
- * this returns true or false if the current browse type is set to static
+ * This returns whether or not the current browse type is set to static.
*/
- public static function is_simple() {
+ public function is_simple() {
- return self::$_state['simple'][self::$type];
+ return $this->_state['simple'];
} // is_simple
/**
- * load_start
- * This returns a stored start point for the browse mojo
- */
- public static function load_start() {
-
- self::$start = intval(self::$_state[self::$type]['start']);
-
- } // end load_start
-
- /**
* get_saved
- * This looks in the session for the saved
- * stuff and returns what it finds
+ * This looks in the session for the saved stuff and returns what it
+ * finds.
*/
- public static function get_saved() {
+ public function get_saved() {
// See if we have it in the local cache first
- if (is_array(self::$_cache['browse'][self::$type])) {
- return self::$_cache['browse'][self::$type];
+ if (is_array($this->_cache)) {
+ return $this->_cache;
}
- if (!self::is_simple()) {
- // If not then we're going to need to read from the database :(
- $sid = session_id();
- $type = Dba::escape(self::$type);
-
- $sql = "SELECT `data` FROM `tmp_browse` WHERE `sid`='$sid' AND `type`='$type'";
+ if (!$this->is_simple()) {
+ $sid = Dba::escape(session_id());
+ $id = Dba::escape($this->id);
+ $sql = "SELECT `object_data` FROM `tmp_browse` WHERE `sid`='$sid' AND `id`='$id'";
$db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results);
- $objects = unserialize($row['data']);
+ $this->_cache = unserialize($row['object_data']);
+ return $this->_cache;
}
else {
- $objects = self::get_objects();
+ $objects = $this->get_objects();
}
return $objects;
@@ -546,11 +568,11 @@ class Query {
* currently browsing by it applies the sql and logic based
* filters
*/
- public static function get_objects() {
+ public function get_objects() {
// First we need to get the SQL statement we are going to run
// This has to run against any possible filters (dependent on type)
- $sql = self::get_sql();
+ $sql = $this->get_sql(true);
$db_results = Dba::read($sql);
$results = array();
@@ -558,17 +580,17 @@ class Query {
$results[] = $data;
}
- $results = self::post_process($results);
+ $results = $this->post_process($results);
$filtered = array();
foreach ($results as $data) {
// Make sure that this object passes the logic filter
- if (self::logic_filter($data['id'])) {
+ if ($this->logic_filter($data['id'])) {
$filtered[] = $data['id'];
}
} // end while
// Save what we've found and then return it
- self::save_objects($filtered);
+ $this->save_objects($filtered);
return $filtered;
@@ -578,84 +600,81 @@ class Query {
* set_base_sql
* This saves the base sql statement we are going to use.
*/
- private static function set_base_sql() {
-
+ private function set_base_sql($force = false) {
+
// Only allow it to be set once
- if (strlen(self::$_state['base'][self::$type])) { return true; }
+ if (strlen($this->_state['base']) && !$force) { return true; }
- switch (self::$type) {
+ switch ($this->get_type()) {
case 'album':
- self::set_select("DISTINCT(`album`.`id`)");
+ $this->set_select("DISTINCT(`album`.`id`)");
$sql = "SELECT %%SELECT%% FROM `album` ";
break;
case 'artist':
- self::set_select("DISTINCT(`artist`.`id`)");
+ $this->set_select("DISTINCT(`artist`.`id`)");
$sql = "SELECT %%SELECT%% FROM `artist` ";
break;
case 'user':
- self::set_select("`user`.`id`");
+ $this->set_select("`user`.`id`");
$sql = "SELECT %%SELECT%% FROM `user` ";
break;
case 'live_stream':
- self::set_select("`live_stream`.`id`");
+ $this->set_select("`live_stream`.`id`");
$sql = "SELECT %%SELECT%% FROM `live_stream` ";
break;
case 'playlist':
- self::set_select("`playlist`.`id`");
+ $this->set_select("`playlist`.`id`");
$sql = "SELECT %%SELECT%% FROM `playlist` ";
break;
case 'flagged':
- self::set_select("`flagged`.`id`");
+ $this->set_select("`flagged`.`id`");
$sql = "SELECT %%SELECT%% FROM `flagged` ";
break;
case 'shoutbox':
- self::set_select("`user_shout`.`id`");
+ $this->set_select("`user_shout`.`id`");
$sql = "SELECT %%SELECT%% FROM `user_shout` ";
break;
case 'video':
- self::set_select("`video`.`id`");
+ $this->set_select("`video`.`id`");
$sql = "SELECT %%SELECT%% FROM `video` ";
break;
case 'tag':
- self::set_select("DISTINCT(`tag`.`id`)");
- self::set_join('left','tag_map','`tag_map`.`tag_id`','`tag`.`id`',1);
+ $this->set_select("DISTINCT(`tag`.`id`)");
+ $this->set_join('left', 'tag_map', '`tag_map`.`tag_id`', '`tag`.`id`', 1);
$sql = "SELECT %%SELECT%% FROM `tag` ";
break;
case 'playlist_song':
case 'song':
default:
- self::set_select("DISTINCT(`song`.`id`)");
+ $this->set_select("DISTINCT(`song`.`id`)");
$sql = "SELECT %%SELECT%% FROM `song` ";
break;
} // end base sql
- self::$_state['base'][self::$type] = $sql;
+ $this->_state['base'] = $sql;
} // set_base_sql
/**
* get_select
- * This returns the selects in a format that is friendly for a sql statement
+ * This returns the selects in a format that is friendly for a sql
+ * statement.
*/
- private static function get_select() {
+ private function get_select() {
- $select_string = implode(self::$_state['select'][self::$type],", ");
+ $select_string = implode($this->_state['select'], ", ");
return $select_string;
} // get_select
/**
* get_base_sql
- * This returns the base sql statement all parsed up, this should be called after all set operations
+ * This returns the base sql statement all parsed up, this should be
+ * called after all set operations.
*/
- private static function get_base_sql() {
-
- // Legacy code, should be removed once other code is updated
- //FIXME: REMOVE
- if (!self::$_state['base'][self::$type]) { self::set_base_sql(); }
-
- $sql = str_replace("%%SELECT%%",self::get_select(),self::$_state['base'][self::$type]);
+ private function get_base_sql() {
+ $sql = str_replace("%%SELECT%%", $this->get_select(), $this->_state['base']);
return $sql;
} // get_base_sql
@@ -664,16 +683,17 @@ class Query {
* get_filter_sql
* This returns the filter part of the sql statement
*/
- private static function get_filter_sql() {
+ private function get_filter_sql() {
- if (!is_array(self::$_state['filter'][self::$type])) {
+ if (!is_array($this->_state['filter'])) {
return '';
}
$sql = "WHERE 1=1 AND ";
- foreach (self::$_state['filter'][self::$type] as $key=>$value) {
- $sql .= self::sql_filter($key,$value);
+ foreach ($this->_state['filter']
+ as $key => $value) {
+ $sql .= $this->sql_filter($key, $value);
}
$sql = rtrim($sql,'AND ') . ' ';
@@ -686,14 +706,17 @@ class Query {
* get_sort_sql
* Returns the sort sql part
*/
- private static function get_sort_sql() {
+ private function get_sort_sql() {
- if (!is_array(self::$_state['sort'][self::$type])) { return ''; }
+ if (!is_array($this->_state['sort'])) {
+ return '';
+ }
$sql = 'ORDER BY ';
- foreach (self::$_state['sort'][self::$type] as $key=>$value) {
- $sql .= self::sql_sort($key,$value);
+ foreach ($this->_state['sort']
+ as $key => $value) {
+ $sql .= $this->sql_sort($key, $value);
}
$sql = rtrim($sql,'ORDER BY ');
@@ -707,11 +730,11 @@ class Query {
* get_limit_sql
* This returns the limit part of the sql statement
*/
- private static function get_limit_sql() {
+ private function get_limit_sql() {
- if (!self::is_simple()) { return ''; }
+ if (!$this->is_simple()) { return ''; }
- $sql = ' LIMIT ' . intval(self::$start) . ',' . intval(self::$offset);
+ $sql = ' LIMIT ' . intval($this->get_start()) . ',' . intval($this->get_offset());
return $sql;
@@ -721,16 +744,15 @@ class Query {
* get_join_sql
* This returns the joins that this browse may need to work correctly
*/
- private static function get_join_sql() {
+ private function get_join_sql() {
- if (!is_array(self::$_state['join'][self::$type])) {
+ if (!is_array($this->_state['join'])) {
return '';
}
$sql = '';
- // We need to itterate through these from 0 - 100 so that we add the joins in the right order
- foreach (self::$_state['join'][self::$type] as $joins) {
+ foreach ($this->_state['join'] as $joins) {
foreach ($joins as $join) {
$sql .= $join . ' ';
} // end foreach joins at this level
@@ -744,9 +766,9 @@ class Query {
* get_having_sql
* this returns the having sql stuff, if we've got anything
*/
- public static function get_having_sql() {
+ public function get_having_sql() {
- $sql = self::$_state['having'][self::$type];
+ $sql = $this->_state['having'];
return $sql;
@@ -755,18 +777,18 @@ class Query {
/**
* get_sql
* This returns the sql statement we are going to use this has to be run
- * every time we get the objects because it depends on the filters and the
- * type of object we are currently browsing
+ * every time we get the objects because it depends on the filters and
+ * the type of object we are currently browsing.
*/
- public static function get_sql($limit=true) {
+ public function get_sql($limit = true) {
- $sql = self::get_base_sql();
+ $sql = $this->get_base_sql();
- $filter_sql = self::get_filter_sql();
- $join_sql = self::get_join_sql();
- $having_sql = self::get_having_sql();
- $order_sql = self::get_sort_sql();
- $limit_sql = $limit ? self::get_limit_sql() : '';
+ $filter_sql = $this->get_filter_sql();
+ $join_sql = $this->get_join_sql();
+ $having_sql = $this->get_having_sql();
+ $order_sql = $this->get_sort_sql();
+ $limit_sql = $limit ? $this->get_limit_sql() : '';
$final_sql = $sql . $join_sql . $filter_sql . $having_sql . $order_sql . $limit_sql;
@@ -776,49 +798,51 @@ class Query {
/**
* post_process
- * This does some additional work on the results that we've received before returning them
+ * This does some additional work on the results that we've received
+ * before returning them.
*/
- private static function post_process($results) {
+ private function post_process($data) {
- $tags = self::$_state['filter']['tag'];
+ $tags = $this->_state['filter']['tag'];
if (!is_array($tags) || sizeof($tags) < 2) {
- return $results;
+ return $data;
}
- $cnt = sizeof($tags);
- $ar = array();
- foreach($results as $row) {
- $ar[$row['id']]++;
+ $tag_count = sizeof($tags);
+ $count = array();
+
+ foreach($data as $row) {
+ $count[$row['id']]++;
}
- $res = array();
+ $results = array();
- foreach($ar as $k=>$v) {
- if ($v >= $cnt) {
- $res[] = array('id' => $k);
+ foreach($count as $key => $value) {
+ if ($value >= $tag_count) {
+ $results[] = array('id' => $key);
}
} // end foreach
- return $res;
+ return $results;
} // post_process
/**
* sql_filter
* This takes a filter name and value and if it is possible
- * to filter by this name on this type returns the approiate sql
+ * to filter by this name on this type returns the appropriate sql
* if not returns nothing
*/
- private static function sql_filter($filter,$value) {
+ private function sql_filter($filter, $value) {
$filter_sql = '';
- switch (self::$type) {
+ switch ($this->get_type()) {
case 'song':
switch($filter) {
case 'tag':
- self::set_join('left','`tag_map`','`tag_map`.`object_id`','`song`.`id`');
+ $this->set_join('left', '`tag_map`', '`tag_map`.`object_id`', '`song`.`id`', 100);
$filter_sql = " `tag_map`.`object_type`='song' AND (";
foreach ($value as $tag_id) {
@@ -881,19 +905,19 @@ class Query {
$filter_sql = " `artist`.`id` = '". Dba::escape($value) . "' AND ";
break;
case 'add_lt':
- self::set_join('left','`song`','`song`.`album`','`album`.`id`');
+ $this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100);
$filter_sql = " `song`.`addition_time` <= '" . Dba::escape($value) . "' AND ";
break;
case 'add_gt':
- self::set_join('left','`song`','`song`.`album`','`album`.`id`');
+ $this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100);
$filter_sql = " `song`.`addition_time` >= '" . Dba::escape($value) . "' AND ";
break;
case 'update_lt':
- self::set_join('left','`song`','`song`.`album`','`album`.`id`');
+ $this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100);
$filter_sql = " `song`.`update_time` <= '" . Dba::escape($value) . "' AND ";
break;
case 'update_gt':
- self::set_join('left','`song`','`song`.`album`','`album`.`id`');
+ $this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100);
$filter_sql = " `song`.`update_time` >= '" . Dba::escape($value) . "' AND ";
break;
default:
@@ -913,19 +937,19 @@ class Query {
$filter_sql = " `artist`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
break;
case 'add_lt':
- self::set_join('left','`song`','`song`.`artist`','`artist`.`id`');
+ $this->set_join('left', '`song`', '`song`.`artist`', '`artist`.`id`', 100);
$filter_sql = " `song`.`addition_time` <= '" . Dba::escape($value) . "' AND ";
break;
case 'add_gt':
- self::set_join('left','`song`','`song`.`artist`','`artist`.`id`');
+ $this->set_join('left', '`song`', '`song`.`artist`', '`artist`.`id`', 100);
$filter_sql = " `song`.`addition_time` >= '" . Dba::escape($value) . "' AND ";
break;
case 'update_lt':
- self::set_join('left','`song`','`song`.`artist`','`artist`.`id`');
+ $this->set_join('left', '`song`', '`song`.`artist`', '`artist`.`id`', 100);
$filter_sql = " `song`.`update_time` <= '" . Dba::escape($value) . "' AND ";
break;
case 'update_gt':
- self::set_join('left','`song`','`song`.`artist`','`artist`.`id`');
+ $this->set_join('left', '`song`', '`song`.`artist`', '`artist`.`id`', 100);
$filter_sql = " `song`.`update_time` >= '" . Dba::escape($value) . "' AND ";
break;
default:
@@ -1005,7 +1029,7 @@ class Query {
* these should be limited as they are often intensive and
* require additional queries per object... :(
*/
- private static function logic_filter($object_id) {
+ private function logic_filter($object_id) {
return true;
@@ -1018,12 +1042,13 @@ class Query {
* a logic based sort that will come later as that's
* a lot more complicated
*/
- private static function sql_sort($field,$order) {
+ private function sql_sort($field, $order) {
if ($order != 'DESC') { $order == 'ASC'; }
- // Depending on the type of browsing we are doing we can apply different filters that apply to different fields
- switch (self::$type) {
+ // Depending on the type of browsing we are doing we can apply
+ // different filters that apply to different fields
+ switch ($this->get_type()) {
case 'song':
switch($field) {
case 'title';
@@ -1040,11 +1065,11 @@ class Query {
break;
case 'album':
$sql = '`album`.`name`';
- self::set_join('left','`album`','`album`.`id`','`song`.`album`');
+ $this->set_join('left', '`album`', '`album`.`id`', '`song`.`album`', 100);
break;
case 'artist':
$sql = '`artist`.`name`';
- self::set_join('left','`artist`','`artist`.`id`','`song`.`artist`');
+ $this->set_join('left', '`artist`', '`artist`.`id`', '`song`.`artist`', 100);
break;
default:
// Rien a faire
@@ -1058,8 +1083,8 @@ class Query {
break;
case 'artist':
$sql = "`artist`.`name`";
- self::set_join('left','`song`','`song`.`album`','`album`.`id`');
- self::set_join('left','`artist`','`song`.`artist`','`artist`.`id`');
+ $this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100);
+ $this->set_join('left', '`artist`', '`song`.`artist`', '`artist`.`id`', 100);
break;
case 'year':
$sql = "`album`.`year`";
@@ -1155,23 +1180,23 @@ class Query {
* sort method and then re-sorts them This is internally
* called by the set_sort() function
*/
- private static function resort_objects() {
+ private function resort_objects() {
// There are two ways to do this.. the easy way...
// and the vollmer way, hopefully we don't have to
// do it the vollmer way
- if (self::is_simple()) {
- $sql = self::get_sql();
+ if ($this->is_simple()) {
+ $sql = $this->get_sql(true);
}
else {
// First pull the objects
- $objects = self::get_saved();
+ $objects = $this->get_saved();
// If there's nothing there don't do anything
if (!count($objects) or !is_array($objects)) {
return false;
}
- $type = self::$type;
+ $type = $this->get_type();
$where_sql = "WHERE `$type`.`id` IN (";
foreach ($objects as $object_id) {
@@ -1182,18 +1207,18 @@ class Query {
$where_sql .= ")";
- $sql = self::get_base_sql();
+ $sql = $this->get_base_sql();
$order_sql = " ORDER BY ";
- foreach (self::$_state['sort'][self::$type] as $key=>$value) {
- $order_sql .= self::sql_sort($key,$value);
+ foreach ($this->_state['sort'] as $key => $value) {
+ $order_sql .= $this->sql_sort($key, $value);
}
// Clean her up
$order_sql = rtrim($order_sql,"ORDER BY ");
$order_sql = rtrim($order_sql,",");
- $sql = $sql . self::get_join_sql() . $where_sql . $order_sql;
+ $sql = $sql . $this->get_join_sql() . $where_sql . $order_sql;
} // if not simple
$db_results = Dba::read($sql);
@@ -1202,34 +1227,48 @@ class Query {
$results[] = $row['id'];
}
- self::save_objects($results);
+ $this->save_objects($results);
return true;
} // resort_objects
/**
+ * store
+ * This saves the current state to the database
+ */
+ public function store() {
+ $sid = Dba::escape(session_id());
+ $id = Dba::escape($this->id);
+ $data = Dba::escape(serialize($this->_state));
+
+ $sql = "UPDATE `tmp_browse` SET `data`='$data' " .
+ "WHERE `sid`='$sid' AND `id`='$id'";
+ $db_results = Dba::write($sql);
+ }
+
+ /**
* save_objects
- * This takes the full array of object ides, often passed into show and then
- * if nessecary it saves them into the session
+ * This takes the full array of object ids, often passed into show and
+ * if necessary it saves them
*/
- public static function save_objects($object_ids) {
+ public function save_objects($object_ids) {
- // Saving these objects has two operations, one hold it in
- // a local variable and then second hold it in a row in the tmp_browse
- // table
- self::$_cache['browse'][self::$type] = $object_ids;
+ // Saving these objects has two operations, one holds it in
+ // a local variable and then second holds it in a row in the
+ // tmp_browse table
// Only do this if it's a not a simple browse
- if (!self::is_simple()) {
+ if (!$this->is_simple()) {
+ $this->_cache = $object_ids;
+ $this->set_total(count($object_ids));
$sid = Dba::escape(session_id());
- $data = Dba::escape(serialize($object_ids));
- $type = Dba::escape(self::$type);
+ $id = Dba::escape($this->id);
+ $data = Dba::escape(serialize($this->_cache));
- $sql = "REPLACE INTO `tmp_browse` SET `data`='$data', `sid`='$sid',`type`='$type'";
+ $sql = "UPDATE `tmp_browse` SET `object_data`='$data' " .
+ "WHERE `sid`='$sid' AND `id`='$id'";
$db_results = Dba::write($sql);
-
- self::$total_objects = count($object_ids);
} // save it
return true;
@@ -1237,24 +1276,12 @@ class Query {
} // save_objects
/**
- * _auto_init
- * this function reloads information back from the session
- * it is called on creation of the class
- */
- public static function _auto_init() {
-
- self::$offset = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
- self::$_state = &$_SESSION['browse'];
-
- } // _auto_init
-
- /**
* get_state
* This is a debug only function
*/
- public static function get_state() {
+ public function get_state() {
- return self::$_state;
+ return $this->_state;
} // get_state
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index 80192049..e86c20ef 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -344,6 +344,9 @@ class Update {
$update_string = '- Add uniqueness constraint to ratings.<br />';
$version[] = array('version' => '360004','description' => $update_string);
+ $update_string = '- Modify tmp_browse to allow caching of multiple browses per session.<br />';
+ $version[] = array('version' => '360005','description' => $update_string);
+
return $version;
} // populate_version
@@ -1929,5 +1932,25 @@ class Update {
self::set_version('db_version','360004');
} // update_360004
+ /**
+ * update_360005
+ * This changes the tmp_browse table around.
+ */
+ public static function update_360005() {
+ $sql = "DROP TABLE `tmp_browse`";
+ $db_results = Dba::write($sql);
+
+ $sql = "CREATE TABLE `tmp_browse` (" .
+ "`id` int(13) NOT NULL auto_increment," .
+ "`sid` varchar(128) character set utf8 NOT NULL default ''," .
+ "`data` longtext collate utf8_unicode_ci NOT NULL," .
+ "`object_data` longtext collate utf8_unicode_ci," .
+ "PRIMARY KEY (`sid`,`id`)" .
+ ") ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
+ $db_results = Dba::write($sql);
+
+ self::set_version('db_version','360005');
+ } // update_360005
+
} // end update class
?>
diff --git a/localplay.php b/localplay.php
index 5c325dfd..9bc22c3a 100644
--- a/localplay.php
+++ b/localplay.php
@@ -82,9 +82,11 @@ switch ($_REQUEST['action']) {
// Pull the current playlist and require the template
$objects = $localplay->get();
require_once Config::get('prefix') . '/templates/show_localplay_status.inc.php';
- Browse::set_type('playlist_localplay');
- Browse::set_static_content(1);
- Browse::show_objects($objects);
+ $browse = new Browse();
+ $browse->set_type('playlist_localplay');
+ $browse->set_static_content(true);
+ $browse->show_objects($objects);
+ $browse->store();
break;
} // end switch action
diff --git a/search.php b/search.php
index 4aedf327..419e6740 100644
--- a/search.php
+++ b/search.php
@@ -41,12 +41,13 @@ switch ($_REQUEST['action']) {
break;
}
case 'search':
+ $browse = new Browse();
require_once Config::get('prefix') . '/templates/show_search.inc.php';
require_once Config::get('prefix') . '/templates/show_search_options.inc.php';
$results = run_search($_REQUEST);
- Browse::set_type('song');
- Browse::reset();
- Browse::show_objects($results);
+ $browse->set_type('song');
+ $browse->show_objects($results);
+ $browse->store();
break;
case 'save_as_track':
$playlist_id = save_search($_REQUEST);
diff --git a/server/ajax.server.php b/server/ajax.server.php
index d2fce49c..ecba7026 100644
--- a/server/ajax.server.php
+++ b/server/ajax.server.php
@@ -268,8 +268,8 @@ switch ($_REQUEST['action']) {
} // end foreach
break;
case 'browse_set':
- Browse::set_type($_REQUEST['object_type']);
- $objects = Browse::get_saved();
+ $browse = new Browse($_REQUEST['browse_id']);
+ $objects = $browse->get_saved();
foreach ($objects as $object_id) {
$GLOBALS['user']->playlist->add_object($object_id,'song');
}
@@ -341,25 +341,6 @@ switch ($_REQUEST['action']) {
$results[$key] = ob_get_contents();
ob_end_clean();
break;
- // Used to change filter/settings on browse
- case 'browse':
- if ($_REQUEST['key'] && $_REQUEST['value']) {
- // Set any new filters we've just added
- Browse::set_filter($_REQUEST['key'],$_REQUEST['value']);
- }
- if ($_REQUEST['sort']) {
- // Set the new sort value
- Browse::set_sort($_REQUEST['sort']);
- }
-
- // Refresh the browse div with our new filter options
- $object_ids = Browse::get_objects();
-
- ob_start();
- Browse::show_objects($object_ids, true);
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
- break;
default:
$results['rfc3514'] = '0x1';
break;
diff --git a/server/browse.ajax.php b/server/browse.ajax.php
index 39966303..f512329c 100644
--- a/server/browse.ajax.php
+++ b/server/browse.ajax.php
@@ -25,44 +25,48 @@
*/
if (AJAX_INCLUDE != '1') { exit; }
+if (isset($_REQUEST['browse_id'])) {
+ $browse_id = $_REQUEST['browse_id'];
+}
+else {
+ $browse_id = null;
+}
+
+$browse = new Browse($browse_id);
+
switch ($_REQUEST['action']) {
case 'browse':
-
$object_ids = array();
- Browse::set_type($_REQUEST['type']);
-
// Check 'value' with isset because it can null
//(user type a "start with" word and deletes it)
if ($_REQUEST['key'] && (isset($_REQUEST['multi_alpha_filter']) OR isset($_REQUEST['value']))) {
// Set any new filters we've just added
- Browse::set_filter($_REQUEST['key'],$_REQUEST['multi_alpha_filter']);
+ $browse->set_filter($_REQUEST['key'],$_REQUEST['multi_alpha_filter']);
}
if ($_REQUEST['sort']) {
// Set the new sort value
- Browse::set_sort($_REQUEST['sort']);
+ $browse->set_sort($_REQUEST['sort']);
}
ob_start();
- Browse::show_objects(false);
+ $browse->show_objects();
$results['browse_content'] = ob_get_clean();
break;
case 'set_sort':
- Browse::set_type($_REQUEST['type']);
-
if ($_REQUEST['sort']) {
- Browse::set_sort($_REQUEST['sort']);
+ $browse->set_sort($_REQUEST['sort']);
}
ob_start();
- Browse::show_objects(false);
+ $browse->show_objects();
$results['browse_content'] = ob_get_clean();
break;
case 'toggle_tag':
$type = $_SESSION['tagcloud_type'] ? $_SESSION['tagcloud_type'] : 'song';
- Browse::set_type($type);
+ $browse->set_type($type);
@@ -94,19 +98,30 @@ switch ($_REQUEST['action']) {
break;
case 'page':
- Browse::set_type($_REQUEST['type']);
- Browse::set_start($_REQUEST['start']);
+ $browse->set_start($_REQUEST['start']);
ob_start();
- Browse::show_objects();
+ $browse->show_objects();
$results['browse_content'] = ob_get_clean();
+ break;
+ case 'show_art':
+ Art::set_enabled();
+ ob_start();
+ $browse->show_objects();
+ $results['browse_content'] = ob_get_clean();
break;
+ case 'get_filters':
+ ob_start();
+ require_once Config::get('prefix') . '/templates/browse_filters.inc.php';
+ $results['browse_filters'] = ob_get_clean();
default:
$results['rfc3514'] = '0x1';
break;
} // switch on action;
+$browse->store();
+
// We always do this
echo xml_from_array($results);
?>
diff --git a/server/democratic.ajax.php b/server/democratic.ajax.php
index 241d1211..1e257d5a 100644
--- a/server/democratic.ajax.php
+++ b/server/democratic.ajax.php
@@ -25,63 +25,30 @@
*/
if (AJAX_INCLUDE != '1') { exit; }
+$democratic = Democratic::get_current_playlist();
+$democratic->set_parent();
+
switch ($_REQUEST['action']) {
case 'delete_vote':
- $democratic = Democratic::get_current_playlist();
- $democratic->set_parent();
$democratic->remove_vote($_REQUEST['row_id']);
-
- ob_start();
- $object_ids = $democratic->get_items();
- Browse::set_type('democratic');
- Browse::reset();
- Browse::set_static_content(1);
- Browse::show_objects($object_ids);
-
- require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php';
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
-
+ $show_browse = true;
break;
case 'add_vote':
-
- $democratic = Democratic::get_current_playlist();
- $democratic->set_parent();
$democratic->add_vote($_REQUEST['object_id'],$_REQUEST['type']);
-
- ob_start();
- $object_ids = $democratic->get_items();
- Browse::set_type('democratic');
- Browse::reset();
- Browse::set_static_content(1);
- Browse::show_objects($object_ids);
-
- require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php';
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
-
+ $show_browse = true;
break;
case 'delete':
if (!$GLOBALS['user']->has_access('75')) {
+ echo xml_from_array(array('rfc3514' => '0x1'));
exit;
}
- $democratic = Democratic::get_current_playlist();
- $democratic->set_parent();
$democratic->delete_votes($_REQUEST['row_id']);
-
- ob_start();
- $object_ids = $democratic->get_items();
- Browse::set_type('democratic');
- Browse::reset();
- Browse::set_static_content(1);
- Browse::show_objects($object_ids);
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
-
+ $show_browse = true;
break;
case 'send_playlist':
if (!Access::check('interface','75')) {
+ echo xml_from_array(array('rfc3514' => '0x1'));
exit;
}
@@ -89,8 +56,8 @@ switch ($_REQUEST['action']) {
$results['rfc3514'] = '<script type="text/javascript">reload_util("'.$_SESSION['iframe']['target'].'")</script>';
break;
case 'clear_playlist':
-
if (!Access::check('interface','100')) {
+ echo xml_from_array(array('rfc3514' => '0x1'));
exit;
}
@@ -98,21 +65,25 @@ switch ($_REQUEST['action']) {
$democratic->set_parent();
$democratic->clear();
- ob_start();
- $object_ids = array();
- Browse::set_type('democratic');
- Browse::reset();
- Browse::set_static_content(1);
- Browse::show_objects($object_ids);
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
-
+ $show_browse = true;
break;
default:
$results['rfc3514'] = '0x1';
break;
} // switch on action;
+if ($show_browse) {
+ ob_start();
+ $object_ids = $democratic->get_items();
+ $browse = new Browse();
+ $browse->set_type('democratic');
+ $browse->set_static_content(true);
+ $browse->show_objects($object_ids);
+ $browse->store();
+ $results['browse_content'] = ob_get_contents();
+ ob_end_clean();
+}
+
// We always do this
echo xml_from_array($results);
?>
diff --git a/server/flag.ajax.php b/server/flag.ajax.php
index 7ba8b3d3..4daccb5c 100644
--- a/server/flag.ajax.php
+++ b/server/flag.ajax.php
@@ -38,10 +38,12 @@ switch ($_REQUEST['action']) {
$flagged = Flag::get_all();
ob_start();
- Browse::set_type('flagged');
- Browse::set_static_content(1);
- Browse::save_objects($flagged);
- Browse::show_objects($flagged);
+ $browse = new Browse();
+ $browse->set_type('flagged');
+ $browse->set_static_content(true);
+ $browse->save_objects($flagged);
+ $browse->show_objects($flagged);
+ $browse->store();
$results['browse_content'] = ob_get_contents();
ob_end_clean();
diff --git a/server/localplay.ajax.php b/server/localplay.ajax.php
index d505b956..8f289d72 100644
--- a/server/localplay.ajax.php
+++ b/server/localplay.ajax.php
@@ -79,9 +79,13 @@ switch ($_REQUEST['action']) {
break;
case 'delete_all':
$localplay->delete_all();
- Browse::save_objects(array());
ob_start();
- Browse::show_objects();
+ $browse = new Browse();
+ $browse->set_type('playlist_localplay');
+ $browse->set_static_content(true);
+ $browse->save_objects(array());
+ $browse->show_objects(array());
+ $browse->store();
$results['browse_content'] = ob_get_contents();
ob_end_clean();
break;
@@ -89,9 +93,12 @@ switch ($_REQUEST['action']) {
$localplay->skip(intval($_REQUEST['id']));
$objects = $localplay->get();
ob_start();
- Browse::set_type('playlist_localplay');
- Browse::set_static_content(1);
- Browse::show_objects($objects);
+ $browse = new Browse();
+ $browse->set_type('playlist_localplay');
+ $browse->set_static_content(true);
+ $browse->save_objects($objects);
+ $browse->show_objects($objects);
+ $browse->store();
$results['browse_content'] = ob_get_contents();
ob_end_clean();
break;
@@ -121,9 +128,12 @@ switch ($_REQUEST['action']) {
$status = $localplay->status();
ob_start();
- Browse::set_type('playlist_localplay');
- Browse::set_static_content(1);
- Browse::show_objects($objects);
+ $browse = new Browse();
+ $browse->set_type('playlist_localplay');
+ $browse->set_static_content(true);
+ $browse->save_objects($objects);
+ $browse->show_objects($objects);
+ $browse->store();
$results['browse_content'] = ob_get_contents();
ob_end_clean();
diff --git a/server/playlist.ajax.php b/server/playlist.ajax.php
index 4c517746..289e7f46 100644
--- a/server/playlist.ajax.php
+++ b/server/playlist.ajax.php
@@ -36,10 +36,12 @@ switch ($_REQUEST['action']) {
$object_ids = $playlist->get_items();
ob_start();
- Browse::set_type('playlist_song');
- Browse::add_supplemental_object('playlist',$playlist->id);
- Browse::save_objects($object_ids);
- Browse::show_objects($object_ids);
+ $browse = new Browse();
+ $browse->set_type('playlist_song');
+ $browse->add_supplemental_object('playlist',$playlist->id);
+ $browse->save_objects($object_ids);
+ $browse->show_objects($object_ids);
+ $browse->store();
$results['browse_content'] = ob_get_clean();
break;
case 'edit_track':
diff --git a/server/random.ajax.php b/server/random.ajax.php
index f7d69b3c..0bf340d5 100644
--- a/server/random.ajax.php
+++ b/server/random.ajax.php
@@ -75,10 +75,11 @@ switch ($_REQUEST['action']) {
$results['rightbar'] = ajax_include('rightbar.inc.php');
// Now setup the browse and show them below!
- Browse::set_type('song');
- Browse::save_objects($object_ids);
+ $browse = new Browse();
+ $browse->set_type('song');
+ $browse->save_objects($object_ids);
ob_start();
- Browse::show_objects();
+ $browse->show_objects();
$results['browse'] = ob_get_contents();
ob_end_clean();
diff --git a/server/tag.ajax.php b/server/tag.ajax.php
index a1c43988..7fd3febd 100644
--- a/server/tag.ajax.php
+++ b/server/tag.ajax.php
@@ -37,20 +37,19 @@ switch ($_REQUEST['action']) {
$tag->remove_map($_GET['type'],$_GET['object_id']);
break;
case 'browse_type':
- Browse::set_type('tag');
- Browse::set_filter('object_type',$_GET['type']);
+ $browse = new Browse($_GET['browse_id']);
+ $browse->set_filter('object_type', $_GET['type']);
+ $browse->store();
break;
case 'add_filter':
-
- // Set browse method
- Browse::set_type('song');
- Browse::set_filter('tag',$_GET['tag_id']);
- $object_ids = Browse::get_objects();
+ $browse = new Browse($_GET['browse_id']);
+ $browse->set_filter('tag', $_GET['tag_id']);
+ $object_ids = $browse->get_objects();
ob_start();
- Browse::show_objects($object_ids);
+ $browse->show_objects($object_ids);
$results['browse_content'] = ob_get_clean();
-
- // Retrive current objects of type based on combined filters
+ $browse->store();
+ // Retrieve current objects of type based on combined filters
break;
default:
$results['rfc3514'] = '0x1';
diff --git a/templates/browse_filters.inc.php b/templates/browse_filters.inc.php
new file mode 100644
index 00000000..c8c65a14
--- /dev/null
+++ b/templates/browse_filters.inc.php
@@ -0,0 +1,70 @@
+<?php
+/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
+/*
+
+ Copyright (c) Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+$ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path');
+?>
+<?php $allowed_filters = Browse::get_allowed_filters($browse->get_type()); ?>
+<li><h4><?php echo _('Filters'); ?></h4>
+<div class="sb3">
+<?php if (in_array('starts_with',$allowed_filters)) { ?>
+ <form id="multi_alpha_filter_form" method="post" action="javascript:void(0);">
+ <label id="multi_alpha_filterLabel" for="multi_alpha_filter"><?php echo _('Starts With'); ?></label>
+ <input type="text" id="multi_alpha_filter" name="multi_alpha_filter" value="<?php echo scrub_out($browse->get_filter('starts_with')); ?>" onKeyUp="DelayRun(this, '400', 'ajaxState', '<?php echo $ajax_info; ?>?page=browse&action=browse&browse_id=<?php echo $browse->id; ?>&key=starts_with', 'multi_alpha_filter');">
+</form>
+<?php } // end if alpha_match ?>
+<?php if (in_array('minimum_count',$allowed_filters)) { ?>
+ <input id="mincountCB" type="checkbox" value="1" />
+ <label id="mincountLabel" for="mincountCB"><?php echo _('Minimum Count'); ?></label><br />
+ <?php echo Ajax::observe('mincountCB', 'click', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=min_count&value=1', '')); ?>
+<?php } ?>
+<?php if (in_array('rated',$allowed_filters)) { ?>
+ <input id="ratedCB" type="checkbox" value="1" />
+ <label id="ratedLabel" for="ratedCB"><?php echo _('Rated'); ?></label><br />
+ <?php echo Ajax::observe('ratedCB', 'click', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=rated&value=1', '')); ?>
+<?php } ?>
+<?php if (in_array('unplayed',$allowed_filters)) { ?>
+ <input id="unplayedCB" type="checkbox" <?php echo $string = $browse->get_filter('unplayed') ? 'checked="checked"' : ''; ?>/>
+ <label id="unplayedLabel" for="unplayedCB"><?php echo _('Unplayed'); ?></label><br />
+<?php } ?>
+<?php if (in_array('show_art',$allowed_filters)) { ?>
+ <input id="show_artCB" type="checkbox" <?php echo $string = $browse->get_filter('show_art') ? 'checked="checked"' : ''; ?>/>
+ <label id="show_artLabel" for="show_artCB"><?php echo _('Show Art'); ?></label><br />
+ <?php echo Ajax::observe('show_artCB','click',Ajax::action('?page=browse&action=show_art&browse_id=' . $browse->id, '')); ?>
+<?php } // if show_art ?>
+<?php if (in_array('playlist_type',$allowed_filters)) { ?>
+ <input id="show_allplCB" type="checkbox" <?php echo $string = $browse->get_filter('playlist_type') ? 'checked="checked"' : ''; ?>/>
+ <label id="show_allplLabel" for="showallplCB"><?php echo _('All Playlists'); ?></label><br />
+ <?php echo Ajax::observe('show_allplCB','click',Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=playlist_type&value=1','')); ?>
+<?php } // if playlist_type ?>
+<?php if (in_array('object_type',$allowed_filters)) { ?>
+ <?php $string = 'otype_' . $browse->get_filter('object_type'); ${$string} = 'selected="selected"'; ?>
+ <input id="typeSongRadio" type="radio" name="object_type" value="1" <?php echo $otype_song; ?>/>
+ <label id="typeSongLabel" for="typeSongRadio"><?php echo _('Song Title'); ?></label><br />
+ <?php echo Ajax::observe('typeSongRadio','click',Ajax::action('?page=tag&action=browse_type&browse_id=' . $browse->id . '&type=song','')); ?>
+ <input id="typeAlbumRadio" type="radio" name="object_type" value="1" />
+ <label id="typeAlbumLabel" for="typeAlbumRadio"><?php echo _('Albums'); ?></label><br />
+ <?php echo Ajax::observe('typeAlbumRadio','click',Ajax::action('?page=tag&action=browse_type&browse_id=' . $browse->id . '&type=album','')); ?>
+ <input id="typeArtistRadio" type="radio" name="object_type" value="1" />
+ <label id="typeArtistLabel" for="typeArtistRadio"><?php echo _('Artist'); ?></label><br />
+ <?php echo Ajax::observe('typeArtistRadio','click',Ajax::action('?page=tag&action=browse_type&browse_id=' . $browse->id . '&type=artist','')); ?>
+<?php } ?>
+</div>
+</li>
diff --git a/templates/list_header.inc.php b/templates/list_header.inc.php
index f9ddb842..b4e36dcd 100644
--- a/templates/list_header.inc.php
+++ b/templates/list_header.inc.php
@@ -28,9 +28,9 @@
*/
// Pull these variables out to allow shorthand (easier for lazy programmers)
-$limit = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
-$start = Browse::get_start();
-$total = Browse::$total_objects;
+$limit = $browse->get_offset();
+$start = $browse->get_start();
+$total = $browse->get_total();
$uid = Config::get('list_header_uid');
$sides = 5;
@@ -91,15 +91,14 @@ while ($page <= $pages) {
// Sort These Arrays of Hotness
ksort($page_data['up']);
ksort($page_data['down']);
-$browse_type = Browse::get_type();
// are there enough items to even need this view?
if ($pages > 1) {
?>
<div class="list-header">
- <?php echo Ajax::text('?page=browse&action=page&type=' . $browse_type . '&start=' . $prev_offset,_('Prev'),'browse_' . $uid . 'prev','','prev'); ?>
- <?php echo Ajax::text('?page=browse&action=page&type=' . $browse_type . '&start=' . $next_offset,_('Next'),'browse_' . $uid . 'next','','next'); ?>
+ <?php echo Ajax::text('?page=browse&action=page&browse_id=' . $browse->id . '&start=' . $prev_offset,_('Prev'),'browse_' . $uid . 'prev','','prev'); ?>
+ <?php echo Ajax::text('?page=browse&action=page&browse_id=' . $browse->id . '&start=' . $next_offset,_('Next'),'browse_' . $uid . 'next','','next'); ?>
<?php
/* Echo Everything below us */
foreach ($page_data['down'] as $page => $offset) {
@@ -107,7 +106,7 @@ if ($pages > 1) {
else {
// Hack Alert
$page++;
- echo Ajax::text('?page=browse&action=page&type=' . $browse_type .'&start=' . $offset,$page,'browse_' . $uid . 'page_' . $page,'','page-nb');
+ echo Ajax::text('?page=browse&action=page&browse_id=' . $browse->id . '&start=' . $offset,$page,'browse_' . $uid . 'page_' . $page,'','page-nb');
}
} // end foreach down
@@ -121,7 +120,7 @@ if ($pages > 1) {
foreach ($page_data['up'] as $page=>$offset) {
if ($offset === '...') { echo '...&nbsp;'; }
else {
- echo Ajax::text('?page=browse&action=page&type=' . $browse_type . '&start=' . $offset,$page,'browse_' . $uid . 'page_' . $page,'','page-nb');
+ echo Ajax::text('?page=browse&action=page&browse_id=' . $browse->id . '&start=' . $offset,$page,'browse_' . $uid . 'page_' . $page,'','page-nb');
} // end else
} // end foreach up
?>
diff --git a/templates/show_album.inc.php b/templates/show_album.inc.php
index b3774bc9..928ffbb3 100644
--- a/templates/show_album.inc.php
+++ b/templates/show_album.inc.php
@@ -85,10 +85,12 @@ $title = scrub_out($album->name) . '&nbsp;(' . $album->year . ')' . $disk .'&nb
&nbsp;
</div>
<?php
- Browse::set_type('song');
- Browse::set_simple_browse(1);
- Browse::set_filter('album', $album->id);
- Browse::set_sort('track','ASC');
- Browse::get_objects();
- Browse::show_objects();
+ $browse = new Browse();
+ $browse->set_type('song');
+ $browse->set_simple_browse(true);
+ $browse->set_filter('album', $album->id);
+ $browse->set_sort('track', 'ASC');
+ $browse->get_objects();
+ $browse->show_objects();
+ $browse->store();
?>
diff --git a/templates/show_album_row.inc.php b/templates/show_album_row.inc.php
index a413b6ae..efbcba09 100644
--- a/templates/show_album_row.inc.php
+++ b/templates/show_album_row.inc.php
@@ -25,7 +25,7 @@
<?php echo Ajax::button('?action=basket&type=album_random&id=' . $album->id,'random',_('Random'),'random_album_' . $album->id); ?>
</td>
<?php
-if (Browse::is_enabled('show_art')) {
+if (Art::is_enabled()) {
$name = '[' . $album->f_artist . '] ' . scrub_out($album->full_name);
?>
<td class="cel_cover">
diff --git a/templates/show_albums.inc.php b/templates/show_albums.inc.php
index 2496c11e..a99e2793 100644
--- a/templates/show_albums.inc.php
+++ b/templates/show_albums.inc.php
@@ -26,7 +26,7 @@ $ajax_url = Config::get('ajax_url');
<table class="tabledata" cellpadding="0" cellspacing="0">
<colgroup>
<col id="col_add" />
-<?php if (Browse::is_enabled('show_art')) { ?>
+<?php if (Art::is_enabled()) { ?>
<col id="col_cover" />
<?php } ?>
<col id="col_album" />
@@ -39,13 +39,13 @@ $ajax_url = Config::get('ajax_url');
</colgroup>
<tr class="th-top">
<th class="cel_add"><?php echo _('Add'); ?></th>
- <?php if (Browse::is_enabled('show_art')) { ?>
+ <?php if (Art::is_enabled()) { ?>
<th class="cel_cover"><?php echo _('Cover'); ?></th>
<?php } ?>
- <th class="cel_album"><?php echo Ajax::text('?page=browse&action=set_sort&type=album&sort=name',_('Album'),'album_sort_name'); ?></th>
- <th class="cel_artist"><?php echo Ajax::text('?page=browse&action=set_sort&type=album&sort=artist',_('Artist'),'album_sort_artist'); ?></th>
+ <th class="cel_album"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=name',_('Album'),'album_sort_name'); ?></th>
+ <th class="cel_artist"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=artist',_('Artist'),'album_sort_artist'); ?></th>
<th class="cel_songs"><?php echo _('Songs'); ?></th>
- <th class="cel_year"><?php echo Ajax::text('?page=browse&action=set_sort&type=album&sort=year',_('Year'),'album_sort_year'); ?></th>
+ <th class="cel_year"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=year',_('Year'),'album_sort_year'); ?></th>
<th class="cel_tags"><?php echo _('Tags'); ?></th>
<th class="col_rating"><?php echo _('Rating'); ?></th>
<th class="cel_action"><?php echo _('Actions'); ?></th>
@@ -70,13 +70,13 @@ $ajax_url = Config::get('ajax_url');
<?php } ?>
<tr class="th-bottom">
<th class="cel_add"><?php echo _('Add'); ?></th>
- <?php if (Browse::is_enabled('show_art')) { ?>
+ <?php if (Art::is_enabled()) { ?>
<th class="cel_cover"><?php echo _('Cover'); ?></th>
<?php } ?>
- <th class="cel_album"><?php echo Ajax::text('?page=browse&action=set_sort&type=album&sort=name',_('Album'),'album_sort_name_bottom'); ?></th>
+ <th class="cel_album"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=name',_('Album'),'album_sort_name_bottom'); ?></th>
<th class="cel_artist"><?php echo _('Artist'); ?></th>
<th class="cel_songs"><?php echo _('Songs'); ?></th>
- <th class="cel_year"><?php echo Ajax::text('?page=browse&action=set_sort&type=album&sort=year',_('Year'),'album_sort_year_bottom'); ?></th>
+ <th class="cel_year"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=year',_('Year'),'album_sort_year_bottom'); ?></th>
<th class="cel_tags"><?php echo _('Tags'); ?></th>
<th class="col_rating"><?php echo _('Rating'); ?></th>
<th class="cel_action"><?php echo _('Actions'); ?></th>
diff --git a/templates/show_artist.inc.php b/templates/show_artist.inc.php
index 5c5e51b6..408e6b5e 100644
--- a/templates/show_artist.inc.php
+++ b/templates/show_artist.inc.php
@@ -22,6 +22,8 @@
$web_path = Config::get('web_path');
?>
<?php
+$browse = new Browse();
+$browse->set_type($object_type);
show_box_top($artist->f_name, 'info-box');
if (Config::get('ratings')) {
?>
@@ -65,13 +67,12 @@ if (Config::get('ratings')) {
</li>
<?php } ?>
<li>
- <input type="checkbox" id="show_artist_artCB" <?php echo $string = Browse::get_filter('show_art') ? 'checked="checked"' : ''; ?>/> <?php echo _('Show Art'); ?>
- <?php echo Ajax::observe('show_artist_artCB','click',Ajax::action('?page=browse&action=browse&key=show_art&value=1&type=album','')); ?>
+ <input type="checkbox" id="show_artist_artCB" <?php echo $string = Art::is_enabled() ? 'checked="checked"' : ''; ?>/> <?php echo _('Show Art'); ?>
+ <?php echo Ajax::observe('show_artist_artCB', 'click', Ajax::action('?page=browse&action=show_art&browse_id=' . $browse->id,'')); ?>
</ul>
</div>
<?php show_box_bottom(); ?>
<?php
- Browse::set_type($object_type);
- Browse::reset();
- Browse::show_objects($object_ids);
+ $browse->show_objects($object_ids);
+ $browse->store();
?>
diff --git a/templates/show_index.inc.php b/templates/show_index.inc.php
index dce60143..703e5c54 100644
--- a/templates/show_index.inc.php
+++ b/templates/show_index.inc.php
@@ -25,7 +25,7 @@
</div> <!-- Close Now Playing Div -->
<!-- Randomly selected albums of the moment -->
<?php
-if (Browse::is_enabled('show_art')) {
+if (Art::is_enabled()) {
echo Ajax::observe('window','load',Ajax::action('?page=index&action=random_albums','random_albums'));
?>
<div id="random_selection">
diff --git a/templates/show_manage_catalogs.inc.php b/templates/show_manage_catalogs.inc.php
index 8ea5f460..86d32f32 100644
--- a/templates/show_manage_catalogs.inc.php
+++ b/templates/show_manage_catalogs.inc.php
@@ -48,9 +48,12 @@
</div>
<?php show_box_bottom(); ?>
<?php
- $catalog_ids = Catalog::get_catalogs();
- Browse::set_type('catalog');
- Browse::set_static_content(1);
- Browse::show_objects($catalog_ids);
+ $catalog_ids = Catalog::get_catalogs();
+ $browse = new Browse();
+ $browse->set_type('catalog');
+ $browse->set_static_content(true);
+ $browse->save_objects($catalog_ids);
+ $browse->show_objects($catalog_ids);
+ $browse->store();
?>
diff --git a/templates/show_now_playing_row.inc.php b/templates/show_now_playing_row.inc.php
index ca4bc14a..a5f291e8 100644
--- a/templates/show_now_playing_row.inc.php
+++ b/templates/show_now_playing_row.inc.php
@@ -73,7 +73,7 @@ $artist = scrub_out(truncate_with_ellipsis($media->f_artist_full));
</div>
</div>
-<?php if (Browse::is_enabled('show_art')) { ?>
+<?php if (Art::is_enabled()) { ?>
<div class="np_group">
<div class="np_cell cel_albumart">
<a target="_blank" href="<?php echo $web_path; ?>/image.php?id=<?php echo $media->album; ?>&amp;type=popup" onclick="popup_art('<?php echo $web_path; ?>/image.php?id=<?php echo $media->album; ?>&amp;type=popup'); return false;">
diff --git a/templates/show_playlist.inc.php b/templates/show_playlist.inc.php
index a38fdee1..ddc227ea 100644
--- a/templates/show_playlist.inc.php
+++ b/templates/show_playlist.inc.php
@@ -68,8 +68,10 @@ show_box_top('<div id="playlist_row_' . $playlist->id . '">' . $title .
</div>
<?php show_box_bottom(); ?>
<?php
- Browse::set_type('playlist_song');
- Browse::add_supplemental_object('playlist',$playlist->id);
- Browse::set_static_content(1);
- Browse::show_objects($object_ids);
+ $browse = new Browse();
+ $browse->set_type('playlist_song');
+ $browse->add_supplemental_object('playlist', $playlist->id);
+ $browse->set_static_content(true);
+ $browse->show_objects($object_ids);
+ $browse->store();
?>
diff --git a/templates/show_random.inc.php b/templates/show_random.inc.php
index e1a73b21..2e573566 100644
--- a/templates/show_random.inc.php
+++ b/templates/show_random.inc.php
@@ -101,10 +101,11 @@
<div id="browse">
<?php
if (is_array($object_ids)) {
- Browse::reset_filters();
- Browse::set_type('song');
- Browse::save_objects($object_ids);
- Browse::show_objects();
+ $browse = new Browse();
+ $browse->set_type('song');
+ $browse->save_objects($object_ids);
+ $browse->show_objects();
+ $browse->store();
echo Ajax::observe('window','load',Ajax::action('?action=refresh_rightbar','playlist_refresh_load'));
}
?>
diff --git a/templates/show_random_albums.inc.php b/templates/show_random_albums.inc.php
index 0b1f0dc8..2b91dae2 100644
--- a/templates/show_random_albums.inc.php
+++ b/templates/show_random_albums.inc.php
@@ -33,7 +33,7 @@ $button = Ajax::button('?page=index&action=random_albums','random',_('Refresh'),
?>
<div class="random_album">
<a href="<?php echo $web_path; ?>/albums.php?action=show&amp;album=<?php echo $album_id; ?>">
- <?php if (Browse::is_enabled('show_art')) { ?>
+ <?php if (Art::is_enabled()) { ?>
<img src="<?php echo $web_path; ?>/image.php?thumb=3&amp;id=<?php echo $album_id; ?>" width="80" height="80" alt="<?php echo $name; ?>" title="<?php echo $name; ?>" />
<?php } else { ?>
<?php echo '[' . $album->f_artist . '] ' . $album->f_name; ?>
diff --git a/templates/show_search_options.inc.php b/templates/show_search_options.inc.php
index 7a8ce87f..fb1b8155 100644
--- a/templates/show_search_options.inc.php
+++ b/templates/show_search_options.inc.php
@@ -25,12 +25,12 @@
<div id="information_actions">
<ul>
<li>
- <?php echo Ajax::button('?action=basket&type=browse_set&object_type=song','add',_('Add Search Results'),'add_search_results'); ?>
+ <?php echo Ajax::button('?action=basket&type=browse_set&browse_id=' . $browse->id,'add',_('Add Search Results'),'add_search_results'); ?>
<?php echo _('Add Search Results'); ?>
</li>
<?php if (Access::check_function('batch_download')) { ?>
<li>
- <a href="<?php echo Config::get('web_path'); ?>/batch.php?action=browse"><?php echo get_user_icon('batch_download', _('Batch Download')); ?></a>
+ <a href="<?php echo Config::get('web_path'); ?>/batch.php?action=browse&browse_id=<?php echo $browse->id; ?>"><?php echo get_user_icon('batch_download', _('Batch Download')); ?></a>
<?php echo _('Batch Download'); ?>
</li>
<?php } ?>
diff --git a/templates/show_songs.inc.php b/templates/show_songs.inc.php
index 0a40b8ad..7eec665b 100644
--- a/templates/show_songs.inc.php
+++ b/templates/show_songs.inc.php
@@ -38,12 +38,12 @@ $ajax_url = Config::get('ajax_url');
</colgroup>
<tr class="th-top">
<th class="cel_add"><?php echo _('Add'); ?></th>
- <th class="cel_song"><?php echo Ajax::text('?page=browse&action=set_sort&type=song&sort=title',_('Song Title'),'sort_song_title'); ?></th>
- <th class="cel_artist"><?php echo Ajax::text('?page=browse&action=set_sort&type=song&sort=artist',_('Artist'),'sort_song_artist'); ?></th>
- <th class="cel_album"><?php echo Ajax::text('?page=browse&action=set_sort&type=song&sort=album',_('Album'),'sort_song_album'); ?></th>
+ <th class="cel_song"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=title', _('Song Title'), 'sort_song_title'); ?></th>
+ <th class="cel_artist"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=artist', _('Artist'), 'sort_song_artist'); ?></th>
+ <th class="cel_album"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=album', _('Album'), 'sort_song_album'); ?></th>
<th class="cel_tags"><?php echo _('Tags'); ?></th>
- <th class="cel_track"><?php echo Ajax::text('?page=browse&action=set_sort&type=song&sort=track',_('Track'),'sort_song_track'); ?></th>
- <th class="cel_time"><?php echo Ajax::text('?page=browse&action=set_sort&type=song&sort=time',_('Time'),'sort_song_time'); ?></th>
+ <th class="cel_track"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=track', _('Track'), 'sort_song_track'); ?></th>
+ <th class="cel_time"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=time', _('Time'), 'sort_song_time'); ?></th>
<?php if (Config::get('ratings')) {
Rating::build_cache('song', $object_ids);
?>
diff --git a/templates/sidebar_home.inc.php b/templates/sidebar_home.inc.php
index 41e74256..3593fb50 100644
--- a/templates/sidebar_home.inc.php
+++ b/templates/sidebar_home.inc.php
@@ -24,7 +24,6 @@ $ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path');
<ul class="sb2" id="sb_home">
<li><h4><?php echo _('Browse'); ?></h4>
<?php
- $allowed_filters = Browse::get_allowed_filters();
// Build the selected dealie
$text = scrub_in($_REQUEST['action']) . '_ac';
${$text} = ' selected="selected"';
@@ -39,52 +38,8 @@ $ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path');
<li id="sb_browse_bb_Video"><a href="<?php echo $web_path; ?>/browse.php?action=video"><?php echo _('Videos'); ?></a></li>
</ul>
</li>
-<?php if (count($allowed_filters)) { ?>
- <li><h4><?php echo _('Filters'); ?></h4>
- <div class="sb3">
- <?php if (in_array('starts_with',$allowed_filters)) { ?>
- <form id="multi_alpha_filter_form" method="post" action="javascript:void(0);">
- <label id="multi_alpha_filterLabel" for="multi_alpha_filter"><?php echo _('Starts With'); ?></label>
- <input type="text" id="multi_alpha_filter" name="multi_alpha_filter" value="<?php echo scrub_out(Browse::get_filter('starts_with')); ?>" onKeyUp="DelayRun(this,'400','ajaxState','<?php echo Config::get('ajax_url'); ?>?page=browse&action=browse&type=<?php echo Browse::get_type(); ?>&key=starts_with','multi_alpha_filter');">
- </form>
- <?php } // end if alpha_match ?>
- <?php if (in_array('minimum_count',$allowed_filters)) { ?>
- <input id="mincountCB" type="checkbox" onclick="ajaxPut('<?php echo $ajax_info; ?>?action=browse&amp;key=min_count&amp;type=<?php echo Browse::get_type(); ?>&amp;value=1');return true;" value="1" />
- <label id="mincountLabel" for="mincountCB"><?php echo _('Minimum Count'); ?></label><br />
- <?php } ?>
- <?php if (in_array('rated',$allowed_filters)) { ?>
- <input id="ratedCB" type="checkbox" onclick="ajaxPut('<?php echo $ajax_info; ?>?action=browse&amp;type=<?php echo Browse::get_type(); ?>&amp;key=rated&amp;value=1');return true;" value="1" />
- <label id="ratedLabel" for="ratedCB"><?php echo _('Rated'); ?></label><br />
- <?php } ?>
- <?php if (in_array('unplayed',$allowed_filters)) { ?>
- <input id="unplayedCB" type="checkbox" <?php echo $string = Browse::get_filter('unplayed') ? 'checked="checked"' : ''; ?>/>
- <label id="unplayedLabel" for="unplayedCB"><?php echo _('Unplayed'); ?></label><br />
- <?php } ?>
- <?php if (in_array('show_art',$allowed_filters)) { ?>
- <input id="show_artCB" type="checkbox" <?php echo $string = Browse::get_filter('show_art') ? 'checked="checked"' : ''; ?>/>
- <label id="show_artLabel" for="show_artCB"><?php echo _('Show Art'); ?></label><br />
- <?php echo Ajax::observe('show_artCB','click',Ajax::action('?page=browse&action=browse&type=' . Browse::get_type() . '&key=show_art&value=1','')); ?>
- <?php } // if show_art ?>
- <?php if (in_array('playlist_type',$allowed_filters)) { ?>
- <input id="show_allplCB" type="checkbox" <?php echo $string = Browse::get_filter('playlist_type') ? 'checked="checked"' : ''; ?>/>
- <label id="show_allplLabel" for="showallplCB"><?php echo _('All Playlists'); ?></label><br />
- <?php echo Ajax::observe('show_allplCB','click',Ajax::action('?page=browse&action=browse&type=' . Browse::get_type() . '&key=playlist_type&value=1','')); ?>
- <?php } // if playlist_type ?>
- <?php if (in_array('object_type',$allowed_filters)) { ?>
- <?php $string = 'otype_' . Browse::get_filter('object_type'); ${$string} = 'selected="selected"'; ?>
- <input id="typeSongRadio" type="radio" name="object_type" value="1" <?php echo $otype_song; ?>/>
- <label id="typeSongLabel" for="typeSongRadio"><?php echo _('Song Title'); ?></label><br />
- <?php echo Ajax::observe('typeSongRadio','click',Ajax::action('?page=tag&action=browse_type&type=song','')); ?>
- <input id="typeAlbumRadio" type="radio" name="object_type" value="1" />
- <label id="typeAlbumLabel" for="typeAlbumRadio"><?php echo _('Albums'); ?></label><br />
- <?php echo Ajax::observe('typeAlbumRadio','click',Ajax::action('?page=tag&action=browse_type&type=album','')); ?>
- <input id="typeArtistRadio" type="radio" name="object_type" value="1" />
- <label id="typeArtistLabel" for="typeArtistRadio"><?php echo _('Artist'); ?></label><br />
- <?php echo Ajax::observe('typeArtistRadio','click',Ajax::action('?page=tag&action=browse_type&type=artist','')); ?>
- <?php } ?>
- </div>
- </li>
-<?php } ?>
+<?php Ajax::start_container('browse_filters'); ?>
+<?php Ajax::end_container(); ?>
<li><h4><?php echo _('Playlist'); ?></h4>
<ul class="sb3" id="sb_home_info">
<li id="sb_home_info_CurrentlyPlaying"><a href="<?php echo $web_path; ?>/index.php"><?php echo _('Currently Playing'); ?></a></li>