crawler supports "nofollow" now
[phinde.git] / www / www-header.php
1 <?php
2 namespace phinde;
3 require_once __DIR__ . '/../src/init.php';
4
5 \Twig_Autoloader::register();
6 $GLOBALS['twig'] = new \Twig_Environment(
7     new \Twig_Loader_Filesystem(__DIR__ . '/../data/templates'),
8     array(
9         //'cache' => '/path/to/compilation_cache',
10         'debug' => true
11     )
12 );
13 $GLOBALS['twig']->addExtension(new \Twig_Extension_Debug());
14
15 $twig->addFunction('ellipsis', new \Twig_Function_Function('\phinde\ellipsis'));
16 function ellipsis($text, $maxlength)
17 {
18     if (strlen($text) > $maxlength) {
19         $text = substr($text, 0, $maxlength - 1) . '…';
20     }
21     return $text;
22 }
23
24 function render($tplname, $vars = array(), $return = false)
25 {
26     if (!isset($vars['htmlhelper'])) {
27         //$vars['htmlhelper'] = new HtmlHelper();
28     }
29     $vars['apptitle'] = 'cweiske.de search';
30     $vars['baseurl'] = '/';
31
32     $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
33     if ($return) {
34         return $template->render($vars);
35     } else {
36         echo $template->render($vars);
37     }
38 }
39 ?>