Skip to content

Commit 3fe7bd4

Browse files
committed
fix: corrected URL schemes
1 parent ded401b commit 3fe7bd4

File tree

6 files changed

+20
-29
lines changed

6 files changed

+20
-29
lines changed

phpmyfaq/assets/templates/admin/content/news.edit.twig

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,5 @@
138138
</div>
139139
</div>
140140
</form>
141-
{% if comments|length > 0 %}
142-
<div class="row"><strong>{{ ad_entry_comment }}</strong></div>
143-
{% endif %}
144-
{% for item in comments %}
145-
<div class="row">
146-
{{ ad_entry_commentby }}
147-
<a href="mailto:{{ item.email }}">
148-
{{ item.user }}
149-
</a>:<br>
150-
{{ item.content }}<br>
151-
{{ newsCommentDate }}{{ item.date|createIsoDate }}
152-
<a href="?action=delcomment&artid={{ newsId }}&cmtid={{ item.id }}&type={{ commentTypeNews }}">
153-
<i aria-hidden="true" class="bi bi-trash"></i>
154-
</a>
155-
</div>
156-
</div>
157-
</div>
158-
{% endfor %}
141+
159142
{% endblock %}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use phpMyFAQ\Export;
3131
use phpMyFAQ\Filter;
3232
use phpMyFAQ\Language\LanguageCodes;
33+
use phpMyFAQ\Link\Util\TitleSlugifier;
3334
use phpMyFAQ\Session\Token;
3435
use phpMyFAQ\Translation;
3536
use Symfony\Component\HttpFoundation\HeaderUtils;
@@ -186,11 +187,12 @@ public function exportReport(Request $request): Response
186187

187188
if (isset($data->url)) {
188189
$text[$i][] = Report::sanitize($report->convertEncoding(sprintf(
189-
'%sindex.php?action=faq&amp;cat=%d&amp;id=%d&amp;artlang=%s',
190+
'%scontent/%d/%d/%s/%s.html',
190191
$this->configuration->getDefaultUrl(),
191192
$reportData['category_id'],
192193
$reportData['faq_id'],
193194
$reportData['faq_language'],
195+
TitleSlugifier::slug($reportData['faq_question']),
194196
)));
195197
}
196198

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
use phpMyFAQ\Instance\Search\OpenSearch;
4343
use phpMyFAQ\Language;
4444
use phpMyFAQ\Link;
45+
use phpMyFAQ\Link\Util\TitleSlugifier;
4546
use phpMyFAQ\Search;
4647
use phpMyFAQ\Search\SearchResultSet;
4748
use phpMyFAQ\Session\Token;
@@ -199,11 +200,12 @@ public function create(Request $request): JsonResponse
199200
}
200201

201202
$url = sprintf(
202-
'%s?action=faq&cat=%d&id=%d&artlang=%s',
203+
'%scontent/%d/%d/%s/%s.html',
203204
$this->configuration->getDefaultUrl(),
204205
$categories[0],
205206
$faqData->getId(),
206207
$faqData->getLanguage(),
208+
TitleSlugifier::slug($faqData->getQuestion()),
207209
);
208210
$oLink = new Link($url, $this->configuration);
209211

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,12 @@ public function edit(Request $request): Response
9191
{
9292
$this->userHasPermission(PermissionType::NEWS_ADD);
9393

94-
$newsId = (int) Filter::filterVar($request->request->get('newsId'), FILTER_VALIDATE_INT);
94+
$newsId = (int) Filter::filterVar($request->attributes->get('newsId'), FILTER_VALIDATE_INT);
9595

9696
$news = $this->container->get(id: 'phpmyfaq.news');
9797
$comment = $this->container->get(id: 'phpmyfaq.comments');
9898
$newsData = $news->get($newsId, true);
9999

100-
$comments = $comment->getCommentsData($newsId, CommentType::NEWS);
101-
102100
$this->addExtension(new AttributeExtension(IsoDateTwigExtension::class));
103101
$this->addExtension(new AttributeExtension(FormatDateTwigExtension::class));
104102
return $this->render('@admin/content/news.edit.twig', [
@@ -109,7 +107,6 @@ public function edit(Request $request): Response
109107
'newsDataContent' => isset($newsData['content'])
110108
? htmlspecialchars((string) $newsData['content'], ENT_QUOTES)
111109
: '',
112-
'comments' => $comments,
113110
'newsId' => $newsId,
114111
'commentTypeNews' => CommentType::NEWS,
115112
]);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,12 @@ public function show(Request $request): Response
268268
$languageUrls = [];
269269
foreach ($availableLanguages as $language) {
270270
$url = sprintf(
271-
'%sindex.php?action=faq&cat=%d&id=%d&artlang=%s',
271+
'%scontent/%d/%d/%s/%s.html',
272272
$this->configuration->getDefaultUrl(),
273273
$cat,
274274
$faqId,
275275
$language,
276+
TitleSlugifier::slug($question),
276277
);
277278
$link = new Link($url, $this->configuration);
278279
$link->setTitle($question);

phpmyfaq/src/phpMyFAQ/Notification.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use phpMyFAQ\Entity\Comment;
2323
use phpMyFAQ\Entity\FaqEntity;
2424
use phpMyFAQ\Entity\QuestionEntity;
25+
use phpMyFAQ\Link\Util\TitleSlugifier;
2526
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
2627

2728
/**
@@ -148,13 +149,13 @@ public function sendFaqCommentNotification(Faq $faq, Comment $comment): void
148149

149150
$title = $faq->faqRecord['title'];
150151

151-
$url = '%sindex.php?action=faq&cat=%d&id=%d&artlang=%s';
152152
$faqUrl = sprintf(
153-
$url,
153+
'%scontent/%d/%d/%s/%s.html',
154154
$this->configuration->getDefaultUrl(),
155155
$category->getCategoryIdFromFaq((int) $faq->faqRecord['id']),
156156
$faq->faqRecord['id'],
157157
$faq->faqRecord['lang'],
158+
TitleSlugifier::slug($title),
158159
);
159160
$link = new Link($faqUrl, $this->configuration);
160161
$link->setTitle($title);
@@ -217,8 +218,13 @@ public function sendNewsCommentNotification(array $newsData, Comment $comment):
217218

218219
$title = $newsData['header'];
219220

220-
$url = '%sindex.php?action=news&newsid=%d&newslang=%s';
221-
$newsUrl = sprintf($url, $this->configuration->getDefaultUrl(), $newsData['id'], $newsData['lang']);
221+
$newsUrl = sprintf(
222+
'%news/%d/%s/%s.html',
223+
$this->configuration->getDefaultUrl(),
224+
$newsData['id'],
225+
$newsData['lang'],
226+
TitleSlugifier::slug($title),
227+
);
222228
$link = new Link($newsUrl, $this->configuration);
223229
$link->setTitle($newsData['header']);
224230

0 commit comments

Comments
 (0)