diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php
index e7c6b2524..8b2a7139f 100755
--- a/gulliver/system/class.g.php
+++ b/gulliver/system/class.g.php
@@ -4956,7 +4956,41 @@ function getDirectorySize($path,$maxmtime=0)
}
require_once PATH_THIRDPARTY . 'smarty/libs/Smarty.class.php';
-
+ $fInfo = pathinfo($template);
+
+ $tplExists = true;
+
+ // file has absolute path
+ if (substr($template, 0, 1) != PATH_SEP) {
+ $template = PATH_TEMPLATE . $template;
+ }
+
+ // fix for template that have dot in its name but is not a valid extension
+ if (isset($fInfo['extension']) && ($fInfo['extension'] != 'tpl' || $fInfo['extension'] != 'html')) {
+ unset($fInfo['extension']);
+ }
+
+ if (!isset($fInfo['extension'])) {
+ if (file_exists($template . '.tpl')) {
+ $template .= '.tpl';
+ }
+ else if (file_exists($template . '.html')) {
+ $template .= '.html';
+ }
+ else {
+ $tplExists = false;
+ }
+ }
+ else {
+ if (!file_exists($template)) {
+ $tplExists = false;
+ }
+ }
+
+ if (!$tplExists) {
+ throw new Exception("Template: $template, doesn't exist!");
+ }
+
$smarty = new Smarty();
$smarty->compile_dir = G::sys_get_temp_dir();
$smarty->cache_dir = G::sys_get_temp_dir();
@@ -4969,7 +5003,7 @@ function getDirectorySize($path,$maxmtime=0)
$smarty->assign($key, $value);
}
- $smarty->display("$template.tpl");
+ $smarty->display($template);
}
/**
diff --git a/workflow/engine/skinEngine/skinEngine.php b/workflow/engine/skinEngine/skinEngine.php
index 6b3b9eac6..735119f7b 100755
--- a/workflow/engine/skinEngine/skinEngine.php
+++ b/workflow/engine/skinEngine/skinEngine.php
@@ -7,6 +7,8 @@
* @author Hugo Loza
*/
+define('SE_LAYOUT_NOT_FOUND', 6);
+
class SkinEngine
{
@@ -149,11 +151,38 @@ class SkinEngine
{
$skinMethod = '_' . strtolower($this->skin);
- if (!method_exists($this, $skinMethod)) {
- $skinMethod = '_default';
+ try {
+ if (!method_exists($this, $skinMethod)) {
+ $skinMethod = '_default';
+ }
+
+ $this->$skinMethod();
+ }
+ catch (Exception $e) {
+ switch ($e->getCode()) {
+ case SE_LAYOUT_NOT_FOUND:
+
+ $data['exception_type'] = 'Skin Engine Exception';
+ $data['exception_title'] = 'Layout not Found';
+ $data['exception_message'] = 'You\'re trying to get a resource from a incorrent skin, please verify you url.';
+ $data['exception_list'] = array();
+ if (substr($this->mainSkin, 0, 2) != 'ux') {
+ $url = '../login/login';
+ }
+ else {
+ $url = '../main/login';
+ }
+
+ $link = 'Try Now';
+
+ $data['exception_notes'][] = ' The System can try redirect to correct url. ' . $link;
+
+ G::renderTemplate(PATH_TPL . 'exception', $data);
+ break;
+ }
+
+ exit(0);
}
-
- $this->$skinMethod();
}
/**
@@ -462,6 +491,14 @@ class SkinEngine
else {
$smarty->template_dir = $this->layoutFile['dirname'];
$tpl = 'layout-'.$this->layout.'.html';
+ //die($smarty->template_dir.PATH_SEP.$tpl);
+
+ if (!file_exists($smarty->template_dir . PATH_SEP . $tpl)) {
+ $e = new Exception("Layout $tpl does not exist!", SE_LAYOUT_NOT_FOUND);
+ $e->layoutFile = $smarty->template_dir . PATH_SEP . $tpl;
+
+ throw $e;
+ }
$smarty->assign('_content_file', $viewFile);
}
diff --git a/workflow/engine/templates/exception.tpl b/workflow/engine/templates/exception.tpl
new file mode 100644
index 000000000..52311c9a4
--- /dev/null
+++ b/workflow/engine/templates/exception.tpl
@@ -0,0 +1,98 @@
+
+
+
+
+
+ Whoops, looks like something went wrong.
+
+
+
+
+ {if isset($title)}
+
{$title}
+ {/if}
+
+ {$exception_type}:
+ {$exception_title}
+
+
+
{$exception_message}
+
+ {if isset($exception_list)}
+
+ {foreach from=$exception_list item=file}
+ - {$file}
+ {/foreach}
+
+ {/if}
+ {if isset($exception_list)}
+
+ {foreach from=$exception_notes item=note}
+ - * {$note}
+ {/foreach}
+
+ {/if}
+
+
+
+
\ No newline at end of file