api.ubillingmessagehelper.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * System message helper class
  4. */
  5. class UbillingMessageHelper {
  6. /**
  7. * Default item deletion alert here
  8. *
  9. * @var string
  10. */
  11. protected $deleteAlert = '';
  12. /**
  13. * Default item editing alert here
  14. *
  15. * @var string
  16. */
  17. protected $editAlert = '';
  18. public function __construct() {
  19. $this->setDeleteAlert();
  20. $this->setEditAlert();
  21. }
  22. /**
  23. * Sets localized string as default deletion warning
  24. */
  25. protected function setDeleteAlert() {
  26. $this->deleteAlert = __('Removing this may lead to irreparable results');
  27. }
  28. /**
  29. * Sets localized string as default edit warning
  30. */
  31. protected function setEditAlert() {
  32. $this->editAlert = __('Are you serious');
  33. }
  34. /**
  35. * Returns localized deletion warning message
  36. *
  37. * @return string
  38. */
  39. public function getDeleteAlert() {
  40. return ($this->deleteAlert);
  41. }
  42. /**
  43. * Returns localized editing warning message
  44. *
  45. * @return string
  46. */
  47. public function getEditAlert() {
  48. return ($this->editAlert);
  49. }
  50. /**
  51. * Returns styled message
  52. *
  53. * @param string $data text message for styling
  54. * @param string $style error, warning, info, success
  55. * @param string $opts custom container options
  56. *
  57. * @return string
  58. */
  59. public function getStyledMessage($data, $style, $opts = '') {
  60. $class = 'alert_' . $style;
  61. $result = wf_tag('span', false, $class, $opts) . $data . wf_tag('span', true);
  62. return ($result);
  63. }
  64. }