merge
This commit is contained in:
commit
f4daf0c5ba
|
@ -12,7 +12,7 @@ class SmartCurl {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($this->cache_dir)) {
|
if (!file_exists($this->cache_dir)) {
|
||||||
mkdir($this->cache_dir);
|
mkdir($this->cache_dir, 0777, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cache_index = $this->cache_dir . '.json';
|
$this->cache_index = $this->cache_dir . '.json';
|
||||||
|
@ -71,17 +71,16 @@ class SmartCurl {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curl_setopt($this->ch, CURLOPT_URL, $url) === false) {
|
if (curl_setopt($this->ch, CURLOPT_URL, $url) === false) {
|
||||||
throw new Exception('set url failed');
|
throw new Exception('set url failed: ' . $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache_file = $this->cache_dir . DIRECTORY_SEPARATOR . $filename;
|
$cache_file = $this->cache_dir . DIRECTORY_SEPARATOR . str_replace('/', '@', $filename);
|
||||||
|
|
||||||
$etag = array_key_exists($url, static::$etags) && file_exists($cache_file) ? static::$etags[$url] : null;
|
$etag = array_key_exists($url, static::$etags) && file_exists($cache_file) ? static::$etags[$url] : null;
|
||||||
|
|
||||||
if (curl_setopt($this->ch, CURLOPT_HTTPHEADER, [
|
if (curl_setopt($this->ch, CURLOPT_HTTPHEADER, [
|
||||||
'If-None-Match:' . (is_null($etag) ? '' : ' ' . $etag),
|
'If-None-Match:' . (is_null($etag) ? '' : ' ' . $etag),
|
||||||
]) === false) {
|
]) === false) {
|
||||||
throw new Exception('set etag failed');
|
throw new Exception('set etag failed: ' . $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = curl_exec($this->ch);
|
$response = curl_exec($this->ch);
|
||||||
|
@ -128,12 +127,6 @@ class SmartCurl {
|
||||||
$body = substr($response, $header_size);
|
$body = substr($response, $header_size);
|
||||||
|
|
||||||
if ($http_code === 200) {
|
if ($http_code === 200) {
|
||||||
$dirname = dirname($filename);
|
|
||||||
|
|
||||||
if ($dirname !== '.') {
|
|
||||||
mkdir($this->cache_dir . DIRECTORY_SEPARATOR . $dirname, 0777, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
file_put_contents($cache_file, $body);
|
file_put_contents($cache_file, $body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
function getSchedConfig($year = 2015) {
|
||||||
|
$globalConfig = [
|
||||||
|
'lang' => 'bg',
|
||||||
|
'cfp_url' => 'https://cfp.openfest.org',
|
||||||
|
'cut_len' => 70,
|
||||||
|
'hidden_speakers' => [4],
|
||||||
|
'hidden_language_tracks' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
$config = [
|
||||||
|
2014 => [
|
||||||
|
'conferenceId' => 1,
|
||||||
|
'eventTypes' => [
|
||||||
|
'lecture' => 1,
|
||||||
|
'workshop' => 2,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
2015 => [
|
||||||
|
'conferenceId' => 2,
|
||||||
|
'eventTypes' => [
|
||||||
|
'lecture' => 3,
|
||||||
|
'workshop' => 4,
|
||||||
|
],
|
||||||
|
'hidden_language_tracks' => [16],
|
||||||
|
],
|
||||||
|
2016 => [
|
||||||
|
'conferenceId' => 3,
|
||||||
|
'eventTypes' => [
|
||||||
|
'lecture' => 5,
|
||||||
|
'workshop' => 6,
|
||||||
|
],
|
||||||
|
'hidden_language_tracks' => [25],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
return array_merge($globalConfig, $config[$year]);
|
||||||
|
}
|
|
@ -1,49 +1,39 @@
|
||||||
<html>
|
<?php
|
||||||
<head>
|
error_reporting(~0);
|
||||||
<title>Test schedule</title>
|
ini_set('display_errors', 1);
|
||||||
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" type="text/css" href="http://www.openfest.org/2014/wp-content/themes/initfest/style.css" />
|
$requirePath = __DIR__ . DIRECTORY_SEPARATOR;
|
||||||
</head>
|
require $requirePath . 'class.SmartCurl.php';
|
||||||
<pre>
|
require $requirePath . 'config.php';
|
||||||
<?php
|
require $requirePath . 'load.php';
|
||||||
//header('Content-Type: text/plain; charset=utf-8');
|
require $requirePath . 'parse.php';
|
||||||
error_reporting(~0);
|
$sched_config = getSchedConfig(date('Y'));
|
||||||
ini_set('display_errors', 1);
|
$data = loadData($sched_config);
|
||||||
|
$sched_config['filterEventType'] = array_key_exists('event_type', $_GET) ? $_GET['event_type'] : null;
|
||||||
$content = require __DIR__ . DIRECTORY_SEPARATOR . 'parse.php';
|
$content = parseData($sched_config, $data);
|
||||||
?>
|
?>
|
||||||
</pre>
|
<html>
|
||||||
<table border="1" style="text-align: center;">
|
<head>
|
||||||
<thead>
|
<title>Test schedule</title>
|
||||||
<tr>
|
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
|
||||||
<td> </td>
|
<link rel="stylesheet" type="text/css" href="http://www.openfest.org/2014/wp-content/themes/initfest/style.css" />
|
||||||
<?php
|
</head>
|
||||||
foreach ($content['halls'] as $hall_name) {
|
<body>
|
||||||
?>
|
<?php
|
||||||
<td><?php echo htmlspecialchars($hall_name); ?></td>
|
echo $content['schedule'];
|
||||||
<?php
|
?>
|
||||||
}
|
<div class="separator"></div>
|
||||||
?>
|
<table border="1">
|
||||||
</tr>
|
<tbody>
|
||||||
</thead>
|
<?php
|
||||||
<tbody>
|
echo $content['legend'], PHP_EOL;
|
||||||
<?php
|
?>
|
||||||
foreach ($content['lines'] as $line) {
|
</tbody>
|
||||||
echo $line, PHP_EOL;
|
</table>
|
||||||
}
|
<?php
|
||||||
?>
|
echo $content['fulltalks'];
|
||||||
</tbody>
|
echo $content['gspk'];
|
||||||
</table>
|
echo $content['fspk'];
|
||||||
<div class="separator"></div>
|
?>
|
||||||
<?php
|
</body>
|
||||||
foreach ($content['fulltalks'] as $line) {
|
</html>
|
||||||
echo $line, PHP_EOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($content['gspk'] as $line) {
|
|
||||||
echo $line, PHP_EOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($content['fspk'] as $line) {
|
|
||||||
echo $line, PHP_EOL;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,59 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
require __DIR__ . DIRECTORY_SEPARATOR . 'class.SmartCurl.php';
|
|
||||||
|
|
||||||
$base_url = 'https://cfp.openfest.org/api/conferences/'. $CF['confid'] .'/';
|
|
||||||
|
|
||||||
$filenames = [
|
|
||||||
'events' => 'events.json',
|
|
||||||
'speakers' => 'speakers.json',
|
|
||||||
'tracks' => 'tracks.json',
|
|
||||||
'event_types' => 'event_types.json',
|
|
||||||
'halls' => 'halls.json',
|
|
||||||
'slots' => 'slots.json',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
|
|
||||||
foreach ($filenames as $name => $filename) {
|
|
||||||
$curl = new SmartCurl($base_url, 'cache' . DIRECTORY_SEPARATOR .$CF['confid']);
|
|
||||||
$json = $curl->getUrl($filename);
|
|
||||||
|
|
||||||
if ($json === false) {
|
|
||||||
// echo 'get failed: ', $filename, ' ', $base_url, PHP_EOL;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$decoded = json_decode($json, true);
|
|
||||||
|
|
||||||
if ($decoded === false) {
|
|
||||||
echo 'decode failed: ', $filename, PHP_EOL;
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$add = true;
|
|
||||||
switch ($name) {
|
|
||||||
case 'halls':
|
|
||||||
$ret = array();
|
|
||||||
foreach($decoded as $id => $hall) {
|
|
||||||
if (in_array($id, $CF['allowedhallids'])) $ret[$id] = $hall['name'];
|
|
||||||
}
|
|
||||||
$decoded = $ret;
|
|
||||||
break;
|
|
||||||
case 'slots':
|
|
||||||
$decoded = array_map(function($el) {
|
|
||||||
foreach (['starts_at', 'ends_at'] as $key) {
|
|
||||||
$el[$key] = strtotime($el[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $el;
|
|
||||||
}, $decoded);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data[$name] = $decoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
function compareKeys($a, $b, $key) {
|
function compareKeys($a, $b, $key) {
|
||||||
$valA = &$a[$key];
|
$valA = &$a[$key];
|
||||||
$valB = &$b[$key];
|
$valB = &$b[$key];
|
||||||
|
@ -61,10 +6,59 @@ function compareKeys($a, $b, $key) {
|
||||||
return ($valA < $valB) ? -1 : (($valA > $valB) ? 1 : 0);
|
return ($valA < $valB) ? -1 : (($valA > $valB) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uasort($data['slots'], function($a, $b) {
|
function loadData($config) {
|
||||||
return compareKeys($a, $b, 'starts_at') ?: compareKeys($a, $b, 'hall_id');
|
$filenames = [
|
||||||
});
|
'events' => 'events.json',
|
||||||
|
'speakers' => 'speakers.json',
|
||||||
|
'tracks' => 'tracks.json',
|
||||||
|
'event_types' => 'event_types.json',
|
||||||
|
'halls' => 'halls.json',
|
||||||
|
'slots' => 'slots.json',
|
||||||
|
];
|
||||||
|
|
||||||
//array_pop($data['halls']);
|
$data = [];
|
||||||
|
$curl = new SmartCurl($config['cfp_url'] . '/api/conferences/');
|
||||||
|
|
||||||
|
foreach ($filenames as $name => $filename) {
|
||||||
|
$json = $curl->getUrl($config['conferenceId'] . '/' . $filename);
|
||||||
|
|
||||||
return $data;
|
if ($json === false) {
|
||||||
|
echo 'get failed: ', $filename, PHP_EOL;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$decoded = json_decode($json, true);
|
||||||
|
|
||||||
|
if ($decoded === false) {
|
||||||
|
echo 'decode failed: ', $filename, PHP_EOL;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$add = true;
|
||||||
|
|
||||||
|
switch ($name) {
|
||||||
|
case 'halls':
|
||||||
|
$decoded = array_map(function($el) {
|
||||||
|
return $el['name'];
|
||||||
|
}, $decoded);
|
||||||
|
break;
|
||||||
|
case 'slots':
|
||||||
|
$decoded = array_map(function($el) {
|
||||||
|
foreach (['starts_at', 'ends_at'] as $key) {
|
||||||
|
$el[$key] = strtotime($el[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $el;
|
||||||
|
}, $decoded);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data[$name] = $decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
uasort($data['slots'], function($a, $b) {
|
||||||
|
return compareKeys($a, $b, 'starts_at') ?: compareKeys($a, $b, 'hall_id');
|
||||||
|
});
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
|
@ -1,169 +1,383 @@
|
||||||
<?php
|
<?php
|
||||||
// 'halfnarp_friendly'
|
function parseData($config, $data) {
|
||||||
// 'events'
|
$languages = array(
|
||||||
// 'speakers'
|
'en' => array(
|
||||||
// 'tracks' [en/bg]
|
'name' => 'English',
|
||||||
// 'event_types' [en/bg]
|
'locale' => 'en_US.UTF8'
|
||||||
// 'halls'
|
),
|
||||||
// 'slots'
|
'bg' => array(
|
||||||
|
'name' => 'Български',
|
||||||
$data = require __DIR__ . DIRECTORY_SEPARATOR . 'load.php';
|
'locale' => 'bg_BG.UTF8'
|
||||||
|
)
|
||||||
/* no idea why do I have to write this, doesn't seem to exist in the system */
|
);
|
||||||
|
|
||||||
$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');
|
||||||
$cut_len = 70;
|
setlocale(LC_TIME, $languages[$config['lang']]['locale']);
|
||||||
$cfp_url = 'http://cfp.openfest.org';
|
|
||||||
$time = 0;
|
// Filter out invalid slots
|
||||||
$date = 0;
|
$data['slots'] = array_filter($data['slots'], function($slot) {
|
||||||
$lines = [];
|
return isset($slot['starts_at'], $slot['ends_at'], $slot['hall_id'], $slot['event_id']);
|
||||||
$fulltalks = [];
|
});
|
||||||
$prev_event_id = 0;
|
|
||||||
$colspan = 1;
|
// Collect the slots for each hall, sort them in order of starting
|
||||||
$hall_ids = array_keys($data['halls']);
|
$slots = [];
|
||||||
$first_hall_id = min($hall_ids);
|
$timestamps = [];
|
||||||
$last_hall_id = max($hall_ids);
|
|
||||||
|
foreach ($data['halls'] as $hall_id => $hall) {
|
||||||
/* We need to set these so we actually parse properly the dates. WP fucks up both. */
|
$slots[$hall_id] = [];
|
||||||
date_default_timezone_set('Europe/Sofia');
|
|
||||||
setlocale(LC_TIME, $languages[$CF['lang']]['locale']);
|
foreach ($data['slots'] as $slot_id => $slot) {
|
||||||
|
if ($slot['hall_id'] !== $hall_id) {
|
||||||
foreach ($data['slots'] as $slot_id => $slot) {
|
continue;
|
||||||
if (! in_array($slot['hall_id'], $CF['allowedhallids'])) continue;
|
}
|
||||||
$slotTime = $slot['starts_at'];
|
|
||||||
$slotDate = date('d', $slotTime);
|
if (!in_array($slot['starts_at'], $timestamps)) {
|
||||||
|
$timestamps[] = $slot['starts_at'];
|
||||||
if ($slotDate !== $date) {
|
}
|
||||||
/* this seems to be the easiest way to localize the date */
|
|
||||||
$localdate = strftime('%d %B - %A' ,$slotTime);
|
if (!in_array($slot['ends_at'], $timestamps)) {
|
||||||
$lines[] = '<tr>';
|
$timestamps[] = $slot['ends_at'];
|
||||||
$lines[] = '<td>' . $localdate . '</td>';
|
}
|
||||||
$lines[] = '<td colspan="3"> </td>';
|
|
||||||
$lines[] = '</tr>';
|
$slots[$hall_id][$slot['starts_at']] = $slot;
|
||||||
|
}
|
||||||
$date = $slotDate;
|
|
||||||
}
|
ksort($slots[$hall_id]);
|
||||||
|
}
|
||||||
if ($slotTime !== $time) {
|
|
||||||
if ($time !== 0) {
|
sort($timestamps);
|
||||||
$lines[] = '</tr>';
|
|
||||||
}
|
// Find all microslots (the smallest time unit)
|
||||||
|
$microslots = [];
|
||||||
$lines[] = '<tr>';
|
$lastTs = 0;
|
||||||
$lines[] = '<td>' . date('H:i', $slot['starts_at']) . ' - ' . date('H:i', $slot['ends_at']) . '</td>';
|
$first = true;
|
||||||
|
|
||||||
$time = $slotTime;
|
foreach ($timestamps as $ts) {
|
||||||
}
|
if ($first) {
|
||||||
|
$lastTs = $ts;
|
||||||
$eid = &$slot['event_id'];
|
$first = false;
|
||||||
$event = &$data['events'][$eid];
|
continue;
|
||||||
|
}
|
||||||
if (is_null($eid) || $event['event_type_id']==6) {
|
|
||||||
$lines[] = '<td>TBA</td>';
|
if (date('d.m', $lastTs) !== date('d.m', $ts)) {
|
||||||
}
|
$lastTs = $ts;
|
||||||
else {
|
continue;
|
||||||
$title = mb_substr($event['title'], 0, $cut_len) . (mb_strlen($event['title']) > $cut_len ? '...' : '');
|
}
|
||||||
$speakers = '';
|
|
||||||
|
$microslots[] = [$lastTs, $ts];
|
||||||
if (count($event['participant_user_ids']) > 0) {
|
$lastTs = $ts;
|
||||||
$speakers = json_encode($event['participant_user_ids']) . '<br>';
|
}
|
||||||
|
|
||||||
$spk = array();
|
// Fill in the event ID for each time slot in each hall
|
||||||
$speaker_name = array();
|
$events = [];
|
||||||
foreach ($event['participant_user_ids'] as $uid) {
|
$filtered_type_id =
|
||||||
/* The check for uid==4 is for us not to show the "Opefest Team" as a presenter for lunches, etc. */
|
array_key_exists('filterEventType', $config) &&
|
||||||
if ($uid == 4 || empty ($data['speakers'][$uid])) {
|
array_key_exists($config['filterEventType'], $config['eventTypes']) ?
|
||||||
continue;
|
$config['eventTypes'][$config['filterEventType']] :
|
||||||
} else {
|
null;
|
||||||
/* TODO: fix the URL */
|
|
||||||
$name = $data['speakers'][$uid]['first_name'] . ' ' . $data['speakers'][$uid]['last_name'];
|
foreach ($data['halls'] as $hall_id => $hall) {
|
||||||
$spk[$uid] = '<a class="vt-p" href="SPKURL#'. $name . '">' . $name . '</a>';
|
$hall_data = [];
|
||||||
}
|
|
||||||
}
|
foreach ($microslots as $timestamps) {
|
||||||
$speakers = implode (', ', $spk);
|
$found = false;
|
||||||
}
|
|
||||||
|
foreach ($data['slots'] as $slot_id => $slot) {
|
||||||
|
if (
|
||||||
/* Hack, we don't want language for the misc track. This is the same for all years. */
|
$slot['hall_id'] === $hall_id &&
|
||||||
if ('misc' !== $data['tracks'][$event['track_id']]['name']['en']) {
|
$slot['starts_at'] <= $timestamps[0] &&
|
||||||
$csslang = "schedule-".$event['language'];
|
$slot['ends_at'] >= $timestamps[1] &&
|
||||||
} else {
|
array_key_exists($slot['event_id'], $data['events'])
|
||||||
$csslang = "";
|
) {
|
||||||
}
|
if (!is_null($filtered_type_id)) {
|
||||||
$cssclass = &$data['tracks'][$event['track_id']]['css_class'];
|
if ($data['events'][$slot['event_id']]['event_type_id'] !== $filtered_type_id) {
|
||||||
$style = ' class="' . $cssclass . ' ' . $csslang . '"';
|
continue;
|
||||||
$content = '<a href=#lecture-' . $eid . '>' . htmlspecialchars($title) . '</a> <br>' . $speakers;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* these are done by $eid, as otherwise we get some talks more than once (for example the lunch) */
|
$found = true;
|
||||||
$fulltalks[$eid] = '';
|
$hall_data[] = [
|
||||||
$fulltalks[$eid] .= '<section id="lecture-' . $eid . '">';
|
'event_id' => $slot['event_id'],
|
||||||
/* We don't want '()' when we don't have a speaker name */
|
'hall_id' => $slot['hall_id'],
|
||||||
$fulltalk_spkr = strlen($speakers)>1 ? ' (' . $speakers . ')' : '';
|
'edge' => $slot['starts_at'] === $timestamps[0] || $slot['ends_at'] === $timestamps[1],
|
||||||
$fulltalks[$eid] .= '<p><strong>' . $event['title'] . ' ' . $fulltalk_spkr . '</strong>';
|
];
|
||||||
$fulltalks[$eid] .= '<p>' . $event['abstract'] . '</p>';
|
break;
|
||||||
$fulltalks[$eid] .= '<div class="separator"></div></section>';
|
}
|
||||||
|
}
|
||||||
if ($slot['event_id'] === $prev_event_id) {
|
|
||||||
array_pop($lines);
|
if (!$found) {
|
||||||
$lines[] = '<td' . $style . ' colspan="' . ++$colspan . '">' . $content . '</td>';
|
$hall_data[] = null;
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
$lines[] = '<td' . $style . '>' . $content . '</td>';
|
|
||||||
$colspan = 1;
|
$events[] = $hall_data;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Remove halls with no events after filtering
|
||||||
$prev_event_id = $slot['event_id'];
|
$count = count($events);
|
||||||
}
|
for ($i = 0; $i < $count; ++$i) {
|
||||||
|
$hasEvents = false;
|
||||||
$lines[] = '</tr>';
|
foreach ($events[$i] as $event_info) {
|
||||||
/* create the legend */
|
if (!is_null($event_info)) {
|
||||||
|
$hasEvents = true;
|
||||||
$legend = [];
|
break;
|
||||||
|
}
|
||||||
foreach($data['tracks'] as $track) {
|
}
|
||||||
$legend[] = '<tr><td class="' . $track['css_class'] . '">' . $track['name'][$CF['lang']] . '</td></tr>';
|
if (!$hasEvents) {
|
||||||
}
|
unset($events[$i]);
|
||||||
foreach ($languages as $l => $n) {
|
}
|
||||||
$legend[] = '<tr><td class="schedule-' . $l . '">' . $n['name'] . '</td></tr>';
|
}
|
||||||
}
|
|
||||||
|
// Transpose the matrix
|
||||||
$gspk = [];
|
// rows->halls, cols->timeslots ===> rows->timeslots, cols->halls
|
||||||
$fspk = [];
|
$events = array_map(null, ...$events);
|
||||||
$types = [];
|
|
||||||
$types['twitter']['url']='https://twitter.com/';
|
// Filter empty slots
|
||||||
$types['twitter']['class']='fa fa-twitter';
|
$count = count($events);
|
||||||
$types['github']['url']='https://github.com/';
|
for ($i = 0; $i < $count; ++$i) {
|
||||||
$types['github']['class']='fa fa-github';
|
$hall_count = count($events[$i]);
|
||||||
$types['email']['url']='mailto:';
|
$hasEvents = false;
|
||||||
$types['email']['class']='fa fa-envelope';
|
|
||||||
|
for ($j = 0; $j < $hall_count; ++$j) {
|
||||||
$gspk[] = '<div class="grid members">';
|
if (!is_null($events[$i][$j]) && $events[$i][$j]['edge']) {
|
||||||
|
$hasEvents = true;
|
||||||
foreach ($data['speakers'] as $speaker) {
|
continue 2;
|
||||||
$name = $speaker['first_name'] . ' ' . $speaker['last_name'];
|
}
|
||||||
|
}
|
||||||
$gspk[] = '<div class="member col4">';
|
|
||||||
$gspk[] = '<a href="#' . $name . '">';
|
if (!$hasEvents) {
|
||||||
$gspk[] = '<img width="100" height="100" src="' . $cfp_url . $speaker['picture']['schedule']['url'].'" class="attachment-100x100 wp-post-image" alt="' . $name .'" />';
|
unset($events[$i]);
|
||||||
$gspk[] = '</a> </div>';
|
}
|
||||||
|
}
|
||||||
$fspk[] = '<div class="speaker" id="' . $name . '">';
|
|
||||||
$fspk[] = '<img width="100" height="100" src="' . $cfp_url . $speaker['picture']['schedule']['url'].'" class="attachment-100x100 wp-post-image" alt="' . $name .'" />';
|
// Merge events longer than one slot
|
||||||
$fspk[] = '<h3>' . $name . '</h3>';
|
$prevEventId = [];
|
||||||
$fspk[] = '<div class="icons">';
|
$prevEventSlot = [];
|
||||||
foreach ($types as $type => $parm) {
|
$prevSlotIndex = 0;
|
||||||
if (!empty($speaker[$type])) {
|
$first = true;
|
||||||
$fspk[] = '<a href="'. $parm['url'] . $speaker[$type] . '"><i class="' . $parm['class'] . '"></i></a>';
|
|
||||||
}
|
foreach ($events as $slot_index => &$events_data) {
|
||||||
}
|
if ($first) {
|
||||||
$fspk[] = '</div>';
|
$prevEventId = array_map(function($event_info) {
|
||||||
$fspk[] = '<p>' . $speaker['biography'] . '</p>';
|
return is_null($event_info) ? null : $event_info['event_id'];
|
||||||
$fspk[] = '</div><div class="separator"></div>';
|
}, $events_data);
|
||||||
}
|
$prevEventSlot = array_fill(0, count($events_data), null);
|
||||||
|
$prevSlotIndex = $slot_index;
|
||||||
$gspk[] = '</div>';
|
$first = false;
|
||||||
|
continue;
|
||||||
return array_merge($data, compact('lines', 'fulltalks', 'gspk', 'fspk', 'legend'));
|
}
|
||||||
|
|
||||||
|
foreach ($events_data as $hall_index => &$event_info) {
|
||||||
|
if (is_null($event_info)) {
|
||||||
|
$prevEventId[$hall_index] = null;
|
||||||
|
$prevEventSlot[$hall_index] = null;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($event_info['event_id'] !== $prevEventId[$hall_index]) {
|
||||||
|
$prevEventId[$hall_index] = $event_info['event_id'];
|
||||||
|
$prevEventSlot[$hall_index] = null;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We have a long event
|
||||||
|
if (is_null($prevEventSlot[$hall_index])) {
|
||||||
|
$prevEventSlot[$hall_index] = $prevSlotIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
$master_slot = &$events[$prevEventSlot[$hall_index]][$hall_index];
|
||||||
|
|
||||||
|
if (!array_key_exists('rowspan', $master_slot)) {
|
||||||
|
$master_slot['rowspan'] = 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
++$master_slot['rowspan'];
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($master_slot);
|
||||||
|
|
||||||
|
$event_info = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($event_info);
|
||||||
|
|
||||||
|
$prevSlotIndex = $slot_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($events_data);
|
||||||
|
|
||||||
|
// Build the HTML
|
||||||
|
$schedule_body = '';
|
||||||
|
$lastTs = 0;
|
||||||
|
$fulltalks = '';
|
||||||
|
$hall_ids = [];
|
||||||
|
|
||||||
|
foreach ($events as $slot_index => $events_data) {
|
||||||
|
$columns = [];
|
||||||
|
|
||||||
|
if (date('d.m', $microslots[$slot_index][0]) !== date('d.m', $lastTs)) {
|
||||||
|
$schedule_body .= '<tr><th colspan="' . (count($events_data) + 1) . '">' . strftime('%d %B - %A', $microslots[$slot_index][0]) . '</th></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$lastTs = $microslots[$slot_index][0];
|
||||||
|
$lastEventId = 0;
|
||||||
|
$colspan = 1;
|
||||||
|
|
||||||
|
foreach ($events_data as $event_info) {
|
||||||
|
if ($event_info === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($event_info['event_id'])) {
|
||||||
|
$columns[] = '<td> </td>';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array($event_info['hall_id'], $hall_ids)) {
|
||||||
|
$hall_ids[] = $event_info['hall_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$eid = &$event_info['event_id'];
|
||||||
|
$event = &$data['events'][$eid];
|
||||||
|
|
||||||
|
$title = mb_substr($event['title'], 0, $config['cut_len']) . (mb_strlen($event['title']) > $config['cut_len'] ? '...' : '');
|
||||||
|
$speakers = '';
|
||||||
|
|
||||||
|
if (count($event['participant_user_ids']) > 0) {
|
||||||
|
$spk = [];
|
||||||
|
|
||||||
|
foreach ($event['participant_user_ids'] as $uid) {
|
||||||
|
if (in_array($uid, $config['hidden_speakers']) || empty($data['speakers'][$uid])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = $data['speakers'][$uid]['first_name'] . ' ' . $data['speakers'][$uid]['last_name'];
|
||||||
|
$spk[] = '<a class="vt-p" href="#' . $name . '">' . $name . '</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$speakers = implode (', ', $spk);
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = '<a href="#lecture-' . $eid . '">' . htmlspecialchars($title) . '</a><br>' . $speakers;
|
||||||
|
|
||||||
|
// these are done by $eid, as otherwise we get some talks more than once (for example the lunch)
|
||||||
|
// TODO: fix this, it's broken
|
||||||
|
$fulltalks .= '<section id="lecture-' . $eid . '">';
|
||||||
|
|
||||||
|
// We don't want '()' when we don't have a speaker name
|
||||||
|
$fulltalk_spkr = strlen($speakers) > 0 ? (' (' . $speakers . ')') : '';
|
||||||
|
$fulltalks .= '<p><strong>' . $event['title'] . ' ' . $fulltalk_spkr . '</strong></p>';
|
||||||
|
$fulltalks .= '<p>' . $event['abstract'] . '</p>';
|
||||||
|
$fulltalks .= '<div class="separator"></div></section>';
|
||||||
|
|
||||||
|
if ($eid === $lastEventId) {
|
||||||
|
array_pop($columns);
|
||||||
|
++$colspan;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$colspan = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rowspan = array_key_exists('rowspan', $event_info) ? (' rowspan="' . $event_info['rowspan'] . '"') : '';
|
||||||
|
|
||||||
|
// CSS
|
||||||
|
$cssClasses = [];
|
||||||
|
|
||||||
|
if (!in_array($event['track_id'], $config['hidden_language_tracks'])) {
|
||||||
|
$cssClasses[] = 'schedule-' . $event['language'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$cssClass = $data['tracks'][$event['track_id']]['css_class'];
|
||||||
|
|
||||||
|
if (strlen($cssClass) > 0) {
|
||||||
|
$cssClasses[] = $cssClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cssClasses = count($cssClasses) > 0 ? (' class="' . implode(' ', $cssClasses) . '"') : '';
|
||||||
|
|
||||||
|
// Render cell
|
||||||
|
$columns[] = '<td' . ($colspan > 1 ? ' colspan="' . $colspan . '"' : $rowspan) . $cssClasses . '>' . $content . '</td>';
|
||||||
|
|
||||||
|
$lastEventId = $eid;
|
||||||
|
unset($eid, $event);
|
||||||
|
}
|
||||||
|
|
||||||
|
$schedule_body .= '<tr><td>';
|
||||||
|
$schedule_body .= strftime('%H:%M', $microslots[$slot_index][0]) . ' - ' . strftime('%H:%M', $microslots[$slot_index][1]);
|
||||||
|
$schedule_body .= '</td>';
|
||||||
|
$schedule_body .= implode('', $columns);
|
||||||
|
$schedule_body .= '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$schedule = '<table border="1"><thead><tr><th></th>';
|
||||||
|
|
||||||
|
foreach ($data['halls'] as $hall_id => $hall) {
|
||||||
|
if (!in_array($hall_id, $hall_ids)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$schedule .= '<th>' . $hall['bg'] . '</th>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$schedule .= '</tr></thead><tbody>';
|
||||||
|
$schedule .= $schedule_body;
|
||||||
|
$schedule .= '</tbody></table>';
|
||||||
|
|
||||||
|
// Create the legend
|
||||||
|
$legend = '';
|
||||||
|
|
||||||
|
foreach($data['tracks'] as $track) {
|
||||||
|
$legend .= '<tr><td class="' . $track['css_class'] . '">' . $track['name'][$config['lang']] . '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($languages as $code => $lang) {
|
||||||
|
$legend .= '<tr><td class="schedule-' . $code . '">' . $lang['name'] . '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Speaker list
|
||||||
|
$gspk = '<div class="grid members">';
|
||||||
|
$fspk = '';
|
||||||
|
$types = [
|
||||||
|
'twitter' => [
|
||||||
|
'class' => 'twitter',
|
||||||
|
'url' => 'https://twitter.com/',
|
||||||
|
],
|
||||||
|
'github' => [
|
||||||
|
'class' => 'github',
|
||||||
|
'url' => 'https://github.com/',
|
||||||
|
],
|
||||||
|
'email' => [
|
||||||
|
'class' => 'envelope',
|
||||||
|
'url' => 'mailto:',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($data['speakers'] as $speaker) {
|
||||||
|
$name = $speaker['first_name'] . ' ' . $speaker['last_name'];
|
||||||
|
|
||||||
|
$gspk .= '<div class="member col4">';
|
||||||
|
$gspk .= '<a href="#' . $name . '">';
|
||||||
|
$gspk .= '<img width="100" height="100" src="' . $config['cfp_url'] . $speaker['picture']['schedule']['url'] . '" class="attachment-100x100 wp-post-image" alt="' . $name . '" />';
|
||||||
|
$gspk .= '</a> </div>';
|
||||||
|
|
||||||
|
$fspk .= '<div class="speaker" id="' . $name . '">';
|
||||||
|
$fspk .= '<img width="100" height="100" src="' . $config['cfp_url'] . $speaker['picture']['schedule']['url'] . '" class="attachment-100x100 wp-post-image" alt="' . $name . '" />';
|
||||||
|
$fspk .= '<h3>' . $name . '</h3>';
|
||||||
|
$fspk .= '<div class="icons">';
|
||||||
|
|
||||||
|
foreach ($types as $type => $param) {
|
||||||
|
if (!empty($speaker[$type])) {
|
||||||
|
$fspk .= '<a href="' . $param['url'] . $speaker[$type] . '"><i class="fa fa-' . $param['class'] . '"></i></a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$fspk .= '</div>';
|
||||||
|
$fspk .= '<p>' . $speaker['biography'] . '</p>';
|
||||||
|
$fspk .= '</div><div class="separator"></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$gspk .= '</div>';
|
||||||
|
|
||||||
|
return compact('schedule', 'fulltalks', 'gspk', 'fspk', 'legend');
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue