Move default template

This commit is contained in:
Knah Tsaeb 2024-12-06 11:34:32 +01:00
parent d575f3d890
commit 6c14601ff3
18 changed files with 10 additions and 9 deletions

View file

@ -38,11 +38,11 @@ class Cache {
* @param array $params An associative array * @param array $params An associative array
* @return bool Returns true if the cached page is still valid; otherwise, false * @return bool Returns true if the cached page is still valid; otherwise, false
*/ */
static function isValidPage(array $params): bool { static function isValidPage(array $params, string $theme): bool {
$mdModifiedTime = 0; $mdModifiedTime = 0;
// @todo add test if file exist // @todo add test if file exist
if ($params['type'] === 'home') { if ($params['type'] === 'home') {
$mdModifiedTime = filemtime(self::$templateDir . '/home.php'); $mdModifiedTime = filemtime(self::$templateDir . '/'.$theme.'/home.php');
} elseif ($params['type'] === 'post') { } elseif ($params['type'] === 'post') {
$postList = new Blogs($params); $postList = new Blogs($params);
$postAttr = $postList->returnPostInfo($params['slug']); $postAttr = $postList->returnPostInfo($params['slug']);

View file

@ -81,7 +81,7 @@ class Dev {
$postRegenCache = 'Post : regen'; $postRegenCache = 'Post : regen';
} }
require __DIR__ . '/../../template/dev.php'; require __DIR__ . '/../../template/'.$params['config']['theme'].'/dev.php';
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
return $content; return $content;

View file

@ -78,7 +78,7 @@ class Home {
$homeContent = preg_replace("/<% lastAppsUpdates %>/", $lastAppsUpdates, $homeContent); $homeContent = preg_replace("/<% lastAppsUpdates %>/", $lastAppsUpdates, $homeContent);
$homeContent = preg_replace("/<% lastPics %>/", $lastPics, $homeContent); $homeContent = preg_replace("/<% lastPics %>/", $lastPics, $homeContent);
require __DIR__ . '/../../template/home.php'; require __DIR__ . '/../../template/'.$params['config']['theme'].'/home.php';
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
return $content; return $content;

View file

@ -32,7 +32,7 @@ class Page {
$pageContent = RenderHtml::markdownToHtml($pageContent); $pageContent = RenderHtml::markdownToHtml($pageContent);
require __DIR__ . '/../../template/page.php'; require __DIR__ . '/../../template/'.$params['config']['theme'].'/page.php';
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();

View file

@ -26,7 +26,7 @@ class Post {
$this->title = $postInfo['title']; $this->title = $postInfo['title'];
$author = $params['config']['author']; $author = $params['config']['author'];
require __DIR__ . '/../../template/post.php'; require __DIR__ . '/../../template/'.$params['config']['theme'].'/post.php';
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
return $content; return $content;

View file

@ -39,7 +39,7 @@ class Posts {
$getPostList = $posts->getFilesForPage($params['page']); $getPostList = $posts->getFilesForPage($params['page']);
$pagination = $posts->makePagination($params['page']); $pagination = $posts->makePagination($params['page']);
require __DIR__ . '/../../template/posts.php'; require __DIR__ . '/../../template/'.$params['config']['theme'].'/posts.php';
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
return $content; return $content;

View file

@ -90,7 +90,7 @@ class Router {
$content = call_user_func_array(array($controller_instance, 'index'), $params); $content = call_user_func_array(array($controller_instance, 'index'), $params);
$title = $controller_instance->title(); $title = $controller_instance->title();
ob_start(); ob_start();
require_once __DIR__ . '/../template/bone.php'; require_once __DIR__ . '/../template/'.$params[0]['config']['theme'].'/bone.php';
$contentFinal = ob_get_contents(); $contentFinal = ob_get_contents();
ob_end_clean(); ob_end_clean();

View file

@ -7,6 +7,7 @@ class Config {
'siteName' => 'My super page', 'siteName' => 'My super page',
'author' => 'Me !!!', 'author' => 'Me !!!',
'useCache' => false, 'useCache' => false,
'theme' => 'default',
'postPerPage' => 5, 'postPerPage' => 5,
'numberOfLastItem' => 5, 'numberOfLastItem' => 5,
'debug' => false, 'debug' => false,

View file

@ -45,7 +45,7 @@ if (isset($match['params']['extraParams']['live']) && $match['params']['extraPar
} }
if ($match) { if ($match) {
if (Cache::isCache($match['params']) && Cache::isValidPage($match['params']) && Cache::isValidConfig() && $config['useCache'] === true) { if (Cache::isCache($match['params']) && Cache::isValidPage($match['params'], $config['theme']) && Cache::isValidConfig() && $config['useCache'] === true) {
$gen = Cache::getCache($match['params']['cacheName'], $match['params']['type']); $gen = Cache::getCache($match['params']['cacheName'], $match['params']['type']);
$genType = 'Serve from cache in : '; $genType = 'Serve from cache in : ';
} else { } else {