diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index b96e4755284..4d39abb4da8 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -346,7 +346,7 @@ class Form
* @return string Code html du tooltip (texte+picto)
* @see Use function textwithpicto if you can.
*/
- function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0,$incbefore='',$noencodehtmltext=0)
+ function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 0, $incbefore = '', $noencodehtmltext = 0)
{
global $conf;
@@ -402,18 +402,24 @@ class Form
* @param int $noencodehtmltext Do not encode into html entity the htmltext
* @return string HTML code of text, picto, tooltip
*/
- function textwithpicto($text,$htmltext,$direction=1,$type='help',$extracss='',$noencodehtmltext=0)
+ function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0)
{
global $conf;
- if ("$type" == "0") $type='info'; // For backward compatibility
+ $alt = '';
+
+ //For backwards compatibility
+ if ($type == '0') $type = 'info';
+ elseif ($type == '1') $type = 'help';
- $alt='';
// If info or help with no javascript, show only text
if (empty($conf->use_javascript_ajax))
{
if ($type == 'info' || $type == 'help') return $text;
- else { $alt=$htmltext; $htmltext='';
+ else
+ {
+ $alt = $htmltext;
+ $htmltext = '';
}
}
// If info or help with smartphone, show only text
@@ -421,15 +427,14 @@ class Form
{
if ($type == 'info' || $type == 'help') return $text;
}
- // Info or help
- if ($type == 'info') $img=img_help(0,$alt);
- if ($type == 'help' || $type ==1) $img=img_help(1,$alt);
- if ($type == 'superadmin') $img=img_picto($alt,"redstar");
- if ($type == 'admin') $img=img_picto($alt,"star");
- // Warnings
- if ($type == 'warning') $img=img_warning($alt);
+
+ if ($type == 'info') $img = img_help(0, $alt);
+ elseif ($type == 'help') $img = img_help(1, $alt);
+ elseif ($type == 'superadmin') $img = img_picto($alt, 'redstar');
+ elseif ($type == 'admin') $img = img_picto($alt, 'star');
+ elseif ($type == 'warning') $img = img_warning($alt);
- return $this->textwithtooltip($text,$htmltext,2,$direction,$img,$extracss,0,'',$noencodehtmltext);
+ return $this->textwithtooltip($text, $htmltext, 2, $direction, $img, $extracss, 0, '', $noencodehtmltext);
}
/**
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 9a20d25f431..52e06332330 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -1707,13 +1707,26 @@ function img_picto($alt, $picto, $options='', $pictoisfullpath=0)
* @return string Return img tag
* @see #img_object, #img_picto
*/
-function img_picto_common($alt, $picto, $options='', $pictoisfullpath=0)
+function img_picto_common($alt, $picto, $options = '', $pictoisfullpath = 0)
{
global $conf;
- if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto.='.png';
- if ($pictoisfullpath) return '';
- if (! empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS) && file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/'.$picto)) return '
';
- return '
';
+
+ if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png';
+
+ if ($pictoisfullpath) $path = $picto;
+ 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);
}
/**
@@ -1725,16 +1738,18 @@ function img_picto_common($alt, $picto, $options='', $pictoisfullpath=0)
*/
function img_action($alt, $numaction)
{
- global $conf,$langs;
- if ($alt=="default")
+ global $conf, $langs;
+
+ if ($alt == 'default')
{
- if ($numaction == -1) $alt=$langs->transnoentitiesnoconv("ChangeDoNotContact");
- if ($numaction == 0) $alt=$langs->transnoentitiesnoconv("ChangeNeverContacted");
- if ($numaction == 1) $alt=$langs->transnoentitiesnoconv("ChangeToContact");
- if ($numaction == 2) $alt=$langs->transnoentitiesnoconv("ChangeContactInProcess");
- if ($numaction == 3) $alt=$langs->transnoentitiesnoconv("ChangeContactDone");
+ if ($numaction == -1) $alt = $langs->transnoentitiesnoconv('ChangeDoNotContact');
+ if ($numaction == 0) $alt = $langs->transnoentitiesnoconv('ChangeNeverContacted');
+ if ($numaction == 1) $alt = $langs->transnoentitiesnoconv('ChangeToContact');
+ if ($numaction == 2) $alt = $langs->transnoentitiesnoconv('ChangeContactInProcess');
+ if ($numaction == 3) $alt = $langs->transnoentitiesnoconv('ChangeContactDone');
}
- return '
';
+
+ return img_picto($alt, 'stcomm'.$numaction.'.png');
}
/**
@@ -1744,11 +1759,13 @@ function img_action($alt, $numaction)
* @param int $size Taille de l'icone : 3 = 16x16px , 2 = 14x14px
* @return string Retourne tag img
*/
-function img_pdf($alt = "default",$size=3)
+function img_pdf($alt = 'default', $size = 3)
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Show");
- return '
';
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Show');
+
+ return img_picto($alt, 'pdf'.$size.'.png');
}
/**
@@ -1757,11 +1774,13 @@ function img_pdf($alt = "default",$size=3)
* @param string $alt Texte sur le alt de l'image
* @return string Return tag img
*/
-function img_edit_add($alt = "default")
+function img_edit_add($alt = 'default')
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Add");
- return img_picto($alt,'edit_add.png');
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Add');
+
+ return img_picto($alt, 'edit_add.png');
}
/**
* Show logo -
@@ -1769,11 +1788,13 @@ function img_edit_add($alt = "default")
* @param string $alt Texte sur le alt de l'image
* @return string Retourne tag img
*/
-function img_edit_remove($alt = "default")
+function img_edit_remove($alt = 'default')
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Remove");
- return img_picto($alt,'edit_remove.png');
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Remove');
+
+ return img_picto($alt, 'edit_remove.png');
}
/**
@@ -1784,15 +1805,13 @@ function img_edit_remove($alt = "default")
* @param string $other Add more attributes on img
* @return string Retourne tag img
*/
-function img_edit($alt = "default", $float=0, $other='')
+function img_edit($alt = 'default', $float = 0, $other = '')
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Modify");
- $img='
';
- return $img;
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Modify');
+
+ return img_picto($alt, 'edit.png', ($float ? 'style="float: right"' : $other));
}
/**
@@ -1803,15 +1822,15 @@ function img_edit($alt = "default", $float=0, $other='')
* @param string $other Add more attributes on img
* @return string Retourne tag img
*/
-function img_view($alt = "default", $float=0, $other='')
+function img_view($alt = 'default', $float = 0, $other = '')
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("View");
- $img='
';
- return $img;
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('View');
+
+ $options = ($float ? 'style="float: right" ' : '').$other;
+
+ return img_picto($alt, 'view.png', $options);
}
/**
@@ -1821,13 +1840,14 @@ function img_view($alt = "default", $float=0, $other='')
* @param string $other Add more attributes on img
* @return string Retourne tag img
*/
-function img_delete($alt = "default", $other='')
+function img_delete($alt = 'default', $other = '')
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Delete");
- return img_picto($alt,'delete.png',$other);
-}
+ global $conf, $langs;
+ if ($alt == 'default') $alt = $langs->trans('Delete');
+
+ return img_picto($alt, 'delete.png', $other);
+}
/**
* Show help logo with cursor "?"
@@ -1836,188 +1856,175 @@ function img_delete($alt = "default", $other='')
* @param string $usealttitle Text to use as alt title
* @return string Retourne tag img
*/
-function img_help($usehelpcursor=1,$usealttitle=1)
+function img_help($usehelpcursor = 1, $usealttitle = 1)
{
- global $conf,$langs;
- $s ='theme.'/img/info.png" border="0"';
+ global $conf, $langs;
+
if ($usealttitle)
{
- if (is_string($usealttitle)) $s.=' alt="'.dol_escape_htmltag($usealttitle).'" title="'.dol_escape_htmltag($usealttitle).'"';
- else $s.=' alt="'.$langs->trans("Info").'" title="'.$langs->trans("Info").'"';
+ if (is_string($usealttitle)) $alt = dol_escape_htmltag($usealttitle);
+ else $alt = $langs->trans('Info');
}
- else $s.=' alt=""';
- $s.='>';
- return $s;
+
+ return img_picto($usealttitle, 'info.png', ($usehelpcursor ? 'style="cursor: help"' : ''));
}
/**
- * Affiche logo info
+ * Show info logo
*
* @param string $alt Text to show on alt image
* @return string Return img tag
*/
-function img_info($alt = "default")
+function img_info($alt = 'default')
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Informations");
- return img_picto($alt,'info.png');
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Informations');
+
+ return img_picto($alt, 'info.png');
}
/**
- * Show logo warning
+ * Show warning logo
*
* @param string $alt Text to show on alt image
* @param int $float If we must add style "float: right"
* @return string Return img tag
*/
-function img_warning($alt = "default",$float=0)
+function img_warning($alt = 'default', $float = 0)
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Warning");
- return img_picto($alt,'warning.png',$float?'style="float: right"':'');
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Warning');
+
+ return img_picto($alt, 'warning.png', ($float ? 'style="float: right"' : ''));
}
/**
- * Affiche logo error
+ * Show error logo
*
* @param string $alt Text to show on alt image
* @return string Return img tag
*/
-function img_error($alt = "default")
+function img_error($alt = 'default')
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Error");
- return img_picto($alt,'error.png');
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Error');
+
+ return img_picto($alt, 'error.png');
}
/**
- * Affiche logo telephone
- *
- * @param string $alt Text to show on alt image
- * @param int $option Option
- * @return string Return img tag
- */
-function img_phone($alt = "default",$option=0)
-{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Call");
- $img='call_out';
- if ($option == 1) $img='call';
- $img='object_commercial';
- return '
';
-}
-
-
-/**
- * Affiche logo suivant
+ * Show next logo
*
* @param string $alt Text to show on alt image
* @return string Return img tag
*/
-function img_next($alt = "default")
+function img_next($alt = 'default')
{
- global $conf,$langs;
- if ($alt=="default") {
- $alt=$langs->trans("Next");
- }
- return '
';
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Next');
+
+ return img_picto($alt, 'next.png');
}
/**
- * Affiche logo precedent
+ * Show previous logo
*
* @param string $alt Text to show on alt image
* @return string Return img tag
*/
-function img_previous($alt = "default")
+function img_previous($alt = 'default')
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Previous");
- return '
';
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Previous');
+
+ return img_picto($alt, 'previous.png');
}
/**
- * Show logo down arrow
+ * Show down arrow logo
*
* @param string $alt Text to show on alt image
* @param int $selected Selected
* @return string Return img tag
*/
-function img_down($alt = "default", $selected=0)
+function img_down($alt = 'default', $selected = 0)
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Down");
- if ($selected) return '
';
- else return '
';
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Down');
+
+ return img_picto($alt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown"');
}
/**
- * Show logo top arrow
+ * Show top arrow logo
*
* @param string $alt Text to show on alt image
* @param int $selected Selected
* @return string Return img tag
*/
-function img_up($alt = "default", $selected=0)
+function img_up($alt = 'default', $selected = 0)
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Up");
- if ($selected) return '
';
- else return '
';
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Up');
+
+ return img_picto($alt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup"');
}
/**
- * Affiche logo gauche
+ * Show left arrow logo
*
* @param string $alt Text to show on alt image
* @param int $selected Selected
* @return string Return img tag
*/
-function img_left($alt = "default", $selected=0)
+function img_left($alt = 'default', $selected = 0)
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Left");
- if ($selected) return '
';
- else return '
';
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Left');
+
+ return img_picto($alt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png'));
}
/**
- * Affiche logo droite
+ * Show right arrow logo
*
* @param string $alt Text to show on alt image
* @param int $selected Selected
* @return string Return img tag
*/
-function img_right($alt = "default", $selected=0)
+function img_right($alt = 'default', $selected = 0)
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Right");
- if ($selected) return '
';
- else return '
';
+ global $conf, $langs;
+
+ if ($alt == 'default') $alt = $langs->trans('Right');
+
+ return img_picto($alt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png'));
}
/**
- * Affiche le logo tick si allow
+ * Show tick logo if allowed
*
* @param string $allow Allow
* @param string $alt Text to show on alt image
* @return string Return img tag
*/
-function img_allow($allow,$alt='default')
+function img_allow($allow, $alt = 'default')
{
- global $conf,$langs;
- if ($alt=="default") $alt=$langs->trans("Active");
+ global $conf, $langs;
- if ($allow == 1)
- {
- return '
';
- }
- else
- {
- return "-";
- }
+ if ($alt == 'default') $alt = $langs->trans('Active');
+
+ if ($allow == 1) return img_picto($alt, 'tick.png');
+
+ return '-';
}
@@ -2028,16 +2035,16 @@ function img_allow($allow,$alt='default')
* @param string $alt Alternate text to show on img mous hover
* @return string Return img tag
*/
-function img_mime($file,$alt='')
+function img_mime($file, $alt = '')
{
- require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $mimetype=dol_mimetype($file,'',1);
- $mimeimg=dol_mimetype($file,'',2);
+ $mimetype = dol_mimetype($file, '', 1);
+ $mimeimg = dol_mimetype($file, '', 2);
- if (empty($alt)) $alt='Mime type: '.$mimetype;
+ if (empty($alt)) $alt = 'Mime type: '.$mimetype;
- return '';
+ return img_picto_common($alt, 'mime/'.$mimeimg);
}
@@ -2048,23 +2055,16 @@ function img_mime($file,$alt='')
* @param string $infoonimgalt Info is shown only on alt of star picto, otherwise it is show on output after the star picto
* @return string String with info text
*/
-function info_admin($text,$infoonimgalt=0)
+function info_admin($text, $infoonimgalt = 0)
{
- global $conf,$langs;
- $s='';
+ global $conf, $langs;
+
if ($infoonimgalt)
{
- $s.=img_picto($text,'star');
+ return img_picto($text, 'star');
}
- else
- {
- $s.='