diff --git a/index.php b/index.php index 0b753c1..787164c 100644 --- a/index.php +++ b/index.php @@ -22,7 +22,6 @@ $twig_templates = new Environment($templateloader); $title = ''; $content = ''; -$head = ''; $topictreff = $twig_templates->render('topictreff.html.twig'); $nextevents = $twig_templates->render('nextevents.html.twig'); @@ -43,32 +42,8 @@ if(gettype($raumstatus_b) == "boolean") { } $topic = $util->get_next_topic(); -$topiclink = 'Topictreff'; -switch ($topic->days) { - case 0: - $topic_output = '
Der nächste '.$topiclink.' findet heute statt!
'; - break; - case 1: - $topic_output = 'Der nächste '.$topiclink.' findet morgen statt!
'; - break; - default: - $topic_output = 'Der nächste '.$topiclink.' findet in '.$topic->days.' Tagen ['.$topic->date.'] statt.
'; - break; -} $treff = $util->get_next_treff(); -$trefflink = 'Treff'; -switch ($treff->days) { - case 0: - $treff_output = 'Der nächste '.$trefflink.' findet heute statt!
'; - break; - case 1: - $treff_output = 'Der nächste '.$trefflink.' findet morgen statt!
'; - break; - default: - $treff_output = 'Der nächste '.$trefflink.' findet in '.$treff->days.' Tagen ['.$treff->date.'] statt.
'; - break; -} $repaircafe = $util->get_next_repaircafe(); $repaircafelink = 'RepairCafe'; @@ -98,6 +73,8 @@ switch ($brunch->days) { break; } +$css = ['main']; + if(isset($_GET['page'])) { $page = $_GET['page']; $active_page = $util->str_mass_replace(array('adresse', 'irc', 'mail'), array('kontakt', 'kontakt', 'kontakt'), $page); @@ -105,85 +82,77 @@ if(isset($_GET['page'])) { switch ($page) { case 'index': $content = $twig_pages->render('index.html.twig', [ 'topic' => $topic_output, 'posts' => $util->generate_post_list(4) ]); - $head = $util->css_link('css/main.css').$util->css_link('css/home.css').$util->css_link('css/events.css'); + $css[] = 'home'; + $css[] = 'events'; break; case 'about': $content = $twig_pages->render('about.html.twig'); - $head = $util->css_link('css/main.css').$util->css_link('css/about.css'); + $css[] = 'about'; break; case 'treff': $content = $twig_pages->render('treff.html.twig'); - $head = $util->css_link('css/main.css'); break; case 'blog': if(!isset($_GET['id'])) { $content = $twig_pages->render('blog.html.twig', [ 'posts' => $util->generate_post_list() ]); - $head = $util->css_link('css/main.css').$util->css_link('css/events.css'); + $css[] = 'events'; } else { $content = $converter->convert($util->get_post_content($_GET['id'])); - $head = $util->css_link('css/main.css').$util->css_link('css/event.css'); + $css[] = 'event'; } break; case 'events': if(!isset($_GET['id'])) { - $content = $twig_pages->render('events.html.twig', [ 'topic' => $topic_output, 'treff' => $treff_output, 'repaircafe' => $repaircafe_output, 'brunch' => $brunch_output, 'events' => $util->generate_event_list() ]); - $head = $util->css_link('css/main.css').$util->css_link('css/events.css'); + $content = $twig_pages->render('events.html.twig', [ 'topic' => $topic, 'treff' => $treff, 'repaircafe' => $repaircafe, 'brunch' => $brunch, 'events' => $util->generate_event_list() ]); + $css[] = 'events'; } else { $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']))); - $head = $util->css_link('css/main.css').$util->css_link('css/event.css'); + $css[] = 'event'; } break; case 'kontakt': $content = $twig_pages->render('kontakt.html.twig'); - $head = $util->css_link('css/main.css').$util->css_link('css/kontakt.css'); + $css[] = 'kontakt'; break; case 'adresse': $content = $twig_pages->render('kontakt/adresse.html.twig'); - $head = $util->css_link('css/main.css'); break; case 'irc': $content = $twig_pages->render('kontakt/irc.html.twig'); - $head = $util->css_link('css/main.css'); break; case 'mail': $content = $twig_pages->render('kontakt/mail.html.twig'); - $head = $util->css_link('css/main.css'); break; case 'tel': $content = $twig_pages->render('kontakt/tel.html.twig'); - $head = $util->css_link('css/main.css'); break; case 'support': $content = $twig_pages->render('support.html.twig'); - $head = $util->css_link('css/main.css'); break; case 'verein': $content = $twig_pages->render('verein.html.twig'); - $head = $util->css_link('css/main.css'); break; case 'impressum': $title = 'impressum'; $content = $twig_pages->render('impressum.html.twig'); - $head = $util->css_link('css/main.css'); break; case 'datenschutz': $title = 'datenschutz'; $content = $twig_pages->render('datenschutz.html.twig'); - $head = $util->css_link('css/main.css'); break; default: $content = $twig_pages->render('404.html.twig', ['page' => $_GET['page']]); - $head = $util->css_link('css/main.css'); break; } } else { $active_page = 'index'; $title = $active_page; - $content = $twig_pages->render('index.html.twig', [ 'topic' => $topic_output, 'posts' => $util->generate_post_list(4) ]); - $head = $util->css_link('css/main.css').$util->css_link('css/home.css').$util->css_link('css/events.css'); + $content = $twig_pages->render('index.html.twig', [ 'posts' => $util->generate_post_list(4) ]); + $css[] = 'home'; + $css[] = 'events'; } $nav = $util->generate_nav($active_page, $pages, $page_names); -echo $twig_templates->render('html5struct.html.twig', ['title' => $title, 'head' => $head, 'nav' => $nav, 'raumstatus' => $raumstatus, 'main' => $content]); +echo $twig_templates->render('html5struct.html.twig', ['title' => $title, 'css' => $css, 'nav' => $nav, 'raumstatus' => $raumstatus, 'main' => $content]); ?> diff --git a/pages/events.html.twig b/pages/events.html.twig index 11c618c..de33e95 100644 --- a/pages/events.html.twig +++ b/pages/events.html.twig @@ -1,6 +1,35 @@Der nächste Topictreff findet heute [{{ topic.date }}] statt!
+ {% elseif topic.days == 1 %} +Der nächste Topictreff findet morgen [{{ topic.date }}] statt!
+ {% else %} +Der nächste Topictreff findet in {{ topic.days }} [{{ topic.date }}] statt!
+ {% endif %} + + {% if treff.days == 0 %} +Der nächste Treff findet heute [{{ treff.date }}] statt!
+ {% elseif treff.days == 1 %} +Der nächste Treff findet morgen [{{ treff.date }}] statt!
+ {% else %} +Der nächste Treff findet in {{ treff.days }} [{{ treff.date }}] statt!
+ {% endif %} + + {% if repaircafe.days == 0 %} +Das nächste RepairCafe findet heute [{{ repaircafe.date }}] statt!
+ {% elseif repaircafe.days == 1 %} +Das nächste RepairCafe findet morgen [{{ repaircafe.date }}] statt!
+ {% else %} +Das nächste RepairCafe findet in {{ repaircafe.days }} [{{ repaircafe.date }}] statt!
+ {% endif %} + + {% if brunch.days == 0 %} +Der nächste Brunch findet heute [{{ brunch.date }}] statt!
+ {% elseif brunch.days == 1 %} +Der nächste Brunch findet morgen [{{ brunch.date }}] statt!
+ {% else %} +Der nächste Brunch findet in {{ brunch.days }} [{{ brunch.date }}] statt!
+ {% endif %} + {{ events | raw }} \ No newline at end of file diff --git a/php/util.php b/php/util.php index 53e5239..7f11f1b 100644 --- a/php/util.php +++ b/php/util.php @@ -6,14 +6,13 @@ class Util { } function generate_nav($active_page, $pages, $page_names) { - $output = ''; return $output; } @@ -144,7 +143,7 @@ class Util { $next_topic->add(new DateInterval('P1D')); } - $output->days = $currentDate->diff($next_topic)->days; + $output->days = $currentDate->diff($next_topic)->days+1; $output->date = $next_topic->format('Y-m-d'); return $output; diff --git a/templates/html5struct.html.twig b/templates/html5struct.html.twig index 8fc2c1b..f8ff45f 100644 --- a/templates/html5struct.html.twig +++ b/templates/html5struct.html.twig @@ -7,14 +7,27 @@