hardcode things a bit less
This commit is contained in:
		| @@ -2,6 +2,8 @@ | |||||||
| require_once 'vendor/autoload.php'; | require_once 'vendor/autoload.php'; | ||||||
| use ICal\ICal; | use ICal\ICal; | ||||||
| static $DATE_FORMAT = 'd.m.Y H:i'; | static $DATE_FORMAT = 'd.m.Y H:i'; | ||||||
|  | static $VISITORS_FILE = '/media/sg/dorf.jetzt_visitors'; | ||||||
|  | static $ICAL_URL = 'https://chaosdorf.de/~derf/cccd_all.ics'; | ||||||
| $state_map = array( | $state_map = array( | ||||||
| 	'closed' => (object) array( | 	'closed' => (object) array( | ||||||
| 		'state_string' => 'Das Dorf ist gerade <em>geschlossen</em>.', | 		'state_string' => 'Das Dorf ist gerade <em>geschlossen</em>.', | ||||||
| @@ -10,7 +12,7 @@ $state_map = array( | |||||||
| 	), | 	), | ||||||
| 	'maybe_open' => (object) 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> | 		'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 kurzfristig ändern.', | 		Der Status kann sich also kstartdate_loopurzfristig ändern.', | ||||||
| 		'svg' => 'done', | 		'svg' => 'done', | ||||||
| 		'color' => 'brown', | 		'color' => 'brown', | ||||||
| 	), | 	), | ||||||
| @@ -55,7 +57,7 @@ $state = $hash_to_state[$hash]; | |||||||
| 		'defaultWeekStart' => 'MO', | 		'defaultWeekStart' => 'MO', | ||||||
| 		'filterDaysBefore' => '1', | 		'filterDaysBefore' => '1', | ||||||
| 	)); | 	)); | ||||||
| $ical->initUrl('https://chaosdorf.de/~derf/cccd_all.ics', $acceptLanguage = 'de'); | $ical->initUrl($ICAL_URL, $acceptLanguage = 'de'); | ||||||
| $events = $ical->eventsFromInterval('2 week'); | $events = $ical->eventsFromInterval('2 week'); | ||||||
| $first_event = $events[0]; | $first_event = $events[0]; | ||||||
| $events = array_slice($events, 1); | $events = array_slice($events, 1); | ||||||
| @@ -63,7 +65,7 @@ $locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']); | |||||||
| if ($locale !== null){ | if ($locale !== null){ | ||||||
| 	setlocale(LC_TIME, $locale); | 	setlocale(LC_TIME, $locale); | ||||||
| } | } | ||||||
| $v = file_get_contents('/media/sg/dorf.jetzt_visitors'); | $v = file_get_contents($VISITORS_FILE); | ||||||
| function format_event($event): string{ | function format_event($event): string{ | ||||||
| 	global $DATE_FORMAT, $ical; | 	global $DATE_FORMAT, $ical; | ||||||
| 	$startdate_loop = $ical->iCalDateToDateTime($event->dtstart_array[3]); | 	$startdate_loop = $ical->iCalDateToDateTime($event->dtstart_array[3]); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user