Fix: optimization
see : http://mkaz.com/web-dev/php-benchmarking-isset-empty-or-var.html
This commit is contained in:
parent
d883c135e0
commit
320ce03e29
@ -1635,26 +1635,32 @@ function img_picto($alt, $picto, $options = '', $pictoisfullpath = false)
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
// Clean parameters
|
|
||||||
if (! preg_match('/(\.png|\.gif)$/i', $picto) && ! preg_match('/^([^@]+)@([^@]+)$/i', $picto)) $picto .= '.png';
|
|
||||||
|
|
||||||
// Define fullpathpicto to use into src
|
// Define fullpathpicto to use into src
|
||||||
if ($pictoisfullpath) $fullpathpicto = $picto;
|
if (! empty($pictoisfullpath)) {
|
||||||
|
// Clean parameters
|
||||||
|
if (! preg_match('/(\.png|\.gif)$/i',$picto))
|
||||||
|
$picto .= '.png';
|
||||||
|
$fullpathpicto = $picto;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// By default, we search into theme directory
|
// By default, we search into theme directory
|
||||||
$url = DOL_URL_ROOT;
|
$url = DOL_URL_ROOT;
|
||||||
$path = 'theme/'.$conf->theme;
|
$path = 'theme/'.$conf->theme;
|
||||||
if (! empty($conf->global->MAIN_FORCETHEMEDIR)) $path = preg_replace('/^\//', '', $conf->global->MAIN_FORCETHEMEDIR).'/'.$path;
|
if (! empty($conf->global->MAIN_FORCETHEMEDIR))
|
||||||
|
$path = preg_replace('/^\//', '', $conf->global->MAIN_FORCETHEMEDIR).'/'.$path;
|
||||||
// If we ask an image into module/img (not into a theme path)
|
// If we ask an image into module/img (not into a theme path)
|
||||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs))
|
if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs))
|
||||||
{
|
{
|
||||||
$picto = $regs[1];
|
$picto = $regs[1];
|
||||||
$path = $regs[2];
|
$path = $regs[2];
|
||||||
}
|
}
|
||||||
if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png';
|
// Clean parameters
|
||||||
|
if (! preg_match('/(\.png|\.gif)$/i',$picto))
|
||||||
|
$picto .= '.png';
|
||||||
// If img file not into standard path, we use alternate path
|
// If img file not into standard path, we use alternate path
|
||||||
if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.'/'.$path.'/img/'.$picto)) $url = DOL_URL_ROOT_ALT;
|
if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.'/'.$path.'/img/'.$picto))
|
||||||
|
$url = DOL_URL_ROOT_ALT;
|
||||||
|
|
||||||
$fullpathpicto = $url.'/'.$path.'/img/'.$picto;
|
$fullpathpicto = $url.'/'.$path.'/img/'.$picto;
|
||||||
}
|
}
|
||||||
@ -1675,8 +1681,6 @@ function img_picto($alt, $picto, $options = '', $pictoisfullpath = false)
|
|||||||
*/
|
*/
|
||||||
function img_object($alt, $picto, $options = '', $pictoisfullpath = false)
|
function img_object($alt, $picto, $options = '', $pictoisfullpath = false)
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
|
|
||||||
return img_picto($alt, 'object_'.$picto, $options, $pictoisfullpath);
|
return img_picto($alt, 'object_'.$picto, $options, $pictoisfullpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user