change torrent pos_state to varchar, support more sticky level

This commit is contained in:
xiaomlove
2021-06-01 01:28:46 +08:00
parent 8e35dc0886
commit 5760adc0c4
17 changed files with 139 additions and 14 deletions
+23
View File
@@ -27,6 +27,20 @@ class Torrent extends NexusModel
'basic_source', 'basic_standard', 'basic_team',
];
const POS_STATE_STICKY_NONE = 'normal';
const POS_STATE_STICKY_ONE = 'sticky';
/**
* alphabet 'r' is after 'n' and before 's', so it will fit: order by pos_state desc,
* first sticky, then r_sticky, then normal
*/
const POS_STATE_STICKY_SECOND = 'r_sticky';
public static $posStates = [
self::POS_STATE_STICKY_NONE => ['text' => 'Normal', 'icon_counts' => 0],
self::POS_STATE_STICKY_SECOND => ['text' => 'Sticky second level', 'icon_counts' => 1],
self::POS_STATE_STICKY_ONE => ['text' => 'Sticky top level', 'icon_counts' => 2],
];
public static function getBasicInfo(): array
{
$result = [];
@@ -36,6 +50,15 @@ class Torrent extends NexusModel
return $result;
}
public static function listPosStates(): array
{
$result = self::$posStates;
foreach ($result as $key => &$value) {
$value['text'] = nexus_trans('torrent.pos_state_' . $key);
}
return $result;
}
public static function getFieldLabels(): array
{
$fields = ['comments', 'times_completed', 'peers_count', 'thank_users_count', 'numfiles'];