21require
'../../../../main.inc.php';
31if ($user->socid > 0) {
36require_once DOL_DOCUMENT_ROOT .
'/admin/tools/ui/class/documentation.class.php';
39$langs->load(
'uxdocumentation');
44 '/includes/ace/src/ace.js',
45 '/includes/ace/src/ext-statusbar.js',
46 '/includes/ace/src/ext-language_tools.js',
49$documentation->docHeader(
'Buttons', $morejs);
53$documentation->view = array(
'Components',
'Buttons');
56$documentation->showSidebar(); ?>
58<div
class=
"doc-wrapper">
60 <?php $documentation->showBreadCrumb(); ?>
62 <div
class=
"doc-content-wrapper">
64 <h1
class=
"documentation-title"><?php echo $langs->trans(
'DocButtonsTitle'); ?></h1>
65 <p
class=
"documentation-text"><?php echo $langs->trans(
'DocButtonsMainDescription'); ?></p>
68 <?php $documentation->showSummary(); ?>
70 <!-- Example of simple
usage -->
71 <div
class=
"documentation-section" id=
"buttonsection-basicusage">
72 <h2
class=
"documentation-title"><?php echo $langs->trans(
'DocBasicUsage'); ?></h2>
73 <p
class=
"documentation-text"><?php echo $langs->trans(
'DocButtonBasicUsageDescription'); ?></p>
74 <div
class=
"documentation-example">
76 $label =
'My action label used for accessibility visually for impaired people';
79 $html =
'<span class="fa fa-clone paddingright" aria-hidden="true"></span> My default action';
80 $action_type =
'default';
85 $html =
'<span class="fa fa-trash-alt paddingright" aria-hidden="true"></span> My delete action';
86 $action_type =
'delete';
91 $html =
'<span class="fa fa-radiation paddingright" aria-hidden="true"></span> My danger action';
92 $action_type =
'danger';
102 $html =
'<span class="fa fa-clone paddingright" aria-hidden="true"></span> My default action';
103 $action_type =
'default';
108 $html =
'<span class="fa fa-trash-alt paddingright" aria-hidden="true"></span> My delete action';
109 $action_type =
'delete';
114 $html =
'<span class="fa fa-radiation paddingright" aria-hidden="true"></span> My danger action';
115 $action_type =
'danger';
136 'print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);',
138 echo $documentation->showCode($lines,
'php'); ?>
141 <!-- Example of modal
usage -->
142 <div
class=
"documentation-section" id=
"buttonsection-modals">
143 <h2
class=
"documentation-title"><?php echo $langs->trans(
'DocButtonModal'); ?></h2>
144 <p
class=
"documentation-text"><?php echo $langs->trans(
'DocButtonModalDescription'); ?></p>
145 <div
class=
"documentation-example">
149 $html =
'<span class="fa fa-clone" paddingright" aria-hidden="true"></span> My default action';
150 $actionType =
'default';
158 $html =
'<span class="fa fa-trash-alt paddingright" aria-hidden="true"></span> My delete action';
159 $actionType =
'delete';
161 $url = $_SERVER[
'PHP_SELF'] .
'?token='.newToken().
'#'.
$id;
164 'url' =>
'your confirm action url',
165 'title' =>
'Your title to display',
166 'action-btn-label' =>
'Your confirm label',
167 'cancel-btn-label' =>
'Your cancel label',
168 'content' =>
'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>'
175 $html =
'<span class="fa fa-clone" ></span> My default action';
176 $actionType =
'delete';
182 print
dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); ?>
187 '// Default parameters',
189 ' \'confirm\' => [],',
192 '// Custom parameters',
194 ' \'confirm\' => array(',
195 ' \'url\' => \'your confirm action url\',',
196 ' \'title\' => \'Your title to display\',',
197 ' \'action-btn-label\' => \'Your confirm label\',',
198 ' \'cancel-btn-label\' => \'Your cancel label\',',
199 ' \'content\' => \'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>\',',
203 'print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);',
205 echo $documentation->showCode($lines,
'php'); ?>
208 <!-- Example of subbutton
usage -->
209 <div
class=
"documentation-section" id=
"buttonsection-submenu">
210 <h2
class=
"documentation-title"><?php echo $langs->trans(
'DocButtonSubmenu'); ?></h2>
211 <p
class=
"documentation-text"><?php echo $langs->trans(
'DocButtonSubmenuDescription'); ?></p>
212 <div
class=
"documentation-example">
215 $html =
'<span class="fa fa-clone" paddingright" aria-hidden="true"></span> My default action';
216 $actionType =
'default';
218 $submenu_url = str_replace(DOL_URL_ROOT,
'', $_SERVER[
'PHP_SELF']);
221 'lang'=>
'documentation@documentation',
222 'url'=> $submenu_url.
'#'.$id,
223 'label' =>
'My SubAction 1',
228 'lang'=>
'documentation@documentation',
229 'url'=> $submenu_url.
'#'.$id,
230 'label' =>
'My SubAction 2',
236 print
dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); ?>
242 '$url = \'url_script\';',
243 'print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);',
245 '// Dropdown button',
248 ' \'lang\' => \'langfile\',',
249 ' \'url\' => \'url_script_1\', // Url without DOL_URL_ROOT',
250 ' \'label\' => \'My SubAction 1\',',
251 ' \'perm\' => 1, // The user have the rights',
254 ' \'lang\' => \'langfile\',',
255 ' \'url\' => \'url_script_2\', // Url without DOL_URL_ROOT',
256 ' \'label\' => \'My SubAction 2\',',
257 ' \'perm\' => 0, // The user does not have the rights',
260 'print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);'
262 echo $documentation->showCode($lines,
'php'); ?>
266 <!-- Example of subbutton
usage -->
267 <div
class=
"documentation-section" id=
"buttonsection-icon-btn">
268 <h2
class=
"documentation-title"><?php echo $langs->trans(
'DocButtonIconsLowEmphasis'); ?></h2>
269 <p
class=
"documentation-text"><?php echo $langs->trans(
'DocButtonIconsDescriptionLowEmphasis'); ?></p>
270 <div
class=
"documentation-example">
272 $btnLabel = $langs->trans(
'Label');
273 print
' <button class="btn-low-emphasis --btn-icon" title="'.dol_escape_htmltag($btnLabel).
'" aria-label="'.
dol_escape_htmltag($btnLabel).
'" >'.
img_picto($btnLabel,
'fa-arrow-right',
'aria-hidden="true"', 0, 0, 1).
'</button>';
275 $btnLabel = $langs->trans(
'Reset');
276 print
' <button class="btn-low-emphasis --btn-icon" title="'.dol_escape_htmltag($btnLabel).
'" aria-label="'.
dol_escape_htmltag($btnLabel).
'" >'.
img_picto($btnLabel,
'eraser',
'aria-hidden="true"', 0, 0, 1).
'</button>';
282 '$btnLabel = $langs->trans(\'Label\');',
283 'print \' <button class="btn-low-emphasis --btn-icon" title="\'.dol_escape_htmltag($btnLabel).\'" aria-label="\'.dol_escape_htmltag($btnLabel).\'" >\'.img_picto($btnLabel, \'fa-arrow-right\', \'aria-hidden="true"\', 0, 0, 1).\'</button>\';',
285 '$btnLabel = $langs->trans(\'Reset\');',
286 'print \' <button class="btn-low-emphasis --btn-icon" title="\'.dol_escape_htmltag($btnLabel).\'" aria-label="\'.dol_escape_htmltag($btnLabel).\'" >\'.img_picto($btnLabel, \'eraser\', \'aria-hidden="true"\', 0, 0, 1).\'</button>\';',
289 echo $documentation->showCode($lines,
'php'); ?>
292 <!-- Example of subbutton
usage -->
293 <div
class=
"documentation-section" id=
"buttonsection-icon-btn">
294 <h2
class=
"documentation-title"><?php echo $langs->trans(
'DocButtonIconsForTitle'); ?></h2>
295 <div
class=
"documentation-example">
299 $btnLabel = $langs->trans(
'Label');
312 '$btnLabel = $langs->trans(\'Label\');',
313 '$status = 0; // Not Enough Permissions',
314 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-file\', \'#\', \'\', $status);',
315 '$status = 1; // Active',
316 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-file\', \'#\', \'\', $status);',
317 '$status = 2; // Active and selected',
318 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-file\', \'#\', \'\', $status);',
319 '$status = -1; // Functionality is disabled',
320 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-file\', \'#\', \'\', $status);',
321 '$status = -2; // Disabled without info',
322 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-file\', \'#\', \'\', $status);',
325 echo $documentation->showCode($lines,
'php'); ?><div
class=
"documentation-example">
328 $btnLabel = $langs->trans(
'Label',
'php');
329 print
dolGetButtonTitle($btnLabel,
'',
'fa fa-download',
'#',
'', 0, [
'forcenohideoftext'=>1]);
330 print
dolGetButtonTitle($btnLabel,
'',
'fa fa-download',
'#',
'', 1, [
'forcenohideoftext'=>1]);
331 print
dolGetButtonTitle($btnLabel,
'',
'fa fa-download',
'#',
'', 2, [
'forcenohideoftext'=>1]);
332 print
dolGetButtonTitle($btnLabel,
'',
'fa fa-download',
'#',
'', -1, [
'forcenohideoftext'=>1]);
333 print
dolGetButtonTitle($btnLabel,
'',
'fa fa-download',
'#',
'', -2, [
'forcenohideoftext'=>1]);
341 '$btnLabel = $langs->trans(\'Label\');',
342 '$status = 0; // Not Enough Permissions',
343 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-download\', \'#\', \'\', $status, [\'forcenohideoftext\'=>1]);',
344 '$status = 1; // Active',
345 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-download\', \'#\', \'\', $status, [\'forcenohideoftext\'=>1]);',
346 '$status = 2; // Active and selected',
347 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-download\', \'#\', \'\', $status, [\'forcenohideoftext\'=>1]);',
348 '$status = -1; // Functionality is disabled',
349 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-download\', \'#\', \'\', $status, [\'forcenohideoftext\'=>1]);',
350 '$status = -2; // Disabled without info',
351 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-download\', \'#\', \'\', $status, [\'forcenohideoftext\'=>1]);',
353 echo $documentation->showCode($lines,
'php'); ?>
361$documentation->docFooter();
Class to manage UI documentation.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
usage($program, $header)
Print the usage when executing scripts from install/.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.