Skip to content

Commit 2e13740

Browse files
committed
refactor: migrated add FAQ page to controller (#3257)
1 parent b474047 commit 2e13740

Some content is hidden

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

58 files changed

+821
-639
lines changed

phpmyfaq/admin/assets/src/api/faqs.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@
1515

1616
export const fetchAllFaqsByCategory = async (categoryId, language, onlyInactive, onlyNew) => {
1717
try {
18-
const currentUrl = window.location.protocol + '//' + window.location.host + window.location.pathname;
19-
const url = new URL(`${currentUrl}api/faqs/${categoryId}/${language}`);
18+
let currentUrl = window.location.protocol + '//' + window.location.host;
19+
let pathname = window.location.pathname;
20+
21+
if (pathname.endsWith('/faqs')) {
22+
pathname = pathname.slice(0, -5);
23+
}
24+
25+
currentUrl += pathname;
26+
const url = new URL(`${currentUrl}/api/faqs/${categoryId}/${language}`);
2027
if (onlyInactive) {
2128
url.searchParams.set('only-inactive', onlyInactive);
2229
}

phpmyfaq/admin/faqs.editor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@
334334
'notifyUser' => $notifyUser,
335335
'notifyEmail' => $notifyEmail,
336336
'csrfToken' => Token::getInstance($container->get('session'))->getTokenString('edit-faq'),
337-
'ad_entry_theme' => Translation::get('ad_entry_theme'),
337+
'msgQuestion' => Translation::get('msgQuestion'),
338338
'msgNoHashAllowed' => Translation::get('msgNoHashAllowed'),
339339
'msgShowHelp' => Translation::get('msgShowHelp'),
340340
'ad_entry_content' => Translation::get('ad_entry_content'),
@@ -375,7 +375,7 @@
375375
'ad_entry_restricted_users' => Translation::get('ad_entry_restricted_users'),
376376
'userPermissionOptions' => $userHelper->getAllUserOptions($userPermission[0], true),
377377
'ad_entry_changelog' => Translation::get('ad_entry_changelog'),
378-
'ad_entry_date' => Translation::get('ad_entry_date'),
378+
'msgDate' => Translation::get('msgDate'),
379379
'ad_entry_changed' => Translation::get('ad_entry_changed'),
380380
'ad_admin_notes_hint' => Translation::get('ad_admin_notes_hint'),
381381
'ad_admin_notes' => Translation::get('ad_admin_notes'),
@@ -397,7 +397,7 @@
397397
'ad_entry_new_revision' => Translation::get('ad_entry_new_revision'),
398398
'ad_gen_yes' => Translation::get('ad_gen_yes'),
399399
'ad_gen_no' => Translation::get('ad_gen_no'),
400-
'ad_entry_sticky' => Translation::get('ad_entry_sticky'),
400+
'msgStickyFAQ' => Translation::get('msgStickyFAQ'),
401401
'ad_entry_allowComments' => Translation::get('ad_entry_allowComments'),
402402
'ad_entry_solution_id' => Translation::get('ad_entry_solution_id'),
403403
'nextSolutionId' => $faq->getNextSolutionId(),

phpmyfaq/admin/header.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
$secLevelEntries['content'] .= $adminHelper->addMenuEntry(
6969
PermissionType::FAQ_ADD->value,
7070
'editentry',
71-
'ad_entry_add'
71+
'ad_entry_add',
72+
'faq/add'
7273
);
7374
$secLevelEntries['content'] .= $adminHelper->addMenuEntry(
7475
'edit_faq+delete_faq',

phpmyfaq/admin/import.csv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
'msgImportRecordsColumnStructure' => Translation::get('msgImportRecordsColumnStructure'),
5454
'csrfToken' => Token::getInstance($container->get('session'))->getTokenString('importfaqs'),
5555
'is_active' => Translation::get('ad_entry_active'),
56-
'is_sticky' => Translation::get('ad_entry_sticky'),
56+
'is_sticky' => Translation::get('msgStickyFAQ'),
5757
'trueFalse' => Translation::get('msgCSVImportTrueOrFalse')
5858
];
5959

phpmyfaq/assets/templates/admin/content/faq.editor.twig

Lines changed: 467 additions & 454 deletions
Large diffs are not rendered by default.

phpmyfaq/assets/templates/admin/content/faq.overview.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@
6868
ID
6969
</th>
7070
<th class="align-middle">
71-
{{ msgQuestion }}
71+
{{ 'msgQuestion' | translate }}
7272
</th>
7373
<th class="align-middle">
74-
{{ msgDate }}
74+
{{ 'msgDate' | translate }}
7575
</th>
7676
<th class="align-middle">
77-
{{ msgSticky }}
77+
{{ 'msgStickyFAQ' | translate }}
7878
</th>
7979
<th class="align-middle">
8080
{{ 'msgActive' | translate }}

phpmyfaq/assets/templates/admin/dashboard.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<div class="col mr-2">
109109
<div class="text-xs font-weight-bold mb-1">
110110
<a class="text-white" href="?action=comments">
111-
{{ 'ad_start_comments' | translate }}
111+
{{ 'msgComments' | translate }}
112112
</a>
113113
</div>
114114
<div class="h5 mb-0 mr-3 font-weight-bold text-gray-800">{{ adminDashboardInfoNumComments }}</div>

phpmyfaq/faq.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
);
221221
$templateVars = [
222222
... $templateVars,
223-
'numberOfComments' => sprintf('%d %s', $numComments[$faqId] ?? 0, Translation::get('ad_start_comments')),
223+
'numberOfComments' => sprintf('%d %s', $numComments[$faqId] ?? 0, Translation::get('msgComments')),
224224
'writeCommentMsg' => $commentMessage
225225
];
226226
}

phpmyfaq/src/admin-routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@
123123
'controller' => [ConfigurationController::class, 'index'],
124124
'methods' => 'GET'
125125
],
126+
'admin.faq.add' => [
127+
'path' => '/faq/add',
128+
'controller' => [FaqController::class, 'add'],
129+
'methods' => 'GET'
130+
],
126131
'admin.faqs' => [
127132
'path' => '/faqs',
128133
'controller' => [FaqController::class, 'index'],

phpmyfaq/src/phpMyFAQ/Controller/Administration/AbstractAdministrationController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,14 @@ protected function getHeader(Request $request): array
8181
$secLevelEntries['content'] .= $adminHelper->addMenuEntry(
8282
PermissionType::FAQ_ADD->value,
8383
'editentry',
84-
'ad_entry_add'
84+
'ad_entry_add',
85+
'faq/add'
8586
);
8687
$secLevelEntries['content'] .= $adminHelper->addMenuEntry(
8788
'edit_faq+delete_faq',
8889
'faqs-overview',
89-
'msgHeaderFAQOverview'
90+
'msgHeaderFAQOverview',
91+
'faqs'
9092
);
9193
$secLevelEntries['content'] .= $adminHelper->addMenuEntry(
9294
PermissionType::FAQ_EDIT->value,

0 commit comments

Comments
 (0)