Skip to content

Commit 3718072

Browse files
committed
refactor: migrated hierachy category page to controller (#3257)
1 parent 1cc6620 commit 3718072

File tree

8 files changed

+170
-222
lines changed

8 files changed

+170
-222
lines changed

phpmyfaq/admin/category.showstructure.php

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

phpmyfaq/admin/index.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,6 @@
267267
case 'copyentry':
268268
require 'faqs.editor.php';
269269
break;
270-
// category administration
271-
case 'showcategory':
272-
require 'category.showstructure.php';
273-
break;
274270
// Config administration
275271
case 'forms':
276272
require 'forms.php';
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{% extends '@admin/index.twig' %}
2+
3+
{% block content %}
4+
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
5+
6+
<h1 class="h2">
7+
<i aria-hidden="true" class="bi bi-folder"></i> {{ ad_menu_categ_structure }}
8+
</h1>
9+
<div class="btn-toolbar mb-2 mb-md-0">
10+
<div class="btn-group mr-2">
11+
<a class="btn btn-outline-success" href="./category/add">
12+
<i aria-hidden="true" class="bi bi-folder-plus"></i> {{ msgAddCategory }}
13+
</a>
14+
<a class="btn btn-outline-info" href="./category">
15+
<i aria-hidden="true" class="bi bi-list"></i> {{ msgHeaderCategoryOverview }}
16+
</a>
17+
</div>
18+
</div>
19+
</div>
20+
{% if message_typ is defined %}
21+
<div class="alert alert-{{ message_typ }} alert-dismissible fade show">
22+
{% if message_heading is defined %}
23+
<h4 class="alert-heading">{{ message_heading }}</h4>
24+
<p>{{ error }}</p>
25+
{% endif %}
26+
{{ message }}
27+
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
28+
</div>
29+
{% endif %}
30+
<table class="table table-light table-striped align-middle">
31+
<thead class="thead-dark">
32+
<tr>
33+
<th>{{ msgCategory }}</th>
34+
<th class="text-center">{{ currentLanguage }}</th>
35+
{% for language in allLangs %}
36+
{% if language != currentLanguage %}
37+
<th class="text-center">{{ language }}</th>
38+
{% endif %}
39+
{% endfor %}
40+
</tr>
41+
</thead>
42+
<tbody>
43+
{% for category in categoryTree %}
44+
<tr>
45+
{% set indent = category.indent * 2 %}
46+
<th>
47+
<a href="?action=editcategory&cat={{ category.id }}"><span><i class="bi bi-pencil"></i></span></a>&nbsp;
48+
<span class="ps-{{ indent }}">{{ category.name }}</span>
49+
</th>
50+
{% for code in allLangCodes %}
51+
<th class="text-center">
52+
{% for catid, category_trans in translations %}
53+
{% if catid == category.id %}
54+
{% set break = false %}
55+
{% for translation_code in category_trans %}
56+
{% if break == false %}
57+
{% if translation_code == code %}
58+
<span class="badge bg-success" title="{{ ad_categ_translated }}"><i class="bi bi-check"></i></span>
59+
{% endif %}
60+
{% if code in category_trans %}
61+
{% else %}
62+
<a href="{{ basePath }}/category/translate/{{ category.id }}?translateTo={{ code }}"
63+
title="{{ ad_categ_translate }}">
64+
<span title="{{ ad_categ_translate }}" class="badge bg-primary">
65+
<i aria-hidden="true" class="bi bi-globe bi-white"></i></span>
66+
</a>
67+
{% set break = true %}
68+
{% endif %}
69+
{% endif %}
70+
{% endfor %}
71+
{% endif %}
72+
{% endfor %}
73+
</th>
74+
{% endfor %}
75+
</tr>
76+
{% endfor %}
77+
</tbody>
78+
</table>
79+
{% endblock %}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<a class="btn btn-outline-success" href="./category/add" id="addCategoryModal">
1111
<i aria-hidden="true" class="bi bi-plus"></i> {{ 'msgAddCategory' | translate }}
1212
</a>
13-
<a class="btn btn-outline-info" href="./category/matrix">
13+
<a class="btn btn-outline-info" href="./category/hierarchy">
1414
<i aria-hidden="true" class="bi bi-list"></i> {{ 'msgCategoryMatrix' | translate }}
1515
</a>
1616
</div>

phpmyfaq/assets/templates/admin/content/category.showstructure.twig

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

phpmyfaq/src/admin-routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@
9292
'controller' => [CategoryController::class, 'edit'],
9393
'methods' => 'GET'
9494
],
95+
'admin.category.hierarchy' => [
96+
'path' => '/category/hierarchy',
97+
'controller' => [CategoryController::class, 'hierarchy'],
98+
'methods' => 'GET'
99+
],
95100
'admin.category.translate' => [
96101
'path' => '/category/translate/{categoryId}',
97102
'controller' => [CategoryController::class, 'translate'],

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,11 @@ protected function getHeader(Request $request): array
256256
case 'admin.category':
257257
case 'admin.category.add':
258258
case 'admin.category.add.child':
259+
case 'admin.category.create':
259260
case 'admin.category.edit':
261+
case 'admin.category.hierarchy':
260262
case 'admin.category.translate':
263+
case 'admin.category.update':
261264
case 'admin.content.sticky-faqs':
262265
case 'admin.comments':
263266
case 'admin.glossary':

0 commit comments

Comments
 (0)