Add switch for disabling event calendar (SARS-CoV-2 Switch™)
This commit is contained in:
		
							
								
								
									
										17
									
								
								index.php
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								index.php
									
									
									
									
									
								
							@@ -3,6 +3,7 @@ require_once 'vendor/autoload.php';
 | 
			
		||||
use ICal\ICal;
 | 
			
		||||
static $DATE_FORMAT = 'd.m.Y H:i';
 | 
			
		||||
static $VISITORS_FILE = '/media/sg/dorf.jetzt_visitors';
 | 
			
		||||
static $ENABLE_CALENDAR = false;
 | 
			
		||||
static $ICAL_URL = 'https://chaosdorf.de/~derf/cccd_all.ics';
 | 
			
		||||
$state_map = array(
 | 
			
		||||
	'closed' => (object) array(
 | 
			
		||||
@@ -12,7 +13,7 @@ $state_map = array(
 | 
			
		||||
	),
 | 
			
		||||
	'maybe_open' => (object) array(
 | 
			
		||||
		'state_string' => 'Das Dorf ist gerade <em>vielleicht geöffnet</em>: </p><p>Der Clubraum ist offen, aber es findet keine Veranstaltung statt.</p><p>
 | 
			
		||||
		Der Status kann sich also kstartdate_loopurzfristig ändern.',
 | 
			
		||||
		Der Status kann sich also kurzfristig ändern.',
 | 
			
		||||
		'svg' => 'done',
 | 
			
		||||
		'color' => 'brown',
 | 
			
		||||
	),
 | 
			
		||||
@@ -51,6 +52,7 @@ $hash_to_state = array(
 | 
			
		||||
$img = file_get_contents('https://chaosdorf.de/raumstatus/status.png');
 | 
			
		||||
$hash = md5($img);
 | 
			
		||||
$state = $hash_to_state[$hash];
 | 
			
		||||
if ($ENABLE_CALENDAR){
 | 
			
		||||
	$ical = new ICal(false, array(
 | 
			
		||||
			'defaultSpan' => 2,
 | 
			
		||||
			'defaultTimeZone' => 'Europe/Berlin',
 | 
			
		||||
@@ -65,7 +67,6 @@ $locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
 | 
			
		||||
	if ($locale !== null){
 | 
			
		||||
		setlocale(LC_TIME, $locale);
 | 
			
		||||
	}
 | 
			
		||||
$v = file_get_contents($VISITORS_FILE);
 | 
			
		||||
	function format_event($event): string{
 | 
			
		||||
		global $DATE_FORMAT, $ical;
 | 
			
		||||
		$startdate_loop = $ical->iCalDateToDateTime($event->dtstart_array[3]);
 | 
			
		||||
@@ -78,6 +79,8 @@ function format_event($event): string{
 | 
			
		||||
		}
 | 
			
		||||
		return $startdate_str . ' – ' . $enddate_str; 
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
$v = file_get_contents($VISITORS_FILE);
 | 
			
		||||
?>
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="de">
 | 
			
		||||
@@ -107,6 +110,7 @@ function format_event($event): string{
 | 
			
		||||
			<div class="card mb-3 text-center">
 | 
			
		||||
				<div class="card-body">
 | 
			
		||||
					<h5 class="card-title">Events</h5>
 | 
			
		||||
					<?php if ($ENABLE_CALENDAR){ ?>
 | 
			
		||||
					<h6 class="card-subtitle mb-2 text-muted">Nächste Veranstaltung</h6>
 | 
			
		||||
					<p class="card-text">
 | 
			
		||||
						<h5 class="font-weight-bold"><?= htmlspecialchars($first_event->summary, ENT_QUOTES, 'UTF-8') ?></h5>
 | 
			
		||||
@@ -124,6 +128,15 @@ function format_event($event): string{
 | 
			
		||||
						</tbody>
 | 
			
		||||
					</table>
 | 
			
		||||
					<a href="https://wiki.chaosdorf.de/Chaosdorf_Wiki:Current_events" class="btn btn-lg btn-block btn-primary">Event-Kalender</a>
 | 
			
		||||
					<?php } else { ?>
 | 
			
		||||
					<h6 class="card-subtitle mb-2 text-muted">Aktuell keine Veranstaltungen.</h6>
 | 
			
		||||
					<p class="card-text">
 | 
			
		||||
						<span class="font-weight-normal">
 | 
			
		||||
							Aktuell finden als Vorsichtsmaßnahme keine öffentlichen Veranstaltungen statt.<br>
 | 
			
		||||
							Bitte beobachte <a href="https://chaosdorf.de">den Blog des Chaosdorf</a> für weitere Informationen.
 | 
			
		||||
						</span>
 | 
			
		||||
					</p>
 | 
			
		||||
					<?php } ?>
 | 
			
		||||
				</div>
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user