Compare commits
3
Commits
b87b7bfa75
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abc9914827 | ||
|
|
d859df0ab4 | ||
|
|
0c16562e87 |
No files matched your search
@@ -103,13 +103,19 @@ QUERY;
|
||||
|
||||
public function retrieveNewsItems($page, $count, $filter, $params) {
|
||||
$filterSql = "";
|
||||
$params = ['target' => self::$WEBSITE_TARGET, 'category' => self::$NEWS_CATEGORY, 'secondarycategory' => self::$EXTERNAL_NEWS_CATEGORY];
|
||||
if($filter) {
|
||||
foreach($filter as $field => $value) {
|
||||
$paramName = preg_replace('/[^A-Za-z0-9]/', '', $field);
|
||||
$filterSql .= " AND $field = :$paramName";
|
||||
$params[$paramName] = $value;
|
||||
}
|
||||
$params['target'] = self::$WEBSITE_TARGET;
|
||||
$params['category'] = self::$NEWS_CATEGORY;
|
||||
$params['secondarycategory'] = self::$EXTERNAL_NEWS_CATEGORY;
|
||||
if($filter) {
|
||||
if(is_array($filter)) {
|
||||
foreach($filter as $field => $value) {
|
||||
$paramName = preg_replace('/[^A-Za-z0-9]/', '', $field);
|
||||
$filterSql .= " AND $field = :$paramName";
|
||||
$params[$paramName] = $value;
|
||||
}
|
||||
} else {
|
||||
$filterSql .= ' AND ' . $filter;
|
||||
}
|
||||
}
|
||||
|
||||
$start = ($page - 1) * $count;
|
||||
@@ -397,6 +403,70 @@ QUERY
|
||||
return $item ? response()->json(new \Model\CalendarEvent($item['data'], $item['images'], $item['podcast'])) : abort(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overzicht voor het NLPO-dashboard
|
||||
*/
|
||||
public function nlpo(Request $request) {
|
||||
$from = $request->get('from');
|
||||
if(!$from) { $from = date('Y-m-d', strtotime('-7 days')); }
|
||||
$to = $request->get('to');
|
||||
if(!$to) { $to = date('Y-m-d'); }
|
||||
|
||||
$filter = 'DATE(`news`.`creationdt`) >= :from AND DATE(`news`.`creationdt`) <= :to';
|
||||
$items = $this->retrieveNewsItems(1, 10000,
|
||||
$filter,
|
||||
['from' => $from, 'to' => $to]);
|
||||
$result = [];
|
||||
foreach($items as $item) {
|
||||
$tags = [];
|
||||
if($item->theme) $tags[] = $item->theme->title;
|
||||
if($item->region) $tags[] = $item->region->title;
|
||||
|
||||
$text = $item->content;
|
||||
$source = app('db')->select('SELECT content FROM `news_target_content` WHERE news = :news AND target = 0 AND published = 1 AND active = 1',
|
||||
['news' => $item->id]);
|
||||
if(count($source)) {
|
||||
$text = $source[0]->content;
|
||||
$source_data = json_decode($source[0]->content);
|
||||
if($source_data) {
|
||||
$text = "";
|
||||
foreach($source_data->article->blocks as $block) {
|
||||
if($block->type == 'authors') {
|
||||
$authors = [];
|
||||
foreach($block->authors as $author) {
|
||||
$authors[] = $author->name;
|
||||
}
|
||||
$item->author = implode(', ', $authors);
|
||||
} else if(isset($block->text) && $block->type != 'info') {
|
||||
$text .= strip_tags($block->text);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$text = $source[0];
|
||||
}
|
||||
}
|
||||
$result[] = [
|
||||
'title' => $this->nlpo_convert_utf8($item->title),
|
||||
'url' => 'https://nhgooi.nl/' . $item->url,
|
||||
'text' => $this->nlpo_convert_utf8($text),
|
||||
'date' => $item->published->format('Y-m-d\TH:i:s.z\Z'),
|
||||
'art_id' => $item->id,
|
||||
'author' => $item->author,
|
||||
'excerpt' => $this->nlpo_convert_utf8(strip_tags($item->content)),
|
||||
'categories' => $tags,
|
||||
'tags' => $tags,
|
||||
'comment_count' => 0
|
||||
];
|
||||
}
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
private function nlpo_convert_utf8($str) {
|
||||
$str = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
|
||||
return $str;
|
||||
}
|
||||
|
||||
private function itemFromCategory($category, $id) {
|
||||
$params = ['id' => (int)$id, 'target' => self::$WEBSITE_TARGET];
|
||||
if(is_array($category)) {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
<itunes:author>NH Gooi Radio</itunes:author>
|
||||
<itunes:explicit>no</itunes:explicit>
|
||||
<itunes:image href="https://nhgooi.nl/images/logo_sqr_hq.png" />
|
||||
<itunes:image href="https://nhgooi.nl/images/{{ isset($program) && $program->id == 1097 ? "hilversum_oorlog.jpg" : "logo_sqr_hq.png" }}" />
|
||||
<itunes:owner>
|
||||
<itunes:name>NH Gooi Radio</itunes:name>
|
||||
<itunes:email>{{isset($program) ? $program->email : 'info' }}@nhgooi.nl</itunes:email>
|
||||
|
||||
@@ -24,6 +24,7 @@ $app->get( 'menu/special', 'MenuController@special' );
|
||||
|
||||
$app->get('nieuws/overzicht', 'NewsController@newslist' );
|
||||
$app->get('nieuws/kabelkrant', 'NewsController@tvlist' );
|
||||
$app->get('nieuws/nlpo', 'NewsController@nlpo' );
|
||||
$app->get('nieuws/regio/{region:[a-z0-9-]+}', 'NewsController@regionlist' );
|
||||
$app->get('nieuws/thema/{theme:[a-z0-9-]+}', 'NewsController@themelist' );
|
||||
$app->get('nieuws/zoeken/{query}', 'NewsController@findnews' );
|
||||
|
||||
Reference in new issue
Block a user