Example #1
0
 public static function smarty_factory()
 {
     if (!isset($_SERVER['smartybase'])) {
         $_SERVER['smartybase'] = "/var/tmp/smarty-" . md5($_SERVER['SCRIPT_FILENAME']);
     }
     if (!lib::$appvars) {
         lib::$appvars = array('filebase' => $_SERVER['filebase'], 'mediabase' => $_SERVER['mediabase'], 'uribase' => $_SERVER['uribase'], 'urirequest' => $_SERVER['urirequest']);
     }
     $smbase = $_SERVER['smartybase'];
     #@mkdir("$smbase/templates", 0777, true);
     @mkdir("{$smbase}/templates_c", 0777, true);
     @mkdir("{$smbase}/cache", 0777, true);
     $smarty = new Smarty();
     $smarty->template_dir = "./views";
     $smarty->compile_dir = "{$smbase}/templates_c";
     $smarty->cache_dir = "{$smbase}/cache";
     # we don't set config dir, we most likely won't use it initially
     $smext = array('smarty_extensions', 'smarty_custom');
     foreach ($smext as $smo) {
         $mnames = get_class_methods($smo);
         foreach ($mnames as $method) {
             if (preg_match('/^func_(\\w+)$/', $method, $m)) {
                 $smarty->register_function($m[1], array($smo, $method));
             } elseif (preg_match('/^modifier_(\\w+)$/', $method, $m)) {
                 $smarty->register_modifier($m[1], array($smo, $method));
             } elseif (preg_match('/^block_(\\w+)$/', $method, $m)) {
                 $smarty->register_block($m[1], array($smo, $method));
             }
         }
     }
     # these are order dependent
     $smarty->register_prefilter(array('smarty_extensions', 'prefilter_convert_loop_breaks'));
     $smarty->register_prefilter(array('smarty_extensions', 'prefilter_convert_loop_continue'));
     $smarty->assign_by_ref('app', lib::$appvars);
     if (file_exists("setup/template_conf.php")) {
         include "setup/template_conf.php";
     }
     return $smarty;
 }