Skip to content

Commit f323e82

Browse files
committed
refactor: migrated the first bunch of admin config pages (#3257)
1 parent 29c6ae9 commit f323e82

File tree

137 files changed

+2739
-1850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+2739
-1850
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This is a log of major user-visible changes in each phpMyFAQ release.
99
### phpMyFAQ v4.1.0-dev - unreleased
1010

1111
- added configuration to edit robots.txt (Thorsten)
12+
- WIP: added Symfony Routing for administration backend (Thorsten)
1213
- removed Webpack, now using Vite (Thorsten)
1314
- migrated from Jest to vitest (Thorsten)
1415

nginx.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ server {
128128
# Administration API
129129
rewrite admin/api/(.*) /admin/api/index.php last;
130130

131+
# Administration pages
132+
rewrite admin/(attachments|configuration|elasticsearch|instance/edit|instance/update|instances|stopwords|system|update) /admin/front.php last;
133+
131134
# REST API v3.0 and v3.1
132135
rewrite ^api/v3\.[01]/(.*) /api/index.php last;
133136

phpmyfaq/.htaccess

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ Header set Access-Control-Allow-Headers "Content-Type, Authorization"
142142
RewriteRule ^update/(.*) update/index.php [L,QSA]
143143
# Administration API
144144
RewriteRule ^admin/api/(.*) admin/api/index.php [L,QSA]
145+
# Administration pages
146+
RewriteRule ^admin/(attachments|configuration|elasticsearch|instance/edit|instance/update|instances|stopwords|system|update) admin/front.php [L,QSA]
145147
# Private APIs
146148
RewriteRule ^api/(autocomplete|bookmark/delete|bookmark/create|user/data/update|user/password/update|user/request-removal|user/remove-twofactor|contact|voting|register|captcha|share|comment/create|faq/create|question/create|webauthn/prepare|webauthn/register|webauthn/prepare-login|webauthn/login) api/index.php [L,QSA]
147149
# Setup APIs

phpmyfaq/404.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
$faqSession->setCurrentUser($user);
3131
$faqSession->userTracking(SessionActionType::NOT_FOUND->value, 0);
3232

33-
$twig = new TwigWrapper(PMF_ROOT_DIR . '/assets/templates/' . TwigWrapper::getTemplateSetName());
33+
$twig = new TwigWrapper(PMF_ROOT_DIR . '/assets/templates/');
3434
$twigTemplate = $twig->loadTemplate('./404.twig');

phpmyfaq/add.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
$category = new Category($faqConfig);
9292
$categories = $category->getAllCategoryIds();
9393

94-
$twig = new TwigWrapper(PMF_ROOT_DIR . '/assets/templates/' . TwigWrapper::getTemplateSetName());
94+
$twig = new TwigWrapper(PMF_ROOT_DIR . '/assets/templates/');
9595
$twigTemplate = $twig->loadTemplate('./add.twig');
9696

9797
// Twig template variables

phpmyfaq/admin/api/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
echo $e->getMessage();
3535
}
3636

37-
$routes = include PMF_SRC_DIR . '/admin-routes.php';
37+
$routes = include PMF_SRC_DIR . '/admin-api-routes.php';
3838

3939
$app = new Application($container);
4040
try {

phpmyfaq/admin/assets/src/configuration/upgrade.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const handleCheckForUpdates = () => {
6060
if (checkUpdateButton) {
6161
checkUpdateButton.addEventListener('click', (event) => {
6262
event.preventDefault();
63-
fetch(window.location.pathname + 'api/update-check', {
63+
fetch('./api/update-check', {
6464
method: 'POST',
6565
headers: {
6666
Accept: 'application/json, text/plain, */*',
@@ -118,7 +118,7 @@ export const handleCheckForUpdates = () => {
118118
version = versionLastChecked.innerText;
119119
}
120120

121-
fetch(window.location.pathname + `api/download-package/${version}`, {
121+
fetch(`./api/download-package/${version}`, {
122122
method: 'POST',
123123
headers: {
124124
Accept: 'application/json, text/plain, */*',
@@ -158,7 +158,7 @@ export const handleCheckForUpdates = () => {
158158
if (extractButton) {
159159
extractButton.addEventListener('click', (event) => {
160160
event.preventDefault();
161-
fetch(window.location.pathname + 'api/extract-package', {
161+
fetch('./api/extract-package', {
162162
method: 'POST',
163163
headers: {
164164
Accept: 'application/json, text/plain, */*',
@@ -202,7 +202,7 @@ export const handleCheckForUpdates = () => {
202202
};
203203

204204
const createTemporaryBackup = async () => {
205-
await fetch(window.location.pathname + 'api/create-temporary-backup', {
205+
await fetch('./api/create-temporary-backup', {
206206
method: 'POST',
207207
headers: {
208208
Accept: 'application/json, text/plain, */*',
@@ -241,7 +241,7 @@ const createTemporaryBackup = async () => {
241241
};
242242

243243
const installPackage = async () => {
244-
await fetch(window.location.pathname + 'api/install-package', {
244+
await fetch('./api/install-package', {
245245
method: 'POST',
246246
headers: {
247247
Accept: 'application/json, text/plain, */*',
@@ -282,7 +282,7 @@ const installPackage = async () => {
282282
};
283283

284284
const updateDatabase = async () => {
285-
await fetch(window.location.pathname + 'api/update-database', {
285+
await fetch('./api/update-database', {
286286
method: 'POST',
287287
headers: {
288288
Accept: 'application/json, text/plain, */*',

phpmyfaq/admin/attachments.php

Lines changed: 0 additions & 84 deletions
This file was deleted.

phpmyfaq/admin/backup.import.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
Token::getInstance($container->get('session'))->verifyToken('restore', $csrfToken)
4444
) {
4545
$twig = new TwigWrapper(PMF_ROOT_DIR . '/assets/templates');
46-
$template = $twig->loadTemplate('./admin/backup/import.twig');
46+
$template = $twig->loadTemplate('@admin/backup/import.twig');
4747

4848
$templateVars = [
4949
'adminHeaderRestore' => Translation::get('ad_csv_rest')

phpmyfaq/admin/backup.main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
if ($user->perm->hasPermission($user->getUserId(), PermissionType::BACKUP->value)) {
3434
$twig = new TwigWrapper(PMF_ROOT_DIR . '/assets/templates');
35-
$template = $twig->loadTemplate('./admin/backup/main.twig');
35+
$template = $twig->loadTemplate('@admin/backup/main.twig');
3636

3737
$templateVars = [
3838
'adminHeaderBackup' => Translation::get('ad_csv_backup'),

0 commit comments

Comments
 (0)