Skip to content

Commit a05b76c

Browse files
committed
Merge branch '4.0' into 'main'
2 parents 6d0abd1 + 652bca9 commit a05b76c

File tree

16 files changed

+44
-85
lines changed

16 files changed

+44
-85
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This is a log of major user-visible changes in each phpMyFAQ release.
2121

2222
### phpMyFAQ v4.0.7 - unreleased
2323

24+
- updated third party dependencies (Thorsten)
2425
- fixed bugs (Thorsten)
2526

2627
### phpMyFAQ v4.0.6 - 2025-02-23

phpmyfaq/assets/templates/default/faq.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
</li>
5959
<li class="list-group-item bg-transparent">
6060
<i aria-hidden="true" class="bi bi-person"></i>
61-
<span class="data" rel="author">{{ faqAuthor }}</span>
61+
<span class="data" rel="author">{{ faqAuthor | raw }}</span>
6262
</li>
6363
<li class="list-group-item bg-transparent">
6464
<i aria-hidden="true" class="bi bi-calendar-date"></i>

phpmyfaq/assets/templates/default/search.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@
5656
<ul class="phpmyfaq-search-results list-unstyled">
5757
{% for result in searchResults %}
5858
<li class="my-2">
59+
{% if result.renderedScore > 0 %}
5960
{{ result.renderedScore | raw }}
61+
{% endif %}
6062
<strong>{{ result.path }}</strong><br>
6163
<i class="bi bi-question-circle-o"></i>
6264
<a title="Test" href="{{ result.url }}">{{ result.question | raw }}</a>

phpmyfaq/content/core/config/constants_elasticsearch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
'fa' => 'english', // NOT SUPPORTED BY ELASTICSEARCH
5959
'fi' => 'finnish',
6060
'fr' => 'light_french',
61-
'fr-ca' => 'light_french',
61+
'fr_ca' => 'light_french',
6262
'ga' => 'irish',
6363
'he' => 'english', // NOT SUPPORTED BY ELASTICSEARCH
6464
'hi' => 'hindi',
@@ -74,7 +74,7 @@
7474
'nl' => 'dutch',
7575
'pl' => 'english', // NOT SUPPORTED BY ELASTICSEARCH
7676
'pt' => 'light_portuguese',
77-
'pt-br' => 'brazilian',
77+
'pt_br' => 'brazilian',
7878
'ro' => 'romanian',
7979
'ru' => 'russian',
8080
'sk' => 'english', // NOT SUPPORTED BY ELASTICSEARCH

phpmyfaq/search.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@
145145
}
146146
}
147147

148-
$searchResult = $faq->renderFaqsByFaqIds($recordIds);
148+
$searchResults = $faq->renderFaqsByFaqIds($recordIds);
149+
$numOfResults = count($recordIds);
149150
}
150151
} else {
151152
$searchResult = '';
@@ -198,7 +199,9 @@
198199
$faqSession->userTracking('fulltext_search', $inputSearchTerm);
199200

200201
// Number of results
201-
$numOfResults = $faqSearchResult->getNumberOfResults();
202+
if ($numOfResults === 0) {
203+
$numOfResults = $faqSearchResult->getNumberOfResults();
204+
}
202205

203206
if (
204207
is_numeric($inputSearchTerm) &&
@@ -246,9 +249,7 @@
246249
$searchHelper->setPlurals(new Plurals());
247250
$searchHelper->setSessionId($sids);
248251

249-
$searchResults = [];
250-
251-
if ('' == $searchResult && !is_null($inputSearchTerm)) {
252+
if (empty($searchResults) && !is_null($inputSearchTerm)) {
252253
try {
253254
$searchResults = $searchHelper->getSearchResult($faqSearchResult, $page);
254255
} catch (Exception) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public function update(Request $request): JsonResponse
320320
$logging->log($this->currentUser, 'admin-publish-existing-faq ' . $faqId);
321321
}
322322

323-
if ('yes' === $revision || $this->configuration->get('records.enableAutoRevisions')) {
323+
if ('yes' === $revision && $this->configuration->get('records.enableAutoRevisions')) {
324324
$faqRevision = new Revision($this->configuration);
325325
$faqRevision->create($faqId, $faqLang);
326326
++$revisionId;

phpmyfaq/src/phpMyFAQ/Faq.php

Lines changed: 21 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use phpMyFAQ\Helper\FaqHelper;
3131
use phpMyFAQ\Instance\Elasticsearch;
3232
use phpMyFAQ\Language\Plurals;
33+
use stdClass;
3334

3435
/*
3536
* Query type definitions
@@ -454,18 +455,15 @@ public function renderFaqsByCategoryId(int $categoryId, string $orderBy = 'id',
454455
/**
455456
* This function returns all not expired records from the given record ids.
456457
*
457-
* @param int[] $faqIds Array of record ids
458+
* @param int[] $faqIds Array of record ids
458459
* @param string $orderBy Order by
459-
* @param string $sortBy Sort by
460+
* @param string $sortBy Sort by
461+
* @throws CommonMarkException
460462
*/
461-
public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', string $sortBy = 'ASC'): string
463+
public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', string $sortBy = 'ASC'): array
462464
{
463-
global $sids;
464-
465465
$records = implode(', ', $faqIds);
466466
$page = Filter::filterInput(INPUT_GET, 'seite', FILTER_VALIDATE_INT, 1);
467-
$taggingId = Filter::filterInput(INPUT_GET, 'tagging_id', FILTER_VALIDATE_INT);
468-
$output = '';
469467

470468
$now = date('YmdHis');
471469
$queryHelper = new QueryHelper($this->user, $this->groups);
@@ -474,7 +472,8 @@ public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', str
474472
SELECT
475473
fd.id AS id,
476474
fd.lang AS lang,
477-
fd.thema AS thema,
475+
fd.thema AS question,
476+
fd.content AS answer,
478477
fcr.category_id AS category_id,
479478
fv.visits AS visits
480479
FROM
@@ -530,29 +529,19 @@ public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', str
530529

531530
$num = $this->configuration->getDb()->numRows($result);
532531
$numberPerPage = $this->configuration->get('records.numberOfRecordsPerPage');
533-
$pages = ceil($num / $numberPerPage);
534532

535533
if ($page == 1) {
536534
$first = 0;
537535
} else {
538536
$first = ($page * $numberPerPage) - $numberPerPage;
539537
}
540538

539+
$searchResults = [];
541540
if ($num > 0) {
542-
if ($pages > 1) {
543-
$output .= sprintf(
544-
'<p><strong>%s %s %s</strong></p>',
545-
Translation::get('msgPage') . $page,
546-
Translation::get('msgVoteFrom'),
547-
$pages . Translation::get('msgPages')
548-
);
549-
}
550-
551-
$output .= '<ul class="phpmyfaq_ul">';
552541
$counter = 0;
553542
$displayedCounter = 0;
554-
555543
$lastFaqId = 0;
544+
$faqHelper = new FaqHelper($this->configuration);
556545
while (($row = $this->configuration->getDb()->fetchObject($result)) && $displayedCounter < $numberPerPage) {
557546
++$counter;
558547
if ($counter <= $first) {
@@ -565,68 +554,34 @@ public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', str
565554
continue; // Don't show multiple FAQs
566555
}
567556

568-
$visits = empty($row->visits) ? 0 : $row->visits;
557+
$rowResult = new stdClass();
569558

570-
$title = $row->thema;
559+
$title = $row->question;
571560
$url = sprintf(
572-
'%sindex.php?%saction=faq&amp;cat=%d&amp;id=%d&amp;artlang=%s',
561+
'%sindex.php?action=faq&cat=%d&id=%d&artlang=%s',
573562
$this->configuration->getDefaultUrl(),
574-
$sids,
575563
$row->category_id,
576564
$row->id,
577565
$row->lang
578566
);
567+
579568
$oLink = new Link($url, $this->configuration);
580-
$oLink->itemTitle = $row->thema;
569+
$oLink->itemTitle = $row->question;
581570
$oLink->text = $title;
582571
$oLink->tooltip = $title;
583-
$listItem = sprintf(
584-
'<li>%s<br><small>(%s)</small></li>',
585-
$oLink->toHtmlAnchor(),
586-
$this->plurals->GetMsg('plmsgViews', $visits)
587-
);
588572

589-
$output .= $listItem;
573+
$rowResult->renderedScore = 0;
574+
$rowResult->question = Utils::chopString($title, 15);
575+
$rowResult->path = '';
576+
$rowResult->url = $oLink->toString();
577+
$rowResult->answerPreview = $faqHelper->renderAnswerPreview($row->answer, 20);
590578

591579
$lastFaqId = $row->id;
580+
$searchResults[] = $rowResult;
592581
}
593-
594-
$output .= '</ul><span id="totFaqRecords" style="display: none;">' . $num . '</span>';
595-
} else {
596-
return '';
597-
}
598-
599-
if ($num > $this->configuration->get('records.numberOfRecordsPerPage')) {
600-
$output .= '<p class="text-center"><strong>';
601-
if (!isset($page)) {
602-
$page = 1;
603-
}
604-
605-
$vor = $page - 1;
606-
$next = $page + 1;
607-
if ($vor != 0) {
608-
$url = $sids . '&amp;action=search&amp;tagging_id=' . $taggingId . '&amp;seite=' . $vor;
609-
$oLink = new Link($this->configuration->getDefaultUrl() . '?' . $url, $this->configuration);
610-
$oLink->itemTitle = 'tag';
611-
$oLink->text = Translation::get('msgPrevious');
612-
$oLink->tooltip = Translation::get('msgPrevious');
613-
$output .= '[ ' . $oLink->toHtmlAnchor() . ' ]';
614-
}
615-
616-
$output .= ' ';
617-
if ($next <= $pages) {
618-
$url = $sids . '&amp;action=search&amp;tagging_id=' . $taggingId . '&amp;seite=' . $next;
619-
$oLink = new Link($this->configuration->getDefaultUrl() . '?' . $url, $this->configuration);
620-
$oLink->itemTitle = 'tag';
621-
$oLink->text = Translation::get('msgNext');
622-
$oLink->tooltip = Translation::get('msgNext');
623-
$output .= '[ ' . $oLink->toHtmlAnchor() . ' ]';
624-
}
625-
626-
$output .= '</strong></p>';
627582
}
628583

629-
return $output;
584+
return $searchResults;
630585
}
631586

632587
/**

phpmyfaq/src/phpMyFAQ/Language/Plurals.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private function plural(string $lang, int $n): int
6767
'cy' => ($n == 1) ? 0 : ($n == 2 ? 1 : (($n != 8 && $n != 11) ? 2 : 3)),
6868
'cs' => ($n == 1) ? 0 : (($n >= 2 && $n <= 4) ? 1 : 2),
6969
'da', 'de', 'el', 'en', 'es', 'eu', 'fa', 'fi', 'it', 'nb', 'nl', 'hu', 'pt', 'sv' => $n != 1,
70-
'fr', 'pt-br' => $n > 1,
70+
'fr', 'pt_br' => $n > 1,
7171
'lt' => ($n % 10 == 1 && $n % 100 != 11) ? 0 : ($n % 10 >= 2 && ($n % 100 < 10 || $n % 100 >= 20) ?
7272
1 : 2),
7373
'lv' => ($n % 10 == 1 && $n % 100 != 11) ? 0 : ($n != 0 ? 1 : 2),

phpmyfaq/translations/language_de.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@
11901190
$LANG_CONF['main.enableAutoUpdateHint'] = ['checkbox', 'Automatischer Check neuer Versionen'];
11911191
$PMF_LANG['ad_user_is_superadmin'] = 'Super-Admin';
11921192
$PMF_LANG['ad_user_overwrite_passwd'] = 'Überschreibe Passwort';
1193-
$LANG_CONF['records.enableAutoRevisions'] = ['checkbox', 'Versionierung für jede FAQ-Änderung'];
1193+
$LANG_CONF['records.enableAutoRevisions'] = ['checkbox', 'Erlaube Versionierung für jede FAQ-Änderung'];
11941194
$PMF_LANG['permission::view_faqs'] = 'FAQs lesen';
11951195
$PMF_LANG['permission::view_categories'] = 'Kategorien lesen';
11961196
$PMF_LANG['permission::view_sections'] = 'Bereiche lesen';

phpmyfaq/translations/language_en.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@
11901190
$LANG_CONF['main.enableAutoUpdateHint'] = ['checkbox', 'Automatic check for new versions'];
11911191
$PMF_LANG['ad_user_is_superadmin'] = 'Super-Admin';
11921192
$PMF_LANG['ad_user_overwrite_passwd'] = 'Overwrite password';
1193-
$LANG_CONF['records.enableAutoRevisions'] = ['checkbox', 'Versioning of all FAQ changes'];
1193+
$LANG_CONF['records.enableAutoRevisions'] = ['checkbox', 'Allow versioning of FAQ changes'];
11941194
$PMF_LANG['permission::view_faqs'] = 'View FAQs';
11951195
$PMF_LANG['permission::view_categories'] = 'View categories';
11961196
$PMF_LANG['permission::view_sections'] = 'View sections';

0 commit comments

Comments
 (0)