button.class.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. class button
  3. {
  4. public static function confirm(?array $_array = NULL)
  5. {
  6. $config = array(
  7. "value" => "Valider",
  8. "title" => "Confirmation",
  9. "text" => "Vous êtes certain de vouloir poursuivre ?",
  10. "confirm" => "Continuer",
  11. "cancel" => "Annuler",
  12. "type" => "submit",
  13. "class" => "btn btn-primary btn-lg",
  14. "style" => "width: 100%",
  15. "add" => ""
  16. );
  17. if($_array != NULL){
  18. (!empty($_array["value"])) ? $config["value"] = $_array["value"] : NULL;
  19. (!empty($_array["text"])) ? $config["text"] = $_array["text"] : NULL;
  20. (!empty($_array["title"])) ? $config["title"] = $_array["title"] : NULL;
  21. (!empty($_array["confirm"])) ? $config["confirm"] = $_array["confirm"] : NULL;
  22. (!empty($_array["cancel"])) ? $config["cancel"] = $_array["cancel"] : NULL;
  23. (!empty($_array["type"])) ? $config["type"] = $_array["type"] : NULL;
  24. (!empty($_array["class"])) ? $config["class"] = $_array["class"] : NULL;
  25. (!empty($_array["style"])) ? $config["style"] = $_array["style"] : NULL;
  26. (!empty($_array["id"])) ? $config["id"] = $_array["id"] : NULL;
  27. (!empty($_array["add"])) ? $config["add"] = $_array["add"] : NULL;
  28. }
  29. $print = "<input ";
  30. $print .= 'class="' . $config["class"] .'" ';
  31. $print .= 'style="' . $config["style"] .'" ';
  32. $print .= 'type="' . $config["type"] .'" ';
  33. $print .= 'value="' . $config["value"] .'" ';
  34. $print .= 'data-confirm="' . $config["text"] .'" ';
  35. $print .= 'data-confirm-title="' . $config["title"] .'" ';
  36. $print .= 'data-confirm-button-confirm="' . $config["confirm"] .'" ';
  37. $print .= 'data-confirm-button-cancel="' . $config["cancel"] .'" ';
  38. if(!empty($_array["id"])) { $print .= 'id="' . $config["id"] .'" '; }
  39. $print .= ' ' . $config["add"] .'>';
  40. echo $print;
  41. }
  42. }