Show Display-Names and Link Rooms in Relive-View

This commit is contained in:
MaZderMind 2015-04-04 13:31:01 +02:00
parent b8f51fa77f
commit 6913b01e5d
3 changed files with 35 additions and 2 deletions

View file

@ -21,6 +21,8 @@ class Relive extends ModelBase
$talks = file_get_contents($this->getJsonUrl());
$talks = (array)json_decode($talks, true);
$mapping = $this->getScheduleToRoomMapping();
usort($talks, function($a, $b) {
$sort = array('live', 'recorded', 'released');
return array_search($a['status'], $sort) > array_search($b['status'], $sort);
@ -34,6 +36,13 @@ class Relive extends ModelBase
else
$talk['url'] = 'relive/'.rawurlencode($talk['id']).'/';
if(isset($mapping[$talk['room']]))
{
$room = $mapping[$talk['room']];
$talk['room'] = $room->getDisplay();
$talk['roomlink'] = $room->getLink();
}
$talks_by_id[$talk['id']] = $talk;
}
@ -86,4 +95,24 @@ class Relive extends ModelBase
{
return 'RELIVE.'.$this->getJsonUrl();
}
private function getScheduleToRoomMapping()
{
$schedule = new Schedule();
$mapping = array();
foreach($schedule->getScheduleToRoomSlugMapping() as $schedule => $slug)
{
try {
$mapping[$schedule] = new Room($slug);
}
catch(NotFoundException $e)
{
//
}
}
return $mapping;
}
}

View file

@ -258,7 +258,7 @@ class Schedule extends ModelBase
return 'SCHEDULE.'.$this->getScheduleUrl();
}
private function getScheduleToRoomSlugMapping()
public function getScheduleToRoomSlugMapping()
{
$mapping = array();
foreach($this->get('ROOMS') as $slug => $room)

View file

@ -54,7 +54,11 @@
</li>
<li>
<span class="fa fa-sign-in"></span>
<?=h($talk['room'])?>
<? if(isset($talk['roomlink'])): ?>
<a href="<?=h($talk['roomlink'])?>"><?=h($talk['room'])?></a>
<? else: ?>
<?=h($talk['room'])?>
<? endif ?>
</li>
</ul>