]> git.mxchange.org Git - friendica.git/blob - include/friendica_smarty.php
Merge pull request #578 from fermionic/20130110-update-smarty-conversion-script
[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->get_template_ldelim('smarty3');
28                 $this->right_delimiter = $a->get_template_rdelim('smarty3');
29
30                 // Don't report errors so verbosely
31                 $this->error_reporting = E_ALL & ~E_NOTICE;
32         }
33
34         function parsed($template = '') {
35                 if($template) {
36                         return $this->fetch('string:' . $template);
37                 }
38                 return $this->fetch('file:' . $this->filename);
39         }
40 }
41
42
43