dolibarr 20.0.2
test_badges.php
1<?php
2//define("NOLOGIN",1); // This means this output page does not require to be logged.
3define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
4if (!defined('NOSESSION')) {
5 define('NOSESSION', '1');
6}
7
8require_once '../../main.inc.php';
9require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
10
11if ($dolibarr_main_prod) {
12 accessforbidden('Access forbidden when $dolibarr_main_prod is set to 1');
13}
14
15/*
16 * View
17 */
18
19header("Content-type: text/html; charset=UTF8");
20
21// Security options
22header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
23header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks)
24
25?>
26<!doctype html>
27<html lang="en">
28 <head>
29 <meta charset="utf-8">
30 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
31 <meta name="description" content="Documentation and examples for theme.">
32
33 <link href="<?php echo DOL_URL_ROOT ?>/theme/eldy/style.css.php" rel="stylesheet">
34 </head>
35 <body class="docpage" style="padding: 20px;">
36
37 <main role="main" >
38 <h1 class="bd-title" id="content">Badges</h1>
39 <p class="bd-lead">Documentation and examples for badges, our small count and labeling component.</p>
40
41 <h2 id="example">Example</h2>
42
43 <p>Badges scale to match the size of the immediate parent element by using relative font sizing and em units.</p>
44
45 <div class="bd-example">
46 <h1>Example heading <span class="badge badge-secondary">New</span></h1>
47 <h2>Example heading <span class="badge badge-secondary">New</span></h2>
48 <h3>Example heading <span class="badge badge-secondary">New</span></h3>
49 <h4>Example heading <span class="badge badge-secondary">New</span></h4>
50 <h5>Example heading <span class="badge badge-secondary">New</span></h5>
51 <h6>Example heading <span class="badge badge-secondary">New</span></h6>
52 </div>
53
54 <figure class="highlight">
55 <pre>
56
57&lt;h1&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h1&gt;
58&lt;h2&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h2&gt;
59&lt;h3&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h3&gt;
60&lt;h4&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h4&gt;
61&lt;h5&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h5&gt;
62&lt;h6&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h6&gt;
63
64 </pre>
65 </figure>
66
67 <p>Badges can be used as part of links or buttons to provide a counter.</p>
68
69 <div class="bd-example">
70 <button type="button" class="button">
71 Notifications <span class="badge badge-primary">4</span>
72 </button>
73 </div>
74
75 <figure class="highlight"><pre>
76&lt;button type=&quot;button&quot; class=&quot;button&quot;&gt;
77 Notifications &lt;span class=&quot;badge badge-primary&quot;&gt;4&lt;/span&gt;
78&lt;/button&gt;
79 </pre></figure>
80
81 <div class="warning">
82 <p>Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.</p>
83
84 <p>Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.</p>
85
86 <p><strong>Remember to use aria-label attribute for accessibility in Dolibarr. Don't forget to use aria-hidden on icons included in badges</strong></p>
87 </div>
88
89 <div class="bd-example">
90 <button type="button" class="button">
91 Profile <span class="badge badge-primary" aria-label="9 unread messages" >9</span>
92 <span class="sr-only">unread messages</span>
93 </button>
94 </div>
95
96 <figure class="highlight">
97 <pre>
98
99
100&lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot;&gt;
101 Profile &lt;span class=&quot;badge badge-light&quot; aria-label=&quot;9 unread messages&quot; &gt;9&lt;/span&gt;
102 &lt;span class=&quot;sr-only&quot;&gt;unread messages&lt;/span&gt;
103&lt;/button&gt;
104
105
106 </pre>
107 </figure>
108
109 <h2 id="contextual-variations">Contextual variations</h2>
110
111 <p>Add any of the below mentioned modifier classes to change the appearance of a badge.</p>
112
113 <div class="bd-example">
114
115 <span class="badge badge-primary">Primary</span>
116 <span class="badge badge-secondary">Secondary</span>
117 <span class="badge badge-success">Success</span>
118 <span class="badge badge-danger">Danger</span>
119 <span class="badge badge-warning">Warning</span>
120 <span class="badge badge-info">Info</span>
121 <span class="badge badge-light">Light</span>
122 <span class="badge badge-dark">Dark</span>
123 </div>
124
125 <figure class="highlight">
126 <pre>
127
128&lt;span class=&quot;badge badge-primary&quot;&gt;Primary&lt;/span&gt;
129&lt;span class=&quot;badge badge-secondary&quot;&gt;Secondary&lt;/span&gt;
130&lt;span class=&quot;badge badge-success&quot;&gt;Success&lt;/span&gt;
131&lt;span class=&quot;badge badge-danger&quot;&gt;Danger&lt;/span&gt;
132&lt;span class=&quot;badge badge-warning&quot;&gt;Warning&lt;/span&gt;
133&lt;span class=&quot;badge badge-info&quot;&gt;Info&lt;/span&gt;
134&lt;span class=&quot;badge badge-light&quot;&gt;Light&lt;/span&gt;
135&lt;span class=&quot;badge badge-dark&quot;&gt;Dark&lt;/span&gt;
136
137 </pre>
138 </figure>
139
140 <div class="warning">
141 <h5 id="conveying-meaning-to-assistive-technologies">Conveying meaning to assistive technologies</h5>
142
143 <p>Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.</p>
144 </div>
145
146
147
148 <h2 id="contextual-variations">Default status</h2>
149
150 <p>Add any of the below mentioned modifier classes to change the appearance of a badge to be linked to a default status.</p>
151
152 <div class="bd-example">
153 <?php for ($i = 0; $i <= 9; $i++) : ?>
154 <span class="badge badge-status<?php print $i; ?>" >status-<?php print $i; ?></span>
155 <?php endfor; ?>
156 </div>
157
158 <figure class="highlight"><pre><pre>
159<?php for ($i = 0; $i <= 9; $i++) : ?>
160&lt;span class="badge badge-status<?php print $i; ?>" &gt;status<?php print $i; ?>&lt;/span&gt;
161<?php endfor; ?>
162 </pre></figure>
163
164
165 <h2 id="pill-badges">Pill badges</h2>
166
167 <p>Use the .badge-pill modifier class to make badges more rounded (with a larger border-radius and additional horizontal padding).</p>
168
169 <div class="bd-example">
170
171 <span class="badge badge-pill badge-primary">Primary</span>
172 <span class="badge badge-pill badge-secondary">Secondary</span>
173 <span class="badge badge-pill badge-success">Success</span>
174 <span class="badge badge-pill badge-danger">Danger</span>
175 <span class="badge badge-pill badge-warning">Warning</span>
176 <span class="badge badge-pill badge-info">Info</span>
177 <span class="badge badge-pill badge-light">Light</span>
178 <span class="badge badge-pill badge-dark">Dark</span>
179
180 <?php for ($i = 0; $i <= 9; $i++) : ?>
181 <span class="badge badge-pill badge-status<?php print $i; ?>" >status<?php print $i; ?></span>
182 <?php endfor; ?>
183
184 </div>
185
186 <figure class="highlight">
187 <pre>
188
189&lt;span class=&quot;badge badge-pill badge-primary&quot;&gt;Primary&lt;/span&gt;
190&lt;span class=&quot;badge badge-pill badge-secondary&quot;&gt;Secondary&lt;/span&gt;
191&lt;span class=&quot;badge badge-pill badge-success&quot;&gt;Success&lt;/span&gt;
192&lt;span class=&quot;badge badge-pill badge-danger&quot;&gt;Danger&lt;/span&gt;
193&lt;span class=&quot;badge badge-pill badge-warning&quot;&gt;Warning&lt;/span&gt;
194&lt;span class=&quot;badge badge-pill badge-info&quot;&gt;Info&lt;/span&gt;
195&lt;span class=&quot;badge badge-pill badge-light&quot;&gt;Light&lt;/span&gt;
196&lt;span class=&quot;badge badge-pill badge-dark&quot;&gt;Dark&lt;/span&gt;
197<?php for ($i = 0; $i <= 9; $i++) : ?>
198&lt;span class="badge badge-pill badge-status<?php print $i; ?>" &gt;status<?php print $i; ?>&lt;/span&gt;
199<?php endfor; ?>
200 </pre></figure>
201
202
203
204 <h2 id="dot-badges">Dot badges</h2>
205
206 <p>.dot-pill modifier class to make badges circle.</p>
207
208 <div class="bd-example">
209
210 <span class="badge badge-dot badge-primary"></span>
211 <span class="badge badge-dot badge-secondary"></span>
212 <span class="badge badge-dot badge-success"></span>
213 <span class="badge badge-dot badge-danger"></span>
214 <span class="badge badge-dot badge-warning"></span>
215 <span class="badge badge-dot badge-info"></span>
216 <span class="badge badge-dot badge-light"></span>
217 <span class="badge badge-dot badge-dark"></span>
218
219 <?php for ($i = 0; $i <= 9; $i++) : ?>
220 <span class="badge badge-dot badge-status<?php print $i; ?>" ></span>
221 <?php endfor; ?>
222
223 </div>
224
225 <figure class="highlight">
226 <pre>
227
228&lt;span class=&quot;badge badge-dot badge-primary&quot;&gt;&lt;/span&gt;
229&lt;span class=&quot;badge badge-dot badge-secondary&quot;&gt;&lt;/span&gt;
230&lt;span class=&quot;badge badge-dot badge-success&quot;&gt;&lt;/span&gt;
231&lt;span class=&quot;badge badge-dot badge-danger&quot;&gt;&lt;/span&gt;
232&lt;span class=&quot;badge badge-dot badge-warning&quot;&gt;&lt;/span&gt;
233&lt;span class=&quot;badge badge-dot badge-info&quot;&gt;&lt;/span&gt;
234&lt;span class=&quot;badge badge-dot badge-light&quot;&gt;&lt;/span&gt;
235&lt;span class=&quot;badge badge-dot badge-dark&quot;&gt;&lt;/span&gt;
236<?php for ($i = 0; $i <= 9; $i++) : ?>
237&lt;span class="badge badge-dot badge-status<?php print $i; ?>" &gt;&lt;/span&gt;
238<?php endfor; ?>
239 </pre></figure>
240
241
242<div class="warning">
243 <p>Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.</p>
244
245 <p>Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.</p>
246
247 <p><strong>Remember to use aria-label attribute for accessibility in Dolibarr. Don't forget to use aria-hidden on icons included in badges</strong></p>
248</div>
249
250
251 <h2 id="links">Links</h2>
252
253 <p>Using the contextual .badge-* classes on an &lt;a&gt; element quickly provide <em>actionable</em> badges with hover and focus states.</p>
254
255 <div class="bd-example">
256
257 <a href="#" class="badge badge-primary">Primary</a>
258 <a href="#" class="badge badge-secondary">Secondary</a>
259 <a href="#" class="badge badge-success">Success</a>
260 <a href="#" class="badge badge-danger">Danger</a>
261 <a href="#" class="badge badge-warning">Warning</a>
262 <a href="#" class="badge badge-info">Info</a>
263 <a href="#" class="badge badge-light">Light</a>
264 <a href="#" class="badge badge-dark">Dark</a>
265 <?php for ($i = 0; $i <= 9; $i++) : ?>
266 <a href="#" class="badge badge-status<?php print $i; ?>" >status<?php print $i; ?></a>
267 <?php endfor; ?>
268
269 </div>
270
271 <figure class="highlight"><pre>
272&lt;a href=&quot;#&quot; class=&quot;badge badge-primary&quot;&gt;Primary&lt;/a&gt;
273&lt;a href=&quot;#&quot; class=&quot;badge badge-secondary&quot;&gt;Secondary&lt;/a&gt;
274&lt;a href=&quot;#&quot; class=&quot;badge badge-success&quot;&gt;Success&lt;/a&gt;
275&lt;a href=&quot;#&quot; class=&quot;badge badge-danger&quot;&gt;Danger&lt;/a&gt;
276&lt;a href=&quot;#&quot; class=&quot;badge badge-warning&quot;&gt;Warning&lt;/a&gt;
277&lt;a href=&quot;#&quot; class=&quot;badge badge-info&quot;&gt;Info&lt;/a&gt;
278&lt;a href=&quot;#&quot; class=&quot;badge badge-light&quot;&gt;Light&lt;/a&gt;
279&lt;a href=&quot;#&quot; class=&quot;badge badge-dark&quot;&gt;Dark&lt;/a&gt;
280<?php for ($i = 0; $i <= 9; $i++) : ?>
281&lt;a href=&quot;#&quot; class="badge badge-status<?php print $i; ?>" &gt;status<?php print $i; ?>&lt;/a&gt;
282<?php endfor; ?>
283 </pre></figure>
284
285
286 <h2 id="helper">Use badge helper function</h2>
287 <p>Using the dolGetBadge function provide in core/lib/functions.lib.php. This function is recommended for code uniformisation and easy maintain</p>
288 <?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'primary') ?>
289 <?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'danger', 'pill') ?>
290 <?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'warning', 'dot') ?>
291
292 <figure class="highlight"><pre>
293&lt;?php print dolGetBadge('your label for accessibility', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'danger', 'pill') ?&gt;
294&lt;?php print dolGetBadge('your label for accessibility', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'warning', 'dot') ?&gt;
295 </pre></figure>
296
297 <h2 id="helper">Use status helper function</h2>
298 <p>Using the dolGetStatus function provide in core/lib/functions.lib.php. This function is recommended for code uniformisation and easy maintain</p>
299 <?php
300 $saveGlobalConf = getDolGlobalString('MAIN_STATUS_USES_CSS');
301 $conf->global->MAIN_STATUS_USES_CSS = 1;
302 ?>
303 <h4>Using hidden global conf MAIN_STATUS_USES_CSS=1</h4>
304 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4') ?></p>
305 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 1) ?></p>
306 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 2) ?></p>
307 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 3) ?></p>
308 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 4) ?></p>
309 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 5) ?></p>
310 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 6) ?></p>
311
312 <?php $conf->global->MAIN_STATUS_USES_CSS = 0; ?>
313 <h4>Disabled hidden global conf : MAIN_STATUS_USES_CSS=0</h4>
314 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 1) ?></p>
315 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 2) ?></p>
316 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 3) ?></p>
317 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 4) ?></p>
318 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 5) ?></p>
319 <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 6) ?></p>
320
321 <?php $conf->global->MAIN_STATUS_USES_CSS = $saveGlobalConf; ?>
322
323
324 <figure class="highlight"><pre>
325&lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4') ?&gt;
326&lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',1) ?&gt;
327&lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',2) ?&gt;
328&lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',3) ?&gt;
329&lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',4) ?&gt;
330&lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',5) ?&gt;
331&lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',6) ?&gt;
332 </pre></figure>
333
334
335 </main>
336
337 </body>
338</html>
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:637
Class to manage donations.
Definition don.class.php:41
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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
conf($dolibarr_main_document_root)
Load conf file (file must exists)
Definition inc.php:420
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.