Compare commits

1 Commits

Author SHA1 Message Date
NH Gooi
54677c8372 Model changes voor nieuwe API 2024-09-12 15:33:53 +02:00
3 changed files with 14 additions and 13 deletions

View File

@@ -437,8 +437,8 @@ QUERY
$authors[] = $author->name; $authors[] = $author->name;
} }
$item->author = implode(', ', $authors); $item->author = implode(', ', $authors);
} else if(isset($block->text) && $block->type != 'info') { } else if(isset($block->text)) {
$text .= strip_tags($block->text); $text .= '<div class="' . $block->type . '">' . $block->text . '</div>';
} }
} }
} else { } else {
@@ -446,25 +446,19 @@ QUERY
} }
} }
$result[] = [ $result[] = [
'title' => $this->nlpo_convert_utf8($item->title), 'title' => $item->title,
'url' => 'https://nhgooi.nl/' . $item->url, 'url' => 'https://nhgooi.nl/' . $item->url,
'text' => $this->nlpo_convert_utf8($text), 'text' => $text,
'date' => $item->published->format('Y-m-d\TH:i:s.z\Z'), 'date' => $item->published->format('Y-m-d\TH:i:s.z\Z'),
'art_id' => $item->id, 'art_id' => $item->id,
'author' => $item->author, 'author' => $item->author,
'excerpt' => $this->nlpo_convert_utf8(strip_tags($item->content)), 'excerpt' => strip_tags($item->content),
'categories' => $tags, 'categories' => $tags,
'tags' => $tags, 'tags' => $tags,
'comment_count' => 0 'comment_count' => 0
]; ];
} }
header('Content-Type: application/json; charset=utf-8'); return response()->json($result);
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) { private function itemFromCategory($category, $id) {

View File

@@ -15,6 +15,7 @@ class CalendarEvent extends Model {
public $keywords; public $keywords;
public $url; public $url;
public $metadata; public $metadata;
public $tags;
public function __construct($data, $images = null, $podcast = null) { public function __construct($data, $images = null, $podcast = null) {
parent::__construct($data); parent::__construct($data);

View File

@@ -19,11 +19,12 @@ class NewsItem extends Model {
public $category; public $category;
public $theme; public $theme;
public $region; public $region;
public $tags;
public $podcast; public $podcast;
public $images; public $images;
public $video; public $video;
public $url; public $url;
public $metadata; public $metadata;
@@ -79,6 +80,11 @@ class NewsItem extends Model {
} }
} }
if(isset($data->tags)) {
foreach($data->tags as $tag) {
$this->theme = new \Model\NewsRegion($tag->titel, $tag->slug);
}
}
$images = ($images != null) ? $images $images = ($images != null) ? $images
: (isset($data->images) ? $data->images : null); : (isset($data->images) ? $data->images : null);