From b6403e336ec7c74d154ea8f78bd855f5aa384b2f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 27 Apr 2016 19:11:41 +0000 Subject: [PATCH] move common::get_tpl_dir to Api\Framework\Template::get_dir, and replaced some other overlooked methods --- api/src/Egw/Base.php | 2 +- api/src/Etemplate/Widget/Select.php | 6 ++-- api/src/Etemplate/Widget/Tree.php | 2 +- api/src/Framework/Template.php | 55 +++++++++++++++++++++++++++++ api/src/Html/HtmLawed.php | 4 +-- api/src/Link.php | 2 +- phpgwapi/inc/class.common.inc.php | 47 ++---------------------- 7 files changed, 65 insertions(+), 53 deletions(-) diff --git a/api/src/Egw/Base.php b/api/src/Egw/Base.php index 7fe105d29c..2c6f60dd10 100644 --- a/api/src/Egw/Base.php +++ b/api/src/Egw/Base.php @@ -109,7 +109,7 @@ class Base case 'framework': return $this->framework = Api\Framework::factory(); case 'template': // need to be instancated for the current app - if (!($tpl_dir = common::get_tpl_dir($this->currentapp))) + if (!($tpl_dir = Api\Framework\Template::get_dir($this->currentapp))) { return null; } diff --git a/api/src/Etemplate/Widget/Select.php b/api/src/Etemplate/Widget/Select.php index e666851c61..ae9bc91ec5 100644 --- a/api/src/Etemplate/Widget/Select.php +++ b/api/src/Etemplate/Widget/Select.php @@ -801,11 +801,11 @@ class Select extends Etemplate\Widget * * @param int $id * @param array $acc =null optional values for keys account_(type|lid|lastname|firstname) to not read them again - * @param int $longnames - * @param boolean $show_type true: return array with values for keys label and icon, false: only label + * @param int $longnames =0 + * @param boolean $show_type =false true: return array with values for keys label and icon, false: only label * @return string|array */ - private static function accountInfo($id,$acc=null,$longnames=0,$show_type=false) + public static function accountInfo($id,$acc=null,$longnames=0,$show_type=false) { if (!$id) { diff --git a/api/src/Etemplate/Widget/Tree.php b/api/src/Etemplate/Widget/Tree.php index 1bd0afe9b4..28de2a14a9 100644 --- a/api/src/Etemplate/Widget/Tree.php +++ b/api/src/Etemplate/Widget/Tree.php @@ -335,7 +335,7 @@ class Tree extends Etemplate\Widget /** * Return image relative to trees image-path * - * @param string $image url of image, eg. from common::image($image, $app) + * @param string $image url of image, eg. from Api\Image::find($image, $app) * @return string path relative to image-path, to use when returning tree data eg. via json */ public static function imagePath($image) diff --git a/api/src/Framework/Template.php b/api/src/Framework/Template.php index f44b4b245e..1a5636cf47 100644 --- a/api/src/Framework/Template.php +++ b/api/src/Framework/Template.php @@ -559,4 +559,59 @@ class Template } return False; } + + /** + * 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 + */ + static function get_dir($appname = '') + { + if (!$appname) + { + $appname = $GLOBALS['egw_info']['flags']['currentapp']; + } + if ($appname == 'logout' || $appname == 'login') + { + $appname = 'phpgwapi'; + } + + if (!isset($GLOBALS['egw_info']['server']['template_set']) && isset($GLOBALS['egw_info']['user']['preferences']['common']['template_set'])) + { + $GLOBALS['egw_info']['server']['template_set'] = $GLOBALS['egw_info']['user']['preferences']['common']['template_set']; + } + + // Setting this for display of template choices in user preferences + if ($GLOBALS['egw_info']['server']['template_set'] == 'user_choice') + { + $GLOBALS['egw_info']['server']['usrtplchoice'] = 'user_choice'; + } + + if (($GLOBALS['egw_info']['server']['template_set'] == 'user_choice' || + !isset($GLOBALS['egw_info']['server']['template_set'])) && + isset($GLOBALS['egw_info']['user']['preferences']['common']['template_set'])) + { + $GLOBALS['egw_info']['server']['template_set'] = $GLOBALS['egw_info']['user']['preferences']['common']['template_set']; + } + if (!file_exists(EGW_SERVER_ROOT.'/phpgwapi/templates/'.basename($GLOBALS['egw_info']['server']['template_set']).'/class.'. + $GLOBALS['egw_info']['server']['template_set'].'_framework.inc.php') && + !file_exists(EGW_SERVER_ROOT.'/'.basename($GLOBALS['egw_info']['server']['template_set']).'/inc/class.'. + $GLOBALS['egw_info']['server']['template_set'].'_framework.inc.php')) + { + $GLOBALS['egw_info']['server']['template_set'] = 'idots'; + } + $tpldir = EGW_SERVER_ROOT . '/' . $appname . '/templates/' . $GLOBALS['egw_info']['server']['template_set']; + $tpldir_default = EGW_SERVER_ROOT . '/' . $appname . '/templates/default'; + + if (@is_dir($tpldir)) + { + return $tpldir; + } + elseif (@is_dir($tpldir_default)) + { + return $tpldir_default; + } + return False; + } } diff --git a/api/src/Html/HtmLawed.php b/api/src/Html/HtmLawed.php index 3fc73a6bb2..bf7c9381f5 100644 --- a/api/src/Html/HtmLawed.php +++ b/api/src/Html/HtmLawed.php @@ -389,7 +389,7 @@ function hl_email_tag_transform($element, $attribute_array=0) { $attribute_array['alt']= $attribute_array['alt'].' [blocked (reason: url length):'.$attribute_array['src'].']'; if (!isset($attribute_array['title'])) $attribute_array['title']=$attribute_array['alt']; - $attribute_array['src']=common::image('phpgwapi','dialog_error'); + $attribute_array['src']=Api\Image::find('phpgwapi','dialog_error'); } if (!preg_match('/^cid:.*/',$attribute_array['src'])) { @@ -400,7 +400,7 @@ function hl_email_tag_transform($element, $attribute_array=0) { $attribute_array['alt']= $attribute_array['alt'].' [blocked external image:'.$attribute_array['src'].']'; if (!isset($attribute_array['title'])) $attribute_array['title']=$attribute_array['alt']; - $attribute_array['src']=common::image('mail','no-image-shown'); + $attribute_array['src']=Api\Image::find('mail','no-image-shown'); $attribute_array['border'] = 1; if ($attribute_array['style']) { diff --git a/api/src/Link.php b/api/src/Link.php index 2c204d29d5..38d076a1ac 100644 --- a/api/src/Link.php +++ b/api/src/Link.php @@ -145,7 +145,7 @@ class Link extends Link\Storage 'name' => 'Accounts', 'icon' => 'addressbook/accounts', 'query' => 'accounts::link_query', - 'title' => 'common::grab_owner_name', + 'title' => 'EGroupware\\Api\\Accounts::username', 'view' => array('menuaction'=>'addressbook.addressbook_ui.view','ajax'=>'true'), 'view_id' => 'account_id' ), diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 69abeedec4..dd4a615fc8 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -489,54 +489,11 @@ class common * * @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 + * @deprecated use Api\Framework\Template::get_dir($appname) */ static function get_tpl_dir($appname = '') { - if (!$appname) - { - $appname = $GLOBALS['egw_info']['flags']['currentapp']; - } - if ($appname == 'logout' || $appname == 'login') - { - $appname = 'phpgwapi'; - } - - if (!isset($GLOBALS['egw_info']['server']['template_set']) && isset($GLOBALS['egw_info']['user']['preferences']['common']['template_set'])) - { - $GLOBALS['egw_info']['server']['template_set'] = $GLOBALS['egw_info']['user']['preferences']['common']['template_set']; - } - - // Setting this for display of template choices in user preferences - if ($GLOBALS['egw_info']['server']['template_set'] == 'user_choice') - { - $GLOBALS['egw_info']['server']['usrtplchoice'] = 'user_choice'; - } - - if (($GLOBALS['egw_info']['server']['template_set'] == 'user_choice' || - !isset($GLOBALS['egw_info']['server']['template_set'])) && - isset($GLOBALS['egw_info']['user']['preferences']['common']['template_set'])) - { - $GLOBALS['egw_info']['server']['template_set'] = $GLOBALS['egw_info']['user']['preferences']['common']['template_set']; - } - if (!file_exists(EGW_SERVER_ROOT.'/phpgwapi/templates/'.basename($GLOBALS['egw_info']['server']['template_set']).'/class.'. - $GLOBALS['egw_info']['server']['template_set'].'_framework.inc.php') && - !file_exists(EGW_SERVER_ROOT.'/'.basename($GLOBALS['egw_info']['server']['template_set']).'/inc/class.'. - $GLOBALS['egw_info']['server']['template_set'].'_framework.inc.php')) - { - $GLOBALS['egw_info']['server']['template_set'] = 'idots'; - } - $tpldir = EGW_SERVER_ROOT . '/' . $appname . '/templates/' . $GLOBALS['egw_info']['server']['template_set']; - $tpldir_default = EGW_SERVER_ROOT . '/' . $appname . '/templates/default'; - - if (@is_dir($tpldir)) - { - return $tpldir; - } - elseif (@is_dir($tpldir_default)) - { - return $tpldir_default; - } - return False; + return Api\Framework\Template::get_dir($appname); } /**