Revert to the initial version of schedule

This commit is contained in:
Vencislav Atanasov 2016-10-16 19:47:05 +03:00
parent 2db122c92a
commit b6b02e48b0
3 changed files with 14 additions and 40 deletions

2
schedule/.gitignore vendored
View File

@ -1,2 +0,0 @@
cache
cache.json

View File

@ -1,7 +1,7 @@
<?php <?php
require __DIR__ . DIRECTORY_SEPARATOR . 'class.SmartCurl.php'; require __DIR__ . DIRECTORY_SEPARATOR . 'class.SmartCurl.php';
$base_url = 'https://cfp.openfest.org/api/conferences/'. $CF['confid'] .'/'; $base_url = 'https://cfp.openfest.org/api/conferences/2/';
$filenames = [ $filenames = [
'events' => 'events.json', 'events' => 'events.json',
@ -12,15 +12,14 @@ $filenames = [
'slots' => 'slots.json', 'slots' => 'slots.json',
]; ];
$data = []; $data = [];
foreach ($filenames as $name => $filename) { foreach ($filenames as $name => $filename) {
$curl = new SmartCurl($base_url, 'cache' . DIRECTORY_SEPARATOR .$CF['confid']); $curl = new SmartCurl($base_url);
$json = $curl->getUrl($filename); $json = $curl->getUrl($filename);
if ($json === false) { if ($json === false) {
echo 'get failed: ', $filename, ' ', $base_url, PHP_EOL; echo 'get failed: ', $filename, PHP_EOL;
exit; exit;
} }
@ -32,13 +31,12 @@ foreach ($filenames as $name => $filename) {
} }
$add = true; $add = true;
switch ($name) { switch ($name) {
case 'halls': case 'halls':
$ret = array(); $decoded = array_map(function($el) {
foreach($decoded as $id => $hall) { return $el['name'];
if (in_array($id, $CF['allowedhallids'])) $ret[$id] = $hall['name']; }, $decoded);
}
$decoded = $ret;
break; break;
case 'slots': case 'slots':
$decoded = array_map(function($el) { $decoded = array_map(function($el) {
@ -65,6 +63,6 @@ uasort($data['slots'], function($a, $b) {
return compareKeys($a, $b, 'starts_at') ?: compareKeys($a, $b, 'hall_id'); return compareKeys($a, $b, 'starts_at') ?: compareKeys($a, $b, 'hall_id');
}); });
//array_pop($data['halls']); array_pop($data['halls']);
return $data; return $data;

View File

@ -9,11 +9,7 @@
$data = require __DIR__ . DIRECTORY_SEPARATOR . 'load.php'; $data = require __DIR__ . DIRECTORY_SEPARATOR . 'load.php';
/* no idea why do I have to write this, doesn't seem to exist in the system */ $cut_len = 50;
$languages = array('en' => array('name' => 'English', 'locale' => 'en_US.UTF8'), 'bg' => array ('name' => 'Български', 'locale' => 'bg_BG.UTF8'));
$cut_len = 70;
$cfp_url = 'http://cfp.openfest.org'; $cfp_url = 'http://cfp.openfest.org';
$time = 0; $time = 0;
$date = 0; $date = 0;
@ -25,20 +21,13 @@ $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);
/* 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[$CF['lang']]['locale']);
foreach ($data['slots'] as $slot_id => $slot) { foreach ($data['slots'] as $slot_id => $slot) {
if (! in_array($slot['hall_id'], $CF['allowedhallids'])) continue;
$slotTime = $slot['starts_at']; $slotTime = $slot['starts_at'];
$slotDate = date('d', $slotTime); $slotDate = date('d', $slotTime);
if ($slotDate !== $date) { if ($slotDate !== $date) {
/* this seems to be the easiest way to localize the date */
$localdate = strftime('%d %B - %A' ,$slotTime);
$lines[] = '<tr>'; $lines[] = '<tr>';
$lines[] = '<td>' . $localdate . '</td>'; $lines[] = '<td>' . date('d F - l', $slotTime) . '</td>';
$lines[] = '<td colspan="3">&nbsp;</td>'; $lines[] = '<td colspan="3">&nbsp;</td>';
$lines[] = '</tr>'; $lines[] = '</tr>';
@ -63,7 +52,7 @@ foreach ($data['slots'] as $slot_id => $slot) {
$lines[] = '<td>TBA</td>'; $lines[] = '<td>TBA</td>';
} }
else { else {
$title = mb_substr($event['title'], 0, $cut_len) . (mb_strlen($event['title']) > $cut_len ? '...' : ''); $title = mb_substr($event['title'], 0, $cut_len) . (strlen($event['title']) > $cut_len ? '...' : '');
$speakers = ''; $speakers = '';
if (count($event['participant_user_ids']) > 0) { if (count($event['participant_user_ids']) > 0) {
@ -78,7 +67,7 @@ foreach ($data['slots'] as $slot_id => $slot) {
} else { } else {
/* TODO: fix the URL */ /* TODO: fix the URL */
$name = $data['speakers'][$uid]['first_name'] . ' ' . $data['speakers'][$uid]['last_name']; $name = $data['speakers'][$uid]['first_name'] . ' ' . $data['speakers'][$uid]['last_name'];
$spk[$uid] = '<a class="vt-p" href="SPKURL#'. $name . '">' . $name . '</a>'; $spk[$uid] = '<a class="vt-p" href="#'. $name . '">' . $name . '</a>';
} }
} }
$speakers = implode (', ', $spk); $speakers = implode (', ', $spk);
@ -103,7 +92,7 @@ foreach ($data['slots'] as $slot_id => $slot) {
$fulltalk_spkr = strlen($speakers)>1 ? ' (' . $speakers . ')' : ''; $fulltalk_spkr = strlen($speakers)>1 ? ' (' . $speakers . ')' : '';
$fulltalks[$eid] .= '<p><strong>' . $event['title'] . ' ' . $fulltalk_spkr . '</strong>'; $fulltalks[$eid] .= '<p><strong>' . $event['title'] . ' ' . $fulltalk_spkr . '</strong>';
$fulltalks[$eid] .= '<p>' . $event['abstract'] . '</p>'; $fulltalks[$eid] .= '<p>' . $event['abstract'] . '</p>';
$fulltalks[$eid] .= '<div class="separator"></div></section>'; $fulltalks[$eid] .= '<div class="separator"></div>';
if ($slot['event_id'] === $prev_event_id) { if ($slot['event_id'] === $prev_event_id) {
array_pop($lines); array_pop($lines);
@ -119,16 +108,6 @@ 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'][$CF['lang']] . '</td></tr>';
}
foreach ($languages as $l => $n) {
$legend[] = '<tr><td class="schedule-' . $l . '">' . $n['name'] . '</td></tr>';
}
$gspk = []; $gspk = [];
$fspk = []; $fspk = [];
@ -159,11 +138,10 @@ foreach ($data['speakers'] as $speaker) {
$fspk[] = '<a href="'. $parm['url'] . $speaker[$type] . '"><i class="' . $parm['class'] . '"></i></a>'; $fspk[] = '<a href="'. $parm['url'] . $speaker[$type] . '"><i class="' . $parm['class'] . '"></i></a>';
} }
} }
$fspk[] = '</div>';
$fspk[] = '<p>' . $speaker['biography'] . '</p>'; $fspk[] = '<p>' . $speaker['biography'] . '</p>';
$fspk[] = '</div><div class="separator"></div>'; $fspk[] = '</div><div class="separator"></div>';
} }
$gspk[] = '</div>'; $gspk[] = '</div>';
return array_merge($data, compact('lines', 'fulltalks', 'gspk', 'fspk', 'legend')); return array_merge($data, compact('lines', 'fulltalks', 'gspk', 'fspk'));