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