Refactoring

This commit is contained in:
Marcos García 2012-07-30 23:23:58 +02:00
parent 0e0cf98c4f
commit 2c466159f9

View File

@ -1705,10 +1705,23 @@ function img_picto($alt, $picto, $options='', $pictoisfullpath=0)
function img_picto_common($alt, $picto, $options = '', $pictoisfullpath = 0) function img_picto_common($alt, $picto, $options = '', $pictoisfullpath = 0)
{ {
global $conf; global $conf;
if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png';
if ($pictoisfullpath) return '<img src="'.$picto.'" border="0" alt="'.dol_escape_htmltag($alt).'" title="'.dol_escape_htmltag($alt).'"'.($options?' '.$options:'').'>';
if (! empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS) && file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/'.$picto)) return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/'.$picto.'" border="0" alt="'.dol_escape_htmltag($alt).'" title="'.dol_escape_htmltag($alt).'"'.($options?' '.$options:'').'>'; if ($pictoisfullpath) $path = $picto;
return '<img src="'.DOL_URL_ROOT.'/theme/common/'.$picto.'" border="0" alt="'.dol_escape_htmltag($alt).'" title="'.dol_escape_htmltag($alt).'"'.($options?' '.$options:'').'>'; else
{
$path = DOL_URL_ROOT.'/theme/common/'.$picto;
if (! empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS))
{
$themepath = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/'.$picto;
if (file_exists($themepath)) return img_picto($alt, $themepath, $options, 1);
}
}
return img_picto($alt, $path, $options, 1);
} }
/** /**
@ -1721,15 +1734,17 @@ function img_picto_common($alt, $picto, $options='', $pictoisfullpath=0)
function img_action($alt, $numaction) function img_action($alt, $numaction)
{ {
global $conf, $langs; global $conf, $langs;
if ($alt=="default")
if ($alt == 'default')
{ {
if ($numaction == -1) $alt=$langs->transnoentitiesnoconv("ChangeDoNotContact"); if ($numaction == -1) $alt = $langs->transnoentitiesnoconv('ChangeDoNotContact');
if ($numaction == 0) $alt=$langs->transnoentitiesnoconv("ChangeNeverContacted"); if ($numaction == 0) $alt = $langs->transnoentitiesnoconv('ChangeNeverContacted');
if ($numaction == 1) $alt=$langs->transnoentitiesnoconv("ChangeToContact"); if ($numaction == 1) $alt = $langs->transnoentitiesnoconv('ChangeToContact');
if ($numaction == 2) $alt=$langs->transnoentitiesnoconv("ChangeContactInProcess"); if ($numaction == 2) $alt = $langs->transnoentitiesnoconv('ChangeContactInProcess');
if ($numaction == 3) $alt=$langs->transnoentitiesnoconv("ChangeContactDone"); if ($numaction == 3) $alt = $langs->transnoentitiesnoconv('ChangeContactDone');
} }
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/stcomm'.$numaction.'.png" border="0" alt="'.dol_escape_htmltag($alt).'" title="'.dol_escape_htmltag($alt).'">';
return img_picto($alt, 'stcomm'.$numaction.'.png');
} }
/** /**
@ -1837,17 +1852,14 @@ function img_delete($alt = 'default', $other = '')
function img_help($usehelpcursor = 1, $usealttitle = 1) function img_help($usehelpcursor = 1, $usealttitle = 1)
{ {
global $conf, $langs; global $conf, $langs;
$s ='<img ';
if ($usehelpcursor) $s.='style="cursor: help;" ';
$s.='src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/info.png" border="0"';
if ($usealttitle) if ($usealttitle)
{ {
if (is_string($usealttitle)) $s.=' alt="'.dol_escape_htmltag($usealttitle).'" title="'.dol_escape_htmltag($usealttitle).'"'; if (is_string($usealttitle)) $alt = dol_escape_htmltag($usealttitle);
else $s.=' alt="'.$langs->trans("Info").'" title="'.$langs->trans("Info").'"'; else $alt = $langs->trans("Info");
} }
else $s.=' alt=""';
$s.='>'; return img_picto($usealttitle, 'info.png', ($usehelpcursor ? 'style="cursor: help"' : ''));
return $s;
} }
/** /**
@ -2004,7 +2016,8 @@ function img_allow($allow, $alt = 'default')
if ($alt == 'default') $alt = $langs->trans('Active'); if ($alt == 'default') $alt = $langs->trans('Active');
if ($allow == 1) return img_picto($alt, 'tick.png'); if ($allow == 1) return img_picto($alt, 'tick.png');
else return '-';
return '-';
} }
@ -2024,7 +2037,7 @@ function img_mime($file,$alt='')
if (empty($alt)) $alt = 'Mime type: '.$mimetype; if (empty($alt)) $alt = 'Mime type: '.$mimetype;
return '<img src="'.DOL_URL_ROOT.'/theme/common/mime/'.$mimeimg.'" border="0" alt="'.$alt.'" title="'.$alt.'">'; return img_picto_common($alt, 'mime/'.$mimeimg);
} }
@ -2038,20 +2051,13 @@ function img_mime($file,$alt='')
function info_admin($text, $infoonimgalt = 0) function info_admin($text, $infoonimgalt = 0)
{ {
global $conf, $langs; global $conf, $langs;
$s='';
if ($infoonimgalt) if ($infoonimgalt)
{ {
$s.=img_picto($text,'star'); return img_picto($text, 'star');
} }
else
{ return '<div class="info">'.img_picto($langs->trans('InfoAdmin'), 'star').' '.$text.'</div>';
$s.='<div class="info">';
$s.=img_picto($langs->trans("InfoAdmin"),'star');
$s.=' ';
$s.=$text;
$s.='</div>';
}
return $s;
} }
@ -2077,8 +2083,8 @@ function dol_print_error($db='',$error='')
// Si erreur intervenue avant chargement langue // Si erreur intervenue avant chargement langue
if (! $langs) if (! $langs)
{ {
require_once(DOL_DOCUMENT_ROOT ."/core/class/translate.class.php"); require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php';
$langs = new Translate("", $conf); $langs = new Translate('', $conf);
$langs->load("main"); $langs->load("main");
} }
$langs->load("main"); $langs->load("main");