Merge branch 'main' into develop

This commit is contained in:
slawkens
2025-05-09 13:14:12 +02:00
16 changed files with 118 additions and 61 deletions

View File

@@ -37,7 +37,7 @@ class Hook
return !isset($ret) || $ret == 1 || $ret;
}
public function executeFilter(...$args) {
public function executeFilter(&$args) {
return include BASE . $this->_file;
}

View File

@@ -30,16 +30,14 @@ class Hooks
return $ret;
}
public function triggerFilter($type, $args = [])
public function triggerFilter($type, &$args): void
{
if(isset(self::$_hooks[$type])) {
foreach(self::$_hooks[$type] as $hook) {
/** @var Hook $hook */
$args = $hook->executeFilter(...$args);
$hook->executeFilter($args);
}
}
return $args;
}
public function exist($type): bool {

View File

@@ -198,6 +198,9 @@ class Plugins {
}
}
global $hooks;
$hooks->triggerFilter(HOOK_FILTER_ROUTES, $routes);
usort($routes, function ($a, $b)
{
// key 3 is priority

View File

@@ -219,7 +219,7 @@ class Settings implements \ArrayAccess
if ($setting['type'] === 'boolean') {
$value = ($setting['default'] ? 'true' : 'false');
}
else if (in_array($setting['type'], ['text', 'number', 'email', 'password', 'textarea'])) {
else if (in_array($setting['type'], ['text', 'number', 'float', 'double', 'email', 'password', 'textarea'])) {
$value = $setting['default'];
}
else if ($setting['type'] === 'options') {
@@ -245,7 +245,11 @@ class Settings implements \ArrayAccess
$checkbox($key, false, $value);
}
else if (in_array($setting['type'], ['text', 'number', 'email', 'password'])) {
else if (in_array($setting['type'], ['text', 'number', 'float', 'double', 'email', 'password'])) {
if (in_array($setting['type'], ['float', 'double'])) {
$setting['type'] = 'number';
}
if ($setting['type'] === 'number') {
$min = (isset($setting['min']) ? ' min="' . $setting['min'] . '"' : '');
$max = (isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '');
@@ -351,7 +355,7 @@ class Settings implements \ArrayAccess
if ($setting['type'] === 'boolean') {
echo ($setting['default'] ? 'Yes' : 'No');
}
else if (in_array($setting['type'], ['text', 'number', 'email', 'password', 'textarea'])) {
else if (in_array($setting['type'], ['text', 'number', 'float', 'double', 'email', 'password', 'textarea'])) {
echo $setting['default'];
}
else if ($setting['type'] === 'options') {
@@ -498,9 +502,12 @@ class Settings implements \ArrayAccess
break;
case 'number':
if (!isset($ret['step']) || (int)$ret['step'] == 1) {
$ret['value'] = (int)$ret['value'];
}
$ret['value'] = (int)$ret['value'];
break;
case 'double':
case 'float':
$ret['value'] = (double)($ret['value']);
break;
default:

View File

@@ -11,7 +11,7 @@ class EnvironmentBridge extends Environment
global $hooks;
$context['viewName'] = $name;
$context = $hooks->triggerFilter(HOOK_FILTER_TWIG_DISPLAY, $context);
$hooks->triggerFilter(HOOK_FILTER_TWIG_DISPLAY, $context);
parent::display($name, $context);
}
@@ -21,7 +21,7 @@ class EnvironmentBridge extends Environment
global $hooks;
$context['viewName'] = $name;
$context = $hooks->triggerFilter(HOOK_FILTER_TWIG_RENDER, $context);
$hooks->triggerFilter(HOOK_FILTER_TWIG_RENDER, $context);
return parent::render($name, $context);
}

View File

@@ -98,6 +98,7 @@ define('HOOK_INSTALL_FINISH', ++$i);
define('HOOK_INSTALL_FINISH_END', ++$i);
// hook filters
define('HOOK_FILTER_ROUTES', ++$i);
define('HOOK_FILTER_TWIG_DISPLAY', ++$i);
define('HOOK_FILTER_TWIG_RENDER', ++$i);
define('HOOK_FILTER_THEME_FOOTER', ++$i);