diff options
author | Chris Slamar <chris@slamar.org> | 2011-01-24 19:25:01 -0600 |
---|---|---|
committer | Chris Slamar <chris@slamar.org> | 2011-01-24 19:25:01 -0600 |
commit | 4910d13fa4623246db810347def57106dd85c9a9 (patch) | |
tree | 7b57a3c13f70572cde82bd343967dff33b331ae2 | |
parent | fc355baf6764ffb87b74002b3a4419a63dab34b1 (diff) | |
download | ampache-4910d13fa4623246db810347def57106dd85c9a9.tar.gz ampache-4910d13fa4623246db810347def57106dd85c9a9.tar.bz2 ampache-4910d13fa4623246db810347def57106dd85c9a9.zip |
Catalog Filtering Added Bug#60
-rw-r--r-- | artists.php | 2 | ||||
-rw-r--r-- | browse.php | 5 | ||||
-rw-r--r-- | config/ampache.cfg.php.dist | 5 | ||||
-rw-r--r-- | index.php | 3 | ||||
-rw-r--r-- | lib/class/ajax.class.php | 2 | ||||
-rw-r--r-- | lib/class/art.class.php | 65 | ||||
-rw-r--r-- | lib/class/artist.class.php | 47 | ||||
-rw-r--r-- | lib/class/browse.class.php | 2 | ||||
-rw-r--r-- | lib/class/catalog.class.php | 2 | ||||
-rw-r--r-- | lib/class/query.class.php | 71 | ||||
-rw-r--r-- | server/browse.ajax.php | 15 | ||||
-rw-r--r-- | server/democratic.ajax.php | 5 | ||||
-rw-r--r-- | templates/browse_filters.inc.php | 29 | ||||
-rw-r--r-- | templates/show_artists.inc.php | 3 | ||||
-rw-r--r-- | templates/show_now_playing.inc.php | 3 |
15 files changed, 185 insertions, 74 deletions
diff --git a/artists.php b/artists.php index d8fb1d91..c811e855 100644 --- a/artists.php +++ b/artists.php @@ -31,7 +31,7 @@ switch($_REQUEST['action']) { case 'show': $artist = new Artist($_REQUEST['artist']); $artist->format(); - $object_ids = $artist->get_albums(); + $object_ids = $artist->get_albums($_REQUEST['catalog']); $object_type = 'album'; require_once Config::get('prefix') . '/templates/show_artist.inc.php'; if (Config::get('lastfm_api_key')) { @@ -32,6 +32,8 @@ /* Base Require */ require_once 'lib/init.php'; +session_start(); + // 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... @@ -56,6 +58,7 @@ switch($_REQUEST['action']) { case 'file': break; case 'album': + $browse->set_filter('catalog',$_SESSION['catalog']); $browse->set_sort('name','ASC'); $browse->show_objects(); break; @@ -73,10 +76,12 @@ switch($_REQUEST['action']) { require_once Config::get('prefix') . '/templates/browse_content.inc.php'; break; case 'artist': + $browse->set_filter('catalog',$_SESSION['catalog']); $browse->set_sort('name','ASC'); $browse->show_objects(); break; case 'song': + $browse->set_filter('catalog',$_SESSION['catalog']); $browse->set_sort('title','ASC'); $browse->show_objects(); break; diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist index d862fc19..fce5218f 100644 --- a/config/ampache.cfg.php.dist +++ b/config/ampache.cfg.php.dist @@ -617,8 +617,3 @@ use_rss = true ; SMTP Password ; your mail auth password. ;mail_auth_pass = "" - -; Twitter -twitter = true -twitter_consumer_key = "tCCFlruiduHyUuC2vNQEyQ" -twitter_consumer_secret = "omRMNdRNktRIqxJVm2uTDyN5iDTUF6Q8eBoinTNgI" @@ -26,6 +26,9 @@ show_header(); $action = isset($_REQUEST['action']) ? scrub_in($_REQUEST['action']) : null; +session_start(); +$_SESSION['catalog'] = 0; + /** * Check for the refresh mojo, if it's there then require the * refresh_javascript include. Must be greater then 5, I'm not diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php index 1b69e17a..a1059e2e 100644 --- a/lib/class/ajax.class.php +++ b/lib/class/ajax.class.php @@ -93,7 +93,7 @@ class Ajax { else { $ajax_string = "ajaxPut('$url',$source_txt)"; } - + return $ajax_string; } // action diff --git a/lib/class/art.class.php b/lib/class/art.class.php index b2829198..d7066a11 100644 --- a/lib/class/art.class.php +++ b/lib/class/art.class.php @@ -534,18 +534,43 @@ class Art extends database_object { $db_results = Dba::write($sql); } // clean + public function checkOrderDB($method, $gatherAll) { + + if( !($gatherAll) ) { + return true; + } + + $config = Config::get('art_order'); + $config = array($config); + $art_order = array(); + + + for( $i = 0; $i < sizeof($config[0]); $i++) { + $art_order[$config[0][$i]] = $i; + } + + $sql = 'SELECT object_id FROM image WHERE object_id = ' . $this->uid; + debug_event('Art', $sql, 6); + $db_results = Dba::read($sql); + + if( $art_order['db'] < $art_order[$method] && (Dba::num_rows($db_results) != 0) ) { + return false; + } else { + return true; + } + } /** * gather * This tries to get the art in question */ - public function gather($options = array(), $limit = false) { + public function gather($options = array(), $limit = false, $gatherAll = false) { // Define vars $results = array(); switch ($this->type) { case 'album': - $allowed_methods = array('db','lastfm','folder','amazon','google','musicbrainz','tags'); + $allowed_methods = array('lastfm','folder','amazon','google','musicbrainz','tag'); break; case 'artist': $allowed_methods = array(); @@ -561,38 +586,38 @@ class Art extends database_object { /* If it's not set */ if (empty($config)) { // They don't want art! - debug_event('Art', 'art_order is empty, skipping art gathering', 3); return array(); } elseif (!is_array($config)) { $config = array($config); } - debug_event('Art','Searching using:' . print_r($config, true), 3); + debug_event('Art','Searching using:' . print_r($config, true),3); foreach ($config as $method) { $data = array(); - if (!in_array($method, $allowed_methods)) { - debug_event('Art', "$method not in allowed_methods, skipping", 3); - continue; - } + debug_event('Art',"method used " .$method_name,3); $method_name = "gather_" . $method; - if (in_array($method_name, $methods)) { - debug_event('Art', "Method used: $method_name", 3); // Some of these take options! switch ($method_name) { case 'gather_amazon': - $data = $this->{$method_name}($limit, $options['keyword']); + if($this->checkOrderDB($method,$gatherAll)) { + $data = $this->{$method_name}($limit, $options['keyword']); + } break; case 'gather_lastfm': - $data = $this->{$method_name}($limit, $options); + if($this->checkOrderDB($method,$gatherAll)) { + $data = $this->{$method_name}($limit, $options); + } break; default: - $data = $this->{$method_name}($limit); + if($this->checkOrderDB($method,$gatherAll)) { + $data = $this->{$method_name}($limit); + } break; } @@ -604,9 +629,6 @@ class Art extends database_object { } } // if the method exists - else { - debug_event("Art", "$method_name not defined", 1); - } } // end foreach @@ -620,17 +642,6 @@ class Art extends database_object { /////////////////////////////////////////////////////////////////////// /** - * gather_db - * This function retrieves art that's already in the database - */ - public function gather_db($limit = null) { - if ($this->get_db()) { - return array('db' => true); - } - return array(); - } - - /** * gather_musicbrainz * This function retrieves art based on MusicBrainz' Advanced * Relationships diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index f7638b94..02a7c7b7 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -32,6 +32,7 @@ class Artist extends database_object { public $albums; public $prefix; public $mbid; // MusicBrainz ID + public $catalog_id; // Constructed vars public $_fake = false; // Set if construct_from_array() used @@ -41,11 +42,12 @@ class Artist extends database_object { * Artist class, for modifing a artist * Takes the ID of the artist and pulls the info from the db */ - public function __construct($id='') { + public function __construct($id='',$catalog_init=0) { /* If they failed to pass in an id, just run for it */ if (!$id) { return false; } + $this->catalog_id = $catalog_init; /* Get the information from the db */ $info = $this->get_info($id); @@ -93,8 +95,9 @@ class Artist extends database_object { // If we need to also pull the extra information, this is normally only used when we are doing the human display if ($extra) { - $sql = "SELECT `song`.`artist`, COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " . - "WHERE `song`.`artist` IN $idlist GROUP BY `song`.`artist`"; + $sql = "SELECT `song`.`artist`, COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` WHERE `song`.`artist` IN $idlist GROUP BY `song`.`artist`"; + + debug_event("Artist", "build_cache sql: " . $sql, "6"); $db_results = Dba::read($sql); while ($row = Dba::fetch_assoc($db_results)) { @@ -130,12 +133,19 @@ class Artist extends database_object { * gets the album ids that this artist is a part * of */ - public function get_albums() { + public function get_albums($catalog) { + + if($catalog) { + $catalog_join = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`"; + $catalog_where = "AND `catalog`.`id` = '$catalog'"; + } $results = array(); - $sql = "SELECT `album`.`id` FROM album LEFT JOIN `song` ON `song`.`album`=`album`.`id` " . - "WHERE `song`.`artist`='$this->id' GROUP BY `album`.`id` ORDER BY `album`.`name`,`album`.`disk`,`album`.`year`"; + $sql = "SELECT `album`.`id` FROM album LEFT JOIN `song` ON `song`.`album`=`album`.`id` $catalog_join " . + "WHERE `song`.`artist`='$this->id' $catalog_where GROUP BY `album`.`id` ORDER BY `album`.`name`,`album`.`disk`,`album`.`year`"; + + debug_event("Artist", "$sql", "6"); $db_results = Dba::read($sql); while ($r = Dba::fetch_assoc($db_results)) { @@ -186,16 +196,21 @@ class Artist extends database_object { * _get_extra info * This returns the extra information for the artist, this means totals etc */ - private function _get_extra_info() { + private function _get_extra_info($catalog=FALSE) { // Try to find it in the cache and save ourselves the trouble - if (parent::is_cached('artist_extra',$this->id)) { + if (parent::is_cached('artist_extra',$this->id) ) { $row = parent::get_from_cache('artist_extra',$this->id); } else { $uid = Dba::escape($this->id); - $sql = "SELECT `song`.`artist`,COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " . - "WHERE `song`.`artist`='$uid' GROUP BY `song`.`artist`"; + $sql = "SELECT `song`.`artist`,COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` WHERE `song`.`artist`='$uid' "; + if ($catalog) { + $sql .= "AND (`song`.`catalog` = '$catalog') "; + } + + $sql .= "GROUP BY `song`.`artist`"; + $db_results = Dba::read($sql); $row = Dba::fetch_assoc($db_results); parent::add_to_cache('artist_extra',$row['artist'],$row); @@ -227,11 +242,15 @@ class Artist extends database_object { // If this is a fake object, we're done here if ($this->_fake) { return true; } - $this->f_name_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&artist=" . $this->id . "\" title=\"" . $this->f_full_name . "\">" . $name . "</a>"; - $this->f_link = Config::get('web_path') . '/artists.php?action=show&artist=' . $this->id; - + if ($this->catalog_id) { + $this->f_name_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&catalog=" . $this->catalog_id . "&artist=" . $this->id . "\" title=\"" . $this->f_full_name . "\">" . $name . "</a>"; + $this->f_link = Config::get('web_path') . '/artists.php?action=show&catalog=' . $this->catalog_id . '&artist=' . $this->id; + } else { + $this->f_name_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&artist=" . $this->id . "\" title=\"" . $this->f_full_name . "\">" . $name . "</a>"; + $this->f_link = Config::get('web_path') . '/artists.php?action=show&artist=' . $this->id; + } // Get the counts - $extra_info = $this->_get_extra_info(); + $extra_info = $this->_get_extra_info($this->catalog_id); //Format the new time thingy that we just got $min = sprintf("%02d",(floor($extra_info['time']/60)%60)); diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index 5feaefde..8e6eba11 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -110,6 +110,8 @@ class Browse extends Query { } elseif ($filter_value = $this->get_filter('starts_with')) { $match = ' (' . $filter_value . ')'; + } elseif ($filter_value = $this->get_filter('catalog')) { + $match = '(' . $filter_value . ')'; } $type = $this->get_type(); diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index f823d01d..4c4e0768 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -680,7 +680,7 @@ class Catalog extends database_object { ); // Return results - $results = $art->gather($options, 1); + $results = $art->gather($options,1,true); if (count($results)) { // Pull the string representation from the source diff --git a/lib/class/query.class.php b/lib/class/query.class.php index 65ee0dc7..3a9476f9 100644 --- a/lib/class/query.class.php +++ b/lib/class/query.class.php @@ -25,9 +25,11 @@ * This handles all of the sql/filtering for the ampache database * this was seperated out from browse to accomodate Dynamic Playlists */ + class Query { public $id; + public $catalog; protected $_state = array(); protected $_cache; @@ -41,7 +43,7 @@ class Query { */ public function __construct($id = null) { $sid = Dba::escape(session_id()); - + if (is_null($id)) { $this->reset(); $data = Dba::escape(serialize($this->_state)); @@ -50,6 +52,7 @@ class Query { "VALUES('$sid', '$data')"; $db_results = Dba::write($sql); $this->id = Dba::insert_id(); + return true; } @@ -88,7 +91,8 @@ class Query { 'show_art', 'starts_with', 'exact_match', - 'alpha_match' + 'alpha_match', + 'catalog' ), 'artist' => array( 'add_lt', @@ -98,7 +102,8 @@ class Query { 'exact_match', 'alpha_match', 'starts_with', - 'tag' + 'tag', + 'catalog' ), 'song' => array( 'add_lt', @@ -108,7 +113,8 @@ class Query { 'exact_match', 'alpha_match', 'starts_with', - 'tag' + 'tag', + 'catalog' ), 'live_stream' => array( 'alpha_match', @@ -223,6 +229,7 @@ class Query { } break; case 'artist': + case 'catalog': case 'album': $this->_state['filter'][$key] = $value; break; @@ -509,6 +516,11 @@ class Query { } // set_offset + public function set_catalog( $catalog_number ) { + $this->catalog = $catalog_number; + debug_event("Catalog", "set catalog id: " . $this->catalog, "5"); + } + /** * set_select * This appends more information to the select part of the SQL @@ -684,7 +696,11 @@ class Query { $sql = "SELECT %%SELECT%% FROM `album` "; break; case 'artist': - $this->set_select("DISTINCT(`artist`.`id`)"); + $this->set_select("`artist`.`id`"); + $sql = "SELECT %%SELECT%% FROM `artist` "; + break; + case 'catalog': + $this->set_select("`artist`.`name`"); $sql = "SELECT %%SELECT%% FROM `artist` "; break; case 'user': @@ -761,11 +777,12 @@ class Query { if (!is_array($this->_state['filter'])) { return ''; } - + $sql = "WHERE 1=1 AND "; foreach ($this->_state['filter'] as $key => $value) { + $sql .= $this->sql_filter($key, $value); } @@ -862,9 +879,13 @@ class Query { $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; - + $final_sql = $sql . $join_sql . $filter_sql . $having_sql; + + if( $this->get_type() == 'artist' ) { + $final_sql .= " GROUP BY `" . $this->get_type() . "`.`name` "; + } + $final_sql .= $order_sql . $limit_sql; + debug_event("Catalog", "catalog sql: " . $final_sql, "6"); return $final_sql; } // get_sql @@ -912,6 +933,7 @@ class Query { $filter_sql = ''; switch ($this->get_type()) { + case 'song': switch($filter) { case 'tag': @@ -931,6 +953,9 @@ class Query { break; case 'starts_with': $filter_sql = " `song`.`title` LIKE '" . Dba::escape($value) . "%' AND "; + if( $this->catalog != 0 ) { + $filter_sql .= " `song`.`catalog` = '" . $this->catalog . "' AND "; + } break; case 'unplayed': $filter_sql = " `song`.`played`='0' AND "; @@ -954,9 +979,9 @@ class Query { $filter_sql = " `song`.`update_time` <= '" . Dba::escape($value) . "' AND "; break; case 'catalog': - $catalogs = $GLOBALS['user']->get_catalogs(); - if (!count($catalogs)) { break; } - $filter_sql .= " `song`.`catalog` IN (" . implode(',',$GLOBALS['user']->get_catalogs()) . ") AND "; + if($value != 0) { + $filter_sql = " `song`.`catalog` = '$value' AND "; + } break; default: // Rien a faire @@ -972,7 +997,11 @@ class Query { $filter_sql = " `album`.`name` LIKE '%" . Dba::escape($value) . "%' AND "; break; case 'starts_with': + $this->set_join('left', '`song`', '`album`.`id`', '`song`.`album`', 100); $filter_sql = " `album`.`name` LIKE '" . Dba::escape($value) . "%' AND "; + if( $this->catalog != 0 ) { + $filter_sql .= "`song`.`catalog` = '" . $this->catalog . "' AND "; + } break; case 'artist': $filter_sql = " `artist`.`id` = '". Dba::escape($value) . "' AND "; @@ -985,6 +1014,13 @@ class Query { $this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100); $filter_sql = " `song`.`addition_time` >= '" . Dba::escape($value) . "' AND "; break; + case 'catalog': + if($value != 0) { + $this->set_join('left','`song`','`album`.`id`','`song`.`album`', 100); + $this->set_join('left','`catalog`','`song`.`catalog`','`catalog`.`id`', 100); + $filter_sql = " (`song`.`catalog` = '$value') AND "; + } + break; case 'update_lt': $this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100); $filter_sql = " `song`.`update_time` <= '" . Dba::escape($value) . "' AND "; @@ -1000,6 +1036,13 @@ class Query { break; case 'artist': switch($filter) { + case 'catalog': + if($value != 0) { + $this->set_join('left','`song`','`artist`.`id`','`song`.`artist`', 100); + $this->set_join('left','`catalog`','`song`.`catalog`','`catalog`.`id`', 100); + $filter_sql = " (`catalog`.`id` = '$value') AND "; + } + break; case 'exact_match': $filter_sql = " `artist`.`name` = '" . Dba::escape($value) . "' AND "; break; @@ -1007,7 +1050,11 @@ class Query { $filter_sql = " `artist`.`name` LIKE '%" . Dba::escape($value) . "%' AND "; break; case 'starts_with': + $this->set_join('left', '`song`', '`artist`.`id`', '`song`.`artist`', 100); $filter_sql = " `artist`.`name` LIKE '" . Dba::escape($value) . "%' AND "; + if( $this->catalog != 0 ) { + $filter_sql .= "`song`.`catalog` = '" . $this->catalog . "' AND "; + } break; case 'add_lt': $this->set_join('left', '`song`', '`song`.`artist`', '`artist`.`id`', 100); diff --git a/server/browse.ajax.php b/server/browse.ajax.php index db8b002d..764e9955 100644 --- a/server/browse.ajax.php +++ b/server/browse.ajax.php @@ -23,6 +23,9 @@ /** * Sub-Ajax page, requires AJAX_INCLUDE */ +require_once("../lib/init.php"); +session_start(); + if (!defined('AJAX_INCLUDE')) { exit; } if (isset($_REQUEST['browse_id'])) { @@ -43,19 +46,25 @@ switch ($_REQUEST['action']) { 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_catalog($_SESSION['catalog']); } if ($_REQUEST['sort']) { // Set the new sort value $browse->set_sort($_REQUEST['sort']); } + if ($_REQUEST['catalog_key'] || $SESSION['catalog'] != 0) { + $browse->set_filter('catalog',$_REQUEST['catalog_key']); + $_SESSION['catalog'] = $_REQUEST['catalog_key']; + } ob_start(); $browse->show_objects(); $results['browse_content'] = ob_get_clean(); break; + case 'set_sort': - + if ($_REQUEST['sort']) { $browse->set_sort($_REQUEST['sort']); } @@ -67,10 +76,6 @@ switch ($_REQUEST['action']) { case 'toggle_tag': $type = $_SESSION['tagcloud_type'] ? $_SESSION['tagcloud_type'] : 'song'; $browse->set_type($type); - - - - break; case 'delete_object': switch ($_REQUEST['type']) { diff --git a/server/democratic.ajax.php b/server/democratic.ajax.php index 41c541f1..0d345119 100644 --- a/server/democratic.ajax.php +++ b/server/democratic.ajax.php @@ -34,10 +34,7 @@ switch ($_REQUEST['action']) { $show_browse = true; break; case 'add_vote': - // Only add the vote if they haven't already voted - if (!$democratic->has_vote($_GET['object_id'],$_GET['type'])) { - $democratic->add_vote($_REQUEST['object_id'],$_REQUEST['type']); - } + $democratic->add_vote($_REQUEST['object_id'],$_REQUEST['type']); $show_browse = true; break; case 'delete': diff --git a/templates/browse_filters.inc.php b/templates/browse_filters.inc.php index c902cd1b..1c3b8e15 100644 --- a/templates/browse_filters.inc.php +++ b/templates/browse_filters.inc.php @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +session_start(); $ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path'); ?> <?php $allowed_filters = Browse::get_allowed_filters($browse->get_type()); ?> @@ -27,7 +28,7 @@ $ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path'); <?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');"> + <input type="text" id="multi_alpha_filter" name="multi_alpha_filter" value="<?php $browse->set_catalog($_SESSION['catalog']); 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)) { ?> @@ -66,5 +67,31 @@ $ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path'); <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 } ?> + +<?php if(in_array('catalog',$allowed_filters)) { ?> +<form method="post" id="catalog_choice" action="javascript.void(0);"> + <label id="catalogLabel" for="catalog_select"><?php echo _('Catalog'); ?></label><br /> + <select id="catalog_select" name="catalog_key"> + <option value="0">All</option> + <?php + $sql = 'SELECT `id`,`name` FROM `catalog`'; + $db_results = Dba::read($sql); + while( $data = Dba::fetch_assoc($db_results) ) { + $results[] = $data; + } + + foreach( $results as $entries ) { + echo '<option value="' . $entries['id']; + if( $_SESSION['catalog'] == $entries['id'] ) { + echo ' selected="selected" '; + } + echo '">' . $entries['name'] . '</options>'; + } + ?> + + </select> +<?php echo Ajax::observe('catalog_select','click',Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id,'catalog_select','catalog_choice'),'1'); ?> +</form> +<?php } ?> </div> </li> diff --git a/templates/show_artists.inc.php b/templates/show_artists.inc.php index 85c079b8..9b197ba6 100644 --- a/templates/show_artists.inc.php +++ b/templates/show_artists.inc.php @@ -18,6 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +session_start(); $web_path = Config::get('web_path'); @@ -49,7 +50,7 @@ if (Config::get('ratings')) { Rating::build_cache('artist',$object_ids); } /* Foreach through every artist that has been passed to us */ foreach ($object_ids as $artist_id) { - $artist = new Artist($artist_id); + $artist = new Artist($artist_id, $_SESSION['catalog']); $artist->format(); ?> <tr id="artist_<?php echo $artist->id; ?>" class="<?php echo flip_class(); ?>"> diff --git a/templates/show_now_playing.inc.php b/templates/show_now_playing.inc.php index ef5d7d96..05b3f828 100644 --- a/templates/show_now_playing.inc.php +++ b/templates/show_now_playing.inc.php @@ -30,9 +30,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. if (count($results)) { $link = Config::get('use_rss') ? ' ' . AmpacheRSS::get_display('nowplaying') : ''; -$twitter = Config::get('twitter') ? ' ' . '<a href="' . Config::get('web_path') . '/modules/twitter/twitter_login.php"><img src="' . Config::get('web_path') . '/modules/twitter/Twitter-Icon.png" alt="Tweet Your Now Playing!" width="18" height="18"></a>' : ''; ?> -<?php show_box_top(_('Now Playing') . $link . $twitter ); ?> +<?php show_box_top(_('Now Playing') . $link); ?> <?php foreach ($results as $item) { $media = $item['media']; |