Skip to content

Commit a939f4d

Browse files
committed
refactor: migrated report page to controller (#3257)
1 parent c4cbff7 commit a939f4d

File tree

9 files changed

+179
-206
lines changed

9 files changed

+179
-206
lines changed

phpmyfaq/admin/header.php

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@
127127
'msgAdminElasticsearchStats',
128128
'statistics/search'
129129
);
130-
$secLevelEntries['statistics'] .= $adminHelper->addMenuEntry('reports', 'reports', 'ad_menu_reports');
130+
$secLevelEntries['statistics'] .= $adminHelper->addMenuEntry(
131+
'reports',
132+
'reports',
133+
'ad_menu_reports',
134+
'statistics/report'
135+
);
131136

132137
$secLevelEntries['imports_exports'] = $adminHelper->addMenuEntry(
133138
PermissionType::FAQ_ADD->value,
@@ -170,11 +175,6 @@
170175
$secLevelEntries['config'] .= $adminHelper->addMenuEntry('editconfig', 'system', 'ad_system_info', 'system');
171176

172177
switch ($action) {
173-
case 'user':
174-
case 'group':
175-
case 'cookies':
176-
$userPage = true;
177-
break;
178178
case 'category-overview':
179179
case 'addcategory':
180180
case 'savecategory':
@@ -206,28 +206,6 @@
206206
case 'stickyfaqs':
207207
$contentPage = true;
208208
break;
209-
case 'statistics':
210-
case 'viewsessions':
211-
case 'sessionbrowse':
212-
case 'adminlog':
213-
case 'searchstats':
214-
case 'reports':
215-
case 'reportview':
216-
$statisticsPage = true;
217-
break;
218-
case 'export':
219-
case 'importcsv':
220-
$exportsPage = true;
221-
break;
222-
case 'backup':
223-
$backupPage = true;
224-
break;
225-
case 'config':
226-
case 'stopwordsconfig':
227-
case 'upgrade':
228-
case 'instances':
229-
case 'system':
230-
case 'elasticsearch':
231209
case 'forms':
232210
$configurationPage = true;
233211
break;

phpmyfaq/admin/index.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,6 @@
314314
case 'glossary':
315315
require 'glossary.php';
316316
break;
317-
// Reports
318-
case 'reportview':
319-
case 'reports':
320-
require 'report.main.php';
321-
break;
322317
// Config administration
323318
case 'forms':
324319
require 'forms.php';

phpmyfaq/admin/report.main.php

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

phpmyfaq/assets/templates/admin/statistics/report.main.twig

Lines changed: 0 additions & 108 deletions
This file was deleted.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{% extends '@admin/index.twig' %}
2+
3+
{% block content %}
4+
<form action="#" id="pmf-admin-report-form" method="post" accept-charset="utf-8">
5+
{{ csrfTokenInput | raw }}
6+
<div
7+
class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
8+
<h1 class="h2">
9+
<i aria-hidden="true" class="bi bi-filetype-csv"></i> {{ 'ad_menu_reports' | translate }}
10+
</h1>
11+
<div class="btn-toolbar mb-2 mb-md-0">
12+
<div class="btn-group mr-2">
13+
<button id="pmf-admin-create-report" class="btn btn-outline-primary" type="button">
14+
{{ 'ad_stat_report_make_report' | translate }}
15+
</button>
16+
</div>
17+
</div>
18+
</div>
19+
20+
<div class="container-fluid">
21+
<div class="row mb-2">
22+
<h4>{{ 'ad_stat_report_fields' | translate }}</h4>
23+
</div>
24+
<div class="row g-3">
25+
<div class="col form-check">
26+
<input class="form-check-input" type="checkbox" id="category" name="category"
27+
value="1" checked>
28+
<label class="form-check-label" for="category">
29+
{{ 'ad_stat_report_category' | translate }}
30+
</label>
31+
</div>
32+
<div class="col form-check">
33+
<input class="form-check-input" type="checkbox" id="sub_category" name="sub_category"
34+
value="1" checked>
35+
<label class="form-check-label" for="sub_category">
36+
{{ 'ad_stat_report_sub_category' | translate }}
37+
</label>
38+
</div>
39+
<div class="col form-check">
40+
<input class="form-check-input" type="checkbox" id="translations"
41+
name="translations" value="1" checked>
42+
<label class="form-check-label" for="translations">
43+
{{ 'ad_stat_report_translations' | translate }}
44+
</label>
45+
</div>
46+
<div class="col form-check">
47+
<input class="form-check-input" type="checkbox" id="language" name="language"
48+
value="1" checked>
49+
<label class="form-check-label" for="language">
50+
{{ 'ad_stat_report_language' | translate }}
51+
</label>
52+
</div>
53+
<div class="col form-check">
54+
<input class="form-check-input" type="checkbox" id="id" name="id" value="1" checked>
55+
<label class="form-check-label" for="id">
56+
{{ 'ad_stat_report_id' | translate }}
57+
</label>
58+
</div>
59+
<div class="col form-check">
60+
<input class="form-check-input" type="checkbox" id="sticky" name="sticky" value="1"
61+
checked>
62+
<label class="form-check-label" for="sticky">
63+
{{ 'ad_stat_report_sticky' | translate }}
64+
</label>
65+
</div>
66+
<div class="col form-check">
67+
<input class="form-check-input" type="checkbox" id="title" name="title" value="1"
68+
checked>
69+
<label class="form-check-label" for="title">
70+
{{ 'ad_stat_report_title' | translate }}
71+
</label>
72+
</div>
73+
<div class="col form-check">
74+
<input class="form-check-input" type="checkbox" id="creation_date"
75+
name="creation_date" value="1" checked>
76+
<label class="form-check-label" for="creation_date">
77+
{{ 'ad_stat_report_creation_date' | translate }}
78+
</label>
79+
</div>
80+
81+
<div class="col form-check">
82+
<input class="form-check-input" type="checkbox" id="owner" name="owner" value="1"
83+
checked>
84+
<label class="form-check-label" for="owner">
85+
{{ 'ad_stat_report_owner' | translate }}
86+
</label>
87+
</div>
88+
<div class="col form-check">
89+
<input class="form-check-input" type="checkbox" id="last_modified_person"
90+
name="last_modified_person" value="1" checked>
91+
<label class="form-check-label" for="last_modified_person">
92+
{{ 'ad_stat_report_last_modified_person' | translate }}
93+
</label>
94+
</div>
95+
<div class="col form-check">
96+
<input class="form-check-input" type="checkbox" id="url" name="url" value="1" checked>
97+
<label class="form-check-label" for="url">
98+
{{ 'ad_stat_report_url' | translate }}
99+
</label>
100+
</div>
101+
<div class="col form-check">
102+
<input class="form-check-input" type="checkbox" id="visits" name="visits" value="1"
103+
checked>
104+
<label class="form-check-label" for="visits">
105+
{{ 'ad_stat_report_visits' | translate }}
106+
</label>
107+
</div>
108+
</div>
109+
110+
</div>
111+
</form>
112+
{% endblock %}

phpmyfaq/src/admin-routes.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use phpMyFAQ\Controller\Administration\InstanceController;
2727
use phpMyFAQ\Controller\Administration\PasswordChangeController;
2828
use phpMyFAQ\Controller\Administration\RatingController;
29+
use phpMyFAQ\Controller\Administration\ReportController;
2930
use phpMyFAQ\Controller\Administration\SessionKeepAliveController;
3031
use phpMyFAQ\Controller\Administration\StatisticsSearchController;
3132
use phpMyFAQ\Controller\Administration\StatisticsSessionsController;
@@ -159,6 +160,11 @@
159160
'controller' => [RatingController::class, 'index'],
160161
'methods' => 'GET'
161162
],
163+
'admin.statistics.report' => [
164+
'path' => '/statistics/report',
165+
'controller' => [ReportController::class, 'index'],
166+
'methods' => 'GET'
167+
],
162168
'admin.statistics.search' => [
163169
'path' => '/statistics/search',
164170
'controller' => [StatisticsSearchController::class, 'index'],

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,6 @@ protected function getHeader(Request $request): array
236236
case 'stickyfaqs':
237237
$contentPage = true;
238238
break;
239-
case 'searchstats':
240-
case 'reports':
241-
case 'reportview':
242-
$statisticsPage = true;
243-
break;
244239
case 'forms':
245240
$configurationPage = true;
246241
break;
@@ -269,6 +264,7 @@ protected function getHeader(Request $request): array
269264
break;
270265
case 'admin.statistics.admin-log':
271266
case 'admin.statistics.ratings':
267+
case 'admin.statistics.report':
272268
case 'admin.statistics.sessions':
273269
case 'admin.statistics.session.day':
274270
case 'admin.statistics.session.id':

phpmyfaq/src/phpMyFAQ/Controller/Administration/Api/ExportController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function exportReport(Request $request): Response
162162

163163
$handle = fopen('php://temp', 'r+');
164164
foreach ($text as $row) {
165-
fputcsv($handle, $row);
165+
fputcsv($handle, $row, ',', '"', '\\', PHP_EOL);
166166
}
167167

168168
rewind($handle);

0 commit comments

Comments
 (0)