Compare commits

...

6 Commits

Author SHA1 Message Date
slawkens
d297e434b8 Add latest clients versions 2023-08-31 14:20:39 +02:00
slawkens
c7966b7c55 Update plugins.php 2023-08-26 07:12:15 +02:00
slawkens
3e12f70861 thanks @elsongabriel, seems str_contains is not available in php 7 2023-08-26 07:11:43 +02:00
slawkens
4aede4c626 Allow hooks to be prefixed with HOOK_ 2023-08-23 11:58:14 +02:00
slawkens
57643bb4aa Patching from develop - twig context for hooks 2023-08-21 12:27:39 +02:00
slawkens
0139e4b446 Update twig.php 2023-08-21 12:20:57 +02:00
3 changed files with 14 additions and 3 deletions

View File

@@ -99,4 +99,10 @@ $config['clients'] = [
1291,
1300,
1310,
1311,
1312,
1316,
1320,
1321,
];

View File

@@ -151,6 +151,10 @@ class Plugins {
foreach(self::getAllPluginsJson() as $plugin) {
if (isset($plugin['hooks'])) {
foreach ($plugin['hooks'] as $_name => $info) {
if (strpos($info['type'], 'HOOK_') !== false) {
$info['type'] = str_replace('HOOK_', '', $info['type']);
}
if (defined('HOOK_'. $info['type'])) {
$hook = constant('HOOK_'. $info['type']);
$hooks[] = ['name' => $_name, 'type' => $hook, 'file' => $info['file']];

View File

@@ -30,7 +30,7 @@ if($dev_mode) {
}
unset($dev_mode);
$filter = new Twig_SimpleFilter('timeago', function ($datetime) {
$filter = new TwigFilter('timeago', function ($datetime) {
$time = time() - strtotime($datetime);
@@ -90,15 +90,16 @@ $function = new TwigFunction('truncate', function ($s, $n) {
});
$twig->addFunction($function);
$function = new TwigFunction('hook', function ($hook, array $params = []) {
$function = new TwigFunction('hook', function ($context, $hook, array $params = []) {
global $hooks;
if(is_string($hook)) {
$hook = constant($hook);
}
$params['context'] = $context;
$hooks->trigger($hook, $params);
});
}, ['needs_context' => true]);
$twig->addFunction($function);
$function = new TwigFunction('config', function ($key) {