1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 17:59:21 +02:00

Add links on tags to show related item types with the same tag (fix #27)

This commit is contained in:
Afterster 2014-06-15 09:16:32 +02:00
parent 50b95d18da
commit f55a0969a5
12 changed files with 57 additions and 12 deletions

View file

@ -78,7 +78,8 @@ switch ($_REQUEST['action']) {
Tag::build_cache($keys); Tag::build_cache($keys);
UI::show_box_top(T_('Tag Cloud'), 'box box_tag_cloud'); UI::show_box_top(T_('Tag Cloud'), 'box box_tag_cloud');
$browse2 = new Browse(); $browse2 = new Browse();
$browse2->set_type('song'); $browse_type = isset($_GET['type']) ? $_GET['type'] : 'song';
$browse2->set_type($browse_type);
$browse2->store(); $browse2->store();
require_once AmpConfig::get('prefix') . '/templates/show_tagcloud.inc.php'; require_once AmpConfig::get('prefix') . '/templates/show_tagcloud.inc.php';
UI::show_box_bottom(); UI::show_box_bottom();

View file

@ -447,7 +447,7 @@ class Album extends database_object
} }
$this->tags = Tag::get_top_tags('album', $this->id); $this->tags = Tag::get_top_tags('album', $this->id);
$this->f_tags = Tag::get_display($this->tags); $this->f_tags = Tag::get_display($this->tags, true, 'album');
} // format } // format

View file

@ -333,7 +333,7 @@ class Artist extends database_object
$this->f_time = ltrim($hours . ':' . $min . ':' . $sec,'0:'); $this->f_time = ltrim($hours . ':' . $min . ':' . $sec,'0:');
$this->tags = Tag::get_top_tags('artist', $this->id); $this->tags = Tag::get_top_tags('artist', $this->id);
$this->f_tags = Tag::get_display($this->tags); $this->f_tags = Tag::get_display($this->tags, true, 'artist');
$this->object_cnt = $extra_info['object_cnt']; $this->object_cnt = $extra_info['object_cnt'];

View file

@ -112,7 +112,7 @@ class Broadcast extends database_object
$this->f_name = $this->name; $this->f_name = $this->name;
$this->f_link = '<a href="' . AmpConfig::get('web_path') . '/broadcast.php?id=' . $this->id . '">' . scrub_out($this->f_name) . '</a>'; $this->f_link = '<a href="' . AmpConfig::get('web_path') . '/broadcast.php?id=' . $this->id . '">' . scrub_out($this->f_name) . '</a>';
$this->tags = Tag::get_top_tags('broadcast', $this->id); $this->tags = Tag::get_top_tags('broadcast', $this->id);
$this->f_tags = Tag::get_display($this->tags); $this->f_tags = Tag::get_display($this->tags, true, 'broadcast');
} }
public static function get_broadcast_list_sql() public static function get_broadcast_list_sql()

View file

@ -181,7 +181,7 @@ class Channel extends database_object
public function format() public function format()
{ {
$this->tags = Tag::get_top_tags('channel', $this->id); $this->tags = Tag::get_top_tags('channel', $this->id);
$this->f_tags = Tag::get_display($this->tags); $this->f_tags = Tag::get_display($this->tags, true, 'channel');
} }
public function get_target_object() public function get_target_object()

View file

@ -1131,7 +1131,7 @@ class Query
switch ($filter) { switch ($filter) {
case 'tag': case 'tag':
$this->set_join('left', '`tag_map`', '`tag_map`.`object_id`', '`song`.`id`', 100); $this->set_join('left', '`tag_map`', '`tag_map`.`object_id`', '`song`.`id`', 100);
$filter_sql = " `tag_map`.`object_type`='song' AND ("; $filter_sql = " `tag_map`.`object_type`='" . $this->get_type() . "' AND (";
foreach ($value as $tag_id) { foreach ($value as $tag_id) {
$filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND"; $filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND";
@ -1193,6 +1193,15 @@ class Query
break; break;
case 'album': case 'album':
switch ($filter) { switch ($filter) {
case 'tag':
$this->set_join('left', '`tag_map`', '`tag_map`.`object_id`', '`album`.`id`', 100);
$filter_sql = " `tag_map`.`object_type`='" . $this->get_type() . "' AND (";
foreach ($value as $tag_id) {
$filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND";
}
$filter_sql = rtrim($filter_sql,'AND') . ') AND ';
break;
case 'exact_match': case 'exact_match':
$filter_sql = " `album`.`name` = '" . Dba::escape($value) . "' AND "; $filter_sql = " `album`.`name` = '" . Dba::escape($value) . "' AND ";
break; break;
@ -1250,6 +1259,15 @@ class Query
break; break;
case 'artist': case 'artist':
switch ($filter) { switch ($filter) {
case 'tag':
$this->set_join('left', '`tag_map`', '`tag_map`.`object_id`', '`artist`.`id`', 100);
$filter_sql = " `tag_map`.`object_type`='" . $this->get_type() . "' AND (";
foreach ($value as $tag_id) {
$filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND";
}
$filter_sql = rtrim($filter_sql,'AND') . ') AND ';
break;
case 'catalog': case 'catalog':
if ($value != 0) { if ($value != 0) {
$this->set_join('left','`song`','`artist`.`id`','`song`.`artist`', 100); $this->set_join('left','`song`','`artist`.`id`','`song`.`artist`', 100);
@ -1392,6 +1410,15 @@ class Query
break; break;
case 'video': case 'video':
switch ($filter) { switch ($filter) {
case 'tag':
$this->set_join('left', '`tag_map`', '`tag_map`.`object_id`', '`video`.`id`', 100);
$filter_sql = " `tag_map`.`object_type`='" . $this->get_type() . "' AND (";
foreach ($value as $tag_id) {
$filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND";
}
$filter_sql = rtrim($filter_sql,'AND') . ') AND ';
break;
case 'alpha_match': case 'alpha_match':
$filter_sql = " `video`.`title` LIKE '%" . Dba::escape($value) . "%' AND "; $filter_sql = " `video`.`title` LIKE '%" . Dba::escape($value) . "%' AND ";
break; break;

View file

@ -889,7 +889,7 @@ class Song extends database_object implements media
// Get the top tags // Get the top tags
$this->tags = Tag::get_top_tags('song', $this->id); $this->tags = Tag::get_top_tags('song', $this->id);
$this->f_tags = Tag::get_display($this->tags); $this->f_tags = Tag::get_display($this->tags, true, 'song');
// Format the size // Format the size
$this->f_size = UI::format_bytes($this->size); $this->f_size = UI::format_bytes($this->size);

View file

@ -478,7 +478,7 @@ class Tag extends database_object
* it also takes a type so that it knows how to return it, this is used * it also takes a type so that it knows how to return it, this is used
* by the formating functions of the different objects * by the formating functions of the different objects
*/ */
public static function get_display($tags) public static function get_display($tags, $link=false, $filter_type='')
{ {
//debug_event('tag.class.php', 'Get display tags called...', '5'); //debug_event('tag.class.php', 'Get display tags called...', '5');
if (!is_array($tags)) { return ''; } if (!is_array($tags)) { return ''; }
@ -491,7 +491,14 @@ class Tag extends database_object
foreach ($value as $vid=>$v) { foreach ($value as $vid=>$v) {
debug_event('tag.class.php', $vid.' = {'.$v.'}', '5'); debug_event('tag.class.php', $vid.' = {'.$v.'}', '5');
}*/ }*/
$results .= $value['name'] . ', '; if ($link) {
$results .= '<a href="' . AmpConfig::get('web_path') . '/browse.php?action=tag&show_tag=' . $value['id'] . (!empty($filter_type) ? '&type=' . $filter_type : '') . '" title="' . $value['name'] . '">';
}
$results .= $value['name'];
if ($link) {
$results .= '</a>';
}
$results .= ', ';
} }
$results = rtrim($results, ', '); $results = rtrim($results, ', ');

View file

@ -54,7 +54,7 @@ if (Art::is_enabled()) {
<td class="cel_artist"><?php echo $album->f_artist_link; ?></td> <td class="cel_artist"><?php echo $album->f_artist_link; ?></td>
<td class="cel_songs"><?php echo $album->song_count; ?></td> <td class="cel_songs"><?php echo $album->song_count; ?></td>
<td class="cel_year"><?php echo $album->year; ?></td> <td class="cel_year"><?php echo $album->year; ?></td>
<td class="cel_tags" title="<?php echo $album->f_tags; ?>"><?php echo $album->f_tags; ?></td> <td class="cel_tags"><?php echo $album->f_tags; ?></td>
<?php if (AmpConfig::get('ratings')) { ?> <?php if (AmpConfig::get('ratings')) { ?>
<td class="cel_rating" id="rating_<?php echo $album->id; ?>_album"><?php Rating::show($album->id, 'album'); ?></td> <td class="cel_rating" id="rating_<?php echo $album->id; ?>_album"><?php Rating::show($album->id, 'album'); ?></td>
<?php } ?> <?php } ?>

View file

@ -44,7 +44,7 @@
<td class="cel_songs"><?php echo $artist->songs; ?></td> <td class="cel_songs"><?php echo $artist->songs; ?></td>
<td class="cel_albums"><?php echo $artist->albums; ?></td> <td class="cel_albums"><?php echo $artist->albums; ?></td>
<td class="cel_time"><?php echo $artist->f_time; ?></td> <td class="cel_time"><?php echo $artist->f_time; ?></td>
<td class="cel_tags" title="<?php echo $artist->f_tags; ?>"><?php echo $artist->f_tags; ?></td> <td class="cel_tags"><?php echo $artist->f_tags; ?></td>
<?php if (AmpConfig::get('ratings')) { ?> <?php if (AmpConfig::get('ratings')) { ?>
<td class="cel_rating" id="rating_<?php echo $artist->id; ?>_artist"><?php Rating::show($artist->id,'artist'); ?></td> <td class="cel_rating" id="rating_<?php echo $artist->id; ?>_artist"><?php Rating::show($artist->id,'artist'); ?></td>
<?php } ?> <?php } ?>

View file

@ -46,7 +46,7 @@
</td> </td>
<td class="cel_artist"><?php echo $song->f_artist_link; ?></td> <td class="cel_artist"><?php echo $song->f_artist_link; ?></td>
<td class="cel_album"><?php echo $song->f_album_link; ?></td> <td class="cel_album"><?php echo $song->f_album_link; ?></td>
<td class="cel_tags" title="<?php echo $song->f_tags; ?>"><?php echo $song->f_tags; ?></td> <td class="cel_tags"><?php echo $song->f_tags; ?></td>
<td class="cel_time"><?php echo $song->f_time; ?></td> <td class="cel_time"><?php echo $song->f_time; ?></td>
<?php if (AmpConfig::get('ratings')) { ?> <?php if (AmpConfig::get('ratings')) { ?>
<td class="cel_rating" id="rating_<?php echo $song->id; ?>_song"><?php Rating::show($song->id,'song'); ?></td> <td class="cel_rating" id="rating_<?php echo $song->id; ?>_song"><?php Rating::show($song->id,'song'); ?></td>

View file

@ -44,6 +44,16 @@
<?php } ?> <?php } ?>
</div> </div>
<?php } ?> <?php } ?>
<?php
if (isset($_GET['show_tag'])) {
$show_tag = intval($_GET['show_tag']);
?>
<script>
$(document).ready(function () {
<?php echo Ajax::action('?page=tag&action=add_filter&browse_id=' . $browse2->id . '&tag_id=' . $show_tag, ''); ?>
});
</script>
<?php } ?>
<?php if (!count($object_ids)) { ?> <?php if (!count($object_ids)) { ?>
<span class="fatalerror"><?php echo T_('Not Enough Data'); ?></span> <span class="fatalerror"><?php echo T_('Not Enough Data'); ?></span>
<?php } ?> <?php } ?>