Most pages are now styled.
Small changes to existing pages. Changes to base layout style.
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\View;
|
||||
@@ -15,95 +15,103 @@ class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
protected $API_URL;
|
||||
protected $API_URL;
|
||||
|
||||
private function getDataFromFileAndConvert($file, $path, $class, $maxItems = 0)
|
||||
{
|
||||
$data = json_decode(Storage::disk('local')->get($file));
|
||||
foreach($path as $subobject) { $data = $data->$subobject; }
|
||||
$items = [];
|
||||
foreach($data as $item_data)
|
||||
{
|
||||
$items[] = new $class($item_data);
|
||||
if($maxItems && count($items) == $maxItems) { break; }
|
||||
}
|
||||
private function getDataFromFileAndConvert($file, $path, $class, $maxItems = 0)
|
||||
{
|
||||
$data = json_decode(Storage::disk('local')->get($file));
|
||||
foreach ($path as $subobject) {
|
||||
$data = $data->$subobject;
|
||||
}
|
||||
$items = [];
|
||||
foreach ($data as $item_data) {
|
||||
$items[] = new $class($item_data);
|
||||
if ($maxItems && count($items) == $maxItems) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
View::share('apiUrl', $this->API_URL = env('API_URL', 'http://api.6fm.nl/'));
|
||||
View::share('imgBase', env('IMAGE_BASE_URL', '/'));
|
||||
View::share('apiUrl', $this->API_URL = env('API_URL', 'http://api.6fm.nl/'));
|
||||
View::share('imgBase', env('IMAGE_BASE_URL', '/'));
|
||||
|
||||
$blogs = $this->getDataFromFileAndConvert('blogs.json', [], '\Model\Blog', 1);
|
||||
$activeBlog = count($blogs) && $blogs[0]->is_active ? $blogs[0] : null;
|
||||
View::share('activeBlog', $activeBlog);
|
||||
$blogs = $this->getDataFromFileAndConvert('blogs.json', [], '\Model\Blog', 1);
|
||||
$activeBlog = count($blogs) && $blogs[0]->is_active ? $blogs[0] : null;
|
||||
View::share('activeBlog', $activeBlog);
|
||||
|
||||
|
||||
//View::share('onAir', file_get_contents(url('onair')));
|
||||
View::composer('widgets.laatstenieuws', function($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('laatste_nieuws.json', ['news'], '\Model\NewsItem'));
|
||||
});
|
||||
View::composer('widgets.populairnieuws', function($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('populair_nieuws.json', [], '\Model\NewsItem'));
|
||||
});
|
||||
View::composer('widgets.nustraks', function($view) {
|
||||
$data = json_decode(Storage::disk('local')->get('nu_straks.json'))->schedule;
|
||||
$programs = [];
|
||||
foreach($data as $item_data)
|
||||
{
|
||||
$programs[] = $program = new \Model\Program($item_data->program);
|
||||
$program->start = new \DateTimeImmutable($item_data->start->date, new \DateTimeZone($item_data->start->timezone));
|
||||
$program->end = new \DateTimeImmutable($item_data->end->date, new \DateTimeZone($item_data->end->timezone));
|
||||
}
|
||||
//View::share('onAir', file_get_contents(url('onair')));
|
||||
View::composer('widgets.laatstenieuws', function ($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('laatste_nieuws.json', ['news'], '\Model\NewsItem'));
|
||||
});
|
||||
View::composer('widgets.populairnieuws', function ($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('populair_nieuws.json', [], '\Model\NewsItem'));
|
||||
});
|
||||
View::composer('widgets.nustraks', function ($view) {
|
||||
$data = json_decode(Storage::disk('local')->get('nu_straks.json'))->schedule;
|
||||
$programs = [];
|
||||
foreach ($data as $item_data) {
|
||||
$programs[] = $program = new \Model\Program($item_data->program);
|
||||
$program->start = new \DateTimeImmutable($item_data->start->date,
|
||||
new \DateTimeZone($item_data->start->timezone));
|
||||
$program->end = new \DateTimeImmutable($item_data->end->date,
|
||||
new \DateTimeZone($item_data->end->timezone));
|
||||
}
|
||||
|
||||
// Need a bit of slack here, otherwise the current program may show up
|
||||
$now = new \DateTimeImmutable('2 minutes ago');
|
||||
$data = json_decode(Storage::disk('local')->get('zojuist.json'))->schedule;
|
||||
$i = 0;
|
||||
foreach(array_reverse($data) as $item_data)
|
||||
{
|
||||
$recent = $program = new \Model\Program($item_data->program);
|
||||
$recent->start = new \DateTimeImmutable($item_data->start->date, new \DateTimeZone($item_data->start->timezone));
|
||||
$recent->end = new \DateTimeImmutable($item_data->end->date, new \DateTimeZone($item_data->end->timezone));
|
||||
if(($recent->end < $now) && (!$recent->nonstop) && (!$recent->rerun)) {
|
||||
$view->with('recent', $recent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Need a bit of slack here, otherwise the current program may show up
|
||||
$now = new \DateTimeImmutable('2 minutes ago');
|
||||
$data = json_decode(Storage::disk('local')->get('zojuist.json'))->schedule;
|
||||
$i = 0;
|
||||
foreach (array_reverse($data) as $item_data) {
|
||||
$recent = $program = new \Model\Program($item_data->program);
|
||||
$recent->start = new \DateTimeImmutable($item_data->start->date,
|
||||
new \DateTimeZone($item_data->start->timezone));
|
||||
$recent->end = new \DateTimeImmutable($item_data->end->date,
|
||||
new \DateTimeZone($item_data->end->timezone));
|
||||
if (($recent->end < $now) && (!$recent->nonstop) && (!$recent->rerun)) {
|
||||
$view->with('recent', $recent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$view->with('data', $programs);
|
||||
});
|
||||
View::composer('widgets.laatstepodcasts', function($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('laatste_podcasts.json', ['podcasts'], '\Model\Podcast'));
|
||||
});
|
||||
View::composer('widgets.regioagenda', function($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('regioagenda.json', [], '\Model\CalendarEvent'));
|
||||
});
|
||||
View::composer('widgets.beelden', function($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('beelden.json', ['items'], '\Model\NewsItem'));
|
||||
});
|
||||
View::composer('widgets.menu', function($view) {
|
||||
$view->with('news', $this->getDataFromFileAndConvert('laatste_nieuws.json', ['news'], '\Model\NewsItem'))
|
||||
->with('popular', $this->getDataFromFileAndConvert('populair_nieuws.json', [], '\Model\NewsItem', 3))
|
||||
->with('podcasts', $this->getDataFromFileAndConvert('laatste_podcasts.json', ['podcasts'], '\Model\Podcast'));
|
||||
});
|
||||
$view->with('data', $programs);
|
||||
});
|
||||
View::composer('widgets.laatstepodcasts', function ($view) {
|
||||
$view->with('data',
|
||||
$this->getDataFromFileAndConvert('laatste_podcasts.json', ['podcasts'], '\Model\Podcast'));
|
||||
});
|
||||
View::composer('widgets.regioagenda', function ($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('regioagenda.json', [], '\Model\CalendarEvent'));
|
||||
});
|
||||
View::composer('widgets.beelden', function ($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('beelden.json', ['items'], '\Model\NewsItem'));
|
||||
});
|
||||
View::composer('widgets.menu', function ($view) {
|
||||
$view->with('news', $this->getDataFromFileAndConvert('laatste_nieuws.json', ['news'], '\Model\NewsItem'))
|
||||
->with('popular', $this->getDataFromFileAndConvert('populair_nieuws.json', [], '\Model\NewsItem', 3))
|
||||
->with('podcasts',
|
||||
$this->getDataFromFileAndConvert('laatste_podcasts.json', ['podcasts'], '\Model\Podcast'));
|
||||
});
|
||||
}
|
||||
|
||||
protected function registerView(Request $request, $type, $id)
|
||||
{
|
||||
if(config('app.env') == 'local') {
|
||||
return;
|
||||
}
|
||||
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)
|
||||
@@ -113,10 +121,10 @@ class Controller extends BaseController
|
||||
// }
|
||||
// return [];
|
||||
|
||||
$arrContextOptions= [
|
||||
$arrContextOptions = [
|
||||
'ssl' => [
|
||||
"verify_peer"=>false,
|
||||
"verify_peer_name"=>false,
|
||||
"verify_peer" => false,
|
||||
"verify_peer_name" => false,
|
||||
],
|
||||
];
|
||||
|
||||
@@ -128,12 +136,16 @@ class Controller extends BaseController
|
||||
return new \DateTime($obj->date, new \DateTimeZone($obj->timezone));
|
||||
}
|
||||
|
||||
public function __call($method, $arguments) {
|
||||
if(substr($method, 0, 5) == 'view_') {
|
||||
$view = substr($method, 5);
|
||||
if(view()->exists($view)) { return view($view, $this->getSidebareData()); }
|
||||
}
|
||||
return abort(404);
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
if (substr($method, 0, 5) == 'view_') {
|
||||
$view = substr($method, 5);
|
||||
if (view()->exists($view)) {
|
||||
return view($view);
|
||||
}
|
||||
}
|
||||
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
public function getSidebareData()
|
||||
|
||||
@@ -2,36 +2,34 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use \Model\NewsItem;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function show()
|
||||
public function show(Request $request)
|
||||
{
|
||||
$apiResult = $this->API('nieuws/overzicht?aantal=12');
|
||||
$total = 10;
|
||||
$page = (int)$request->get('pagina', 1);
|
||||
$apiResult = $this->API('nieuws/overzicht?pagina=' . (int)max(1, $page) . '&aantal=' . $total);
|
||||
$news = [];
|
||||
foreach($apiResult->news as $newsItem)
|
||||
{
|
||||
$news[] = new \Model\NewsItem($newsItem);
|
||||
}
|
||||
|
||||
$apiResult = $this->API('programma/schema/nustraks');
|
||||
$comingUp = [];
|
||||
foreach($apiResult->schedule as $program)
|
||||
{
|
||||
$comingUp[] = [
|
||||
'start' => self::JsonToDateTime($program->start),
|
||||
'end' => self::JsonToDateTime($program->end),
|
||||
'program' => new \Model\Program($program->program)
|
||||
];
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$news[] = new \Model\NewsItem($newsItem);
|
||||
}
|
||||
|
||||
$populair = [];
|
||||
$apiResult = $this->API('nieuws/populair?pagina=' . (int)max(1, $page) . '&aantal=' . $total);
|
||||
foreach ($apiResult as $newsItem) {
|
||||
$populair[] = new \Model\NewsItem($newsItem);
|
||||
}
|
||||
|
||||
$apiResult = $this->API('podcast/overzicht?aantal=20');
|
||||
$podcasts = [];
|
||||
foreach($apiResult->podcasts as $podcast) {
|
||||
$podcasts[] = new \Model\Podcast($podcast);
|
||||
$apiResult = $this->API('podcast/overzicht?aantal=3');
|
||||
$podcast = new \Model\Podcast($apiResult->podcasts[0]);
|
||||
foreach ($apiResult->podcasts as $_podcast) {
|
||||
$podcasts[] = new \Model\Podcast($_podcast);
|
||||
}
|
||||
|
||||
return view('home', ['news' => $news, 'podcasts' => $podcasts, 'comingUp' => $comingUp]);
|
||||
return view('home', ['populair' => $populair, 'podcasts' => $podcasts, 'podcast' => $podcast, 'title' => 'Home', 'news' => $news, 'searchURL' => 'nieuws/zoeken']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class NewsController extends Controller
|
||||
|
||||
|
||||
|
||||
return view('newsitem', array_merge($this->getSidebareData(), ['news' => $newsItem, 'metadata' => $newsItem->metadata]));
|
||||
return view('newsitem', array_merge($this->getSidebareData(), ['news' => $newsItem, 'metadata' => $newsItem->metadata, 'searchURL' => 'nieuws/zoeken']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,15 +137,13 @@ class NewsController extends Controller
|
||||
}
|
||||
|
||||
$populair = [];
|
||||
if ($url == 'overzicht') {
|
||||
if ($title == null) {
|
||||
$total = 5;
|
||||
}
|
||||
$apiResult = $this->API('nieuws/populair?pagina=' . (int)max(1,
|
||||
$page) . ($total ? '&aantal=' . $total : ''));
|
||||
foreach ($apiResult as $newsItem) {
|
||||
$populair[] = new \Model\NewsItem($newsItem);
|
||||
}
|
||||
if ($title == null) {
|
||||
$total = 5;
|
||||
}
|
||||
$apiResult = $this->API('nieuws/populair?pagina=' . (int)max(1,
|
||||
$page) . ($total ? '&aantal=' . $total : ''));
|
||||
foreach ($apiResult as $newsItem) {
|
||||
$populair[] = new \Model\NewsItem($newsItem);
|
||||
}
|
||||
|
||||
$podcast = null;
|
||||
@@ -158,7 +156,13 @@ class NewsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return view($request->ajax() ? ($title == null ? 'partial/home_newslist_small' : 'partial/newslist_small') : ($title == null ? 'home' : 'newslist'), ['populair' => $populair, 'podcasts' => $podcasts, 'podcast' => $podcast, 'id' => $id, 'title' => $title, 'news' => $news, 'searchURL' => 'nieuws/zoeken']);
|
||||
$newsItems = [];
|
||||
$apiResult = $this->API('nieuws/overzicht?aantal=5');
|
||||
foreach ($apiResult->news as $_newsItem) {
|
||||
$newsItems[] = new \Model\NewsItem($_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']);
|
||||
}
|
||||
|
||||
public function popular()
|
||||
|
||||
@@ -13,21 +13,21 @@ class StreamController extends Controller
|
||||
{
|
||||
return view('listen', [
|
||||
'source' => self::$STREAM_URL . 'mp3live',
|
||||
'title' => 'Luister live',
|
||||
'title' => 'Luister live',
|
||||
'content' => 'de live-uitzending van NH Gooi.',
|
||||
'isStream' => true ]);
|
||||
}
|
||||
|
||||
|
||||
public function livetv()
|
||||
{
|
||||
return view('watch', ['stream' => 'https://rrr.sz.xlcdn.com/?account=nhnieuws&file=nhgooi&type=live&service=wowza&protocol=https&output=playlist.m3u8']);
|
||||
return view('watch', ['title' => 'Kijk NH Gooi Tv', 'stream' => 'https://rrr.sz.xlcdn.com/?account=nhnieuws&file=nhgooi&type=live&service=wowza&protocol=https&output=playlist.m3u8']);
|
||||
// return view('watch', ['stream' => 'https://stream.nhgooi.nl:81/tv']);
|
||||
}
|
||||
|
||||
public function studio()
|
||||
{
|
||||
// return view('watch', ['stream' => 'https://stream.nhgooi.nl:81/live/studio']);
|
||||
return view('watch', ['stream' => 'https://studiocam.nhgooi.nl/studiocam/live/index.m3u8']);
|
||||
return view('watch', ['title' => 'Kijk NH Gooi Tv Studio', 'stream' => 'https://studiocam.nhgooi.nl/studiocam/live/index.m3u8']);
|
||||
}
|
||||
|
||||
public function podcast(Request $request, $id)
|
||||
@@ -39,10 +39,10 @@ class StreamController extends Controller
|
||||
}
|
||||
|
||||
return view('listen', [
|
||||
'source' => $this->API_URL . 'podcast/download' . $apiResult->url . '?auth=' . $podcast->auth,
|
||||
'title' => $podcast->title,
|
||||
'source' => $this->API_URL . 'podcast/download' . $apiResult->url . '?auth=' . $podcast->auth,
|
||||
'title' => $podcast->title,
|
||||
'content' => $podcast->title,
|
||||
'isStream' => false,
|
||||
'isStream' => false,
|
||||
'canDownload' => true ]);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class StreamController extends Controller
|
||||
$url = '/luister/programma/' . $date->format('Y/m/d/H') . '/' . $duration . '/' . $i;
|
||||
$hours[$offset == $i ? '#' : $url] = 'Uur ' . ($i + 1) . ' (' . $other->format('H') . ':00)';
|
||||
}
|
||||
|
||||
|
||||
return view('listen', [
|
||||
'source' => $this->API_URL . 'programma/download/' . $current->format('Y/m/d/H') . '/1',
|
||||
'tabs' => $hours,
|
||||
@@ -69,8 +69,8 @@ class StreamController extends Controller
|
||||
public function gemeenteraad(Request $request) {
|
||||
return view('listen', [
|
||||
'source' => self::$STREAM_URL . 'gemhuizen',
|
||||
'title' => 'Gemeenteraad Huizen',
|
||||
'content' => 'de openbare vergadering van de gemeenteraad Huizen',
|
||||
'title' => 'Gemeenteraad Huizen',
|
||||
'content' => 'de openbare vergadering van de gemeenteraad Huizen',
|
||||
'isStream' => true,
|
||||
'canDownload' => false ]);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class StreamController extends Controller
|
||||
public function kerkdienst(Request $request) {
|
||||
return view('listen', [
|
||||
'source' => $this->API_URL . 'kerkdienst/download',
|
||||
'title' => 'Kerkdienst gemist',
|
||||
'title' => 'Kerkdienst gemist',
|
||||
'content' => 'de kerkdienst van afgelopen zondag',
|
||||
'isStream' => false,
|
||||
'canDownload' => true ]);
|
||||
|
||||
Reference in New Issue
Block a user