Rewrite the schedule generation script #31

Merged
user890104 merged 19 commits from schedule-rewrite into master 2016-10-24 00:52:04 +03:00
2 changed files with 43 additions and 4 deletions
Showing only changes of commit 33ecff552c - Show all commits

View File

@ -2,7 +2,7 @@
error_reporting(~0); error_reporting(~0);
ini_set('display_errors', 1); ini_set('display_errors', 1);
$lang = 'bg'; define('SCHED_LANG', 'bg');
?> ?>
<html> <html>
<head> <head>
@ -23,7 +23,7 @@ $content = require __DIR__ . DIRECTORY_SEPARATOR . 'parse.php';
<?php <?php
foreach ($content['halls'] as $hall_name) { foreach ($content['halls'] as $hall_name) {
?> ?>
<td><?php echo htmlspecialchars($hall_name[$lang]); ?></td> <td><?php echo htmlspecialchars($hall_name[SCHED_LANG]); ?></td>
<?php <?php
} }
?> ?>
@ -38,6 +38,15 @@ foreach ($content['lines'] as $line) {
</tbody> </tbody>
</table> </table>
<div class="separator"></div> <div class="separator"></div>
<table border="1">
<tbody>
<?php
foreach ($content['legend'] as $line) {
echo $line, PHP_EOL;
}
?>
</tbody>
</table>
<?php <?php
foreach ($content['fulltalks'] as $line) { foreach ($content['fulltalks'] as $line) {
echo $line, PHP_EOL; echo $line, PHP_EOL;

View File

@ -9,6 +9,10 @@
$data = require __DIR__ . DIRECTORY_SEPARATOR . 'load.php'; $data = require __DIR__ . DIRECTORY_SEPARATOR . 'load.php';
if (!defined('SCHED_LANG')) {
define('SCHED_LANG', 'bg');
}
$cut_len = 70; $cut_len = 70;
$cfp_url = 'http://cfp.openfest.org'; $cfp_url = 'http://cfp.openfest.org';
$time = 0; $time = 0;
@ -21,13 +25,28 @@ $hall_ids = array_keys($data['halls']);
$first_hall_id = min($hall_ids); $first_hall_id = min($hall_ids);
$last_hall_id = max($hall_ids); $last_hall_id = max($hall_ids);
$languages = array(
'en' => 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) { foreach ($data['slots'] as $slot_id => $slot) {
$slotTime = $slot['starts_at']; $slotTime = $slot['starts_at'];
$slotDate = date('d', $slotTime); $slotDate = date('d', $slotTime);
if ($slotDate !== $date) { if ($slotDate !== $date) {
$lines[] = '<tr>'; $lines[] = '<tr>';
$lines[] = '<td>' . date('d F - l', $slotTime) . '</td>'; $lines[] = '<td>' . strftime('%d %B - %A', $slotTime) . '</td>';
$lines[] = '<td colspan="3">&nbsp;</td>'; $lines[] = '<td colspan="3">&nbsp;</td>';
$lines[] = '</tr>'; $lines[] = '</tr>';
@ -114,6 +133,17 @@ foreach ($data['slots'] as $slot_id => $slot) {
$lines[] = '</tr>'; $lines[] = '</tr>';
/* create the legend */
$legend = [];
foreach($data['tracks'] as $track) {
$legend[] = '<tr><td class="' . $track['css_class'] . '">' . $track['name'][SCHED_LANG] . '</td></tr>';
}
foreach ($languages as $code => $lang) {
$legend[] = '<tr><td class="schedule-' . $code . '">' . $lang['name'] . '</td></tr>';
}
$gspk = []; $gspk = [];
$fspk = []; $fspk = [];
$types = []; $types = [];
@ -150,4 +180,4 @@ foreach ($data['speakers'] as $speaker) {
$gspk[] = '</div>'; $gspk[] = '</div>';
return array_merge($data, compact('lines', 'fulltalks', 'gspk', 'fspk')); return array_merge($data, compact('lines', 'fulltalks', 'gspk', 'fspk', 'legend'));