mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-27 17:59:22 +02:00
* move Twig functions to separate file
This commit is contained in:
parent
b714bf4abe
commit
6158d81b5e
@ -32,36 +32,7 @@ require_once SYSTEM . 'libs/cache.php';
|
|||||||
$cache = Cache::getInstance($config['cache_engine'], $config['cache_prefix']);
|
$cache = Cache::getInstance($config['cache_engine'], $config['cache_prefix']);
|
||||||
|
|
||||||
// twig
|
// twig
|
||||||
require_once LIBS . 'Twig/Autoloader.php';
|
require_once SYSTEM . 'twig.php';
|
||||||
Twig_Autoloader::register();
|
|
||||||
|
|
||||||
$twig_loader = new Twig_Loader_Filesystem(SYSTEM . 'templates');
|
|
||||||
$twig = new Twig_Environment($twig_loader, array(
|
|
||||||
'cache' => CACHE . 'twig/',
|
|
||||||
'auto_reload' => true,
|
|
||||||
//'debug' => true
|
|
||||||
));
|
|
||||||
|
|
||||||
$function = new Twig_SimpleFunction('getStyle', function ($i) {
|
|
||||||
return getStyle($i);
|
|
||||||
});
|
|
||||||
$twig->addFunction($function);
|
|
||||||
|
|
||||||
$function = new Twig_SimpleFunction('getLink', function ($s) {
|
|
||||||
return getLink($s);
|
|
||||||
});
|
|
||||||
$twig->addFunction($function);
|
|
||||||
|
|
||||||
$function = new Twig_SimpleFunction('hook', function ($hook) {
|
|
||||||
global $hooks;
|
|
||||||
$hooks->trigger($hook);
|
|
||||||
});
|
|
||||||
$twig->addFunction($function);
|
|
||||||
|
|
||||||
$filter = new Twig_SimpleFilter('urlencode', function ($s) {
|
|
||||||
return urlencode($s);
|
|
||||||
});
|
|
||||||
$twig->addFilter($filter);
|
|
||||||
|
|
||||||
// trim values we receive
|
// trim values we receive
|
||||||
if(isset($_POST))
|
if(isset($_POST))
|
||||||
|
32
system/twig.php
Normal file
32
system/twig.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once LIBS . 'Twig/Autoloader.php';
|
||||||
|
Twig_Autoloader::register();
|
||||||
|
|
||||||
|
$twig_loader = new Twig_Loader_Filesystem(SYSTEM . 'templates');
|
||||||
|
$twig = new Twig_Environment($twig_loader, array(
|
||||||
|
'cache' => CACHE . 'twig/',
|
||||||
|
'auto_reload' => true,
|
||||||
|
//'debug' => true
|
||||||
|
));
|
||||||
|
|
||||||
|
$function = new Twig_SimpleFunction('getStyle', function ($i) {
|
||||||
|
return getStyle($i);
|
||||||
|
});
|
||||||
|
$twig->addFunction($function);
|
||||||
|
|
||||||
|
$function = new Twig_SimpleFunction('getLink', function ($s) {
|
||||||
|
return getLink($s);
|
||||||
|
});
|
||||||
|
$twig->addFunction($function);
|
||||||
|
|
||||||
|
$function = new Twig_SimpleFunction('hook', function ($hook) {
|
||||||
|
global $hooks;
|
||||||
|
$hooks->trigger($hook);
|
||||||
|
});
|
||||||
|
$twig->addFunction($function);
|
||||||
|
|
||||||
|
$filter = new Twig_SimpleFilter('urlencode', function ($s) {
|
||||||
|
return urlencode($s);
|
||||||
|
});
|
||||||
|
$twig->addFilter($filter);
|
Loading…
x
Reference in New Issue
Block a user