Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30893eb7a7 | ||
|
|
9bee381f6c | ||
|
|
8125895538 |
No files matched your search
@@ -1,4 +1,5 @@
|
||||
/node_modules
|
||||
/bootstrap/cache
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
|
||||
+4
-1
@@ -55,10 +55,13 @@ RUN composer install \
|
||||
--optimize-autoloader
|
||||
|
||||
RUN mkdir -p \
|
||||
storage/app \
|
||||
storage/framework/cache/data \
|
||||
storage/framework/sessions \
|
||||
storage/framework/views \
|
||||
storage/logs \
|
||||
bootstrap/cache \
|
||||
&& chown -R www-data:www-data storage bootstrap/cache \
|
||||
&& chmod -R ug+rwx storage bootstrap/cache
|
||||
&& chmod -R ug+rwX storage bootstrap/cache
|
||||
|
||||
EXPOSE 80
|
||||
@@ -1,38 +0,0 @@
|
||||
FROM php:8.2-apache
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get -y install \
|
||||
g++ \
|
||||
libcurl4-gnutls-dev \
|
||||
libxml2-dev \
|
||||
libxslt-dev \
|
||||
libzip-dev \
|
||||
zlib1g-dev \
|
||||
msmtp \
|
||||
unzip \
|
||||
git \
|
||||
ssl-cert \
|
||||
locales \
|
||||
--no-install-recommends \
|
||||
&& docker-php-ext-install pdo pdo_mysql mysqli xsl xml zip opcache \
|
||||
&& a2enmod rewrite ssl proxy proxy_http headers \
|
||||
&& apt-get purge -y g++ \
|
||||
&& apt-get autoremove -y \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
|
||||
# Get latest Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Update the default apache site with the config we created.
|
||||
ADD docker/apache.dev.conf /etc/apache2/sites-enabled/000-default.conf
|
||||
|
||||
WORKDIR /var/www/html
|
||||
COPY . /var/www/html
|
||||
|
||||
RUN mkdir -p storage/framework/{sessions,views,cache,cache/data} && \
|
||||
chown -R www-data:www-data storage/framework && \
|
||||
chmod -R 775 storage
|
||||
|
||||
# RUN php artisan cache:clear && \
|
||||
# php artisan config:clear && \
|
||||
# php artisan view:clear
|
||||
+53
-34
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
private $API_URL;
|
||||
private $API_URL;
|
||||
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
@@ -19,6 +21,22 @@ class Kernel extends ConsoleKernel
|
||||
//
|
||||
];
|
||||
|
||||
private function getFromApi($url, $file) {
|
||||
$response = Http::connectTimeout(5)
|
||||
->timeout(15)
|
||||
->withHeaders([
|
||||
'Host' => $this->API_HOST
|
||||
])
|
||||
->get($this->API_URL . $url);
|
||||
|
||||
if ($response->successful()) {
|
||||
Storage::disk('local')->put(
|
||||
$file,
|
||||
$response->body()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
@@ -27,39 +45,40 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$this->API_URL = env('API_URL', 'https://api.nhgooi.nl/');
|
||||
|
||||
// Update latest news (3 items)
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('laatste_nieuws.json', file_get_contents($this->API_URL . 'nieuws/overzicht?pagina=1&aantal=3'));
|
||||
Storage::disk('local')->put('populair_nieuws.json', file_get_contents($this->API_URL . 'nieuws/populair'));
|
||||
})->everyMinute();
|
||||
|
||||
// Update now / later
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('nu_straks.json', file_get_contents($this->API_URL . 'programma/schema/nustraks'));
|
||||
Storage::disk('local')->put('zojuist.json', file_get_contents($this->API_URL . 'programma/schema/recent'));
|
||||
})->everyMinute();
|
||||
|
||||
// Update latest podcasts (6 items)
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('laatste_podcasts.json', file_get_contents($this->API_URL . 'podcast/overzicht?pagina=1&aantal=6'));
|
||||
})->everyMinute();
|
||||
|
||||
// Update calendar items
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('regioagenda.json', file_get_contents($this->API_URL . 'agenda/overzicht'));
|
||||
})->everyMinute();
|
||||
|
||||
// Update blogs
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('blogs.json', file_get_contents($this->API_URL . 'blog/overzicht'));
|
||||
})->everyMinute();
|
||||
|
||||
// Update featured images
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('beelden.json', file_get_contents($this->API_URL . 'beelden/overzicht'));
|
||||
})->everyMinute();
|
||||
$this->API_URL = env('API_URL', 'https://api.nhgooi.nl/');
|
||||
$this->API_HOST = env('API_HOST', $this->API_URL);
|
||||
|
||||
// Update latest news (3 items)
|
||||
$schedule->call(function () {
|
||||
$this->getFromApi('nieuws/overzicht?pagina=1&aantal=3', 'laatste_nieuws.json');
|
||||
$this->getFromApi('nieuws/populair', 'populair_nieuws.json');
|
||||
})->everyMinute();
|
||||
|
||||
// Update now / later
|
||||
$schedule->call(function () {
|
||||
$this->getFromApi('programma/schema/nustraks', 'nu_straks.json');
|
||||
$this->getFromApi('programma/schema/recent', 'zojuist.json');
|
||||
})->everyMinute();
|
||||
|
||||
// Update latest podcasts (6 items)
|
||||
$schedule->call(function () {
|
||||
$this->getFromApi('podcast/overzicht?pagina=1&aantal=6', 'laatste_podcasts.json');
|
||||
})->everyMinute();
|
||||
|
||||
// Update calendar items
|
||||
$schedule->call(function () {
|
||||
$this->getFromApi('agenda/overzicht', 'regioagenda.json');
|
||||
})->everyMinute();
|
||||
|
||||
// Update blogs
|
||||
$schedule->call(function () {
|
||||
$this->getFromApi('blog/overzicht', 'blogs.json');
|
||||
})->everyMinute();
|
||||
|
||||
// Update featured images
|
||||
$schedule->call(function () {
|
||||
$this->getFromApi('beelden/overzicht', 'beelden.json');
|
||||
})->everyMinute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,19 +9,19 @@ class CalendarController extends Controller
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
parent::registerView($request, 'agenda', $id);
|
||||
$apiResult = $this->API('agenda/item/' . (int)$id);
|
||||
$calendarEvent = new \Model\CalendarEvent($apiResult->news);
|
||||
$apiResult = (object) $this->API('agenda/item/' . (int)$id);
|
||||
$calendarEvent = new \Model\CalendarEvent((object) $apiResult->news);
|
||||
|
||||
return view('calendarevent', array_merge($this->getSidebareData(), ['event' => $calendarEvent, 'metadata' => $calendarEvent->metadata]));
|
||||
}
|
||||
|
||||
public function overview(Request $request)
|
||||
{
|
||||
$apiResult = $this->API('agenda/overzicht?aantal=100');
|
||||
$apiResult = (object) $this->API('agenda/overzicht?aantal=100');
|
||||
$calendar = [];
|
||||
foreach($apiResult->events as $calendarItem)
|
||||
{
|
||||
$calendar[] = new \Model\CalendarEvent($calendarItem);
|
||||
$calendar[] = new \Model\CalendarEvent((object) $calendarItem);
|
||||
}
|
||||
|
||||
return view('calendarlist', array_merge($this->getSidebareData(), ['events' => $calendar]));
|
||||
|
||||
@@ -12,7 +12,7 @@ class ContactController extends Controller
|
||||
{
|
||||
public function show()
|
||||
{
|
||||
$page = $this->API('statisch/contact');
|
||||
$page = (object) $this->API('statisch/contact');
|
||||
if ($page == null) {
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\View;
|
||||
@@ -16,7 +18,9 @@ class Controller extends BaseController
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
protected $API_URL;
|
||||
|
||||
protected $API_HOST;
|
||||
|
||||
|
||||
private function getDataFromFileAndConvert($file, $path, $class, $maxItems = 0)
|
||||
{
|
||||
$data = json_decode(Storage::get($file));
|
||||
@@ -38,6 +42,7 @@ class Controller extends BaseController
|
||||
{
|
||||
View::share('apiUrl', $this->API_URL = env('API_URL', 'http://api.6fm.nl/'));
|
||||
View::share('imgBase', env('IMAGE_BASE_URL', '/'));
|
||||
$this->API_HOST = env('API_HOST', $this->API_URL);
|
||||
|
||||
//View::share('onAir', file_get_contents(url('onair')));
|
||||
View::composer('widgets.laatstenieuws', function ($view) {
|
||||
@@ -92,7 +97,12 @@ class Controller extends BaseController
|
||||
);
|
||||
});
|
||||
View::composer('widgets.menu', function($view) {
|
||||
$view->with('items', json_decode(Storage::get('static/menu.json')));
|
||||
try {
|
||||
$menuData = json_decode(Storage::get('static/menu.json'));
|
||||
$view->with('items', $menuData ?? []);
|
||||
} catch (\Exception $e) {
|
||||
$view->with('items', []);
|
||||
}
|
||||
});
|
||||
|
||||
View::share('disableBanners', env('DISABLE_BANNERS', false));
|
||||
@@ -102,51 +112,73 @@ class Controller extends BaseController
|
||||
{
|
||||
if (config('app.env') == 'local') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
app('db')->insert(
|
||||
'INSERT INTO `pagestats`(`type`, `item_id`, `visitor_ip`, `session`, `referer`) VALUES(:type, :id, :ip, :session, :referer)',
|
||||
[
|
||||
'type' => $type,
|
||||
'id' => $id,
|
||||
'ip' => $request->server('REMOTE_ADDR'),
|
||||
'session' => md5(Session::getId()),
|
||||
'referer' => $request->server('HTTP_REFERRER')
|
||||
]
|
||||
);
|
||||
// app('db')->insert(
|
||||
// 'INSERT INTO `pagestats`(`type`, `item_id`, `visitor_ip`, `session`, `referer`) VALUES(:type, :id, :ip, :session, :referer)',
|
||||
// [
|
||||
// 'type' => $type,
|
||||
// 'id' => $id,
|
||||
// 'ip' => $request->server('REMOTE_ADDR'),
|
||||
// 'session' => md5(Session::getId()),
|
||||
// 'referer' => $request->server('HTTP_REFERRER')
|
||||
// ]
|
||||
// );
|
||||
}
|
||||
|
||||
protected function API($url)
|
||||
{
|
||||
$arrContextOptions = [
|
||||
'ssl' => [
|
||||
"verify_peer" => false,
|
||||
"verify_peer_name" => false,
|
||||
],
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'X-Api-Key: ' . sha1(request()->server('REMOTE_ADDR')) . "\r\n"
|
||||
. 'X-User-Agent: ' . request()->server('HTTP_USER_AGENT') . "\r\n"
|
||||
]
|
||||
];
|
||||
//\dump($http_response_header);
|
||||
$result = @file_get_contents($this->API_URL . $url, false, stream_context_create($arrContextOptions));
|
||||
return $result ? json_decode($result) : null;
|
||||
try {
|
||||
$response = Http::connectTimeout(5)
|
||||
->timeout(15)
|
||||
->withHeaders([
|
||||
'Host' => $this->API_HOST,
|
||||
'X-Api-Key' => sha1(request()->server('REMOTE_ADDR')),
|
||||
'X-User-Agent' => request()->server('HTTP_USER_AGENT')
|
||||
])
|
||||
->get($this->API_URL . $url);
|
||||
|
||||
if ($response->successful()) {
|
||||
$body = $response->body();
|
||||
return $body ? json_decode($body) : null;
|
||||
}
|
||||
Log::warning('API request failed', [
|
||||
'url' => $this->API_URL . $url,
|
||||
'status' => $response->status()
|
||||
]);
|
||||
return null;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('API request error', [
|
||||
'url' => $this->API_URL . $url,
|
||||
'error' => $e->getMessage()
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkAPI($url)
|
||||
{
|
||||
return $this->get_http_response_code($this->API_URL . $url);
|
||||
return $this->getHttpResponseCode($url);
|
||||
}
|
||||
|
||||
protected function get_http_response_code($url)
|
||||
protected function getHttpResponseCode($url)
|
||||
{
|
||||
$headers = get_headers($url);
|
||||
return substr($headers[0], 9, 3);
|
||||
try {
|
||||
$response = Http::connectTimeout(5)
|
||||
->timeout(15)
|
||||
->withHeaders([
|
||||
'Host' => $this->API_HOST,
|
||||
'X-Api-Key' => sha1(request()->server('REMOTE_ADDR')),
|
||||
'X-User-Agent' => request()->server('HTTP_USER_AGENT')
|
||||
])
|
||||
->head($this->API_URL . $url);
|
||||
|
||||
return $response->status();
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected static function JsonToDateTime($obj)
|
||||
{
|
||||
return is_object($obj) ? new \DateTime($obj->date, new \DateTimeZone($obj->timezone)) : \Carbon\Carbon::parse($obj)->setTimezone(date_default_timezone_get());
|
||||
@@ -169,13 +201,13 @@ class Controller extends BaseController
|
||||
public function getSidebareData()
|
||||
{
|
||||
$populair = [];
|
||||
$apiResult = $this->API('nieuws/populair?aantal=5');
|
||||
$apiResult = (object) $this->API('nieuws/populair?aantal=5');
|
||||
foreach ($apiResult->news as $_newsItem) {
|
||||
$populair[] = new \Model\NewsItem($_newsItem);
|
||||
}
|
||||
|
||||
$newsItems = [];
|
||||
$apiResult = $this->API('nieuws/overzicht?aantal=5');
|
||||
$apiResult = (object) $this->API('nieuws/overzicht?aantal=5');
|
||||
foreach ($apiResult->news as $_newsItem) {
|
||||
$newsItems[] = new \Model\NewsItem($_newsItem);
|
||||
}
|
||||
@@ -189,13 +221,15 @@ class Controller extends BaseController
|
||||
return view($slug);
|
||||
}
|
||||
|
||||
$page = $this->API('statisch/' . $slug);
|
||||
if ($page == null) {
|
||||
$page = (object) $this->API('statisch/' . $slug);
|
||||
if ($page == null || !isset($page->title)) {
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
$page->published = Controller::JsonToDateTime($page->published);
|
||||
if ($page->edited) {
|
||||
if(isset($page->published)) {
|
||||
$page->published = Controller::JsonToDateTime($page->published);
|
||||
}
|
||||
if (isset($page->edited) && $page->edited) {
|
||||
$page->edited = Controller::JsonToDateTime($page->edited);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,24 +10,31 @@ class HomeController extends Controller
|
||||
public function show(Request $request)
|
||||
{
|
||||
$page = (int) $request->get('pagina', 1);
|
||||
$apiResult = $this->API('nieuws/overzicht?pagina=' . (int) max(1, $page) . '&aantal=10');
|
||||
$apiResult = (object) $this->API('nieuws/overzicht?pagina=' . (int) max(1, $page) . '&aantal=10');
|
||||
$news = [];
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$news[] = new \Model\NewsItem($newsItem);
|
||||
if ($apiResult && isset($apiResult->news)) {
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$news[] = new \Model\NewsItem((object) $newsItem);
|
||||
}
|
||||
}
|
||||
|
||||
$apiResult = $this->API('nieuws/liveblogs');
|
||||
$liveblogs = $apiResult->liveblogs;
|
||||
$apiResult = (object) $this->API('nieuws/liveblogs');
|
||||
$liveblogs = $apiResult && isset($apiResult->liveblogs) ? $apiResult->liveblogs : [];
|
||||
|
||||
$populair = [];
|
||||
$apiResult = $this->API('nieuws/populair?pagina=' . (int) max(1, $page) . '&aantal=5');
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$populair[] = new \Model\NewsItem($newsItem);
|
||||
$apiResult = (object) $this->API('nieuws/populair?pagina=' . (int) max(1, $page) . '&aantal=5');
|
||||
if ($apiResult && isset($apiResult->news)) {
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$populair[] = new \Model\NewsItem((object) $newsItem);
|
||||
}
|
||||
}
|
||||
|
||||
$apiResult = $this->API('podcast/overzicht?aantal=15');
|
||||
$index = array_rand($apiResult->podcasts);
|
||||
$podcast = new \Model\Podcast($apiResult->podcasts[$index]);
|
||||
$podcast = null;
|
||||
$apiResult = (object) $this->API('podcast/overzicht?aantal=15');
|
||||
if ($apiResult && isset($apiResult->podcasts) && !empty($apiResult->podcasts)) {
|
||||
$index = array_rand($apiResult->podcasts);
|
||||
$podcast = new \Model\Podcast((object) $apiResult->podcasts[$index]);
|
||||
}
|
||||
return view('home', ['populair' => $populair, 'podcast' => $podcast, 'title' => 'Home', 'news' => $news, 'liveblogs' => $liveblogs, 'searchURL' => 'nieuws/zoeken']);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class ImagesController extends Controller
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
$apiResult = $this->API('beelden/details/' . $id);
|
||||
$apiResult = (object) $this->API('beelden/details/' . $id);
|
||||
$imagesItem = new \Model\NewsItem($apiResult->images);
|
||||
|
||||
return view('imagesitem', ['images' => $imagesItem, 'metadata' => $imagesItem->metadata]);
|
||||
@@ -39,7 +39,7 @@ class ImagesController extends Controller
|
||||
private function listImages(Request $request, $url, $title = null)
|
||||
{
|
||||
$page = (int)$request->get('pagina', 1);
|
||||
$apiResult = $this->API('beelden/' . $url . '?pagina=' . (int)max(1, $page));
|
||||
$apiResult = (object) $this->API('beelden/' . $url . '?pagina=' . (int)max(1, $page));
|
||||
$images = [];
|
||||
foreach($apiResult->items as $imagesItem)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ class JobsController extends Controller
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
parent::registerView($request, 'nieuws', $id);
|
||||
$apiResult = $this->API('vacatures/details/' . $id);
|
||||
$apiResult = (object) $this->API('vacatures/details/' . $id);
|
||||
$jobsItem = new \Model\JobOpening($apiResult->item);
|
||||
return view('jobsitem', array_merge($this->getSidebareData(), ['job' => $jobsItem, 'metadata' => $jobsItem->metadata]));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class KerkdienstController extends Controller
|
||||
public function main(Request $request)
|
||||
{
|
||||
parent::registerView($request, 'kerkdienst', 0);
|
||||
$apiResult = $this->API('kerkdienst');
|
||||
return view('kerkdienst', ['kerkdienst' => new \Model\Kerkdienst($apiResult)]);
|
||||
$apiResult = (object) $this->API('kerkdienst');
|
||||
return view('kerkdienst', ['kerkdienst' => new \Model\Kerkdienst((object) $apiResult)]);
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,8 @@ class NewsController extends Controller
|
||||
if (request()->get('preview', null) != null) {
|
||||
$preview = "?preview=" . request()->get('preview');
|
||||
}
|
||||
$apiResult = $this->API('nieuws/bericht/' . $id . $preview);
|
||||
$newsItem = new \Model\NewsItem($apiResult->news);
|
||||
$apiResult = (object) $this->API('nieuws/bericht/' . $id . $preview);
|
||||
$newsItem = new \Model\NewsItem((object) $apiResult->news);
|
||||
|
||||
switch ($apiResult->version) {
|
||||
case 1:
|
||||
@@ -54,10 +54,10 @@ class NewsController extends Controller
|
||||
{
|
||||
$page = (int) $request->get('pagina', 1);
|
||||
$id = $request->get('id', '');
|
||||
$apiResult = $this->API('nieuws/overzicht?pagina=' . (int) max(1, $page) . '&aantal=5');
|
||||
$apiResult = (object) $this->API('nieuws/overzicht?pagina=' . (int) max(1, $page) . '&aantal=5');
|
||||
$news = [];
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$news[] = new \Model\NewsItem($newsItem);
|
||||
$news[] = new \Model\NewsItem((object) $newsItem);
|
||||
}
|
||||
|
||||
return view('partial/newslist_small', ['id' => $id, 'news' => $news]);
|
||||
@@ -68,9 +68,9 @@ class NewsController extends Controller
|
||||
$page = (int) $request->get('pagina', 1);
|
||||
$id = $request->get('id', '');
|
||||
$populair = [];
|
||||
$apiResult = $this->API('nieuws/populair?pagina=' . (int) max(1, $page) . '&aantal=5');
|
||||
$apiResult = (object) $this->API('nieuws/populair?pagina=' . (int) max(1, $page) . '&aantal=5');
|
||||
foreach ($apiResult->news as $_newsItem) {
|
||||
$populair[] = new \Model\NewsItem($_newsItem);
|
||||
$populair[] = new \Model\NewsItem((object) $_newsItem);
|
||||
}
|
||||
|
||||
return view('partial/newslist_small', ['id' => $id, 'news' => $populair]);
|
||||
@@ -99,9 +99,9 @@ class NewsController extends Controller
|
||||
|
||||
public function activeblog()
|
||||
{
|
||||
$apiResult = $this->API('blog/overzicht');
|
||||
if (count($apiResult)) {
|
||||
$blog = new \Model\Blog($apiResult[0]);
|
||||
$apiResult = (object) $this->API('blog/overzicht');
|
||||
if (count((array) $apiResult)) {
|
||||
$blog = new \Model\Blog((object) $apiResult[0]);
|
||||
if ($blog->is_active) {
|
||||
return redirect($blog->url);
|
||||
}
|
||||
@@ -115,9 +115,9 @@ class NewsController extends Controller
|
||||
|
||||
parent::registerView($request, 'blog', $id);
|
||||
|
||||
$blog = $this->API('nieuws/liveblog/' . (int) $id);
|
||||
$blog = (object) $this->API('nieuws/liveblog/' . (int) $id);
|
||||
foreach ($blog->artikelen as &$item) {
|
||||
$item = new \Model\NewsItem($item);
|
||||
$item = new \Model\NewsItem((object) $item);
|
||||
}
|
||||
|
||||
if (request()->ajax()) {
|
||||
@@ -140,38 +140,38 @@ class NewsController extends Controller
|
||||
if ($url == 'overzicht' && $request->get('dateStart', null) && $request->get('dateEnd', null)) {
|
||||
$url = 'datum/' . $request->get('dateStart', null) . '/' . $request->get('dateEnd', null);
|
||||
}
|
||||
$apiResult = $this->API('nieuws/' . $url . '?pagina=' . (int) max(1, $page) . ($total ? '&aantal=' . $total : ''));
|
||||
$apiResult = (object) $this->API('nieuws/' . $url . '?pagina=' . (int) max(1, $page) . ($total ? '&aantal=' . $total : ''));
|
||||
$news = [];
|
||||
foreach ($apiResult->news ?? [] as $newsItem) {
|
||||
$news[] = new \Model\NewsItem($newsItem);
|
||||
$news[] = new \Model\NewsItem((object) $newsItem);
|
||||
}
|
||||
|
||||
$populair = [];
|
||||
if ($title == null) {
|
||||
$total = 5;
|
||||
}
|
||||
$apiResult = $this->API('nieuws/populair?pagina=' . (int) max(
|
||||
$apiResult = (object) $this->API('nieuws/populair?pagina=' . (int) max(
|
||||
1,
|
||||
$page
|
||||
) . ($total ? '&aantal=' . $total : ''));
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$populair[] = new \Model\NewsItem($newsItem);
|
||||
$populair[] = new \Model\NewsItem((object) $newsItem);
|
||||
}
|
||||
|
||||
$podcast = null;
|
||||
$podcasts = [];
|
||||
if ($title == null) {
|
||||
$apiResult = $this->API('podcast/overzicht?aantal=3');
|
||||
$podcast = new \Model\Podcast($apiResult->podcasts[0]);
|
||||
$apiResult = (object) $this->API('podcast/overzicht?aantal=3');
|
||||
$podcast = new \Model\Podcast((object) $apiResult->podcasts[0]);
|
||||
foreach ($apiResult->podcasts as $_podcast) {
|
||||
$podcasts[] = new \Model\Podcast($_podcast);
|
||||
$podcasts[] = new \Model\Podcast((object) $_podcast);
|
||||
}
|
||||
}
|
||||
|
||||
$newsItems = [];
|
||||
$apiResult = $this->API('nieuws/overzicht?aantal=5');
|
||||
$apiResult = (object) $this->API('nieuws/overzicht?aantal=5');
|
||||
foreach ($apiResult->news as $_newsItem) {
|
||||
$newsItems[] = new \Model\NewsItem($_newsItem);
|
||||
$newsItems[] = new \Model\NewsItem((object) $_newsItem);
|
||||
}
|
||||
|
||||
return view($request->ajax() ? ($title == null ? 'partial/home_newslist_small' : 'partial/newslist_small') : ($title == null ? 'news' : 'newslist'), ['populair' => $populair, 'newsItems' => $newsItems, 'podcasts' => $podcasts, 'podcast' => $podcast, 'id' => $id, 'title' => $title, 'news' => $news, 'searchURL' => 'nieuws/zoeken']);
|
||||
@@ -179,7 +179,7 @@ class NewsController extends Controller
|
||||
|
||||
public function popular()
|
||||
{
|
||||
$apiResult = $this->API('nieuws/populair');
|
||||
$apiResult = (object) $this->API('nieuws/populair');
|
||||
$news = [];
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$news[] = new \Model\NewsItem($newsItem);
|
||||
@@ -190,7 +190,7 @@ class NewsController extends Controller
|
||||
|
||||
public function regionieuws()
|
||||
{
|
||||
$data = $this->API('nieuws/regionieuws.json');
|
||||
$data = (object) $this->API('nieuws/regionieuws.json');
|
||||
return view('listen', [
|
||||
'source' => $this->API_URL . 'nieuws/regionieuws.mp3',
|
||||
'title' => 'Regionieuws',
|
||||
|
||||
@@ -13,7 +13,7 @@ class PodcastController extends Controller
|
||||
$viewData = [];
|
||||
if((int)$programma > 0) {
|
||||
$action = 'programma/' . (int)$programma;
|
||||
$viewData['program'] = new \Model\Program($this->API('programma/details/' . (int)$programma));
|
||||
$viewData['program'] = new \Model\Program((object) $this->API('programma/details/' . (int)$programma));
|
||||
}
|
||||
|
||||
return $this->getPodcastList($request, $action, $viewData);
|
||||
@@ -22,7 +22,7 @@ class PodcastController extends Controller
|
||||
private function getPodcastList(Request $request, $action, $viewData = [])
|
||||
{
|
||||
$page = (int)$request->get('pagina', 1);
|
||||
$apiResult = $this->API('podcast/' . $action . '?pagina=' . (int)max(1, $page) . '&aantal=8');
|
||||
$apiResult = (object) $this->API('podcast/' . $action . '?pagina=' . (int)max(1, $page) . '&aantal=8');
|
||||
$podcasts = [];
|
||||
foreach($apiResult->podcasts as $podcast)
|
||||
{
|
||||
@@ -35,15 +35,15 @@ class PodcastController extends Controller
|
||||
public function podcast(Request $request, $id)
|
||||
{
|
||||
parent::registerView($request, 'podcast', $id);
|
||||
$apiResult = $this->API('podcast/details/' . (int)$id);
|
||||
$podcast = new \Model\Podcast($apiResult);
|
||||
$apiResult = (object) $this->API('podcast/details/' . (int)$id);
|
||||
$podcast = new \Model\Podcast((object) $apiResult);
|
||||
$podcasts = [];
|
||||
if($podcast->program) {
|
||||
$apiResult = $this->API('podcast/programma/' . (int)$podcast->program->id . '?pagina=1&aantal=5');
|
||||
$apiResult = (object) $this->API('podcast/programma/' . (int)$podcast->program->id . '?pagina=1&aantal=5');
|
||||
$podcasts = [];
|
||||
foreach($apiResult->podcasts as $p)
|
||||
{
|
||||
$podcasts[] = new \Model\Podcast($p);
|
||||
$podcasts[] = new \Model\Podcast((object) $p);
|
||||
}
|
||||
}
|
||||
return view('podcastitem', ['podcast' => $podcast, 'metadata' => $podcast->metadata, 'podcasts' => $podcasts, 'isPodcast' => true]);
|
||||
|
||||
@@ -11,7 +11,7 @@ class RadioController extends Controller
|
||||
{
|
||||
$start = $date ? (new \DateTime($date))->format('Y-m-d') : (new \DateTime("-2 day"))->format('Y-m-d');
|
||||
$end = $date ? (new \DateTime($date))->modify('+1 day')->format('Y-m-d') : (new \DateTime("+3 day"))->format('Y-m-d');
|
||||
$apiResult = $this->API('programma/schema/periode/' . $start . '/' . $end);
|
||||
$apiResult = (object) $this->API('programma/schema/periode/' . $start . '/' . $end);
|
||||
$schedule = [];
|
||||
foreach($apiResult->schedule as $program)
|
||||
{
|
||||
@@ -19,7 +19,7 @@ class RadioController extends Controller
|
||||
'starttime' => self::JsonToDateTime($program->start),
|
||||
'endtime' => self::JsonToDateTime($program->end),
|
||||
'shift' => 0,
|
||||
'program' => new \Model\Program($program->program)
|
||||
'program' => new \Model\Program((object) $program->program)
|
||||
];
|
||||
}
|
||||
|
||||
@@ -49,11 +49,11 @@ class RadioController extends Controller
|
||||
|
||||
public function program($id)
|
||||
{
|
||||
$apiResult = $this->API('programma/details/' . (int)$id);
|
||||
$apiResult = (object) $this->API('programma/details/' . (int)$id);
|
||||
if($apiResult == null) {
|
||||
return abort(404);
|
||||
}
|
||||
return view('radioprogram', ['program' => new \Model\Program($apiResult)]);
|
||||
return view('radioprogram', ['program' => new \Model\Program((object) $apiResult)]);
|
||||
}
|
||||
|
||||
public function podcast(Request $request, $id, $title = '')
|
||||
@@ -63,11 +63,11 @@ class RadioController extends Controller
|
||||
}
|
||||
|
||||
parent::registerView($request, 'podcast', $id);
|
||||
$apiResult = $this->API('podcast/details/' . (int)$id);
|
||||
$podcast = new \Model\Podcast($apiResult);
|
||||
$apiResult = (object) $this->API('podcast/details/' . (int)$id);
|
||||
$podcast = new \Model\Podcast((object) $apiResult);
|
||||
|
||||
$page = (int)$request->get('pagina', 1);
|
||||
$apiResult = $this->API('podcast/overzicht?pagina=' . (int)max(1, $page) . '&aantal=6');
|
||||
$apiResult = (object) $this->API('podcast/overzicht?pagina=' . (int)max(1, $page) . '&aantal=6');
|
||||
$podcasts = [];
|
||||
foreach($apiResult->podcasts as $_podcast)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ class RadioController extends Controller
|
||||
$viewData = [];
|
||||
if((int)$programma > 0) {
|
||||
$action = 'programma/' . (int)$programma;
|
||||
$viewData['program'] = new \Model\Program($this->API('programma/details/' . (int)$programma));
|
||||
$viewData['program'] = new \Model\Program((object) $this->API('programma/details/' . (int)$programma));
|
||||
}
|
||||
|
||||
return $this->getPodcastList($request, $action, array_merge($this->getSidebareData(), $viewData));
|
||||
@@ -99,13 +99,13 @@ class RadioController extends Controller
|
||||
$programs = [];
|
||||
$now = new \DateTimeImmutable('2 minutes ago');
|
||||
$page = (int)$request->get('pagina', 1);
|
||||
$apiResult = $this->API('programma/schema/recent?pagina=' . (int)max(1, $page) . '&aantal=12');
|
||||
$apiResult = (object) $this->API('programma/schema/recent?pagina=' . (int)max(1, $page) . '&aantal=12');
|
||||
foreach($apiResult->schedule as $item) {
|
||||
if(!$item->program->nonstop && !$item->program->rerun) {
|
||||
$item->start = self::JsonToDateTime($item->start);
|
||||
$item->end = self::JsonToDateTime($item->end);
|
||||
$item->current = $item->end >= $now;
|
||||
$item->program = new \Model\Program($item->program);
|
||||
$item->program = new \Model\Program((object) $item->program);
|
||||
$programs[] = $item;
|
||||
}
|
||||
}
|
||||
@@ -116,11 +116,11 @@ class RadioController extends Controller
|
||||
private function getPodcastList(Request $request, $action, $viewData = [])
|
||||
{
|
||||
$page = (int)$request->get('pagina', 1);
|
||||
$apiResult = $this->API('podcast/' . $action . '?pagina=' . (int)max(1, $page) . '&aantal=12');
|
||||
$apiResult = (object) $this->API('podcast/' . $action . '?pagina=' . (int)max(1, $page) . '&aantal=12');
|
||||
$podcasts = [];
|
||||
foreach($apiResult->podcasts as $podcast)
|
||||
{
|
||||
$podcasts[] = new \Model\Podcast($podcast);
|
||||
$podcasts[] = new \Model\Podcast((object) $podcast);
|
||||
}
|
||||
|
||||
return view($request->ajax() ? 'partial/podcastitems' : 'podcastlist', array_merge($viewData, ['id' => 'items-podcasts', 'podcasts' => $podcasts, 'searchURL' => 'gemist/zoeken', 'isPodcast' => false]));
|
||||
|
||||
@@ -61,11 +61,11 @@ class SpecialController extends Controller
|
||||
public function bart(Request $request)
|
||||
{
|
||||
$page = (int)$request->get('pagina', 1);
|
||||
$apiResult = $this->API('blog/overzicht/2019-07-01/2019-07-10?pagina=' . (int)max(1, $page));
|
||||
$apiResult = (object) $this->API('blog/overzicht/2019-07-01/2019-07-10?pagina=' . (int)max(1, $page));
|
||||
$blog = [];
|
||||
foreach($apiResult->items as $blogItem)
|
||||
{
|
||||
$blog[] = new \Model\NewsItem($blogItem);
|
||||
$blog[] = new \Model\NewsItem((object) $blogItem);
|
||||
}
|
||||
|
||||
return view($request->ajax() ? 'bloglistitems' : 'bloglist', ['title' => 'De Nacht van Bart - 6 juli 2019', 'items' => $blog]);
|
||||
|
||||
@@ -14,7 +14,23 @@ class Blog extends Model {
|
||||
public $url;
|
||||
|
||||
public function __construct($data, $images = null, $podcast = null) {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure id is a string, not an array
|
||||
if(is_array($this->id)) {
|
||||
$this->id = $this->id[0] ?? '';
|
||||
}
|
||||
|
||||
// Ensure title is a string, not an array
|
||||
if(is_array($this->title)) {
|
||||
$this->title = $this->title[0] ?? '';
|
||||
}
|
||||
|
||||
parent::ConvertToDateTime($this->start_date);
|
||||
parent::ConvertToDateTime($this->end_date);
|
||||
|
||||
|
||||
@@ -18,7 +18,23 @@ class CalendarEvent extends Model {
|
||||
public $tags;
|
||||
|
||||
public function __construct($data, $images = null, $podcast = null) {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure id is a string, not an array
|
||||
if(is_array($this->id)) {
|
||||
$this->id = $this->id[0] ?? '';
|
||||
}
|
||||
|
||||
// Ensure title is a string, not an array
|
||||
if(is_array($this->title)) {
|
||||
$this->title = $this->title[0] ?? '';
|
||||
}
|
||||
|
||||
parent::ConvertToDateTime($this->starts);
|
||||
parent::ConvertToDateTime($this->ends);
|
||||
|
||||
@@ -26,7 +42,7 @@ class CalendarEvent extends Model {
|
||||
if(isset($data->keywords)) {
|
||||
if(is_array($data->keywords)) {
|
||||
$this->keywords = $data->keywords;
|
||||
} else if(trim($data->keywords)) {
|
||||
} else if(trim((string) $data->keywords)) {
|
||||
$this->keywords = explode(' ', $data->keywords);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +63,7 @@ class CalendarEvent extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$this->url = "/agenda/{$this->id}/" . parent::url_slug($this->title);
|
||||
$this->url = "/agenda/{$this->id}/" . parent::url_slug($this->title ?? '');
|
||||
$this->metadata = (new MetaData())
|
||||
->set('title', $this->title)
|
||||
->set('description', strip_tags($this->excerpt()))
|
||||
|
||||
@@ -12,7 +12,23 @@ class JobOpening extends Model {
|
||||
public $url;
|
||||
|
||||
public function __construct($data, $images = null, $podcast = null) {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure id is a string, not an array
|
||||
if(is_array($this->id)) {
|
||||
$this->id = $this->id[0] ?? '';
|
||||
}
|
||||
|
||||
// Ensure title is a string, not an array
|
||||
if(is_array($this->title)) {
|
||||
$this->title = $this->title[0] ?? '';
|
||||
}
|
||||
|
||||
parent::ConvertToDateTime($this->starts);
|
||||
parent::ConvertToDateTime($this->ends);
|
||||
|
||||
@@ -20,7 +36,7 @@ class JobOpening extends Model {
|
||||
if(isset($data->keywords)) {
|
||||
if(is_array($data->keywords)) {
|
||||
$this->keywords = $data->keywords;
|
||||
} else if(trim($data->keywords)) {
|
||||
} else if(trim((string) $data->keywords)) {
|
||||
$this->keywords = explode(' ', $data->keywords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,18 @@ class KerkdienstInstance extends Model {
|
||||
public $start;
|
||||
|
||||
public function __construct($data) {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure name is a string, not an array
|
||||
if(is_array($this->name)) {
|
||||
$this->name = $this->name[0] ?? '';
|
||||
}
|
||||
|
||||
parent::ConvertToDateTime($this->start);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,18 @@ class NewsImage extends Model {
|
||||
public $url;
|
||||
|
||||
public function __construct($data, $urlPrefix = '/') {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure title is a string, not an array
|
||||
if(is_array($this->title)) {
|
||||
$this->title = $this->title[0] ?? '';
|
||||
}
|
||||
|
||||
// Deserialisatie van JSON heeft url in data,
|
||||
// lezen uit database heeft file en (als het goed is) urlPrefix
|
||||
if(isset($data->file)) {
|
||||
|
||||
+45
-11
@@ -29,7 +29,23 @@ class NewsItem extends Model {
|
||||
public $metadata;
|
||||
|
||||
public function __construct($data, $images = null, $podcast = null) {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure id is a string, not an array
|
||||
if(is_array($this->id)) {
|
||||
$this->id = $this->id[0] ?? '';
|
||||
}
|
||||
|
||||
// Ensure title is a string, not an array
|
||||
if(is_array($this->title)) {
|
||||
$this->title = $this->title[0] ?? '';
|
||||
}
|
||||
|
||||
parent::ConvertToDateTime($this->published);
|
||||
parent::ConvertToDateTime($this->edited);
|
||||
|
||||
@@ -43,9 +59,9 @@ class NewsItem extends Model {
|
||||
{
|
||||
if(is_object($data->source))
|
||||
{
|
||||
$this->source = new \Model\NewsSource($data->source->title, $data->source->url, $data->source->show);
|
||||
$this->source = new \Model\NewsSource($data->source->title ?? null, $data->source->url ?? null, $data->source->show ?? false);
|
||||
} else if($data->source) {
|
||||
$this->source = new \Model\NewsSource($data->source, $data->source_url, $data->showsource);
|
||||
$this->source = new \Model\NewsSource($data->source, $data->source_url ?? null, $data->showsource ?? false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,33 +75,45 @@ class NewsItem extends Model {
|
||||
if(isset($data->keywords)) {
|
||||
if(is_array($data->keywords) || is_object($data->keywords)) {
|
||||
$this->keywords = $data->keywords;
|
||||
} else if(trim($data->keywords)) {
|
||||
} else if(trim((string) $data->keywords)) {
|
||||
$this->keywords = explode(' ', $data->keywords);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data->region)) {
|
||||
if(is_object($data->region)) {
|
||||
$this->region = new \Model\NewsRegion($data->region->title, $data->region->slug);
|
||||
$this->region = new \Model\NewsRegion($data->region->title ?? null, $data->region->slug ?? null);
|
||||
} else {
|
||||
$this->region = new \Model\NewsRegion($data->region, $data->region_slug);
|
||||
$this->region = new \Model\NewsRegion($data->region, $data->region_slug ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data->theme)) {
|
||||
if(is_object($data->theme)) {
|
||||
$this->theme = new \Model\NewsRegion($data->theme->title, $data->theme->slug);
|
||||
$this->theme = new \Model\NewsRegion($data->theme->title ?? null, $data->theme->slug ?? null);
|
||||
} else {
|
||||
$this->theme = new \Model\NewsRegion($data->theme, $data->theme_slug);
|
||||
$this->theme = new \Model\NewsRegion($data->theme, $data->theme_slug ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data->tags)) {
|
||||
$this->tags = [];
|
||||
foreach($data->tags as $tag) {
|
||||
$this->theme = new \Model\NewsRegion($tag->titel, $tag->slug);
|
||||
if(is_object($tag)) {
|
||||
$this->tags[] = new \Model\NewsRegion($tag->titel ?? null, $tag->slug ?? null);
|
||||
} elseif(is_array($tag)) {
|
||||
$this->tags[] = new \Model\NewsRegion($tag['titel'] ?? null, $tag['slug'] ?? null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure content is iterable for views - convert string to empty array
|
||||
if(isset($this->content) && is_string($this->content)) {
|
||||
$this->content = [];
|
||||
} elseif(!isset($this->content)) {
|
||||
$this->content = [];
|
||||
}
|
||||
|
||||
$images = ($images != null) ? $images
|
||||
: (isset($data->images) ? $data->images : null);
|
||||
if($images) {
|
||||
@@ -95,7 +123,7 @@ class NewsItem extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$this->url = "/nieuws/{$this->id}/" . parent::url_slug($this->title);
|
||||
$this->url = "/nieuws/{$this->id}/" . parent::url_slug($this->title ?? '');
|
||||
$this->metadata = (new MetaData())
|
||||
->set('title', $this->title)
|
||||
->set('description', strip_tags($this->excerpt()))
|
||||
@@ -108,11 +136,17 @@ class NewsItem extends Model {
|
||||
}
|
||||
|
||||
public function excerpt() {
|
||||
// Handle case where content might be an array of blocks instead of a string
|
||||
if(is_array($this->content) || is_object($this->content)) {
|
||||
return '<p class="news-excerpt"></p>';
|
||||
}
|
||||
|
||||
$hasImages = isset($this->images) && count($this->images) > 0;
|
||||
$maxLength = $hasImages ? 200 : 500;
|
||||
$text = (string) $this->content;
|
||||
return '<p class="news-excerpt ' . ($hasImages ? 'short' : 'long') . '">' .
|
||||
substr($this->content, 0, $maxLength) .
|
||||
(strlen($this->content) > $maxLength ? '...' : '') .
|
||||
substr($text, 0, $maxLength) .
|
||||
(strlen($text) > $maxLength ? '...' : '') .
|
||||
'</p>';
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,13 @@ namespace Model;
|
||||
|
||||
class NewsRegion {
|
||||
public $title;
|
||||
public $titel; // Support both English and Dutch spelling
|
||||
public $slug;
|
||||
|
||||
public function __construct($title, $slug = null) {
|
||||
public function __construct($title = null, $slug = null) {
|
||||
$this->title = $title;
|
||||
$this->slug = $slug ? $slug : strtolower(str_replace(' ', '', $title));
|
||||
$this->titel = $title; // Also set titel for compatibility with API responses
|
||||
$this->slug = $slug ? $slug : ($title ? strtolower(str_replace(' ', '', $title)) : null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+32
-3
@@ -21,10 +21,31 @@ class Podcast extends Model {
|
||||
private $key;
|
||||
|
||||
public function __construct($data) {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure id is a string, not an array
|
||||
if(is_array($this->id)) {
|
||||
$this->id = $this->id[0] ?? '';
|
||||
}
|
||||
|
||||
// Ensure title is a string, not an array
|
||||
if(is_array($this->title)) {
|
||||
$this->title = $this->title[0] ?? '';
|
||||
}
|
||||
|
||||
// Ensure image is not an array from API
|
||||
if(is_array($this->image)) {
|
||||
$this->image = null;
|
||||
}
|
||||
|
||||
parent::ConvertToDateTime($this->created);
|
||||
|
||||
$this->url = '/' . $this->id . '/' . parent::url_slug($this->title) . '.mp3';
|
||||
$this->url = '/' . $this->id . '/' . parent::url_slug($this->title ?? '') . '.mp3';
|
||||
if($this->soundfilename) {
|
||||
// Only generate when not constructing from a JSON object
|
||||
$this->key = sha1($this->id . ':' . date('Y-m-d') . ':' . $this->soundfilename);
|
||||
@@ -36,7 +57,15 @@ class Podcast extends Model {
|
||||
if(is_object($data->program)) {
|
||||
$this->program = new \Model\Program($data->program);
|
||||
} elseif($data->program) {
|
||||
$this->program = new \Model\Program(['id' => $data->program, 'name' => $data->program_name, 'description' => $data->program_description]);
|
||||
$program_name = $data->program_name ?? null;
|
||||
if(is_array($program_name)) {
|
||||
$program_name = $program_name[0] ?? null;
|
||||
}
|
||||
$program_desc = $data->program_description ?? null;
|
||||
if(is_array($program_desc)) {
|
||||
$program_desc = $program_desc[0] ?? null;
|
||||
}
|
||||
$this->program = new \Model\Program((object) ['id' => $data->program, 'name' => $program_name, 'description' => $program_desc]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +73,7 @@ class Podcast extends Model {
|
||||
$imagedata = new \stdClass();
|
||||
$imagedata->id = $this->id;
|
||||
$imagedata->file = $data->imagefile;
|
||||
$imagedata->title = $data->imagecaption;
|
||||
$imagedata->title = $data->imagecaption ?? null;
|
||||
$this->image = new NewsImage($imagedata, '/img/podcast/');
|
||||
}
|
||||
|
||||
|
||||
+22
-3
@@ -18,10 +18,29 @@ class Program extends Model {
|
||||
public $next;
|
||||
|
||||
public function __construct($data) {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure id is a string, not an array
|
||||
if(is_array($this->id)) {
|
||||
$this->id = $this->id[0] ?? '';
|
||||
}
|
||||
|
||||
// Ensure name is a string, not an array
|
||||
if(is_array($this->name)) {
|
||||
$this->name = $this->name[0] ?? '';
|
||||
}
|
||||
|
||||
if(isset($data->suffix) && $data->suffix) {
|
||||
$this->name .= ' ' . $data->suffix;
|
||||
$suffix = $data->suffix;
|
||||
if(is_array($suffix)) {
|
||||
$suffix = $suffix[0] ?? '';
|
||||
}
|
||||
$this->name .= ' ' . $suffix;
|
||||
}
|
||||
|
||||
if($this->recent && $this->recent) {
|
||||
@@ -37,7 +56,7 @@ class Program extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data->email) && ($mailComma = strpos($data->email, ',')) !== false) {
|
||||
if(isset($data->email) && ($mailComma = strpos((string) $data->email, ',')) !== false) {
|
||||
$this->email = substr($data->email, 0, $mailComma);
|
||||
}
|
||||
|
||||
@@ -46,7 +65,7 @@ class Program extends Model {
|
||||
$this->rerun = $data->state == 3;
|
||||
}
|
||||
|
||||
$this->url = "/{$this->id}/" . parent::url_slug($this->name);
|
||||
$this->url = "/{$this->id}/" . parent::url_slug($this->name ?? '');
|
||||
}
|
||||
|
||||
public function isSpecial() {
|
||||
|
||||
@@ -6,5 +6,19 @@ class ProgramHost extends Model {
|
||||
public $id;
|
||||
public $name;
|
||||
public $email;
|
||||
|
||||
public function __construct($data) {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure name is a string, not an array
|
||||
if(is_array($this->name)) {
|
||||
$this->name = $this->name[0] ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,24 @@ class Track extends Model {
|
||||
public $isLayout;
|
||||
|
||||
public function __construct($data) {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure string fields are not arrays
|
||||
if(is_array($this->title)) {
|
||||
$this->title = $this->title[0] ?? '';
|
||||
}
|
||||
if(is_array($this->itemCode)) {
|
||||
$this->itemCode = $this->itemCode[0] ?? '';
|
||||
}
|
||||
if(is_array($this->artist)) {
|
||||
$this->artist = $this->artist[0] ?? '';
|
||||
}
|
||||
|
||||
parent::ConvertToDateTime($this->start);
|
||||
parent::ConvertToDateTime($this->ends);
|
||||
$isLayout = $this->isLayout();
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that gets used when writing
|
||||
| messages to the logs. The name specified in this channel must be listed
|
||||
| in the channels configuration array defined below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Out of
|
||||
| the box, Laravel uses the Monolog PHP logging library. This gives
|
||||
| you a variety of powerful log handlers / formatters to utilize.
|
||||
|
|
||||
| Available Drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => ['single'],
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => 14,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => 'Laravel Log',
|
||||
'emoji' => ':boom:',
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => \Monolog\Handler\SyslogUdpHandler::class,
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'facility' => LOG_USER,
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => \Monolog\Handler\StreamHandler::class,
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => LOG_USER,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => \Monolog\Handler\NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
Reference in new issue
Block a user