2024-03-14 23:58:11 +01:00
|
|
|
<?php
|
|
|
|
|
2024-05-09 19:24:12 +02:00
|
|
|
namespace App\Http\Controllers;
|
2024-03-14 23:58:11 +01:00
|
|
|
|
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
2024-05-13 06:14:53 +02:00
|
|
|
use App\Services\Assets\AssetService;
|
|
|
|
use App\Services\Data\AuthService;
|
|
|
|
use App\Services\Data\SortingService;
|
|
|
|
use App\Services\Data\ThemeService;
|
2024-03-14 23:58:11 +01:00
|
|
|
|
|
|
|
class ThemeController extends Controller
|
|
|
|
{
|
|
|
|
protected PageRepositoryInterface $pages;
|
|
|
|
protected AuthService $auth;
|
2024-03-16 19:36:51 +01:00
|
|
|
protected AssetService $assets;
|
2024-03-14 23:58:11 +01:00
|
|
|
protected SortingService $sort;
|
2024-04-25 23:03:06 +02:00
|
|
|
protected ThemeService $themes;
|
2024-03-14 23:58:11 +01:00
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
PageRepositoryInterface $pageRepository,
|
|
|
|
AuthService $authService,
|
2024-03-16 19:36:51 +01:00
|
|
|
AssetService $assetService,
|
2024-03-14 23:58:11 +01:00
|
|
|
SortingService $sortService,
|
2024-04-25 23:03:06 +02:00
|
|
|
ThemeService $themeService,
|
2024-03-14 23:58:11 +01:00
|
|
|
) {
|
2024-03-16 19:36:51 +01:00
|
|
|
$this->pages = $pageRepository;
|
|
|
|
$this->auth = $authService;
|
|
|
|
$this->assets = $assetService;
|
|
|
|
$this->sort = $sortService;
|
2024-04-25 23:03:06 +02:00
|
|
|
$this->themes = $themeService;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function start()
|
|
|
|
{
|
|
|
|
if ($this->auth::status()) {
|
|
|
|
return view('theme.start', [
|
|
|
|
"status" => $this->auth::status(),
|
|
|
|
"title" => "Fipamo Theme Kit",
|
|
|
|
"pages" => $this->themes->getCustomViews('page')
|
|
|
|
]);
|
|
|
|
} else {
|
2024-05-06 23:09:24 +02:00
|
|
|
return redirect('dashboard');
|
2024-04-25 23:03:06 +02:00
|
|
|
}
|
2024-03-14 23:58:11 +01:00
|
|
|
}
|
|
|
|
|
2024-03-15 03:03:46 +01:00
|
|
|
public function getView($view = 'index')
|
2024-03-14 23:58:11 +01:00
|
|
|
{
|
2024-03-16 19:36:51 +01:00
|
|
|
//move assets to theme testing dir
|
|
|
|
$this->assets->moveToTheme();
|
|
|
|
$currentTheme = $this->assets->getCurrentTheme();
|
2024-03-15 21:28:26 +01:00
|
|
|
$template;
|
|
|
|
$pageData = [];
|
2024-03-15 03:03:46 +01:00
|
|
|
switch ($view) {
|
2024-03-15 21:28:26 +01:00
|
|
|
case "index":
|
2024-03-15 03:03:46 +01:00
|
|
|
case "page":
|
2024-03-15 21:28:26 +01:00
|
|
|
$view == 'index' ?
|
2024-03-16 19:36:51 +01:00
|
|
|
$template = $currentTheme . '.index' :
|
|
|
|
$template = $currentTheme . '.page';
|
2024-04-23 21:41:41 +02:00
|
|
|
$page = $this->pages->getById('F4429D34-25E7-4CA9-9B0A-742810277505');
|
2024-03-28 23:42:37 +01:00
|
|
|
$pageData = $this->sort->page($page);
|
2024-03-15 21:28:26 +01:00
|
|
|
break;
|
|
|
|
case "tags":
|
2024-03-16 19:36:51 +01:00
|
|
|
$template = $currentTheme . '.tags';
|
2024-03-28 23:42:37 +01:00
|
|
|
$pageData = $this->sort->tags();
|
2024-03-15 21:28:26 +01:00
|
|
|
break;
|
|
|
|
case "archives":
|
|
|
|
case "archive":
|
2024-03-16 19:36:51 +01:00
|
|
|
$template = $currentTheme . '.archive';
|
2024-03-28 23:42:37 +01:00
|
|
|
$pageData = $this->sort->archive();
|
2024-03-15 03:03:46 +01:00
|
|
|
break;
|
2024-04-25 23:03:06 +02:00
|
|
|
default:
|
|
|
|
$template = $currentTheme . '.' . $view;
|
|
|
|
$page = $this->pages->getById('F4429D34-25E7-4CA9-9B0A-742810277505');
|
|
|
|
$pageData = $this->sort->page($page);
|
2024-03-15 03:03:46 +01:00
|
|
|
}
|
2024-03-14 23:58:11 +01:00
|
|
|
if ($this->auth::status()) {
|
2024-03-15 21:28:26 +01:00
|
|
|
return view($template, $pageData);
|
2024-03-14 23:58:11 +01:00
|
|
|
} else {
|
|
|
|
return redirect('dashboard/start');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|