dolibarr 21.0.0-beta
badges.php
1<?php
2/*
3 * Copyright (C) 2024 Anthony Damhet <a.damhet@progiseize.fr>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License 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 General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
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$morejs = [
45 '/includes/ace/src/ace.js',
46 '/includes/ace/src/ext-statusbar.js',
47 '/includes/ace/src/ext-language_tools.js',
48];
49// Output html head + body - Param is Title
50$documentation->docHeader('Badges', $morejs);
51
52// Set view for menu and breadcrumb
53// Menu must be set in constructor of documentation class
54$documentation->view = array('Components','Badges');
55
56// Output sidebar
57$documentation->showSidebar(); ?>
58
59<div class="doc-wrapper">
60
61 <?php $documentation->showBreadCrumb(); ?>
62
63 <div class="doc-content-wrapper">
64
65 <h1 class="documentation-title"><?php echo $langs->trans('DocBadgeTitle'); ?></h1>
66 <p class="documentation-text"><?php echo $langs->trans('DocBadgeMainDescription'); ?></p>
67
68 <!-- Summary -->
69 <?php $documentation->showSummary(); ?>
70
71 <!-- Basic usage -->
72 <div class="documentation-section" id="badgesection-basicusage">
73 <h2 class="documentation-title"><?php echo $langs->trans('DocBasicUsage'); ?></h2>
74 <p class="documentation-text"><?php echo $langs->trans('DocBadgeScaleDescription'); ?></p>
75 <div class="documentation-example">
76 <h1>Example heading <span class="badge badge-secondary">New</span></h1>
77 <h2>Example heading <span class="badge badge-secondary">New</span></h2>
78 <h3>Example heading <span class="badge badge-secondary">New</span></h3>
79 <h4>Example heading <span class="badge badge-secondary">New</span></h4>
80 <h5>Example heading <span class="badge badge-secondary">New</span></h5>
81 <h6>Example heading <span class="badge badge-secondary">New</span></h6>
82 </div>
83
84 <?php
85 $lines = array(
86 '<h1>Example heading <span class="badge badge-secondary">New</span></h1>',
87 '<h2>Example heading <span class="badge badge-secondary">New</span></h2>',
88 '<h3>Example heading <span class="badge badge-secondary">New</span></h3>',
89 '<h4>Example heading <span class="badge badge-secondary">New</span></h4>',
90 '<h5>Example heading <span class="badge badge-secondary">New</span></h5>',
91 '<h6>Example heading <span class="badge badge-secondary">New</span></h6>'
92 );
93 echo $documentation->showCode($lines); ?>
94
95 <p class="documentation-text"><?php echo $langs->trans('DocBadgeUseOnLinksOrButtons'); ?></p>
96 <div class="documentation-example">
97 <button type="button" class="button">
98 <?php echo $langs->trans('Notifications'); ?> <span class="badge badge-primary">4</span>
99 </button>
100 </div>
101
102 <?php
103 $lines = array(
104 '<button type="button" class="button">',
105 ' Notifications <span class="badge badge-primary">4</span>',
106 '</button>',
107 );
108 echo $documentation->showCode($lines); ?>
109
110 <div class="warning">
111 <p class="documentation-text"><?php echo $langs->trans('DocBadgeWarningAriaHidden1'); ?></p>
112 <p class="documentation-text"><?php echo $langs->trans('DocBadgeWarningAriaHidden2'); ?></p>
113 <p class="documentation-text"><strong><?php echo $langs->trans('DocBadgeWarningAriaHidden3'); ?></strong></p>
114 </div>
115
116 <div class="documentation-example">
117 <button type="button" class="button">
118 Profile <span class="badge badge-primary" aria-label="9 unread messages" >9</span>
119 <span class="sr-only">unread messages</span>
120 </button>
121 </div>
122
123 <?php
124 $lines = array(
125 '<button type="button" class="button">',
126 ' Profile <span class="badge badge-primary" aria-label="9 unread messages" >9</span>',
127 ' <span class="sr-only">unread messages</span>',
128 '</button>',
129 );
130 echo $documentation->showCode($lines); ?>
131 </div>
132
133 <!-- Contextual variations -->
134 <div class="documentation-section" id="badgesection-contextvariations">
135 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgeContextualVariations'); ?></h2>
136 <p class="documentation-text"><?php echo $langs->trans('DocBadgeContextualVariationsDescription'); ?></p>
137 <div class="documentation-example">
138 <span class="badge badge-primary">Primary</span>
139 <span class="badge badge-secondary">Secondary</span>
140 <span class="badge badge-success">Success</span>
141 <span class="badge badge-danger">Danger</span>
142 <span class="badge badge-warning">Warning</span>
143 <span class="badge badge-info">Info</span>
144 <span class="badge badge-light">Light</span>
145 <span class="badge badge-dark">Dark</span>
146 </div>
147 <?php
148 $lines = array(
149 '<span class="badge badge-primary">Primary</span>',
150 '<span class="badge badge-secondary">Secondary</span>',
151 '<span class="badge badge-success">Success</span>',
152 '<span class="badge badge-danger">Danger</span>',
153 '<span class="badge badge-warning">Warning</span>',
154 '<span class="badge badge-info">Info</span>',
155 '<span class="badge badge-light">Light</span>',
156 '<span class="badge badge-dark">Dark</span>',
157 );
158 echo $documentation->showCode($lines); ?>
159 <div class="warning">
160 <p class="documentation-text"><strong><?php echo $langs->trans('DocBadgeContextualVariationsWarning1'); ?></strong></p>
161 <p class="documentation-text"><?php echo $langs->trans('DocBadgeContextualVariationsWarning2'); ?></p>
162 </div>
163 </div>
164
165 <!-- Default status -->
166 <div class="documentation-section" id="badgesection-defaultstatus">
167 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgeDefaultStatus'); ?></h2>
168 <p class="documentation-text"><?php echo $langs->trans('DocBadgeDefaultStatusDescription'); ?></p>
169 <div class="documentation-example">
170 <?php for ($i = 0; $i <= 9; $i++) : ?>
171 <span class="badge badge-status<?php print $i; ?>" >status-<?php print $i; ?></span>
172 <?php endfor; ?>
173 </div>
174 <?php
175 $lines = array();
176 for ($i = 0; $i <= 9; $i++) :
177 $lines[] = '<span class="badge badge-status'.$i.'">status-'.$i.'</span>';
178 endfor;
179 echo $documentation->showCode($lines); ?>
180 </div>
181
182 <!-- Pill badges -->
183 <div class="documentation-section" id="badgesection-pill">
184 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgePillBadges'); ?></h2>
185 <p class="documentation-text"><?php echo $langs->trans('DocBadgePillBadgesDescription'); ?></p>
186 <div class="documentation-example">
187 <span class="badge badge-pill badge-primary">Primary</span>
188 <span class="badge badge-pill badge-secondary">Secondary</span>
189 <span class="badge badge-pill badge-success">Success</span>
190 <span class="badge badge-pill badge-danger">Danger</span>
191 <span class="badge badge-pill badge-warning">Warning</span>
192 <span class="badge badge-pill badge-info">Info</span>
193 <span class="badge badge-pill badge-light">Light</span>
194 <span class="badge badge-pill badge-dark">Dark</span>
195 <?php for ($i = 0; $i <= 9; $i++) : ?>
196 <span class="badge badge-pill badge-status<?php print $i; ?>">status<?php print $i; ?></span>
197 <?php endfor; ?>
198 </div>
199 <?php
200 $lines = array(
201 '<span class="badge badge-pill badge-primary">Primary</span>',
202 '<span class="badge badge-pill badge-secondary">Secondary</span>',
203 '<span class="badge badge-pill badge-success">Success</span>',
204 '<span class="badge badge-pill badge-danger">Danger</span>',
205 '<span class="badge badge-pill badge-warning">Warning</span>',
206 '<span class="badge badge-pill badge-info">Info</span>',
207 '<span class="badge badge-pill badge-light">Light</span>',
208 '<span class="badge badge-pill badge-dark">Dark</span>',
209 );
210 for ($i = 0; $i <= 9; $i++) :
211 $lines[] = '<span class="badge badge-pill badge-status'.$i.'">status-'.$i.'</span>';
212 endfor;
213 echo $documentation->showCode($lines); ?>
214 </div>
215
216 <!-- Dot badges -->
217 <div class="documentation-section" id="badgesection-dot">
218 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgeDotBadges'); ?></h2>
219 <p class="documentation-text"><?php echo $langs->trans('DocBadgeDotBadgesDescription'); ?></p>
220 <div class="documentation-example">
221 <span class="badge badge-dot badge-primary"></span>
222 <span class="badge badge-dot badge-secondary"></span>
223 <span class="badge badge-dot badge-success"></span>
224 <span class="badge badge-dot badge-danger"></span>
225 <span class="badge badge-dot badge-warning"></span>
226 <span class="badge badge-dot badge-info"></span>
227 <span class="badge badge-dot badge-light"></span>
228 <span class="badge badge-dot badge-dark"></span>
229 <?php for ($i = 0; $i <= 9; $i++) : ?>
230 <span class="badge badge-dot badge-status<?php print $i; ?>"></span>
231 <?php endfor; ?>
232 </div>
233 <?php
234 $lines = array(
235 '<span class="badge badge-dot badge-primary"></span>',
236 '<span class="badge badge-dot badge-secondary"></span>',
237 '<span class="badge badge-dot badge-success"></span>',
238 '<span class="badge badge-dot badge-danger"></span>',
239 '<span class="badge badge-dot badge-warning"></span>',
240 '<span class="badge badge-dot badge-info"></span>',
241 '<span class="badge badge-dot badge-light"></span>',
242 '<span class="badge badge-dot badge-dark"></span>',
243 );
244 for ($i = 0; $i <= 9; $i++) :
245 $lines[] = '<span class="badge badge-dot badge-status'.$i.'"></span>';
246 endfor;
247 echo $documentation->showCode($lines); ?>
248 </div>
249
250 <!-- Links -->
251 <div class="documentation-section" id="badgesection-links">
252 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgeLinks'); ?></h2>
253 <p class="documentation-text"><?php echo $langs->trans('DocBadgeLinksDescription'); ?></p>
254 <div class="documentation-example">
255 <a href="#" class="badge badge-primary">Primary</a>
256 <a href="#" class="badge badge-secondary">Secondary</a>
257 <a href="#" class="badge badge-success">Success</a>
258 <a href="#" class="badge badge-danger">Danger</a>
259 <a href="#" class="badge badge-warning">Warning</a>
260 <a href="#" class="badge badge-info">Info</a>
261 <a href="#" class="badge badge-light">Light</a>
262 <a href="#" class="badge badge-dark">Dark</a>
263 <?php for ($i = 0; $i <= 9; $i++) : ?>
264 <a href="#" class="badge badge-status<?php print $i; ?>" >status<?php print $i; ?></a>
265 <?php endfor; ?>
266 </div>
267 <?php
268 $lines = array(
269 '<a href="#" class="badge badge-primary">Primary</a>',
270 '<a href="#" class="badge badge-secondary">Secondary</a>',
271 '<a href="#" class="badge badge-success">Success</a>',
272 '<a href="#" class="badge badge-danger">Danger</a>',
273 '<a href="#" class="badge badge-warning">Warning</a>',
274 '<a href="#" class="badge badge-info">Info</a>',
275 '<a href="#" class="badge badge-light">Light</a>',
276 '<a href="#" class="badge badge-dark">Dark</a>',
277 );
278 for ($i = 0; $i <= 9; $i++) :
279 $lines[] = '<a href="#" class="badge badge-status'.$i.'" >status'.$i.'</a>';
280 endfor;
281 echo $documentation->showCode($lines); ?>
282 </div>
283
284 <!-- Use badge helper function -->
285 <div class="documentation-section" id="badgesection-dolgetbadge">
286 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgeHelper'); ?></h2>
287 <p class="documentation-text"><?php echo $langs->trans('DocBadgeHelperDescription'); ?></p>
288 <div class="documentation-example">
289 <?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'primary'); ?>
290 <?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'danger', 'pill'); ?>
291 <?php print dolGetBadge('your label for accessibility', 'your label', 'warning', 'dot'); ?>
292 </div>
293 <?php
294 $lines = array(
295 "/**",
296 " * Function dolGetBadge",
297 " *",
298 " * @param string \$label label of badge no html : use in alt attribute for accessibility",
299 " * @param string \$html optional : label of badge with html",
300 " * @param string \$type type of badge : Primary Secondary Success Danger Warning Info Light Dark status0 status1 status2 status3 status4 status5 status6 status7 status8 status9",
301 " * @param string \$mode Default '' , 'pill', 'dot'",
302 " * @param string \$url the url for link",
303 " * ... See more: core/lib/functions.lib.php ",
304 "",
305 "<?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'primary'); ?>",
306 "<?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'danger', 'pill'); ?>",
307 "<?php print dolGetBadge('your label for accessibility', 'your label', 'warning', 'dot'); ?>",
308 );
309 echo $documentation->showCode($lines); ?>
310 </div>
311
312 <!-- -->
313
314 </div>
315
316 </div>
317
318<?php
319// Output close body + html
320$documentation->docFooter();
321?>
Class to manage UI documentation.
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
dolGetBadge($label, $html='', $type='primary', $mode='', $url='', $params=array())
Function dolGetBadge.
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
usage($program, $header)
Print the usage when executing scripts from install/.
Definition inc.php:94
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.