diff --git a/.htaccess b/.htaccess
index bab9358..9145ea9 100644
--- a/.htaccess
+++ b/.htaccess
@@ -33,6 +33,11 @@ AddType application/wasm .wasm
AddType video/x-matroska .mkv
AddType text/css .css
+# Special case for Plik
+
+ Header set Content-Type "text/css; charset=utf-8"
+
+
# Correcting some default options for security and language/content redirection.
# FollowSymlinks is also on since it's required for "mod_rewrite" and the server is jailed/containerized.
diff --git a/commons/content/manager.php b/commons/content/manager.php
index ef37e05..cc1869a 100644
--- a/commons/content/manager.php
+++ b/commons/content/manager.php
@@ -9,9 +9,14 @@ if(basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
include_once 'commons/langs.php';
enum EContentDisplayType {
- const NONE = 0;
- const SEARCH = 1;
- const DISPLAY = 2;
+ /** No display type have or could be determined. */
+ case NONE;
+
+ /** The content index should be shown */
+ case SEARCH;
+
+ /** The page for a specific piece of content should be shown */
+ case DISPLAY;
}
class ContentIndexEntry {
@@ -47,7 +52,7 @@ class ContentIndexEntry {
}
class ContentManager {
- public ContentDisplayType|int $displayType;
+ public EContentDisplayType $displayType;
public bool $hasError;
public string $errorMessageKey;
public ?string $requestedId;
@@ -87,7 +92,7 @@ class ContentManager {
// Doing some dark magic whose inner workings are lost to times...
$requestedUrlPart = explode(
"?",
- explode("#", preg_replace("^\/(content|tools)^", "", $requestedUrl))[0]
+ explode("#", preg_replace("^/(content|tools)^", "", $requestedUrl))[0]
)[0];
if(strcmp($requestedUrlPart, "/") == 0) {
@@ -177,7 +182,7 @@ class ContentManager {
/**
* If currently in a "EContentDisplayType::DISPLAY" context, we prepare the path to the content definition.
* This definition must be loaded afterward depending on the content's type. (content, tool, article, ...)
- * @param string $rootIndexFilepath
+ * @param string $contentRootPath
* @return void
*/
function prepareContentFilePath(string $contentRootPath): void {
@@ -189,7 +194,7 @@ class ContentManager {
}
// Preparing and checking the content's info index file.
- $this->contentFilepath = get_content_file_path($contentRootPath, $this->requestedId);
+ $this->contentFilepath = ContentManager::getContentFilePath($contentRootPath, $this->requestedId);
if(empty($this->contentFilepath)) {
// File doesn't exist !
@@ -197,29 +202,32 @@ class ContentManager {
$this->errorMessageKey = "content.error.message.data.not.exist";
}
}
-}
-
-// Common utilities
-function get_content_file_path(string $contentRootPath, string $contentId): ?string {
- if(ctype_alnum(str_replace("-", "", $contentId))) {
- return realpath($contentRootPath . "/items/" . $contentId . ".json");
+
+ /**
+ * Returns the path to the main JSON file for a desired piece of content.
+ * @param string $contentRootPath
+ * @param string $contentId
+ * @return string|null
+ */
+ private static function getContentFilePath(string $contentRootPath, string $contentId): ?string {
+ if(ctype_alnum(str_replace("-", "", $contentId))) {
+ return realpath($contentRootPath . "/items/" . $contentId . ".json");
+ }
+ return null;
+ }
+
+ /**
+ * Prepares a ContentManager for the current page.
+ * @param string $contentRootPath Root path for the relevant content ("/content", "/tools", ...)
+ * @return ContentManager
+ */
+ public static function createContentManager(string $contentRootPath): ContentManager {
+ return new ContentManager(
+ $contentRootPath,
+ l10n_url_switch(NULL),
+ isset($_GET['tags']) ? htmlspecialchars($_GET['tags']) : NULL
+ );
}
- return null;
-}
-
-// Functions for use in pages
-
-/**
- * Prepares a ContentManager for the current page.
- * @param string $contentRootPath Root path for the relevant content ("/content", "/tools", ...)
- * @return ContentManager
- */
-function getContentManager(string $contentRootPath): ContentManager {
- return new ContentManager(
- $contentRootPath,
- l10n_url_switch(NULL),
- isset($_GET['tags']) ? htmlspecialchars($_GET['tags']) : NULL
- );
}
?>
\ No newline at end of file
diff --git a/content/index.php b/content/index.php
index ed384bc..50573ce 100644
--- a/content/index.php
+++ b/content/index.php
@@ -9,7 +9,7 @@ include_once 'commons/langs.php';
// Preparing the content
include_once 'commons/content/manager.php';
include_once 'commons/content/composer.php';
-$contentManager = getContentManager($config_dir_content);
+$contentManager = ContentManager::createContentManager($config_dir_content);
$content = NULL;
if(!$contentManager->hasError && $contentManager->displayType == EContentDisplayType::DISPLAY) {
$content = load_content_by_file_path($contentManager->contentFilepath);
diff --git a/index.php b/index.php
index c2abb73..53e1d44 100644
--- a/index.php
+++ b/index.php
@@ -39,10 +39,10 @@ include 'commons/DOM/sidebar.php';
hasError && $contentManager->displayType == ContentDisplayType::CONTENT) {
+ if(!$contentManager->hasError && $contentManager->displayType == EContentDisplayType::DISPLAY) {
$content = load_content_by_file_path($contentManager->contentFilepath);
if(is_null($content)) {
$contentManager->hasError = true;
diff --git a/tools/index.php b/tools/index.php
index e0a88d7..a126a49 100644
--- a/tools/index.php
+++ b/tools/index.php
@@ -8,7 +8,7 @@ include_once 'commons/langs.php';
// Preparing the content manager to get the page's context.
include_once 'commons/content/manager.php';
-$contentManager = getContentManager($config_dir_tools);
+$contentManager = ContentManager::createContentManager($config_dir_tools);
// Attempting to load the tool's data if relevant.
// If loaded, we can assume the standardized index wasn't loaded by "$contentManager".