133 lines
4.7 KiB
PHP
133 lines
4.7 KiB
PHP
<?php
|
|
|
|
require __DIR__ . '/vendor/autoload.php';
|
|
|
|
use Twig\Environment;
|
|
use Twig\Loader\FilesystemLoader;
|
|
use League\CommonMark\CommonMarkConverter;
|
|
|
|
require __DIR__ . '/php/util.php';
|
|
require __DIR__ . '/php/events.php';
|
|
require __DIR__ . '/php/posts.php';
|
|
|
|
$converter = new CommonMarkConverter([
|
|
'html_input' => 'strip',
|
|
'allow_unsafe_links' => false,
|
|
]);
|
|
|
|
$pageloader = new FilesystemLoader(__DIR__ . '/pages');
|
|
$templateloader = new FilesystemLoader(__DIR__ . '/templates');
|
|
|
|
$twig_pages = new Environment($pageloader);
|
|
$twig_templates = new Environment($templateloader);
|
|
|
|
$title = '';
|
|
$content = '';
|
|
|
|
$raumstatus_b = get_web_json('https://status.ctdo.de/api/simple/v2')["state"];
|
|
$raumstatus = '<b>unbekannt</b>';
|
|
|
|
$pages = array('index', 'about', 'treff', 'blog', 'events', 'kontakt', 'support', 'verein');
|
|
$page_names = array('index', 'über uns', 'zeiten & location', 'blog', 'events', 'kontakt', 'support', 'verein');
|
|
|
|
$active_page = '';
|
|
|
|
if(gettype($raumstatus_b) == "boolean") {
|
|
if($raumstatus_b)
|
|
$raumstatus = html_link('https://status.ctdo.de/', 'green-text', '<b>offen</b>', TRUE);
|
|
else
|
|
$raumstatus = html_link('https://status.ctdo.de/', 'red-text', '<b>geschlossen</b>', TRUE);
|
|
}
|
|
|
|
$topic = get_next_topic();
|
|
|
|
$treff = get_next_treff();
|
|
|
|
$repaircafe = get_next_repaircafe();
|
|
|
|
$brunch = get_next_brunch();
|
|
|
|
$css = ['main'];
|
|
|
|
if(isset($_GET['page'])) {
|
|
$page = $_GET['page'];
|
|
$active_page = str_mass_replace(array('adresse', 'irc', 'mail'), array('kontakt', 'kontakt', 'kontakt'), $page);
|
|
$title = $page_names[array_search($active_page, $pages)];
|
|
switch ($page) {
|
|
case 'index':
|
|
$content = $twig_pages->render('index.twig', [ 'topic' => $topic_output, 'posts' => generate_post_list(4) ]);
|
|
$css[] = 'home';
|
|
$css[] = 'events';
|
|
break;
|
|
case 'about':
|
|
$content = $twig_pages->render('about.twig');
|
|
$css[] = 'about';
|
|
break;
|
|
case 'treff':
|
|
$content = $twig_pages->render('treff.twig');
|
|
break;
|
|
case 'blog':
|
|
if(!isset($_GET['id'])) {
|
|
$content = $twig_pages->render('blog.twig', [ 'posts' => generate_post_list() ]);
|
|
$css[] = 'events';
|
|
} else {
|
|
$content = $converter->convert(get_post_content($_GET['id']));
|
|
$css[] = 'event';
|
|
}
|
|
break;
|
|
case 'events':
|
|
if(!isset($_GET['id'])) {
|
|
$content = $twig_pages->render('events.twig', [ 'topic' => $topic, 'treff' => $treff, 'repaircafe' => $repaircafe, 'brunch' => $brunch, 'events' => generate_event_list() ]);
|
|
$css[] = 'events';
|
|
} else {
|
|
$content = str_mass_replace(array('{{ topicdatum }}', 'Chaostreff Dortmund e.V.', '{{ treffdatum }}', '{{ repaircafedatum }}', '{{ brunchdatum }}'), array(get_next_topic()->date, html_link('/?page=treff', '', 'Chaostreff Dortmund e.V.', FALSE), get_next_treff()->date, get_next_repaircafe()->date, get_next_brunch()->date), $converter->convert(get_event_content($_GET['id'])));
|
|
$css[] = 'event';
|
|
}
|
|
break;
|
|
case 'kontakt':
|
|
$content = $twig_pages->render('kontakt.twig');
|
|
$css[] = 'kontakt';
|
|
break;
|
|
case 'adresse':
|
|
$content = $twig_pages->render('kontakt/adresse.twig');
|
|
break;
|
|
case 'irc':
|
|
$content = $twig_pages->render('kontakt/irc.twig');
|
|
break;
|
|
case 'mail':
|
|
$content = $twig_pages->render('kontakt/mail.twig');
|
|
break;
|
|
case 'tel':
|
|
$content = $twig_pages->render('kontakt/tel.twig');
|
|
break;
|
|
case 'support':
|
|
$content = $twig_pages->render('support.twig');
|
|
break;
|
|
case 'verein':
|
|
$content = $twig_pages->render('verein.twig');
|
|
break;
|
|
case 'impressum':
|
|
$title = 'impressum';
|
|
$content = $twig_pages->render('impressum.twig');
|
|
break;
|
|
case 'datenschutz':
|
|
$title = 'datenschutz';
|
|
$content = $twig_pages->render('datenschutz.twig');
|
|
break;
|
|
default:
|
|
$content = $twig_pages->render('404.twig', ['page' => $_GET['page']]);
|
|
break;
|
|
}
|
|
} else {
|
|
$active_page = 'index';
|
|
$title = $active_page;
|
|
$content = $twig_pages->render('index.twig', [ 'posts' => generate_post_list(4) ]);
|
|
$css[] = 'home';
|
|
$css[] = 'events';
|
|
}
|
|
|
|
$nav = generate_nav($active_page, $pages, $page_names);
|
|
|
|
echo $twig_templates->render('default.twig', ['title' => $title, 'css' => $css, 'nav' => $nav, 'raumstatus' => $raumstatus, 'main' => $content]);
|
|
?>
|