2024-02-22 09:42:37 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once "lib/router.php";
|
|
|
|
require_once "lib/newsarticle.php";
|
|
|
|
|
|
|
|
global $routerConfig;
|
|
|
|
|
|
|
|
$output = file_get_contents($routerConfig["template_dir"] . "newsArticles.html");
|
|
|
|
|
|
|
|
$articles_out = "";
|
2024-02-22 13:57:05 +01:00
|
|
|
$articles = [];
|
|
|
|
$articles_tmp = getNewsArticles();
|
|
|
|
if($articles_tmp['Status'] == "Success"){
|
|
|
|
$articles = $articles_tmp["Articles"];
|
|
|
|
}
|
2024-02-22 09:42:37 +01:00
|
|
|
|
2024-02-22 13:57:05 +01:00
|
|
|
$articleTemplate = file_get_contents($routerConfig["template_dir"] . "newsArticle.html");
|
2024-02-22 18:00:30 +01:00
|
|
|
$output = str_replace("__TEMPLATE_FOR_ARTICLE_CONTENT__", $articleTemplate, $output);
|
2024-02-22 09:42:37 +01:00
|
|
|
foreach ($articles as $article){
|
|
|
|
$articleTitle = htmlspecialchars($article["Title"]);
|
|
|
|
$articleBody = htmlspecialchars($article["Body"]);
|
2024-04-25 23:40:27 +02:00
|
|
|
//$articleFileList = $article["FileList"];
|
2024-04-25 23:42:07 +02:00
|
|
|
//$articleWrittenBy = $article["WrittenBy"];
|
2024-02-22 09:42:37 +01:00
|
|
|
$articleWrittenAt = htmlspecialchars($article["WrittenAt"]);
|
2024-02-22 18:00:30 +01:00
|
|
|
$articleWrittenByName = htmlspecialchars($article["WrittenByName"]);
|
2024-11-18 22:55:24 +01:00
|
|
|
$articleTemplateTemp = str_replace("__TEMPLATE_ARTICLE_TITLE__", $articleTitle, $articleTemplate);
|
|
|
|
$articleTemplateTemp = str_replace("__TEMPLATE_ARTICLE_AUTHOR__", $articleWrittenByName, $articleTemplateTemp);
|
|
|
|
$articleTemplateTemp = str_replace("__TEMPLATE_ARTICLE_DATE__", $articleWrittenAt, $articleTemplateTemp);
|
|
|
|
$articleTemplateTemp = str_replace("__TEMPLATE_ARTICLE_BODY__", $articleBody, $articleTemplateTemp);
|
2024-02-22 13:57:05 +01:00
|
|
|
|
2024-11-18 22:55:24 +01:00
|
|
|
$articles_out .= $articleTemplateTemp;
|
2024-02-22 09:42:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$output = str_replace("__TEMPLATE__ARTICLES_HERE__", $articles_out, $output);
|
|
|
|
|
|
|
|
return [
|
|
|
|
"output" => $output,
|
|
|
|
"parameters" =>
|
|
|
|
[
|
2024-02-24 09:01:55 +01:00
|
|
|
"minimal_permission_level" => 1,
|
2024-02-22 09:42:37 +01:00
|
|
|
"secret" => "no",
|
2024-11-18 22:55:24 +01:00
|
|
|
"page_title" => "Articles"
|
2024-02-22 09:42:37 +01:00
|
|
|
]
|
|
|
|
];
|