From 33ecff552c0c3b6076c10489fcc9524be3ec6772 Mon Sep 17 00:00:00 2001 From: Vencislav Atanasov Date: Sun, 16 Oct 2016 21:01:19 +0300 Subject: [PATCH] Add legend, fix issues with the locale --- schedule/index.php | 13 +++++++++++-- schedule/parse.php | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/schedule/index.php b/schedule/index.php index 43ca62a..6b9875c 100644 --- a/schedule/index.php +++ b/schedule/index.php @@ -2,7 +2,7 @@ error_reporting(~0); ini_set('display_errors', 1); -$lang = 'bg'; +define('SCHED_LANG', 'bg'); ?> @@ -23,7 +23,7 @@ $content = require __DIR__ . DIRECTORY_SEPARATOR . 'parse.php'; - + @@ -38,6 +38,15 @@ foreach ($content['lines'] as $line) {
+ + + + +
array( + 'name' => 'English', + 'locale' => 'en_US.UTF8' + ), + 'bg' => array( + 'name' => 'Български', + 'locale' => 'bg_BG.UTF8' + ) +); + +/* We need to set these so we actually parse properly the dates. WP fucks up both. */ +date_default_timezone_set('Europe/Sofia'); +setlocale(LC_TIME, $languages[SCHED_LANG]['locale']); + foreach ($data['slots'] as $slot_id => $slot) { $slotTime = $slot['starts_at']; $slotDate = date('d', $slotTime); if ($slotDate !== $date) { $lines[] = ''; - $lines[] = '' . date('d F - l', $slotTime) . ''; + $lines[] = '' . strftime('%d %B - %A', $slotTime) . ''; $lines[] = ' '; $lines[] = ''; @@ -114,6 +133,17 @@ foreach ($data['slots'] as $slot_id => $slot) { $lines[] = ''; +/* create the legend */ +$legend = []; + +foreach($data['tracks'] as $track) { + $legend[] = '' . $track['name'][SCHED_LANG] . ''; +} + +foreach ($languages as $code => $lang) { + $legend[] = '' . $lang['name'] . ''; +} + $gspk = []; $fspk = []; $types = []; @@ -150,4 +180,4 @@ foreach ($data['speakers'] as $speaker) { $gspk[] = ''; -return array_merge($data, compact('lines', 'fulltalks', 'gspk', 'fspk')); +return array_merge($data, compact('lines', 'fulltalks', 'gspk', 'fspk', 'legend'));