Skip to content

Commit

Permalink
refactor: removed usage of old Template class (#2969)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Jul 7, 2024
1 parent 24e0272 commit ecf2d4a
Show file tree
Hide file tree
Showing 47 changed files with 141 additions and 600 deletions.
6 changes: 5 additions & 1 deletion phpmyfaq/404.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/

use phpMyFAQ\Enums\SessionActionType;
use phpMyFAQ\Template\TwigWrapper;
use Twig\Extension\DebugExtension;

if (!defined('IS_VALID_PHPMYFAQ')) {
http_response_code(400);
Expand All @@ -24,4 +26,6 @@

$faqSession->userTracking(SessionActionType::NOT_FOUND->value, 0);

$template->parse('mainPageContent', []);
$twig = new TwigWrapper(PMF_ROOT_DIR . '/assets/templates');
$twig->addExtension(new DebugExtension());
$twigTemplate = $twig->loadTemplate('./404.twig');
6 changes: 2 additions & 4 deletions phpmyfaq/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@

// Twig template variables
$templateVars = [
... $templateVars,
'baseHref' => $faqSystem->getSystemUri($faqConfig),
'msgNewContentHeader' => Translation::get('msgNewContentHeader'),
'msgNewContentAddon' => Translation::get('msgNewContentAddon'),
Expand Down Expand Up @@ -140,7 +141,4 @@
];
}

$template->addRenderedTwigOutput(
'mainPageContent',
$twigTemplate->render($templateVars)
);
return $templateVars;
6 changes: 2 additions & 4 deletions phpmyfaq/ask.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
$twigTemplate = $twig->loadTemplate('./ask.twig');

$templateVars = [
... $templateVars,
'baseHref' => $faqSystem->getSystemUri($faqConfig),
'msgMatchingQuestions' => Translation::get('msgMatchingQuestions'),
'msgFinishSubmission' => Translation::get('msgFinishSubmission'),
Expand Down Expand Up @@ -90,7 +91,4 @@
}
}

$template->addRenderedTwigOutput(
'mainPageContent',
$twigTemplate->render($templateVars)
);
return $templateVars;
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/add.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">
{% if noCategories == true %}
<div class="alert alert-danger">{{ msgFormDisabledDueToMissingCategories|raw }}</div>
Expand Down Expand Up @@ -109,3 +112,5 @@
<script src="{{ baseHref }}admin/assets/js/editor/tinymce.min.js?{{ currentTimestamp }}"></script>
{% endif %}
{% endif %}

{% endblock %}
4 changes: 4 additions & 0 deletions phpmyfaq/assets/templates/ask.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">
{% if noCategories == true %}
<div class="alert alert-danger">{{ msgFormDisabledDueToMissingCategories|raw }}</div>
Expand Down Expand Up @@ -76,3 +79,4 @@
</form>
{% endif %}
</section>
{% endblock %}
4 changes: 4 additions & 0 deletions phpmyfaq/assets/templates/attachment.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{% extends 'index.twig' %}

{% block content %}
{% if attachmentErrors %}
<section>
{% for item in attachmentErrors %}
<li>{{ item }}</li>
{% endfor %}
</section>
{% endif %}
{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/bookmarks.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<!-- @todo Toasts -> have to be moved to header and footer.twig --->
<div class="toast-container position-fixed top-0 start-50 translate-middle-x mt-5 p-3">
<div id="pmf-notification" class="toast align-items-center text-bg-primary shadow border-0" role="alert"
Expand Down Expand Up @@ -59,3 +62,5 @@

</div>
</div>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/contact.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">
<h1>{{ pageHeader }}</h1>
<p>{{ msgContactOwnText|raw }}</p>
Expand Down Expand Up @@ -65,3 +68,5 @@
</div>
<!-- PLEASE DO NOT REMOVE THE COPYRIGHT NOTICE - THANK YOU -->
</section>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/faq.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<!-- @todo Toasts -> have to be moved to header and footer.twig --->
<div class="toast-container position-fixed top-0 start-50 translate-middle-x mt-5 p-3">
<div id="pmf-notification" class="toast align-items-center text-bg-primary shadow border-0" role="alert"
Expand Down Expand Up @@ -229,3 +232,5 @@
</div>
</div>
</div>
{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/glossary.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">
<h1>{{ pageHeader }}</h1>
<article>
Expand All @@ -15,3 +18,5 @@
</div>
</div>
</section>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/login.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<div class="col-12">
{% if useSslForLogins %}
<p>
Expand Down Expand Up @@ -79,3 +82,5 @@
</div>
</div>
</div>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/news.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<div class="row g-5">
<div class="col-md-8">
<h2 class="pb-4 mb-4 border-bottom">{{ newsHeader }}</h2>
Expand Down Expand Up @@ -70,3 +73,5 @@
</div>
</div>
</div>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/open-questions.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">
<h1>{{ pageHeader }}</h1>
<p>{{ msgQuestionText }}</p>
Expand Down Expand Up @@ -48,3 +51,5 @@
{% endif %}
</table>
</section>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/overview.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">
<h1>{{ pageHeader }}</h1>

Expand Down Expand Up @@ -27,3 +30,5 @@
{% set lastCategory = faq['category_id'] %}
{% endfor %}
</section>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/password.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">

<div class="row mb-2">
Expand Down Expand Up @@ -48,3 +51,5 @@
</div>

</section>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/register.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">
<h1>{{ pageHeader }}</h1>
<p>{{ msgRegistrationCredentials }} {{ msgRegistrationNote }}</p>
Expand Down Expand Up @@ -55,3 +58,5 @@
</div>
</form>
</section>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/request-removal.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">
<h1>{{ pageHeader }}</h1>
<p>{{ msgUserRemovalText }}</p>
Expand Down Expand Up @@ -88,3 +91,5 @@
</div>
</form>
</section>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/search.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<div class="row g-5">
<div class="col-md-8">
<h2 class="pb-4 mb-4 border-bottom">{{ pageHeader }}</h2>
Expand Down Expand Up @@ -116,3 +119,5 @@
</div>
</div>
</div>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/share-by-email.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">
<div class="row mb-2">
<div class="col">
Expand Down Expand Up @@ -89,3 +92,5 @@
</div>
</form>
</section>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/show.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<div class="row g-5">
<div class="col-md-8">
<h2 class="pb-4 mb-4 border-bottom">{{ categoryHeader }}</h2>
Expand Down Expand Up @@ -26,3 +29,5 @@
</div>
</div>
</div>

{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/sitemap.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<section class="col-12">
<h1>{{ pageHeader }}</h1>

Expand All @@ -18,3 +21,5 @@
{% endfor %}
</ul>
</section>

{% endblock %}
2 changes: 1 addition & 1 deletion phpmyfaq/assets/templates/startpage.twig
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@
</div>
</div>

{% endblock content %}
{% endblock %}
5 changes: 5 additions & 0 deletions phpmyfaq/assets/templates/ucp.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% extends 'index.twig' %}

{% block content %}
<div class="row">
<div class="col-4 pmf-personal-gravatar">
<div class="card shadow mb-4">
Expand Down Expand Up @@ -225,3 +228,5 @@
</div>
</div>
</div>

{% endblock %}
Loading

0 comments on commit ecf2d4a

Please sign in to comment.