dolibarr 24.0.0-beta
icons.php
1<?php
2/*
3 * Copyright (C) 2024 Anthony Damhet <a.damhet@progiseize.fr>
4 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program and files/directory inner it is free software: you can
7 * redistribute it and/or modify it under the terms of the
8 * GNU Affero General Public License (AGPL) as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU AGPL for more details.
16 *
17 * You should have received a copy of the GNU AGPL
18 * along with this program. If not, see <https://www.gnu.org/licenses/agpl-3.0.html>.
19 */
20
21// Load Dolibarr environment
22require '../../../../main.inc.php';
23
31// Protection if external user
32if ($user->socid > 0) {
34}
35
36// Includes
37require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php';
38
39// Load documentation translations
40$langs->load('uxdocumentation');
41
42//
43$documentation = new Documentation($db);
44
45// Output html head + body - Param is Title
46$documentation->docHeader('Icons', [], ['admin/tools/ui/css/doc-icons.css'], GETPOST('hidenavmenu'));
47
48// Set view for menu and breadcrumb
49// Menu must be set in constructor of documentation class
50$documentation->view = array('Components','Icons');
51$form = new Form($db);
52
53$mode = GETPOST('mode'); // ex : no-btn
54$displayMode = GETPOST('displayMode') == 'kanban' ? 'kanban' : 'icon-only';
55$revertDisplayMode = $displayMode == 'kanban' ? 'icon-only' : 'kanban';
56$revertDisplayName = $displayMode == 'kanban' ? $langs->trans('ViewList') : $langs->trans('ViewKanban');
57$switchDisplayLink = dol_buildpath($documentation->baseUrl . '/components/icons.php', 1) . '?displayMode=' . $revertDisplayMode;
58$switchDisplayLinkIcon = $displayMode == 'kanban' ? 'fa fa-th' : 'fa fa-th-list';
59
60// Output sidebar
61if (!GETPOST('hidenavmenu')) {
62 $documentation->showSidebar();
63}
64?>
65
66<div class="doc-wrapper<?php print GETPOST('hidenavmenu') ? "-bis" : ""; ?>">
67
68 <?php
69 if (!GETPOST('hidenavmenu')) {
70 $documentation->showBreadCrumb();
71 }
72 ?>
73
74 <div class="doc-content-wrapper">
75
76 <h1 class="documentation-title"><?php echo $langs->trans('DocIconsTitle'); ?></h1>
77 <p class="documentation-text"><?php echo $langs->trans('DocIconsMainDescription'); ?></p>
78
79 <!-- Summary -->
80 <?php $documentation->showSummary(); ?>
81
82 <br>
83
84 <!-- List of usage font awesome icon -->
85 <div class="documentation-section" id="img-picto-section-list">
86
87 <?php
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 $iconFileFa = 'icons.json';
173 $iconFilePath = DOL_DOCUMENT_ROOT . '/theme/common/fontawesome-5/metadata';
174
175 // Load the full FontAwesome 5 icons JSON
176 $allIconsRaw = file_get_contents($iconFilePath . '/' . $iconFileFa);
177 $fontAwesomeIcons = []; // This will be the output array in shims.json format
178
179 if ($allIconsRaw === false) {
180 dol_print_error($db, 'Error: missing file ' . $iconFilePath . '/' . $iconFileFa);
181 } else {
182 $allIcons = json_decode($allIconsRaw, true);
183 if ($allIcons === null) {
184 dol_print_error($db, 'Error: cannot decode JSON from ' . $iconFilePath . '/' . $iconFileFa);
185 } else {
186 foreach ($allIcons as $iconName => $iconData) {
187 // Determine prefix: 'fab' for brands, 'fas' or 'far' can be added later if needed
188 $prefix = in_array('brands', $iconData['styles']) ? 'fab' : null;
189 // Format: [ "icon-name", "prefix if any", null ]
190 $fontAwesomeIcons[] = [$iconName, $prefix, null]; // null reserved for future alias
191 }
192 }
193 }
194 ?>
195
196 <h2 class="documentation-title"><?php echo $langs->trans('DocIconsListFontAwesome'); ?></h2>
197 <?php /* <p class="documentation-text"><?php echo $langs->trans('DocDocIconsListDescription'); ?></p>*/ ?>
198
199 <?php print $form->getSearchFilterToolInput('.documentation-fontawesome-icon-list .info-box, .documentation-fontawesome-icon-list .doc-icon-list-item',
200 'search-tools-input',
201 '',
202 ['attr' => [
203 'data-no-item-target' => '#icon-section-list .search-tool-no-results',
204 ],
205 ]
206 ); ?>
207
208 <div class="right">
209 <?php
210 if ($mode != 'no-btn') {
211 print dolGetButtonTitle($revertDisplayName, '', $switchDisplayLinkIcon, $switchDisplayLink.'#icon-section-list', '', 1, ['forcenohideoftext' => 1]);
212 }
213 ?>
214 </div>
215
216 <div class="documentation-example">
217 <div class="documentation-fontawesome-icon-list">
218 <?php
219 $alreadyDisplay = [];
220 if ($fontAwesomeIcons) {
221 foreach ($fontAwesomeIcons as $iconData) {
222 $class = $iconData[1] ?? 'fa';
223 if (!empty($iconData[2])) {
224 $class .= ' fa-'.$iconData[2];
225 } else {
226 $class .= ' fa-'.$iconData[0];
227 }
228
229 if (in_array($class, $alreadyDisplay)) {
230 continue;
231 }
232
233 $alreadyDisplay[] = $class;
234 $iconCode = '<span class="'.$class.'" ></span>';
235 $iconLabel = !empty($iconData[2]) ? $iconData[2] : $iconData[0];
236
237 if ($displayMode == 'kanban') {
238 print '<div class="info-box ">
239 <span class="info-box-icon bg-infobox-expensereport">
240 ' . $iconCode . '
241 </span>
242 <div class="info-box-content">
243 <div class="info-box-title" >' . $iconLabel . '</div>
244 <div class="info-box-lines">
245 <div class="info-box-line spanoverflow nowrap">
246 <div class="inline-block nowraponall">
247 <div class="documentation-code"><pre>' . dol_htmlentities($iconCode) . '</pre></div>
248 </div>
249 </div>
250 </div><!-- /.info-box-lines -->
251 </div><!-- /.info-box-content -->
252 </div>';
253 } else {
254 $tooltip = '<u>'.$langs->trans("DocCodeForMenuOrModuleBuilder").':</u><br>'.$class;
255 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>';
256 }
257 }
258 }
259 ?>
260 </div>
261
262 <div class="search-tool-no-results center hidden-search-result" ><?php print $langs->trans('NoResults') ?></div>
263 </div>
264 </div>
265 <!-- -->
266 </div>
267 </div>
268
269<?php
270// Output close body + html
271$documentation->docFooter();
272
273
280function getImgPictoNameList()
281{
282 $imgpicto = array_merge(array_keys(getImgPictoConv()), array(
283 // Keep in this list only picto that are NOT already into getImgPictoConv()
284 '1downarrow',
285 '1uparrow',
286 '1leftarrow',
287 '1rightarrow',
288 '1uparrow_selected',
289 '1downarrow_selected',
290 '1leftarrow_selected',
291 '1rightarrow_selected',
292 'angle-double-down',
293 'angle-double-up',
294 'barcode',
295 'bank',
296 'bell',
297 'birthday-cake',
298 'briefcase-medical',
299 'bug',
300 'building',
301 'hourglass',
302 'cash-register',
303 'clock',
304 'clone',
305 'code',
306 'cog',
307 'cron',
308 'cubes',
309 'check-circle',
310 'check-square',
311 'circle',
312 'chevron-left',
313 'chevron-right',
314 'chevron-down',
315 'chevron-up',
316 'dolly',
317 'download',
318 'ellipsis-h',
319 'envelope',
320 'eraser',
321 'external-link-alt',
322 'external-link-square-alt',
323 'eye',
324 'file',
325 'file-code',
326 'file-export',
327 'file-import',
328 'file-upload',
329 'autofill',
330 'folder',
331 'folder-open',
332 'folder-plus',
333 'font',
334 'generic',
335 'globe-americas',
336 'hands-helping',
337 'id-card',
338 'images',
339 'key',
340 'language',
341 'link',
342 'list',
343 'listlight',
344 'lock',
345 'long-arrow-alt-right',
346 'map-marker-alt',
347 'minus',
348 'money-bill-alt',
349 'note',
350 'off',
351 'on',
352 'paragraph',
353 'play',
354 'phone',
355 'search',
356 'share-alt',
357 'stripe-s',
358 'unlink',
359 'user',
360 'user-tie',
361 'wrench',
362 'discord',
363 'facebook',
364 'flickr',
365 'instagram',
366 'linkedin',
367 'github',
368 'google',
369 'meetup',
370 'microsoft',
371 'skype',
372 'slack',
373 'twitter',
374 'pinterest',
375 'reddit',
376 'snapchat',
377 'tumblr',
378 'youtube',
379 'viadeo',
380 'google-plus-g',
381 'whatsapp',
382 'home',
383 'pencil-ruler',
384 'question',
385 'rss',
386 'search-plus',
387 'shapes',
388 'square',
389 'sort-numeric-down',
390 'supplier_invoice',
391 'terminal',
392 'undo',
393 'user-cog',
394 'user-injured',
395 'user-md',
396 'upload',
397 'stamp',
398 'signature'
399 ));
400
401 asort($imgpicto);
402
403 return array_unique($imgpicto); // @phpstan-ignore return.type
404}
Class to manage UI documentation.
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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)
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...
$conf db user
Active Directory does not allow anonymous connections.
Definition repair.php:134
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.