phpstan level 0 error free - fixes for kyu subpage - move mams into participo framework - remove legacy `lib/db.php` usage - add attributer admin function - add newsposter - fixing apiKey creation
249 lines
7.4 KiB
PHP
249 lines
7.4 KiB
PHP
<?php
|
||
require_once "bootstrap.php";
|
||
|
||
require_once "participoLib/participo.php";
|
||
require_once "parsedown/Parsedown.php";
|
||
require_once "spyc/Spyc.php";
|
||
|
||
$mdRoot =
|
||
"markdown/" .
|
||
(array_key_exists("kyu", $_GET) ? $_GET["kyu"] : "8") .
|
||
"terKyu";
|
||
|
||
participo::init($CONFIG["cwsvJudo"], $SECRETS["cwsvJudo"]);
|
||
|
||
$Parsedown = new Parsedown();
|
||
|
||
function htmlCardCode($article, $Parsedown)
|
||
{
|
||
if (empty($article["yaml"]) && empty($article["mdText"])) {
|
||
return "";
|
||
}
|
||
$videoFrame = array_key_exists("yaml", $article)
|
||
? (array_key_exists("video", $article["yaml"])
|
||
? "<div style=\"text-align: center;width=100%;height=auto;\">" .
|
||
html5VideoFrame($article["yaml"]["video"]) .
|
||
"</div>"
|
||
: "")
|
||
: "";
|
||
$ytVideoFrame = array_key_exists("yaml", $article)
|
||
? (array_key_exists("youtube", $article["yaml"])
|
||
? ytLightEmbed($article["yaml"]["youtube"])
|
||
: "")
|
||
: "";
|
||
return "<div class=\"col s12 m6\">" .
|
||
"<div class=\"card blue-grey darken-1\">" .
|
||
"<div class=\"card-image\">" .
|
||
(!empty($videoFrame) ? $videoFrame : $ytVideoFrame) .
|
||
"</div>" .
|
||
"<div class=\"card-content white-text\">" .
|
||
"<span class=\"card-title activator\">" .
|
||
$article["yaml"]["title"] .
|
||
"<i class=\"material-icons right\">more_vert</i>" .
|
||
"</span>" .
|
||
"</div>" .
|
||
"<div class=\"card-reveal\">" .
|
||
"<span class=\"card-title\">" .
|
||
$article["yaml"]["title"] .
|
||
"<i class=\"material-icons right\">close</i>" .
|
||
"</span>" .
|
||
$Parsedown->text($article["mdText"]) .
|
||
"</div>" .
|
||
"</div>" .
|
||
"</div>";
|
||
}
|
||
|
||
//! create the <video>Tag for videoJs
|
||
function videoJsFrame($item)
|
||
{
|
||
return "<video " .
|
||
"id=\"" .
|
||
str_replace("/", "-", $item["url"]) .
|
||
"\" " .
|
||
"class=\"video-js\" " .
|
||
"controls " .
|
||
"preload=\"auto\" " .
|
||
// ."poster=\"//vjs.zencdn.net/v/oceans.png\""
|
||
"data-setup='{}' " .
|
||
">" .
|
||
"<source src=\"" .
|
||
$item["url"] .
|
||
"\" type=\"video/webm\">" . //</source>"
|
||
"<p class=\"vjs-no-js\">" .
|
||
"To view this video please enable JavaScript, and consider upgrading to a web browser that " .
|
||
"<a href=\"https://videojs.com/html5-video-support/\" target=\"_blank\">" .
|
||
"supports HTML5 video" .
|
||
"</a>" .
|
||
"</p>" .
|
||
"</video>";
|
||
}
|
||
|
||
function html5VideoFrame($item)
|
||
{
|
||
return "<video " .
|
||
"style=\"max-width:100%;height: auto;\"" .
|
||
" src=\"" .
|
||
$item["url"] .
|
||
"\"" .
|
||
" width=\"" .
|
||
$item["width"] .
|
||
"\"" .
|
||
" height=\"" .
|
||
$item["height"] .
|
||
"\"" .
|
||
" controls" .
|
||
" preload=\"none\"" .
|
||
(array_key_exists("poster", $item)
|
||
? " poster=\"" . $item["poster"]["url"] . "\""
|
||
: "") .
|
||
"></video>";
|
||
}
|
||
|
||
//! embed youtube
|
||
function ytLightEmbed($item)
|
||
{
|
||
return "<lite-youtube " .
|
||
"videoid=\"" .
|
||
$item["videoid"] .
|
||
"\" " .
|
||
// ."playlabel=\"".$title."\""
|
||
"params=\"" .
|
||
"start=" .
|
||
$item["from"] .
|
||
"&end=" .
|
||
$item["to"] .
|
||
"&modestbranding=1" .
|
||
"&playsinline=0" .
|
||
"&loop=1" .
|
||
"\" " .
|
||
"></lite-youtube>";
|
||
}
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="de">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>Gürtelprüfungsordnung</title>
|
||
<?php readfile("./shared/imports.php"); ?>
|
||
|
||
<link rel="stylesheet" type="text/css" href="/ressourcen/video-js/video-js.min.css">
|
||
<script type="javascript" src="/ressourcen/video-js/video.min.js"></script>
|
||
|
||
<!-- Include the CSS & JS.. (This could be direct from the package or bundled) -->
|
||
<!-- <link rel="stylesheet" href="lib/lite-youtube-embed/lite-yt-embed.css" />
|
||
<script src="lib/lite-youtube-embed/lite-yt-embed.js"></script> -->
|
||
|
||
<!--- AutoInit -->
|
||
<script>
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
var materialboxElements = document.querySelectorAll('.materialboxed');
|
||
var materialboxInstances = M.Materialbox.init(materialboxElements, {
|
||
// specify options here
|
||
});
|
||
});
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
var elems = document.querySelectorAll('.sidenav');
|
||
var instances = M.Sidenav.init(elems, {
|
||
// specify options here
|
||
});
|
||
});
|
||
</script>
|
||
<style>
|
||
h1{
|
||
font-size: 2.5rem;
|
||
}
|
||
h2{
|
||
font-size: 2.25rem;
|
||
}
|
||
h3{
|
||
font-size: 2.0rem;
|
||
}
|
||
</style>
|
||
|
||
<!--Let browser know website is optimized for mobile-->
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||
<style>
|
||
ul:not(.browser-default) > li{
|
||
list-style-type: circle;
|
||
}
|
||
</style>
|
||
</head>
|
||
|
||
<body>
|
||
<ul id="slide-out" class="sidenav">
|
||
<?php require_once "sidenav/loginStatus.php"; ?>
|
||
<li><div class="divider"></div></li>
|
||
<?php require_once "sidenav/kyu.php"; ?>
|
||
<li><div class="divider"></div></li>
|
||
<?php require_once "sidenav/backToMain.php"; ?>
|
||
</ul>
|
||
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
|
||
<em>Achtung: Seit dem 1. Januar 2024 gilt mittlerweile ein <a href="https://www.judobund.de/bildung/graduierungssystem/kyu-graduierungssystem">neues Gürtelprüfungsprogramm</a>. Bei Gelegenheit™️ wird es auch hier aktualisiert.</em>
|
||
<?php if (is_dir($mdRoot)) {
|
||
$kyuMetadata = Spyc::YAMLLoad($mdRoot . "/meta.yaml");
|
||
echo "<h1>" . $kyuMetadata["title"] . "</h1>";
|
||
|
||
$dirNames = [];
|
||
$dirIterator = new DirectoryIterator($mdRoot);
|
||
foreach ($dirIterator as $dirInfo) {
|
||
if (!$dirInfo->isDir() || $dirInfo->isDot()) {
|
||
continue;
|
||
}
|
||
$dirNames[] = $dirInfo->__toString();
|
||
}
|
||
sort($dirNames);
|
||
foreach ($dirNames as $dirName) {
|
||
$fullDirName = $mdRoot . "/" . $dirName;
|
||
$sectionMetadata = Spyc::YAMLLoad($fullDirName . "/meta.yaml");
|
||
echo "<h2>" . $sectionMetadata["title"] . "</h2>";
|
||
echo "<div class=\"row\">";
|
||
|
||
$fileIterator = new DirectoryIterator($fullDirName);
|
||
$fileNames = [];
|
||
foreach ($fileIterator as $fileInfo) {
|
||
if (!$fileInfo->isFile()) {
|
||
continue;
|
||
}
|
||
if ($fileInfo->getExtension() != "md") {
|
||
continue;
|
||
}
|
||
$fileNames[] = $fileInfo->__toString();
|
||
}
|
||
sort($fileNames);
|
||
foreach ($fileNames as $fileName) {
|
||
$fullFileName = $fullDirName . "/" . $fileName;
|
||
$article = loadMarkdownFile($fullFileName);
|
||
echo htmlCardCode($article, $Parsedown);
|
||
}
|
||
echo "</div>";
|
||
}
|
||
} else {
|
||
echo "<h2>Fehler: Verzeichnis `{$mdRoot}` nicht gefunden!</h2>";
|
||
} ?>
|
||
|
||
<footer class="page-footer blue-grey darken-1">
|
||
<div class="container">
|
||
<div class="col l4 offset-l2 s12">
|
||
<ul>
|
||
<li>
|
||
<a
|
||
title="Seite auf HTML 5 Konformität prüfen"
|
||
href="http://validator.w3.org/check?uri=<?php echo urlencode(
|
||
getCurPagesUrl(),
|
||
); ?>"
|
||
rel="nofollow"
|
||
>Valid <img
|
||
src="/ressourcen/graphiken/icons/HTML5_1Color_Black.svg"
|
||
alt="HTML 5"
|
||
title="HTML 5 Logo"
|
||
style="height:1em;display:inline;vertical-align:middle;">
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
|
||
</body>
|
||
</html>
|