22{
23 public const DEFAULT_SORTATION = self::LAST_POST_DESC;
24
25 case SUBJECT_ASC = 1;
26 case SUBJECT_DESC = 2;
27 case LAST_POST_ASC = 3;
28 case LAST_POST_DESC = 4;
29 case RATING_ASC = 5;
30 case RATING_DESC = 6;
31
33 {
34 return match($this) {
35 self::SUBJECT_ASC => 'forums_thread_sorting_asc',
36 self::SUBJECT_DESC => 'forums_thread_sorting_dsc',
37 self::LAST_POST_ASC => 'forums_last_posting_asc',
38 self::LAST_POST_DESC => 'forums_last_posting_dsc',
39 self::RATING_ASC => 'forums_rating_asc',
40 self::RATING_DESC => 'forums_rating_dsc',
41 };
42 }
43
44 public function field(): string
45 {
46 return match($this) {
47 self::SUBJECT_ASC, self::SUBJECT_DESC => 'thr_subject',
48 self::LAST_POST_ASC, self::LAST_POST_DESC => 'lp_date',
49 self::RATING_ASC, self::RATING_DESC => 'rating',
50 };
51 }
52
53 public function direction(): string
54 {
55 return match($this) {
56 self::SUBJECT_ASC, self::LAST_POST_ASC, self::RATING_ASC => 'asc',
57 self::SUBJECT_DESC, self::LAST_POST_DESC, self::RATING_DESC => 'desc',
58 };
59 }
60}