taxonomy create/edit redirect

This commit is contained in:
xiaomlove
2022-11-09 21:56:03 +08:00
parent b92b911b1e
commit 6479f0a799
17 changed files with 105 additions and 20 deletions

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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'))
,
]);
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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");

View File

@@ -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' => '最新优先',
);
?>

View File

@@ -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') {
<input type="radio" name="inclbookmarked" id="inclbookmarked0" value="0" checked="checked" /><label for="inclbookmarked0"><?php echo $lang_getrss['text_all']?></label>&nbsp;<input type="radio" name="inclbookmarked" id="inclbookmarked1" value="1" /><label for="inclbookmarked1"><?php echo $lang_getrss['text_only_bookmarked']?></label><div><?php echo $lang_getrss['text_show_bookmarked_note']?></div>
</td>
</tr>
<tr>
<td class="rowhead"><?php echo $lang_getrss['row_sort']?>
</td>
<td class="rowfollow" align="left">
<label><input type="radio" name="sort" value="sticky"><?php echo $lang_getrss['sort_sticky']?></label>
<label><input type="radio" name="sort" value="newest"><?php echo $lang_getrss['sort_newest']?></label>
</td>
</tr>
<tr>
<td class="rowhead"><?php echo $lang_getrss['row_item_title_type']?>
</td>

View File

@@ -94,7 +94,7 @@ if ($approvalStatusNoneVisible == 'no' && !user_can('staffmem')) {
function get_where($tablename = "sources", $itemname = "source", $getname = "sou")
{
global $where;
$items = searchbox_item_list($tablename);
$items = searchbox_item_list($tablename, 0);
$whereitemina = array();
foreach ($items as $item)
{
@@ -118,8 +118,14 @@ get_where("teams", "team", "tea");
get_where("audiocodecs", "audiocodec", "aud");
if ($where)
$where = "WHERE ".$where;
$query = "SELECT torrents.id, torrents.category, torrents.name, torrents.small_descr, torrents.descr, torrents.info_hash, torrents.size, torrents.added, torrents.anonymous, users.username AS username, categories.id AS cat_id, categories.name AS cat_name FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where ORDER BY torrents.added DESC LIMIT $limit";
if (!empty($_GET['sort']) && $_GET['sort'] == 'newest') {
$sort = "id desc";
} else {
$sort = "pos_state desc, id desc";
}
$query = "SELECT torrents.id, torrents.category, torrents.name, torrents.small_descr, torrents.descr, torrents.info_hash, torrents.size, torrents.added, torrents.anonymous, users.username AS username, categories.id AS cat_id, categories.name AS cat_name FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where ORDER BY $sort LIMIT $limit";
$list = \Nexus\Database\NexusDB::select($query);
$list = apply_filter('torrent_list', $list, $startindex == 0 ? 0 : 1, null);
$torrentRep = new \App\Repositories\TorrentRepository();
$url = get_protocol_prefix().$BASEURL;
$year = substr($datefounded, 0, 4);

View File

@@ -207,7 +207,7 @@ elseif ($CURUSER['notifs']){
$special_state = 5;
elseif (strpos($CURUSER['notifs'], "[spstate=6]") !== false)
$special_state = 6;
elseif (strpos($CURUSER['notifs'], "[spstate=6]") !== false)
elseif (strpos($CURUSER['notifs'], "[spstate=7]") !== false)
$special_state = 7;
}