diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index 6a966c365..0d3f5a977 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -63,6 +63,24 @@ class TemplateHandler return $oTemplate; } + /** + * Reset all instance properties to the default state. + * + * @return void + */ + protected function resetState() + { + $this->path = null; + $this->web_path = null; + $this->filename = null; + $this->file = null; + $this->compiled_file = null; + $this->config = new stdClass; + $this->skipTags = null; + $this->compiled_file = null; + self::$rootTpl = null; + } + /** * set variables for template compile * @param string $tpl_path @@ -76,6 +94,7 @@ class TemplateHandler $tpl_path = trim(preg_replace('@^' . preg_quote(\RX_BASEDIR, '@') . '|\./@', '', str_replace('\\', '/', $tpl_path)), '/') . '/'; if($tpl_path === '/' || !is_dir($tpl_path)) { + $this->resetState(); return; } if(!file_exists(\RX_BASEDIR . $tpl_path . $tpl_filename) && file_exists(\RX_BASEDIR . $tpl_path . $tpl_filename . '.html')) @@ -122,8 +141,8 @@ class TemplateHandler // if target file does not exist exit if(!$this->file || !file_exists($this->file)) { - $tpl_path = str_replace('\\', '/', $tpl_path); - $error_message = "Template not found: ${tpl_path}${tpl_filename}" . ($tpl_file ? " (${tpl_file})" : ''); + $tpl_path = rtrim(str_replace('\\', '/', $tpl_path), '/') . '/'; + $error_message = "Template not found: ${tpl_path}${tpl_filename}.html" . ($tpl_file ? " (${tpl_file})" : ''); trigger_error($error_message, \E_USER_WARNING); return escape($error_message); } @@ -145,7 +164,9 @@ class TemplateHandler $tmpfilename = tempnam(sys_get_temp_dir(), 'rx-compiled'); if($tmpfilename === false || Rhymix\Framework\Storage::write($tmpfilename, $buff) === false) { - return 'Fatal Error : Cannot create temporary file. Please check permissions.'; + $error_message = 'Template compile failed: Cannot create temporary file. Please check permissions.'; + trigger_error($error_message, \E_USER_WARNING); + return escape($error_message); } $this->compiled_file = $tmpfilename; @@ -189,8 +210,8 @@ class TemplateHandler // if target file does not exist exit if(!$this->file || !file_exists($this->file)) { - $tpl_path = str_replace('\\', '/', $tpl_path); - $error_message = "Template not found: ${tpl_path}${tpl_filename}"; + $tpl_path = rtrim(str_replace('\\', '/', $tpl_path), '/') . '/'; + $error_message = "Template not found: ${tpl_path}${tpl_filename}.html"; trigger_error($error_message, \E_USER_WARNING); return escape($error_message); } diff --git a/widgets/content/content.class.php b/widgets/content/content.class.php index 2ca059ccf..a5acf9524 100644 --- a/widgets/content/content.class.php +++ b/widgets/content/content.class.php @@ -736,7 +736,7 @@ class content extends WidgetHandler function _compile($args,$content_items) { - $oTemplate = &TemplateHandler::getInstance(); + $oTemplate = TemplateHandler::getInstance(); // Set variables for widget $widget_info = new stdClass(); $widget_info->modules_info = $args->modules_info;