dolibarr 21.0.0-beta
badges.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$res=0;
21if (! $res && file_exists("../../main.inc.php")) : $res=@include '../../main.inc.php';
22endif;
23if (! $res && file_exists("../../../main.inc.php")) : $res=@include '../../../main.inc.php';
24endif;
25if (! $res && file_exists("../../../../main.inc.php")) : $res=@include '../../../../main.inc.php';
26endif;
27
28// Protection if external user
29if ($user->socid > 0) : accessforbidden();
30endif;
31
32// Includes
33dol_include_once('admin/tools/ui/class/documentation.class.php');
34
35// Load documentation translations
36$langs->load('uxdocumentation');
37
38//
39$documentation = new Documentation($db);
40
41// Output html head + body - Param is Title
42$documentation->docHeader('Badges');
43
44// Set view for menu and breadcrumb
45// Menu must be set in constructor of documentation class
46$documentation->view = array('Components','Badges');
47
48// Output sidebar
49$documentation->showSidebar(); ?>
50
51<div class="doc-wrapper">
52
53 <?php $documentation->showBreadCrumb(); ?>
54
55 <div class="doc-content-wrapper">
56
57 <h1 class="documentation-title"><?php echo $langs->trans('DocBadgeTitle'); ?></h1>
58 <p class="documentation-text"><?php echo $langs->trans('DocBadgeMainDescription'); ?></p>
59
60 <!-- Summary -->
61 <?php $documentation->showSummary(); ?>
62
63 <!-- Basic usage -->
64 <div class="documentation-section" id="badgesection-basicusage">
65 <h2 class="documentation-title"><?php echo $langs->trans('DocBasicUsage'); ?></h2>
66 <p class="documentation-text"><?php echo $langs->trans('DocBadgeScaleDescription'); ?></p>
67 <div class="documentation-example">
68 <h1>Example heading <span class="badge badge-secondary">New</span></h1>
69 <h2>Example heading <span class="badge badge-secondary">New</span></h2>
70 <h3>Example heading <span class="badge badge-secondary">New</span></h3>
71 <h4>Example heading <span class="badge badge-secondary">New</span></h4>
72 <h5>Example heading <span class="badge badge-secondary">New</span></h5>
73 <h6>Example heading <span class="badge badge-secondary">New</span></h6>
74 </div>
75
76 <?php
77 $lines = array(
78 '<h1>Example heading <span class="badge badge-secondary">New</span></h1>',
79 '<h2>Example heading <span class="badge badge-secondary">New</span></h2>',
80 '<h3>Example heading <span class="badge badge-secondary">New</span></h3>',
81 '<h4>Example heading <span class="badge badge-secondary">New</span></h4>',
82 '<h5>Example heading <span class="badge badge-secondary">New</span></h5>',
83 '<h6>Example heading <span class="badge badge-secondary">New</span></h6>'
84 );
85 echo $documentation->showCode($lines); ?>
86
87 <p class="documentation-text"><?php echo $langs->trans('DocBadgeUseOnLinksOrButtons'); ?></p>
88 <div class="documentation-example">
89 <button type="button" class="button">
90 <?php echo $langs->trans('Notifications'); ?> <span class="badge badge-primary">4</span>
91 </button>
92 </div>
93
94 <?php
95 $lines = array(
96 '<button type="button" class="button">',
97 ' Notifications <span class="badge badge-primary">4</span>',
98 '</button>',
99 );
100 echo $documentation->showCode($lines); ?>
101
102 <div class="warning">
103 <p class="documentation-text"><?php echo $langs->trans('DocBadgeWarningAriaHidden1'); ?></p>
104 <p class="documentation-text"><?php echo $langs->trans('DocBadgeWarningAriaHidden2'); ?></p>
105 <p class="documentation-text"><strong><?php echo $langs->trans('DocBadgeWarningAriaHidden3'); ?></strong></p>
106 </div>
107
108 <div class="documentation-example">
109 <button type="button" class="button">
110 Profile <span class="badge badge-primary" aria-label="9 unread messages" >9</span>
111 <span class="sr-only">unread messages</span>
112 </button>
113 </div>
114
115 <?php
116 $lines = array(
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 );
122 echo $documentation->showCode($lines); ?>
123 </div>
124
125 <!-- Contextual variations -->
126 <div class="documentation-section" id="badgesection-contextvariations">
127 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgeContextualVariations'); ?></h2>
128 <p class="documentation-text"><?php echo $langs->trans('DocBadgeContextualVariationsDescription'); ?></p>
129 <div class="documentation-example">
130 <span class="badge badge-primary">Primary</span>
131 <span class="badge badge-secondary">Secondary</span>
132 <span class="badge badge-success">Success</span>
133 <span class="badge badge-danger">Danger</span>
134 <span class="badge badge-warning">Warning</span>
135 <span class="badge badge-info">Info</span>
136 <span class="badge badge-light">Light</span>
137 <span class="badge badge-dark">Dark</span>
138 </div>
139 <?php
140 $lines = array(
141 '<span class="badge badge-primary">Primary</span>',
142 '<span class="badge badge-secondary">Secondary</span>',
143 '<span class="badge badge-success">Success</span>',
144 '<span class="badge badge-danger">Danger</span>',
145 '<span class="badge badge-warning">Warning</span>',
146 '<span class="badge badge-info">Info</span>',
147 '<span class="badge badge-light">Light</span>',
148 '<span class="badge badge-dark">Dark</span>',
149 );
150 echo $documentation->showCode($lines); ?>
151 <div class="warning">
152 <p class="documentation-text"><strong><?php echo $langs->trans('DocBadgeContextualVariationsWarning1'); ?></strong></p>
153 <p class="documentation-text"><?php echo $langs->trans('DocBadgeContextualVariationsWarning2'); ?></p>
154 </div>
155 </div>
156
157 <!-- Default status -->
158 <div class="documentation-section" id="badgesection-defaultstatus">
159 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgeDefaultStatus'); ?></h2>
160 <p class="documentation-text"><?php echo $langs->trans('DocBadgeDefaultStatusDescription'); ?></p>
161 <div class="documentation-example">
162 <?php for ($i = 0; $i <= 9; $i++) : ?>
163 <span class="badge badge-status<?php print $i; ?>" >status-<?php print $i; ?></span>
164 <?php endfor; ?>
165 </div>
166 <?php
167 $lines = array();
168 for ($i = 0; $i <= 9; $i++) :
169 $lines[] = '<span class="badge badge-status'.$i.'">status-'.$i.'</span>';
170 endfor;
171 echo $documentation->showCode($lines); ?>
172 </div>
173
174 <!-- Pill badges -->
175 <div class="documentation-section" id="badgesection-pill">
176 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgePillBadges'); ?></h2>
177 <p class="documentation-text"><?php echo $langs->trans('DocBadgePillBadgesDescription'); ?></p>
178 <div class="documentation-example">
179 <span class="badge badge-pill badge-primary">Primary</span>
180 <span class="badge badge-pill badge-secondary">Secondary</span>
181 <span class="badge badge-pill badge-success">Success</span>
182 <span class="badge badge-pill badge-danger">Danger</span>
183 <span class="badge badge-pill badge-warning">Warning</span>
184 <span class="badge badge-pill badge-info">Info</span>
185 <span class="badge badge-pill badge-light">Light</span>
186 <span class="badge badge-pill badge-dark">Dark</span>
187 <?php for ($i = 0; $i <= 9; $i++) : ?>
188 <span class="badge badge-pill badge-status<?php print $i; ?>">status<?php print $i; ?></span>
189 <?php endfor; ?>
190 </div>
191 <?php
192 $lines = array(
193 '<span class="badge badge-pill badge-primary">Primary</span>',
194 '<span class="badge badge-pill badge-secondary">Secondary</span>',
195 '<span class="badge badge-pill badge-success">Success</span>',
196 '<span class="badge badge-pill badge-danger">Danger</span>',
197 '<span class="badge badge-pill badge-warning">Warning</span>',
198 '<span class="badge badge-pill badge-info">Info</span>',
199 '<span class="badge badge-pill badge-light">Light</span>',
200 '<span class="badge badge-pill badge-dark">Dark</span>',
201 );
202 for ($i = 0; $i <= 9; $i++) :
203 $lines[] = '<span class="badge badge-pill badge-status'.$i.'">status-'.$i.'</span>';
204 endfor;
205 echo $documentation->showCode($lines); ?>
206 </div>
207
208 <!-- Dot badges -->
209 <div class="documentation-section" id="badgesection-dot">
210 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgeDotBadges'); ?></h2>
211 <p class="documentation-text"><?php echo $langs->trans('DocBadgeDotBadgesDescription'); ?></p>
212 <div class="documentation-example">
213 <span class="badge badge-dot badge-primary"></span>
214 <span class="badge badge-dot badge-secondary"></span>
215 <span class="badge badge-dot badge-success"></span>
216 <span class="badge badge-dot badge-danger"></span>
217 <span class="badge badge-dot badge-warning"></span>
218 <span class="badge badge-dot badge-info"></span>
219 <span class="badge badge-dot badge-light"></span>
220 <span class="badge badge-dot badge-dark"></span>
221 <?php for ($i = 0; $i <= 9; $i++) : ?>
222 <span class="badge badge-dot badge-status<?php print $i; ?>"></span>
223 <?php endfor; ?>
224 </div>
225 <?php
226 $lines = array(
227 '<span class="badge badge-dot badge-primary"></span>',
228 '<span class="badge badge-dot badge-secondary"></span>',
229 '<span class="badge badge-dot badge-success"></span>',
230 '<span class="badge badge-dot badge-danger"></span>',
231 '<span class="badge badge-dot badge-warning"></span>',
232 '<span class="badge badge-dot badge-info"></span>',
233 '<span class="badge badge-dot badge-light"></span>',
234 '<span class="badge badge-dot badge-dark"></span>',
235 );
236 for ($i = 0; $i <= 9; $i++) :
237 $lines[] = '<span class="badge badge-dot badge-status'.$i.'"></span>';
238 endfor;
239 echo $documentation->showCode($lines); ?>
240 </div>
241
242 <!-- Links -->
243 <div class="documentation-section" id="badgesection-links">
244 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgeLinks'); ?></h2>
245 <p class="documentation-text"><?php echo $langs->trans('DocBadgeLinksDescription'); ?></p>
246 <div class="documentation-example">
247 <a href="#" class="badge badge-primary">Primary</a>
248 <a href="#" class="badge badge-secondary">Secondary</a>
249 <a href="#" class="badge badge-success">Success</a>
250 <a href="#" class="badge badge-danger">Danger</a>
251 <a href="#" class="badge badge-warning">Warning</a>
252 <a href="#" class="badge badge-info">Info</a>
253 <a href="#" class="badge badge-light">Light</a>
254 <a href="#" class="badge badge-dark">Dark</a>
255 <?php for ($i = 0; $i <= 9; $i++) : ?>
256 <a href="#" class="badge badge-status<?php print $i; ?>" >status<?php print $i; ?></a>
257 <?php endfor; ?>
258 </div>
259 <?php
260 $lines = array(
261 '<a href="#" class="badge badge-primary">Primary</a>',
262 '<a href="#" class="badge badge-secondary">Secondary</a>',
263 '<a href="#" class="badge badge-success">Success</a>',
264 '<a href="#" class="badge badge-danger">Danger</a>',
265 '<a href="#" class="badge badge-warning">Warning</a>',
266 '<a href="#" class="badge badge-info">Info</a>',
267 '<a href="#" class="badge badge-light">Light</a>',
268 '<a href="#" class="badge badge-dark">Dark</a>',
269 );
270 for ($i = 0; $i <= 9; $i++) :
271 $lines[] = '<a href="#" class="badge badge-status'.$i.'" >status'.$i.'</a>';
272 endfor;
273 echo $documentation->showCode($lines); ?>
274 </div>
275
276 <!-- Use badge helper function -->
277 <div class="documentation-section" id="badgesection-dolgetbadge">
278 <h2 class="documentation-title"><?php echo $langs->trans('DocBadgeHelper'); ?></h2>
279 <p class="documentation-text"><?php echo $langs->trans('DocBadgeHelperDescription'); ?></p>
280 <div class="documentation-example">
281 <?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'primary'); ?>
282 <?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'danger', 'pill'); ?>
283 <?php print dolGetBadge('your label for accessibility', 'your label', 'warning', 'dot'); ?>
284 </div>
285 <?php
286 $lines = array(
287 "/**",
288 " * Function dolGetBadge",
289 " *",
290 " * @param string \$label label of badge no html : use in alt attribute for accessibility",
291 " * @param string \$html optional : label of badge with html",
292 " * @param string \$type type of badge : Primary Secondary Success Danger Warning Info Light Dark status0 status1 status2 status3 status4 status5 status6 status7 status8 status9",
293 " * @param string \$mode Default '' , 'pill', 'dot'",
294 " * @param string \$url the url for link",
295 " * ... See more: core/lib/functions.lib.php ",
296 "",
297 "<?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'primary'); ?>",
298 "<?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'danger', 'pill'); ?>",
299 "<?php print dolGetBadge('your label for accessibility', 'your label', 'warning', 'dot'); ?>",
300 );
301 echo $documentation->showCode($lines); ?>
302 </div>
303
304 <!-- -->
305
306 </div>
307
308 </div>
309
310<?php
311// Output close body + html
312$documentation->docFooter();
313?>
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.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.