Skip to content

Commit bb85ab7

Browse files
committed
feat: removed configuration for enabling rewrite rules
1 parent d209bce commit bb85ab7

35 files changed

+202
-382
lines changed

phpmyfaq/index.php

+34-72
Original file line numberDiff line numberDiff line change
@@ -603,78 +603,40 @@
603603
);
604604
}
605605

606-
if ($faqConfig->get('main.enableRewriteRules')) {
607-
$tplNavigation = [
608-
'backToHome' => '<a class="nav-link" href="./index.html">' . Translation::get('msgHome') . '</a>',
609-
'allCategories' => '<a class="nav-link px-2 text-white" href="./show-categories.html">' .
610-
Translation::get('msgShowAllCategories') . '</a>',
611-
'msgAddContent' => '<a class="nav-link px-2 text-white" href="./addcontent.html">' .
612-
Translation::get('msgAddContent') . '</a>',
613-
'msgQuestion' => $faqConfig->get('main.enableAskQuestions')
614-
?
615-
'<a class="nav-link px-2 text-white" href="./ask.html">' . Translation::get('msgQuestion') . '</a>'
616-
:
617-
'',
618-
'msgOpenQuestions' => $faqConfig->get('main.enableAskQuestions')
619-
?
620-
'<a class="nav-link px-2 text-white" href="./open-questions.html">' .
621-
Translation::get('msgOpenQuestions') . '</a>'
622-
:
623-
'',
624-
'msgSearch' => '<a class="nav-link" href="./search.html">' . Translation::get('msgAdvancedSearch') . '</a>',
625-
'msgContact' => '<a class="nav-link px-2 link-light" href="./contact.html">' . Translation::get('msgContact') .
626-
'</a>',
627-
'msgGlossary' => '<a class="nav-link px-2 link-light" href="./glossary.html">' .
628-
Translation::get('ad_menu_glossary') . '</a>',
629-
'privacyLink' => sprintf(
630-
'<a class="nav-link px-2 link-light" target="_blank" href="%s">%s</a>',
631-
Strings::htmlentities($faqConfig->get('main.privacyURL')),
632-
Translation::get('msgPrivacyNote')
633-
),
634-
'faqOverview' => '<a class="nav-link px-2 link-light" href="./overview.html">' .
635-
Translation::get('faqOverview') . '</a>',
636-
'showSitemap' => '<a class="nav-link px-2 link-light" href="./sitemap/A/' . $faqLangCode . '.html">' .
637-
Translation::get('msgSitemap') . '</a>',
638-
'breadcrumbHome' => '<a href="./index.html">' . Translation::get('msgHome') . '</a>',
639-
];
640-
} else {
641-
$tplNavigation = [
642-
'backToHome' => '<a href="index.php?' . $sids . '">' . Translation::get('msgHome') . '</a>',
643-
'allCategories' => '<a class="nav-link" href="index.php?' . $sids . 'action=show">' .
644-
Translation::get('msgShowAllCategories') . '</a>',
645-
'msgAddContent' => '<a class="nav-link" href="index.php?' . $sids . 'action=add&cat=' . $cat . '">' .
646-
Translation::get('msgAddContent') . '</a>',
647-
'msgQuestion' => $faqConfig->get('main.enableAskQuestions')
648-
?
649-
'<a class="nav-link" href="index.php?' . $sids . 'action=ask&category_id=' . $cat . '">' .
650-
Translation::get('msgQuestion') . '</a>'
651-
:
652-
'',
653-
'msgOpenQuestions' => $faqConfig->get('main.enableAskQuestions')
654-
?
655-
'<a class="nav-link" href="index.php?' . $sids . 'action=open-questions">' .
656-
Translation::get('msgOpenQuestions') . '</a>'
657-
:
658-
'',
659-
'msgSearch' => '<a class="nav-link" href="index.php?' . $sids . 'action=search">' .
660-
Translation::get('msgAdvancedSearch') . '</a>',
661-
'msgContact' => '<a class="nav-link px-2 link-light" href="index.php?' . $sids . 'action=contact">' .
662-
Translation::get('msgContact') . '</a>',
663-
'msgGlossary' => '<a class="nav-link px-2 link-light" href="index.php?' . $sids . 'action=glossary">' .
664-
Translation::get('ad_menu_glossary') . '</a>',
665-
'privacyLink' => sprintf(
666-
'<a class="nav-link px-2 link-light" target="_blank" href="%s">%s</a>',
667-
Strings::htmlentities($faqConfig->get('main.privacyURL')),
668-
Translation::get('msgPrivacyNote')
669-
),
670-
'faqOverview' => '<a class="nav-link px-2 link-light" href="index.php?' . $sids . 'action=overview">' .
671-
Translation::get('faqOverview') . '</a>',
672-
'showSitemap' => '<a class="nav-link px-2 link-light" href="index.php?' . $sids . 'action=sitemap&amp;lang=' .
673-
$faqLangCode . '">' .
674-
Translation::get('msgSitemap') . '</a>',
675-
'breadcrumbHome' => '<a href="index.php?' . $sids . '">' . Translation::get('msgHome') . '</a>',
676-
];
677-
}
606+
$tplNavigation = [
607+
'backToHome' => '<a class="nav-link" href="./index.html">' . Translation::get('msgHome') . '</a>',
608+
'allCategories' => '<a class="nav-link px-2 text-white" href="./show-categories.html">' .
609+
Translation::get('msgShowAllCategories') . '</a>',
610+
'msgAddContent' => '<a class="nav-link px-2 text-white" href="./addcontent.html">' .
611+
Translation::get('msgAddContent') . '</a>',
612+
'msgQuestion' => $faqConfig->get('main.enableAskQuestions')
613+
?
614+
'<a class="nav-link px-2 text-white" href="./ask.html">' . Translation::get('msgQuestion') . '</a>'
615+
:
616+
'',
617+
'msgOpenQuestions' => $faqConfig->get('main.enableAskQuestions')
618+
?
619+
'<a class="nav-link px-2 text-white" href="./open-questions.html">' .
620+
Translation::get('msgOpenQuestions') . '</a>'
621+
:
622+
'',
623+
'msgSearch' => '<a class="nav-link" href="./search.html">' . Translation::get('msgAdvancedSearch') . '</a>',
624+
'msgContact' => '<a class="nav-link px-2 link-light" href="./contact.html">' . Translation::get('msgContact') .
625+
'</a>',
626+
'msgGlossary' => '<a class="nav-link px-2 link-light" href="./glossary.html">' .
627+
Translation::get('ad_menu_glossary') . '</a>',
628+
'privacyLink' => sprintf(
629+
'<a class="nav-link px-2 link-light" target="_blank" href="%s">%s</a>',
630+
Strings::htmlentities($faqConfig->get('main.privacyURL')),
631+
Translation::get('msgPrivacyNote')
632+
),
633+
'faqOverview' => '<a class="nav-link px-2 link-light" href="./overview.html">' .
634+
Translation::get('faqOverview') . '</a>',
635+
'showSitemap' => '<a class="nav-link px-2 link-light" href="./sitemap/A/' . $faqLangCode . '.html">' .
636+
Translation::get('msgSitemap') . '</a>',
637+
'breadcrumbHome' => '<a href="./index.html">' . Translation::get('msgHome') . '</a>',
638+
];
639+
678640

679641
$tplNavigation['faqHome'] = Strings::htmlentities($faqConfig->getDefaultUrl());
680642
$tplNavigation['activeSearch'] = ('search' == $action) ? 'active' : '';

phpmyfaq/search.php

+9-25
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,7 @@
202202
) && $faqConfig->get('search.searchForSolutionId')
203203
) {
204204
$response = new Response();
205-
if ($faqConfig->get('main.enableRewriteRules')) {
206-
$response->isRedirect($faqConfig->getDefaultUrl() . 'solution_id_' . $inputSearchTerm . '.html');
207-
} else {
208-
$response->isRedirect($faqConfig->getDefaultUrl() . 'index.php?solution_id=' . $inputSearchTerm);
209-
}
205+
$response->isRedirect($faqConfig->getDefaultUrl() . 'solution_id_' . $inputSearchTerm . '.html');
210206
$response->send();
211207
exit();
212208
}
@@ -216,26 +212,14 @@
216212
$mostPopularSearchData = $faqSearch->getMostPopularSearches($faqConfig->get('search.numberSearchTerms'));
217213

218214
// Set base URL scheme
219-
if ($faqConfig->get('main.enableRewriteRules')) {
220-
$baseUrl = sprintf(
221-
'%ssearch.html?search=%s&amp;seite=%d%s&amp;pmf-search-category=%d',
222-
$faqConfig->getDefaultUrl(),
223-
urlencode($inputSearchTerm),
224-
$page,
225-
$languages,
226-
$inputCategory
227-
);
228-
} else {
229-
$baseUrl = sprintf(
230-
'%s?%saction=search&amp;search=%s&amp;seite=%d%s&amp;pmf-search-category=%d',
231-
$faqConfig->getDefaultUrl(),
232-
empty($sids) ? '' : 'sids=' . $sids . '&amp;',
233-
urlencode($inputSearchTerm),
234-
$page,
235-
$languages,
236-
$inputCategory
237-
);
238-
}
215+
$baseUrl = sprintf(
216+
'%ssearch.html?search=%s&amp;seite=%d%s&amp;pmf-search-category=%d',
217+
$faqConfig->getDefaultUrl(),
218+
urlencode($inputSearchTerm),
219+
$page,
220+
$languages,
221+
$inputCategory
222+
);
239223

240224
// Pagination options
241225
$options = [

phpmyfaq/setup/migrations.php

+3
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@
187187
$faqConfig->add('upgrade.releaseEnvironment', 'development');
188188
$faqConfig->add('upgrade.dateLastChecked', '');
189189

190+
// Rewrite rules are now mandatory
191+
$faqConfig->delete('main.enableRewriteRules');
192+
190193
// Bookmarks support
191194
$query[] = match ($dbConfig->getType()) {
192195
'mysqli' => 'CREATE TABLE ' . $prefix . 'faqbookmarks (

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

+2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
use Symfony\Component\HttpFoundation\JsonResponse;
3030
use Symfony\Component\HttpFoundation\Request;
3131
use Symfony\Component\HttpFoundation\Response;
32+
use Symfony\Component\Routing\Annotation\Route;
3233

3334
class AutoCompleteController
3435
{
36+
#[Route('api/autocomplete')]
3537
public function search(Request $request): JsonResponse
3638
{
3739
$response = new JsonResponse();

phpmyfaq/src/phpMyFAQ/Core/Controller.php

-49
This file was deleted.

phpmyfaq/src/phpMyFAQ/Faq.php

+9-14
Original file line numberDiff line numberDiff line change
@@ -471,20 +471,15 @@ public function renderRecordsByCategoryId(int $categoryId, string $orderBy = 'id
471471
}
472472

473473
if ($pages > 1) {
474-
// Set rewrite URL, if needed
475-
if ($this->config->get('main.enableRewriteRules')) {
476-
$link = new Link($this->config->getDefaultUrl(), $this->config);
477-
$useRewrite = true;
478-
$rewriteUrl = sprintf(
479-
'%scategory/%d/%%d/%s.html',
480-
$this->config->getDefaultUrl(),
481-
$categoryId,
482-
$link->getSEOItemTitle($title)
483-
);
484-
} else {
485-
$useRewrite = false;
486-
$rewriteUrl = '';
487-
}
474+
$link = new Link($this->config->getDefaultUrl(), $this->config);
475+
$useRewrite = true;
476+
$rewriteUrl = sprintf(
477+
'%scategory/%d/%%d/%s.html',
478+
$this->config->getDefaultUrl(),
479+
$categoryId,
480+
$link->getSEOItemTitle($title)
481+
);
482+
488483
$baseUrl = sprintf(
489484
'%sindex.php?%saction=show&amp;cat=%d&amp;seite=%d',
490485
$this->config->getDefaultUrl(),

0 commit comments

Comments
 (0)