dolibarr 23.0.3
icons.php
1<?php
2/*
3 * Copyright (C) 2024 Anthony Damhet <a.damhet@progiseize.fr>
4 *
5 * This program and files/directory inner it is free software: you can
6 * redistribute it and/or modify it under the terms of the
7 * GNU Affero General Public License (AGPL) as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU AGPL for more details.
15 *
16 * You should have received a copy of the GNU AGPL
17 * along with this program. If not, see <https://www.gnu.org/licenses/agpl-3.0.html>.
18 */
19
20// Load Dolibarr environment
21require '../../../../main.inc.php';
22
30// Protection if external user
31if ($user->socid > 0) {
33}
34
35// Includes
36require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php';
37
38// Load documentation translations
39$langs->load('uxdocumentation');
40
41//
42$documentation = new Documentation($db);
43
44// Output html head + body - Param is Title
45$documentation->docHeader('Icons', [], ['admin/tools/ui/css/doc-icons.css'], GETPOST('hidenavmenu'));
46
47// Set view for menu and breadcrumb
48// Menu must be set in constructor of documentation class
49$documentation->view = array('Components','Icons');
50$form = new Form($db);
51
52$mode=GETPOST('mode'); // ex : no-btn
53$displayMode = GETPOST('displayMode') == 'kanban' ? 'kanban' : 'icon-only';
54$revertDisplayMode = $displayMode == 'kanban' ? 'icon-only' : 'kanban';
55$revertDisplayName = $displayMode == 'kanban' ? $langs->trans('ViewList') : $langs->trans('ViewKanban');
56$switchDisplayLink = dol_buildpath($documentation->baseUrl . '/components/icons.php', 1) . '?displayMode=' . $revertDisplayMode;
57$switchDisplayLinkIcon = $displayMode == 'kanban' ? 'fa fa-th' : 'fa fa-th-list';
58
59// Output sidebar
60if (!GETPOST('hidenavmenu')) {
61 $documentation->showSidebar();
62}
63?>
64
65<div class="doc-wrapper<?php print GETPOST('hidenavmenu') ? "-bis" : ""; ?>">
66
67 <?php
68 if (!GETPOST('hidenavmenu')) {
69 $documentation->showBreadCrumb();
70 }
71 ?>
72
73 <div class="doc-content-wrapper">
74
75 <h1 class="documentation-title"><?php echo $langs->trans('DocIconsTitle'); ?></h1>
76 <p class="documentation-text"><?php echo $langs->trans('DocIconsMainDescription'); ?></p>
77
78 <!-- Summary -->
79 <?php $documentation->showSummary(); ?>
80
81 <br>
82
83 <!-- List of usage font awesome icon -->
84 <div class="documentation-section" id="img-picto-section-list">
85
86 <?php
87
88 $iconFileName = 'shims.json';
89 $iconFilePath = DOL_DOCUMENT_ROOT . '/theme/common/fontawesome-5/metadata';
90
91 $fontAwesomeIconRaw = file_get_contents($iconFilePath. '/' .$iconFileName);
92 if ($fontAwesomeIconRaw === false) {
93 dol_print_error($db, 'Error missing file '. $iconFilePath . '/' . $iconFileName);
94 }
95
96 $fontAwesomeIcons = json_decode($fontAwesomeIconRaw);
97 if ($fontAwesomeIcons === null) {
98 dol_print_error($db, 'Error decoding '. $iconFilePath . '/' . $iconFileName);
99 }
100 ?>
101
102 <h2 class="documentation-title"><?php echo $langs->trans('DocIconsListImgPicto'); ?></h2>
103 <?php /* <p class="documentation-text"><?php echo $langs->trans('DocDocIconsListDescription'); ?></p>*/ ?>
104
105 <?php print $form->getSearchFilterToolInput(
106 '.documentation-img-picto-icon-list .info-box, .documentation-img-picto-icon-list .doc-icon-list-item',
107 'search-tools-input',
108 '',
109 ['attr' => [
110 'data-no-item-target' => '#img-picto-section-list .search-tool-no-results',
111 ],
112 ]
113 ); ?>
114
115 <div class="right">
116 <?php
117 if ($mode != 'no-btn') {
118 print dolGetButtonTitle($revertDisplayName, '', $switchDisplayLinkIcon, $switchDisplayLink.'#img-picto-section-list', '', 1, ['forcenohideoftext'=>1]);
119 }
120 ?>
121 </div>
122
123 <div class="documentation-example">
124 <div class="documentation-img-picto-icon-list">
125 <?php
126 $arrayofdolibarriconkey = getImgPictoNameList();
127
128 foreach ($arrayofdolibarriconkey as $iconName) {
129 $labelAlt = 'Text on title tag for tooltip';
130
131 if ($displayMode == 'kanban') {
132 $iconCode = img_picto($iconName, $iconName);
133 print '<div class="info-box ">
134 <span class="info-box-icon bg-infobox-expensereport">
135 '.$iconCode.'
136 </span>
137 <div class="info-box-content">
138 <div class="info-box-title" >'. $iconName .'</div>
139 <div class="info-box-lines">
140 <div class="info-box-line spanoverflow nowrap">
141 <div class="inline-block nowraponall">
142 <div class="documentation-code"><pre>'.dol_htmlentities('img_picto(\''.$labelAlt.'\', \''.$iconName.'\')').'</pre></div>
143 </div>
144 </div>
145 </div><!-- /.info-box-lines -->
146 </div><!-- /.info-box-content -->
147 </div>';
148 } else {
149 $tooltip = '<u>'.$langs->trans("DocCodeForMenuOrModuleBuilder").':</u><br>'.$iconName;
150 $tooltip .= '<br><br><u>'.$langs->trans("DocExampleForPHPCode").':</u><br>img_picto(\''.$labelAlt.'\', \''.$iconName.'\')';
151 $iconCode = img_picto($tooltip, $iconName, '', 0, 0, 0, '', 'classfortooltip');
152 print '<span class="doc-icon-list-item">'.$iconCode;
153 print '<span class="doc-icon-hidden-name-for-search">'.$iconName.'</span></span>';
154 }
155 }
156 ?>
157 </div>
158
159 <div class="search-tool-no-results center hidden-search-result" ><?php print $langs->trans('NoResults') ?></div>
160 </div>
161 </div>
162 <!-- -->
163
164
165 <br><br>
166
167
168 <!-- List of usage font awesome icon -->
169 <div class="documentation-section" id="icon-section-list">
170
171 <?php
172
173 $iconFileName = 'shims.json';
174 $iconFilePath = DOL_DOCUMENT_ROOT . '/theme/common/fontawesome-5/metadata';
175
176 $fontAwesomeIconRaw = file_get_contents($iconFilePath. '/' .$iconFileName);
177 if ($fontAwesomeIconRaw === false) {
178 dol_print_error($db, 'Error missing file '. $iconFilePath . '/' . $iconFileName);
179 }
180
181 $fontAwesomeIcons = json_decode($fontAwesomeIconRaw);
182 if ($fontAwesomeIcons === null) {
183 dol_print_error($db, 'Error decoding '. $iconFilePath . '/' . $iconFileName);
184 }
185 ?>
186
187 <h2 class="documentation-title"><?php echo $langs->trans('DocIconsListFontAwesome'); ?></h2>
188 <?php /* <p class="documentation-text"><?php echo $langs->trans('DocDocIconsListDescription'); ?></p>*/ ?>
189
190 <?php print $form->getSearchFilterToolInput('.documentation-fontawesome-icon-list .info-box, .documentation-fontawesome-icon-list .doc-icon-list-item',
191 'search-tools-input',
192 '',
193 ['attr' => [
194 'data-no-item-target' => '#icon-section-list .search-tool-no-results',
195 ],
196 ]
197 ); ?>
198
199 <div class="right">
200 <?php
201 if ($mode != 'no-btn') {
202 print dolGetButtonTitle($revertDisplayName, '', $switchDisplayLinkIcon, $switchDisplayLink.'#icon-section-list', '', 1, ['forcenohideoftext'=>1]);
203 }
204 ?>
205 </div>
206
207 <div class="documentation-example">
208 <div class="documentation-fontawesome-icon-list">
209 <?php
210 $alreadyDisplay = [];
211 if ($fontAwesomeIcons && is_array($fontAwesomeIcons)) {
212 foreach ($fontAwesomeIcons as $iconData) {
213 $class= $iconData[1]??'fa';
214 if (!empty($iconData[2])) {
215 $class.= ' fa-'.$iconData[2];
216 } else {
217 $class.= ' fa-'.$iconData[0];
218 }
219
220 if (in_array($class, $alreadyDisplay)) {
221 continue;
222 }
223
224 $alreadyDisplay[] = $class;
225 $iconCode = '<span class="'.$class.'" ></span>';
226
227 if ($displayMode == 'kanban') {
228 print '<div class="info-box ">
229 <span class="info-box-icon bg-infobox-expensereport">
230 ' . $iconCode . '
231 </span>
232 <div class="info-box-content">
233 <div class="info-box-title" >' . ($iconData[2] ?? ($iconData[0] ?? '')) . '</div>
234 <div class="info-box-lines">
235 <div class="info-box-line spanoverflow nowrap">
236 <div class="inline-block nowraponall">
237 <div class="documentation-code"><pre>' . dol_htmlentities($iconCode) . '</pre></div>
238 </div>
239 </div>
240 </div><!-- /.info-box-lines -->
241 </div><!-- /.info-box-content -->
242 </div>';
243 } else {
244 $tooltip = '<u>'.$langs->trans("DocCodeForMenuOrModuleBuilder").':</u><br>'.$class;
245 print '<span class="doc-icon-list-item classfortooltip" title="'.dol_escape_htmltag($tooltip).'">'.$iconCode.'<span class="doc-icon-hidden-name-for-search">'.$class.'</span></span>';
246 }
247 }
248 }
249 ?>
250 </div>
251
252 <div class="search-tool-no-results center hidden-search-result" ><?php print $langs->trans('NoResults') ?></div>
253 </div>
254 </div>
255 <!-- -->
256 </div>
257 </div>
258
259<?php
260// Output close body + html
261$documentation->docFooter();
262
263
270function getImgPictoNameList()
271{
272 return array_merge(array_keys(getImgPictoConv()), array(
273 // Reduce this list to picto that are not already into getImgPictoConv()
274 '1downarrow',
275 '1uparrow',
276 '1leftarrow',
277 '1rightarrow',
278 '1uparrow_selected',
279 '1downarrow_selected',
280 '1leftarrow_selected',
281 '1rightarrow_selected',
282 'accountancy',
283 'accounting_account',
284 'account',
285 'accountline',
286 'action',
287 'add',
288 'address',
289 'ai',
290 'angle-double-down',
291 'angle-double-up',
292 'asset',
293 'back',
294 'bank_account',
295 'barcode',
296 'bank',
297 'bell',
298 'bill',
299 'billa',
300 'billr',
301 'billd',
302 'birthday-cake',
303 'blockedlog',
304 'bom',
305 'bookcal',
306 'bookmark',
307 'briefcase-medical',
308 'bug',
309 'building',
310 'card',
311 'calendarlist',
312 'calendar',
313 'calendarmonth',
314 'calendarweek',
315 'calendarday',
316 'calendarperuser',
317 'calendarpertype',
318 'hourglass',
319 'cash-register',
320 'category',
321 'chart',
322 'check',
323 'clock',
324 'clone',
325 'close_title',
326 'code',
327 'cog',
328 'collab',
329 'company',
330 'contact',
331 'country',
332 'contract',
333 'conversation',
334 'cron',
335 'cross',
336 'cubes',
337 'check-circle',
338 'check-square',
339 'circle',
340 'stop-circle',
341 'currency',
342 'multicurrency',
343 'chevron-left',
344 'chevron-right',
345 'chevron-down',
346 'chevron-up',
347 'chevron-double-left',
348 'chevron-double-right',
349 'chevron-double-down',
350 'chevron-double-top',
351 'commercial',
352 'companies',
353 'delete',
354 'dolly',
355 'dollyrevert',
356 'donation',
357 'download',
358 'dynamicprice',
359 'edit',
360 'ellipsis-h',
361 'email',
362 'entity',
363 'envelope',
364 'eraser',
365 'establishment',
366 'expensereport',
367 'external-link-alt',
368 'external-link-square-alt',
369 'eye',
370 'filter',
371 'file',
372 'file-o',
373 'file-code',
374 'file-export',
375 'file-import',
376 'file-upload',
377 'autofill',
378 'folder',
379 'folder-open',
380 'folder-plus',
381 'font',
382 'generate',
383 'generic',
384 'globe',
385 'globe-americas',
386 'graph',
387 'grip',
388 'grip_title',
389 'group',
390 'hands-helping',
391 'help',
392 'holiday',
393 'id-card',
394 'images',
395 'incoterm',
396 'info',
397 'info_black',
398 'intervention',
399 'inventory',
400 'intracommreport',
401 'jobprofile',
402 'key',
403 'knowledgemanagement',
404 'label',
405 'language',
406 'layout',
407 'line',
408 'link',
409 'list',
410 'list-alt',
411 'listlight',
412 'loan',
413 'lock',
414 'lot',
415 'long-arrow-alt-right',
416 'margin',
417 'map-marker-alt',
418 'member',
419 'meeting',
420 'minus',
421 'money-bill-alt',
422 'movement',
423 'mrp',
424 'note',
425 'next',
426 'off',
427 'on',
428 'order',
429 'paragraph',
430 'play',
431 'pdf',
432 'phone',
433 'phoning',
434 'phoning_mobile',
435 'phoning_fax',
436 'playdisabled',
437 'previous',
438 'poll',
439 'pos',
440 'printer',
441 'product',
442 'propal',
443 'proposal',
444 'puce',
445 'resize',
446 'search',
447 'service',
448 'stats',
449 'stock',
450 'security',
451 'setup',
452 'share-alt',
453 'sign-out',
454 'split',
455 'stripe',
456 'stripe-s',
457 'switch_off',
458 'switch_on',
459 'switch_on_grey',
460 'switch_on_warning',
461 'switch_on_red',
462 'tools',
463 'unlink',
464 'uparrow',
465 'user',
466 'user-tie',
467 'vcard',
468 'wrench',
469 'discord',
470 'facebook',
471 'flickr',
472 'instagram',
473 'linkedin',
474 'github',
475 'google',
476 'jabber',
477 'meetup',
478 'microsoft',
479 'skype',
480 'slack',
481 'twitter',
482 'pinterest',
483 'reddit',
484 'snapchat',
485 'tumblr',
486 'youtube',
487 'viadeo',
488 'google-plus-g',
489 'whatsapp',
490 'generic',
491 'home',
492 'hrm',
493 'members',
494 'products',
495 'invoicing',
496 'partnership',
497 'payment',
498 'payment_vat',
499 'pencil-ruler',
500 'pictoconfirm',
501 'preview',
502 'project',
503 'projectpub',
504 'projecttask',
505 'question',
506 'refresh',
507 'region',
508 'salary',
509 'shipment',
510 'state',
511 'supplier_invoice',
512 'supplier_invoicea',
513 'supplier_invoicer',
514 'supplier_invoiced',
515 'technic',
516 'ticket',
517 'error',
518 'warning',
519 'recent',
520 'reception',
521 'recruitmentcandidature',
522 'recruitmentjobposition',
523 'replacement',
524 'resource',
525 'recurring',
526 'rss',
527 'search-plus',
528 'shapes',
529 'skill',
530 'square',
531 'sort-numeric-down',
532 'status',
533 'stop-circle',
534 'supplier',
535 'supplier_proposal',
536 'supplier_order',
537 'supplier_invoice',
538 'terminal',
539 'tick',
540 'timespent',
541 'title_setup',
542 'title_accountancy',
543 'title_bank',
544 'title_hrm',
545 'title_agenda',
546 'trip',
547 'uncheck',
548 'undo',
549 'url',
550 'user-cog',
551 'user-injured',
552 'user-md',
553 'upload',
554 'vat',
555 'website',
556 'workstation',
557 'webhook',
558 'world',
559 'private',
560 'conferenceorbooth',
561 'eventorganization',
562 'stamp',
563 'signature',
564 'webportal'
565 ));
566}
Class to manage UI documentation.
Class to manage generation of HTML components Only common components must be here.
info($id)
Load info of user object.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:171
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
div refaddress div address
$conf db user
Active Directory does not allow anonymous connections.
Definition repair.php:129
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.