fipamo/app/Http/Controllers/ThemeController.php
ro ed6f028598
added layout varible to sorting, updated ignore
data sorting needed a new variable to differentiate between index page
rendering and standard page rendering, so that was added to the return
as well as updating the render script to include the variable that
wasn't being added for tags

also updated the git ignore file to ignore global images that are not
used by the base system. the script theme folder needs to be ignore as
well as that is going to updated by the theme itself for front end
coding and not used by the system
2024-06-26 14:08:53 -06:00

84 lines
2.7 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Interfaces\PageRepositoryInterface;
use App\Services\Assets\AssetService;
use App\Interfaces\MemberRepositoryInterface;
use App\Services\Data\SortingService;
use App\Services\Data\ThemeService;
class ThemeController extends Controller
{
protected PageRepositoryInterface $pages;
protected MemberRepositoryInterface $member;
protected AssetService $assets;
protected SortingService $sort;
protected ThemeService $themes;
public function __construct(
PageRepositoryInterface $pageRepository,
MemberRepositoryInterface $memberRepo,
AssetService $assetService,
SortingService $sortService,
ThemeService $themeService,
) {
$this->pages = $pageRepository;
$this->member = $memberRepo;
$this->assets = $assetService;
$this->sort = $sortService;
$this->themes = $themeService;
}
public function start()
{
if ($this->member::status()) {
return view('theme.start', [
"status" => $this->member::status(),
"title" => "Fipamo Theme Kit",
"pages" => $this->themes->getCustomViews('page')
]);
} else {
return redirect('dashboard');
}
}
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';
//TODO: Get rid of hard link page IDS
$page = $this->pages->getById('F791DED9-0359-4662-8976-4C474803D2C6');
$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 . '.index';
$page = $this->pages->getById('26245BDB-1A38-4455-80A2-7A03DE26EE33');
$pageData = $this->sort->page($page);
}
if ($this->member::status()) {
return view($template, $pageData);
} else {
return redirect('dashboard/start');
}
}
}