mirror of
https://github.com/slawkens/myaac.git
synced 2026-02-06 13:16:22 +01:00
Merge branch 'main' into develop
This commit is contained in:
@@ -23,7 +23,6 @@ use MyAAC\News;
|
||||
use MyAAC\Plugins;
|
||||
use MyAAC\Settings;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use Twig\Loader\ArrayLoader as Twig_ArrayLoader;
|
||||
|
||||
function message($message, $type, $return)
|
||||
{
|
||||
@@ -1463,17 +1462,7 @@ function getCustomPage($name, &$success): string
|
||||
ob_end_clean();
|
||||
}
|
||||
else {
|
||||
$oldLoader = $twig->getLoader();
|
||||
|
||||
$twig_loader_array = new Twig_ArrayLoader(array(
|
||||
'content.html' => $page['body']
|
||||
));
|
||||
|
||||
$twig->setLoader($twig_loader_array);
|
||||
|
||||
$content .= $twig->render('content.html');
|
||||
|
||||
$twig->setLoader($oldLoader);
|
||||
$content .= $twig->renderInline($page['body']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace MyAAC\Twig;
|
||||
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ArrayLoader as Twig_ArrayLoader;
|
||||
|
||||
class EnvironmentBridge extends Environment
|
||||
{
|
||||
@@ -25,4 +26,21 @@ class EnvironmentBridge extends Environment
|
||||
|
||||
return parent::render($name, $context);
|
||||
}
|
||||
|
||||
public function renderInline($content, array $context = []): string
|
||||
{
|
||||
$oldLoader = $this->getLoader();
|
||||
|
||||
$twig_loader_array = new Twig_ArrayLoader(array(
|
||||
'content.html' => $content
|
||||
));
|
||||
|
||||
$this->setLoader($twig_loader_array);
|
||||
|
||||
$ret = $this->render('content.html', $context);
|
||||
|
||||
$this->setLoader($oldLoader);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,21 +37,31 @@
|
||||
{% for key, value in settings %}
|
||||
{% if value.show_if is defined %}
|
||||
$(function () {
|
||||
$('input[name="settings[{{ value.show_if[0] }}]"]').change(function () {
|
||||
{% set inputType = 'input' %}
|
||||
|
||||
{% if settings[value.show_if[0]]['type'] == 'options' %}
|
||||
{% set inputType = 'select' %}
|
||||
{% endif %}
|
||||
|
||||
$('{{ inputType }}[name="settings[{{ value.show_if[0] }}]"]').change(function () {
|
||||
performChecks_{{ key }}(this);
|
||||
});
|
||||
|
||||
{% if settings[value.show_if[0]]['type'] == 'boolean' %}
|
||||
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]:checked');
|
||||
{% else %}
|
||||
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]');
|
||||
performChecks_{{ key }}('{{ inputType }}[name="settings[{{ value.show_if[0] }}]"]');
|
||||
{% endif %}
|
||||
});
|
||||
|
||||
function performChecks_{{ key }}(el)
|
||||
{
|
||||
let success = false;
|
||||
|
||||
let thisVal = $(el).val();
|
||||
{% if settings[value.show_if[0]]['type'] == 'options' %}
|
||||
thisVal = $(el).find(":selected").val();
|
||||
{% endif %}
|
||||
|
||||
let operator = '{{ value.show_if[1]|raw }}';
|
||||
if (operator === '>') {
|
||||
|
||||
Reference in New Issue
Block a user