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\Repository\Model\Art;
24use Ampache\Module\Api\Ajax;
25use Ampache\Module\System\Core;
26use Ampache\Module\System\Dba;
27use Ampache\Repository\Model\Browse;
28
29/** @var Ampache\Repository\Model\Browse $browse */
30/** @var array $object_ids */
31
32if (!Core::is_session_started()) {
33    session_start();
34} ?>
35
36<?php $allowed_filters = Browse::get_allowed_filters($browse->get_type()); ?>
37<li>
38    <h4><?php echo T_('Filters'); ?></h4>
39    <div class="sb3">
40    <?php if (in_array('starts_with', $allowed_filters)) { ?>
41        <form id="multi_alpha_filter_form" action="javascript:void(0);">
42            <label id="multi_alpha_filterLabel" for="multi_alpha_filter"><?php echo T_('Starts With'); ?></label>
43            <input type="text" id="multi_alpha_filter" name="multi_alpha_filter" value="<?php $browse->set_catalog($_SESSION['catalog']);
44    echo scrub_out($browse->get_filter('starts_with')); ?>" onKeyUp="delayRun(this, '400', 'ajaxState', '<?php echo Ajax::url('?page=browse&action=browse&browse_id=' . $browse->id . '&key=starts_with'); ?>', 'multi_alpha_filter');">
45        </form>
46    <?php
47} // end if alpha_match?>
48    <?php if (in_array('minimum_count', $allowed_filters)) { ?>
49        <input id="mincountCB" type="checkbox" value="1" />
50        <label id="mincountLabel" for="mincountCB"><?php echo T_('Minimum Count'); ?></label><br />
51        <?php echo Ajax::observe('mincountCB', 'click', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=min_count&value=1', '')); ?>
52    <?php
53    } ?>
54    <?php if (in_array('rated', $allowed_filters)) { ?>
55        <input id="ratedCB" type="checkbox" value="1" />
56        <label id="ratedLabel" for="ratedCB"><?php echo T_('Rated'); ?></label><br />
57        <?php echo Ajax::observe('ratedCB', 'click', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=rated&value=1', '')); ?>
58    <?php
59    } ?>
60    <?php if (in_array('unplayed', $allowed_filters)) { ?>
61        <input id="unplayedCB" type="checkbox" <?php echo $string = $browse->get_filter('unplayed') ? 'checked="checked"' : ''; ?>/>
62        <label id="unplayedLabel" for="unplayedCB"><?php echo T_('Unplayed'); ?></label><br />
63    <?php
64    } ?>
65    <?php if (in_array('playlist_type', $allowed_filters)) { ?>
66        <input id="show_allplCB" type="checkbox" <?php echo $string = $browse->get_filter('playlist_type') ? 'checked="checked"' : ''; ?>/>
67        <label id="show_allplLabel" for="showallplCB"><?php echo T_('All Playlists'); ?></label><br />
68        <?php echo Ajax::observe('show_allplCB', 'click', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=playlist_type&value=1', '')); ?>
69    <?php
70    } // if playlist_type?>
71    <?php if (in_array('object_type', $allowed_filters)) { ?>
72        <?php $string = 'otype_' . $browse->get_filter('object_type');
73        ${$string}    = 'selected="selected"'; ?>
74        <input id="typeSongRadio" type="radio" name="object_type" value="1" <?php echo $otype_song; ?>/>
75        <label id="typeSongLabel" for="typeSongRadio"><?php echo T_('Song Title'); ?></label><br />
76        <?php echo Ajax::observe('typeSongRadio', 'click', Ajax::action('?page=tag&action=browse_type&browse_id=' . $browse->id . '&type=song', '')); ?>
77        <input id="typeAlbumRadio" type="radio" name="object_type" value="1" />
78        <label id="typeAlbumLabel" for="typeAlbumRadio"><?php echo T_('Albums'); ?></label><br />
79        <?php echo Ajax::observe('typeAlbumRadio', 'click', Ajax::action('?page=tag&action=browse_type&browse_id=' . $browse->id . '&type=album', '')); ?>
80        <input id="typeArtistRadio" type="radio" name="object_type" value="1" />
81        <label id="typeArtistLabel" for="typeArtistRadio"><?php echo T_('Artist'); ?></label><br />
82        <?php echo Ajax::observe('typeArtistRadio', 'click', Ajax::action('?page=tag&action=browse_type&browse_id=' . $browse->id . '&type=artist', '')); ?>
83    <?php
84    } ?>
85
86    <?php if (in_array('catalog', $allowed_filters)) { ?>
87        <form method="post" id="catalog_choice" action="javascript.void(0);">
88            <label id="catalogLabel" for="catalog_select"><?php echo T_('Catalog'); ?></label><br />
89            <select id="catalog_select" name="catalog_key">
90                <option value="0"><?php echo T_('All'); ?></option>
91                <?php $sql = 'SELECT `id`, `name` FROM `catalog`';
92        $db_results        = Dba::read($sql);
93        while ($data = Dba::fetch_assoc($db_results)) {
94            $results[] = $data;
95        }
96
97        foreach ($results as $entries) {
98            echo '<option value="' . $entries['id'] . '" ';
99            if ($_SESSION['catalog'] == $entries['id']) {
100                echo ' selected="selected" ';
101            }
102            echo '>' . $entries['name'] . '</options>';
103        } ?>
104
105            </select>
106        <?php echo Ajax::observe('catalog_select', 'change', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id, 'catalog_select', 'catalog_choice')); ?>
107        </form>
108    <?php
109    } ?>
110    <?php if (in_array('show_art', $allowed_filters)) { ?>
111        <?php echo T_('Toggle Artwork'); ?>&nbsp;<input id="show_artCB" type="checkbox" checked="checked"/>
112        <?php echo Ajax::observe('show_artCB', 'click', Ajax::action('?page=browse&action=show_art&browse_id=' . $browse->id, '')); ?>
113    <?php
114    } // if show_art?>
115    </div>
116</li>
117