Skip to content

Commit

Permalink
refactor: migrated copy FAQ page to controller (#3257)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Dec 26, 2024
1 parent 121610d commit 8374f85
Show file tree
Hide file tree
Showing 55 changed files with 344 additions and 292 deletions.
14 changes: 7 additions & 7 deletions phpmyfaq/admin/faqs.editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@

// Header
if (0 !== $faqData['id'] && 'copyentry' !== $action) {
$currentRevision = sprintf('%s 1.%d', Translation::get('ad_entry_revision'), $selectedRevisionId);
$currentRevision = sprintf('%s 1.%d', Translation::get('msgRevision'), $selectedRevisionId);

$faqUrl = sprintf(
'%sindex.php?action=faq&cat=%s&id=%d&artlang=%s',
Expand Down Expand Up @@ -299,7 +299,7 @@
'ad_changerev' => Translation::get('ad_changerev'),
'revisions' => $revisions,
'selectedRevisionId' => $selectedRevisionId,
'ad_entry_revision' => Translation::get('ad_entry_revision'),
'msgRevision' => Translation::get('msgRevision'),
];
}

Expand Down Expand Up @@ -355,14 +355,14 @@
'attachments' => $attList,
'msgAddAttachment' => Translation::get('msgAddAttachment'),
'msgTags' => Translation::get('msgTags'),
'ad_entry_keywords' => Translation::get('ad_entry_keywords'),
'ad_entry_author' => Translation::get('ad_entry_author'),
'msgKeywords' => Translation::get('msgKeywords'),
'msgAuthor' => Translation::get('msgAuthor'),
'msgEmail' => Translation::get('msgEmail'),
'msgSeoCenter' => Translation::get('msgSeoCenter'),
'msgSerp' => Translation::get('msgSerp'),
'msgSerpTitle' => Translation::get('msgSerpTitle'),
'ad_entry_grouppermission' => Translation::get('ad_entry_grouppermission'),
'ad_entry_all_groups' => Translation::get('ad_entry_all_groups'),
'msgGroupPermissions' => Translation::get('msgGroupPermissions'),
'msgAccessAllGroups' => Translation::get('msgAccessAllGroups'),
'allGroups' => $allGroups,
'restrictedGroups' => $restrictedGroups,
'ad_entry_restricted_groups' => Translation::get('ad_entry_restricted_groups'),
Expand All @@ -381,7 +381,7 @@
'ad_admin_notes' => Translation::get('ad_admin_notes'),
'ad_entry_changelog_history' => Translation::get('ad_entry_changelog_history'),
'changelogs' => $changelog->getByFaqId($faqData['id']),
'ad_entry_revision' => Translation::get('ad_entry_revision'),
'msgRevision' => Translation::get('msgRevision'),
'ad_gen_reset' => Translation::get('ad_gen_reset'),
'ad_entry_save' => Translation::get('ad_entry_save'),
'msgUpdateFaqDate' => Translation::get('msgUpdateFaqDate'),
Expand Down
4 changes: 2 additions & 2 deletions phpmyfaq/admin/import.csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
'categoryId' => Translation::get('ad_categ_categ'),
'question' => Translation::get('ad_entry_topic'),
'answer' => Translation::get('msgAnswer'),
'keywords' => Translation::get('ad_entry_keywords'),
'author' => Translation::get('ad_entry_author'),
'keywords' => Translation::get('msgKeywords'),
'author' => Translation::get('msgAuthor'),
'email' => Translation::get('msgEmail'),
'languageCode' => Translation::get('msgLanguageCode'),
'seperateWithCommas' => Translation::get('msgSeperateWithCommas'),
Expand Down
4 changes: 2 additions & 2 deletions phpmyfaq/assets/templates/admin/content/category.add.twig
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@
{% if permLevel != 'basic' %}
<div class="row mb-2">
<label class="col-lg-2 col-form-label" for="restricted_groups">
{{ ad_entry_grouppermission }}
{{ 'msgGroupPermissions' | translate }}
</label>
<div class="col-lg-4">
<div class="form-check">
<input type="radio" name="grouppermission" id="grouppermission_all" value="all"
class="form-check-input" checked>
<label class="form-check-label" for="grouppermission_all">
{{ ad_entry_all_groups }}
{{ 'msgAccessAllGroups' | translate }}
</label>
</div>
<div class="form-check">
Expand Down
4 changes: 2 additions & 2 deletions phpmyfaq/assets/templates/admin/content/category.edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@

<div class="row mb-2">
<label class="col-lg-2 col-form-label" for="restricted_groups">
{{ categoryGroupPermissionLabel }}
{{ 'msgGroupPermissions' | translate }}
</label>
<div class="col-lg-4">
<div class="form-check">
<input type="radio" name="grouppermission" id="grouppermission_all" value="all"
class="form-check-input" {{ allGroups }}>
<label class="form-check-label" for="grouppermission_all">
{{ categoryGroupPermissionAllLabel }}
{{ 'msgAccessAllGroups' | translate }}
</label>
</div>
<div class="form-check">
Expand Down
21 changes: 13 additions & 8 deletions phpmyfaq/assets/templates/admin/content/faq.editor.twig
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
{% for currentRevision in revisions %}
{% set selected = selectedRevisionId == faqData['revision_id'] %}
<option value="{{ currentRevision['revision_id'] }}" {{ selected == true ? ' selected' }}>
{{ ad_entry_revision }} 1.{{ currentRevision['revision_id'] }}:
{{ 'msgRevision' | translate }} 1.{{ currentRevision['revision_id'] }}:
{{ currentRevision['updated'] | createIsoDate }} - {{ currentRevision['author'] }}
</option>
{% endfor %}
Expand Down Expand Up @@ -230,18 +230,21 @@

<!-- Keywords -->
<div class="row mb-2">
<label class="col-lg-2 col-form-label" for="keywords">{{ ad_entry_keywords }}</label>
<label class="col-lg-2 col-form-label" for="keywords">
{{ 'msgKeywords' | translate }}
</label>
<div class="col-lg-10">
<input type="text" name="keywords" id="keywords" maxlength="255" class="form-control"
autocomplete="off"
value="{{ faqData['keywords'] }}">
autocomplete="off" value="{{ faqData['keywords'] }}">
<small id="keywordsHelp" class="form-text visually-hidden">{{ 'msgShowHelp' | translate }}</small>
</div>
</div>

<!-- Author -->
<div class="row mb-2">
<label class="col-lg-2 col-form-label" for="author">{{ ad_entry_author }}</label>
<label class="col-lg-2 col-form-label" for="author">
{{ 'msgAuthor' | translate }}
</label>
<div class="col-lg-10">
<input type="text" name="author" id="author" value="{{ faqData['author'] }}" class="form-control">
</div>
Expand Down Expand Up @@ -289,13 +292,15 @@
{% if not isBasicPermission %}
<div class="form-group">
<div class="row">
<div class="col-3 col-form-label pt-0">{{ ad_entry_grouppermission }}</div>
<div class="col-3 col-form-label pt-0">
{{ 'msgGroupPermissions' | translate }}
</div>
<div class="col-6">
<div class="form-check">
<input type="radio" id="allgroups" name="grouppermission" value="all" class="form-check-input"
{{ allGroups ? 'checked' : '' }}>
<label class="form-check-label" for="allgroups">
{{ ad_entry_all_groups }}
{{ 'msgAccessAllGroups' | translate }}
</label>
</div>
<div class="form-check">
Expand Down Expand Up @@ -396,7 +401,7 @@
</div>
<div class="d-flex align-items-center me-3">
<i aria-hidden="true" class="bi bi-archive me-1"></i>
{{ ad_entry_revision }} 1.{{ changelog['revision_id'] }}
{{ 'msgRevision' | translate }} 1.{{ changelog['revision_id'] }}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<thead>
<tr>
<th></th>
<th>{{ msgAuthor }}</th>
<th>{{ 'msgAuthor' | translate }}</th>
<th>{{ 'msgQuestion' | translate }}</th>
<th colspan="2">{{ msgVisibility }}?</th>
</tr>
Expand Down
5 changes: 5 additions & 0 deletions phpmyfaq/src/admin-routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@
'controller' => [FaqController::class, 'add'],
'methods' => 'GET'
],
'admin.faq.copy' => [
'path' => '/faq/copy/{faqId}/{faqLanguage}',
'controller' => [FaqController::class, 'copy'],
'methods' => 'GET'
],
'admin.faq.edit' => [
'path' => '/faq/edit/{faqId}/{faqLanguage}',
'controller' => [FaqController::class, 'edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ protected function getHeader(Request $request): array
case 'admin.content.sticky-faqs':
case 'admin.comments':
case 'admin.faq.add':
case 'admin.faq.copy':
case 'admin.faq.edit':
case 'admin.faqs':
case 'admin.glossary':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,7 @@ public function edit(Request $request): Response
'categoryOwnerOptions' => $userHelper->getAllUserOptions($categoryData->getUserId()),
'isMediumPermission' => $this->configuration->get('security.permLevel') !== 'basic',
'allGroupsOptions' => $allGroupsOptions,
'categoryGroupPermissionLabel' => Translation::get('ad_entry_grouppermission'),
'allGroups' => $allGroups ? 'checked' : '',
'categoryGroupPermissionAllLabel' => Translation::get('ad_entry_all_groups'),
'restrictedGroups' => $restrictedGroups ? 'checked' : '',
'restrictedGroupsLabel' => Translation::get('ad_entry_restricted_groups'),
'restrictedGroupsOptions' => $restrictedGroupOptions,
Expand Down Expand Up @@ -755,8 +753,6 @@ private function getBaseTemplateVars(): array
'ad_entry_restricted_users' => Translation::get('ad_entry_restricted_users'),
'ad_entry_userpermission' => Translation::get('ad_entry_userpermission'),
'ad_categ_add' => Translation::get('ad_categ_add'),
'ad_entry_grouppermission' => Translation::get('ad_entry_grouppermission'),
'ad_entry_all_groups' => Translation::get('ad_entry_all_groups'),
'ad_entry_restricted_groups' => Translation::get('ad_entry_restricted_groups'),
'restricted_groups' => ($this->configuration->get('security.permLevel') === 'medium') ?
$this->currentUser->perm->getAllGroupsOptions([], $this->currentUser) : '',
Expand Down
Loading

0 comments on commit 8374f85

Please sign in to comment.