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`
|
||||
|
||||
@@ -14,7 +14,7 @@ class CalendarEvent extends Model {
|
||||
public $keywords;
|
||||
public $url;
|
||||
|
||||
public function __construct($data, $images = null) {
|
||||
public function __construct($data, $images = null, $podcast = null) {
|
||||
parent::__construct($data);
|
||||
parent::ConvertToDateTime($this->starts);
|
||||
parent::ConvertToDateTime($this->ends);
|
||||
@@ -28,7 +28,12 @@ class CalendarEvent extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$this->podcast = isset($data->podcast) && $data->podcast ? $data->podcast : null;
|
||||
if($podcast)
|
||||
{
|
||||
$this->podcast = new \Model\Podcast($podcast);
|
||||
} else if(isset($data->podcast) && $data->podcast) {
|
||||
$this->podcast = new \Model\Podcast($data->podcast);
|
||||
}
|
||||
|
||||
$images = ($images != null) ? $images
|
||||
: (isset($data->images) ? $data->images : null);
|
||||
|
||||
@@ -17,14 +17,14 @@ class NewsItem extends Model {
|
||||
public $category;
|
||||
public $theme;
|
||||
public $region;
|
||||
|
||||
|
||||
public $podcast;
|
||||
public $images;
|
||||
public $video;
|
||||
|
||||
public $url;
|
||||
|
||||
public function __construct($data, $images = null) {
|
||||
public function __construct($data, $images = null, $podcast = null) {
|
||||
parent::__construct($data);
|
||||
parent::ConvertToDateTime($this->published);
|
||||
parent::ConvertToDateTime($this->edited);
|
||||
@@ -35,11 +35,21 @@ class NewsItem extends Model {
|
||||
}
|
||||
|
||||
$this->source = null;
|
||||
if(is_object($data->source))
|
||||
if(isset($data->source))
|
||||
{
|
||||
$this->source = new \Model\NewsSource($data->source->title, $data->source->url, $data->source->url);
|
||||
} else if($data->source) {
|
||||
$this->source = new \Model\NewsSource($data->source, $data->source_url, $data->showsource);
|
||||
if(is_object($data->source))
|
||||
{
|
||||
$this->source = new \Model\NewsSource($data->source->title, $data->source->url, $data->source->show);
|
||||
} else if($data->source) {
|
||||
$this->source = new \Model\NewsSource($data->source, $data->source_url, $data->showsource);
|
||||
}
|
||||
}
|
||||
|
||||
if($podcast)
|
||||
{
|
||||
$this->podcast = new \Model\Podcast($podcast);
|
||||
} else if(isset($data->podcast) && $data->podcast) {
|
||||
$this->podcast = new \Model\Podcast($data->podcast);
|
||||
}
|
||||
|
||||
$this->keywords = null;
|
||||
@@ -49,8 +59,6 @@ class NewsItem extends Model {
|
||||
$this->keywords = explode(' ', $data->keywords);
|
||||
}
|
||||
|
||||
$this->podcast = $data->podcast ? $data->podcast : null;
|
||||
|
||||
$images = ($images != null) ? $images
|
||||
: (isset($data->images) ? $data->images : null);
|
||||
if($images) {
|
||||
|
||||
Reference in New Issue
Block a user