array_intersect_key($activity, array_flip(self::FIELDS))]; } $result = []; foreach (self::LANGUAGES as $lang) { foreach (self::FIELDS as $field) $result[$lang][$field] = (string) ($stored[$lang][$field] ?? ''); } return $result; } /** Upgrade invite (type 10) shows only body text; it has no title in any language. */ public const CONTENT_ONLY = [10]; public static function fields(int $type): array { return in_array($type, self::CONTENT_ONLY, true) ? ['content'] : self::FIELDS; } public static function select(array $activity, string $lang): ?array { $text = self::all($activity)[$lang] ?? null; if ($text && in_array((int)($activity['type'] ?? 0), self::CONTENT_ONLY, true)) { return trim($text['content']) === '' ? null : ['lang' => $lang, 'content' => $text['content']]; } if (!$text || trim($text['title']) === '') return null; return ['lang' => $lang, 'title' => $text['title'], 'content' => $text['content'] === '' ? null : $text['content']]; } }