|
- <%
- Class AdminController_Class
- Private m_useLayout
- Private m_title
-
- Private Sub Class_Initialize()
- m_useLayout = True
- m_title = "Admin"
- End Sub
-
- Public Property Get useLayout
- useLayout = m_useLayout
- End Property
-
- Public Property Let useLayout(v)
- m_useLayout = v
- End Property
-
- Public Property Get Title
- Title = m_title
- End Property
-
- Public Property Let Title(v)
- m_title = v
- End Property
-
- '---------------------------------------------------------------
- ' Action: Index
- '---------------------------------------------------------------
- Public Sub Index()
- m_title = "Admin Dashboard"
- %>
- <!--#include file="../views/Admin/index.asp" -->
- <%
- End Sub
-
- '---------------------------------------------------------------
- ' Action: Posts
- '---------------------------------------------------------------
- Public Sub Posts()
- m_title = "Manage Posts"
- Dim posts
- Set posts = PostsRepository().FindAllWhere(Empty, "CreatedDate DESC", 0, 0)
- %>
- <!--#include file="../views/Admin/posts.asp" -->
- <%
- End Sub
-
- '---------------------------------------------------------------
- ' Action: Categories
- '---------------------------------------------------------------
- Public Sub Categories()
- m_title = "Manage Categories"
- Dim categories
- Set categories = CategoriesRepository().FindAll
- %>
- <!--#include file="../views/Admin/categories.asp" -->
- <%
- End Sub
-
- '---------------------------------------------------------------
- ' Action: PublishPost
- '---------------------------------------------------------------
- Public Sub PublishPost(ByVal id)
- Dim post
- On Error Resume Next
- Set post = PostsRepository().FindByID(id)
- If Err.Number <> 0 Then
- Err.Clear
- On Error GoTo 0
- Flash().AddError "Post not found."
- Response.Redirect "/admin/posts"
- Exit Sub
- End If
- On Error GoTo 0
-
- post.IsPublished = 1
- If Not IsDate(post.PublishedDate) Or CDate(post.PublishedDate) <= #1/1/1970# Then
- post.PublishedDate = Now()
- End If
- post.UpdatedDate = Now()
- PostsRepository().Update post
- Flash().Success = "Post published."
- Response.Redirect "/admin/posts"
- End Sub
-
- '---------------------------------------------------------------
- ' Action: UnpublishPost
- '---------------------------------------------------------------
- Public Sub UnpublishPost(ByVal id)
- Dim post
- On Error Resume Next
- Set post = PostsRepository().FindByID(id)
- If Err.Number <> 0 Then
- Err.Clear
- On Error GoTo 0
- Flash().AddError "Post not found."
- Response.Redirect "/admin/posts"
- Exit Sub
- End If
- On Error GoTo 0
-
- post.IsPublished = 0
- post.UpdatedDate = Now()
- PostsRepository().Update post
- Flash().Success = "Post unpublished."
- Response.Redirect "/admin/posts"
- End Sub
-
- End Class
-
- Dim AdminController_Class__Singleton
- Function AdminController()
- If IsEmpty(AdminController_Class__Singleton) Then
- Set AdminController_Class__Singleton = New AdminController_Class
- End If
- Set AdminController = AdminController_Class__Singleton
- End Function
- %>
|