1: <?php
2: /**
3: * This file contains the wrapper class for smarty wrapper plugin.
4: *
5: * @package Plugin
6: * @subpackage SmartyWrapper
7: * @author Andreas Dieter
8: * @copyright four for business AG <www.4fb.de>
9: * @license http://www.contenido.org/license/LIZENZ.txt
10: * @link http://www.4fb.de
11: * @link http://www.contenido.org
12: */
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: /**
17: * Wrapper class for Integration of smarty.
18: *
19: * @package Plugin
20: * @subpackage SmartyWrapper
21: */
22: class cSmartyWrapper extends Smarty {
23: /**
24: * @see Smarty_Internal_TemplateBase::fetch()
25: *
26: * @param string $template the resource handle of the template file or template object
27: * @param mixed $cache_id cache id to be used with this template
28: * @param mixed $compile_id compile id to be used with this template
29: * @param object $parent next higher level of Smarty variables
30: * @param bool $display
31: * @param bool $merge_tpl_vars
32: * @param bool $no_output_filter
33: *
34: * @return mixed|string
35: */
36: public function fetch($template = NULL, $cache_id = NULL, $compile_id = NULL, $parent = NULL, $display = false, $merge_tpl_vars = true, $no_output_filter = false) {
37: if ($this->templateExists($template) === false) {
38: $moduleId = (int) cRegistry::getCurrentModuleId();
39: if ($moduleId > 0) {
40: $module = new cModuleHandler($moduleId);
41: $template = $module->getTemplatePath($template);
42: }
43: }
44:
45: return parent::fetch($template, $cache_id, $compile_id, $parent, $display, $merge_tpl_vars, $no_output_filter);
46: }
47:
48: /**
49: *
50: * @see Smarty_Internal_TemplateBase::fetch()
51: *
52: * @param string $template the resource handle of the template file or template object
53: * @param mixed $cache_id cache id to be used with this template
54: * @param mixed $compile_id compile id to be used with this template
55: * @param object $parent next higher level of Smarty variables
56: * @param bool $display
57: * @param bool $merge_tpl_vars
58: * @param bool $no_output_filter
59: *
60: * @return string
61: */
62: public function fetchGeneral($template = NULL, $cache_id = NULL, $compile_id = NULL, $parent = NULL, $display = false, $merge_tpl_vars = true, $no_output_filter = false) {
63: $template = cRegistry::getFrontendPath() . 'templates/' . $template;
64:
65: return parent::fetch($template, $cache_id, $compile_id, $parent, $display, $merge_tpl_vars, $no_output_filter);
66: }
67:
68: /**
69: * @param string $template the resource handle of the template file or template object
70: * @param mixed $cache_id cache id to be used with this template
71: * @param mixed $compile_id compile id to be used with this template
72: * @param object $parent next higher level of Smarty variables
73: */
74: public function display($template = NULL, $cache_id = NULL, $compile_id = NULL, $parent = NULL) {
75: global $frontend_debug;
76:
77: if ($this->templateExists($template) === false) {
78: $moduleId = (int) cRegistry::getCurrentModuleId();
79: if ($moduleId > 0) {
80: $module = new cModuleHandler($moduleId);
81: $template = $module->getTemplatePath($template);
82: }
83: }
84:
85: if ($frontend_debug['template_display']) {
86: echo("<!-- SMARTY TEMPLATE " . $template . " -->");
87: }
88:
89: return parent::display($template, $cache_id, $compile_id, $parent);
90: }
91:
92: /**
93: * @see Smarty_Internal_TemplateBase::display()
94: *
95: * @param string $template the resource handle of the template file or template object
96: * @param mixed $cache_id cache id to be used with this template
97: * @param mixed $compile_id compile id to be used with this template
98: * @param object $parent next higher level of Smarty variables
99: */
100: public function displayGeneral($template = NULL, $cache_id = NULL, $compile_id = NULL, $parent = NULL) {
101: $this->fetchGeneral($template, $cache_id, $compile_id, $parent, true);
102: }
103:
104: /**
105: * Empty cache for a specific template
106: *
107: * @param string $template_name template name
108: * @param string $cache_id cache id
109: * @param string $compile_id compile id
110: * @param integer $exp_time expiration time
111: * @param string $type resource type
112: * @return integer number of cache files deleted
113: */
114: public function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null) {
115: if ($this->templateExists($template_name) === false) {
116: $moduleId = (int) cRegistry::getCurrentModuleId();
117: if ($moduleId > 0) {
118: $module = new cModuleHandler($moduleId);
119: $template_name = $module->getTemplatePath($template_name);
120: }
121: }
122:
123: return parent::clearCache($template_name, $cache_id, $compile_id, $exp_time, $type);
124: }
125:
126: }