forked from projects/fipamo
ro
6cb9631a46
a basic preview engine has been added to ease the process of editing pages. currently it previews all basic templates and custom created pages this is will replace the external fipamo theme kit tool, which will be archived
84 lines
2.6 KiB
PHP
84 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Theming;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Interfaces\PageRepositoryInterface;
|
|
use App\Services\AuthService;
|
|
use App\Services\SortingService;
|
|
use App\Services\AssetService;
|
|
use App\Services\ThemeService;
|
|
|
|
class ThemeController extends Controller
|
|
{
|
|
protected PageRepositoryInterface $pages;
|
|
protected AuthService $auth;
|
|
protected AssetService $assets;
|
|
protected SortingService $sort;
|
|
protected ThemeService $themes;
|
|
|
|
public function __construct(
|
|
PageRepositoryInterface $pageRepository,
|
|
AuthService $authService,
|
|
AssetService $assetService,
|
|
SortingService $sortService,
|
|
ThemeService $themeService,
|
|
) {
|
|
$this->pages = $pageRepository;
|
|
$this->auth = $authService;
|
|
$this->assets = $assetService;
|
|
$this->sort = $sortService;
|
|
$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 {
|
|
return redirect('back.login');
|
|
}
|
|
}
|
|
|
|
public function getView($view = 'index')
|
|
{
|
|
//move assets to theme testing dir
|
|
$this->assets->moveToTheme();
|
|
$currentTheme = $this->assets->getCurrentTheme();
|
|
$template;
|
|
$pageData = [];
|
|
switch ($view) {
|
|
case "index":
|
|
case "page":
|
|
$view == 'index' ?
|
|
$template = $currentTheme . '.index' :
|
|
$template = $currentTheme . '.page';
|
|
$page = $this->pages->getById('F4429D34-25E7-4CA9-9B0A-742810277505');
|
|
$pageData = $this->sort->page($page);
|
|
break;
|
|
case "tags":
|
|
$template = $currentTheme . '.tags';
|
|
$pageData = $this->sort->tags();
|
|
break;
|
|
case "archives":
|
|
case "archive":
|
|
$template = $currentTheme . '.archive';
|
|
$pageData = $this->sort->archive();
|
|
break;
|
|
default:
|
|
$template = $currentTheme . '.' . $view;
|
|
$page = $this->pages->getById('F4429D34-25E7-4CA9-9B0A-742810277505');
|
|
$pageData = $this->sort->page($page);
|
|
}
|
|
if ($this->auth::status()) {
|
|
return view($template, $pageData);
|
|
} else {
|
|
return redirect('dashboard/start');
|
|
}
|
|
}
|
|
}
|