Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 8 měsíci
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <%
  2. '=======================================================================================================================
  3. ' Flash Message Class
  4. '=======================================================================================================================
  5. Class Flash_Class
  6. Private m_errors_key
  7. Private m_success_key
  8. Private Sub Class_Initialize
  9. m_errors_key = "mvc.flash.errors_array"
  10. m_success_key = "mvc.flash.success_message"
  11. End Sub
  12. 'helper methods to avoid if..then statements in views
  13. Public Sub ShowErrorsIfPresent
  14. if HasErrors then ShowErrors
  15. End Sub
  16. Public Sub ShowSuccessIfPresent
  17. if HasSuccess then ShowSuccess
  18. End Sub
  19. '---------------------------------------------------------------------------------------------------------------------
  20. ' Errors
  21. '---------------------------------------------------------------------------------------------------------------------
  22. Public Property Get HasErrors
  23. HasErrors = (Not IsEmpty(Session(m_errors_key)))
  24. End Property
  25. Public Property Get Errors
  26. Errors = Session(m_errors_key)
  27. End Property
  28. Public Property Let Errors(ary)
  29. Session(m_errors_key) = ary
  30. End Property
  31. Public Sub AddError(msg)
  32. dim ary
  33. if IsEmpty(Session(m_errors_key)) then
  34. ary = Array()
  35. redim ary(-1)
  36. else
  37. ary = Session(m_errors_key)
  38. end if
  39. redim preserve ary(ubound(ary) + 1)
  40. ary(ubound(ary)) = msg
  41. Session(m_errors_key) = ary
  42. End Sub
  43. 'Public Sub ShowErrors
  44. ' ClearErrors
  45. 'End Sub
  46. Public Sub ShowErrors
  47. if HasErrors then
  48. %>
  49. <div class="alert alert-error">
  50. <button type="button" class="close" data-dismiss="alert">&times;</button>
  51. <h4>Error!</h4>
  52. <ul>
  53. <%
  54. dim ary, i
  55. ary = Errors
  56. for i = 0 to ubound(ary)
  57. put "<li>"
  58. put H(ary(i))
  59. put "</li>"
  60. next
  61. %>
  62. </ul>
  63. </div>
  64. <%
  65. ClearErrors
  66. end if
  67. End Sub
  68. Public Sub ClearErrors
  69. Session.Contents.Remove(m_errors_key)
  70. End Sub
  71. '---------------------------------------------------------------------------------------------------------------------
  72. ' Success
  73. '---------------------------------------------------------------------------------------------------------------------
  74. Public Property Get HasSuccess
  75. HasSuccess = (Not IsEmpty(Session(m_success_key)))
  76. End Property
  77. Public Property Get Success
  78. Success = Session(m_success_key)
  79. End Property
  80. Public Property Let Success(msg)
  81. Session(m_success_key) = msg
  82. End Property
  83. Public Sub ShowSuccess
  84. if HasSuccess then
  85. %>
  86. <div class="alert alert-success">
  87. <button type="button" class="close" data-dismiss="alert">&times;</button>
  88. <%= H(Success) %>
  89. </div>
  90. <%
  91. ClearSuccess
  92. end if
  93. End Sub
  94. Public Sub ClearSuccess
  95. Session.Contents.Remove(m_success_key)
  96. End Sub
  97. End Class
  98. Function Flash()
  99. set Flash = new Flash_Class
  100. End Function
  101. %>

Powered by TurnKey Linux.