mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-20 00:30:50 +08:00
improve searchbox extra
This commit is contained in:
@@ -33,6 +33,7 @@ use App\Repositories\ToolRepository;
|
||||
use App\Repositories\TorrentRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Notifications\Notification;
|
||||
use GeoIp2\Database\Reader;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Encryption\Encrypter;
|
||||
@@ -90,8 +91,15 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$columnInfo = NexusDB::getMysqlColumnInfo('searchbox', 'section_name');
|
||||
dd($columnInfo);
|
||||
// Notification::make()
|
||||
// ->success()
|
||||
// ->title('Test Test')
|
||||
// ->send()
|
||||
// ;
|
||||
$key = 'sbsb';
|
||||
$r = session()->push($key, [1,2,3]);
|
||||
$r = session()->get($key);
|
||||
dd($r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class CategoryResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('mode')
|
||||
->options(SearchBox::query()->pluck('name', 'id')->toArray())
|
||||
->options(SearchBox::listModeOptions())
|
||||
->label(__('label.search_box.label'))
|
||||
->required()
|
||||
,
|
||||
|
||||
@@ -84,6 +84,7 @@ class IconResource extends Resource
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
|
||||
@@ -44,7 +44,7 @@ class SecondIconResource extends Resource
|
||||
$specialMode = Setting::get('main.specialcat');
|
||||
$torrentTaxonomySchema = $searchBoxRep->listTaxonomyFormSchema($torrentMode);
|
||||
$specialTaxonomySchema = $searchBoxRep->listTaxonomyFormSchema($specialMode);
|
||||
$modeOptions = SearchBox::query()->whereIn('id', [$torrentMode, $specialMode])->pluck('name', 'id')->toArray();
|
||||
$modeOptions = SearchBox::listModeOptions();
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
@@ -52,12 +52,6 @@ class SecondIconResource extends Resource
|
||||
->required()
|
||||
->helperText(__('label.second_icon.name_help'))
|
||||
,
|
||||
Forms\Components\Select::make('mode')
|
||||
->label(__('label.search_box.label'))
|
||||
->options($modeOptions)
|
||||
->required()
|
||||
->reactive()
|
||||
,
|
||||
Forms\Components\TextInput::make('image')
|
||||
->label(__('label.second_icon.image'))
|
||||
->required()
|
||||
@@ -79,6 +73,11 @@ class SecondIconResource extends Resource
|
||||
->columns(4)
|
||||
->hidden(fn (\Closure $get) => $get('mode') != $specialMode)
|
||||
,
|
||||
Forms\Components\Select::make('mode')
|
||||
->options($modeOptions)
|
||||
->label(__('label.search_box.taxonomy.mode'))
|
||||
->helperText(__('label.search_box.taxonomy.mode_help'))
|
||||
,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -109,6 +108,7 @@ class SecondIconResource extends Resource
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
|
||||
@@ -87,6 +87,12 @@ class SectionResource extends Resource
|
||||
->label(__('label.search_box.custom_fields_display'))
|
||||
->helperText(__('label.search_box.custom_fields_display_help'))
|
||||
,
|
||||
Forms\Components\CheckboxList::make('other')
|
||||
->options(SearchBox::listExtraText())
|
||||
->columns(2)
|
||||
->label(__('label.search_box.other'))
|
||||
,
|
||||
|
||||
Forms\Components\Section::make(__('label.search_box.section_name'))
|
||||
->schema($sectionNameLocalSchema)
|
||||
->columns(count($sectionNameLocalSchema))
|
||||
|
||||
@@ -28,4 +28,15 @@ class EditSection extends EditRecord
|
||||
clear_search_box_cache($this->record->id);
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeFill(array $data): array
|
||||
{
|
||||
foreach (SearchBox::$extras as $field => $text) {
|
||||
if (!empty($data['extra'][$field])) {
|
||||
$data['other'][] = $field;
|
||||
}
|
||||
unset($data['extra'][$field]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,4 +21,5 @@ class EditTag extends EditRecord
|
||||
{
|
||||
return $this->getResource()::getUrl('index');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,20 +15,24 @@ class TrackerController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function announce(Request $request): \Illuminate\Http\Response
|
||||
{
|
||||
throw new \RuntimeException("Deprecated! Reference to: https://nexusphp.org/2022/07/18/tracker-url-recommend-to-use-old-announce-php/");
|
||||
return $this->repository->announce($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function scrape(Request $request): \Illuminate\Http\Response
|
||||
{
|
||||
throw new \RuntimeException("Deprecated! Reference to: https://nexusphp.org/2022/07/18/tracker-url-recommend-to-use-old-announce-php/");
|
||||
return $this->repository->scrape($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,10 @@ class Kernel extends HttpKernel
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\Platform::class,
|
||||
],
|
||||
'filament' => [
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Filament\Http\Middleware\Authenticate::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -58,7 +62,6 @@ class Kernel extends HttpKernel
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.nexus' => \App\Http\Middleware\NexusAuth::class,
|
||||
'auth.filament' => \Filament\Http\Middleware\Authenticate::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
|
||||
@@ -11,6 +11,8 @@ class SearchBox extends NexusModel
|
||||
{
|
||||
private static array $instances = [];
|
||||
|
||||
private static array $modeOptions = [];
|
||||
|
||||
protected $table = 'searchbox';
|
||||
|
||||
protected $fillable = [
|
||||
@@ -18,7 +20,8 @@ class SearchBox extends NexusModel
|
||||
'showsource', 'showmedium', 'showcodec', 'showstandard', 'showprocessing', 'showteam', 'showaudiocodec',
|
||||
'custom_fields', 'custom_fields_display_name', 'custom_fields_display',
|
||||
'extra->' . self::EXTRA_TAXONOMY_LABELS,
|
||||
'extra->' . self::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST
|
||||
'extra->' . self::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST,
|
||||
'extra->' . self::EXTRA_DISPLAY_SEED_BOX_ICON_ON_TORRENT_LIST,
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -55,27 +58,36 @@ class SearchBox extends NexusModel
|
||||
self::EXTRA_DISPLAY_SEED_BOX_ICON_ON_TORRENT_LIST => ['text' => 'Display seed box icon on torrent list'],
|
||||
];
|
||||
|
||||
public static function listExtraText(): array
|
||||
public static function listExtraText($fullName = false): array
|
||||
{
|
||||
$result = [];
|
||||
foreach (self::$extras as $extra => $info) {
|
||||
$result[$extra] = nexus_trans("searchbox.extras.$extra");
|
||||
foreach (self::$extras as $field => $info) {
|
||||
if ($fullName) {
|
||||
$name = "extra[$field]";
|
||||
} else {
|
||||
$name = $field;
|
||||
}
|
||||
$result[$name] = nexus_trans("searchbox.extras.$field");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function formatTaxonomyExtra(array $data): array
|
||||
{
|
||||
do_log("data: " . json_encode($data));
|
||||
foreach (self::$taxonomies as $field => $table) {
|
||||
$data["show{$field}"] = 0;
|
||||
foreach ($data['extra'][self::EXTRA_TAXONOMY_LABELS] ?? [] as $item) {
|
||||
if ($field == $item['torrent_field']) {
|
||||
$data["show{$field}"] = 1;
|
||||
// $data["extra->" . self::EXTRA_TAXONOMY_LABELS][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
$data["extra->" . self::EXTRA_TAXONOMY_LABELS] = $data['extra'][self::EXTRA_TAXONOMY_LABELS];
|
||||
$other = $data['other'] ?? [];
|
||||
$data["extra->" . self::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST] = in_array(self::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST, $other) ? 1 : 0;
|
||||
$data["extra->" . self::EXTRA_DISPLAY_SEED_BOX_ICON_ON_TORRENT_LIST] = in_array(self::EXTRA_DISPLAY_SEED_BOX_ICON_ON_TORRENT_LIST, $other) ? 1 : 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -137,6 +149,17 @@ class SearchBox extends NexusModel
|
||||
})->get();
|
||||
}
|
||||
|
||||
public static function listModeOptions(): array
|
||||
{
|
||||
if (!empty(self::$modeOptions)) {
|
||||
return self::$modeOptions;
|
||||
}
|
||||
self::$modeOptions = SearchBox::query()
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
return self::$modeOptions;
|
||||
}
|
||||
|
||||
public function getCustomFieldsAttribute($value): array
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
|
||||
@@ -81,8 +81,8 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware_group' => 'auth.filament',
|
||||
// 'middleware_group' => 'web',
|
||||
'middleware_group' => 'filament',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Dark mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By enabling this setting, your notifications will be ready for Tailwind's
|
||||
| Dark Mode feature.
|
||||
|
|
||||
| https://tailwindcss.com/docs/dark-mode
|
||||
|
|
||||
*/
|
||||
|
||||
'dark_mode' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database notifications
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By enabling this feature, your users are able to open a slide-over within
|
||||
| the app to view their database notifications.
|
||||
|
|
||||
*/
|
||||
|
||||
'database' => [
|
||||
'enabled' => false,
|
||||
'trigger' => null,
|
||||
'polling_interval' => '30s',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Layout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the configuration for the general layout of notifications.
|
||||
|
|
||||
*/
|
||||
|
||||
'layout' => [
|
||||
'alignment' => [
|
||||
'horizontal' => 'right',
|
||||
'vertical' => 'top',
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
@@ -679,6 +679,7 @@ elseif($action == 'add')
|
||||
}
|
||||
elseif($action == 'submit')
|
||||
{
|
||||
die("This method is deprecated! This method is no longer available in 1.8, it does not save data correctly, please go to the management system!");
|
||||
$dbtablename=return_category_db_table_name($type);
|
||||
if ($_POST['isedit']){
|
||||
$id = intval($_POST['id'] ?? 0);
|
||||
|
||||
@@ -150,7 +150,14 @@ return [
|
||||
'approval_status' => 'Approval status',
|
||||
'pos_state' => 'Pos state',
|
||||
'sp_state' => 'Promotion',
|
||||
'visible' => 'Visible',
|
||||
'visible' => 'Active',
|
||||
'source' => 'Source',
|
||||
'codec' => 'Codec',
|
||||
'audiocodec' => 'Audio codec',
|
||||
'medium' => 'Medium',
|
||||
'team' => 'Team',
|
||||
'processing' => 'Processing',
|
||||
'standard' => 'Standard',
|
||||
'picktype' => 'Recommend',
|
||||
'promotion_time_type' => 'Promotion type time',
|
||||
'hr' => 'H&R',
|
||||
@@ -254,6 +261,7 @@ return [
|
||||
then it's label:<%artist.label%>,it's value:<%artist.value%>",
|
||||
'category' => 'Category',
|
||||
'torrent_field_duplicate' => 'Torrent table field::field cannot be reused!',
|
||||
'other' => 'Other',
|
||||
'taxonomy' => [
|
||||
'name' => 'Name',
|
||||
'sort_index' => 'Sort',
|
||||
|
||||
@@ -114,6 +114,7 @@ return [
|
||||
],
|
||||
'exam' => [
|
||||
'label' => '考核',
|
||||
'is_done' => '是否完成',
|
||||
'is_discovered' => '自动发现',
|
||||
'register_time_range' => [
|
||||
'begin' => '注册时间开始',
|
||||
@@ -262,6 +263,7 @@ return [
|
||||
'custom_fields_display_help' => '使用特殊的标签代表字段的名称和值,如某字段其 Name 为 artist,则它的名称为:<%artist.label%>,它的值为:<%artist.value%>',
|
||||
'category' => '分类',
|
||||
'torrent_field_duplicate' => '种子表字段::field 不能重复使用!',
|
||||
'other' => '其他',
|
||||
'taxonomy' => [
|
||||
'name' => '名称',
|
||||
'sort_index' => '排序',
|
||||
|
||||
@@ -143,14 +143,21 @@ return [
|
||||
'owner' => '發布者',
|
||||
'size' => '大小',
|
||||
'ttl' => '存活時間',
|
||||
'seeders' => '做种',
|
||||
'leechers' => '下载',
|
||||
'seeders' => '做種',
|
||||
'leechers' => '下載',
|
||||
'times_completed' => '完成次數',
|
||||
'category' => '類型',
|
||||
'approval_status' => '審核狀態',
|
||||
'pos_state' => '置頂',
|
||||
'sp_state' => '優惠',
|
||||
'visible' => '活種',
|
||||
'source' => '來源',
|
||||
'codec' => '編碼',
|
||||
'audiocodec' => '音頻編碼',
|
||||
'medium' => '媒介',
|
||||
'team' => '製作組',
|
||||
'processing' => '處理',
|
||||
'standard' => '分辨率',
|
||||
'picktype' => '推薦',
|
||||
'promotion_time_type' => '優惠時間類型',
|
||||
'hr' => 'H&R',
|
||||
@@ -252,6 +259,7 @@ return [
|
||||
'custom_fields_display_help' => '使用特殊的標簽代表字段的名稱和值,如某字段其 Name 為 artist,則它的名稱為:<%artist.label%>,它的值為:<%artist.value%>',
|
||||
'category' => '分類',
|
||||
'torrent_field_duplicate' => '種子表字段::field 不能重復使用!',
|
||||
'other' => '其他',
|
||||
'taxonomy' => [
|
||||
'name' => '名稱',
|
||||
'sort_index' => '排序',
|
||||
|
||||
Reference in New Issue
Block a user