2023-02-27 07:34:39 +00:00
|
|
|
<?php
|
2023-02-27 08:11:24 +00:00
|
|
|
|
2023-04-13 16:44:38 +00:00
|
|
|
require __DIR__ . '/vendor/autoload.php';
|
2023-04-17 14:45:44 +00:00
|
|
|
require __DIR__ . '/php/util.php';
|
2023-02-27 07:34:39 +00:00
|
|
|
|
2023-04-13 16:44:38 +00:00
|
|
|
use Twig\Environment;
|
|
|
|
use Twig\Loader\FilesystemLoader;
|
2023-04-30 18:37:16 +00:00
|
|
|
use League\CommonMark\CommonMarkConverter;
|
|
|
|
|
|
|
|
$converter = new CommonMarkConverter([
|
|
|
|
'html_input' => 'strip',
|
|
|
|
'allow_unsafe_links' => false,
|
|
|
|
]);
|
2023-04-13 16:44:38 +00:00
|
|
|
|
2023-04-17 14:45:44 +00:00
|
|
|
$util = new Util();
|
|
|
|
|
2023-04-13 16:44:38 +00:00
|
|
|
$pageloader = new FilesystemLoader(__DIR__ . '/pages');
|
|
|
|
$templateloader = new FilesystemLoader(__DIR__ . '/templates');
|
2023-04-17 14:45:44 +00:00
|
|
|
|
2023-04-13 16:44:38 +00:00
|
|
|
$twig_pages = new Environment($pageloader);
|
|
|
|
$twig_templates = new Environment($templateloader);
|
|
|
|
|
|
|
|
$title = '';
|
|
|
|
$content = '';
|
|
|
|
|
|
|
|
$topictreff = $twig_templates->render('topictreff.html.twig');
|
|
|
|
$nextevents = $twig_templates->render('nextevents.html.twig');
|
|
|
|
|
2023-04-17 14:45:44 +00:00
|
|
|
$raumstatus_b = $util->raumstatus();
|
|
|
|
$raumstatus = '<b>unbekannt</b>';
|
|
|
|
|
2023-05-06 14:34:12 +00:00
|
|
|
$pages = array('index', 'about', 'treff', 'blog', 'events', 'kontakt', 'support', 'verein');
|
|
|
|
$page_names = array('index', 'über uns', 'zeiten & location', 'blog', 'events', 'kontakt', 'support', 'verein');
|
2023-04-30 18:37:16 +00:00
|
|
|
|
|
|
|
$active_page = '';
|
2023-04-17 14:45:44 +00:00
|
|
|
|
|
|
|
if(gettype($raumstatus_b) == "boolean") {
|
|
|
|
if($raumstatus_b)
|
2023-04-30 18:37:16 +00:00
|
|
|
$raumstatus = $util->html_link('https://status.ctdo.de/', 'green-text', '<b>offen</b>', TRUE);
|
2023-04-17 14:45:44 +00:00
|
|
|
else
|
2023-04-30 18:37:16 +00:00
|
|
|
$raumstatus = $util->html_link('https://status.ctdo.de/', 'red-text', '<b>geschlossen</b>', TRUE);
|
2023-04-17 14:45:44 +00:00
|
|
|
}
|
2023-04-13 16:44:38 +00:00
|
|
|
|
2023-05-06 14:34:12 +00:00
|
|
|
$topic = $util->get_next_topic();
|
2023-05-06 21:51:56 +00:00
|
|
|
|
|
|
|
$treff = $util->get_next_treff();
|
|
|
|
|
|
|
|
$repaircafe = $util->get_next_repaircafe();
|
|
|
|
$repaircafelink = '<a href="/?page=events&id=repaircafe">RepairCafe</a>';
|
2023-05-16 11:40:03 +00:00
|
|
|
switch ($repaircafe->days) {
|
2023-05-06 21:51:56 +00:00
|
|
|
case 0:
|
|
|
|
$repaircafe_output = '<p class="topic">Das nächste '.$repaircafelink.' findet heute statt!</p>';
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
$repaircafe_output = '<p class="topic">Das nächste '.$repaircafelink.' findet morgen statt!</p>';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$repaircafe_output = '<p class="topic">Das nächste '.$repaircafelink.' findet in '.$repaircafe->days.' Tagen ['.$repaircafe->date.'] statt.</p>';
|
2023-05-06 14:34:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-05-16 11:40:03 +00:00
|
|
|
$brunch = $util->get_next_brunch();
|
|
|
|
$brunchlink = '<a href="/?page=events&id=brunch">ChaosBrunch</a>';
|
|
|
|
switch ($brunch->days) {
|
|
|
|
case 0:
|
|
|
|
$brunch_output = '<p class="topic">Das nächste '.$brunchlink.' findet heute statt!</p>';
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
$brunch_output = '<p class="topic">Das nächste '.$brunchlink.' findet morgen statt!</p>';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$brunch_output = '<p class="topic">Das nächste '.$brunchlink.' findet in '.$brunch->days.' Tagen ['.$brunch->date.'] statt.</p>';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-06-17 19:51:45 +00:00
|
|
|
$css = ['main'];
|
|
|
|
|
2023-04-13 16:44:38 +00:00
|
|
|
if(isset($_GET['page'])) {
|
|
|
|
$page = $_GET['page'];
|
2023-04-30 18:37:16 +00:00
|
|
|
$active_page = $util->str_mass_replace(array('adresse', 'irc', 'mail'), array('kontakt', 'kontakt', 'kontakt'), $page);
|
|
|
|
$title = $page_names[array_search($active_page, $pages)];
|
2023-04-13 16:44:38 +00:00
|
|
|
switch ($page) {
|
|
|
|
case 'index':
|
2023-05-06 14:34:12 +00:00
|
|
|
$content = $twig_pages->render('index.html.twig', [ 'topic' => $topic_output, 'posts' => $util->generate_post_list(4) ]);
|
2023-06-17 19:51:45 +00:00
|
|
|
$css[] = 'home';
|
|
|
|
$css[] = 'events';
|
2023-04-17 14:45:44 +00:00
|
|
|
break;
|
|
|
|
case 'about':
|
|
|
|
$content = $twig_pages->render('about.html.twig');
|
2023-06-17 19:51:45 +00:00
|
|
|
$css[] = 'about';
|
2023-04-17 14:45:44 +00:00
|
|
|
break;
|
|
|
|
case 'treff':
|
|
|
|
$content = $twig_pages->render('treff.html.twig');
|
|
|
|
break;
|
2023-05-06 14:34:12 +00:00
|
|
|
case 'blog':
|
|
|
|
if(!isset($_GET['id'])) {
|
|
|
|
$content = $twig_pages->render('blog.html.twig', [ 'posts' => $util->generate_post_list() ]);
|
2023-06-17 19:51:45 +00:00
|
|
|
$css[] = 'events';
|
2023-05-06 14:34:12 +00:00
|
|
|
} else {
|
|
|
|
$content = $converter->convert($util->get_post_content($_GET['id']));
|
2023-06-17 19:51:45 +00:00
|
|
|
$css[] = 'event';
|
2023-05-06 14:34:12 +00:00
|
|
|
}
|
|
|
|
break;
|
2023-04-17 14:45:44 +00:00
|
|
|
case 'events':
|
2023-05-06 21:51:56 +00:00
|
|
|
if(!isset($_GET['id'])) {
|
2023-06-17 19:51:45 +00:00
|
|
|
$content = $twig_pages->render('events.html.twig', [ 'topic' => $topic, 'treff' => $treff, 'repaircafe' => $repaircafe, 'brunch' => $brunch, 'events' => $util->generate_event_list() ]);
|
|
|
|
$css[] = 'events';
|
2023-04-30 18:37:16 +00:00
|
|
|
} else {
|
2023-05-16 11:40:03 +00:00
|
|
|
$content = $util->str_mass_replace(array('{{ topicdatum }}', 'Chaostreff Dortmund e.V.', '{{ treffdatum }}', '{{ repaircafedatum }}', '{{ brunchdatum }}'), array($util->get_next_topic()->date, $util->html_link('/?page=treff', '', 'Chaostreff Dortmund e.V.', FALSE), $util->get_next_treff()->date, $util->get_next_repaircafe()->date, $util->get_next_brunch()->date), $converter->convert($util->get_event_content($_GET['id'])));
|
2023-06-17 19:51:45 +00:00
|
|
|
$css[] = 'event';
|
2023-04-30 18:37:16 +00:00
|
|
|
}
|
2023-04-17 14:45:44 +00:00
|
|
|
break;
|
|
|
|
case 'kontakt':
|
|
|
|
$content = $twig_pages->render('kontakt.html.twig');
|
2023-06-17 19:51:45 +00:00
|
|
|
$css[] = 'kontakt';
|
2023-04-17 14:45:44 +00:00
|
|
|
break;
|
|
|
|
case 'adresse':
|
|
|
|
$content = $twig_pages->render('kontakt/adresse.html.twig');
|
|
|
|
break;
|
|
|
|
case 'irc':
|
|
|
|
$content = $twig_pages->render('kontakt/irc.html.twig');
|
|
|
|
break;
|
|
|
|
case 'mail':
|
|
|
|
$content = $twig_pages->render('kontakt/mail.html.twig');
|
|
|
|
break;
|
|
|
|
case 'tel':
|
|
|
|
$content = $twig_pages->render('kontakt/tel.html.twig');
|
|
|
|
break;
|
|
|
|
case 'support':
|
|
|
|
$content = $twig_pages->render('support.html.twig');
|
|
|
|
break;
|
|
|
|
case 'verein':
|
|
|
|
$content = $twig_pages->render('verein.html.twig');
|
|
|
|
break;
|
|
|
|
case 'impressum':
|
2023-04-30 18:37:16 +00:00
|
|
|
$title = 'impressum';
|
2023-04-17 14:45:44 +00:00
|
|
|
$content = $twig_pages->render('impressum.html.twig');
|
|
|
|
break;
|
|
|
|
case 'datenschutz':
|
2023-04-30 18:37:16 +00:00
|
|
|
$title = 'datenschutz';
|
2023-04-17 14:45:44 +00:00
|
|
|
$content = $twig_pages->render('datenschutz.html.twig');
|
2023-04-13 16:44:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$content = $twig_pages->render('404.html.twig', ['page' => $_GET['page']]);
|
|
|
|
break;
|
2023-02-27 07:34:39 +00:00
|
|
|
}
|
2023-04-13 16:44:38 +00:00
|
|
|
} else {
|
2023-04-30 18:37:16 +00:00
|
|
|
$active_page = 'index';
|
|
|
|
$title = $active_page;
|
2023-06-17 19:51:45 +00:00
|
|
|
$content = $twig_pages->render('index.html.twig', [ 'posts' => $util->generate_post_list(4) ]);
|
|
|
|
$css[] = 'home';
|
|
|
|
$css[] = 'events';
|
2023-04-13 16:44:38 +00:00
|
|
|
}
|
|
|
|
|
2023-04-30 18:37:16 +00:00
|
|
|
$nav = $util->generate_nav($active_page, $pages, $page_names);
|
|
|
|
|
2023-06-17 19:51:45 +00:00
|
|
|
echo $twig_templates->render('html5struct.html.twig', ['title' => $title, 'css' => $css, 'nav' => $nav, 'raumstatus' => $raumstatus, 'main' => $content]);
|
2023-04-13 16:44:38 +00:00
|
|
|
?>
|