diff --git a/page-schedule.php b/page-schedule.php index 99625a8..2aa097c 100644 --- a/page-schedule.php +++ b/page-schedule.php @@ -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
@@ -80,7 +46,7 @@ $content = require __DIR__ . DIRECTORY_SEPARATOR . 'schedule' . DIRECTORY_SEPARA diff --git a/page-speakers.php b/page-speakers.php index ec47910..d4deb25 100644 --- a/page-speakers.php +++ b/page-speakers.php @@ -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); diff --git a/schedule-config.php b/schedule-config.php new file mode 100644 index 0000000..26eec58 --- /dev/null +++ b/schedule-config.php @@ -0,0 +1,59 @@ + 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 ); +} + + + +?> diff --git a/schedule/load.php b/schedule/load.php index c90b7a2..9c2c971 100644 --- a/schedule/load.php +++ b/schedule/load.php @@ -1,7 +1,7 @@ '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; diff --git a/schedule/parse.php b/schedule/parse.php index 13e07f1..f01351d 100644 --- a/schedule/parse.php +++ b/schedule/parse.php @@ -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);