|
- <%
- Response.ExpiresAbsolute = "2000-01-01"
- Response.AddHeader "pragma", "no-cache"
- Response.AddHeader "cache-control", "private, no-cache, must-revalidate"
-
-
-
-
-
- Class MVC_Dispatcher_Class
- Private m_controller_name
- Private m_action_name
- Private m_default_action_name
- Private m_action_params
- Private m_controller_instance
- Private m_is_partial
-
- Private Sub Class_initialize
- m_default_action_name = "Index"
- SetControllerActionNames
-
- End Sub
-
- Public Property Get ControllerName
- ControllerName = m_controller_name
- end Property
-
- Public Property Get ActionName
- ActionName = m_action_name
- end Property
-
- Public Property Get IsPartial
- IsPartial = m_is_partial
- End Property
-
-
-
-
-
-
-
-
- Public Sub Dispatch
- dim class_name : class_name = m_controller_name & "Controller"
-
-
- executeglobal "dim Controller : set Controller = new " & class_name
-
- If Request.Querystring("_P").Count = 1 then
- m_is_partial = true
- Else
- m_is_partial = false
- End If
-
- If Not IsPartial then
- %>
- <!--#include file="../App/Views/Shared/layout.header.asp"-->
- <%
- End If
-
- ExecuteAction ActionName
-
- If Not IsPartial then
- %>
- <!--#include file="../App/Views/Shared/layout.footer.asp"-->
- <%
- End If
- End Sub
-
-
-
- Private Sub ExecuteAction(action_name)
-
- Execute "Controller." & action_name
- End Sub
-
-
-
-
- Public Sub RequirePost
- If Request.Form.Count = 0 Then Err.Raise 1, "MVC_Helper_Class:RequirePost", "Action only responds to POST requests."
- End Sub
-
-
- Public Sub RedirectTo(controller_name, action_name)
- RedirectToExt controller_name, action_name, empty
- End Sub
-
-
-
- Public Sub RedirectToExt(controller_name, action_name, params)
- Response.Redirect Routes.UrlTo(controller_name, action_name, params)
- End Sub
-
-
- Public Sub RedirectToAction(ByVal action_name)
- RedirectToActionExt action_name, empty
- End Sub
-
-
-
- Public Sub RedirectToActionExt(ByVal action_name, ByVal params)
- RedirectToExt ControllerName, action_name, params
- End Sub
-
-
- Public Sub RedirectToActionPOST(action_name)
- RedirectToActionExtPOST action_name, empty
- End Sub
-
-
- Public Sub RedirectToActionExtPOST(action_name, params)
- put "<form id='mvc_redirect_to_action_post' action='" & Routes.UrlTo(ControllerName, action_name, empty) & "' method='POST'>"
- put "<input type='hidden' name='mvc_redirect_to_action_post_flag' value='1'>"
- if Not IsEmpty(params) then
- dim i, key, val
- for i = 0 to ubound(params) step 2
- KeyVal params, i, key, val
- put "<input type='hidden' name='" & key & "' value='" & val & "'>"
- next
- end if
- put "</form>"
- put "<script type='text/javascript'>"
- put "$('#mvc_redirect_to_action_post').submit();"
- put "</script>"
- End Sub
-
-
-
-
-
- Private Sub SetControllerActionNames
- dim full_path : full_path = request.servervariables("path_info")
- dim part_path : part_path = split(full_path, Routes.ControllersUrl)(1)
- dim part_path_split : part_path_split = split(part_path, "/")
-
- m_controller_name = part_path_split(0)
- m_action_name = Choice(request("_A") <> "", request("_A"), m_default_action_name)
- End Sub
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- end Class
-
-
-
- dim MVC_Dispatcher_Class__Singleton
- Function MVC()
- if IsEmpty(MVC_Dispatcher_Class__Singleton) then
- set MVC_Dispatcher_Class__Singleton = new MVC_Dispatcher_Class
- end if
- set MVC = MVC_Dispatcher_Class__Singleton
- End Function
-
-
- %>
|