myaac/system/twig.php
Lee 8e6bc73ca6 Creature page overhaul
Updates the creature pages to show more information.
You will need to reload your creatures.
-modifies database with migration 31
-small customisations are allowed via config file.
-functions added, getMonsterLink, getItemRarity, getCreatureImgPath, left, right,
-added functions to twig.
-view elements, immunities, summons, voices, loot, pushables, canpush, canwalk, runonhealth,hostile,attackable,rewardboss,defense,armor
-filter bosses
-show list as picture preview or names list
2020-12-28 16:37:03 +00:00

85 lines
2.0 KiB
PHP

<?php
use Twig\Environment as Twig_Environment;
use Twig\Extension\DebugExtension as Twig_DebugExtension;
use Twig\Loader\FilesystemLoader as Twig_FilesystemLoader;
use Twig\TwigFilter;
use Twig\TwigFunction;
$dev_mode = (config('env') === 'dev');
$twig_loader = new Twig_FilesystemLoader(SYSTEM . 'templates');
$twig = new Twig_Environment($twig_loader, array(
'cache' => CACHE . 'twig/',
'auto_reload' => $dev_mode,
'debug' => $dev_mode
));
if($dev_mode) {
$twig->addExtension(new Twig_DebugExtension());
}
unset($dev_mode);
$function = new TwigFunction('getStyle', function ($i) {
return getStyle($i);
});
$twig->addFunction($function);
$function = new TwigFunction('getCreatureImgPath', function ($i) {
return getCreatureImgPath($i);
});
$twig->addFunction($function);
$function = new TwigFunction('getLink', function ($s) {
return getLink($s);
});
$twig->addFunction($function);
$function = new TwigFunction('generateLink', function ($s, $n, $b = false) {
return generateLink($s, $n, $b);
});
$twig->addFunction($function);
$function = new TwigFunction('getPlayerLink', function ($s, $p) {
return getPlayerLink($s, $p);
});
$twig->addFunction($function);
$function = new TwigFunction('getMonsterLink', function ($s, $p) {
return getMonsterLink($s, $p);
});
$twig->addFunction($function);
$function = new TwigFunction('getGuildLink', function ($s, $p) {
return getGuildLink($s, $p);
});
$twig->addFunction($function);
$function = new TwigFunction('hook', function ($hook) {
global $hooks;
if(is_string($hook)) {
$hook = constant($hook);
}
$hooks->trigger($hook);
});
$twig->addFunction($function);
$function = new TwigFunction('config', function ($key) {
return config($key);
});
$twig->addFunction($function);
$function = new TwigFunction('getCustomPage', function ($name) {
$success = false;
return getCustomPage($name, $success);
});
$twig->addFunction($function);
$filter = new TwigFilter('urlencode', function ($s) {
return urlencode($s);
});
$twig->addFilter($filter);
unset($function, $filter);