filter allowed hall ids

This commit is contained in:
Vasil Kolev 2015-10-22 14:06:18 +03:00 committed by Openfest
parent 137cddd05f
commit 8388551abd
3 changed files with 23 additions and 5 deletions

View File

@ -5,6 +5,17 @@ wp_nav_menu( array( 'theme_location' => 'footer-schedule', 'container_class' =>
$lang = pll_current_language('slug'); $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 * There is no better way to get where the speakers are
*/ */

View File

@ -3,6 +3,8 @@
get_header(); get_header();
wp_nav_menu( array( 'theme_location' => 'footer-schedule', 'container_class' => 'content subnav cf' ) ); wp_nav_menu( array( 'theme_location' => 'footer-schedule', 'container_class' => 'content subnav cf' ) );
$allowedhallids = array(6,7,8,9);
$content = require __DIR__ . DIRECTORY_SEPARATOR . 'schedule' . DIRECTORY_SEPARATOR . 'parse.php'; $content = require __DIR__ . DIRECTORY_SEPARATOR . 'schedule' . DIRECTORY_SEPARATOR . 'parse.php';
//var_dump($data); //var_dump($data);
?> ?>

View File

@ -12,6 +12,10 @@ $filenames = [
'slots' => 'slots.json', 'slots' => 'slots.json',
]; ];
if (empty($allowedhallids)) {
$allowedhallids = array (6,7,8);
}
$data = []; $data = [];
foreach ($filenames as $name => $filename) { foreach ($filenames as $name => $filename) {
@ -31,12 +35,13 @@ foreach ($filenames as $name => $filename) {
} }
$add = true; $add = true;
switch ($name) { switch ($name) {
case 'halls': case 'halls':
$decoded = array_map(function($el) { $ret = array();
return $el['name']; foreach($decoded as $id => $hall) {
}, $decoded); if (in_array($id, $allowedhallids)) $ret[$id] = $hall['name'];
}
$decoded = $ret;
break; break;
case 'slots': case 'slots':
$decoded = array_map(function($el) { $decoded = array_map(function($el) {
@ -63,6 +68,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;