Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

8 miesięcy temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <%
  2. '=======================================================================================================================
  3. ' ROUTING HELPER
  4. '=======================================================================================================================
  5. Class Route_Helper_Class
  6. Public Property Get NoCacheToken
  7. NoCacheToken = Timer() * 100
  8. End Property
  9. Public Sub Initialize(app_url)
  10. m_app_url = app_url
  11. m_content_url = m_app_url & "Content/"
  12. m_stylesheets_url = m_content_url & "Styles/"
  13. m_controllers_url = m_app_url & "Controllers/"
  14. End Sub
  15. Public Property Get AppURL
  16. AppURL = m_app_url
  17. end Property
  18. Public Property Get ContentURL
  19. ContentURL = m_content_url
  20. end Property
  21. Public Property Get ControllersURL
  22. ControllersUrl = m_controllers_url
  23. end Property
  24. Public Property Get StylesheetsURL
  25. StylesheetsURL = m_stylesheets_url
  26. end Property
  27. ''
  28. ' Generates a URL to the specified controller + action combo, with querystring parameters appended if included.
  29. '
  30. ' @param controller_name String name of the controller
  31. ' @param action_name String name of the controller action
  32. ' @param params_array KV Array key/value pair array, to be converted to &key1=val1&key2=val2&...&keyn=valn
  33. ' @returns
  34. ''
  35. Public Function UrlTo(controller_name, action_name, params_array)
  36. dim qs : qs = TO_Querystring(params_array)
  37. if len(qs) > 0 then qs = "&" & qs
  38. UrlTo = Me.ControllersURL & controller_name & "/" & controller_name & "Controller.asp?_A=" & action_name & qs & "&_NC=" & NoCacheToken
  39. End Function
  40. '---------------------------------------------------------------------------------------------------------------------
  41. ' PRIVATE
  42. '---------------------------------------------------------------------------------------------------------------------
  43. Private m_app_url
  44. Private m_content_url
  45. Private m_stylesheets_url
  46. Private m_controllers_url
  47. Private Function TO_Querystring(the_array)
  48. dim result : result = ""
  49. if not isempty(the_array) then
  50. dim idx
  51. for idx = lbound(the_array) to ubound(the_array) step 2
  52. result = result & GetParam(the_array, idx)
  53. 'append & between parameters, but not on the last parameter
  54. if not (idx = ubound(the_array) - 1) then result = result & "&"
  55. next
  56. end if
  57. TO_Querystring = result
  58. End Function
  59. Private Function GetParam(params_array, key_idx)
  60. dim key, val
  61. KeyVal params_array, key_idx, key, val
  62. GetParam = key & "=" & val
  63. End Function
  64. end class
  65. dim Route_Helper__Singleton : set Route_Helper__Singleton = Nothing
  66. Function Routes()
  67. if Route_Helper__Singleton is Nothing then
  68. set Route_Helper__Singleton = new Route_Helper_Class
  69. end if
  70. set Routes = Route_Helper__Singleton
  71. End Function
  72. %>

Powered by TurnKey Linux.