WIP: bring participo back - consistent use of bootstrap - formatting -
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
This commit is contained in:
@@ -1,137 +1,122 @@
|
||||
<?php
|
||||
require_once("./config/participo.php");
|
||||
require_once "bootstrap.php";
|
||||
|
||||
require_once($config['basePath'] . "/ressourcen/parsedown/Parsedown.php");
|
||||
require_once($config['basePath'] . "/ressourcen/spyc/Spyc.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";
|
||||
$mdRoot =
|
||||
"markdown/" .
|
||||
(array_key_exists("kyu", $_GET) ? $_GET["kyu"] : "8") .
|
||||
"terKyu";
|
||||
|
||||
participo::init($CONFIG["cwsvJudo"], $SECRETS["cwsvJudo"]);
|
||||
|
||||
$Parsedown = new Parsedown();
|
||||
|
||||
//! loading a markdownfile with yaml-header
|
||||
//! returns an assocative array('yaml'=>array(..), 'mdText'=>string)
|
||||
function loadMarkdownFile($fileName){
|
||||
$fileText = file_get_contents($fileName);
|
||||
|
||||
$fileParts = preg_split('/[\n]*[-]{3}[\n]/', $fileText, 3);
|
||||
|
||||
return array(
|
||||
'yaml' => Spyc::YAMLLoadString($fileParts[1])
|
||||
, 'mdText' => preg_replace("/^#(.*)$/m", "", $fileParts[2])
|
||||
);
|
||||
}
|
||||
|
||||
/// @brief Gibt die URL der gerade aufgerufenen Seite zurück
|
||||
function getCurPagesUrl(){
|
||||
$pageURL = 'http';
|
||||
if ($_SERVER["HTTPS"] == "on"){
|
||||
$pageURL .= "s";
|
||||
}
|
||||
$pageURL .= "://";
|
||||
if($_SERVER["SERVER_PORT"] != "80"){
|
||||
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
||||
}
|
||||
else{
|
||||
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
||||
}
|
||||
return $pageURL;
|
||||
}
|
||||
|
||||
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>";
|
||||
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 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>";
|
||||
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>";
|
||||
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>
|
||||
@@ -139,11 +124,11 @@ function ytLightEmbed($item){
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Gürtelprüfungsordnung</title>
|
||||
<?php readfile("./shared/imports.php");?>
|
||||
<?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>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo($config['baseUrl']);?>/ressourcen/video-js/video-js.min.css">
|
||||
<script type="javascript" src="<?php echo($config['baseUrl']);?>/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> -->
|
||||
@@ -165,7 +150,7 @@ function ytLightEmbed($item){
|
||||
</script>
|
||||
<style>
|
||||
h1{
|
||||
font-size: 2.5rem;
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
h2{
|
||||
font-size: 2.25rem;
|
||||
@@ -174,7 +159,7 @@ function ytLightEmbed($item){
|
||||
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>
|
||||
@@ -186,55 +171,66 @@ function ytLightEmbed($item){
|
||||
|
||||
<body>
|
||||
<ul id="slide-out" class="sidenav">
|
||||
<?php require_once("sidenav/loginStatus.php");?>
|
||||
<?php require_once "sidenav/loginStatus.php"; ?>
|
||||
<li><div class="divider"></div></li>
|
||||
<?php require_once("sidenav/kyu.php"); ?>
|
||||
<?php require_once "sidenav/kyu.php"; ?>
|
||||
<li><div class="divider"></div></li>
|
||||
<?php require_once("sidenav/backToMain.php"); ?>
|
||||
<?php require_once "sidenav/backToMain.php"; ?>
|
||||
</ul>
|
||||
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
|
||||
<?php
|
||||
$kyuMetadata = Spyc::YAMLLoad( $mdRoot."/meta.yaml" );
|
||||
echo("<h1>".$kyuMetadata['title']."</h1>");
|
||||
<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("<div class=\"row\">");
|
||||
echo("<h2>".$sectionMetadata['title']."</h2>");
|
||||
$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>");
|
||||
};
|
||||
?>
|
||||
$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
|
||||
<a
|
||||
title="Seite auf HTML 5 Konformität prüfen"
|
||||
href="http://validator.w3.org/check?uri=<?php echo(urlencode(getCurPagesUrl()));?>"
|
||||
href="http://validator.w3.org/check?uri=<?php echo urlencode(
|
||||
getCurPagesUrl(),
|
||||
); ?>"
|
||||
rel="nofollow"
|
||||
>Valid <img
|
||||
src="/ressourcen/graphiken/icons/HTML5_1Color_Black.svg"
|
||||
@@ -249,4 +245,4 @@ function ytLightEmbed($item){
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user