-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrated sticky FAQs page to controller (#3257)
- Loading branch information
Showing
11 changed files
with
101 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{% extends '@admin/index.twig' %} | ||
|
||
{% block content %} | ||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> | ||
<h1 class="h2"> | ||
<i aria-hidden="true" class="bi bi-star"></i> {{ stickyFAQsHeader }} | ||
</h1> | ||
</div> | ||
|
||
{% if orderingStickyFaqsActivated == false %} | ||
<div class="alert alert-warning alert-dismissible fade show">{{ alertMessageStickyFaqsDeactivated | raw }} | ||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> | ||
</div> | ||
{% endif %} | ||
|
||
{% if stickyData is empty %} | ||
<div class="alert alert-danger alert-dismissible fade show">{{ alertMessageNoStickyRecords | raw }} | ||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> | ||
</div> | ||
{% endif %} | ||
|
||
{% if orderingStickyFaqsActivated != false %} | ||
<div class="card shadow mt-5 ml-5" id="mainCardStickyFAQs"> | ||
<div class="card-body"> | ||
<ul class="list-group list-group-numbered {{ sortableDisabled }}" id="stickyFAQs" data-csrf="{{ csrfToken }}"> | ||
{% for faq in stickyData %} | ||
<li class="list-group-item" data-pmf-faqid="{{ faq.id|e }}"> | ||
<a href="{{ faq.url|e }}">{{ faq.question|e }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> | ||
{% endif %} | ||
{% endblock %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
phpmyfaq/src/phpMyFAQ/Controller/Administration/StickyFaqsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace phpMyFAQ\Controller\Administration; | ||
|
||
use phpMyFAQ\Core\Exception; | ||
use phpMyFAQ\Enums\PermissionType; | ||
use phpMyFAQ\Session\Token; | ||
use phpMyFAQ\Translation; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Twig\Error\LoaderError; | ||
|
||
class StickyFaqsController extends AbstractAdministrationController | ||
{ | ||
/** | ||
* @throws Exception | ||
* @throws LoaderError | ||
* @throws \Exception | ||
*/ | ||
#[Route('/sticky-faqs')] | ||
public function index(Request $request): Response | ||
{ | ||
$this->userHasPermission(PermissionType::FAQ_EDIT); | ||
|
||
$customOrdering = $this->configuration->get('records.orderStickyFaqsCustom'); | ||
|
||
return $this->render( | ||
'@admin/content/sticky-faqs.twig', | ||
[ | ||
... $this->getHeader($request), | ||
... $this->getFooter(), | ||
'stickyFAQsHeader' => Translation::get('stickyRecordsHeader'), | ||
'stickyData' => $this->container->get('phpmyfaq.faq')->getStickyFaqsData(), | ||
'sortableDisabled' => ($customOrdering === false) ? 'sortable-disabled' : '', | ||
'orderingStickyFaqsActivated' => $this->configuration->get('records.orderStickyFaqsCustom'), | ||
'alertMessageStickyFaqsDeactivated' => Translation::get('msgOrderStickyFaqsCustomDeactivated'), | ||
'alertMessageNoStickyRecords' => Translation::get('msgNoStickyFaqs'), | ||
'csrfToken' => Token::getInstance($this->container->get('session'))->getTokenString('order-stickyfaqs') | ||
] | ||
); | ||
} | ||
} |