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\Search; 25use Ampache\Module\System\Core; 26use Ampache\Module\Util\Ui; 27 28/** @var null|Search $playlist */ 29 30if ($playlist) { 31 $logic_operator = $playlist->logic_operator; 32} else { 33 $logic_operator = Core::get_request('operator'); 34} 35$logic_operator = strtolower($logic_operator); ?> 36<script src="<?php echo AmpConfig::get('web_path'); ?>/lib/javascript/search.js"></script> 37<script src="<?php echo AmpConfig::get('web_path'); ?>/lib/javascript/search-data.php?type=<?php echo (string) scrub_out(filter_input(INPUT_GET, 'type', FILTER_SANITIZE_SPECIAL_CHARS)) ?: 'song'; ?>"></script> 38 39<?php Ui::show_box_top(T_('Rules') . "...", 'box box_rules'); ?> 40<table class="tabledata"> 41<tbody id="searchtable"> 42 <tr id="rules_operator"> 43 <td><?php echo T_('Match'); ?></td> 44 <td> 45 <select name="operator"> 46 <option value="and" <?php if ($logic_operator == 'and') { 47 echo 'selected="selected"'; 48}?>><?php echo T_('all rules'); ?></option> 49 <option value="or" <?php if ($logic_operator == 'or') { 50 echo 'selected="selected"'; 51}?>><?php echo T_('any rule'); ?></option> 52 </select> 53 </td> 54 </tr> 55 <tr id="rules_addrowbutton"> 56 <td> 57 <a id="addrowbutton" href="javascript:void(0)"> 58 <?php echo Ui::get_icon('add'); ?> 59 <?php echo T_('Add Another Rule'); ?> 60 </a> 61 <script>$('#addrowbutton').on('click', SearchRow.add);</script> 62 </td> 63 </tr> 64</tbody> 65</table> 66<?php Ui::show_box_bottom(); ?> 67 68<?php 69if ($playlist) { 70 $out = $playlist->to_js(); 71} else { 72 $mysearch = new Search(null, (string) filter_input(INPUT_GET, 'type', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); 73 $mysearch->parse_rules(Search::clean_request($_REQUEST)); 74 $out = $mysearch->to_js(); 75} 76if ($out) { 77 echo $out; 78} else { 79 echo '<script>SearchRow.add();</script>'; 80} ?> 81