getSmarty(); } return self::$_object; } public static function setTemplate($template) { self::$_template = $template; } public static function setTemplateName($templateName = 'template') { self::$_templateName = $templateName; } public static function render($data) { self::_checkTemplate(); self::getObject()->register_resource(self::$_resourceName, [self::getInstance(), "getTemplate", "getTimestamp", "getSecure", "getTrusted"]); self::_assignVariables($data); $template = self::getObject()->fetch(self::$_resourceName . ':' . self::$_templateName); return $template; } protected static function _checkTemplate() { if (is_null(self::$_template)) { throw new Qs_Exception('Template was not defined. Use Qs_Smarty::setTemplate method '); } } protected static function _assignVariables($data) { foreach ($data as $name => $value) { self::getObject()->assign($name, $value); } } public function getTemplate($tpl_name, &$tpl_source, &$smarty_obj) { throw new Qs_Exception(__CLASS__ . '::' . __METHOD__ . ' must be overridden'); } public function getTimestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) { throw new Qs_Exception(__CLASS__ . '::' . __METHOD__ . ' must be overridden'); } public function getSecure($tpl_name, &$smarty_obj) // no need to override { return true; } public function getTrusted($tpl_name, &$smarty_obj) // no need to override { } }