button.class.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. );
  16. if($_array != NULL){
  17. (!empty($_array["value"])) ? $config["value"] = $_array["value"] : NULL;
  18. (!empty($_array["text"])) ? $config["text"] = $_array["text"] : NULL;
  19. (!empty($_array["title"])) ? $config["title"] = $_array["title"] : NULL;
  20. (!empty($_array["confirm"])) ? $config["confirm"] = $_array["confirm"] : NULL;
  21. (!empty($_array["cancel"])) ? $config["cancel"] = $_array["cancel"] : NULL;
  22. (!empty($_array["type"])) ? $config["type"] = $_array["type"] : NULL;
  23. (!empty($_array["class"])) ? $config["class"] = $_array["class"] : NULL;
  24. (!empty($_array["style"])) ? $config["style"] = $_array["style"] : NULL;
  25. (!empty($_array["id"])) ? $config["id"] = $_array["id"] : NULL;
  26. }
  27. $print = "<input ";
  28. $print .= 'class="' . $config["class"] .'" ';
  29. $print .= 'style="' . $config["style"] .'" ';
  30. $print .= 'type="' . $config["type"] .'" ';
  31. $print .= 'value="' . $config["value"] .'" ';
  32. $print .= 'data-confirm="' . $config["text"] .'" ';
  33. $print .= 'data-confirm-title="' . $config["title"] .'" ';
  34. $print .= 'data-confirm-button-confirm="' . $config["confirm"] .'" ';
  35. $print .= 'data-confirm-button-cancel="' . $config["cancel"] .'" ';
  36. if(!empty($_array["id"])) { $print .= 'id="' . $config["id"] .'" '; }
  37. $print .= ">";
  38. echo $print;
  39. }
  40. }