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\Art;
25use Ampache\Repository\Model\Podcast_Episode;
26use Ampache\Repository\Model\Rating;
27use Ampache\Repository\Model\User;
28use Ampache\Repository\Model\Userflag;
29use Ampache\Module\Api\Ajax;
30use Ampache\Module\Util\Ui;
31
32/** @var Ampache\Repository\Model\Browse $browse */
33/** @var array $object_ids */
34
35$thcount      = 6;
36$show_ratings = User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags'));
37$is_mashup    = $browse->is_mashup();
38$is_table     = $browse->is_grid_view();
39//mashup and grid view need different css
40$cel_cover   = ($is_table) ? "cel_cover" : 'grid_cover';
41$cel_time    = ($is_table) ? "cel_time" : 'grid_time';
42$cel_counter = ($is_table) ? "cel_counter" : 'grid_counter'; ?>
43<?php if ($browse->is_show_header()) {
44    require Ui::find_template('list_header.inc.php');
45} ?>
46<table class="tabledata striped-rows <?php echo $browse->get_css_class() ?>" data-objecttype="podcast_episode">
47    <thead>
48        <tr class="th-top">
49            <th class="cel_play essential"></th>
50            <th class="cel_title essential persist"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=title', T_('Title'), 'podcast_episode_sort_title'); ?></th>
51            <th class="cel_add essential"></th>
52            <?php if ($is_mashup) {
53    ++$thcount; ?>
54            <th class="cel_podcast"><?php echo T_('Podcast'); ?></th>
55                <?php
56} ?>
57            <th class="<?php echo $cel_time; ?> optional"><?php echo T_('Time'); ?></th>
58            <?php if (AmpConfig::get('show_played_times')) { ?>
59            <th class="<?php echo $cel_counter; ?> optional"><?php echo T_('# Played'); ?></th>
60            <?php } ?>
61            <th class="cel_pubdate optional"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=pubDate', T_('Publication Date'), 'podcast_episode_sort_pubdate'); ?></th>
62            <th class="cel_state optional"><?php echo T_('State'); ?></th>
63            <?php if ($show_ratings) {
64        ++$thcount; ?>
65            <th class="cel_ratings optional"><?php echo T_('Rating'); ?></th>
66            <?php
67    } ?>
68            <th class="cel_action essential"><?php echo T_('Actions'); ?></th>
69        </tr>
70    </thead>
71    <tbody>
72        <?php
73        if (AmpConfig::get('ratings')) {
74            Rating::build_cache('podcast_episode', $object_ids);
75        }
76        if (AmpConfig::get('userflags')) {
77            Userflag::build_cache('podcast_episode', $object_ids);
78        }
79
80        foreach ($object_ids as $episode_id) {
81            $libitem = new Podcast_Episode($episode_id);
82            $libitem->format(); ?>
83        <tr id="podcast_episode_<?php echo $libitem->id; ?>">
84            <?php require Ui::find_template('show_podcast_episode_row.inc.php'); ?>
85        </tr>
86        <?php
87        } ?>
88        <?php if (!count($object_ids)) { ?>
89        <tr>
90            <td colspan="<?php echo $thcount; ?>"><span class="nodata"><?php echo T_('No podcast episode found'); ?></span></td>
91        </tr>
92        <?php
93        } ?>
94    </tbody>
95    <tfoot>
96        <tr class="th-bottom">
97            <th class="cel_play"></th>
98            <th class="<?php echo $cel_cover; ?>"><?php echo T_('Art'); ?></th>
99            <th class="cel_title"><?php echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=title', T_('Title'), 'podcast_episode_sort_title_bottom'); ?></th>
100            <th class="cel_add"></th>
101            <?php if ($is_mashup) { ?>
102            <th class="cel_podcast"><?php echo T_('Podcast'); ?></th>
103            <?php } ?>
104            <th class="<?php echo $cel_time; ?>"><?php echo T_('Time'); ?></th>
105            <?php if (AmpConfig::get('show_played_times')) { ?>
106            <th class="<?php echo $cel_counter; ?> optional"><?php echo T_('# Played'); ?></th>
107            <?php } ?>
108            <th class="cel_pubdate"><?php echo T_('Publication Date'); ?></th>
109            <th class="cel_state"><?php echo T_('State'); ?></th>
110            <?php if ($show_ratings) { ?>
111            <th class="cel_ratings optional"><?php echo T_('Rating'); ?></th>
112            <?php
113            } ?>
114            <th class="cel_action"><?php echo T_('Actions'); ?></th>
115        </tr>
116    <tfoot>
117</table>
118<?php show_table_render(); ?>
119<?php if ($browse->is_show_header()) {
120                require Ui::find_template('list_header.inc.php');
121            } ?>
122