Changes to schedule for frontend

This commit is contained in:
2017-07-27 00:06:57 +02:00
parent 8b30298ca6
commit 4ff0d7acc2
5 changed files with 28 additions and 19 deletions

View File

@@ -146,11 +146,9 @@ QUERY
/**
* Programmaschema per week
*/
public function schedule(Request $request, $weeksAhead = null) {
if($weeksAhead === null) { $weeksAhead = 1; }
else if($weeksAhead <= 0) { return abort(400); }
$start = new \DateTimeImmutable('Monday this week');
$einde = $start->add(\DateInterval::createFromDateString((int)$weeksAhead . ' weeks'));
public function schedule(Request $request, $shiftWeeks = null) {
$start = (new \DateTimeImmutable('Monday this week'))->add(\DateInterval::createFromDateString((int)$shiftWeeks . ' weeks'));
$einde = $start->add(\DateInterval::createFromDateString('1 week'));
return response()->json($this->createSchedule($start, $einde));
}
@@ -231,30 +229,29 @@ QUERY
$actieveProgrammas[$programma->priority] = $programma;
for($prio = $programma->priority; $prio >= 0; --$prio) {
if($actieveProgrammas[$prio] != null) {
if(($index == -1) || ($schema[$index]['time'] != $tijdstip)) { $index++; }
$schema[$index] = ['time' => $tijdstip, 'program' => $programmaInfo[$actieveProgrammas[$prio]->id]];
if(($index == -1) || ($schema[$index]['starttime'] != $tijdstip)) { $index++; }
$schema[$index] = ['starttime' => $tijdstip, 'endtime' => null, 'program' => $programmaInfo[$actieveProgrammas[$prio]->id]];
break;
}
}
} else /*if($programmaWissel[PW_TYPE] == PROGRAMMA_EINDE)*/ {
$actieveProgrammas[$programma->priority] = null;
if(($index == -1) || ($schema[$index]['program'] != null)) { $index++; }
$schema[$index] = ['time' => $tijdstip, 'program' => null];
$schema[$index] = ['starttime' => $tijdstip, 'program' => null];
for($prio = $programma->priority; $prio < count($actieveProgrammas); ++$prio) {
if($actieveProgrammas[$prio] != null) {
$schema[$index] = ['time' => $tijdstip, 'program' => $programmaInfo[$actieveProgrammas[$prio]->id]];
$schema[$index] = ['starttime' => $tijdstip, 'endtime' => null, 'program' => $programmaInfo[$actieveProgrammas[$prio]->id]];
break;
}
}
}
}
if(false) {
for($i = 1; $i <= count($schema); $i++) {
$eindTijd = ($i == count($schema)) ? $einde : $schema[$i]['time'];
$programma = $schema[$i-1]['program'];
print $schema[$i-1]['time']->format('D d-m-Y, H:i:s') . " - " . $eindTijd->format('D d-m-Y, H:i:s') . ": " . ($programma != null ? $programma->name : "NULL") . "\n";
}
for($i = 1; $i <= count($schema); $i++) {
$eindTijd = ($i == count($schema)) ? $einde : $schema[$i]['starttime'];
$schema[$i - 1]['endtime'] = $eindTijd;
//$programma = $schema[$i-1]['program'];
//print $schema[$i-1]['starttime']->format('D d-m-Y, H:i:s') . " - " . $eindTijd->format('D d-m-Y, H:i:s') . ": " . ($programma != null ? $programma->name : "NULL") . "\n";
}
return ['startdate' => $start, 'enddate' => $einde, 'schedule' => $schema, 'errors' => $fouten];

View File

@@ -30,7 +30,7 @@ $app->get('podcast/download/{id:\d+}/[{title}]', 'PodcastController@download' );
$app->get('podcast/stream/{id:\d+}/[{title}]', 'PodcastController@stream' );
$app->get('programma/schema/nustraks', 'ProgramController@comingup' );
$app->get('programma/schema/week[/{weeksAhead:\d+}]', 'ProgramController@schedule' );
$app->get('programma/schema/week[/{shiftWeeks:-?\d+}]', 'ProgramController@schedule' );
$app->get('/programma/details/{id:\d+}', 'ProgramController@details' );
// live/onair

View File

@@ -13,7 +13,7 @@ class NewsImage extends Model {
// Deserialisatie van JSON heeft url in data,
// lezen uit database heeft file en (als het goed is) urlPrefix
if(isset($data->file)) {
$this->url = $urlPrefix . $data->file;
$this->url = 'http://www.6fm.nl' . $urlPrefix . $data->file;
}
}
}

View File

@@ -36,7 +36,14 @@ class NewsItem extends Model {
? new \Model\NewsSource($data->source->title, $data->source->url, $data->source->url)
: new \Model\NewsSource($data->source, $data->source_url, $data->showsource);
}
$this->keywords = !is_array($data->keywords) && trim($data->keywords) ? explode(' ', $data->keywords) : null;
$this->keywords = null;
if(is_array($data->keywords)) {
$this->keywords = $data->keywords;
} else if(trim($data->keywords)) {
$this->keywords = explode(' ', $data->keywords);
}
$this->podcast = $data->podcast ? $data->podcast : null;
$images = ($images != null) ? $images

View File

@@ -16,9 +16,14 @@ class Program extends Model {
public function __construct($data) {
parent::__construct($data);
$this->isSpecial = ($data->priority < 2);
if(!isset($data->isSpecial) && isset($data->priority)) {
$this->isSpecial = ($data->priority < 2);
}
if(($mailComma = strpos($data->email, ',')) !== false) {
$this->email = substr($data->email, 0, $mailComma);
}
$this->url = "/{$this->id}/" . parent::url_slug($this->name);
}
}