diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index c4fb5e7b..0cf819bc 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -26,7 +26,7 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule) { $schedule->command('exam:assign_cronjob')->everyMinute()->withoutOverlapping(); - $schedule->command('exam:checkout_cronjob')->everyMinute()->withoutOverlapping(); + $schedule->command('exam:checkout_cronjob')->everyFiveMinutes()->withoutOverlapping(); $schedule->command('exam:update_progress --bulk=1')->hourly()->withoutOverlapping(); $schedule->command('backup:cronjob')->everyMinute()->withoutOverlapping(); $schedule->command('hr:update_status')->everyTenMinutes()->withoutOverlapping(); diff --git a/app/Filament/Resources/Section/AudioCodecResource/Pages/CreateAudioCodec.php b/app/Filament/Resources/Section/AudioCodecResource/Pages/CreateAudioCodec.php index ed84b835..034e75ea 100644 --- a/app/Filament/Resources/Section/AudioCodecResource/Pages/CreateAudioCodec.php +++ b/app/Filament/Resources/Section/AudioCodecResource/Pages/CreateAudioCodec.php @@ -5,8 +5,9 @@ namespace App\Filament\Resources\Section\AudioCodecResource\Pages; use App\Filament\Resources\Section\AudioCodecResource; use Filament\Pages\Actions; use Filament\Resources\Pages\CreateRecord; +use App\Filament\Resources\Section\CodecResource\Pages\CreateCodec; -class CreateAudioCodec extends CreateRecord +class CreateAudioCodec extends CreateCodec { protected static string $resource = AudioCodecResource::class; } diff --git a/app/Filament/Resources/Section/CodecResource/Pages/CreateCodec.php b/app/Filament/Resources/Section/CodecResource/Pages/CreateCodec.php index 1eacb3de..a3aad7a7 100644 --- a/app/Filament/Resources/Section/CodecResource/Pages/CreateCodec.php +++ b/app/Filament/Resources/Section/CodecResource/Pages/CreateCodec.php @@ -9,4 +9,20 @@ use Filament\Resources\Pages\CreateRecord; class CreateCodec extends CreateRecord { protected static string $resource = CodecResource::class; + + public function afterCreate() + { + clear_search_box_cache(); + $model = static::$resource::getModel(); + $table = (new $model)->getTable(); + clear_taxonomy_cache($table); + } + + protected function mutateFormDataBeforeCreate(array $data): array + { + if ($data['mode'] === null) { + $data['mode'] = 0; + } + return $data; + } } diff --git a/app/Filament/Resources/Section/CodecResource/Pages/EditCodec.php b/app/Filament/Resources/Section/CodecResource/Pages/EditCodec.php index 098f2b05..2b74b14e 100644 --- a/app/Filament/Resources/Section/CodecResource/Pages/EditCodec.php +++ b/app/Filament/Resources/Section/CodecResource/Pages/EditCodec.php @@ -23,6 +23,17 @@ class EditCodec extends EditRecord public function afterSave() { clear_search_box_cache(); + $model = static::$resource::getModel(); + $table = (new $model)->getTable(); + clear_taxonomy_cache($table); + } + + protected function mutateFormDataBeforeSave(array $data): array + { + if ($data['mode'] === null) { + $data['mode'] = 0; + } + return $data; } } diff --git a/app/Filament/Resources/Section/MediaResource/Pages/CreateMedia.php b/app/Filament/Resources/Section/MediaResource/Pages/CreateMedia.php index fff19031..85b0a82b 100644 --- a/app/Filament/Resources/Section/MediaResource/Pages/CreateMedia.php +++ b/app/Filament/Resources/Section/MediaResource/Pages/CreateMedia.php @@ -2,11 +2,12 @@ namespace App\Filament\Resources\Section\MediaResource\Pages; +use App\Filament\Resources\Section\CodecResource\Pages\CreateCodec; use App\Filament\Resources\Section\MediaResource; use Filament\Pages\Actions; use Filament\Resources\Pages\CreateRecord; -class CreateMedia extends CreateRecord +class CreateMedia extends CreateCodec { protected static string $resource = MediaResource::class; } diff --git a/app/Filament/Resources/Section/ProcessingResource/Pages/CreateProcessing.php b/app/Filament/Resources/Section/ProcessingResource/Pages/CreateProcessing.php index df5f2079..33dd1afa 100644 --- a/app/Filament/Resources/Section/ProcessingResource/Pages/CreateProcessing.php +++ b/app/Filament/Resources/Section/ProcessingResource/Pages/CreateProcessing.php @@ -5,8 +5,9 @@ namespace App\Filament\Resources\Section\ProcessingResource\Pages; use App\Filament\Resources\Section\ProcessingResource; use Filament\Pages\Actions; use Filament\Resources\Pages\CreateRecord; +use App\Filament\Resources\Section\CodecResource\Pages\CreateCodec; -class CreateProcessing extends CreateRecord +class CreateProcessing extends CreateCodec { protected static string $resource = ProcessingResource::class; } diff --git a/app/Filament/Resources/Section/SecondIconResource.php b/app/Filament/Resources/Section/SecondIconResource.php index 1aab9207..330b08cb 100644 --- a/app/Filament/Resources/Section/SecondIconResource.php +++ b/app/Filament/Resources/Section/SecondIconResource.php @@ -61,6 +61,12 @@ class SecondIconResource extends Resource ->label(__('label.second_icon.class_name')) ->helperText(__('label.second_icon.class_name_help')) , + Forms\Components\Select::make('mode') + ->options($modeOptions) + ->label(__('label.search_box.taxonomy.mode')) + ->helperText(__('label.search_box.taxonomy.mode_help')) + ->reactive() + , Forms\Components\Section::make(__('label.second_icon.select_section')) ->id("taxonomy_$torrentMode") ->schema($torrentTaxonomySchema) @@ -73,11 +79,7 @@ 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')) - , + ]); } diff --git a/app/Filament/Resources/Section/SourceResource/Pages/CreateSource.php b/app/Filament/Resources/Section/SourceResource/Pages/CreateSource.php index 4052c2b4..7e863ac5 100644 --- a/app/Filament/Resources/Section/SourceResource/Pages/CreateSource.php +++ b/app/Filament/Resources/Section/SourceResource/Pages/CreateSource.php @@ -5,8 +5,9 @@ namespace App\Filament\Resources\Section\SourceResource\Pages; use App\Filament\Resources\Section\SourceResource; use Filament\Pages\Actions; use Filament\Resources\Pages\CreateRecord; +use App\Filament\Resources\Section\CodecResource\Pages\CreateCodec; -class CreateSource extends CreateRecord +class CreateSource extends CreateCodec { protected static string $resource = SourceResource::class; } diff --git a/app/Filament/Resources/Section/StandardResource/Pages/CreateStandard.php b/app/Filament/Resources/Section/StandardResource/Pages/CreateStandard.php index 35107b16..e2e77456 100644 --- a/app/Filament/Resources/Section/StandardResource/Pages/CreateStandard.php +++ b/app/Filament/Resources/Section/StandardResource/Pages/CreateStandard.php @@ -5,8 +5,9 @@ namespace App\Filament\Resources\Section\StandardResource\Pages; use App\Filament\Resources\Section\StandardResource; use Filament\Pages\Actions; use Filament\Resources\Pages\CreateRecord; +use App\Filament\Resources\Section\CodecResource\Pages\CreateCodec; -class CreateStandard extends CreateRecord +class CreateStandard extends CreateCodec { protected static string $resource = StandardResource::class; } diff --git a/app/Filament/Resources/Section/TeamResource/Pages/CreateTeam.php b/app/Filament/Resources/Section/TeamResource/Pages/CreateTeam.php index aec6c158..5345fd44 100644 --- a/app/Filament/Resources/Section/TeamResource/Pages/CreateTeam.php +++ b/app/Filament/Resources/Section/TeamResource/Pages/CreateTeam.php @@ -5,8 +5,9 @@ namespace App\Filament\Resources\Section\TeamResource\Pages; use App\Filament\Resources\Section\TeamResource; use Filament\Pages\Actions; use Filament\Resources\Pages\CreateRecord; +use App\Filament\Resources\Section\CodecResource\Pages\CreateCodec; -class CreateTeam extends CreateRecord +class CreateTeam extends CreateCodec { protected static string $resource = TeamResource::class; } diff --git a/app/Models/SecondIcon.php b/app/Models/SecondIcon.php index 5927632b..32b174ac 100644 --- a/app/Models/SecondIcon.php +++ b/app/Models/SecondIcon.php @@ -16,12 +16,15 @@ class SecondIcon extends NexusModel { foreach (SearchBox::$taxonomies as $torrentField => $table) { $mode = $data['mode']; - if (empty($data[$torrentField][$mode])) { + if ($mode === null || empty($data[$torrentField][$mode])) { unset($data[$torrentField]); } else { $data[$torrentField] = $data[$torrentField][$mode]; } } + if ($data['mode'] === null) { + $data['mode'] = 0; + } return $data; } diff --git a/include/functions.php b/include/functions.php index 4121b361..cfd26355 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3265,12 +3265,17 @@ function genrelist($catmode = 1) { return $ret; } -function searchbox_item_list($table, $mode){ +function searchbox_item_list(string $table, int $mode){ global $Cache; $cacheKey = "{$table}_list_mode_{$mode}"; if (!$ret = $Cache->get_value($cacheKey)){ $ret = array(); - $res = sql_query("SELECT * FROM $table where (mode = '$mode' or mode = 0) ORDER BY sort_index, id"); + $sql = "SELECT * FROM $table"; + if ($mode > 0) { + $sql .= " where (mode = '$mode' or mode = 0)"; + } + $sql .= " ORDER BY sort_index, id"; + $res = sql_query($sql); while ($row = mysql_fetch_array($res)) $ret[] = $row; $Cache->cache_value($cacheKey, $ret, 3600); @@ -6066,6 +6071,8 @@ TD; ->where(function (\Illuminate\Database\Query\Builder $query) use ($mode) { return $query->where('mode', $mode)->orWhere('mode', 0); }) + ->orderBy('sort_index', 'asc') + ->orderBy('id', 'asc') ->get() ->chunk($searchBox->catsperrow); foreach ($taxonomyChunks as $chunk) { diff --git a/include/globalfunctions.php b/include/globalfunctions.php index dd612a99..49c3f2c7 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -972,7 +972,7 @@ function getDataTraffic(array $torrent, array $queries, array $user, $peer, $sna function clear_user_cache($uid, $passkey = '') { - do_log("uid: $uid, passkey: $passkey"); + do_log("clear_user_cache, uid: $uid, passkey: $passkey"); \Nexus\Database\NexusDB::cache_del("user_{$uid}_content"); \Nexus\Database\NexusDB::cache_del("user_{$uid}_roles"); \Nexus\Database\NexusDB::cache_del("announce_user_passkey_$uid");//announce.php @@ -984,6 +984,7 @@ function clear_user_cache($uid, $passkey = '') function clear_setting_cache() { + do_log("clear_setting_cache"); \Nexus\Database\NexusDB::cache_del('nexus_settings_in_laravel'); \Nexus\Database\NexusDB::cache_del('nexus_settings_in_nexus'); } @@ -993,15 +994,32 @@ function clear_setting_cache() */ function clear_category_cache() { + do_log("clear_category_cache"); \Nexus\Database\NexusDB::cache_del('category_content'); } +/** + * @see functions.php::searchbox_item_list() + */ +function clear_taxonomy_cache($table) +{ + do_log("clear_taxonomy_cache: $table"); + $list = \App\Models\SearchBox::query()->get(['id']); + foreach ($list as $item) { + \Nexus\Database\NexusDB::cache_del("{$table}_list_mode_{$item->id}"); + } + \Nexus\Database\NexusDB::cache_del("{$table}_list_mode_0"); +} + function clear_staff_message_cache() { do_log("clear_staff_message_cache"); \App\Repositories\MessageRepository::updateStaffMessageCountCache(false); } +/** + * @see functions.php::get_searchbox_value() + */ function clear_search_box_cache() { do_log("clear_search_box_cache"); diff --git a/lang/chs/lang_getrss.php b/lang/chs/lang_getrss.php index 788abde9..ab877aa0 100644 --- a/lang/chs/lang_getrss.php +++ b/lang/chs/lang_getrss.php @@ -39,7 +39,10 @@ $lang_getrss = array 'select_or' => "或", 'select_exact' => "准确", 'text_mode' => "", - 'text_keyword_note' => "只订阅标题中包含此关键字的项目" + 'text_keyword_note' => "只订阅标题中包含此关键字的项目", + 'row_sort' => '排序', + 'sort_sticky' => '置顶优先(默认)', + 'sort_newest' => '最新优先', ); ?> diff --git a/public/getrss.php b/public/getrss.php index e88aea34..1d9445a0 100644 --- a/public/getrss.php +++ b/public/getrss.php @@ -156,6 +156,11 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $query[] = "search_mode=".$search_mode; } } + if (!empty($_POST['sort']) && in_array($_POST['sort'], ['newest', 'sticky'])) { + $query[] = "sort=" . $_POST['sort']; + } else { + $query[] = "sort=sticky"; + } $inclbookmarked=intval($_POST['inclbookmarked'] ?? 0); if($inclbookmarked) { @@ -317,6 +322,14 @@ if (get_setting('main.spsct') == 'yes') {
+