Refactored commons/content.php for tools page
Update composer.php, config.php, and 7 more files...
This commit is contained in:
@@ -8,6 +8,7 @@ if(basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
|
|||||||
// Including required helpers.
|
// Including required helpers.
|
||||||
include_once 'commons/config.php';
|
include_once 'commons/config.php';
|
||||||
include_once 'commons/langs.php';
|
include_once 'commons/langs.php';
|
||||||
|
include_once 'commons/content.php';
|
||||||
|
|
||||||
// Required to make headings
|
// Required to make headings
|
||||||
include_once 'commons/DOM/utils.php';
|
include_once 'commons/DOM/utils.php';
|
||||||
@@ -931,16 +932,6 @@ function get_content_error(string $error_title_key, string $error_description_ke
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_content_file_path(string $content_id) : ?string {
|
|
||||||
global $dir_content;
|
|
||||||
|
|
||||||
if(ctype_alnum(str_replace("-", "", $content_id))) {
|
|
||||||
return realpath($dir_content . "/items/" . $content_id . ".json");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function load_content_by_file_path(string $file_path) : ?ComposerContent {
|
function load_content_by_file_path(string $file_path) : ?ComposerContent {
|
||||||
$content_json_data = json_decode(file_get_contents($file_path), true);
|
$content_json_data = json_decode(file_get_contents($file_path), true);
|
||||||
if(is_null($content_json_data)) {
|
if(is_null($content_json_data)) {
|
||||||
@@ -950,7 +941,9 @@ function load_content_by_file_path(string $file_path) : ?ComposerContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function load_content_by_id(string $content_id) : ?ComposerContent {
|
function load_content_by_id(string $content_id) : ?ComposerContent {
|
||||||
$content_file_path = get_content_file_path($content_id);
|
// FIXME: Find another way to get `$config_dir_content` here !
|
||||||
|
global $config_dir_content;
|
||||||
|
$content_file_path = get_content_file_path($config_dir_content, $content_id);
|
||||||
|
|
||||||
if(is_null($content_file_path)) {
|
if(is_null($content_file_path)) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ if(basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
|
|||||||
|
|
||||||
$host = "nibblepoker.lu";
|
$host = "nibblepoker.lu";
|
||||||
$host_uri = "https://nibblepoker.lu";
|
$host_uri = "https://nibblepoker.lu";
|
||||||
|
|
||||||
$dir_commons = dirname(__FILE__);
|
$dir_commons = dirname(__FILE__);
|
||||||
$dir_root = realpath($dir_commons . "/../");
|
$dir_root = realpath($dir_commons . "/../");
|
||||||
$dir_content = realpath($dir_commons . "/../" . "content/");
|
$config_dir_content = realpath($dir_commons . "/../" . "content/");
|
||||||
|
$config_dir_tools = realpath($dir_commons . "/../" . "content/");
|
||||||
|
|
||||||
// Optional features
|
// Optional features
|
||||||
$enable_grids = false;
|
$enable_grids = false;
|
||||||
|
|||||||
@@ -7,139 +7,193 @@ if(basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
|
|||||||
|
|
||||||
// Importing required scripts.
|
// Importing required scripts.
|
||||||
include_once 'commons/langs.php';
|
include_once 'commons/langs.php';
|
||||||
include_once 'commons/composer.php';
|
|
||||||
|
|
||||||
// Defining some options.
|
|
||||||
$PRINT_CONTENT_DEBUG_INFO_TEXT_ELEMENTS = true;
|
|
||||||
$PRINT_CONTENT_DEBUG_ERROR_TEXT_ELEMENTS = true;
|
|
||||||
|
|
||||||
// Defining constants and enums.
|
|
||||||
abstract class ContentDisplayType {
|
abstract class ContentDisplayType {
|
||||||
const NONE = 0;
|
const NONE = 0;
|
||||||
const SEARCH = 1;
|
const SEARCH = 1;
|
||||||
const CONTENT = 2;
|
const CONTENT = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preparing default variables.
|
class ContentIndexEntry {
|
||||||
$requested_content_display_type = ContentDisplayType::NONE;
|
public string $id;
|
||||||
$content_has_error = false;
|
public ?array $title;
|
||||||
$content_error_message_key = "content.error.message.none";
|
public ?array $preamble;
|
||||||
$content_error_message = "";
|
public string $image;
|
||||||
$requested_tags = array();
|
public array $tags;
|
||||||
$raw_additional_tags = "";
|
public int $priority;
|
||||||
$filtered_content_index_data = NULL;
|
|
||||||
$requested_item_data = NULL;
|
|
||||||
$content = null;
|
|
||||||
|
|
||||||
// Detecting content display type requested.
|
function __construct(string $id, ?array $title, ?array $preamble, ?string $image, ?array $tags, ?int $priority) {
|
||||||
$content_requested_url_part = explode("?", explode("#", preg_replace("^\/(content)^", "", l10n_url_switch(NULL)))[0])[0];
|
$this->id = $id;
|
||||||
|
$this->title = $title;
|
||||||
|
$this->preamble = $preamble;
|
||||||
|
$this->image = is_null($image) ? "/resources/NibblePoker/images/placeholder.png" : $image;
|
||||||
|
$this->tags = is_null($tags) ? [] : $tags;
|
||||||
|
$this->priority = is_null($priority) ? 0 : $priority;
|
||||||
|
}
|
||||||
|
|
||||||
if(strcmp($content_requested_url_part, "/") == 0) {
|
static function from_json(array $json_data) : ?ContentIndexEntry {
|
||||||
$requested_content_display_type = ContentDisplayType::SEARCH;
|
if(!key_exists("id", $json_data)) {
|
||||||
} else {
|
return null;
|
||||||
$requested_content_display_type = ContentDisplayType::CONTENT;
|
}
|
||||||
$content_requested_url_part = ltrim($content_requested_url_part, "/");
|
return new ContentIndexEntry(
|
||||||
|
$json_data["id"],
|
||||||
|
key_exists("title", $json_data) ? $json_data["title"] : null,
|
||||||
|
key_exists("preamble", $json_data) ? $json_data["preamble"] : null,
|
||||||
|
key_exists("image", $json_data) ? $json_data["image"] : null,
|
||||||
|
key_exists("tags", $json_data) ? $json_data["tags"] : null,
|
||||||
|
key_exists("priority", $json_data) ? $json_data["priority"] : null
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($requested_content_display_type == ContentDisplayType::SEARCH) {
|
class ContentManager {
|
||||||
// Checking if more tags were given
|
public ContentDisplayType|int $displayType;
|
||||||
if(isset($_GET['tags'])) {
|
public bool $hasError;
|
||||||
$raw_additional_tags = htmlspecialchars($_GET['tags']);
|
public string $errorMessageKey;
|
||||||
|
public ?string $requestedId;
|
||||||
|
public ?array $requestedTags;
|
||||||
|
public ?array $rootIndexEntries;
|
||||||
|
public ?string $contentFilepath;
|
||||||
|
|
||||||
// Checking the length to prevent bad requests
|
function __construct(string $contentRootPath, string $requestedUrl, ?string $urlTags) {
|
||||||
if(strlen($raw_additional_tags) > 256) {
|
// Preparing default values
|
||||||
$content_has_error = true;
|
$this->displayType = ContentDisplayType::NONE;
|
||||||
$content_error_message_key = "content.error.message.tags.length";
|
$this->hasError = false;
|
||||||
goto content_end;
|
$this->errorMessageKey = "content.error.message.none";
|
||||||
|
$this->requestedId = NULL;
|
||||||
|
$this->requestedTags = NULL;
|
||||||
|
$this->rootIndexEntries = NULL;
|
||||||
|
$this->contentFilepath = NULL;
|
||||||
|
|
||||||
|
// Doing some standard things
|
||||||
|
$this->processUrl($requestedUrl, $urlTags);
|
||||||
|
if(!$this->hasError) {
|
||||||
|
if($this->displayType == ContentDisplayType::SEARCH) {
|
||||||
|
$this->loadRootIndex(realpath($contentRootPath . "/index.json"));
|
||||||
|
} else if($this->displayType == ContentDisplayType::CONTENT) {
|
||||||
|
$this->prepareContentFilePath($contentRootPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extracting the additional tags safely
|
function processUrl(string $requestedUrl, ?string $urlTags): void {
|
||||||
$raw_additional_tags_exploded = explode(";", $raw_additional_tags);
|
// Doing some dark magic whose inner workings are lost to times...
|
||||||
for($i = 0; $i < count($raw_additional_tags_exploded); $i++) {
|
$requestedUrlPart = explode(
|
||||||
if(strlen($raw_additional_tags_exploded[$i]) > 0) {
|
"?",
|
||||||
if(ctype_alnum($raw_additional_tags_exploded[$i])) {
|
explode("#", preg_replace("^\/(content)^", "", $requestedUrl))[0]
|
||||||
$requested_tags[] = $raw_additional_tags_exploded[$i];
|
)[0];
|
||||||
|
|
||||||
|
if(strcmp($requestedUrlPart, "/") == 0) {
|
||||||
|
$this->displayType = ContentDisplayType::SEARCH;
|
||||||
|
|
||||||
|
if(is_null($urlTags)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strlen($urlTags) > 256) {
|
||||||
|
$this->hasError = true;
|
||||||
|
$this->errorMessageKey = "content.error.message.tags.length";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$explodedTags = explode(";", $urlTags);
|
||||||
|
$this->requestedTags = count($explodedTags) > 0 ? array() : $this->requestedTags;
|
||||||
|
for($i = 0; $i < count($explodedTags); $i++) {
|
||||||
|
if(strlen($explodedTags[$i]) > 0) {
|
||||||
|
if(ctype_alnum($explodedTags[$i])) {
|
||||||
|
$this->requestedTags[] = $explodedTags[$i];
|
||||||
} else {
|
} else {
|
||||||
$content_has_error = true;
|
$this->hasError = true;
|
||||||
$content_error_message_key = "content.error.message.tags.alphanumeric";
|
$this->errorMessageKey = "content.error.message.tags.alphanumeric";
|
||||||
goto content_end;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($raw_additional_tags_exploded);
|
} else {
|
||||||
|
$this->displayType = ContentDisplayType::CONTENT;
|
||||||
|
$this->requestedId = ltrim($requestedUrlPart, "/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadRootIndex(string $rootIndexFilepath): void {
|
||||||
// Loading the content index.
|
// Loading the content index.
|
||||||
$content_json = file_get_contents(realpath($dir_content . "/index.json"));
|
$rawJsonContent = file_get_contents($rootIndexFilepath);
|
||||||
$content_index_data = json_decode($content_json, true);
|
$jsonContent = json_decode($rawJsonContent, true);
|
||||||
unset($content_json);
|
unset($rawJsonContent);
|
||||||
|
|
||||||
// Filtering out unwanted entries.
|
$this->rootIndexEntries = array();
|
||||||
$filtered_content_index_data = array();
|
for($i = 0; $i < count($jsonContent); $i++) {
|
||||||
for($i = 0; $i < count($content_index_data); $i++) {
|
// Filtering out unwanted entries and putting their data in a proper class.
|
||||||
if(count(array_intersect($content_index_data[$i]["tags"], $requested_tags)) == count($requested_tags)) {
|
if(!is_null($this->requestedTags)) {
|
||||||
$filtered_content_index_data[] = $content_index_data[$i];
|
if(count(array_intersect($jsonContent[$i]["tags"], $this->requestedTags)) == 0) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//if(count(array_intersect($jsonContent[$i]["tags"], $this->requestedTags)) == count($this->requestedTags)) {}
|
||||||
|
|
||||||
// Cleaning some variables.
|
// Parsing the raw data into a structure.
|
||||||
unset($content_index_data);
|
$newIndexEntry = ContentIndexEntry::from_json($jsonContent[$i]);
|
||||||
unset($content_json);
|
|
||||||
|
|
||||||
// Checking if we found content for the user.
|
// Checking if it was parsed properly
|
||||||
if(count($filtered_content_index_data) == 0) {
|
if(is_null($newIndexEntry)) {
|
||||||
|
$this->hasError = true;
|
||||||
|
$this->errorMessageKey = "content.error.message.failed.structure";
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
$this->rootIndexEntries[] = $newIndexEntry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($jsonContent);
|
||||||
|
|
||||||
|
// Checking if we found any content for the user.
|
||||||
|
if(count($this->rootIndexEntries) == 0) {
|
||||||
// No relevant article/page were found for the given tags.
|
// No relevant article/page were found for the given tags.
|
||||||
$content_has_error = true;
|
$this->hasError = true;
|
||||||
$content_error_message_key = "content.error.message.detect.empty";
|
$this->errorMessageKey = "content.error.message.detect.empty";
|
||||||
goto content_end;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sorting entries based on their priority
|
// Sorting entries based on their priority
|
||||||
for($i = 0; $i < count($filtered_content_index_data); $i++) {
|
usort($this->rootIndexEntries, function (ContentIndexEntry $a, ContentIndexEntry $b) {
|
||||||
if(!isset($filtered_content_index_data[$i]["priority"])) {
|
if($a->priority == $b->priority) {
|
||||||
$filtered_content_index_data[$i]["priority"] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
usort($filtered_content_index_data, function ($a, $b) {
|
|
||||||
if($a["priority"] == $b["priority"]) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return ($a["priority"] > $b["priority"]) ? -1 : 1;
|
return ($a->priority > $b->priority) ? -1 : 1;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} else if($requested_content_display_type == ContentDisplayType::CONTENT) {
|
function prepareContentFilePath(string $contentRootPath): void {
|
||||||
// Sanitizing the requested ID.
|
// Sanitizing the requested ID.
|
||||||
if(!ctype_alnum(str_replace("-", "", $content_requested_url_part))) {
|
if(!ctype_alnum(str_replace("-", "", $this->requestedId))) {
|
||||||
$content_has_error = true;
|
$this->hasError = true;
|
||||||
$content_error_message_key = "content.error.message.id.alphanumeric";
|
$this->errorMessageKey = "content.error.message.id.alphanumeric";
|
||||||
goto content_end;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loading the content's data
|
// Preparing and checking the content's info index file.
|
||||||
$content_file_path = get_content_file_path($content_requested_url_part);
|
$this->contentFilepath = get_content_file_path($contentRootPath, $this->requestedId);
|
||||||
|
|
||||||
if(empty($content_file_path)) {
|
if(empty($this->contentFilepath)) {
|
||||||
// File doesn't exist !
|
// File doesn't exist !
|
||||||
$content_has_error = true;
|
$this->hasError = true;
|
||||||
$content_error_message_key = "content.error.message.data.not.exist";
|
$this->errorMessageKey = "content.error.message.data.not.exist";
|
||||||
unset($content_file_path);
|
|
||||||
goto content_end;
|
|
||||||
} else {
|
|
||||||
$content = load_content_by_file_path($content_file_path);
|
|
||||||
|
|
||||||
if(is_null($content)) {
|
|
||||||
$content_has_error = true;
|
|
||||||
$content_error_message_key = "content.error.message.cannot.load";
|
|
||||||
unset($content_file_path);
|
|
||||||
goto content_end;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($content_file_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content_end:
|
// Common utilities
|
||||||
// TODO: Create error thingy
|
function get_content_file_path(string $contentRootPath, string $contentId) : ?string {
|
||||||
$content_error_message = localize($content_error_message_key);
|
if(ctype_alnum(str_replace("-", "", $contentId))) {
|
||||||
|
return realpath($contentRootPath . "/items/" . $contentId . ".json");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
// Functions for use in pages
|
||||||
|
function getContentManager(string $contentRootPath): ContentManager {
|
||||||
|
return new ContentManager(
|
||||||
|
$contentRootPath,
|
||||||
|
l10n_url_switch(NULL),
|
||||||
|
isset($_GET['tags']) ? htmlspecialchars($_GET['tags']) : NULL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
7
commons/strings/en/tools.json
Normal file
7
commons/strings/en/tools.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"tools.head.title": "Tools - NibblePoker",
|
||||||
|
"tools.head.description": "TODO: description",
|
||||||
|
"tools.og.title": "NibblePoker - Tools",
|
||||||
|
"tools.og.description": "TODO: description",
|
||||||
|
"tools.header.title": "Tools"
|
||||||
|
}
|
||||||
@@ -5,14 +5,27 @@ $start_time = microtime(true);
|
|||||||
set_include_path('../');
|
set_include_path('../');
|
||||||
include_once 'commons/config.php';
|
include_once 'commons/config.php';
|
||||||
include_once 'commons/langs.php';
|
include_once 'commons/langs.php';
|
||||||
|
|
||||||
|
// Preparing the content
|
||||||
include_once 'commons/content.php';
|
include_once 'commons/content.php';
|
||||||
|
include_once 'commons/composer.php';
|
||||||
|
$contentManager = getContentManager($config_dir_content);
|
||||||
|
$content = NULL;
|
||||||
|
if(!$contentManager->hasError && $contentManager->displayType == ContentDisplayType::CONTENT) {
|
||||||
|
$content = load_content_by_file_path($contentManager->contentFilepath);
|
||||||
|
if(is_null($content)) {
|
||||||
|
$contentManager->hasError = true;
|
||||||
|
$contentManager->errorMessageKey = "content.error.message.cannot.load";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$content_error_message = localize($contentManager->errorMessageKey);
|
||||||
|
|
||||||
// Checking if an error occurred while loading data and parsing the URL.
|
// Checking if an error occurred while loading data and parsing the URL.
|
||||||
// And if not, enabling special features.
|
// And if not, enabling special features.
|
||||||
$content_error_code = 200;
|
$content_error_code = 200;
|
||||||
if ($content_has_error) {
|
if($contentManager->hasError) {
|
||||||
// TODO: Add condition for the lack of data for an item.
|
// TODO: Add condition for the lack of data for an item.
|
||||||
if (is_null($filtered_content_index_data)) {
|
if(is_null($contentManager->rootIndexEntries)) {
|
||||||
// Failed to get a display type or to extract types.
|
// Failed to get a display type or to extract types.
|
||||||
header("HTTP/1.1 400 Bad Request");
|
header("HTTP/1.1 400 Bad Request");
|
||||||
$content_error_code = 400;
|
$content_error_code = 400;
|
||||||
@@ -34,12 +47,12 @@ if ($content_has_error) {
|
|||||||
include 'commons/DOM/head.php';
|
include 'commons/DOM/head.php';
|
||||||
|
|
||||||
// Preparing values for the head's tags.
|
// Preparing values for the head's tags.
|
||||||
if ($content_has_error) {
|
if ($contentManager->hasError) {
|
||||||
$content_head_title = localize("content.error.head.title");
|
$content_head_title = localize("content.error.head.title");
|
||||||
$content_head_description = $content_error_message;
|
$content_head_description = $content_error_message;
|
||||||
$content_head_og_title = localize("content.error.og.title");
|
$content_head_og_title = localize("content.error.og.title");
|
||||||
$content_head_og_description = $content_error_message;
|
$content_head_og_description = $content_error_message;
|
||||||
} elseif($requested_content_display_type == ContentDisplayType::CONTENT) {
|
} elseif($contentManager->displayType == ContentDisplayType::CONTENT) {
|
||||||
$content_head_title =
|
$content_head_title =
|
||||||
localize("content.item.head.title.prefix") .
|
localize("content.item.head.title.prefix") .
|
||||||
$content->get_head_title() .
|
$content->get_head_title() .
|
||||||
@@ -50,7 +63,7 @@ if ($content_has_error) {
|
|||||||
$content->get_head_title() .
|
$content->get_head_title() .
|
||||||
localize("content.item.og.title.suffix");
|
localize("content.item.og.title.suffix");
|
||||||
$content_head_og_description = $content->get_head_description();
|
$content_head_og_description = $content->get_head_description();
|
||||||
} elseif($requested_content_display_type == ContentDisplayType::SEARCH) {
|
} elseif($contentManager->displayType == ContentDisplayType::SEARCH) {
|
||||||
$content_head_title = localize("content.search.head.title");
|
$content_head_title = localize("content.search.head.title");
|
||||||
$content_head_description = localize("content.search.head.description");;
|
$content_head_description = localize("content.search.head.description");;
|
||||||
$content_head_og_title = localize("content.search.og.title");;
|
$content_head_og_title = localize("content.search.og.title");;
|
||||||
@@ -79,17 +92,17 @@ include 'commons/DOM/body-2.php';
|
|||||||
<header class="w-full p-m pl-s">
|
<header class="w-full p-m pl-s">
|
||||||
<h1 class="t-size-17 t-w-500">
|
<h1 class="t-size-17 t-w-500">
|
||||||
<?php
|
<?php
|
||||||
if($content_has_error) {
|
if($contentManager->hasError) {
|
||||||
echo('<i class="fad fa-exclamation-triangle t-size-16 mr-s t-muted"></i>');
|
echo('<i class="fad fa-exclamation-triangle t-size-16 mr-s t-muted"></i>');
|
||||||
echo(localize("content.header.base"));
|
echo(localize("content.header.base"));
|
||||||
echo('<span class="mx-s t-size-15">❱</span>');
|
echo('<span class="mx-s t-size-15">❱</span>');
|
||||||
echo(localize("content.error.header"));
|
echo(localize("content.error.header"));
|
||||||
} elseif($requested_content_display_type == ContentDisplayType::SEARCH) {
|
} elseif($contentManager->displayType == ContentDisplayType::SEARCH) {
|
||||||
echo('<i class="fad fa-briefcase t-size-16 mr-s t-muted"></i>');
|
echo('<i class="fad fa-briefcase t-size-16 mr-s t-muted"></i>');
|
||||||
echo(localize("content.header.base"));
|
echo(localize("content.header.base"));
|
||||||
echo('<span class="mx-s t-size-15">❱</span>');
|
echo('<span class="mx-s t-size-15">❱</span>');
|
||||||
echo(localize("content.search.header"));
|
echo(localize("content.search.header"));
|
||||||
} elseif($requested_content_display_type == ContentDisplayType::CONTENT) {
|
} elseif($contentManager->displayType == ContentDisplayType::CONTENT) {
|
||||||
echo('<i class="fad fa-briefcase t-size-16 mr-s t-muted"></i>');
|
echo('<i class="fad fa-briefcase t-size-16 mr-s t-muted"></i>');
|
||||||
echo(localize("content.header.base"));
|
echo(localize("content.header.base"));
|
||||||
echo('<span class="mx-s t-size-15">❱</span>');
|
echo('<span class="mx-s t-size-15">❱</span>');
|
||||||
@@ -104,9 +117,9 @@ include 'commons/DOM/body-2.php';
|
|||||||
<?php
|
<?php
|
||||||
// Checking if an error occurred.
|
// Checking if an error occurred.
|
||||||
if($content_error_code != 200) {
|
if($content_error_code != 200) {
|
||||||
if($requested_content_display_type == ContentDisplayType::SEARCH) {
|
if($contentManager->displayType == ContentDisplayType::SEARCH) {
|
||||||
printMainHeader(localize("content.error.heading.main.search"), "fad fa-exclamation-triangle");
|
printMainHeader(localize("content.error.heading.main.search"), "fad fa-exclamation-triangle");
|
||||||
} elseif($requested_content_display_type == ContentDisplayType::CONTENT) {
|
} elseif($contentManager->displayType == ContentDisplayType::CONTENT) {
|
||||||
printMainHeader(localize("content.error.heading.main.content"), "fad fa-exclamation-triangle");
|
printMainHeader(localize("content.error.heading.main.content"), "fad fa-exclamation-triangle");
|
||||||
} else {
|
} else {
|
||||||
printMainHeader(localize("content.error.heading.main.fallback"), "fad fa-exclamation-triangle");
|
printMainHeader(localize("content.error.heading.main.fallback"), "fad fa-exclamation-triangle");
|
||||||
@@ -117,52 +130,54 @@ include 'commons/DOM/body-2.php';
|
|||||||
goto content_printing_end;
|
goto content_printing_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($requested_content_display_type == ContentDisplayType::SEARCH) {
|
if($contentManager->displayType == ContentDisplayType::SEARCH) {
|
||||||
// We are handling a content search with at least one result.
|
// We are handling a content search with at least one result.
|
||||||
|
|
||||||
// Making the header with the amount of results.
|
// Making the header with the amount of results.
|
||||||
printMainHeader(
|
printMainHeader(
|
||||||
count($filtered_content_index_data) > 1 ?
|
count($contentManager->rootIndexEntries) > 1 ?
|
||||||
localize("content.search.heading.main.multiple") :
|
localize("content.search.heading.main.multiple") :
|
||||||
localize("content.search.heading.main.single"),
|
localize("content.search.heading.main.single"),
|
||||||
"fad fa-file-search",
|
"fad fa-file-search",
|
||||||
count($filtered_content_index_data) . " " . (
|
count($contentManager->rootIndexEntries) . " " . (
|
||||||
count($filtered_content_index_data) > 1 ?
|
count($contentManager->rootIndexEntries) > 1 ?
|
||||||
localize("content.search.count.multiple") :
|
localize("content.search.count.multiple") :
|
||||||
localize("content.search.count.single")));
|
localize("content.search.count.single")));
|
||||||
|
|
||||||
// Printing the entry for each piece of relevant content.
|
// Printing the entry for each piece of relevant content.
|
||||||
for($iContent = 0; $iContent < count($filtered_content_index_data); $iContent++) {
|
$doPrintRuler = false;
|
||||||
$current_content = $filtered_content_index_data[$iContent];
|
foreach($contentManager->rootIndexEntries as $current_content) {
|
||||||
|
/** @var ContentIndexEntry $current_content */
|
||||||
|
|
||||||
if($iContent > 0) {
|
if($doPrintRuler) {
|
||||||
echo('<hr class="subtle">');
|
echo('<hr class="subtle">');
|
||||||
|
} else {
|
||||||
|
$doPrintRuler = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo('<div class="p-s">');
|
echo('<div class="p-s">');
|
||||||
echo('<a class="casper-link" href="'.l10n_url_abs("/content/".$current_content["id"]).'">');
|
echo('<a class="casper-link" href="'.l10n_url_abs("/content/".$current_content->id).'">');
|
||||||
echo('<div class="content-search-entry">');
|
echo('<div class="content-search-entry">');
|
||||||
|
|
||||||
echo('<img class="content-search-image mr-s r-l" src="' . $current_content["image"] . '">');
|
echo('<img class="content-search-image mr-s r-l" src="' . $current_content->image . '">');
|
||||||
echo('<h3 class="mb-xs">' . $current_content["title"][$user_language] . '</h3>');
|
echo('<h3 class="mb-xs">' . $current_content->title[$user_language] . '</h3>');
|
||||||
echo('<p>' . $current_content["preamble"][$user_language] . '</p>');
|
echo('<p>' . $current_content->preamble[$user_language] . '</p>');
|
||||||
|
|
||||||
echo('</div>');
|
echo('</div>');
|
||||||
echo('</a>');
|
echo('</a>');
|
||||||
|
|
||||||
echo('<p class="mt-xs"><i class="fad fa-tags t-size-8"></i>');
|
echo('<p class="mt-xs"><i class="fad fa-tags t-size-8"></i>');
|
||||||
for($iContentTag = 0; $iContentTag < count($current_content["tags"]); $iContentTag++) {
|
foreach($current_content->tags as $current_content_tag) {
|
||||||
echo('<a href="' . l10n_url_abs("/content/?tags=".$current_content["tags"][$iContentTag]) .
|
echo('<a href="' . l10n_url_abs("/content/?tags=".$current_content_tag) .
|
||||||
'" class="ml-xs">#' . $current_content["tags"][$iContentTag] . '</a>');
|
'" class="ml-xs">#' . $current_content_tag . '</a>');
|
||||||
}
|
}
|
||||||
echo('</p>');
|
echo('</p>');
|
||||||
|
|
||||||
echo('</div>');
|
echo('</div>');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Print the tags used in the search and others that may be available.
|
// TODO: Print the tags used in the search and others that may be available.
|
||||||
} elseif($requested_content_display_type == ContentDisplayType::CONTENT) {
|
} elseif($contentManager->displayType == ContentDisplayType::CONTENT) {
|
||||||
// Printing the content
|
// Printing the content
|
||||||
echo($content->get_html());
|
echo($content->get_html());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ if(isset($_SERVER['REDIRECT_STATUS'])) {
|
|||||||
$np_err_img_alt = localize("error.skit.pc.dead");
|
$np_err_img_alt = localize("error.skit.pc.dead");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
echo('<img id="error-page-skit" src="' . $np_err_img . '" alt="' . $np_err_img_alt . '">');
|
echo('<img id="error-page-skit" src="' . $np_err_img . '" alt="' . $np_err_img_alt . '" draggable="false">');
|
||||||
?>
|
?>
|
||||||
</main>
|
</main>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
filter: grayscale(100%);
|
filter: grayscale(100%);
|
||||||
mix-blend-mode: multiply;
|
mix-blend-mode: multiply;
|
||||||
opacity: 40%;
|
opacity: 40%;
|
||||||
width: 100%;
|
// Fixes the width to the size of the sidebar minus its padding. (15rem - 1rem * 2)
|
||||||
|
width: 13rem;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,10 +37,14 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 1.5em;
|
bottom: 1.5em;
|
||||||
right: 1.5em;
|
right: 1.5em;
|
||||||
filter: drop-shadow(0 0 0.5rem #0000007F);
|
filter: drop-shadow(0 0 0.25rem #0000007F);
|
||||||
mix-blend-mode: multiply;
|
mix-blend-mode: multiply;
|
||||||
//opacity: 0.25;
|
//opacity: 0.25;
|
||||||
opacity: 0.2;
|
opacity: 0.2;
|
||||||
|
|
||||||
|
// Preventing the selection and dragging of the image for aesthetic reasons.
|
||||||
|
user-drag: none;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logo colors
|
// Logo colors
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ header, nav, footer {
|
|||||||
background-color: #{$color-background-surround};
|
background-color: #{$color-background-surround};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Might be easier to have it as absolute, shift it left when closing and using a blank spacing div tbh...
|
||||||
|
// Or nest content in div, and when retracted move it out at the same speed, idk...
|
||||||
.sidebar {
|
.sidebar {
|
||||||
width: #{$size-sidebar};
|
width: #{$size-sidebar};
|
||||||
max-width: #{$size-sidebar};
|
max-width: #{$size-sidebar};
|
||||||
@@ -28,7 +30,8 @@ header, nav, footer {
|
|||||||
|
|
||||||
&.retracted {
|
&.retracted {
|
||||||
width: 0;
|
width: 0;
|
||||||
padding: 0;
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user