Skip to content

Commit 4c9d884

Browse files
committed
refactor: migrated open questions page (#3834)
1 parent 028b0d5 commit 4c9d884

File tree

3 files changed

+79
-61
lines changed

3 files changed

+79
-61
lines changed

phpmyfaq/open-questions.php

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
/**
4+
* Open Questions Controller
5+
*
6+
* This Source Code Form is subject to the terms of the Mozilla Public License,
7+
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
8+
* obtain one at https://mozilla.org/MPL/2.0/.
9+
*
10+
* @package phpMyFAQ
11+
* @author Thorsten Rinne <[email protected]>
12+
* @copyright 2002-2026 phpMyFAQ Team
13+
* @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14+
* @link https://www.phpmyfaq.de
15+
* @since 2002-09-17
16+
*/
17+
18+
declare(strict_types=1);
19+
20+
namespace phpMyFAQ\Controller\Frontend;
21+
22+
use phpMyFAQ\Category;
23+
use phpMyFAQ\Core\Exception;
24+
use phpMyFAQ\Enums\PermissionType;
25+
use phpMyFAQ\Helper\QuestionHelper;
26+
use phpMyFAQ\Translation;
27+
use Symfony\Component\HttpFoundation\Request;
28+
use Symfony\Component\HttpFoundation\Response;
29+
use Symfony\Component\Routing\Attribute\Route;
30+
31+
final class OpenQuestionsController extends AbstractFrontController
32+
{
33+
/**
34+
* Displays the open questions page.
35+
*
36+
* @throws Exception
37+
* @throws \Exception
38+
*/
39+
#[Route(path: '/open-questions.html', name: 'public.open-questions')]
40+
public function index(Request $request): Response
41+
{
42+
$faqSession = $this->container->get('phpmyfaq.user.session');
43+
$faqSession->setCurrentUser($this->currentUser);
44+
$faqSession->userTracking('open_questions', 0);
45+
46+
$category = new Category($this->configuration);
47+
$questionHelper = new QuestionHelper();
48+
$questionHelper->setConfiguration($this->configuration)->setCategory($category);
49+
50+
return $this->render('open-questions.twig', [
51+
...$this->getHeader($request),
52+
'title' => sprintf('%s - %s', Translation::get(key: 'msgOpenQuestions'), $this->configuration->getTitle()),
53+
'metaDescription' => sprintf(
54+
Translation::get(key: 'msgOpenQuestionsMetaDesc'),
55+
$this->configuration->getTitle(),
56+
),
57+
'pageHeader' => Translation::get(key: 'msgOpenQuestions'),
58+
'msgQuestionText' => Translation::get(key: 'msgQuestionText'),
59+
'msgDate_User' => Translation::get(key: 'msgDate_User'),
60+
'msgQuestion2' => Translation::get(key: 'msgQuestion2'),
61+
'openQuestions' => $questionHelper->getOpenQuestions(),
62+
'isCloseQuestionEnabled' => $this->configuration->get('records.enableCloseQuestion'),
63+
'userHasPermissionToAnswer' => $this->currentUser->perm->hasPermission(
64+
$this->currentUser->getUserId(),
65+
PermissionType::FAQ_ADD->value,
66+
),
67+
'msgQuestionsWaiting' => Translation::get(key: 'msgQuestionsWaiting'),
68+
'msgNoQuestionsAvailable' => Translation::get(key: 'msgNoQuestionsAvailable'),
69+
'msg2answerFAQ' => Translation::get(key: 'msg2answerFAQ'),
70+
'msg2answer' => Translation::get(key: 'msg2answer'),
71+
]);
72+
}
73+
}

phpmyfaq/src/public-routes.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use phpMyFAQ\Controller\Frontend\ContactController;
2323
use phpMyFAQ\Controller\Frontend\GlossaryController;
2424
use phpMyFAQ\Controller\Frontend\LoginController;
25+
use phpMyFAQ\Controller\Frontend\OpenQuestionsController;
2526
use phpMyFAQ\Controller\Frontend\OverviewController;
2627
use phpMyFAQ\Controller\Frontend\PageNotFoundController;
2728
use phpMyFAQ\Controller\Frontend\PdfController;
@@ -63,6 +64,11 @@
6364
'controller' => [LoginController::class, 'index'],
6465
'methods' => 'GET|POST',
6566
],
67+
'public.open-questions' => [
68+
'path' => '/open-questions.html',
69+
'controller' => [OpenQuestionsController::class, 'index'],
70+
'methods' => 'GET',
71+
],
6672
'public.overview' => [
6773
'path' => '/overview.html',
6874
'controller' => [OverviewController::class, 'index'],

0 commit comments

Comments
 (0)