Added content filtering, Removed old files
Update strings.json, blog-listing.php, and 5 more files...
This commit is contained in:
@@ -4,4 +4,5 @@ $host = "nibblepoker.lu";
|
||||
$host_uri = "https://nibblepoker.lu";
|
||||
$dir_commons = dirname(__FILE__);
|
||||
$dir_root = realpath($dir_commons . "/../");
|
||||
$dir_content = realpath($dir_commons . "/../" . "content/");
|
||||
?>
|
@@ -2,6 +2,8 @@
|
||||
<?php
|
||||
// TODO: Include lang once
|
||||
|
||||
// TODO: Add /content as raw input of some sort (No auto tags).
|
||||
|
||||
// This helper requires PHP 8 or newer !
|
||||
|
||||
// Defining constants and enums.
|
||||
@@ -74,9 +76,9 @@ if($requested_content_type == ContentType::BLOG) {
|
||||
} elseif(str_starts_with($content_requested_url_part, "/docker/")) {
|
||||
$requested_tags[] = "docker";
|
||||
} else {
|
||||
$content_has_error = true;
|
||||
$_content_error_message_key = "error.content.detect.subtype";
|
||||
goto content_end;
|
||||
//$content_has_error = true;
|
||||
//$_content_error_message_key = "error.content.detect.subtype";
|
||||
//goto content_end;
|
||||
}
|
||||
} elseif($requested_content_type == ContentType::ELECTRONICS) {
|
||||
// May be changed later if a specific resource is requested and found.
|
||||
@@ -90,9 +92,9 @@ if($requested_content_type == ContentType::BLOG) {
|
||||
} elseif(str_starts_with($content_requested_url_part, "/ham/")) {
|
||||
$requested_tags[] = "ham";
|
||||
} else {
|
||||
$content_has_error = true;
|
||||
$_content_error_message_key = "error.content.detect.subtype";
|
||||
goto content_end;
|
||||
//$content_has_error = true;
|
||||
//$_content_error_message_key = "error.content.detect.subtype";
|
||||
//goto content_end;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +113,37 @@ if(count($requested_tags) == 0) {
|
||||
}
|
||||
$content_requested_url_part = preg_replace("^\/(java|python|purebasic|others|ham|iot|experiments|applications|tutorials|tools)^", "", $content_requested_url_part);
|
||||
|
||||
// TODO: detect specific resource and parameters, and load data.
|
||||
// TODO: Detect specific resource or additional tags and parameters
|
||||
|
||||
if($requested_content_display_type == ContentDisplayType::SEARCH) {
|
||||
// Loading the content index.
|
||||
$content_json = file_get_contents(realpath($dir_content . "/index.json"));
|
||||
$content_index_data = json_decode($content_json, true);
|
||||
unset($content_json);
|
||||
|
||||
// Filtering out unwanted entries.
|
||||
$filtered_content_index_data = array();
|
||||
for($i = 0; $i < count($content_index_data); $i++) {
|
||||
if(count(array_intersect($content_index_data[$i]["tags"], $requested_tags)) == count($requested_tags)) {
|
||||
$filtered_content_index_data[] = $content_index_data[$i];
|
||||
}
|
||||
}
|
||||
|
||||
// Cleaning some variables.
|
||||
unset($content_index_data);
|
||||
unset($content_json);
|
||||
|
||||
// Checking if we found content for the user.
|
||||
if(count($filtered_content_index_data) == 0) {
|
||||
// No relevant article/page were found for the given tags.
|
||||
$content_has_error = true;
|
||||
$_content_error_message_key = "error.content.detect.empty";
|
||||
goto content_end;
|
||||
}
|
||||
}
|
||||
// TODO: Get relevant data
|
||||
|
||||
|
||||
|
||||
content_end:
|
||||
$content_error_message = localize($_content_error_message_key);
|
||||
|
@@ -58,7 +58,8 @@
|
||||
"error.content.detect.category": "Failed to detect which category of content you requested.",
|
||||
"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.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."
|
||||
},
|
||||
"fr": {
|
||||
"home.title.nav": "Accueil",
|
||||
@@ -118,7 +119,8 @@
|
||||
"error.content.detect.category": "Impossibilité de détecter la catégorie de contenu demandée.",
|
||||
"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.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é."
|
||||
},
|
||||
"lb": {
|
||||
"home.title.nav": "Doheem",
|
||||
|
Reference in New Issue
Block a user