finish searchbox build + upload/edit form quality render

This commit is contained in:
xiaomlove
2022-09-14 19:05:29 +08:00
parent a7717b2ce8
commit c9c16bc5bd
22 changed files with 313 additions and 79 deletions
+14 -2
View File
@@ -19,7 +19,7 @@ if (!$row) die();
$customField = new \Nexus\Field\Field();
$tagIdArr = \App\Models\TorrentTag::query()->where('torrent_id', $id)->get()->pluck('tag_id')->toArray();
$searchBoxRep = new \App\Repositories\SearchBoxRepository();
if ($enablespecial == 'yes' && user_can('movetorrent'))
$allowmove = true; //enable moving torrent to other section
else $allowmove = false;
@@ -35,7 +35,7 @@ else
$othermode = $browsecatmode;
$movenote = $lang_edit['text_move_to_browse'];
}
/*
$showsource = (get_searchbox_value($sectionmode, 'showsource') || ($allowmove && get_searchbox_value($othermode, 'showsource'))); //whether show sources or not
$showmedium = (get_searchbox_value($sectionmode, 'showmedium') || ($allowmove && get_searchbox_value($othermode, 'showmedium'))); //whether show media or not
$showcodec = (get_searchbox_value($sectionmode, 'showcodec') || ($allowmove && get_searchbox_value($othermode, 'showcodec'))); //whether show codecs or not
@@ -43,6 +43,7 @@ $showstandard = (get_searchbox_value($sectionmode, 'showstandard') || ($allowmov
$showprocessing = (get_searchbox_value($sectionmode, 'showprocessing') || ($allowmove && get_searchbox_value($othermode, 'showprocessing'))); //whether show processings or not
$showteam = (get_searchbox_value($sectionmode, 'showteam') || ($allowmove && get_searchbox_value($othermode, 'showteam'))); //whether show teams or not
$showaudiocodec = (get_searchbox_value($sectionmode, 'showaudiocodec') || ($allowmove && get_searchbox_value($othermode, 'showaudiocodec'))); //whether show audio codecs or not
*/
$settingMain = get_setting('main');
stdhead($lang_edit['head_edit_torrent'] . "\"". $row["name"] . "\"");
@@ -105,6 +106,7 @@ else {
$movecheckbox = "<input type=\"checkbox\" id=movecheck name=\"movecheck\" value=\"1\" onclick=\"disableother2('oricat','newcat')\" />";
}
tr($lang_edit['row_type']."<font color=\"red\">*</font>", $s.($allowmove ? "&nbsp;&nbsp;".$movecheckbox.$movenote.$s2 : ""), 1);
/*
if ($showsource || $showmedium || $showcodec || $showaudiocodec || $showstandard || $showprocessing){
if ($showsource){
$source_select = torrent_selection($lang_edit['text_source'],"source_sel","sources",$row["source"]);
@@ -147,6 +149,16 @@ else {
tr($lang_edit['row_content'],$team_select,1);
}
*/
$sectionCurrent = $searchBoxRep->renderQualitySelect($sectionmode);
tr($lang_edit['row_quality'], $sectionCurrent, 1, "hide mode mode_$sectionmode");
if ($allowmove && $othermode) {
$selectOther = $searchBoxRep->renderQualitySelect($othermode);
tr($lang_edit['row_quality'], $selectOther, 1, "hide mode mode_$othermode");
}
tr($lang_functions['text_tags'], (new \App\Repositories\TagRepository())->renderCheckbox($tagIdArr), 1);
$rowChecks = [];
+16 -8
View File
@@ -6,7 +6,7 @@ loggedinorreturn();
$brsectiontype = $browsecatmode;
$spsectiontype = $specialcatmode;
if ($enablespecial == 'yes' && get_user_class() >= get_setting('authority.view_special_torrent'))
if ($enablespecial == 'yes' && user_can('view_special_torrent'))
$allowspecial = true;
else $allowspecial = false;
$showsubcat = (get_searchbox_value($brsectiontype, 'showsubcat') || ($allowspecial && get_searchbox_value($spsectiontype, 'showsubcat')));
@@ -29,13 +29,13 @@ $brcats = genrelist($brsectiontype);
$spcats = genrelist($spsectiontype);
if ($showsubcat){
if ($showsource) $sources = searchbox_item_list("sources");
if ($showmedium) $media = searchbox_item_list("media");
if ($showcodec) $codecs = searchbox_item_list("codecs");
if ($showstandard) $standards = searchbox_item_list("standards");
if ($showprocessing) $processings = searchbox_item_list("processings");
if ($showteam) $teams = searchbox_item_list("teams");
if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs");
if ($showsource) $sources = searchbox_item_list("sources", $brsectiontype);
if ($showmedium) $media = searchbox_item_list("media", $brsectiontype);
if ($showcodec) $codecs = searchbox_item_list("codecs", $brsectiontype);
if ($showstandard) $standards = searchbox_item_list("standards", $brsectiontype);
if ($showprocessing) $processings = searchbox_item_list("processings", $brsectiontype);
if ($showteam) $teams = searchbox_item_list("teams", $brsectiontype);
if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs", $brsectiontype);
}
stdhead($lang_getrss['head_rss_feeds']);
$query = [];
@@ -177,6 +177,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
stdfoot();
die();
}
?>
<h1 align="center"><?php echo $lang_getrss['text_rss_feeds']?></h1>
<form method="post" action="getrss.php">
@@ -186,6 +187,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
</td>
<td class="rowfollow" align="left">
<?php
/*
$categories = "<table><tr><td class=\"embedded\" align=\"left\"><b>".$lang_getrss['text_category']."</b></td></tr><tr>";
$i = 0;
foreach ($brcats as $cat)//print category list of Torrents section
@@ -296,7 +298,13 @@ if ($allowspecial) //print category list of Special section
}
}
$categories .= "</table>";
*/
$categories = build_search_box_category_table($browsecatmode, 'yes', 'torrents.php?allsec=1', false, 3);
print($categories);
print '<div style="height: 1px;background-color: #eee;margin: 10px 0"></div>';
$categoriesSpecial = build_search_box_category_table($specialcatmode, 'yes', 'torrents.php?allsec=1', false, 3);
print($categoriesSpecial);
?>
</td>
</tr>
+26 -1
View File
@@ -28,7 +28,7 @@ jQuery('.btn-get-pt-gen').on('click', function () {
}, 'json')
})
//auto fill quality
function autoSelect(value) {
// console.log(`autoSelect: ${value}`)
value = value.replace(/[-\/\.]+/ig, '').toUpperCase();
@@ -36,6 +36,10 @@ function autoSelect(value) {
for (let i = 0; i < names.length; i++) {
const name = names[i];
const select = jQuery("select[name="+name+"]")
if (select.prop('disabled')) {
console.log("name: " + name + " is disabled, skip")
continue
}
// console.log("check name: " + name)
select.children("option").each(function (index, option) {
let _option = jQuery(option)
@@ -71,3 +75,24 @@ jQuery("#compose").on("click", ".nexus-action-btn",function () {
}
}
})
//change section
function showHideQuality(activeSelect) {
let mode = activeSelect.getAttribute("data-mode")
let value = activeSelect.value
console.log(mode, value)
if (value == 0) {
//enable all section
jQuery("select[name=type]").prop("disabled", false);
//disable all quality tr
jQuery("tr.mode").hide().find("select").prop("disabled", true);
} else {
jQuery("select[name=type]").prop("disabled", true);
activeSelect.disabled = false
//active current section quality tr
jQuery("tr.mode_" + mode).show().find("select").prop("disabled", false);
}
}
jQuery("#compose").on("change", "select[name=type]", function () {
showHideQuality(this)
});
+3
View File
@@ -530,3 +530,6 @@ img.hitandrun {
background-position: 100% 0;
}
}
.hide {
display: none;
}
+8 -8
View File
@@ -23,7 +23,7 @@ switch (nexus()->getScript()) {
if (get_setting('main.spsct') != 'yes') {
httperr();
}
if (get_user_class() < get_setting('authority.view_special_torrent')) {
if (!user_can('view_special_torrent')) {
stderr($lang_special['std_sorry'],$lang_special['std_permission_denied_only'].get_user_class_name(get_setting('authority.view_special_torrent'),false,true,true).$lang_special['std_or_above_can_view'],false);
}
$sectiontype = $specialcatmode;
@@ -44,13 +44,13 @@ $catpadding = get_searchbox_value($sectiontype, 'catpadding'); //padding space b
$cats = genrelist($sectiontype);
if ($showsubcat){
if ($showsource) $sources = searchbox_item_list("sources");
if ($showmedium) $media = searchbox_item_list("media");
if ($showcodec) $codecs = searchbox_item_list("codecs");
if ($showstandard) $standards = searchbox_item_list("standards");
if ($showprocessing) $processings = searchbox_item_list("processings");
if ($showteam) $teams = searchbox_item_list("teams");
if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs");
if ($showsource) $sources = searchbox_item_list("sources", $sectiontype);
if ($showmedium) $media = searchbox_item_list("media", $sectiontype);
if ($showcodec) $codecs = searchbox_item_list("codecs", $sectiontype);
if ($showstandard) $standards = searchbox_item_list("standards", $sectiontype);
if ($showprocessing) $processings = searchbox_item_list("processings", $sectiontype);
if ($showteam) $teams = searchbox_item_list("teams", $sectiontype);
if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs", $sectiontype);
}
$searchstr_ori = htmlspecialchars(trim($_GET["search"] ?? ''));
+15 -4
View File
@@ -23,6 +23,7 @@ $allowtwosec = ($allowtorrents && $allowspecial);
$brsectiontype = $browsecatmode;
$spsectiontype = $specialcatmode;
/*
$showsource = (($allowtorrents && get_searchbox_value($brsectiontype, 'showsource')) || ($allowspecial && get_searchbox_value($spsectiontype, 'showsource'))); //whether show sources or not
$showmedium = (($allowtorrents && get_searchbox_value($brsectiontype, 'showmedium')) || ($allowspecial && get_searchbox_value($spsectiontype, 'showmedium'))); //whether show media or not
$showcodec = (($allowtorrents && get_searchbox_value($brsectiontype, 'showcodec')) || ($allowspecial && get_searchbox_value($spsectiontype, 'showcodec'))); //whether show codecs or not
@@ -30,9 +31,10 @@ $showstandard = (($allowtorrents && get_searchbox_value($brsectiontype, 'showsta
$showprocessing = (($allowtorrents && get_searchbox_value($brsectiontype, 'showprocessing')) || ($allowspecial && get_searchbox_value($spsectiontype, 'showprocessing'))); //whether show processings or not
$showteam = (($allowtorrents && get_searchbox_value($brsectiontype, 'showteam')) || ($allowspecial && get_searchbox_value($spsectiontype, 'showteam'))); //whether show teams or not
$showaudiocodec = (($allowtorrents && get_searchbox_value($brsectiontype, 'showaudiocodec')) || ($allowspecial && get_searchbox_value($spsectiontype, 'showaudiocodec'))); //whether show languages or not
*/
$settingMain = get_setting('main');
$torrentRep = new \App\Repositories\TorrentRepository();
$searchBoxRep = new \App\Repositories\SearchBoxRepository();
stdhead($lang_upload['head_upload']);
?>
<form id="compose" enctype="multipart/form-data" action="takeupload.php" method="post" name="upload">
@@ -84,7 +86,7 @@ stdhead($lang_upload['head_upload']);
if ($allowtorrents){
$disablespecial = " onchange=\"disableother('browsecat','specialcat')\"";
$s = "<select name=\"type\" id=\"browsecat\" ".($allowtwosec ? $disablespecial : "").">\n<option value=\"0\">".$lang_upload['select_choose_one']."</option>\n";
$s = "<select name=\"type\" id=\"browsecat\" data-mode='$browsecatmode'>\n<option value=\"0\">".$lang_upload['select_choose_one']."</option>\n";
$cats = genrelist($browsecatmode);
foreach ($cats as $row)
$s .= "<option value=\"" . $row["id"] . "\">" . htmlspecialchars($row["name"]) . "</option>\n";
@@ -93,7 +95,7 @@ stdhead($lang_upload['head_upload']);
else $s = "";
if ($allowspecial){
$disablebrowse = " onchange=\"disableother('specialcat','browsecat')\"";
$s2 = "<select name=\"type\" id=\"specialcat\" ".$disablebrowse.">\n<option value=\"0\">".$lang_upload['select_choose_one']."</option>\n";
$s2 = "<select name=\"type\" id=\"specialcat\" data-mode='$specialcatmode'>\n<option value=\"0\">".$lang_upload['select_choose_one']."</option>\n";
$cats2 = genrelist($specialcatmode);
foreach ($cats2 as $row)
$s2 .= "<option value=\"" . $row["id"] . "\">" . htmlspecialchars($row["name"]) . "</option>\n";
@@ -101,7 +103,7 @@ stdhead($lang_upload['head_upload']);
}
else $s2 = "";
tr($lang_upload['row_type']."<font color=\"red\">*</font>", ($allowtwosec ? $lang_upload['text_to_browse_section'] : "").$s.($allowtwosec ? $lang_upload['text_to_special_section'] : "").$s2.($allowtwosec ? $lang_upload['text_type_note'] : ""),1);
/*
if ($showsource || $showmedium || $showcodec || $showaudiocodec || $showstandard || $showprocessing){
if ($showsource){
$source_select = torrent_selection($lang_upload['text_source'],"source_sel","sources");
@@ -144,6 +146,15 @@ stdhead($lang_upload['head_upload']);
tr($lang_upload['row_content'],$team_select,1);
}
*/
if ($allowtorrents) {
$selectNormal = $searchBoxRep->renderQualitySelect($browsecatmode);
tr($lang_upload['row_quality'], $selectNormal, 1, "hide mode mode_$browsecatmode");
}
if ($allowspecial) {
$selectNormal = $searchBoxRep->renderQualitySelect($specialcatmode);
tr($lang_upload['row_quality'], $selectNormal, 1, "hide mode mode_$specialcatmode");
}
//==== offer dropdown for offer mod from code by S4NE
$offerres = sql_query("SELECT id, name FROM offers WHERE userid = ".sqlesc($CURUSER['id'])." AND allowed = 'allowed' ORDER BY name ASC") or sqlerr(__FILE__, __LINE__);
+9 -1
View File
@@ -367,6 +367,7 @@ $spsectiontype = $specialcatmode;
if ($enablespecial == 'yes' && get_user_class() >= get_setting('authority.view_special_torrent'))
$allowspecial = true;
else $allowspecial = false;
/*
$showsubcat = (get_searchbox_value($brsectiontype, 'showsubcat') || ($allowspecial && get_searchbox_value($spsectiontype, 'showsubcat')));
$showsource = (get_searchbox_value($brsectiontype, 'showsource') || ($allowspecial && get_searchbox_value($spsectiontype, 'showsource'))); //whether show sources or not
$showmedium = (get_searchbox_value($brsectiontype, 'showmedium') || ($allowspecial && get_searchbox_value($spsectiontype, 'showmedium'))); //whether show media or not
@@ -395,6 +396,7 @@ if ($showprocessing) $processings = searchbox_item_list("processings");
if ($showteam) $teams = searchbox_item_list("teams");
if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs");
}
*/
print ("<table border=0 cellspacing=0 cellpadding=5 width=".CONTENT_WIDTH.">");
form ("tracker");
if ($type == 'saved')
@@ -403,6 +405,7 @@ if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs");
tr_small($lang_usercp['row_email_notification'], "<input type=checkbox name=pmnotif" . (strpos($CURUSER['notifs'], "[pm]") !== false ? " checked" : "") . " value=yes> ".$lang_usercp['checkbox_notification_received_pm']."<br />\n<input type=checkbox name=emailnotif" . (strpos($CURUSER['notifs'], "[email]") !== false ? " checked" : "") . " value=\"yes\" /> ".$lang_usercp['checkbox_notification_default_categories'], 1);
//no this option
$brenablecatrow = false;
/*
$categories = "<table>".($allowspecial ? "<tr><td class=embedded align=left><font class=big>".$lang_usercp['text_at_browse_page']."</font></td></tr></table><table>" : "")."<tr><td class=embedded align=left><b>".($brenablecatrow == true ? $brcatrow[0] : $lang_usercp['text_category'])."</b></td></tr><tr>";
$i = 0;
foreach ($brcats as $cat)//print category list of Torrents section
@@ -536,7 +539,12 @@ if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs");
$categories .= "<tr><td class=bottom><b>".$lang_usercp['text_show_dead_active']."</b><br /><select name=\"incldead\"><option value=\"0\" ".(strpos($CURUSER['notifs'], "[incldead=0]") !== false ? " selected" : "").">".$lang_usercp['select_including_dead']."</option><option value=\"1\" ".(strpos($CURUSER['notifs'], "[incldead=1]") !== false || strpos($CURUSER['notifs'], "incldead") == false ? " selected" : "").">".$lang_usercp['select_active']."</option><option value=\"2\" ".(strpos($CURUSER['notifs'], "[incldead=2]") !== false ? " selected" : "").">".$lang_usercp['select_dead']."</option></select></td><td class=bottom align=left><b>".$lang_usercp['text_show_special_torrents']."</b><br /><select name=\"spstate\"><option value=\"0\" ".($special_state == 0 ? " selected" : "").">".$lang_usercp['select_all']."</option>".promotion_selection($special_state)."</select></td><td class=bottom><b>".$lang_usercp['text_show_bookmarked']."</b><br /><select name=\"inclbookmarked\"><option value=\"0\" ".(strpos($CURUSER['notifs'], "[inclbookmarked=0]") !== false ? " selected" : "").">".$lang_usercp['select_all']."</option><option value=\"1\" ".(strpos($CURUSER['notifs'], "[inclbookmarked=1]") !== false ? " selected" : "")." >".$lang_usercp['select_bookmarked']."</option><option value=\"2\" ".(strpos($CURUSER['notifs'], "[inclbookmarked=2]") !== false ? " selected" : "").">".$lang_usercp['select_bookmarked_exclude']."</option></select></td></tr>";
$categories .= "</table>";
tr_small($lang_usercp['row_browse_default_categories'],$categories,1);
*/
$categories = build_search_box_category_table($browsecatmode, 'yes','torrents.php?allsec=1', false, 3, $CURUSER['notifs']);
$delimiter = '<div style="height: 1px;background-color: #eee;margin: 10px 0"></div>';
$categoriesSpecial = build_search_box_category_table($specialcatmode, 'yes','torrents.php?allsec=1', false, 3, $CURUSER['notifs']);
$extra = "<table><caption><font class='big'>{$lang_usercp['text_additional_selection']}</font></caption><tr><td class=bottom><b>".$lang_usercp['text_show_dead_active']."</b><br /><select name=\"incldead\"><option value=\"0\" ".(strpos($CURUSER['notifs'], "[incldead=0]") !== false ? " selected" : "").">".$lang_usercp['select_including_dead']."</option><option value=\"1\" ".(strpos($CURUSER['notifs'], "[incldead=1]") !== false || strpos($CURUSER['notifs'], "incldead") == false ? " selected" : "").">".$lang_usercp['select_active']."</option><option value=\"2\" ".(strpos($CURUSER['notifs'], "[incldead=2]") !== false ? " selected" : "").">".$lang_usercp['select_dead']."</option></select></td><td class=bottom align=left><b>".$lang_usercp['text_show_special_torrents']."</b><br /><select name=\"spstate\"><option value=\"0\" ".($special_state == 0 ? " selected" : "").">".$lang_usercp['select_all']."</option>".promotion_selection($special_state)."</select></td><td class=bottom><b>".$lang_usercp['text_show_bookmarked']."</b><br /><select name=\"inclbookmarked\"><option value=\"0\" ".(strpos($CURUSER['notifs'], "[inclbookmarked=0]") !== false ? " selected" : "").">".$lang_usercp['select_all']."</option><option value=\"1\" ".(strpos($CURUSER['notifs'], "[inclbookmarked=1]") !== false ? " selected" : "")." >".$lang_usercp['select_bookmarked']."</option><option value=\"2\" ".(strpos($CURUSER['notifs'], "[inclbookmarked=2]") !== false ? " selected" : "").">".$lang_usercp['select_bookmarked_exclude']."</option></select></td></tr></table>";
tr_small($lang_usercp['row_browse_default_categories'],$categories . $delimiter . $categoriesSpecial . $delimiter . $extra,1);
$ss_r = sql_query("SELECT * FROM stylesheets") or die;
$ss_sa = array();
while ($ss_a = mysql_fetch_array($ss_r))