Support: Add ability to modify FAQ

This commit is contained in:
Maxim Leshchenko 2022-05-21 10:04:33 +01:00
parent f8c0071227
commit 91d852e071
No known key found for this signature in database
GPG key ID: BB9C44A8733FBEEE
6 changed files with 42 additions and 9 deletions

View file

@ -28,6 +28,41 @@ final class SupportPresenter extends OpenVKPresenter
$this->assertUserLoggedIn();
$this->template->mode = in_array($this->queryParam("act"), ["faq", "new", "list"]) ? $this->queryParam("act") : "faq";
if($this->template->mode === "faq") {
$lang = Session::i()->get("lang", "ru");
$base = OPENVK_ROOT . "/data/knowledgebase/faq";
if(file_exists("$base.$lang.md"))
$file = "$base.$lang.md";
else if(file_exists("$base.md"))
$file = "$base.md";
else
$file = NULL;
if(is_null($file)) {
$this->template->faq = [];
} else {
$lines = file($file);
$faq = [];
$index = 0;
foreach($lines as $line) {
if(strpos($line, "# ") === 0)
++$index;
$faq[$index][] = $line;
}
$this->template->faq = array_map(function($section) {
$title = substr($section[0], 2);
array_shift($section);
return [
$title,
(new Parsedown())->text(implode("\n", $section))
];
}, $faq);
}
}
$this->template->count = $this->tickets->getTicketsCountByUserId($this->user->id);
if($this->template->mode === "list") {
$this->template->page = (int) ($this->queryParam("p") ?? 1);

View file

@ -51,9 +51,9 @@
{if $isMain}
<h4>{_support_faq}</h4><br />
<div class="faq">
<div id="faqhead">{_support_faq_title}</div>
<div id="faqcontent">{_support_faq_content}</div>
<div n:foreach="$faq as $section" class="faq">
<div id="faqhead">{$section[0]}</div>
<div id="faqcontent">{$section[1]|noescape}</div>
</div>
{/if}

View file

@ -0,0 +1,2 @@
# Who is this website for?
The site is designed to find friends and acquaintances, as well as view user data. It is like a city directory, through which people can quickly find relevant information about a person.

View file

@ -0,0 +1,2 @@
# Для кого этот сайт?
Сайт предназначен для поиска друзей и знакомых, а также для просмотра данных пользователя. Это как справочник города, с помощью которого люди могут быстро найти актуальную информацию о человеке.

View file

@ -665,9 +665,6 @@
"support_list" = "List of tickets";
"support_new" = "New ticket";
"support_faq_title" = "Who is this website for?";
"support_faq_content" = "The site is designed to find friends and acquaintances, as well as view user data. It is like a city directory, through which people can quickly find relevant information about a person.";
"support_new_title" = "Enter the topic of your ticket";
"support_new_content" = "Describe the issue or suggestion";

View file

@ -702,9 +702,6 @@
"support_list" = "Список обращений";
"support_new" = "Новое обращение";
"support_faq_title" = "Для кого этот сайт?";
"support_faq_content" = "Сайт предназначен для поиска друзей и знакомых, а также для просмотра данных пользователя. Это как справочник города, с помощью которого люди могут быстро найти актуальную информацию о человеке.";
"support_new_title" = "Введите тему вашего обращения";
"support_new_content" = "Опишите проблему или предложение";