2020-08-18 18:31:28 +02:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 11:52:11 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-08-18 18:31:28 +02:00
|
|
|
/**
|
2022-02-19 17:06:11 +01:00
|
|
|
* @copyright 2020 Ad Aures
|
2020-08-18 18:31:28 +02:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
use App\Models\PageModel;
|
2023-08-27 15:26:06 +02:00
|
|
|
use Config\App;
|
2020-08-18 18:31:28 +02:00
|
|
|
|
2021-05-19 18:35:13 +02:00
|
|
|
if (! function_exists('render_page_links')) {
|
2021-05-06 16:00:48 +02:00
|
|
|
/**
|
|
|
|
* Returns instance pages as links inside nav tag
|
|
|
|
*
|
|
|
|
* @return string html pages navigation
|
|
|
|
*/
|
2023-07-26 19:19:40 +02:00
|
|
|
function render_page_links(string $class = null, string $podcastHandle = null): string
|
2021-05-06 16:00:48 +02:00
|
|
|
{
|
|
|
|
$pages = (new PageModel())->findAll();
|
|
|
|
$links = anchor(route_to('home'), lang('Common.home'), [
|
2021-11-05 15:36:34 +01:00
|
|
|
'class' => 'px-2 py-1 underline hover:no-underline focus:ring-accent',
|
2020-08-18 18:31:28 +02:00
|
|
|
]);
|
2023-07-26 19:19:40 +02:00
|
|
|
if ($podcastHandle !== null) {
|
|
|
|
$links .= anchor(route_to('podcast-links', $podcastHandle), lang('Podcast.links'), [
|
|
|
|
'class' => 'px-2 py-1 underline hover:no-underline focus:ring-accent',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2021-05-06 16:00:48 +02:00
|
|
|
$links .= anchor(route_to('credits'), lang('Person.credits'), [
|
2021-11-05 15:36:34 +01:00
|
|
|
'class' => 'px-2 py-1 underline hover:no-underline focus:ring-accent',
|
2021-05-06 16:00:48 +02:00
|
|
|
]);
|
2021-11-12 17:31:35 +01:00
|
|
|
$links .= anchor(route_to('map'), lang('Page.map.title'), [
|
2021-11-05 15:36:34 +01:00
|
|
|
'class' => 'px-2 py-1 underline hover:no-underline focus:ring-accent',
|
2021-09-17 17:50:55 +02:00
|
|
|
]);
|
2021-05-06 16:00:48 +02:00
|
|
|
foreach ($pages as $page) {
|
2022-03-04 15:33:48 +01:00
|
|
|
$links .= anchor($page->link, esc($page->title), [
|
2021-11-05 15:36:34 +01:00
|
|
|
'class' => 'px-2 py-1 underline hover:no-underline focus:ring-accent',
|
2021-05-06 16:00:48 +02:00
|
|
|
]);
|
|
|
|
}
|
2020-08-18 18:31:28 +02:00
|
|
|
|
2022-07-07 12:08:04 +02:00
|
|
|
// if set in .env, add legal notice link at the end of page links
|
2023-08-27 15:26:06 +02:00
|
|
|
if (config(App::class)->legalNoticeURL !== null) {
|
|
|
|
$links .= anchor(config(App::class)->legalNoticeURL, lang('Common.legal_notice'), [
|
2023-06-12 16:47:38 +02:00
|
|
|
'class' => 'px-2 py-1 underline hover:no-underline focus:ring-accent',
|
2022-07-07 12:08:04 +02:00
|
|
|
'target' => '_blank',
|
2023-06-12 16:47:38 +02:00
|
|
|
'rel' => 'noopener noreferrer',
|
2022-07-07 12:08:04 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2021-05-06 16:00:48 +02:00
|
|
|
return '<nav class="' . $class . '">' . $links . '</nav>';
|
|
|
|
}
|
2020-08-18 18:31:28 +02:00
|
|
|
}
|