Fragment terugluisteren toegevoegd aan nieuws en agenda
This commit is contained in:
@@ -9,11 +9,10 @@ ini_set('display_errors', true);
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
// TODO: Include podcast
|
||||
private static $NEWS_CATEGORY = 1;
|
||||
private static $CALENDAR_CATEGORY = 42;
|
||||
private static $BASE_SQL = <<<QUERY
|
||||
SELECT `news`.`id`, `content`.`title`, `content`.`content`, `news`.`podcast`, `news`.`video`, `news`.`keywords`, `news`.`titlewithdate`,
|
||||
SELECT `news`.`id`, `content`.`title`, `content`.`content`, `news`.`podcast` AS `podcast_id`, `news`.`video`, `news`.`keywords`, `news`.`titlewithdate`,
|
||||
`news`.`creationdt` AS `published`, `content`.`creator`, `content`.`editingdt` AS `edited`, `content`.`editor`,
|
||||
`news`.`startdt` AS `starts`, `news`.`enddt` AS `ends`,
|
||||
`content`.`showsource` AS `showsource`, `sources`.`title` AS `source`, `sources`.`url` AS `source_url`,
|
||||
@@ -90,7 +89,7 @@ QUERY;
|
||||
*/
|
||||
public function newsitem($id) {
|
||||
$item = $this->itemFromCategory(self::$NEWS_CATEGORY, $id);
|
||||
return $item ? response()->json(new \Model\NewsItem($item['data'], $item['images'])) : abort(404);
|
||||
return $item ? response()->json(new \Model\NewsItem($item['data'], $item['images'], $item['podcast'])) : abort(404);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +97,7 @@ QUERY;
|
||||
*/
|
||||
public function calendaritem($id) {
|
||||
$item = $this->itemFromCategory(self::$CALENDAR_CATEGORY, $id);
|
||||
return $item ? response()->json(new \Model\CalendarEvent($item['data'], $item['images'])) : abort(404);
|
||||
return $item ? response()->json(new \Model\CalendarEvent($item['data'], $item['images'], $item['podcast'])) : abort(404);
|
||||
}
|
||||
|
||||
private function itemFromCategory($category, $id) {
|
||||
@@ -112,7 +111,14 @@ QUERY;
|
||||
// Note: content is stored in the database with an additional addslashes() - don't ask why, just remove it :)
|
||||
$newsItem[0]->content = stripslashes($newsItem[0]->content);
|
||||
$images = app('db')->select(self::$LOAD_IMAGES, ['newsId' => $id]);
|
||||
return ['data' => $newsItem[0], 'images' => $images];
|
||||
$podcast = null;
|
||||
if($newsItem[0]->podcast_id > 0)
|
||||
{
|
||||
$podcast = app('db')->select(PodcastController::$BASE_SQL . ' AND `podcast`.`id` = :podcastId', ['podcastId' => $newsItem[0]->podcast_id]);
|
||||
$podcast = count($podcast) ? $podcast[0] : null;
|
||||
}
|
||||
|
||||
return ['data' => $newsItem[0], 'images' => $images, 'podcast' => $podcast];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ ini_set('display_errors', true);
|
||||
class PodcastController extends Controller
|
||||
{
|
||||
// TODO: Include program
|
||||
private static $BASE_SQL = <<<QUERY
|
||||
public static $BASE_SQL = <<<QUERY
|
||||
SELECT `podcast`.`id`, `podcast`.`soundfilename`,
|
||||
`podcast_meta`.`creationdt` AS `created`, `podcast_meta`.`title`, `podcast_meta`.`content`, `podcast_meta`.`program`,
|
||||
`programs`.`longname` AS `program_name`, `programs`.`description` AS `program_description`
|
||||
|
||||
Reference in New Issue
Block a user