caching = 0; $smarty->compile_dir = $templates_compiledir; //$smarty->error_reporting = 0; return $smarty; } public static function registerResources($smarty) { $smarty->register_resource("fromstr", array( array('MG_SMS_SmartyHelper','fromstr_template'), array('MG_SMS_SmartyHelper','fromstr_timestamp'), array('MG_SMS_SmartyHelper','fromstr_secure'), array('MG_SMS_SmartyHelper','fromstr_trusted'), ) ); } public static function fromstr_template($tpl_name, &$tpl_source, &$smarty_obj) { $tpl_source = $smarty_obj->get_template_vars($tpl_name); return empty($tpl_source)?false:true; } public static function fromstr_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) { $tpl_timestamp = time(); return true; } public static function fromstr_secure($tpl_name, &$smarty_obj) { return true; } public static function fromstr_trusted($tpl_name, &$smarty_obj) { } public static function fetchFromString($string,$data=false) { $smarty = self::getSmarty(); self::registerResources($smarty); if(is_array($data)) { foreach($data as $key => $value) { $smarty->assign($key, $value); } } $uid = uniqid(); //caching prevent $smarty->assign($uid, $string); if(WHMCS6) return $smarty->fetch('string:'.$string, $uid); else return $smarty->fetch('fromstr:'.$uid); } }