Add List of usable icons with img_picto function

This commit is contained in:
John BOTELLA 2024-11-23 18:26:40 +01:00
parent 469baa0b5b
commit c642396dca
4 changed files with 106 additions and 42 deletions

View File

@ -130,7 +130,10 @@ class Documentation
'url' => dol_buildpath($baseUrl.'/components/icons.php', 1),
'icon' => 'far fa-flag pictofixedwidth',
'submenu' => array(),
'summary' => array(),
'summary' => array(
'DocIconsList' => '#img-picto-section-list',
'DocIconsFontAwesomeList' => '#icon-section-list',
),
),
'Progress' => array(
'url' => dol_buildpath($baseUrl.'/components/progress-bars.php', 1),

View File

@ -60,7 +60,58 @@ $documentation->showSidebar(); ?>
<!-- Summary -->
<?php $documentation->showSummary(); ?>
<!-- Basic usage -->
<!-- List of usage font awesome icon -->
<div class="documentation-section" id="img-picto-section-list">
<?php
$iconFileName = 'shims.json';
$iconFilePath = DOL_DOCUMENT_ROOT . '/theme/common/fontawesome-5/metadata';
$fontAwesomeIconRaw = file_get_contents($iconFilePath. '/' .$iconFileName);
if ($fontAwesomeIconRaw === false) {
dol_print_error($db, 'Error missing file '. $iconFilePath . '/' . $iconFileName);
}
$fontAwesomeIcons = json_decode($fontAwesomeIconRaw);
if ($fontAwesomeIcons === null) {
dol_print_error($db, 'Error decoding '. $iconFilePath . '/' . $iconFileName);
}
?>
<h2 class="documentation-title"><?php echo $langs->trans('DocIconsList'); ?></h2>
<?php /* <p class="documentation-text"><?php echo $langs->trans('DocDocIconsListDescription'); ?></p>*/ ?>
<div class="documentation-example">
<div class="documentation-fontawesome-icon-list">
<?php
foreach (getImgPictoNameList() as $iconName) {
$labelAlt = 'Text on title tag for tooltip';
$iconCode = img_picto($iconName, $iconName);
print '<div class="info-box ">
<span class="info-box-icon bg-infobox-expensereport">
'.$iconCode.'
</span>
<div class="info-box-content">
<div class="info-box-title" >'. $iconName .'</div>
<div class="info-box-lines">
<div class="info-box-line spanoverflow nowrap">
<div class="inline-block nowraponall">
<div class="documentation-code"><pre>'.dol_htmlentities('img_picto(\''.$labelAlt.'\', '.$iconName.')').'</pre></div>
</div>
</div>
</div><!-- /.info-box-lines -->
</div><!-- /.info-box-content -->
</div>';
}
?>
</div>
</div>
</div>
<!-- -->
<!-- List of usage font awesome icon -->
<div class="documentation-section" id="icon-section-list">
<?php
@ -81,8 +132,6 @@ $documentation->showSidebar(); ?>
<h2 class="documentation-title"><?php echo $langs->trans('DocIconsList'); ?></h2>
<?php /* <p class="documentation-text"><?php echo $langs->trans('DocDocIconsListDescription'); ?></p>*/ ?>
<div class="documentation-example">
<div class="documentation-fontawesome-icon-list">

View File

@ -5065,43 +5065,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco
return $enabledisablehtml;
}
if (empty($srconly) && in_array($pictowithouttext, array(
'1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected',
'accountancy', 'accounting_account', 'account', 'accountline', 'action', 'add', 'address', 'ai', 'angle-double-down', 'angle-double-up', 'asset',
'back', 'bank_account', 'barcode', 'bank', 'bell', 'bill', 'billa', 'billr', 'billd', 'birthday-cake', 'bom', 'bookcal', 'bookmark', 'briefcase-medical', 'bug', 'building',
'card', 'calendarlist', 'calendar', 'calendarmonth', 'calendarweek', 'calendarday', 'calendarperuser', 'calendarpertype', 'hourglass',
'cash-register', 'category', 'chart', 'check', 'clock', 'clone', 'close_title', 'code', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'conversation', 'cron', 'cross', 'cubes',
'check-circle', 'check-square', 'circle', 'stop-circle', 'currency', 'multicurrency',
'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top',
'chevron-double-left', 'chevron-double-right', 'chevron-double-down', 'chevron-double-top',
'commercial', 'companies',
'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'dynamicprice',
'edit', 'ellipsis-h', 'email', 'entity', 'envelope', 'eraser', 'establishment', 'expensereport', 'external-link-alt', 'external-link-square-alt', 'eye',
'filter', 'file', 'file-o', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'folder-plus', 'font',
'gears', 'generate', 'generic', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group',
'hands-helping', 'help', 'holiday',
'id-card', 'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'jobprofile',
'key', 'knowledgemanagement',
'label', 'language', 'layout', 'line', 'link', 'list', 'list-alt', 'listlight', 'loan', 'lock', 'lot', 'long-arrow-alt-right',
'margin', 'map-marker-alt', 'member', 'meeting', 'minus', 'money-bill-alt', 'movement', 'mrp', 'note', 'next',
'off', 'on', 'order',
'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'proposal', 'puce',
'stock', 'resize', 'service', 'stats',
'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_grey', 'switch_on_warning', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'user-tie', 'vcard', 'wrench',
'github', 'google', 'jabber', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
'generic', 'home', 'hrm', 'members', 'products', 'invoicing',
'partnership', 'payment', 'payment_vat', 'pencil-ruler', 'pictoconfirm', 'preview', 'project', 'projectpub', 'projecttask', 'question', 'refresh', 'region',
'salary', 'shipment', 'state', 'supplier_invoice', 'supplier_invoicea', 'supplier_invoicer', 'supplier_invoiced',
'technic', 'ticket',
'error', 'warning',
'recent', 'reception', 'recruitmentcandidature', 'recruitmentjobposition', 'replacement', 'resource', 'recurring','rss',
'shapes', 'skill', 'square', 'sort-numeric-down', 'status', 'stop-circle', 'supplier', 'supplier_proposal', 'supplier_order', 'supplier_invoice',
'terminal', 'tick', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', 'trip',
'uncheck', 'undo', 'url', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'webhook', 'world', 'private',
'conferenceorbooth', 'eventorganization',
'stamp', 'signature',
'webportal'
))) {
if (empty($srconly) && in_array($pictowithouttext, getImgPictoNameList())) {
$fakey = $pictowithouttext;
$facolor = '';
$fasize = '';
@ -5337,6 +5301,53 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco
return '<img src="'.$fullpathpicto.'"'.($notitle ? '' : ' alt="'.dol_escape_htmltag($alt).'"').(($notitle || empty($titlealt)) ? '' : ' title="'.dol_escape_htmltag($titlealt).'"').($moreatt ? ' '.$moreatt.($morecss ? ' class="'.$morecss.'"' : '') : ' class="inline-block'.($morecss ? ' '.$morecss : '').'"').'>'; // Alt is used for accessibility, title for popup
}
/**
* Get all usage icon name for img_picto
* @return string[]
*/
function getImgPictoNameList()
{
return array(
'1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected',
'accountancy', 'accounting_account', 'account', 'accountline', 'action', 'add', 'address', 'ai', 'angle-double-down', 'angle-double-up', 'asset',
'back', 'bank_account', 'barcode', 'bank', 'bell', 'bill', 'billa', 'billr', 'billd', 'birthday-cake', 'bom', 'bookcal', 'bookmark', 'briefcase-medical', 'bug', 'building',
'card', 'calendarlist', 'calendar', 'calendarmonth', 'calendarweek', 'calendarday', 'calendarperuser', 'calendarpertype', 'hourglass',
'cash-register', 'category', 'chart', 'check', 'clock', 'clone', 'close_title', 'code', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'conversation', 'cron', 'cross', 'cubes',
'check-circle', 'check-square', 'circle', 'stop-circle', 'currency', 'multicurrency',
'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top',
'chevron-double-left', 'chevron-double-right', 'chevron-double-down', 'chevron-double-top',
'commercial', 'companies',
'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'dynamicprice',
'edit', 'ellipsis-h', 'email', 'entity', 'envelope', 'eraser', 'establishment', 'expensereport', 'external-link-alt', 'external-link-square-alt', 'eye',
'filter', 'file', 'file-o', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'folder-plus', 'font',
'gears', 'generate', 'generic', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group',
'hands-helping', 'help', 'holiday',
'id-card', 'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'jobprofile',
'key', 'knowledgemanagement',
'label', 'language', 'layout', 'line', 'link', 'list', 'list-alt', 'listlight', 'loan', 'lock', 'lot', 'long-arrow-alt-right',
'margin', 'map-marker-alt', 'member', 'meeting', 'minus', 'money-bill-alt', 'movement', 'mrp', 'note', 'next',
'off', 'on', 'order',
'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'proposal', 'puce',
'stock', 'resize', 'service', 'stats',
'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_grey', 'switch_on_warning', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'user-tie', 'vcard', 'wrench',
'github', 'google', 'jabber', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
'generic', 'home', 'hrm', 'members', 'products', 'invoicing',
'partnership', 'payment', 'payment_vat', 'pencil-ruler', 'pictoconfirm', 'preview', 'project', 'projectpub', 'projecttask', 'question', 'refresh', 'region',
'salary', 'shipment', 'state', 'supplier_invoice', 'supplier_invoicea', 'supplier_invoicer', 'supplier_invoiced',
'technic', 'ticket',
'error', 'warning',
'recent', 'reception', 'recruitmentcandidature', 'recruitmentjobposition', 'replacement', 'resource', 'recurring', 'rss',
'shapes', 'skill', 'square', 'sort-numeric-down', 'status', 'stop-circle', 'supplier', 'supplier_proposal', 'supplier_order', 'supplier_invoice',
'terminal', 'tick', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', 'trip',
'uncheck', 'undo', 'url', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'webhook', 'world', 'private',
'conferenceorbooth', 'eventorganization',
'stamp', 'signature',
'webportal'
);
}
/**
* Show a picto called object_picto (generic function)
*

View File

@ -82,5 +82,6 @@ DocButtonIconsForTitle = Buttons for list title
# Fontawesome icons
DocIconsTitle = Icons used by Dolibarr
DocIconsList = List of usable icons with img_picto function
DocIconsMainDescription = Dolibarr use a part of fontawesome 5 icons
DocIconsList = List of usable font icons
DocIconsFontAwesomeList = List of usable fontawesome icons