test_buttons.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?php
  2. if (!defined('NOREQUIRESOC')) {
  3. define('NOREQUIRESOC', '1');
  4. }
  5. if (!defined('NOCSRFCHECK')) {
  6. define('NOCSRFCHECK', 1);
  7. }
  8. if (!defined('NOTOKENRENEWAL')) {
  9. define('NOTOKENRENEWAL', 1);
  10. }
  11. if (!defined('NOLOGIN')) {
  12. define('NOLOGIN', 1); // File must be accessed by logon page so without login
  13. }
  14. if (!defined('NOREQUIREHTML')) {
  15. define('NOREQUIREHTML', 1);
  16. }
  17. if (!defined('NOREQUIREAJAX')) {
  18. define('NOREQUIREAJAX', '1');
  19. }
  20. if (!defined('NOSESSION')) {
  21. define('NOSESSION', '1');
  22. }
  23. if (!defined('NOREQUIREMENU')) {
  24. define('NOREQUIREMENU', '1');
  25. }
  26. session_cache_limiter('public');
  27. require_once '../../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
  29. // Security
  30. if ($dolibarr_main_prod) {
  31. accessforbidden();
  32. }
  33. /*
  34. * View
  35. */
  36. llxHeader('', 'Documentation and examples for theme');
  37. ?>
  38. <main role="main" >
  39. <h1 class="bd-title" id="content">Button for action</h1>
  40. <p class="bd-lead">Documentation and examples for buttons.</p>
  41. <h2 id="example01">Example of simple usage</h2>
  42. <p>Buttons for user allowed to click.</p>
  43. <div class="bd-example">
  44. <?php
  45. $n = 1;
  46. $label = 'My action label used for accessibility visually for impaired people';
  47. $html = '<span class="fa fa-clone" ></span> My default action';
  48. $actionType = 'default';
  49. $n++;
  50. $id = 'mybuttonid'.$n;
  51. $url = '#'.$id;
  52. $userRight = 1;
  53. $params = array();
  54. print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
  55. $html = '<span class="fa fa-clone" ></span> My delete action';
  56. $actionType = 'delete';
  57. $n++;
  58. $id = 'mybuttonid'.$n;
  59. $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
  60. print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
  61. $html = '<span class="fa fa-clone" ></span> My danger action';
  62. $actionType = 'danger';
  63. $n++;
  64. $id = 'mybuttonid'.$n;
  65. $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
  66. print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
  67. ?>
  68. </div>
  69. <p>Buttons for user <strong>NOT</strong> allowed to click.</p>
  70. <div class="bd-example">
  71. <?php
  72. $label = 'My action label used for accessibility visually for impaired people';
  73. $html = '<span class="fa fa-clone" ></span> My default action';
  74. $actionType = 'default';
  75. $n++;
  76. $id = 'mybuttonid'.$n;
  77. $url = '#'.$id;
  78. $userRight = 0;
  79. print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
  80. $html = '<span class="fa fa-clone" ></span> My delete action';
  81. $actionType = 'delete';
  82. $n++;
  83. $id = 'mybuttonid'.$n;
  84. $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
  85. print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
  86. $html = '<span class="fa fa-clone" ></span> My danger action';
  87. $actionType = 'danger';
  88. $n++;
  89. $id = 'mybuttonid'.$n;
  90. $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
  91. print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
  92. ?>
  93. </div>
  94. <h2 id="example01">Example of confirm dialog</h2>
  95. <p>Buttons for user allowed to click.</p>
  96. <div class="bd-example">
  97. <?php
  98. $label = 'My action label used for accessibility visually for impaired people';
  99. $html = '<span class="fa fa-clone" ></span> My default action';
  100. $actionType = 'default';
  101. $n++;
  102. $id = 'mybuttonid'.$n;
  103. $url = '#'.$id;
  104. $userRight = 1;
  105. $params = array(
  106. 'confirm' => true
  107. );
  108. print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
  109. $html = '<span class="fa fa-clone" ></span> My delete action';
  110. $actionType = 'delete';
  111. $n++;
  112. $id = 'mybuttonid'.$n;
  113. $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
  114. $params = array(
  115. 'confirm' => array(
  116. 'url' => 'your confirm action url',
  117. 'title' => 'Your title to display',
  118. 'action-btn-label' => 'Your confirm label',
  119. 'cancel-btn-label' => 'Your cancel label',
  120. 'content' => 'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>'
  121. )
  122. );
  123. print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
  124. ?>
  125. </div>
  126. <p>Buttons for user <strong>NOT</strong> allowed to click.</p>
  127. <div class="bd-example">
  128. <?php
  129. $label = 'My action label used for accessibility visually for impaired people';
  130. $html = '<span class="fa fa-clone" ></span> My default action';
  131. $actionType = 'default';
  132. $n++;
  133. $id = 'mybuttonid'.$n;
  134. $url = '#'.$id;
  135. $userRight = 0;
  136. $params = array(
  137. 'confirm' => true
  138. );
  139. print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
  140. $html = '<span class="fa fa-clone" ></span> My delete action';
  141. $actionType = 'delete';
  142. $n++;
  143. $id = 'mybuttonid'.$n;
  144. $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
  145. $params = array(
  146. 'confirm' => array(
  147. 'url' => 'your confirm action url',
  148. 'title' => 'Your title to display',
  149. 'action-btn-label' => 'Your confirm label',
  150. 'cancel-btn-label' => 'Your cancel label',
  151. 'content' => 'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>'
  152. )
  153. );
  154. print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
  155. ?>
  156. </div>
  157. </main>
  158. <?php llxFooter();