2024-03-14 23:58:11 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Theming;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
|
|
|
use App\Services\AuthService;
|
|
|
|
use App\Services\SortingService;
|
2024-03-16 19:36:51 +01:00
|
|
|
use App\Services\AssetService;
|
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;
|
|
|
|
|
|
|
|
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-03-16 19:36:51 +01:00
|
|
|
$this->pages = $pageRepository;
|
|
|
|
$this->auth = $authService;
|
|
|
|
$this->assets = $assetService;
|
|
|
|
$this->sort = $sortService;
|
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-03-18 23:14:17 +01:00
|
|
|
$page = $this->pages->getById('532E2250-F8CB-4E87-9782-8AFBEE88DD5E');
|
2024-03-15 21:28:26 +01:00
|
|
|
$data = $this->sort->page($page);
|
|
|
|
$pageData = [
|
|
|
|
"debug" => "true",
|
2024-03-16 19:36:51 +01:00
|
|
|
"theme" => $currentTheme,
|
2024-03-15 21:28:26 +01:00
|
|
|
"status" => $this->auth::status(),
|
|
|
|
"title" => "THEME PAGE",
|
|
|
|
"meta" => $data['meta'],
|
|
|
|
"menu" => $data['menu'],
|
|
|
|
"info" => $data['info'],
|
|
|
|
"media" => $data['media'],
|
|
|
|
"files" => $data['files'],
|
|
|
|
"content" => $data['content'],
|
|
|
|
"recent" => $data['recent'],
|
|
|
|
"feature" => $data['featured'],
|
|
|
|
"tags" => $data['tags'],
|
|
|
|
"dynamicRender" => $data['dynamicRender'],
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
case "tags":
|
2024-03-16 19:36:51 +01:00
|
|
|
$template = $currentTheme . '.tags';
|
2024-03-15 21:28:26 +01:00
|
|
|
$data = $this->sort->tags();
|
|
|
|
$pageData = [
|
|
|
|
'debug' => true, // for theme kit
|
2024-03-16 19:36:51 +01:00
|
|
|
'theme' => $currentTheme, // for theme kit
|
2024-03-15 21:28:26 +01:00
|
|
|
'title' => 'Pages Tagged as Tag',
|
|
|
|
'dynamicRender' => $data['info']['dynamicRender'],
|
2024-03-18 23:14:17 +01:00
|
|
|
'$pages' => $data['info']['tags'][3]['pages'],
|
2024-03-15 21:28:26 +01:00
|
|
|
'info' => $data['info'],
|
|
|
|
'menu' => $data['info']['menu'],
|
|
|
|
'media' => [
|
|
|
|
['file' => $data['info']['image'],
|
|
|
|
'type' => trim(pathinfo($data['info']['image'], PATHINFO_EXTENSION))]
|
|
|
|
],
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
case "archives":
|
|
|
|
case "archive":
|
2024-03-16 19:36:51 +01:00
|
|
|
$template = $currentTheme . '.archive';
|
2024-03-15 21:28:26 +01:00
|
|
|
$data = $this->sort->archive();
|
|
|
|
$pageData = [
|
|
|
|
'debug' => true, // for theme kit
|
2024-03-16 19:36:51 +01:00
|
|
|
'theme' => $currentTheme, // for theme kit
|
2024-03-15 21:28:26 +01:00
|
|
|
'title' => 'Archives',
|
|
|
|
'dynamicRender' => $data['info']['dynamicRender'],
|
|
|
|
'archive' => $data['archive'],
|
|
|
|
'info' => $data['info'],
|
|
|
|
'menu' => $data['info']['menu'],
|
|
|
|
'media' => [
|
|
|
|
['file' => $data['info']['image'],
|
|
|
|
'type' => trim(pathinfo($data['info']['image'], PATHINFO_EXTENSION))]
|
|
|
|
],
|
|
|
|
];
|
2024-03-15 03:03:46 +01:00
|
|
|
break;
|
|
|
|
}
|
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');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|