Improved the content system

Update content.php, strings.json, and 2 more files...
This commit is contained in:
2021-12-09 10:54:28 +01:00
parent 9a0dff1fe9
commit e117954197
4 changed files with 146 additions and 73 deletions

View File

@@ -24,12 +24,14 @@ abstract class ContentDisplayType {
// Preparing default variables.
$requested_content_type = ContentType::NONE;
$requested_content_display_type = ContentDisplayType::NONE;
$requested_tags = array();
$content_has_error = false;
$_content_error_message_key = "error.content.none";
$content_error_message = "";
$was_item_requested = false;
$requested_tags = NULL;
$filtered_content_index_data = NULL;
// Detecting content type requested.
$content_requested_url_part = l10n_url_switch(NULL);
@@ -48,12 +50,14 @@ if(str_starts_with($content_requested_url_part, "/blog/")) {
// Detecting what kind of item was requested, parsing additional parameters and loading required data.
$content_requested_url_part = preg_replace("^\/(blog|programming|electronics)^", "", $content_requested_url_part);
$requested_tags = array();
if($requested_content_type == ContentType::BLOG) {
if(str_starts_with($content_requested_url_part, "/article/")) {
$requested_content_display_type = ContentDisplayType::ARTICLE;
} else {
$requested_content_display_type = ContentDisplayType::SEARCH;
}
$requested_tags[] = "blog";
} elseif($requested_content_type == ContentType::PROGRAMMING) {
// May be changed later if a specific resource is requested and found.
$requested_content_display_type = ContentDisplayType::SEARCH;
@@ -148,4 +152,24 @@ if($requested_content_display_type == ContentDisplayType::SEARCH) {
content_end:
$content_error_message = localize($_content_error_message_key);
// These function are placed here to prevent the main file from becoming impossible to read.
function printErrorCard($title, $content) {
echo('<div class="card p-0 mx-0"><div class="px-card py-10 border-bottom px-20"><div class="container-fluid">'.
'<div class="row"><h2 class="card-title font-size-18 m-0"><i class="fad fa-exclamation-triangle"></i>&nbsp;&nbsp;'.
$title.'</h2></div></div></div><div class="px-card py-20 bg-light-lm bg-very-dark-dm rounded-bottom px-20">'.
'<h3 class="m-0 font-size-20 text-center font-weight-semi-bold">'.$content.'</h3></div></div>');
}
function startMainCard($iconClasses, $title, $subTitle) {
echo('<div class="card p-0 mx-0"><div class="px-card py-10 border-bottom px-20"><div class="container-fluid">'.
'<div class="row"><div class="col-4"><h2 class="card-title font-size-18 m-0"><i class="'.$iconClasses.
'"></i>&nbsp;&nbsp;'.localize($title).'</h2></div><div class="col-8 text-right font-italic">'.
'<h2 class="card-title font-size-18 m-0 text-super-muted">'.$subTitle.'</h2></div></div></div></div>');
}
function endMainCard() {
echo('</div>');
}
?>

View File

@@ -60,7 +60,12 @@
"error.content.detect.display": "Failed to detect if you requested the category's search page or a specific one.",
"error.content.detect.subtype": "Failed to detect the sub-type of content you requested.",
"error.content.detect.tags": "Failed to detect the basic tags for the content you requested.",
"error.content.detect.empty": "No content could be found for the given tags."
"error.content.detect.empty": "No content could be found for the given tags.",
"content.title.error": "$content.title.error",
"content.title.search": "$content.title.search",
"content.title.article": "$content.title.article",
"content.title.application": "$content.title.application"
},
"fr": {
"home.title.nav": "Accueil",
@@ -122,7 +127,12 @@
"error.content.detect.display": "Impossibilité de détecter si une recherche ou page spécifique était demandée.",
"error.content.detect.subtype": "Impossibilité de détecter le sous-type de contenu demandé.",
"error.content.detect.tags": "Impossibilité de détecter les tags de base du contenu demandé.",
"error.content.detect.empty": "Aucun contenu en rapport avec les tags choisi n'as été trouvé."
"error.content.detect.empty": "Aucun contenu en rapport avec les tags choisi n'as été trouvé.",
"content.title.error": "$content.title.error",
"content.title.search": "$content.title.search",
"content.title.article": "$content.title.article",
"content.title.application": "$content.title.application"
},
"lb": {
"home.title.nav": "Doheem",