dScribe CMS project: the Status class
In a good CMS you need to have a good idea about the life of your content through the different steps.
This is done with a Status attached to the piece of content. So to do so in dScribe, I wrote this class, and I can easily manage from any part of my code the Status properties.
I am also thinking about Enums for a next version but this one (in VB) works well:
Imports System Namespace dScribe Public Class StatusCodes Public Sub New() End Sub Public Const None As Integer = &H0 Public Const Creating As Integer = &H1 Public Const AwaitingEdit As Integer = &H2 Public Const RequiresUpdate As Integer = &H10001 Public Const Editing As Integer = &H4 Public Const AwaitingApproval As Integer = &H8 Public Const RequiresEditing As Integer = &H10004 Public Const Approving As Integer = &H10 Public Const Approved As Integer = &H20 Public Const Deployed As Integer = &H40 Public Const Archived As Integer = &H80 Public Const Discontinued As Integer = &H100000 Public Overloads Shared Function ToString(ByVal val As Integer) As String Select Case val Case Creating Return "Creating" Case AwaitingEdit Return "Awaiting Edit" Case RequiresUpdate Return "Requires Update" Case Editing Return "Editing" Case AwaitingApproval Return "Awaiting Approval" Case RequiresEditing Return "Requires Editing" Case Approving Return "Approving" Case Approved Return "Approved" Case Deployed Return "Deployed" Case Archived Return "Archived" Case Discontinued Return "Discontinued" Case Else Return "None" End Select End Function Public Shared Function isCreating(ByVal val As String) As Boolean Return (Convert.ToInt32(val) & Creating) = Creating End Function Public Shared Function isAwaitingEdit(ByVal val As String) As Boolean Return (Convert.ToInt32(val) & AwaitingEdit) = AwaitingEdit End Function Public Shared Function isRequiresUpdate(ByVal val As String) As Boolean Return (Convert.ToInt32(val) & RequiresUpdate) = RequiresUpdate End Function Public Shared Function isEditing(ByVal val As String) As Boolean Return (Convert.ToInt32(val) & Editing) = Editing End Function Public Shared Function isAwaitingApproval(ByVal val As String) As Boolean Return (Convert.ToInt32(val) & AwaitingApproval) = AwaitingApproval End Function Public Shared Function isRequiresEditing(ByVal val As String) As Boolean Return (Convert.ToInt32(val) & RequiresEditing) = RequiresEditing End Function Public Shared Function isApproving(ByVal val As String) As Boolean Return (Convert.ToInt32(val) & Approving) = Approving End Function Public Shared Function isApproved(ByVal val As String) As Boolean Return (Convert.ToInt32(val) & Approved) = Approved End Function Public Shared Function isDeployed(ByVal val As String) As Boolean Return (Convert.ToInt32(val) & Deployed) = Deployed End Function Public Shared Function isArchived(ByVal val As String) As Boolean Return (Convert.ToInt32(val) & Archived) = Archived End Function End Class End Namespace |