Loading app/Config/Routes.php +6 −0 Original line number Diff line number Diff line Loading @@ -781,6 +781,12 @@ $routes->group('@(:podcastName)', function ($routes): void { $routes->get('/credits', 'CreditsController', [ 'as' => 'credits', ]); $routes->get('/map', 'MapMarkerController', [ 'as' => 'map', ]); $routes->get('/episodes-markers', 'MapMarkerController::getEpisodesMarkers', [ 'as' => 'episodes-markers', ]); $routes->get('/pages/(:slug)', 'PageController/$1', [ 'as' => 'page', ]); Loading app/Controllers/Admin/PodcastImportController.php +4 −4 Original line number Diff line number Diff line Loading @@ -124,8 +124,8 @@ class PodcastImportController extends BaseController if (property_exists($nsPodcast, 'location') && $nsPodcast->location !== null) { $location = new Location( (string) $nsPodcast->location, (string) $nsPodcast->location->attributes()['geo'], (string) $nsPodcast->location->attributes()['osm'], $nsPodcast->location->attributes()['geo'] === null ? null : (string) $nsPodcast->location->attributes()['geo'], $nsPodcast->location->attributes()['osm'] === null ? null : (string) $nsPodcast->location->attributes()['osm'], ); } if (property_exists($nsPodcast, 'guid') && $nsPodcast->guid !== null) { Loading Loading @@ -338,8 +338,8 @@ class PodcastImportController extends BaseController if (property_exists($nsPodcast, 'location') && $nsPodcast->location !== null) { $location = new Location( (string) $nsPodcast->location, (string) $nsPodcast->location->attributes()['geo'], (string) $nsPodcast->location->attributes()['osm'], $nsPodcast->location->attributes()['geo'] === null ? null : (string) $nsPodcast->location->attributes()['geo'], $nsPodcast->location->attributes()['osm'] === null ? null : (string) $nsPodcast->location->attributes()['osm'], ); } Loading app/Controllers/MapMarkerController.php 0 → 100644 +59 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); /** * @copyright 2020 Podlibre * @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3 * @link https://castopod.org/ */ namespace App\Controllers; use App\Entities\Page; use App\Models\EpisodeModel; use CodeIgniter\HTTP\ResponseInterface; class MapMarkerController extends BaseController { public function index(): string { $locale = service('request') ->getLocale(); $cacheName = "page_map_{$locale}"; if (! ($found = cache($cacheName))) { $found = view('map', [], [ 'cache' => DECADE, 'cache_name' => $cacheName, ]); } return $found; } public function getEpisodesMarkers(): ResponseInterface { $cacheName = 'episodes_markers'; if (! ($found = cache($cacheName))) { $episodes = (new EpisodeModel())->where('location_geo is not', null) ->findAll(); $found = []; foreach ($episodes as $episode) { $found[] = [ 'latitude' => $episode->location->latitude, 'longitude' => $episode->location->longitude, 'location_name' => $episode->location->name, 'location_url' => $episode->location->url, 'episode_link' => $episode->link, 'podcast_link' => $episode->podcast->link, 'image_path' => $episode->image->thumbnail_url, 'podcast_title' => $episode->podcast->title, 'episode_title' => $episode->title, ]; } // The page cache is set to a decade so it is deleted manually upon episode update cache() ->save($cacheName, $found, DECADE); } return $this->response->setJSON($found); } } app/Entities/Location.php +12 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ use Config\Services; * @property string $name * @property string|null $geo * @property string|null $osm * @property double|null $latitude * @property double|null $longitude */ class Location extends Entity { Loading @@ -34,12 +36,21 @@ class Location extends Entity public function __construct( protected string $name, protected ?string $geo = null, protected ?string $osm = null protected ?string $osm = null, ) { $latitude = null; $longitude = null; if ($geo !== null) { $geoArray = explode(',', substr($geo, 4)); $latitude = floatval($geoArray[0]); $longitude = floatval($geoArray[1]); } parent::__construct([ 'name' => $name, 'geo' => $geo, 'osm' => $osm, 'latitude' => $latitude, 'longitude' => $longitude, ]); } Loading app/Helpers/page_helper.php +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ if (! function_exists('render_page_links')) { $links .= anchor(route_to('credits'), lang('Person.credits'), [ 'class' => 'px-2 underline hover:no-underline', ]); $links .= anchor(route_to('map'), lang('Page.map'), [ 'class' => 'px-2 underline hover:no-underline', ]); foreach ($pages as $page) { $links .= anchor($page->link, $page->title, [ 'class' => 'px-2 underline hover:no-underline', Loading Loading
app/Config/Routes.php +6 −0 Original line number Diff line number Diff line Loading @@ -781,6 +781,12 @@ $routes->group('@(:podcastName)', function ($routes): void { $routes->get('/credits', 'CreditsController', [ 'as' => 'credits', ]); $routes->get('/map', 'MapMarkerController', [ 'as' => 'map', ]); $routes->get('/episodes-markers', 'MapMarkerController::getEpisodesMarkers', [ 'as' => 'episodes-markers', ]); $routes->get('/pages/(:slug)', 'PageController/$1', [ 'as' => 'page', ]); Loading
app/Controllers/Admin/PodcastImportController.php +4 −4 Original line number Diff line number Diff line Loading @@ -124,8 +124,8 @@ class PodcastImportController extends BaseController if (property_exists($nsPodcast, 'location') && $nsPodcast->location !== null) { $location = new Location( (string) $nsPodcast->location, (string) $nsPodcast->location->attributes()['geo'], (string) $nsPodcast->location->attributes()['osm'], $nsPodcast->location->attributes()['geo'] === null ? null : (string) $nsPodcast->location->attributes()['geo'], $nsPodcast->location->attributes()['osm'] === null ? null : (string) $nsPodcast->location->attributes()['osm'], ); } if (property_exists($nsPodcast, 'guid') && $nsPodcast->guid !== null) { Loading Loading @@ -338,8 +338,8 @@ class PodcastImportController extends BaseController if (property_exists($nsPodcast, 'location') && $nsPodcast->location !== null) { $location = new Location( (string) $nsPodcast->location, (string) $nsPodcast->location->attributes()['geo'], (string) $nsPodcast->location->attributes()['osm'], $nsPodcast->location->attributes()['geo'] === null ? null : (string) $nsPodcast->location->attributes()['geo'], $nsPodcast->location->attributes()['osm'] === null ? null : (string) $nsPodcast->location->attributes()['osm'], ); } Loading
app/Controllers/MapMarkerController.php 0 → 100644 +59 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); /** * @copyright 2020 Podlibre * @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3 * @link https://castopod.org/ */ namespace App\Controllers; use App\Entities\Page; use App\Models\EpisodeModel; use CodeIgniter\HTTP\ResponseInterface; class MapMarkerController extends BaseController { public function index(): string { $locale = service('request') ->getLocale(); $cacheName = "page_map_{$locale}"; if (! ($found = cache($cacheName))) { $found = view('map', [], [ 'cache' => DECADE, 'cache_name' => $cacheName, ]); } return $found; } public function getEpisodesMarkers(): ResponseInterface { $cacheName = 'episodes_markers'; if (! ($found = cache($cacheName))) { $episodes = (new EpisodeModel())->where('location_geo is not', null) ->findAll(); $found = []; foreach ($episodes as $episode) { $found[] = [ 'latitude' => $episode->location->latitude, 'longitude' => $episode->location->longitude, 'location_name' => $episode->location->name, 'location_url' => $episode->location->url, 'episode_link' => $episode->link, 'podcast_link' => $episode->podcast->link, 'image_path' => $episode->image->thumbnail_url, 'podcast_title' => $episode->podcast->title, 'episode_title' => $episode->title, ]; } // The page cache is set to a decade so it is deleted manually upon episode update cache() ->save($cacheName, $found, DECADE); } return $this->response->setJSON($found); } }
app/Entities/Location.php +12 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ use Config\Services; * @property string $name * @property string|null $geo * @property string|null $osm * @property double|null $latitude * @property double|null $longitude */ class Location extends Entity { Loading @@ -34,12 +36,21 @@ class Location extends Entity public function __construct( protected string $name, protected ?string $geo = null, protected ?string $osm = null protected ?string $osm = null, ) { $latitude = null; $longitude = null; if ($geo !== null) { $geoArray = explode(',', substr($geo, 4)); $latitude = floatval($geoArray[0]); $longitude = floatval($geoArray[1]); } parent::__construct([ 'name' => $name, 'geo' => $geo, 'osm' => $osm, 'latitude' => $latitude, 'longitude' => $longitude, ]); } Loading
app/Helpers/page_helper.php +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ if (! function_exists('render_page_links')) { $links .= anchor(route_to('credits'), lang('Person.credits'), [ 'class' => 'px-2 underline hover:no-underline', ]); $links .= anchor(route_to('map'), lang('Page.map'), [ 'class' => 'px-2 underline hover:no-underline', ]); foreach ($pages as $page) { $links .= anchor($page->link, $page->title, [ 'class' => 'px-2 underline hover:no-underline', Loading