Skip to content

Commit 8149e9e

Browse files
committed
Merge branch '4.1' into 'main'
2 parents 28514f5 + cb7ae54 commit 8149e9e

File tree

9 files changed

+4282
-115
lines changed

9 files changed

+4282
-115
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ This is a log of major user-visible changes in each phpMyFAQ release.
6262
- updated Farsi translation
6363
- updated Canadian French translation
6464
- updated Hebrew translation
65+
- updated Swedish translation
66+
- updated Indonesian translation
67+
- updated Korean translation
68+
- updated Lithuanian translation
69+
- updated Latvian translation
6570
- updated to PHPUnit v12 (Thorsten)
6671
- migrated codebase to use PHP 8.3 language features (Thorsten)
6772
- migrated from WYSIWYG editor from TinyMCE to Jodit Editor (Thorsten)
File renamed without changes.

phpmyfaq/.htaccess

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ Header set Access-Control-Allow-Headers "Content-Type, Authorization"
145145
# User pages
146146
RewriteRule ^user/(ucp|bookmarks|request-removal|logout|register) index.php?action=$1 [L,QSA]
147147
# Setup and update pages
148-
RewriteRule ^setup/(.*) setup/index.php [L,QSA]
148+
RewriteCond %{REQUEST_URI} ^(.*/)setup/
149+
RewriteRule ^(.*/)?setup/(.*) $1setup/index.php [L,QSA]
149150
RewriteRule ^update/(.*) update/index.php [L,QSA]
150151
# Administration API
151152
RewriteRule ^admin/api/(.*) admin/api/index.php [L,QSA]

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

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,17 @@
4040
final class ExportController extends AbstractController
4141
{
4242
/**
43-
* @throws Exception
4443
* @throws \Exception
4544
*/
4645
#[Route(path: 'admin/api/export/file', name: 'admin.api.export.file', methods: ['GET'])]
4746
public function exportFile(Request $request): void
4847
{
4948
$this->userHasPermission(PermissionType::EXPORT);
5049

51-
$categoryId = (int) Filter::filterVar($request->attributes->get('categoryId'), FILTER_VALIDATE_INT);
52-
$downwards = Filter::filterVar($request->attributes->get('downwards'), FILTER_VALIDATE_BOOLEAN, false);
53-
$inlineDisposition = Filter::filterVar($request->attributes->get('disposition'), FILTER_SANITIZE_SPECIAL_CHARS);
54-
$type = Filter::filterVar($request->attributes->get('export-type'), FILTER_SANITIZE_SPECIAL_CHARS, 'none');
50+
$categoryId = (int) Filter::filterVar($request->request->get('categoryId'), FILTER_VALIDATE_INT);
51+
$downwards = Filter::filterVar($request->request->get('downwards'), FILTER_VALIDATE_BOOLEAN, false);
52+
$inlineDisposition = Filter::filterVar($request->request->get('disposition'), FILTER_SANITIZE_SPECIAL_CHARS);
53+
$type = Filter::filterVar($request->request->get('export-type'), FILTER_SANITIZE_SPECIAL_CHARS, 'none');
5554

5655
$faq = $this->container->get(id: 'phpmyfaq.faq');
5756
$category = new Category($this->configuration, [], false);
@@ -63,18 +62,17 @@ public function exportFile(Request $request): void
6362

6463
// Stream the file content
6564
$httpStreamer = new HttpStreamer($type, $content);
66-
if ('inline' === $inlineDisposition) {
67-
$httpStreamer->send(HeaderUtils::DISPOSITION_INLINE);
68-
} else {
69-
$httpStreamer->send(HeaderUtils::DISPOSITION_ATTACHMENT);
70-
}
65+
$disposition = 'inline' === $inlineDisposition
66+
? HeaderUtils::DISPOSITION_INLINE
67+
: HeaderUtils::DISPOSITION_ATTACHMENT;
68+
$httpStreamer->send($disposition);
7169
} catch (Exception|JsonException|CommonMarkException $e) {
7270
echo $e->getMessage();
7371
}
7472
}
7573

7674
/**
77-
* @throws Exception|\Exception
75+
* @throws \Exception
7876
*/
7977
#[Route(path: 'admin/api/export/report', name: 'admin.api.export.report', methods: ['POST'])]
8078
public function exportReport(Request $request): Response
@@ -143,18 +141,16 @@ public function exportReport(Request $request): Response
143141
foreach ($report->getReportingData() as $reportData) {
144142
$i = $reportData['faq_id'];
145143
if (isset($data->category, $reportData['category_name'])) {
144+
$text[$i][] = Report::sanitize($report->convertEncoding($reportData['category_name']));
146145
if (0 !== $reportData['category_parent']) {
147146
$text[$i][] = Report::sanitize($reportData['category_parent']);
148-
} else {
149-
$text[$i][] = Report::sanitize($report->convertEncoding($reportData['category_name']));
150147
}
151148
}
152149

153150
if (isset($data->sub_category)) {
154-
if (0 != $reportData['category_parent']) {
151+
$text[$i][] = 'n/a';
152+
if (0 !== $reportData['category_parent']) {
155153
$text[$i][] = Report::sanitize($report->convertEncoding($reportData['category_name']));
156-
} else {
157-
$text[$i][] = 'n/a';
158154
}
159155
}
160156

@@ -186,10 +182,9 @@ public function exportReport(Request $request): Response
186182
$text[$i][] = Report::sanitize($report->convertEncoding($reportData['faq_org_author']));
187183
}
188184

185+
$text[$i][] = '';
189186
if (isset($data->last_modified_person, $reportData['faq_last_author'])) {
190187
$text[$i][] = Report::sanitize($report->convertEncoding($reportData['faq_last_author']));
191-
} else {
192-
$text[$i][] = '';
193188
}
194189

195190
if (isset($data->url)) {
@@ -207,9 +202,9 @@ public function exportReport(Request $request): Response
207202
}
208203
}
209204

210-
$handle = fopen('php://temp', 'r+');
205+
$handle = fopen('php://temp', mode: 'r+');
211206
foreach ($text as $row) {
212-
fputcsv($handle, $row, ',', '"', '\\', PHP_EOL);
207+
fputcsv($handle, fields: $row, separator: ',', enclosure: '"', escape: '\\', eol: PHP_EOL);
213208
}
214209

215210
rewind($handle);

0 commit comments

Comments
 (0)