]> git.mxchange.org Git - friendica.git/blob - include/friendica_smarty.php
Merge pull request #557 from fermionic/20121224-installer-check-for-smarty3
[friendica.git] / include / friendica_smarty.php
1 <?php
2
3 require_once("library/Smarty/libs/Smarty.class.php");
4
5 class FriendicaSmarty extends Smarty {
6
7         public $filename;
8
9         function __construct() {
10                 parent::__construct();
11
12                 $a = get_app();
13                 $theme = current_theme();
14
15                 // setTemplateDir can be set to an array, which Smarty will parse in order.
16                 // The order is thus very important here
17                 $template_dirs = array('theme' => "view/theme/$theme/smarty3/");
18                 if( x($a->theme_info,"extends") )
19                         $template_dirs = $template_dirs + array('extends' => "view/theme/".$a->theme_info["extends"]."/smarty3/");
20                 $template_dirs = $template_dirs + array('base' => 'view/smarty3/');
21                 $this->setTemplateDir($template_dirs);
22
23                 $this->setCompileDir('view/smarty3/compiled/');
24                 $this->setConfigDir('view/smarty3/config/');
25                 $this->setCacheDir('view/smarty3/cache/');
26
27                 $this->left_delimiter = $a->smarty3_ldelim;
28                 $this->right_delimiter = $a->smarty3_rdelim;
29         }
30
31         function parsed($template = '') {
32                 if($template) {
33                         return $this->fetch('string:' . $template);
34                 }
35                 return $this->fetch('file:' . $this->filename);
36         }
37 }
38
39
40