mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
fix Framework\Template::get_dir() to either return a directory or throw a WrongParameter Exception, fixes several Scrutinizer warnings
This commit is contained in:
parent
a5d4400918
commit
921adfb10f
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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!");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user