diff --git a/api/src/Egw.php b/api/src/Egw.php index f324f5ee91..3c91308ff3 100644 --- a/api/src/Egw.php +++ b/api/src/Egw.php @@ -18,6 +18,7 @@ namespace EGroupware\Api; // they are only used, if phpgwapi is installed use accounts as egw_accounts; use egw_session; +use common; /** * New written class to create the eGW enviroment AND restore it from a php-session @@ -409,14 +410,20 @@ class Egw extends Egw\Base // A few hacker resistant constants that will be used throught the program if (file_exists(EGW_SERVER_ROOT.'/phpgwapi')) { - define('EGW_TEMPLATE_DIR', $this->common->get_tpl_dir('phpgwapi')); - define('EGW_IMAGES_DIR', $this->common->get_image_path('phpgwapi')); - define('EGW_IMAGES_FILEDIR', $this->common->get_image_dir('phpgwapi')); - define('EGW_APP_ROOT', $this->common->get_app_dir()); - define('EGW_APP_INC', $this->common->get_inc_dir()); - define('EGW_APP_TPL', $this->common->get_tpl_dir()); - define('EGW_IMAGES', $this->common->get_image_path()); - define('EGW_APP_IMAGES_DIR', $this->common->get_image_dir()); + define('EGW_TEMPLATE_DIR', Framework\Template::get_dir('phpgwapi')); + define('EGW_IMAGES_DIR', common::get_image_path('phpgwapi')); + define('EGW_IMAGES_FILEDIR', common::get_image_dir('phpgwapi')); + define('EGW_APP_ROOT', common::get_app_dir()); + define('EGW_APP_INC', common::get_inc_dir()); + try { + define('EGW_APP_TPL', Framework\Template::get_dir()); + } + catch (Exception\WrongParameter $e) { + unset($e); + define('EGW_APP_TPL', null); + } + define('EGW_IMAGES', common::get_image_path()); + define('EGW_APP_IMAGES_DIR', common::get_image_dir()); // and the old ones define('PHPGW_TEMPLATE_DIR',EGW_TEMPLATE_DIR); define('PHPGW_IMAGES_DIR',EGW_IMAGES_DIR); diff --git a/api/src/Egw/Base.php b/api/src/Egw/Base.php index 8464e59d44..3bfafad330 100644 --- a/api/src/Egw/Base.php +++ b/api/src/Egw/Base.php @@ -112,11 +112,13 @@ class Base case 'framework': return $this->framework = Api\Framework::factory(); case 'template': // need to be instancated for the current app - if (!($tpl_dir = Api\Framework\Template::get_dir($this->currentapp))) - { + try { + return $this->template = new Api\Framework\Template(Api\Framework\Template::get_dir($this->currentapp)); + } + catch (EGroupware\Api\Exception\WrongParameter $e) { + unset($e); return null; } - return $this->template = new Api\Framework\Template($tpl_dir); case 'ldap': return $this->ldap = Api\Ldap::factory(false); default: diff --git a/api/src/Framework/Template.php b/api/src/Framework/Template.php index 1a5636cf47..1e2655560b 100644 --- a/api/src/Framework/Template.php +++ b/api/src/Framework/Template.php @@ -564,7 +564,8 @@ class Template * get template dir of an application * * @param $appname appication name optional can be derived from $GLOBALS['egw_info']['flags']['currentapp']; - * @return string|boolean dir or false if no dir is found + * @return string template directory + * @throws Api\Exception\WrongParameter if no directory is found */ static function get_dir($appname = '') { @@ -612,6 +613,6 @@ class Template { return $tpldir_default; } - return False; + throw new Api\Exception\WrongParameter("Template directory for app '$appname' not found!"); } }