add a config file, add per-year support
This commit is contained in:
parent
dde9dea189
commit
a820618363
|
@ -3,41 +3,7 @@
|
|||
get_header();
|
||||
wp_nav_menu( array( 'theme_location' => 'footer-schedule', 'container_class' => 'content subnav cf' ) );
|
||||
|
||||
$lang = pll_current_language('slug');
|
||||
|
||||
|
||||
/* TODO make this read the ids from the proper place, as this breaks other years*/
|
||||
if ( preg_match('/^workshop/', $pagename) ) {
|
||||
$workshop = true;
|
||||
$allowedhallids = array(9);
|
||||
} else {
|
||||
$workshop = false;
|
||||
$allowedhallids = array(6,7,8);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* There is no better way to get where the speakers are
|
||||
*/
|
||||
|
||||
if ('en' === $lang) {
|
||||
$s_slug = 'speakers';
|
||||
} else {
|
||||
$s_slug = 'lektori';
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'name' => $s_slug,
|
||||
'post_type' => 'page',
|
||||
'numberposts' => 1
|
||||
);
|
||||
|
||||
$url = '';
|
||||
|
||||
$my_posts = get_posts($args);
|
||||
if( $my_posts ) {
|
||||
$url = get_permalink( $my_posts[0]->ID );
|
||||
}
|
||||
require("schedule-config.php");
|
||||
|
||||
$content = require __DIR__ . DIRECTORY_SEPARATOR . 'schedule' . DIRECTORY_SEPARATOR . 'parse.php';
|
||||
//var_dump($data);
|
||||
|
@ -63,7 +29,7 @@ $content = require __DIR__ . DIRECTORY_SEPARATOR . 'schedule' . DIRECTORY_SEPARA
|
|||
<tbody>
|
||||
<?php
|
||||
foreach ($content['lines'] as $line) {
|
||||
echo str_replace('SPKURL', $url, $line), PHP_EOL;
|
||||
echo str_replace('SPKURL', $CF['speakers_url'], $line), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
|
@ -80,7 +46,7 @@ $content = require __DIR__ . DIRECTORY_SEPARATOR . 'schedule' . DIRECTORY_SEPARA
|
|||
</table>
|
||||
<?php
|
||||
foreach ($content['fulltalks'] as $line) {
|
||||
echo str_replace('SPKURL', $url, $line), PHP_EOL;
|
||||
echo str_replace('SPKURL', $CF['speakers_url'], $line), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
get_header();
|
||||
wp_nav_menu( array( 'theme_location' => 'footer-schedule', 'container_class' => 'content subnav cf' ) );
|
||||
|
||||
$allowedhallids = array(6,7,8,9);
|
||||
require("schedule-config.php");
|
||||
|
||||
$content = require __DIR__ . DIRECTORY_SEPARATOR . 'schedule' . DIRECTORY_SEPARATOR . 'parse.php';
|
||||
//var_dump($data);
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/* basic config for all conferences
|
||||
* needs to be included from a WP page, otherwise won't work properly
|
||||
* some of this stuff would need to be moved to be taken from Clarion in the future
|
||||
*/
|
||||
$CF = array();
|
||||
|
||||
$CF['lang'] = pll_current_language('slug');
|
||||
|
||||
|
||||
$hall_defs = array( '2014' => array('lectures' => array(1, 2, 3), 'workshops' => array(4, 5), 'all' => array(1, 2, 3, 4, 5) ),
|
||||
'2015' => array('lectures' => array(6, 7, 8), 'workshops' => array(9), 'all' => array(6, 7, 8, 9) )
|
||||
);
|
||||
|
||||
/* clarion conference ids */
|
||||
$confids = array('2014' => 1, '2015' => 2);
|
||||
|
||||
|
||||
/* get stuff from WP and parse */
|
||||
$siteurl = get_option('siteurl');
|
||||
$year = preg_replace('%.*/([0-9]*)$%', '\1', $siteurl);
|
||||
|
||||
$CF['confid'] = $confids[$year];
|
||||
|
||||
/* TODO make this read the ids from the proper place, as this breaks other years*/
|
||||
if ( preg_match('/^workshop/', $pagename) ) {
|
||||
$CF['allowedhallids'] = $hall_defs[$year]['workshops'];
|
||||
} else if (preg_match('/^(speakers|lektori)/', $pagename) ) {
|
||||
$CF['allowedhallids'] = $hall_defs[$year]['all'];
|
||||
} else {
|
||||
$CF['allowedhallids'] = $hall_defs[$year]['lectures'];
|
||||
}
|
||||
|
||||
/*
|
||||
* There is no better way to get where the speakers are
|
||||
*/
|
||||
|
||||
if ('en' === $lang) {
|
||||
$CF['s_slug'] = 'speakers';
|
||||
} else {
|
||||
$CF['s_slug'] = 'lektori';
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'name' => $s_slug,
|
||||
'post_type' => 'page',
|
||||
'numberposts' => 1
|
||||
);
|
||||
|
||||
$speakers_url = '';
|
||||
|
||||
$my_posts = get_posts($args);
|
||||
if( $my_posts ) {
|
||||
$CF['speakers_url'] = get_permalink( $my_posts[0]->ID );
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
require __DIR__ . DIRECTORY_SEPARATOR . 'class.SmartCurl.php';
|
||||
|
||||
$base_url = 'https://cfp.openfest.org/api/conferences/2/';
|
||||
$base_url = 'https://cfp.openfest.org/api/conferences/'. $CF['confid'] .'/';
|
||||
|
||||
$filenames = [
|
||||
'events' => 'events.json',
|
||||
|
@ -13,17 +13,14 @@ $filenames = [
|
|||
];
|
||||
|
||||
|
||||
if (empty($allowedhallids)) {
|
||||
$allowedhallids = array (6,7,8);
|
||||
}
|
||||
$data = [];
|
||||
|
||||
foreach ($filenames as $name => $filename) {
|
||||
$curl = new SmartCurl($base_url);
|
||||
$curl = new SmartCurl($base_url, 'cache' . DIRECTORY_SEPARATOR .$CF['confid']);
|
||||
$json = $curl->getUrl($filename);
|
||||
|
||||
if ($json === false) {
|
||||
echo 'get failed: ', $filename, PHP_EOL;
|
||||
echo 'get failed: ', $filename, ' ', $base_url, PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -39,7 +36,7 @@ foreach ($filenames as $name => $filename) {
|
|||
case 'halls':
|
||||
$ret = array();
|
||||
foreach($decoded as $id => $hall) {
|
||||
if (in_array($id, $allowedhallids)) $ret[$id] = $hall['name'];
|
||||
if (in_array($id, $CF['allowedhallids'])) $ret[$id] = $hall['name'];
|
||||
}
|
||||
$decoded = $ret;
|
||||
break;
|
||||
|
|
|
@ -33,7 +33,7 @@ date_default_timezone_set('Europe/Sofia');
|
|||
setlocale(LC_TIME, $languages[$lang]['locale']);
|
||||
|
||||
foreach ($data['slots'] as $slot_id => $slot) {
|
||||
if (! in_array($slot['hall_id'], $allowedhallids)) continue;
|
||||
if (! in_array($slot['hall_id'], $CF['allowedhallids'])) continue;
|
||||
$slotTime = $slot['starts_at'];
|
||||
$slotDate = date('d', $slotTime);
|
||||
|
||||
|
|
Loading…
Reference in New Issue