Imports System.Collections.Generic
Imports CharterDotCom.CommonEntities.Library
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.CommonEntities.Library.EntityMemberServices
'Imports CharterDotCom.CommonEntities.Library.EntityEBSServices
Imports CharterDotCom.CommonEntities.Library.EntitySupport
Imports CharterDotCom.CommonEntities.Library.EntitySearch
Imports CharterDotCom.CommonEntities.Library.EntityWebConfig
'Imports CharterDotCom.CommonEntities.Library.EntityG2BServices
Imports CharterDotCom.CommonEntities.Library.Common
Imports CharterDotCom.WebSite.Library

Partial Class Controls_GeneralContent
    Inherits System.Web.UI.UserControl

    Public Property ContentKey() As String
        Get
            If ViewState(Me.ID & "_ContentKey") Is Nothing Then
                Return Nothing
            Else
                Return CType(ViewState(Me.ID & "_ContentKey"), String)
            End If
        End Get

        Set(ByVal value As String)
            ViewState(Me.ID & "_ContentKey") = value
        End Set
    End Property

    Public Property OwnerID() As Integer
        Get
            If ViewState(Me.ID & "_OwnerID") Is Nothing Then
                Return Nothing
            Else
                Return CInt(ViewState(Me.ID & "_OwnerID"))
            End If
        End Get

        Set(ByVal value As Integer)
            ViewState(Me.ID & "_OwnerID") = value.ToString()
        End Set
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If Page.User.IsInRole(RoleName.Author) Then
                pContentHead.Style("border") = "red solid 1px"
                pContentHead.Attributes("onclick") = String.Format("top.editor.location.href='{0}/Authors/Editor.aspx?{1}={2}&{3}={4}&{5}={6}'", _
                 Request.ApplicationPath, QueryStringName.OwnerTypeID, OwnerType.Other.GetHashCode(), _
                 QueryStringName.OwnerID, 0, QueryStringName.ControlID, ContentKey & ":Head")

                pContentBody.Style("border") = "red solid 1px"
                pContentBody.Attributes("onclick") = String.Format("top.editor.location.href='{0}/Authors/Editor.aspx?{1}={2}&{3}={4}&{5}={6}'", _
                 Request.ApplicationPath, QueryStringName.OwnerTypeID, OwnerType.Other.GetHashCode(), _
                 QueryStringName.OwnerID, 0, QueryStringName.ControlID, ContentKey & ":Body")
            Else
                pContentHead.Style("border") = "0"
                pContentHead.Attributes.Remove("onclick")

                pContentBody.Style("border") = "0"
                pContentBody.Attributes.Remove("onclick")
            End If
        End If
    End Sub

    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        If Not Page.IsPostBack Then
            If ContentKey IsNot Nothing Then
                ltrContentHead.Text = ContentManager.Instance.GetContent(ContentKey & ":Head", OwnerID, OwnerType.Other)

                If ltrContentHead.Text = String.Empty Then
          'ltrContentHead.Text = "ControlID - " & ContentKey & ":Head"
                End If

                ltrContentBody.Text = ContentManager.Instance.GetContent(ContentKey & ":Body", OwnerID, OwnerType.Other)
                If ltrContentBody.Text = String.Empty Then
                    ltrContentBody.Text = "ControlID - " & ContentKey & ":Body"
                End If

                txtContentKey.Value = ContentKey
            End If
        End If
    End Sub

End Class
