mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-20 17:37:23 +08:00
custom fields add priority + display
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
class SearchBox extends NexusModel
|
||||
{
|
||||
protected $table = 'searchbox';
|
||||
@@ -33,6 +35,21 @@ class SearchBox extends NexusModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getCustomFieldsAttribute($value): array
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
return explode(',', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setCustomFieldsAttribute($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$this->attributes['custom_fields'] = implode(',', $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function categories(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(Category::class, 'mode');
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class TorrentCustomField extends NexusModel
|
||||
{
|
||||
protected $table = 'torrents_custom_fields';
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = ['name', 'label', 'type', 'required', 'is_single_row', 'options', 'help', 'display', 'priority'];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class TorrentCustomFieldValue extends NexusModel
|
||||
{
|
||||
protected $table = 'torrents_custom_field_values';
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = ['torrent_id', 'custom_field_id', 'custom_field_value', ];
|
||||
|
||||
}
|
||||
@@ -25,11 +25,12 @@ class BaseRepository
|
||||
$canViewAnonymousClass = Setting::get('authority.viewanonymous');
|
||||
if($user->privacy == "strong" || ($torrent && $torrent->anonymous == 'yes' && $user->id == $torrent->owner)) {
|
||||
//用户强私密,或者种子作者匿名而当前项作者刚好为种子作者
|
||||
$anonymousText = nexus_trans('label.anonymous');
|
||||
if($authenticator->class >= $canViewAnonymousClass || $user->id == $authenticator->id) {
|
||||
//但当前用户权限可以查看匿名者,或当前用户查看自己的数据,显示个匿名,后边加真实用户名
|
||||
return sprintf('匿名(%s)', $username);
|
||||
return sprintf('%s(%s)', $anonymousText, $username);
|
||||
} else {
|
||||
return '匿名';
|
||||
return $anonymousText;
|
||||
}
|
||||
} else {
|
||||
return $username;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('torrents_custom_fields', function (Blueprint $table) {
|
||||
$table->text('display')->nullable(true)->after('help');
|
||||
$table->integer('priority')->default(0)->after('display');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('torrents_custom_fields', function (Blueprint $table) {
|
||||
$table->dropColumn('display', 'priority');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.27');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-09-18');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-09-19');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -26,5 +26,6 @@ $lang_fields = [
|
||||
'field_type_checkbox' => '横向多选',
|
||||
'field_type_select' => '下拉单选',
|
||||
'field_type_image' => '图片',
|
||||
'col_display' => '自定义展示',
|
||||
|
||||
];
|
||||
];
|
||||
|
||||
@@ -25,5 +25,6 @@ $lang_fields = [
|
||||
'field_type_radio' => '橫向單選',
|
||||
'field_type_checkbox' => '橫向多選',
|
||||
'field_type_select' => '下拉單選',
|
||||
'col_display' => '自定義展示',
|
||||
|
||||
];
|
||||
];
|
||||
|
||||
@@ -26,5 +26,6 @@ $lang_fields = [
|
||||
'field_type_checkbox' => 'Horizontal multiple select',
|
||||
'field_type_select' => 'Vertical single select',
|
||||
'field_type_image' => 'Image',
|
||||
'col_display' => 'Custom display',
|
||||
|
||||
];
|
||||
];
|
||||
|
||||
+74
-29
@@ -2,6 +2,10 @@
|
||||
|
||||
namespace Nexus\Field;
|
||||
|
||||
use App\Models\SearchBox;
|
||||
use App\Models\TorrentCustomField;
|
||||
use App\Models\TorrentCustomFieldValue;
|
||||
use Elasticsearch\Endpoints\Search;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class Field
|
||||
@@ -86,7 +90,7 @@ class Field
|
||||
|
||||
function buildFieldForm(array $row = [])
|
||||
{
|
||||
global $lang_fields, $lang_functions;
|
||||
global $lang_fields, $lang_functions, $lang_catmanage;
|
||||
$trName = tr($lang_fields['col_name'] . '<font color="red">*</font>', '<input type="text" name="name" value="' . ($row['name'] ?? '') . '" style="width: 300px" /> ' . $lang_fields['col_name_help'], 1, '', true);
|
||||
$trLabel = tr($lang_fields['col_label'] . '<font color="red">*</font>', '<input type="text" name="label" value="' . ($row['label'] ?? '') . '" style="width: 300px" />', 1, '', true);
|
||||
$trType = tr($lang_fields['col_type'] . '<font color="red">*</font>', $this->radio('type', $this->getTypeRadioOptions(), $row['type'] ?? null), 1, '', true);
|
||||
@@ -94,6 +98,9 @@ class Field
|
||||
$trHelp = tr($lang_fields['col_help'], '<textarea name="help" rows="4" cols="80">' . ($row['help'] ?? '') . '</textarea>', 1, '', true);
|
||||
$trOptions = tr($lang_fields['col_options'], '<textarea name="options" rows="6" cols="80">' . ($row['options'] ?? '') . '</textarea><br/>' . $lang_fields['col_options_help'], 1, '', true);
|
||||
$trIsSingleRow = tr($lang_fields['col_is_single_row'] . '<font color="red">*</font>', $this->radio('is_single_row', ['0' => $lang_functions['text_no'], '1' => $lang_functions['text_yes']], $row['is_single_row'] ?? null), 1, '', true);
|
||||
$trPriority = tr(nexus_trans('label.priority') . '<font color="red">*</font>', '<input type="number" name="priority" value="' . ($row['priority'] ?? '0') . '" style="width: 300px" />', 1, '', true);
|
||||
$trDisplay = tr($lang_fields['col_display'], '<textarea name="display" rows="4" cols="80">' . ($row['display'] ?? '') . '</textarea><br/>' . $lang_catmanage['row_custom_field_display_help'], 1, '', true);
|
||||
|
||||
$id = $row['id'] ?? 0;
|
||||
$form = <<<HTML
|
||||
<div>
|
||||
@@ -109,6 +116,8 @@ class Field
|
||||
{$trHelp}
|
||||
{$trOptions}
|
||||
{$trIsSingleRow}
|
||||
{$trPriority}
|
||||
{$trDisplay}
|
||||
</table>
|
||||
</div>
|
||||
<div style="text-align: center; margin-top: 10px;">
|
||||
@@ -126,7 +135,7 @@ HTML;
|
||||
$perPage = 10;
|
||||
$total = get_row_count('torrents_custom_fields');
|
||||
list($paginationTop, $paginationBottom, $limit) = pager($perPage, $total, "?");
|
||||
$sql = "select * from torrents_custom_fields order by id asc $limit";
|
||||
$sql = "select * from torrents_custom_fields order by priority desc $limit";
|
||||
$res = sql_query($sql);
|
||||
$header = [
|
||||
'id' => $lang_fields['col_id'],
|
||||
@@ -135,6 +144,7 @@ HTML;
|
||||
'type_text' => $lang_fields['col_type'],
|
||||
'required_text' => $lang_fields['col_required'],
|
||||
'is_single_row_text' => $lang_fields['col_is_single_row'],
|
||||
'priority' => nexus_trans('label.priority'),
|
||||
'action' => $lang_fields['col_action'],
|
||||
];
|
||||
$rows = [];
|
||||
@@ -203,6 +213,8 @@ HEAD;
|
||||
|
||||
$attributes['help'] = $data['help'] ?? '';
|
||||
$attributes['options'] = trim($data['options'] ?? '');
|
||||
$attributes['display'] = trim($data['display'] ?? '');
|
||||
$attributes['priority'] = trim($data['priority'] ?? '0');
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$attributes['updated_at'] = $now;
|
||||
$table = 'torrents_custom_fields';
|
||||
@@ -252,24 +264,29 @@ HEAD;
|
||||
|
||||
}
|
||||
|
||||
public function renderOnUploadPage($torrentId = 0)
|
||||
public function renderOnUploadPage($torrentId = 0, $searchBoxId)
|
||||
{
|
||||
global $browsecatmode;
|
||||
$searchBox = NexusDB::getOne('searchbox', "id = $browsecatmode");
|
||||
$searchBox = NexusDB::getOne('searchbox', "id = $searchBoxId");
|
||||
if (empty($searchBox)) {
|
||||
throw new \RuntimeException("Invalid search box: $browsecatmode");
|
||||
throw new \RuntimeException("Invalid search box: $searchBoxId");
|
||||
}
|
||||
$customValues = $this->listTorrentCustomField($torrentId);
|
||||
$sql = sprintf('select * from torrents_custom_fields where id in (%s)', $searchBox['custom_fields'] ?: 0);
|
||||
$customValues = $this->listTorrentCustomField($torrentId, $searchBoxId);
|
||||
$sql = sprintf('select * from torrents_custom_fields where id in (%s) order by priority desc', $searchBox['custom_fields'] ?: 0);
|
||||
$res = sql_query($sql);
|
||||
$html = '';
|
||||
while ($row = mysql_fetch_assoc($res)) {
|
||||
$name = "custom_fields[{$row['id']}]";
|
||||
$name = "custom_fields[$searchBoxId][{$row['id']}]";
|
||||
$currentValue = $customValues[$row['id']]['custom_field_value'] ?? '';
|
||||
$requireText = '';
|
||||
if ($row['required']) {
|
||||
$requireText = "<font color=\"red\">*</font>";
|
||||
}
|
||||
$trLabel = $row['label'] . $requireText;
|
||||
$trRelation = "mode_$searchBoxId";
|
||||
if ($row['type'] == self::TYPE_TEXT) {
|
||||
$html .= tr($row['label'], sprintf('<input type="text" name="%s" value="%s" style="width: %s"/>', $name, $currentValue, '99%'), 1);
|
||||
$html .= tr($trLabel, sprintf('<input type="text" name="%s" value="%s" style="width: %s"/>', $name, $currentValue, '99%'), 1, $trRelation);
|
||||
} elseif ($row['type'] == self::TYPE_TEXTAREA) {
|
||||
$html .= tr($row['label'], sprintf('<textarea name="%s" rows="4" style="width: %s">%s</textarea>', $name, '99%', $currentValue), 1);
|
||||
$html .= tr($trLabel, sprintf('<textarea name="%s" rows="4" style="width: %s">%s</textarea>', $name, '99%', $currentValue), 1, $trRelation);
|
||||
} elseif ($row['type'] == self::TYPE_RADIO || $row['type'] == self::TYPE_CHECKBOX) {
|
||||
if ($row['type'] == self::TYPE_CHECKBOX) {
|
||||
$name .= '[]';
|
||||
@@ -293,7 +310,7 @@ HEAD;
|
||||
$row['type'], $name, $value, $checked, $label
|
||||
);
|
||||
}
|
||||
$html .= tr($row['label'], $part, 1);
|
||||
$html .= tr($trLabel, $part, 1, $trRelation);
|
||||
} elseif ($row['type'] == self::TYPE_SELECT) {
|
||||
$part = '<select name="' . $name . '">';
|
||||
foreach (preg_split('/[\r\n]+/', trim($row['options'])) as $option) {
|
||||
@@ -312,7 +329,7 @@ HEAD;
|
||||
);
|
||||
}
|
||||
$part .= '</select>';
|
||||
$html .= tr($row['label'], $part, 1);
|
||||
$html .= tr($trLabel, $part, 1, $trRelation);
|
||||
} elseif ($row['type'] == self::TYPE_IMAGE) {
|
||||
$callbackFunc = "preview_custom_field_image_" . $row['id'];
|
||||
$iframeId = "iframe_$callbackFunc";
|
||||
@@ -351,18 +368,14 @@ HEAD;
|
||||
}
|
||||
</script>
|
||||
JS;
|
||||
$html .= tr($row['label'], $y, 1);
|
||||
$html .= tr($trLabel, $y, 1, $trRelation, true);
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function listTorrentCustomField($torrentId, $searchBoxId = 0)
|
||||
public function listTorrentCustomField($torrentId, $searchBoxId)
|
||||
{
|
||||
global $browsecatmode;
|
||||
if ($searchBoxId <= 0) {
|
||||
$searchBoxId = $browsecatmode;
|
||||
}
|
||||
//suppose torrentId is array
|
||||
$isArray = true;
|
||||
$torrentIdArr = $torrentId;
|
||||
@@ -371,7 +384,7 @@ JS;
|
||||
$torrentIdArr = [$torrentId];
|
||||
}
|
||||
$torrentIdStr = implode(',', $torrentIdArr);
|
||||
$res = sql_query("select f.*, v.custom_field_value, v.torrent_id from torrents_custom_field_values v inner join torrents_custom_fields f on v.custom_field_id = f.id inner join searchbox box on box.id = $searchBoxId and find_in_set(f.id, box.custom_fields) where torrent_id in ($torrentIdStr)");
|
||||
$res = sql_query("select f.*, v.custom_field_value, v.torrent_id from torrents_custom_field_values v inner join torrents_custom_fields f on v.custom_field_id = f.id inner join searchbox box on box.id = $searchBoxId and find_in_set(f.id, box.custom_fields) where torrent_id in ($torrentIdStr) order by f.priority desc");
|
||||
$values = [];
|
||||
$result = [];
|
||||
while ($row = mysql_fetch_assoc($res)) {
|
||||
@@ -402,12 +415,11 @@ JS;
|
||||
return $isArray ? $result : ($result[$torrentId] ?? []);
|
||||
}
|
||||
|
||||
public function renderOnTorrentDetailsPage($torrentId)
|
||||
public function renderOnTorrentDetailsPage($torrentId, $searchBoxId)
|
||||
{
|
||||
global $browsecatmode;
|
||||
$displayName = get_searchbox_value($browsecatmode, 'custom_fields_display_name');
|
||||
$customFields = $this->listTorrentCustomField($torrentId);
|
||||
$mixedRowContent = get_searchbox_value($browsecatmode, 'custom_fields_display');
|
||||
$displayName = get_searchbox_value($searchBoxId, 'custom_fields_display_name');
|
||||
$customFields = $this->listTorrentCustomField($torrentId, $searchBoxId);
|
||||
$mixedRowContent = get_searchbox_value($searchBoxId, 'custom_fields_display');
|
||||
$rowByRowHtml = '';
|
||||
$shouldRenderMixRow = false;
|
||||
foreach ($customFields as $field) {
|
||||
@@ -422,8 +434,15 @@ JS;
|
||||
$mixedRowContent = str_replace("<%{$field['name']}.label%>", $field['label'], $mixedRowContent);
|
||||
$mixedRowContent = str_replace("<%{$field['name']}.value%>", $contentNotFormatted, $mixedRowContent);
|
||||
if ($field['is_single_row']) {
|
||||
$contentFormatted = $this->formatCustomFieldValue($field, true);
|
||||
$rowByRowHtml .= tr($field['label'], $contentFormatted, 1);
|
||||
if (!empty($field['display'])) {
|
||||
$customFieldDisplay = $field['display'];
|
||||
$customFieldDisplay = str_replace("<%{$field['name']}.label%>", $field['label'], $customFieldDisplay);
|
||||
$customFieldDisplay = str_replace("<%{$field['name']}.value%>", $contentNotFormatted, $customFieldDisplay);
|
||||
$rowByRowHtml .= tr($field['label'], format_comment($customFieldDisplay, false), 1);
|
||||
} else {
|
||||
$contentFormatted = $this->formatCustomFieldValue($field, true);
|
||||
$rowByRowHtml .= tr($field['label'], $contentFormatted, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,13 +462,13 @@ JS;
|
||||
switch ($customFieldWithValue['type']) {
|
||||
case self::TYPE_TEXT:
|
||||
case self::TYPE_TEXTAREA:
|
||||
$result .= $doFormatComment ? format_comment($fieldValue) : $fieldValue;
|
||||
$result .= $doFormatComment ? format_comment($fieldValue, false) : $fieldValue;
|
||||
break;
|
||||
case self::TYPE_IMAGE:
|
||||
if (substr($fieldValue, 0, 4) == 'http') {
|
||||
$result .= $doFormatComment ? formatImg($fieldValue, true, 700, 0, "attach{$customFieldWithValue['id']}") : $fieldValue;
|
||||
} else {
|
||||
$result .= $doFormatComment ? format_comment($fieldValue) : $fieldValue;
|
||||
$result .= $doFormatComment ? format_comment($fieldValue, false) : $fieldValue;
|
||||
}
|
||||
break;
|
||||
case self::TYPE_RADIO:
|
||||
@@ -492,6 +511,32 @@ JS;
|
||||
}
|
||||
|
||||
|
||||
public function saveFieldValues($searchBoxId, $torrentId, array $data)
|
||||
{
|
||||
$searchBox = SearchBox::query()->findOrFail($searchBoxId);
|
||||
$enabledFields = TorrentCustomField::query()->find($searchBox->custom_fields);
|
||||
$insert = [];
|
||||
$now = now();
|
||||
foreach ($enabledFields as $field) {
|
||||
if (empty($data[$field->id])) {
|
||||
if ($field->required) {
|
||||
// throw new \InvalidArgumentException(nexus_trans("nexus.require_argument", ['argument' => $field->label]));
|
||||
do_log("Field: {$field->label} required, but empty");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$insert[] = [
|
||||
'torrent_id' => $torrentId,
|
||||
'custom_field_id' => $field->id,
|
||||
'custom_field_value' => $data[$field->id],
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
}
|
||||
TorrentCustomFieldValue::query()->where('torrent_id', $torrentId)->delete();
|
||||
TorrentCustomFieldValue::query()->insert($insert);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -278,7 +278,7 @@ JS;
|
||||
do_action('torrent_detail_before_desc', $row['id'], $CURUSER['id']);
|
||||
|
||||
/**************start custom fields****************/
|
||||
echo $customField->renderOnTorrentDetailsPage($id);
|
||||
echo $customField->renderOnTorrentDetailsPage($id, $row['search_box_id']);
|
||||
|
||||
/**************end custom fields****************/
|
||||
|
||||
|
||||
+28
-4
@@ -67,8 +67,6 @@ else {
|
||||
echo $ptGen->renderUploadPageFormInput($row['pt_gen']);
|
||||
}
|
||||
|
||||
$customField->renderOnUploadPage($id);
|
||||
|
||||
if ($enablenfo_main=='yes')
|
||||
tr($lang_edit['row_nfo_file'], "<font class=\"medium\"><input type=\"radio\" name=\"nfoaction\" value=\"keep\" checked=\"checked\" />".$lang_edit['radio_keep_current'].
|
||||
"<input type=\"radio\" name=\"nfoaction\" value=\"remove\" />".$lang_edit['radio_remove'].
|
||||
@@ -81,7 +79,7 @@ else {
|
||||
tr($lang_functions['text_technical_info'], '<textarea name="technical_info" rows="8" style="width: 99%;">' . $row['technical_info'] . '</textarea><br/>' . $lang_functions['text_technical_info_help_text'], 1);
|
||||
}
|
||||
|
||||
$s = "<select name=\"type\" id=\"oricat\">";
|
||||
$s = "<select name=\"type\" id=\"oricat\" data-mode='$sectionmode'>";
|
||||
|
||||
$cats = genrelist($sectionmode);
|
||||
foreach ($cats as $subrow) {
|
||||
@@ -93,7 +91,7 @@ else {
|
||||
|
||||
$s .= "</select>\n";
|
||||
if ($allowmove){
|
||||
$s2 = "<select name=\"type\" id=newcat disabled>\n";
|
||||
$s2 = "<select name=\"type\" id=newcat disabled data-mode='$othermode'>\n";
|
||||
$cats2 = genrelist($othermode);
|
||||
foreach ($cats2 as $subrow) {
|
||||
$s2 .= "<option value=\"" . $subrow["id"] . "\"";
|
||||
@@ -147,6 +145,12 @@ else {
|
||||
|
||||
tr($lang_edit['row_content'],$team_select,1);
|
||||
}
|
||||
|
||||
echo $customField->renderOnUploadPage($id, $browsecatmode);
|
||||
if ($enablespecial) {
|
||||
$customField->renderOnUploadPage($id, $specialcatmode);
|
||||
}
|
||||
|
||||
tr($lang_functions['text_tags'], (new \App\Repositories\TagRepository())->renderCheckbox($tagIdArr), 1);
|
||||
|
||||
$rowChecks = [];
|
||||
@@ -282,6 +286,26 @@ EOT;
|
||||
}
|
||||
\Nexus\Nexus::js('vendor/jquery-loading/jquery.loading.min.js', 'footer', true);
|
||||
\Nexus\Nexus::js('js/ptgen.js', 'footer', true);
|
||||
$customFieldJs = <<<JS
|
||||
jQuery("#movecheck").on("change", function () {
|
||||
let _this = jQuery(this);
|
||||
let checked = _this.prop("checked");
|
||||
let activeSelect
|
||||
if (checked) {
|
||||
activeSelect = jQuery("#newcat");
|
||||
} else {
|
||||
activeSelect = jQuery("#oricat");
|
||||
}
|
||||
let mode = activeSelect.attr("data-mode");
|
||||
console.log(mode)
|
||||
jQuery("tr[relation]").hide();
|
||||
jQuery("tr[relation=mode_" + mode +"]").show();
|
||||
})
|
||||
jQuery("tr[relation]").hide();
|
||||
jQuery("tr[relation=mode_{$sectionmode}]").show();
|
||||
|
||||
JS;
|
||||
\Nexus\Nexus::js($customFieldJs, 'footer', false);
|
||||
stdfoot();
|
||||
function getAddedTimeOption($timeStamp, $addSeconds) {
|
||||
$timeStamp += $addSeconds;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
require "../include/bittorrent.php";
|
||||
dbconn();
|
||||
require_once(get_langfile_path());
|
||||
require_once(get_langfile_path('catmanage.php'));
|
||||
loggedinorreturn();
|
||||
if (get_user_class() < UC_ADMINISTRATOR) {
|
||||
permissiondenied();
|
||||
|
||||
+3
-14
@@ -224,20 +224,9 @@ $dateTimeStringNow = date("Y-m-d H:i:s");
|
||||
* add custom fields
|
||||
* @since v1.6
|
||||
*/
|
||||
if (!empty($_POST['custom_fields'])) {
|
||||
\Nexus\Database\NexusDB::delete('torrents_custom_field_values', "torrent_id = $id");
|
||||
foreach ($_POST['custom_fields'] as $customField => $customValue) {
|
||||
foreach ((array)$customValue as $value) {
|
||||
$customData = [
|
||||
'torrent_id' => $id,
|
||||
'custom_field_id' => $customField,
|
||||
'custom_field_value' => $value,
|
||||
'created_at' => $dateTimeStringNow,
|
||||
'updated_at' => $dateTimeStringNow,
|
||||
];
|
||||
\Nexus\Database\NexusDB::insert('torrents_custom_field_values', $customData);
|
||||
}
|
||||
}
|
||||
if (!empty($_POST['custom_fields'][$newcatmode])) {
|
||||
$customField = new \Nexus\Field\Field();
|
||||
$customField->saveFieldValues($newcatmode, $id, $_POST['custom_fields'][$newcatmode]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-14
@@ -390,20 +390,9 @@ if ($saveResult === false) {
|
||||
* add custom fields
|
||||
* @since v1.6
|
||||
*/
|
||||
if (!empty($_POST['custom_fields'])) {
|
||||
$now = date('Y-m-d H:i:s');
|
||||
foreach ($_POST['custom_fields'] as $customField => $customValue) {
|
||||
foreach ((array)$customValue as $value) {
|
||||
$customData = [
|
||||
'torrent_id' => $id,
|
||||
'custom_field_id' => $customField,
|
||||
'custom_field_value' => $value,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
\Nexus\Database\NexusDB::insert('torrents_custom_field_values', $customData);
|
||||
}
|
||||
}
|
||||
if (!empty($_POST['custom_fields'][$catmod])) {
|
||||
$customField = new \Nexus\Field\Field();
|
||||
$customField->saveFieldValues($catmod, $id, $_POST['custom_fields'][$catmod]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+21
-4
@@ -70,8 +70,6 @@ stdhead($lang_upload['head_upload']);
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
echo $ptGen->renderUploadPageFormInput("");
|
||||
}
|
||||
$field = new \Nexus\Field\Field();
|
||||
$field->renderOnUploadPage();
|
||||
if ($enablenfo_main=='yes') {
|
||||
tr($lang_upload['row_nfo_file'], "<input type=\"file\" class=\"file\" name=\"nfo\" /><br /><font class=\"medium\">".$lang_upload['text_only_viewed_by'].get_user_class_name($viewnfo_class,false,true,true).$lang_upload['text_or_above']."</font>", 1);
|
||||
}
|
||||
@@ -85,7 +83,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' ".($allowtwosec ? $disablespecial : "").">\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";
|
||||
@@ -94,7 +92,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' ".$disablebrowse.">\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";
|
||||
@@ -145,6 +143,11 @@ stdhead($lang_upload['head_upload']);
|
||||
|
||||
tr($lang_upload['row_content'],$team_select,1);
|
||||
}
|
||||
$customField = new \Nexus\Field\Field();
|
||||
echo $customField->renderOnUploadPage(0, $browsecatmode);
|
||||
if ($enablespecial) {
|
||||
echo $customField->renderOnUploadPage(0, $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__);
|
||||
@@ -222,4 +225,18 @@ JS;
|
||||
<?php
|
||||
\Nexus\Nexus::js('vendor/jquery-loading/jquery.loading.min.js', 'footer', true);
|
||||
\Nexus\Nexus::js('js/ptgen.js', 'footer', true);
|
||||
$customFieldJs = <<<JS
|
||||
jQuery("#compose").on("change", "select[name=type]", function () {
|
||||
let _this = jQuery(this);
|
||||
let mode = _this.attr("data-mode");
|
||||
let value = _this.val();
|
||||
console.log(mode)
|
||||
jQuery("tr[relation]").hide();
|
||||
if (value > 0) {
|
||||
jQuery("tr[relation=mode_" + mode +"]").show();
|
||||
}
|
||||
})
|
||||
jQuery("tr[relation]").hide();
|
||||
JS;
|
||||
\Nexus\Nexus::js($customFieldJs, 'footer', false);
|
||||
stdfoot();
|
||||
|
||||
@@ -33,6 +33,7 @@ return [
|
||||
'submit' => 'Submit',
|
||||
'cancel' => 'Cancel',
|
||||
'reset' => 'Reset',
|
||||
'anonymous' => 'Anonymous',
|
||||
'setting' => [
|
||||
'nav_text' => 'Setting',
|
||||
'backup' => [
|
||||
|
||||
@@ -33,6 +33,7 @@ return [
|
||||
'submit' => '提交',
|
||||
'cancel' => '取消',
|
||||
'reset' => '重置',
|
||||
'anonymous' => '匿名',
|
||||
'setting' => [
|
||||
'nav_text' => '设置',
|
||||
'backup' => [
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
|
||||
return [
|
||||
'invalid_argument' => '参数错误',
|
||||
'require_argument' => ':argument 不能为空',
|
||||
];
|
||||
|
||||
@@ -33,6 +33,7 @@ return [
|
||||
'submit' => '提交',
|
||||
'cancel' => '取消',
|
||||
'reset' => '重置',
|
||||
'anonymous' => '匿名',
|
||||
'setting' => [
|
||||
'nav_text' => '設置',
|
||||
'backup' => [
|
||||
|
||||
Reference in New Issue
Block a user