Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensive url changes to enable app to work in a subdirectory #336

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Consent/Views/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</x-page-head>

<x-admin-box>
<form action="/admin/settings/consent" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/consent') ?>" method="post">
<?= csrf_field() ?>

<fieldset>
Expand Down
2 changes: 1 addition & 1 deletion src/Email/Views/email_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</x-page-head>

<x-admin-box>
<form action="/admin/settings/email" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/email') ?>" method="post">
<?= csrf_field() ?>

<fieldset>
Expand Down
4 changes: 2 additions & 2 deletions src/Groups/Views/_tabs.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<ul class="nav nav-tabs nav-fill" style="margin-bottom: -2px;">
<li class="nav-item">
<a class="nav-link <?php if ($tab === 'basics') : ?> active <?php endif ?>"
href="<?= isset($group) ? '/' . ADMIN_AREA . '/settings/groups/' . $group : '#' ?>">
href="<?= isset($group) ? site_url(ADMIN_AREA . '/settings/groups/' . $group) : '#' ?>">
Group Details
</a>
</li>
<?php if (auth()->user()->can('groups.edit')) : ?>
<li class="nav-item">
<a class="nav-link <?php if ($tab === 'permissions') : ?> active <?php endif ?>"
href="/<?= ADMIN_AREA . '/settings/groups/' . $group . '/permissions' ?>">
href="<?= site_url(ADMIN_AREA . '/settings/groups/' . $group . '/permissions') ?>">
Permissions
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion src/Groups/Views/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<?php $this->section('main') ?>
<x-page-head>
<a href="/<?= ADMIN_AREA ?>/settings/groups" class="back">&larr; Groups</a>
<a href="<?= site_url(ADMIN_AREA . '/settings/groups') ?>" class="back">&larr; Groups</a>
<h2>Edit Groups &amp; Permissions</h2>
</x-page-head>

Expand Down
2 changes: 1 addition & 1 deletion src/Groups/Views/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<?php foreach ($groups as $alias => $group) : ?>
<tr>
<td>
<a href="/<?= ADMIN_AREA ?>/settings/groups/<?= $alias ?>">
<a href="<?= site_url(ADMIN_AREA . '/settings/groups/' . $alias) ?>">
<?= esc($group['title']) ?>
</a>
</td>
Expand Down
2 changes: 1 addition & 1 deletion src/Groups/Views/permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<?php $this->section('main') ?>
<x-page-head>
<a href="/<?= ADMIN_AREA ?>/settings/groups" class="back">&larr; Groups</a>
<a href="<?= site_url(ADMIN_AREA . '/settings/groups/') ?>" class="back">&larr; Groups</a>
<h2>Edit Groups &amp; Permissions</h2>
</x-page-head>

Expand Down
4 changes: 2 additions & 2 deletions src/Menus/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MenuItem

public function __construct(?array $data = null)
{
if (! is_array($data)) {
if (!is_array($data)) {
return;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ public function setUrl(string $url)
*/
public function setNamedRoute(string $name)
{
$this->url = route_to($name);
$this->url = url_to($name);

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Settings/Views/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</x-page-head>

<x-admin-box>
<form action="/admin/settings/general" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/general') ?>" method="post">
<?= csrf_field() ?>

<fieldset>
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<fieldset>
<legend>PHP Info</legend>

<a href="/<?= ADMIN_AREA ?>/tools/php-info" class="btn btn-primary" target="_blank">View PHP Info</a>
<a href="<?= site_url(ADMIN_AREA . '/tools/php-info') ?>" class="btn btn-primary" target="_blank">View PHP Info</a>
</fieldset>

<fieldset>
Expand Down
2 changes: 1 addition & 1 deletion src/Users/Views/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<?php $this->section('main') ?>
<x-page-head>
<a href="/<?= ADMIN_AREA ?>/users" class="back">&larr; Users</a>
<a href="<?= site_url(ADMIN_AREA . '/users') ?>" class="back">&larr; Users</a>
<h2><?= isset($user) ? 'Edit User' : 'New User' ?></h2>
</x-page-head>

Expand Down
2 changes: 1 addition & 1 deletion src/Users/Views/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<?php if (auth()->user()->can('users.create')): ?>
<div class="col-auto">
<a href="<?= route_to('user-new') ?>" class="btn btn-primary">New User</a>
<a href="<?= url_to('user-new') ?>" class="btn btn-primary">New User</a>
</div>
<?php endif ?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Users/Views/permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<?php $this->section('main') ?>
<x-page-head>
<a href="/<?= ADMIN_AREA ?>/users" class="back">&larr; Users</a>
<a href="<?= site_url(ADMIN_AREA . '/users') ?>" class="back">&larr; Users</a>
<h2>Edit User</h2>
</x-page-head>

Expand Down
2 changes: 1 addition & 1 deletion src/Users/Views/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<?php $this->section('main') ?>
<x-page-head>
<a href="/<?= ADMIN_AREA ?>/users" class="back">&larr; Users</a>
<a href="<?= site_url(ADMIN_AREA . '/users') ?>" class="back">&larr; Users</a>
<h2>Edit User</h2>
</x-page-head>

Expand Down
2 changes: 1 addition & 1 deletion src/Users/Views/user_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</x-page-head>

<x-admin-box>
<form action="/admin/settings/users" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/users') ?>" method="post">
<?= csrf_field() ?>

<fieldset>
Expand Down
6 changes: 3 additions & 3 deletions src/Views/Auth/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="card-body">
<h5 class="card-title mb-5"><?= lang('Auth.login') ?></h5>

<form action="<?= route_to('login') ?>" method="post">
<form action="<?= url_to('login') ?>" method="post">
<?= csrf_field() ?>

<!-- Email -->
Expand All @@ -37,11 +37,11 @@
</div>

<?php if (setting('Auth.allowMagicLinkLogins')) : ?>
<p class="text-center"><?= lang('Auth.forgotPassword') ?> <a href="<?= route_to('magic-link') ?>"><?= lang('Auth.useMagicLink') ?></a></p>
<p class="text-center"><?= lang('Auth.forgotPassword') ?> <a href="<?= url_to('magic-link') ?>"><?= lang('Auth.useMagicLink') ?></a></p>
<?php endif ?>

<?php if (setting('Auth.allowRegistration')) : ?>
<p class="text-center"><?= lang('Auth.needAccount') ?> <a href="<?= route_to('register') ?>"><?= lang('Auth.register') ?></a></p>
<p class="text-center"><?= lang('Auth.needAccount') ?> <a href="<?= url_to('register') ?>"><?= lang('Auth.register') ?></a></p>
<?php endif ?>

</form>
Expand Down
2 changes: 1 addition & 1 deletion src/Views/Auth/magic_link_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="card-body">
<h5 class="card-title mb-4"><?= lang('Auth.useMagicLink') ?></h5>

<form action="<?= route_to('magic-link') ?>" method="post">
<form action="<?= url_to('magic-link') ?>" method="post">
<?= csrf_field() ?>

<p class="text-muted mb-4"><?= lang('Bonfire.magicLinkInfo') ?></p>
Expand Down
6 changes: 3 additions & 3 deletions src/Views/Auth/register.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?= $this->extend('master') ?>
<?php $this->extend('master'); ?>

<?= $this->section('title') ?><?= lang('Auth.register') ?> <?= $this->endSection() ?>

Expand All @@ -9,7 +9,7 @@
<div class="card-body">
<h5 class="card-title mb-5"><?= lang('Auth.register') ?></h5>

<form action="<?= route_to('register') ?>" method="post">
<form action="<?= url_to('register') ?>" method="post">
<?= csrf_field() ?>

<!-- Email -->
Expand Down Expand Up @@ -59,7 +59,7 @@
<button type="submit" class="btn btn-primary btn-block btn-lg"><?= lang('Auth.register') ?></button>
</div>

<p class="text-center"><?= lang('Auth.haveAccount') ?> <a href="<?= route_to('login') ?>"><?= lang('Auth.login') ?></a></p>
<p class="text-center"><?= lang('Auth.haveAccount') ?> <a href="<?= url_to('login') ?>"><?= lang('Auth.login') ?></a></p>

</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Views/Cells/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
<?php if (setting('Stats.stats_showLink')) : ?>
<div class="widget-stats-link">
<a href="<?= $widget->url() ?>"><?= lang('Widgets.viewDetail') ?> <i class="fa fa-arrow-alt-circle-right"></i></a>
<a href="<?= site_url($widget->url()) ?>"><?= lang('Widgets.viewDetail') ?> <i class="fa fa-arrow-alt-circle-right"></i></a>
</div>
<?php endif?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Views/_barchart.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<x-admin-box>

<form action="/<?= ADMIN_AREA ?>/settings/widgets" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/widgets') ?>" method="post">
<?= csrf_field() ?>
<input type="hidden" id="widget" name="widget" value="<?=$tab?>">

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Views/_doughnutchart.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<x-admin-box>

<form action="/<?= ADMIN_AREA ?>/settings/widgets" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/widgets') ?>" method="post">
<?= csrf_field() ?>
<input type="hidden" id="widget" name="widget" value="<?=$tab?>">

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Views/_linechart.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<x-admin-box>

<form action="/<?= ADMIN_AREA ?>/settings/widgets" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/widgets') ?>" method="post">
<?= csrf_field() ?>
<input type="hidden" id="widget" name="widget" value="<?=$tab?>">

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Views/_piechart.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<x-admin-box>

<form action="/<?= ADMIN_AREA ?>/settings/widgets" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/widgets') ?>" method="post">
<?= csrf_field() ?>
<input type="hidden" id="widget" name="widget" value="<?=$tab?>">

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Views/_polarareachart.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<x-admin-box>

<form action="/<?= ADMIN_AREA ?>/settings/widgets" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/widgets') ?>" method="post">
<?= csrf_field() ?>
<input type="hidden" id="widget" name="widget" value="<?=$tab?>">

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Views/_stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<x-admin-box>

<form action="/<?= ADMIN_AREA ?>/settings/widgets" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/widgets') ?>" method="post">
<?= csrf_field() ?>
<input type="hidden" id="widget" name="widget" value="<?=$tab?>">

Expand Down
14 changes: 7 additions & 7 deletions src/Widgets/Views/_tabs.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
<ul class="nav nav-tabs nav-fill" style="margin-bottom: -2px;">
<li class="nav-item">
<a class="nav-link <?php if ($tab === 'basics') : ?> active <?php endif ?>"
href="/<?= ADMIN_AREA . '/settings/widgets' ?>">
href="<?= site_url(ADMIN_AREA . '/settings/widgets') ?>">
Widgets
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($tab === 'stats') : ?> active <?php endif ?>"
href="/<?= ADMIN_AREA . '/settings/widgets/stats' ?>">
href="<?= site_url(ADMIN_AREA . '/settings/widgets/stats') ?>">
Statistics Widget
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($tab === 'linechart') : ?> active <?php endif ?>"
href="/<?= ADMIN_AREA . '/settings/widgets/linechart' ?>">
href="<?= site_url(ADMIN_AREA . '/settings/widgets/linechart') ?>">
Line Chart
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($tab === 'barchart') : ?> active <?php endif ?>"
href="/<?= ADMIN_AREA . '/settings/widgets/barchart' ?>">
href="<?= site_url(ADMIN_AREA . '/settings/widgets/barchart') ?>">
Bar Chart
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($tab === 'doughnutchart') : ?> active <?php endif ?>"
href="/<?= ADMIN_AREA . '/settings/widgets/doughnutchart' ?>">
href="<?= site_url(ADMIN_AREA . '/settings/widgets/doughnutchart') ?>">
Doughnut Chart
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($tab === 'piechart') : ?> active <?php endif ?>"
href="/<?= ADMIN_AREA . '/settings/widgets/piechart' ?>">
href="<?= site_url(ADMIN_AREA . '/settings/widgets/piechart') ?>">
Pie Chart
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($tab === 'polarareachart') : ?> active <?php endif ?>"
href="/<?= ADMIN_AREA . '/settings/widgets/polarareachart' ?>">
href="<?= site_url(ADMIN_AREA . '/settings/widgets/polarareachart') ?>">
Polar Area Chart
</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions src/Widgets/Views/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<x-admin-box>

<form action="/<?= ADMIN_AREA ?>/settings/widgets" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/widgets') ?>" method="post">
<?= csrf_field() ?>
<fieldset>

Expand All @@ -37,7 +37,7 @@
</div>
</form>

<form action="/<?= ADMIN_AREA ?>/settings/widgetsReset" method="post">
<form action="<?= site_url(ADMIN_AREA . '/settings/widgetsReset') ?>" method="post">
<?= csrf_field() ?>
<div class="text-end px-5 py-3">
<input type="submit" value="Reset all settings of all widgets to their default values" class="btn btn-danger btn-lg">
Expand Down
2 changes: 1 addition & 1 deletion tests/Menus/MenuItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function testWithNamedRoutes()
$item = new MenuItem();
$item->setNamedRoute('home');

$this->assertSame('/home-sweet-home', $item->url());
$this->assertSame(site_url('/home-sweet-home'), $item->url());
}

public function testPropertyGetter()
Expand Down
4 changes: 2 additions & 2 deletions themes/Admin/Components/sidebar.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a class="px-3 d-block fs-3 text-light text-decoration-none me-0" href="/<?= ADMIN_AREA ?>">
<a class="px-3 d-block fs-3 text-light text-decoration-none me-0" href="<?= site_url(ADMIN_AREA) ?>">
<div class="site-stamp rounded d-inline-flex align-content-center justify-content-center">
<?= substr(setting('Site.siteName') ?? 'bonfire', 0, 1) ?>
</div>
Expand All @@ -9,7 +9,7 @@
<!-- Dashboard -->
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link <?= url_is('/' . ADMIN_AREA) ? 'active' : '' ?>" href="/<?= ADMIN_AREA ?>" title="<?= lang('Bonfire.dashboard') ?>">
<a class="nav-link <?= url_is(ADMIN_AREA) ? 'active' : '' ?>" href="<?= site_url(ADMIN_AREA) ?>" title="<?= lang('Bonfire.dashboard') ?>">
<i class="fas fa-home"></i>
<span><?= lang('Bonfire.dashboard') ?></span>
</a>
Expand Down
6 changes: 3 additions & 3 deletions themes/Admin/_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</button>

<!-- Search Form -->
<form action="<?= route_to('search') ?>" method="post" class="flex-grow-1">
<form action="<?= url_to('search') ?>" method="post" class="flex-grow-1">
<?= csrf_field() ?>

<input class="form-control form-control bg-light w-100" type="text" name="search_term" placeholder="<?= lang('Bonfire.search') ?>" aria-label="<?= lang('Bonfire.search'); ?>"
Expand All @@ -20,9 +20,9 @@
<?= auth()->user()->renderAvatar(32) ?>
</a>
<ul class="dropdown-menu dropdown-menu-end text-small" aria-labelledby="dropdownUser1" style="">
<li><a class="dropdown-item" href="/<?= ADMIN_AREA ?>/users/<?= auth()->id() ?>"><?= lang('Bonfire.myAccount') ?></a></li>
<li><a class="dropdown-item" href="<?= site_url(ADMIN_AREA . '/users/' . auth()->id()) ?>"><?= lang('Bonfire.myAccount') ?></a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="<?= route_to('logout') ?>"><?= lang('Bonfire.signOut') ?></a></li>
<li><a class="dropdown-item" href="<?= site_url('logout') ?>"><?= lang('Bonfire.signOut') ?></a></li>
</ul>
</div>
<?php endif ?>
Expand Down
2 changes: 1 addition & 1 deletion themes/Auth/master.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</aside>

<header class="navbar navbar-light bg-none flex-md-nowrap p-0 shadow-sm">
<a class="px-3 d-block fs-3 text-dark text-decoration-none col-md-3 col-lg-2 me-0" href="/<?= ADMIN_AREA ?>">
<a class="px-3 d-block fs-3 text-dark text-decoration-none col-md-3 col-lg-2 me-0" href="<?= site_url(ADMIN_AREA) ?>">
<?= setting('Site.siteName') ?? 'Bonfire' ?>
</a>
</header>
Expand Down