2024-03-19 02:48:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Front;
|
|
|
|
|
2024-05-06 21:37:26 +02:00
|
|
|
use App\Services\SettingsService;
|
2024-03-19 02:48:59 +01:00
|
|
|
use App\Http\Controllers\Controller;
|
2024-05-06 21:37:26 +02:00
|
|
|
use App\Services\AuthService;
|
2024-05-06 23:09:24 +02:00
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
|
|
|
use App\Services\SortingService;
|
|
|
|
use App\Services\AssetService;
|
|
|
|
|
|
|
|
use function _\find;
|
2024-03-19 02:48:59 +01:00
|
|
|
|
|
|
|
class StartController extends Controller
|
|
|
|
{
|
2024-04-16 23:36:57 +02:00
|
|
|
protected $settings;
|
2024-05-06 21:37:26 +02:00
|
|
|
protected $auth;
|
2024-05-06 23:09:24 +02:00
|
|
|
protected PageRepositoryInterface $pages;
|
|
|
|
protected AssetService $assets;
|
|
|
|
protected SortingService $sort;
|
2024-04-16 23:36:57 +02:00
|
|
|
|
2024-05-06 23:09:24 +02:00
|
|
|
public function __construct(
|
|
|
|
PageRepositoryInterface $pageRepository,
|
|
|
|
SettingsService $settingsService,
|
|
|
|
AuthService $authService,
|
|
|
|
AssetService $assetService,
|
|
|
|
SortingService $sortService,
|
|
|
|
) {
|
|
|
|
$this->pages = $pageRepository;
|
2024-05-06 21:37:26 +02:00
|
|
|
$this->settings = $settingsService;
|
|
|
|
$this->auth = $authService;
|
2024-05-06 23:09:24 +02:00
|
|
|
$this->assets = $assetService;
|
|
|
|
$this->sort = $sortService;
|
2024-03-19 02:48:59 +01:00
|
|
|
}
|
|
|
|
|
2024-05-06 21:37:26 +02:00
|
|
|
public function index($first = 00, $second = 00, $third = 00)
|
2024-03-19 02:48:59 +01:00
|
|
|
{
|
2024-05-06 23:09:24 +02:00
|
|
|
$global = $this->settings->getGlobal();
|
|
|
|
$currentTheme = $this->assets->getCurrentTheme();
|
|
|
|
$template;
|
|
|
|
$pageData = [];
|
|
|
|
$pages = $this->pages->getAll();
|
2024-04-16 23:36:57 +02:00
|
|
|
//check if configs are present
|
|
|
|
if (file_exists(env('FOLKS_PATH')) && file_exists(env('SETTINGS_PATH'))) {
|
2024-05-06 21:37:26 +02:00
|
|
|
if ($global['dynamicRender'] == 'true') {
|
|
|
|
if (is_numeric($first)) {
|
2024-05-06 23:09:24 +02:00
|
|
|
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'];
|
|
|
|
}
|
2024-05-06 21:37:26 +02:00
|
|
|
} else {
|
2024-05-06 23:09:24 +02:00
|
|
|
if ($first == null || $first == '') {
|
|
|
|
$page = $pages->where('id', 1)->first();
|
|
|
|
$pageData = $this->sort->page($page);
|
|
|
|
$template = $currentTheme . '.index';
|
|
|
|
} else {
|
|
|
|
}
|
2024-05-06 21:37:26 +02:00
|
|
|
}
|
2024-05-06 23:09:24 +02:00
|
|
|
return view($template, $pageData);
|
2024-05-06 21:37:26 +02:00
|
|
|
} else {
|
|
|
|
return response()->file('../public/index.html');
|
|
|
|
}
|
2024-04-16 23:36:57 +02:00
|
|
|
} else {
|
|
|
|
return view('back.init', ["status" => false, "title" => "Set Up"]);
|
|
|
|
}
|
2024-03-19 02:48:59 +01:00
|
|
|
}
|
2024-05-06 23:09:24 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2024-03-19 02:48:59 +01:00
|
|
|
}
|