Skip to content

Commit ded401b

Browse files
committed
fix: corrected URL schemes
1 parent 86cc0e4 commit ded401b

File tree

11 files changed

+39
-30
lines changed

11 files changed

+39
-30
lines changed

docs/openapi.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@
633633
"content": {
634634
"application/json": {
635635
"schema": {},
636-
"example": "[\n {\n \"date\": \"2019-07-13T11:28:00+0200\",\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"answer\": \"A good question!\",\n \"visits\": 10,\n \"url\": \"https://www.example.org/index.php?action=faq&cat=1&id=36&artlang=de\"\n }\n ]"
636+
"example": "[\n {\n \"date\": \"2019-07-13T11:28:00+0200\",\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"answer\": \"A good question!\",\n \"visits\": 10,\n \"url\": \"https://www.example.org/content/1/36/de/how-can-i-survive-without-phpmyfaq.html\"\n }\n ]"
637637
}
638638
}
639639
},
@@ -676,7 +676,7 @@
676676
"content": {
677677
"application/json": {
678678
"schema": {},
679-
"example": "[\n {\n \"date\": \"2019-07-13T11:28:00+0200\",\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"answer\": \"A good question!\",\n \"visits\": 10,\n \"url\": \"https://www.example.org/index.php?action=faq&cat=1&id=36&artlang=de\"\n }\n ]"
679+
"example": "[\n {\n \"date\": \"2019-07-13T11:28:00+0200\",\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"answer\": \"A good question!\",\n \"visits\": 10,\n \"url\": \"https://www.example.org/content/1/36/de/how-can-i-survive-without-phpmyfaq.html\"\n }\n ]"
680680
}
681681
}
682682
},
@@ -719,7 +719,7 @@
719719
"content": {
720720
"application/json": {
721721
"schema": {},
722-
"example": "[\n {\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"url\": \"https://www.example.org/index.php?action=faq&cat=1&id=36&artlang=de\",\n \"id\": 8,\n \"order\": 1\n },\n {\n \"question\": \"Is there life after death?\",\n \"url\": \"https://www.example.org/index.php?action=faq&cat=1&id=1&artlang=en\",\n \"id\": 10,\n \"order\": 2\n }\n ]"
722+
"example": "[\n {\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"url\": \"https://www.example.org/content/1/36/de/how-can-i-survive-without-phpmyfaq.html\",\n \"id\": 8,\n \"order\": 1\n },\n {\n \"question\": \"Is there life after death?\",\n \"url\": \"https://www.example.org/content/1/1/de/is-there-life-after-death.html\",\n \"id\": 10,\n \"order\": 2\n }\n ]"
723723
}
724724
}
725725
},

docs/openapi.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ paths:
426426
content:
427427
application/json:
428428
schema: {}
429-
example: "[\n {\n \"date\": \"2019-07-13T11:28:00+0200\",\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"answer\": \"A good question!\",\n \"visits\": 10,\n \"url\": \"https://www.example.org/index.php?action=faq&cat=1&id=36&artlang=de\"\n }\n ]"
429+
example: "[\n {\n \"date\": \"2019-07-13T11:28:00+0200\",\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"answer\": \"A good question!\",\n \"visits\": 10,\n \"url\": \"https://www.example.org/content/1/36/de/how-can-i-survive-without-phpmyfaq.html\"\n }\n ]"
430430
'404':
431431
description: "If there's not one latest FAQ."
432432
headers:
@@ -455,7 +455,7 @@ paths:
455455
content:
456456
application/json:
457457
schema: {}
458-
example: "[\n {\n \"date\": \"2019-07-13T11:28:00+0200\",\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"answer\": \"A good question!\",\n \"visits\": 10,\n \"url\": \"https://www.example.org/index.php?action=faq&cat=1&id=36&artlang=de\"\n }\n ]"
458+
example: "[\n {\n \"date\": \"2019-07-13T11:28:00+0200\",\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"answer\": \"A good question!\",\n \"visits\": 10,\n \"url\": \"https://www.example.org/content/1/36/de/how-can-i-survive-without-phpmyfaq.html\"\n }\n ]"
459459
'404':
460460
description: "If there's not a single trending FAQ."
461461
headers:
@@ -484,7 +484,7 @@ paths:
484484
content:
485485
application/json:
486486
schema: {}
487-
example: "[\n {\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"url\": \"https://www.example.org/index.php?action=faq&cat=1&id=36&artlang=de\",\n \"id\": 8,\n \"order\": 1\n },\n {\n \"question\": \"Is there life after death?\",\n \"url\": \"https://www.example.org/index.php?action=faq&cat=1&id=1&artlang=en\",\n \"id\": 10,\n \"order\": 2\n }\n ]"
487+
example: "[\n {\n \"question\": \"How can I survive without phpMyFAQ?\",\n \"url\": \"https://www.example.org/content/1/36/de/how-can-i-survive-without-phpmyfaq.html\",\n \"id\": 8,\n \"order\": 1\n },\n {\n \"question\": \"Is there life after death?\",\n \"url\": \"https://www.example.org/content/1/1/de/is-there-life-after-death.html\",\n \"id\": 10,\n \"order\": 2\n }\n ]"
488488
'404':
489489
description: "If there's not one sticky FAQ."
490490
headers:

phpmyfaq/admin/assets/src/content/attachment-upload.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ describe('handleAttachmentUploads', () => {
507507
'a',
508508
expect.objectContaining({
509509
className: 'me-2',
510-
href: '../index.php?action=attachment&id=789',
510+
href: '../attachment/789',
511511
innerText: 'document.pdf',
512512
})
513513
);

phpmyfaq/admin/assets/src/content/attachment-upload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const handleAttachmentUploads = (): void => {
8686
addElement('li', {}, [
8787
addElement('a', {
8888
className: 'me-2',
89-
href: `../index.php?action=attachment&id=${attachment.attachmentId}`,
89+
href: `../attachment/${attachment.attachmentId}`,
9090
innerText: attachment.fileName,
9191
}),
9292
addElement(

phpmyfaq/src/phpMyFAQ/Controller/Api/FaqController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public function getPopular(): JsonResponse
304304
"question": "How can I survive without phpMyFAQ?",
305305
"answer": "A good question!",
306306
"visits": 10,
307-
"url": "https://www.example.org/index.php?action=faq&cat=1&id=36&artlang=de"
307+
"url": "https://www.example.org/content/1/36/de/how-can-i-survive-without-phpmyfaq.html"
308308
}
309309
]',
310310
))]
@@ -351,7 +351,7 @@ public function getLatest(): JsonResponse
351351
"question": "How can I survive without phpMyFAQ?",
352352
"answer": "A good question!",
353353
"visits": 10,
354-
"url": "https://www.example.org/index.php?action=faq&cat=1&id=36&artlang=de"
354+
"url": "https://www.example.org/content/1/36/de/how-can-i-survive-without-phpmyfaq.html"
355355
}
356356
]',
357357
))]
@@ -395,13 +395,13 @@ public function getTrending(): JsonResponse
395395
example: '[
396396
{
397397
"question": "How can I survive without phpMyFAQ?",
398-
"url": "https://www.example.org/index.php?action=faq&cat=1&id=36&artlang=de",
398+
"url": "https://www.example.org/content/1/36/de/how-can-i-survive-without-phpmyfaq.html",
399399
"id": 8,
400400
"order": 1
401401
},
402402
{
403403
"question": "Is there life after death?",
404-
"url": "https://www.example.org/index.php?action=faq&cat=1&id=1&artlang=en",
404+
"url": "https://www.example.org/content/1/1/de/is-there-life-after-death.html",
405405
"id": 10,
406406
"order": 2
407407
}

phpmyfaq/src/phpMyFAQ/Faq.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use phpMyFAQ\Helper\FaqHelper;
3434
use phpMyFAQ\Instance\Search\Elasticsearch;
3535
use phpMyFAQ\Language\Plurals;
36+
use phpMyFAQ\Link\Util\TitleSlugifier;
3637
use stdClass;
3738

3839
/*
@@ -566,11 +567,12 @@ public function renderFaqsByFaqIds(
566567

567568
$title = $row->question;
568569
$url = sprintf(
569-
'%sindex.php?action=faq&cat=%d&id=%d&artlang=%s',
570+
'%scontent/%d/%d/%s/%s.html',
570571
$this->configuration->getDefaultUrl(),
571572
$row->category_id,
572573
$row->id,
573574
$row->lang,
575+
TitleSlugifier::slug($row->question),
574576
);
575577

576578
$oLink = new Link($url, $this->configuration);
@@ -777,12 +779,14 @@ public function getFaqsByIds(array $faqIds): array
777779
$visits = empty($row->visits) ? 0 : $row->visits;
778780

779781
$url = sprintf(
780-
'%sindex.php?action=faq&cat=%d&id=%d&artlang=%s',
782+
'%scontent/%d/%d/%s/%s.html',
781783
$this->configuration->getDefaultUrl(),
782784
$row->category_id,
783785
$row->id,
784786
$row->lang,
787+
TitleSlugifier::slug($row->question),
785788
);
789+
786790
$oLink = new Link($url, $this->configuration);
787791
$oLink->setTitle($row->question);
788792
$oLink->text = $row->question;
@@ -871,15 +875,16 @@ public function getFaqByIdAndCategoryId(int $faqId, int $categoryId): array
871875
$result = $this->configuration->getDb()->query($query);
872876

873877
if ($row = $this->configuration->getDb()->fetchObject($result)) {
874-
$faqUrl = sprintf(
875-
'%sindex.php?action=faq&cat=%d&id=%d&artlang=%s',
878+
$url = sprintf(
879+
'%scontent/%d/%d/%s/%s.html',
876880
$this->configuration->getDefaultUrl(),
877881
$row->category_id,
878882
$row->id,
879883
$row->lang,
884+
TitleSlugifier::slug($row->question),
880885
);
881886

882-
$link = new Link($faqUrl, $this->configuration);
887+
$link = new Link($url, $this->configuration);
883888
$link->setTitle($row->question);
884889

885890
return [

phpmyfaq/src/phpMyFAQ/Faq/Statistics.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use phpMyFAQ\Language;
2727
use phpMyFAQ\Language\Plurals;
2828
use phpMyFAQ\Link;
29+
use phpMyFAQ\Link\Util\TitleSlugifier;
2930
use phpMyFAQ\Translation;
3031
use phpMyFAQ\Utils;
3132
use stdClass;
@@ -399,11 +400,12 @@ public function getTrendingData(int $count = PMF_NUMBER_RECORDS_TRENDING, ?strin
399400

400401
$title = $row->question;
401402
$url = sprintf(
402-
'%sindex.php?action=faq&cat=%d&id=%d&artlang=%s',
403+
'%scontent/%d/%d/%s/%s.html',
403404
$this->configuration->getDefaultUrl(),
404405
$row->category_id,
405406
$row->id,
406407
$row->language,
408+
TitleSlugifier::slug($row->question),
407409
);
408410
$oLink = new Link($url, $this->configuration);
409411
$oLink->setTitle($title);

phpmyfaq/src/phpMyFAQ/Helper/CategoryHelper.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use phpMyFAQ\Core\Exception;
2626
use phpMyFAQ\Language\LanguageCodes;
2727
use phpMyFAQ\Link;
28+
use phpMyFAQ\Link\Util\TitleSlugifier;
2829
use phpMyFAQ\Strings;
2930
use phpMyFAQ\Translation;
3031
use phpMyFAQ\User;
@@ -143,11 +144,7 @@ public function buildAvailableCategoryTranslationsList(array $availableCategoryT
143144
$html = '';
144145

145146
foreach ($availableCategoryTranslations as $language => $category) {
146-
$url = sprintf(
147-
'%sindex.php?action=show&lang=%s',
148-
$this->configuration->getDefaultUrl(),
149-
LanguageCodes::getKey($language),
150-
);
147+
$url = sprintf('%sshow-categories.html?lang=%s', $this->configuration->getDefaultUrl(), $language);
151148
$link = new Link($url, $this->configuration);
152149
$link->setTitle(Strings::htmlentities($category));
153150
$link->text = Strings::htmlentities($category);

phpmyfaq/src/phpMyFAQ/Helper/QuestionHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ public function generateSmartAnswer(SearchResultSet $searchResultSet): string
5050
$smartAnswer .= '<ul>';
5151
foreach ($searchResultSet->getResultSet() as $result) {
5252
$url = sprintf(
53-
'%sindex.php?action=faq&cat=%d&id=%d&artlang=%s',
53+
'%scontent/%d/%d/%s/%s.html',
5454
$this->configuration->getDefaultUrl(),
5555
$result->category_id,
5656
$result->id,
5757
$result->lang,
58+
TitleSlugifier::slug($result->question),
5859
);
5960
$link = new Link($url, $this->configuration);
6061
$link->text = Utils::chopString($result->question, 15);

phpmyfaq/src/phpMyFAQ/Helper/SearchHelper.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use phpMyFAQ\Configuration;
2525
use phpMyFAQ\Faq;
2626
use phpMyFAQ\Link;
27+
use phpMyFAQ\Link\Util\TitleSlugifier;
2728
use phpMyFAQ\Search\SearchResultSet;
2829
use phpMyFAQ\Strings;
2930
use phpMyFAQ\Utils;
@@ -79,11 +80,12 @@ public function createAutoCompleteResult(SearchResultSet $searchResultSet): arra
7980

8081
// Build the link to the faq record
8182
$currentUrl = sprintf(
82-
'%s?action=faq&cat=%d&id=%d&artlang=%s&highlight=%s',
83-
$this->configuration->getDefaultUrl() . 'index.php',
83+
'%scontent/%d/%d/%s/%s.html?highlight=%s',
84+
$this->configuration->getDefaultUrl(),
8485
$result->category_id,
8586
$result->id,
8687
$result->lang,
88+
TitleSlugifier::slug($result->question),
8789
urlencode($this->searchTerm),
8890
);
8991

@@ -128,7 +130,7 @@ public function renderAdminSuggestionResult(SearchResultSet $searchResultSet): a
128130
}
129131

130132
// Build the link to the faq record
131-
$currentUrl = $this->configuration->getDefaultUrl() . sprintf('index.php?solution_id=%d', $solutionId);
133+
$currentUrl = $this->configuration->getDefaultUrl() . sprintf('solution_id_%d.html', $solutionId);
132134
$adminUrl =
133135
$this->configuration->getDefaultUrl() . sprintf('admin/faq/edit/%d/%s', $result->id, $result->lang);
134136

@@ -206,11 +208,12 @@ public function getSearchResult(SearchResultSet $searchResultSet, int $currentPa
206208

207209
// Build the link to the faq record
208210
$currentUrl = sprintf(
209-
'%sindex.php?action=faq&cat=%d&id=%d&artlang=%s&highlight=%s',
211+
'%scontent/%d/%d/%s/%s.html?highlight=%s',
210212
$this->configuration->getDefaultUrl(),
211213
$resultSet->category_id,
212214
$resultSet->id,
213215
$resultSet->lang,
216+
TitleSlugifier::slug($resultSet->question),
214217
urlencode($searchTerm),
215218
);
216219

@@ -274,11 +277,12 @@ public function renderRelatedFaqs(SearchResultSet $searchResultSet, int $recordI
274277
++$counter;
275278

276279
$url = sprintf(
277-
'%sindex.php?action=faq&cat=%d&id=%d&artlang=%s',
280+
'%scontent/%d/%d/%s/%s.html',
278281
$this->configuration->getDefaultUrl(),
279282
$result->category_id,
280283
$result->id,
281284
$result->lang,
285+
TitleSlugifier::slug($result->question),
282286
);
283287
$link = new Link($url, $this->configuration);
284288
$link->setTitle(Strings::htmlentities($result->question));

0 commit comments

Comments
 (0)