ASP Classic blog framework - BrainOrdure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
5.1KB

  1. <%
  2. ' Auto-generated Controller: Categories
  3. ' Generated on 5/2/2026 9:47:37 PM
  4. ' Generator: generateController.vbs v1.0
  5. '
  6. ' Remember to:
  7. ' 1. Add to app/controllers/autoload_controllers.asp
  8. ' 2. Register in core/lib.ControllerRegistry.asp
  9. ' 3. Add routes in public/Default.asp
  10. Class CategoriesController_Class
  11. Private m_useLayout
  12. Private m_title
  13. Private Sub Class_Initialize()
  14. m_useLayout = True
  15. m_title = "Categories"
  16. End Sub
  17. Public Property Get useLayout
  18. useLayout = m_useLayout
  19. End Property
  20. Public Property Let useLayout(v)
  21. m_useLayout = v
  22. End Property
  23. Public Property Get Title
  24. Title = m_title
  25. End Property
  26. Public Property Let Title(v)
  27. m_title = v
  28. End Property
  29. '---------------------------------------------------------------
  30. ' Action: Index
  31. '---------------------------------------------------------------
  32. Public Sub Index()
  33. Dim categories
  34. Set categories = CategoriesRepository().FindAll
  35. %>
  36. <!--#include file="../views/Categories/index.asp" -->
  37. <%
  38. End Sub
  39. '---------------------------------------------------------------
  40. ' Action: Show
  41. '---------------------------------------------------------------
  42. Public Sub Show(ByVal id)
  43. Dim category
  44. On Error Resume Next
  45. Set category = CategoriesRepository().FindByID(id)
  46. If Err.Number <> 0 Then
  47. Err.Clear
  48. On Error GoTo 0
  49. Response.Status = "404 Not Found"
  50. %>
  51. <!--#include file="../views/Error/NotFound.asp" -->
  52. <%
  53. Exit Sub
  54. End If
  55. On Error GoTo 0
  56. %>
  57. <!--#include file="../views/Categories/show.asp" -->
  58. <%
  59. End Sub
  60. '---------------------------------------------------------------
  61. ' Action: New
  62. '---------------------------------------------------------------
  63. Public Sub NewForm()
  64. %>
  65. <!--#include file="../views/Categories/new.asp" -->
  66. <%
  67. End Sub
  68. '---------------------------------------------------------------
  69. ' Action: Create
  70. '---------------------------------------------------------------
  71. Public Sub Create()
  72. Dim name : name = Trim(Request.Form("Name"))
  73. If Len(name) = 0 Then
  74. Flash().AddError "Name is required."
  75. Response.Redirect "/categories/new"
  76. Exit Sub
  77. End If
  78. Dim category
  79. Set category = New POBO_Categories
  80. category.Name = name
  81. category.Slug = Request.Form("Slug")
  82. category.Description = Request.Form("Description")
  83. CategoriesRepository().AddNew category
  84. Flash().Success = "Category created."
  85. Response.Redirect "/categories"
  86. End Sub
  87. '---------------------------------------------------------------
  88. ' Action: Edit
  89. '---------------------------------------------------------------
  90. Public Sub Edit(ByVal id)
  91. Dim category
  92. On Error Resume Next
  93. Set category = CategoriesRepository().FindByID(id)
  94. If Err.Number <> 0 Then
  95. Err.Clear
  96. On Error GoTo 0
  97. Response.Status = "404 Not Found"
  98. %>
  99. <!--#include file="../views/Error/NotFound.asp" -->
  100. <%
  101. Exit Sub
  102. End If
  103. On Error GoTo 0
  104. %>
  105. <!--#include file="../views/Categories/edit.asp" -->
  106. <%
  107. End Sub
  108. '---------------------------------------------------------------
  109. ' Action: Update
  110. '---------------------------------------------------------------
  111. Public Sub Update(ByVal id)
  112. Dim category
  113. On Error Resume Next
  114. Set category = CategoriesRepository().FindByID(id)
  115. If Err.Number <> 0 Then
  116. Err.Clear
  117. On Error GoTo 0
  118. Response.Status = "404 Not Found"
  119. %>
  120. <!--#include file="../views/Error/NotFound.asp" -->
  121. <%
  122. Exit Sub
  123. End If
  124. On Error GoTo 0
  125. Dim name : name = Trim(Request.Form("Name"))
  126. If Len(name) = 0 Then
  127. Flash().AddError "Name is required."
  128. Response.Redirect "/categories/" & Server.URLEncode(CStr(id)) & "/edit"
  129. Exit Sub
  130. End If
  131. category.Name = name
  132. category.Slug = Request.Form("Slug")
  133. category.Description = Request.Form("Description")
  134. CategoriesRepository().Update category
  135. Flash().Success = "Category updated."
  136. Response.Redirect "/categories"
  137. End Sub
  138. '---------------------------------------------------------------
  139. ' Action: Delete
  140. '---------------------------------------------------------------
  141. Public Sub Delete(ByVal id)
  142. CategoriesRepository().Delete id
  143. Flash().Success = "Category deleted."
  144. Response.Redirect "/categories"
  145. End Sub
  146. End Class
  147. ' Singleton instance
  148. Dim CategoriesController_Class__Singleton
  149. Function CategoriesController()
  150. If IsEmpty(CategoriesController_Class__Singleton) Then
  151. Set CategoriesController_Class__Singleton = New CategoriesController_Class
  152. End If
  153. Set CategoriesController = CategoriesController_Class__Singleton
  154. End Function
  155. %>

Powered by TurnKey Linux.