forked from Wavyzz/dolibarr
Merge pull request #19655 from cfoellmann/wus/hotfix/fontawesome-PR
use any available fontawesome icon in picto
This commit is contained in:
@@ -1666,7 +1666,11 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab
|
|||||||
$limittitle = 30;
|
$limittitle = 30;
|
||||||
$out .= '<a class="tabTitle">';
|
$out .= '<a class="tabTitle">';
|
||||||
if ($picto) {
|
if ($picto) {
|
||||||
$out .= img_picto($title, ($pictoisfullpath ? '' : 'object_').$picto, '', $pictoisfullpath, 0, 0, '', 'imgTabTitle').' ';
|
$noprefix = $pictoisfullpath;
|
||||||
|
if (strpos($picto, 'fontawesome_') !== false) {
|
||||||
|
$noprefix = 1;
|
||||||
|
}
|
||||||
|
$out .= img_picto($title, ($noprefix ? '' : 'object_').$picto, '', $pictoisfullpath, 0, 0, '', 'imgTabTitle').' ';
|
||||||
}
|
}
|
||||||
$out .= '<span class="tabTitleText">'.dol_escape_htmltag(dol_trunc($title, $limittitle)).'</span>';
|
$out .= '<span class="tabTitleText">'.dol_escape_htmltag(dol_trunc($title, $limittitle)).'</span>';
|
||||||
$out .= '</a>';
|
$out .= '</a>';
|
||||||
@@ -2021,10 +2025,14 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
|
|||||||
$width = 14;
|
$width = 14;
|
||||||
$cssclass = 'photorefcenter';
|
$cssclass = 'photorefcenter';
|
||||||
$picto = $object->picto;
|
$picto = $object->picto;
|
||||||
|
$prefix = 'object_';
|
||||||
if ($object->element == 'project' && !$object->public) {
|
if ($object->element == 'project' && !$object->public) {
|
||||||
$picto = 'project'; // instead of projectpub
|
$picto = 'project'; // instead of projectpub
|
||||||
}
|
}
|
||||||
$nophoto = img_picto('No photo', 'object_'.$picto);
|
if (strpos($picto, 'fontawesome_') !== false) {
|
||||||
|
$prefix = '';
|
||||||
|
}
|
||||||
|
$nophoto = img_picto('No photo', $prefix.$picto);
|
||||||
}
|
}
|
||||||
$morehtmlleft .= '<!-- No photo to show -->';
|
$morehtmlleft .= '<!-- No photo to show -->';
|
||||||
$morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
|
$morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
|
||||||
@@ -3609,6 +3617,7 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF
|
|||||||
* Example: picto.png if picto.png is stored into htdocs/theme/mytheme/img
|
* Example: picto.png if picto.png is stored into htdocs/theme/mytheme/img
|
||||||
* Example: picto.png@mymodule if picto.png is stored into htdocs/mymodule/img
|
* Example: picto.png@mymodule if picto.png is stored into htdocs/mymodule/img
|
||||||
* Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1)
|
* Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1)
|
||||||
|
* Example: fontawesome_envelope-open-text_fas_red_1em if you want to use fontaweseome icons: fontawesome_<icon-name>_<style>_<color>_<size> (only icon-name is mandatory)
|
||||||
* @param string $moreatt Add more attribute on img tag (For example 'class="pictofixedwidth"')
|
* @param string $moreatt Add more attribute on img tag (For example 'class="pictofixedwidth"')
|
||||||
* @param boolean|int $pictoisfullpath If true or 1, image path is a full path
|
* @param boolean|int $pictoisfullpath If true or 1, image path is a full path
|
||||||
* @param int $srconly Return only content of the src attribute of img.
|
* @param int $srconly Return only content of the src attribute of img.
|
||||||
@@ -3640,6 +3649,40 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$pictowithouttext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto);
|
$pictowithouttext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto);
|
||||||
|
|
||||||
|
if (strpos($pictowithouttext, 'fontawesome_') !== false) {
|
||||||
|
$pictowithouttext = explode('_', $pictowithouttext);
|
||||||
|
$marginleftonlyshort = 0;
|
||||||
|
|
||||||
|
$fakey = 'fa-'.$pictowithouttext[1];
|
||||||
|
$fa = $pictowithouttext[2] ? $pictowithouttext[2] : 'fa';
|
||||||
|
$facolor = $pictowithouttext[3] ? $pictowithouttext[3] : '';
|
||||||
|
$fasize = $pictowithouttext[4] ? $pictowithouttext[4] : '';
|
||||||
|
|
||||||
|
// This snippet only needed since function img_edit accepts only one additional parameter: no separate one for css only.
|
||||||
|
// class/style need to be extracted to avoid duplicate class/style validation errors when $moreatt is added to the end of the attributes.
|
||||||
|
$morestyle = '';
|
||||||
|
$reg = array();
|
||||||
|
if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) {
|
||||||
|
$morecss .= ($morecss ? ' ' : '').$reg[1];
|
||||||
|
$moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt);
|
||||||
|
}
|
||||||
|
if (preg_match('/style="([^"]+)"/', $moreatt, $reg)) {
|
||||||
|
$morestyle = $reg[1];
|
||||||
|
$moreatt = str_replace('style="'.$reg[1].'"', '', $moreatt);
|
||||||
|
}
|
||||||
|
$moreatt = trim($moreatt);
|
||||||
|
|
||||||
|
$enabledisablehtml = '<span class="'.$fa.' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ? ' marginleftonlyshort' : ' marginleftonly') : '');
|
||||||
|
$enabledisablehtml .= ($morecss ? ' '.$morecss : '').'" style="'.($fasize ? ('font-size: '.$fasize.';') : '').($facolor ? (' color: '.$facolor.';') : '').($morestyle ? ' '.$morestyle : '').'"'.(($notitle || empty($titlealt)) ? '' : ' title="'.dol_escape_htmltag($titlealt).'"').($moreatt ? ' '.$moreatt : '').'>';
|
||||||
|
/*if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||||
|
$enabledisablehtml .= $titlealt;
|
||||||
|
}*/
|
||||||
|
$enabledisablehtml .= '</span>';
|
||||||
|
|
||||||
|
return $enabledisablehtml;
|
||||||
|
}
|
||||||
|
|
||||||
$pictowithouttext = str_replace('object_', '', $pictowithouttext);
|
$pictowithouttext = str_replace('object_', '', $pictowithouttext);
|
||||||
if (empty($srconly) && in_array($pictowithouttext, array(
|
if (empty($srconly) && in_array($pictowithouttext, array(
|
||||||
'1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected',
|
'1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected',
|
||||||
|
|||||||
Reference in New Issue
Block a user