Added live blog
This commit is contained in:
@@ -8,6 +8,8 @@ class NewsController extends Controller
|
||||
{
|
||||
private static $NEWS_CATEGORY = 1;
|
||||
private static $CALENDAR_CATEGORY = 42;
|
||||
private static $BLOG_CATEGORY = 45;
|
||||
|
||||
private static $BASE_SQL = <<<QUERY
|
||||
SELECT `news`.`id`, `content`.`title`, `content`.`content`, `news`.`podcast` AS `podcast_id`, `news`.`video`, `news`.`keywords`, `news`.`titlewithdate`,
|
||||
`news`.`creationdt` AS `published`, `content`.`creator`, `news`.`pubupdatedt` AS `edited`,
|
||||
@@ -137,6 +139,42 @@ QUERY;
|
||||
return response()->json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blogitems ophalen
|
||||
*/
|
||||
public function bloglist(Request $request, $from, $to) {
|
||||
$count = (int)$request->get('aantal', 15);
|
||||
$page = (int)$request->get('pagina', 1);
|
||||
if($count <= 0 || $page <= 0) {
|
||||
return abort(400);
|
||||
}
|
||||
|
||||
$startIndex = ($page - 1) * $count;
|
||||
$start = new \DateTime($from);
|
||||
$end = new \DateTime($to);
|
||||
$blogItems = app('db')->select($sql = self::$BASE_SQL
|
||||
. ' AND `news`.`startdt` >= :start AND `news`.`startdt` <= :end '
|
||||
. ' ORDER BY `news`.`startdt` DESC'
|
||||
. ' LIMIT ' . (int)$startIndex . ', ' . (int)$count,
|
||||
['category' => self::$BLOG_CATEGORY, 'start' => $from, 'end' => $to]);
|
||||
|
||||
$result = array();
|
||||
foreach($blogItems as $blogItem) {
|
||||
// Note: content is stored in the database with an additional addslashes() - don't ask why, just remove it :)
|
||||
$blogItem->content = $blogItem->content;
|
||||
$pictures = app('db')->select(self::$LOAD_IMAGES, ['newsId' => $blogItem->id]);
|
||||
if($blogItem->podcast_id > 0)
|
||||
{
|
||||
$podcast = app('db')->select(PodcastController::$BASE_SQL . ' AND `podcast`.`id` = :podcastId', ['podcastId' => $blogItem->podcast_id]);
|
||||
$podcast = count($podcast) ? $podcast[0] : null;
|
||||
}
|
||||
|
||||
$result[] = new \Model\NewsItem($blogItem, $pictures, $podcast);
|
||||
}
|
||||
|
||||
return response()->json(['page' => $page, 'count' => $count, 'items' => $result]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Populaire berichten ophalen
|
||||
|
||||
@@ -27,6 +27,8 @@ $app->get('agenda/overzicht[/week]', 'NewsController@calendarlist' );
|
||||
$app->get('agenda/item/{id:\d+}', 'NewsController@calendaritem' );
|
||||
$app->get('agenda/populair', 'NewsController@popularCalendar' );
|
||||
|
||||
$app->get('blog/overzicht/{from:\d\d\d\d-\d\d?-\d\d?}/{to:\d\d\d\d-\d\d?-\d\d?}', 'NewsController@bloglist' );
|
||||
|
||||
$app->get('podcast/overzicht', 'PodcastController@overview' );
|
||||
$app->get('podcast/details/{id:\d+}', 'PodcastController@details' );
|
||||
$app->get('podcast/zoeken/{query}', 'PodcastController@findpodcast' );
|
||||
|
||||
Reference in New Issue
Block a user