ASP Classic blog framework - BrainOrdure
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

120 lines
3.4KB

  1. <%
  2. Class AdminController_Class
  3. Private m_useLayout
  4. Private m_title
  5. Private Sub Class_Initialize()
  6. m_useLayout = True
  7. m_title = "Admin"
  8. End Sub
  9. Public Property Get useLayout
  10. useLayout = m_useLayout
  11. End Property
  12. Public Property Let useLayout(v)
  13. m_useLayout = v
  14. End Property
  15. Public Property Get Title
  16. Title = m_title
  17. End Property
  18. Public Property Let Title(v)
  19. m_title = v
  20. End Property
  21. '---------------------------------------------------------------
  22. ' Action: Index
  23. '---------------------------------------------------------------
  24. Public Sub Index()
  25. m_title = "Admin Dashboard"
  26. %>
  27. <!--#include file="../views/Admin/index.asp" -->
  28. <%
  29. End Sub
  30. '---------------------------------------------------------------
  31. ' Action: Posts
  32. '---------------------------------------------------------------
  33. Public Sub Posts()
  34. m_title = "Manage Posts"
  35. Dim posts
  36. Set posts = PostsRepository().FindAllWhere(Empty, "CreatedDate DESC", 0, 0)
  37. %>
  38. <!--#include file="../views/Admin/posts.asp" -->
  39. <%
  40. End Sub
  41. '---------------------------------------------------------------
  42. ' Action: Categories
  43. '---------------------------------------------------------------
  44. Public Sub Categories()
  45. m_title = "Manage Categories"
  46. Dim categories
  47. Set categories = CategoriesRepository().FindAll
  48. %>
  49. <!--#include file="../views/Admin/categories.asp" -->
  50. <%
  51. End Sub
  52. '---------------------------------------------------------------
  53. ' Action: PublishPost
  54. '---------------------------------------------------------------
  55. Public Sub PublishPost(ByVal id)
  56. Dim post
  57. On Error Resume Next
  58. Set post = PostsRepository().FindByID(id)
  59. If Err.Number <> 0 Then
  60. Err.Clear
  61. On Error GoTo 0
  62. Flash().AddError "Post not found."
  63. Response.Redirect "/admin/posts"
  64. Exit Sub
  65. End If
  66. On Error GoTo 0
  67. post.IsPublished = 1
  68. If Not IsDate(post.PublishedDate) Or CDate(post.PublishedDate) <= #1/1/1970# Then
  69. post.PublishedDate = Now()
  70. End If
  71. post.UpdatedDate = Now()
  72. PostsRepository().Update post
  73. Flash().Success = "Post published."
  74. Response.Redirect "/admin/posts"
  75. End Sub
  76. '---------------------------------------------------------------
  77. ' Action: UnpublishPost
  78. '---------------------------------------------------------------
  79. Public Sub UnpublishPost(ByVal id)
  80. Dim post
  81. On Error Resume Next
  82. Set post = PostsRepository().FindByID(id)
  83. If Err.Number <> 0 Then
  84. Err.Clear
  85. On Error GoTo 0
  86. Flash().AddError "Post not found."
  87. Response.Redirect "/admin/posts"
  88. Exit Sub
  89. End If
  90. On Error GoTo 0
  91. post.IsPublished = 0
  92. post.UpdatedDate = Now()
  93. PostsRepository().Update post
  94. Flash().Success = "Post unpublished."
  95. Response.Redirect "/admin/posts"
  96. End Sub
  97. End Class
  98. Dim AdminController_Class__Singleton
  99. Function AdminController()
  100. If IsEmpty(AdminController_Class__Singleton) Then
  101. Set AdminController_Class__Singleton = New AdminController_Class
  102. End If
  103. Set AdminController = AdminController_Class__Singleton
  104. End Function
  105. %>

Powered by TurnKey Linux.