current state

This commit is contained in:
2026-02-08 10:42:01 +01:00
parent 0a4372c40d
commit e055af9248
70 changed files with 4882 additions and 330 deletions

View File

@@ -24,15 +24,15 @@ class LegacyService
$featured = null;
$memberFeatured = null;
try {
$featured = DB::connection('legacy')->table('featured_works as fw')
try {
$featured = DB::table('featured_works as fw')
->leftJoin('wallz as w', 'fw.artwork_id', '=', 'w.id')
->leftJoin('users as u', 'w.user_id', '=', 'u.user_id')
->select('w.id', 'w.name', 'w.picture', 'u.uname', 'fw.post_date')
->orderByDesc('fw.post_date')
->first();
$memberFeatured = DB::connection('legacy')->table('users_opinions as o')
$memberFeatured = DB::table('users_opinions as o')
->leftJoin('wallz as w', 'o.artwork_id', '=', 'w.id')
->leftJoin('users as u', 'w.user_id', '=', 'u.user_id')
->select(DB::raw('COUNT(*) AS votes'), 'w.id', 'w.name', 'w.picture', 'u.uname')
@@ -80,9 +80,9 @@ class LegacyService
if (empty($uploads)) {
try {
$uploads = DB::connection('legacy')->table('wallz as w')
$uploads = DB::table('wallz as w')
->leftJoin('users as u', 'w.user_id', '=', 'u.user_id')
->leftJoin('artworks_categories as c', 'w.category', '=', 'c.category_id')
->leftJoin('categories as c', 'w.category', '=', 'c.id')
->where('w.approved', 1)
->orderByDesc('w.datum')
->limit(20)
@@ -93,7 +93,7 @@ class LegacyService
'name' => $row->name,
'picture' => $row->picture,
'uname' => $row->uname,
'category_name' => $row->category_name ?? '',
'category_name' => $row->category_name ?? $row->name ?? '',
];
})
->toArray();
@@ -119,8 +119,8 @@ class LegacyService
public function forumNews(): array
{
try {
return DB::connection('legacy')->table('forum_topics as t1')
try {
return DB::table('forum_topics as t1')
->leftJoin('users as t2', 't1.user_id', '=', 't2.user_id')
->select(
't1.topic_id',
@@ -144,7 +144,7 @@ class LegacyService
public function ourNews(): array
{
try {
return DB::connection('legacy')->table('news as t1')
return DB::table('news as t1')
->join('news_categories as t2', 't1.category_id', '=', 't2.category_id')
->join('users as t3', 't1.user_id', '=', 't3.user_id')
->select(
@@ -170,7 +170,7 @@ class LegacyService
public function latestForumActivity(): array
{
try {
return DB::connection('legacy')->table('forum_topics as t1')
return DB::table('forum_topics as t1')
->select(
't1.topic_id',
't1.topic',
@@ -191,11 +191,11 @@ class LegacyService
public function browseGallery(int $perPage = 50)
{
try {
return DB::connection('legacy')->table('wallz as w')
->leftJoin('artworks_categories as c', 'w.category', '=', 'c.category_id')
try {
return DB::table('wallz as w')
->leftJoin('categories as c', 'w.category', '=', 'c.id')
->leftJoin('users as u', 'w.user_id', '=', 'u.user_id')
->select('w.id', 'w.name', 'w.picture', 'w.category', 'w.datum', 'c.category_name', 'u.uname')
->select('w.id', 'w.name', 'w.picture', 'w.category', 'w.datum', DB::raw('c.name as category_name'), 'u.uname')
->where('w.approved', 1)
->where('w.public', 'Y')
->orderByDesc('w.datum')
@@ -226,9 +226,9 @@ class LegacyService
}
try {
$category = DB::connection('legacy')->table('artworks_categories')
->select('category_id', 'category_name', 'description', 'rootid', 'section_id')
->where('category_id', $id)
$category = DB::table('categories')
->select(DB::raw('id as category_id'), DB::raw('name as category_name'), 'description', DB::raw('parent_id as rootid'), DB::raw('content_type_id as section_id'))
->where('id', $id)
->first();
} catch (\Throwable $e) {
$category = null;
@@ -240,10 +240,10 @@ class LegacyService
$perPage = 40;
try {
$base = DB::connection('legacy')->table('wallz as t1')
->select('t1.id', 't1.name', 't1.picture', 't3.uname', 't1.category', 't2.category_name')
->join('artworks_categories as t2', 't1.category', '=', 't2.category_id')
try {
$base = DB::table('wallz as t1')
->select('t1.id', 't1.name', 't1.picture', 't3.uname', 't1.category', DB::raw('t2.name as category_name'))
->join('categories as t2', 't1.category', '=', 't2.id')
->leftJoin('users as t3', 't1.user_id', '=', 't3.user_id')
->where('t1.approved', 1)
->where(function ($q) use ($id, $category) {
@@ -289,23 +289,23 @@ class LegacyService
$artworks = null;
}
try {
$subcategories = DB::connection('legacy')->table('artworks_categories')
->select('category_id', 'category_name')
->where('rootid', $id)
try {
$subcategories = DB::table('categories')
->select(DB::raw('id as category_id'), DB::raw('name as category_name'))
->where('parent_id', $id)
->orderBy('category_name')
->get();
if ($subcategories->isEmpty() && $category->rootid) {
$subcategories = DB::connection('legacy')->table('artworks_categories')
->select('category_id', 'category_name')
->where('rootid', $category->rootid)
if ($subcategories->isEmpty() && $category->rootid) {
$subcategories = DB::table('categories')
->select(DB::raw('id as category_id'), DB::raw('name as category_name'))
->where('parent_id', $category->rootid)
->orderBy('category_name')
->get();
}
if ($subcategories->isEmpty()) {
$subcategories = DB::connection('legacy')->table('skupine')
if ($subcategories->isEmpty()) {
$subcategories = DB::table('skupine')
->select('category_id', 'category_name')
->where('rootid', $id)
->orderBy('category_name')
@@ -313,7 +313,7 @@ class LegacyService
}
} catch (\Throwable $e) {
try {
$subcategories = DB::connection('legacy')->table('skupine')
$subcategories = DB::table('skupine')
->select('category_id', 'category_name')
->where('rootid', $id)
->orderBy('category_name')
@@ -341,15 +341,15 @@ class LegacyService
public function browseCategories()
{
try {
$categories = DB::connection('legacy')->table('artworks_categories')
->select('category_id', 'category_name', 'description')
->where('section_id', 0)
->where('rootid', 0)
->orderBy('category_id')
$categories = DB::table('categories')
->select(DB::raw('id as category_id'), DB::raw('name as category_name'), 'description')
->where('content_type_id', 0)
->where(DB::raw('parent_id'), 0)
->orderBy('id')
->get();
if ($categories->isEmpty()) {
$categories = DB::connection('legacy')->table('skupine')
$categories = DB::table('skupine')
->select('category_id', 'category_name', 'description')
->where('section_id', 0)
->where('rootid', 0)
@@ -358,7 +358,7 @@ class LegacyService
}
} catch (\Throwable $e) {
try {
$categories = DB::connection('legacy')->table('skupine')
$categories = DB::table('skupine')
->select('category_id', 'category_name', 'description')
->where('section_id', 0)
->where('rootid', 0)
@@ -373,14 +373,14 @@ class LegacyService
if ($categories->isNotEmpty()) {
$ids = $categories->pluck('category_id')->unique()->values()->all();
try {
$subs = DB::connection('legacy')->table('artworks_categories')
->select('category_id', 'category_name', 'picture', 'section_id')
->whereIn('section_id', $ids)
$subs = DB::table('categories')
->select(DB::raw('id as category_id'), DB::raw('name as category_name'), 'image as picture', DB::raw('content_type_id as section_id'))
->whereIn('content_type_id', $ids)
->orderBy('category_name')
->get();
if ($subs->isEmpty()) {
$subs = DB::connection('legacy')->table('skupine')
$subs = DB::table('skupine')
->select('category_id', 'category_name', 'picture', 'section_id')
->whereIn('section_id', $ids)
->orderBy('category_name')
@@ -405,7 +405,7 @@ class LegacyService
public function forumIndex()
{
try {
$topics = DB::connection('legacy')->table('forum_topics as t')
$topics = DB::table('forum_topics as t')
->select(
't.topic_id',
't.topic',
@@ -435,7 +435,7 @@ class LegacyService
public function forumTopic(int $topic_id, int $page = 1)
{
try {
$topic = DB::connection('legacy')->table('forum_topics')->where('topic_id', $topic_id)->first();
$topic = DB::table('forum_topics')->where('topic_id', $topic_id)->first();
} catch (\Throwable $e) {
$topic = null;
}
@@ -445,7 +445,7 @@ class LegacyService
}
try {
$subtopics = DB::connection('legacy')->table('forum_topics as t')
$subtopics = DB::table('forum_topics as t')
->leftJoin('users as u', 't.user_id', '=', 'u.user_id')
->select(
't.topic_id',
@@ -478,7 +478,7 @@ class LegacyService
$sort = strtolower(request()->query('sort', 'desc')) === 'asc' ? 'asc' : 'desc';
try {
$posts = DB::connection('legacy')->table('forum_posts as p')
$posts = DB::table('forum_posts as p')
->leftJoin('users as u', 'p.user_id', '=', 'u.user_id')
->select('p.id', 'p.message', 'p.post_date', 'u.uname', 'u.user_id', 'u.icon', 'u.eicon')
->where('p.topic_id', $topic->topic_id)
@@ -491,7 +491,7 @@ class LegacyService
if (! $posts || $posts->total() === 0) {
try {
$posts = DB::connection('legacy')->table('forum_posts as p')
$posts = DB::table('forum_posts as p')
->leftJoin('users as u', 'p.user_id', '=', 'u.user_id')
->select('p.id', 'p.message', 'p.post_date', 'u.uname', 'u.user_id', 'u.icon', 'u.eicon')
->where('p.tid', $topic->topic_id)
@@ -529,10 +529,10 @@ class LegacyService
public function getArtwork(int $id)
{
try {
$row = DB::connection('legacy')->table('wallz as w')
$row = DB::table('wallz as w')
->leftJoin('users as u', 'w.user_id', '=', 'u.user_id')
->leftJoin('artworks_categories as c', 'w.category', '=', 'c.category_id')
->select('w.*', 'u.uname', 'c.category_name')
->leftJoin('categories as c', 'w.category', '=', 'c.id')
->select('w.*', 'u.uname', DB::raw('c.name as category_name'))
->where('w.id', $id)
->first();
} catch (\Throwable $e) {
@@ -567,7 +567,7 @@ class LegacyService
// additional stats (best-effort)
try {
$num_downloads = DB::connection('legacy')->table('artworks_downloads')
$num_downloads = DB::table('artworks_downloads')
->where('date', DB::raw('CURRENT_DATE'))
->where('artwork_id', $row->id)
->count();
@@ -576,7 +576,7 @@ class LegacyService
}
try {
$monthly_downloads = DB::connection('legacy')->table('monthly_downloads')
$monthly_downloads = DB::table('monthly_downloads')
->where('fname', $row->id)
->count();
} catch (\Throwable $e) {
@@ -584,7 +584,7 @@ class LegacyService
}
try {
$num_comments = DB::connection('legacy')->table('artworks_comments')
$num_comments = DB::table('artwork_comments')
->where('name', $row->id)
->where('author', '<>', '')
->count();
@@ -593,7 +593,7 @@ class LegacyService
}
try {
$num_favourites = DB::connection('legacy')->table('favourites')
$num_favourites = DB::table('favourites')
->where('artwork_id', $row->id)
->count();
} catch (\Throwable $e) {
@@ -601,7 +601,7 @@ class LegacyService
}
try {
$featured = DB::connection('legacy')->table('featured_works')
$featured = DB::table('featured_works')
->where('rootid', $row->rootid ?? 0)
->where('artwork_id', $row->id)
->orderByDesc('type')