forked from projects/fipamo
ro
36d04c8f68
service classes are beginning to swell as there functionality is being fleshed out, so a new organizational structure was needed to make sure class sizes don't become too large and to increase site managability and legibilty as more features get added and the code base grows. data is for retrieving, managing site information, assets interact with external files and upkeep is for maintenance. some additional tweaks were also made to the options menu template to prep it for it's transition to a toolbar component
100 lines
3.6 KiB
PHP
100 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
|
use App\Services\Assets\AssetService;
|
|
use App\Services\Data\SettingsService;
|
|
use App\Services\Data\AuthService;
|
|
use App\Services\Data\SortingService;
|
|
|
|
use function _\find;
|
|
|
|
class FrontController extends Controller
|
|
{
|
|
protected $settings;
|
|
protected $auth;
|
|
protected PageRepositoryInterface $pages;
|
|
protected AssetService $assets;
|
|
protected SortingService $sort;
|
|
|
|
public function __construct(
|
|
PageRepositoryInterface $pageRepository,
|
|
SettingsService $settingsService,
|
|
AuthService $authService,
|
|
AssetService $assetService,
|
|
SortingService $sortService,
|
|
) {
|
|
$this->pages = $pageRepository;
|
|
$this->settings = $settingsService;
|
|
$this->auth = $authService;
|
|
$this->assets = $assetService;
|
|
$this->sort = $sortService;
|
|
}
|
|
|
|
//REFACTOR: there is some method overlap between index and pages, so that needs to be addressed
|
|
public function index($first = 00, $second = 00, $third = 00)
|
|
{
|
|
$global = $this->settings->getGlobal();
|
|
$currentTheme = $this->assets->getCurrentTheme();
|
|
$template;
|
|
$pageData = [];
|
|
$pages = $this->pages->getAll();
|
|
//check if configs are present
|
|
if (file_exists(env('FOLKS_PATH')) && file_exists(env('SETTINGS_PATH'))) {
|
|
if ($global['dynamicRender'] == 'true') {
|
|
if (is_numeric($first)) {
|
|
if ($first == 00 || !isset($first)) {
|
|
$page = $pages->where('id', 1)->first();
|
|
$pageData = $this->sort->page($page);
|
|
$template = $currentTheme . '.index';
|
|
} else {
|
|
$page = $this->pages->getBySlug($third);
|
|
$pageData = $this->sort->page($page);
|
|
$template = $currentTheme . '.' . $page['layout'];
|
|
}
|
|
} else {
|
|
if ($first == null || $first == '') {
|
|
$page = $pages->where('id', 1)->first();
|
|
$pageData = $this->sort->page($page);
|
|
$template = $currentTheme . '.index';
|
|
} else {
|
|
}
|
|
}
|
|
return view($template, $pageData);
|
|
} else {
|
|
return response()->file('../public/index.html');
|
|
}
|
|
} else {
|
|
return view('back.init', ["status" => false, "title" => "Set Up"]);
|
|
}
|
|
}
|
|
|
|
public function page($first = 00, $second = 00, $third = 00)
|
|
{
|
|
$currentTheme = $this->assets->getCurrentTheme();
|
|
switch ($first) {
|
|
case 'archive':
|
|
case 'archives':
|
|
$template = $currentTheme . '.archive';
|
|
$pageData = $this->sort->archive();
|
|
break;
|
|
case 'tags':
|
|
$template = $currentTheme . '.tags';
|
|
$tags = $this->sort->tags(false);
|
|
$tagData = find($tags['tags'], ['tag_name' => $second]);
|
|
$pageData = [
|
|
'theme' => $currentTheme, // for theme kit
|
|
'title' => 'Pages Tagged as ' . $second,
|
|
'dynamicRender' => $tags['dynamicRender'],
|
|
'info' => $tags['info'],
|
|
'menu' => $tags['menu'],
|
|
'pages' => $tagData['pages'],
|
|
'media' => $tags['media'],
|
|
];
|
|
break;
|
|
}
|
|
return view($template, $pageData);
|
|
}
|
|
}
|