Skip to content

Commit

Permalink
refactor: migrated report page to controller (#3257)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Nov 30, 2024
1 parent c4cbff7 commit a939f4d
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 206 deletions.
34 changes: 6 additions & 28 deletions phpmyfaq/admin/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@
'msgAdminElasticsearchStats',
'statistics/search'
);
$secLevelEntries['statistics'] .= $adminHelper->addMenuEntry('reports', 'reports', 'ad_menu_reports');
$secLevelEntries['statistics'] .= $adminHelper->addMenuEntry(
'reports',
'reports',
'ad_menu_reports',
'statistics/report'
);

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

switch ($action) {
case 'user':
case 'group':
case 'cookies':
$userPage = true;
break;
case 'category-overview':
case 'addcategory':
case 'savecategory':
Expand Down Expand Up @@ -206,28 +206,6 @@
case 'stickyfaqs':
$contentPage = true;
break;
case 'statistics':
case 'viewsessions':
case 'sessionbrowse':
case 'adminlog':
case 'searchstats':
case 'reports':
case 'reportview':
$statisticsPage = true;
break;
case 'export':
case 'importcsv':
$exportsPage = true;
break;
case 'backup':
$backupPage = true;
break;
case 'config':
case 'stopwordsconfig':
case 'upgrade':
case 'instances':
case 'system':
case 'elasticsearch':
case 'forms':
$configurationPage = true;
break;
Expand Down
5 changes: 0 additions & 5 deletions phpmyfaq/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,6 @@
case 'glossary':
require 'glossary.php';
break;
// Reports
case 'reportview':
case 'reports':
require 'report.main.php';
break;
// Config administration
case 'forms':
require 'forms.php';
Expand Down
59 changes: 0 additions & 59 deletions phpmyfaq/admin/report.main.php

This file was deleted.

108 changes: 0 additions & 108 deletions phpmyfaq/assets/templates/admin/statistics/report.main.twig

This file was deleted.

112 changes: 112 additions & 0 deletions phpmyfaq/assets/templates/admin/statistics/report.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{% extends '@admin/index.twig' %}

{% block content %}
<form action="#" id="pmf-admin-report-form" method="post" accept-charset="utf-8">
{{ csrfTokenInput | raw }}
<div
class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">
<i aria-hidden="true" class="bi bi-filetype-csv"></i> {{ 'ad_menu_reports' | translate }}
</h1>
<div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group mr-2">
<button id="pmf-admin-create-report" class="btn btn-outline-primary" type="button">
{{ 'ad_stat_report_make_report' | translate }}
</button>
</div>
</div>
</div>

<div class="container-fluid">
<div class="row mb-2">
<h4>{{ 'ad_stat_report_fields' | translate }}</h4>
</div>
<div class="row g-3">
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="category" name="category"
value="1" checked>
<label class="form-check-label" for="category">
{{ 'ad_stat_report_category' | translate }}
</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="sub_category" name="sub_category"
value="1" checked>
<label class="form-check-label" for="sub_category">
{{ 'ad_stat_report_sub_category' | translate }}
</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="translations"
name="translations" value="1" checked>
<label class="form-check-label" for="translations">
{{ 'ad_stat_report_translations' | translate }}
</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="language" name="language"
value="1" checked>
<label class="form-check-label" for="language">
{{ 'ad_stat_report_language' | translate }}
</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="id" name="id" value="1" checked>
<label class="form-check-label" for="id">
{{ 'ad_stat_report_id' | translate }}
</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="sticky" name="sticky" value="1"
checked>
<label class="form-check-label" for="sticky">
{{ 'ad_stat_report_sticky' | translate }}
</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="title" name="title" value="1"
checked>
<label class="form-check-label" for="title">
{{ 'ad_stat_report_title' | translate }}
</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="creation_date"
name="creation_date" value="1" checked>
<label class="form-check-label" for="creation_date">
{{ 'ad_stat_report_creation_date' | translate }}
</label>
</div>

<div class="col form-check">
<input class="form-check-input" type="checkbox" id="owner" name="owner" value="1"
checked>
<label class="form-check-label" for="owner">
{{ 'ad_stat_report_owner' | translate }}
</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="last_modified_person"
name="last_modified_person" value="1" checked>
<label class="form-check-label" for="last_modified_person">
{{ 'ad_stat_report_last_modified_person' | translate }}
</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="url" name="url" value="1" checked>
<label class="form-check-label" for="url">
{{ 'ad_stat_report_url' | translate }}
</label>
</div>
<div class="col form-check">
<input class="form-check-input" type="checkbox" id="visits" name="visits" value="1"
checked>
<label class="form-check-label" for="visits">
{{ 'ad_stat_report_visits' | translate }}
</label>
</div>
</div>

</div>
</form>
{% endblock %}
6 changes: 6 additions & 0 deletions phpmyfaq/src/admin-routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use phpMyFAQ\Controller\Administration\InstanceController;
use phpMyFAQ\Controller\Administration\PasswordChangeController;
use phpMyFAQ\Controller\Administration\RatingController;
use phpMyFAQ\Controller\Administration\ReportController;
use phpMyFAQ\Controller\Administration\SessionKeepAliveController;
use phpMyFAQ\Controller\Administration\StatisticsSearchController;
use phpMyFAQ\Controller\Administration\StatisticsSessionsController;
Expand Down Expand Up @@ -159,6 +160,11 @@
'controller' => [RatingController::class, 'index'],
'methods' => 'GET'
],
'admin.statistics.report' => [
'path' => '/statistics/report',
'controller' => [ReportController::class, 'index'],
'methods' => 'GET'
],
'admin.statistics.search' => [
'path' => '/statistics/search',
'controller' => [StatisticsSearchController::class, 'index'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,6 @@ protected function getHeader(Request $request): array
case 'stickyfaqs':
$contentPage = true;
break;
case 'searchstats':
case 'reports':
case 'reportview':
$statisticsPage = true;
break;
case 'forms':
$configurationPage = true;
break;
Expand Down Expand Up @@ -269,6 +264,7 @@ protected function getHeader(Request $request): array
break;
case 'admin.statistics.admin-log':
case 'admin.statistics.ratings':
case 'admin.statistics.report':
case 'admin.statistics.sessions':
case 'admin.statistics.session.day':
case 'admin.statistics.session.id':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function exportReport(Request $request): Response

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

rewind($handle);
Expand Down
Loading

0 comments on commit a939f4d

Please sign in to comment.