1<?php 2/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ 3/** 4 * 5 * LICENSE: GNU Affero General Public License, version 3 (AGPL-3.0-or-later) 6 * Copyright 2001 - 2020 Ampache.org 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Affero General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Affero General Public License for more details. 17 * 18 * You should have received a copy of the GNU Affero General Public License 19 * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 * 21 */ 22 23use Ampache\Config\AmpConfig; 24use Ampache\Repository\Model\Album; 25use Ampache\Repository\Model\Art; 26use Ampache\Repository\Model\Rating; 27use Ampache\Repository\Model\User; 28use Ampache\Repository\Model\Userflag; 29use Ampache\Module\Authorization\Access; 30use Ampache\Module\Api\Ajax; 31use Ampache\Module\Util\Ui; 32 33/** @var Ampache\Repository\Model\Browse $browse */ 34/** @var array $object_ids */ 35/** @var string $limit_threshold */ 36 37$web_path = AmpConfig::get('web_path'); 38$thcount = 9; 39$show_ratings = User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags')); 40$hide_genres = AmpConfig::get('hide_genres'); 41$is_table = $browse->is_grid_view(); 42$group_release = AmpConfig::get('album_release_type'); 43$original_year = AmpConfig::get('use_original_year'); 44$year_sort = ($original_year) ? "&sort=original_year" : "&sort=year"; 45// translate once 46$album_text = T_('Album'); 47$artist_text = T_('Album Artist'); 48$songs_text = T_('Songs'); 49$year_text = T_('Year'); 50$count_text = T_('# Played'); 51$genres_text = T_('Genres'); 52$rating_text = T_('Rating'); 53$action_text = T_('Actions'); 54// mashup and grid view need different css 55$cel_cover = ($is_table) ? "cel_cover" : 'grid_cover'; 56$cel_album = ($is_table) ? "cel_album" : 'grid_album'; 57$cel_artist = ($is_table) ? "cel_artist" : 'grid_artist'; 58$cel_tags = ($is_table) ? "cel_tags" : 'grid_tags'; 59$cel_counter = ($is_table) ? "cel_counter" : 'grid_counter'; 60// TODO: enable album sort links again when you can work out how to fix it 61$album_link = ($group_release) ? $album_text : Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=name', $album_text, 'album_sort_name'); 62$artist_link = ($group_release) ? $artist_text : Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=album_artist', $artist_text, 'album_sort_artist'); 63$songs_link = ($group_release) ? $songs_text : Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=song_count', $songs_text, 'album_sort_song_count'); 64$year_link = ($group_release) ? $year_text : Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . $year_sort, $year_text, 'album_sort_year'); 65$count_link = ($group_release) ? $count_text : Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=total_count', $count_text, 'album_sort_total_count'); 66?> 67<?php if ($browse->is_show_header()) { 68 require Ui::find_template('list_header.inc.php'); 69} ?> 70<table class="tabledata striped-rows <?php echo $browse->get_css_class() ?>" data-objecttype="album"> 71 <thead> 72 <tr class="th-top"> 73 <div class="libitem_menu"> 74 <th class="cel_play essential"></th> 75 <th class="<?php echo $cel_cover; ?> optional"><?php echo T_('Art'); ?></th> 76</div> 77 <th class="<?php echo $cel_album; ?> essential persist"><?php echo $album_link; ?></th> 78 <th class="cel_add essential"></th> 79 <th class="<?php echo $cel_artist; ?> essential"><?php echo $artist_link; ?></th> 80 <th class="cel_songs optional"><?php echo $songs_link; ?></th> 81 <th class="cel_year essential"><?php echo $year_link; ?></th> 82 <?php if (AmpConfig::get('show_played_times')) { ?> 83 <th class="<?php echo $cel_counter; ?> optional"><?php echo $count_link; ?></th> 84 <?php } ?> 85 <?php if (!$hide_genres) { 86 ++$thcount; ?> 87 <th class="<?php echo $cel_tags; ?> optional"><?php echo $genres_text; ?></th> 88 <?php 89} ?> 90 <?php if ($show_ratings) { 91 ++$thcount; ?> 92 <th class="cel_ratings optional"><?php echo $rating_text; ?></th> 93 <?php 94 } ?> 95 <th class="cel_action essential"><?php echo $action_text; ?></th> 96 </tr> 97 </thead> 98 <tbody> 99 <?php if (AmpConfig::get('ratings')) { 100 Rating::build_cache('album', $object_ids); 101 } 102 if (AmpConfig::get('userflags')) { 103 Userflag::build_cache('album', $object_ids); 104 } 105 106 $show_direct_play_cfg = AmpConfig::get('directplay'); 107 $directplay_limit = AmpConfig::get('direct_play_limit'); 108 109 /* Foreach through the albums */ 110 foreach ($object_ids as $album_id) { 111 $libitem = new Album($album_id); 112 $libitem->format(true, $limit_threshold); 113 $show_direct_play = $show_direct_play_cfg; 114 $show_playlist_add = Access::check('interface', 25); 115 if ($directplay_limit > 0) { 116 $show_playlist_add = ($libitem->song_count <= $directplay_limit); 117 if ($show_direct_play) { 118 $show_direct_play = $show_playlist_add; 119 } 120 } ?> 121 <tr id="album_<?php echo $libitem->id ?>" class="libitem_menu"> 122 <?php require Ui::find_template('show_album_row.inc.php'); ?> 123 </tr> 124 <?php 125 }?> 126 <?php if (!count($object_ids)) { ?> 127 <tr> 128 <td colspan="<?php echo $thcount; ?>"><span class="nodata"><?php echo T_('No Album found'); ?></span></td> 129 </tr> 130 <?php } ?> 131 </tbody> 132 <tfoot> 133 <tr class="th-bottom"> 134 <th class="cel_play"></th> 135 <th class="<?php echo $cel_cover; ?>"><?php echo T_('Art'); ?></th> 136 <th class="<?php echo $cel_album; ?>"><?php echo $album_text; ?></th> 137 <th class="cel_add"></th> 138 <th class="<?php echo $cel_artist; ?>"><?php echo $artist_text; ?></th> 139 <th class="cel_songs"><?php echo $songs_text; ?></th> 140 <th class="cel_year"><?php echo $year_text; ?></th> 141 <?php if (AmpConfig::get('show_played_times')) { ?> 142 <th class="<?php echo $cel_counter; ?> optional"><?php echo $count_text; ?></th> 143 <?php } ?> 144 <?php if (!$hide_genres) { ?> 145 <th class="<?php echo $cel_tags; ?>"><?php echo $genres_text; ?></th> 146 <?php } ?> 147 <?php if ($show_ratings) { ?> 148 <th class="cel_ratings optional"><?php echo $rating_text; ?></th> 149 <?php } ?> 150 <th class="cel_action"><?php echo $action_text; ?></th> 151 </tr> 152 <tfoot> 153</table> 154 155<?php show_table_render(); ?> 156<?php if ($browse->is_show_header()) { 157 require Ui::find_template('list_header.inc.php'); 158 } ?> 159