<%
Class Cls_Admin
    Private BodyCssName, AdminPath, AdminTitle, IncHtmlFile
    Private startTime

    Private Sub Class_Initialize()
        startTime = Timer()
        BodyCssName = "mainbody"
        AdminPath = "../"
    End Sub

    Private Sub Class_Terminate()
        If IsObject(CmsMain) Then Set CmsMain = Nothing
        If IsObject(CmsFun) Then Set CmsFun = Nothing
        Set Easp = Nothing
    End Sub

    Public Property Let SetBodyCssName(ByVal v)
        BodyCssName = v
    End Property

    Public Property Let SetAdminPath(ByVal v)
        AdminPath = v
    End Property

    Public Property Let SetAdminTitle(ByVal v)
        AdminTitle = v
    End Property

    Public Property Let SetIncHtmlFile(ByVal v)
        IncHtmlFile = v
    End Property

    Public Sub LoadHead()
        Dim strTemp
        strTemp = ""
        strTemp = strTemp & "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">" & vbCrLf
        strTemp = strTemp & "<html xmlns=""http://www.w3.org/1999/xhtml"">" & vbCrLf
        strTemp = strTemp & "<head>" & vbCrLf
        strTemp = strTemp & "<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""/>" & vbCrLf
        strTemp = strTemp & "<script>" & vbCrLf
        strTemp = strTemp & "var SiteInfo = {" & vbCrLf
        strTemp = strTemp & "    SiteName: '"& CmsSiteName &"'," & vbCrLf
        strTemp = strTemp & "    DialogSkin: '"& CmsDialogSkin &"'," & vbCrLf
        strTemp = strTemp & "    Templates: '"& CmsTemplates &"'," & vbCrLf
        strTemp = strTemp & "    TempSkin: '"& CmsTempSkin &"'" & vbCrLf
        strTemp = strTemp & "};" & vbCrLf
        strTemp = strTemp & "var AdminInfo = {" & vbCrLf
        strTemp = strTemp & "    AdminId: '"& Easp.Cookie("ZjjCmsCms>AdminId") &"'," & vbCrLf
        strTemp = strTemp & "    AdminName: '"& Easp.Cookie("ZjjCmsCms>AdminName") &"'," & vbCrLf
        strTemp = strTemp & "    LoginTime: '"& Easp.Cookie("ZjjCmsCms>LoginTime") &"'," & vbCrLf
        strTemp = strTemp & "    LoginIp: '"& Easp.Cookie("ZjjCmsCms>LoginIp") &"'," & vbCrLf
        strTemp = strTemp & "    LoginNum: '"& Easp.Cookie("ZjjCmsCms>LoginNum") &"'" & vbCrLf
        strTemp = strTemp & "};" & vbCrLf
        strTemp = strTemp & "</script>" & vbCrLf
        strTemp = strTemp & "<title>"& AdminTitle &" 管理员控制面板</title>" & vbCrLf
        strTemp = strTemp & "<meta http-equiv=""Expires"" Content=""0""/>" & vbCrLf
        strTemp = strTemp & "<meta http-equiv=""Cache-Control"" Content=""no-cache""/>" & vbCrLf
        strTemp = strTemp & "<meta http-equiv=""Pragma"" Content=""no-cache""/>" & vbCrLf
        strTemp = strTemp & CmsMain.LoadCssFile(SiteWebFilePath & "Scripts/jquery/ui/skins/Aqua/css/ligerui-all.css")
        strTemp = strTemp & CmsMain.LoadCssFile(AdminPath & "images/style.css")
        strTemp = strTemp & CmsMain.LoadCssFile(SiteWebFilePath & "Scripts/jquery/plugins/Validform/Validform.css")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/jquery/jquery.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/jquery/ui/liger.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/jquery/plugins/jquery.form.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/jquery/plugins/Validform/Validform.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/DatePicker/WdatePicker.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/plugins/ChinesePY.js")
        strTemp = strTemp & CmsMain.LoadDialogScript(SiteWebFilePath)
        strTemp = strTemp & IncHtmlFile
        strTemp = strTemp & CmsMain.LoadJsFile(AdminPath & "js/admin.js")
        strTemp = strTemp & CmsMain.LoadJsFile(AdminPath & "js/initValidform.js")
        strTemp = strTemp & "</head>" & vbCrLf
        strTemp = strTemp & "<body class="""& BodyCssName &""">" & vbCrLf
        Easp.W strTemp
    End Sub

    Public Sub LoadInfoHead()
        Dim strTemp
        strTemp = ""
        strTemp = strTemp & "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">" & vbCrLf
        strTemp = strTemp & "<html xmlns=""http://www.w3.org/1999/xhtml"">" & vbCrLf
        strTemp = strTemp & "<head>" & vbCrLf
        strTemp = strTemp & "<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""/>" & vbCrLf
        strTemp = strTemp & "<script>" & vbCrLf
        strTemp = strTemp & "var SiteInfo = {" & vbCrLf
        strTemp = strTemp & "    SiteName: '"& CmsSiteName &"'," & vbCrLf
        strTemp = strTemp & "    DialogSkin: '"& CmsDialogSkin &"'," & vbCrLf
        strTemp = strTemp & "    Templates: '"& CmsTemplates &"'," & vbCrLf
        strTemp = strTemp & "    TempSkin: '"& CmsTempSkin &"'" & vbCrLf
        strTemp = strTemp & "};" & vbCrLf
        strTemp = strTemp & "var AdminInfo = {" & vbCrLf
        strTemp = strTemp & "    AdminId: '"& Easp.Cookie("ZjjCmsCms>AdminId") &"'," & vbCrLf
        strTemp = strTemp & "    AdminName: '"& Easp.Cookie("ZjjCmsCms>AdminName") &"'," & vbCrLf
        strTemp = strTemp & "    LoginTime: '"& Easp.Cookie("ZjjCmsCms>LoginTime") &"'," & vbCrLf
        strTemp = strTemp & "    LoginIp: '"& Easp.Cookie("ZjjCmsCms>LoginIp") &"'," & vbCrLf
        strTemp = strTemp & "    LoginNum: '"& Easp.Cookie("ZjjCmsCms>LoginNum") &"'" & vbCrLf
        strTemp = strTemp & "};" & vbCrLf
        strTemp = strTemp & "</script>" & vbCrLf
        strTemp = strTemp & "<title>"& AdminTitle &" 管理员控制面板</title>" & vbCrLf
        strTemp = strTemp & "<meta http-equiv=""Expires"" Content=""0""/>" & vbCrLf
        strTemp = strTemp & "<meta http-equiv=""Cache-Control"" Content=""no-cache""/>" & vbCrLf
        strTemp = strTemp & "<meta http-equiv=""Pragma"" Content=""no-cache""/>" & vbCrLf
        strTemp = strTemp & CmsMain.LoadCssFile(SiteWebFilePath & "Scripts/jquery/ui/skins/Aqua/css/ligerui-all.css")
        strTemp = strTemp & CmsMain.LoadCssFile(AdminPath & "images/style.css")
        strTemp = strTemp & CmsMain.LoadCssFile(SiteWebFilePath & "Scripts/jquery/plugins/Validform/Validform.css")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/jquery/jquery.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/jquery/ui/liger.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/jquery/plugins/jquery.form.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/jquery/plugins/Validform/Validform.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/DatePicker/WdatePicker.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/plugins/ChinesePY.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/swfupload/swfupload.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/swfupload/swfupload.queue.js")
        strTemp = strTemp & CmsMain.LoadJsFile(SiteWebFilePath & "Scripts/swfupload/swfupload.handlers.js")
        strTemp = strTemp & CmsMain.LoadEditorScript(SiteWebFilePath)
        strTemp = strTemp & CmsMain.LoadDialogScript(SiteWebFilePath)
        strTemp = strTemp & IncHtmlFile
        strTemp = strTemp & CmsMain.LoadJsFile(AdminPath & "js/admin.js")
        strTemp = strTemp & CmsMain.LoadJsFile(AdminPath & "js/initValidform.js")
        strTemp = strTemp & "</head>" & vbCrLf
        strTemp = strTemp & "<body class="""& BodyCssName &""">" & vbCrLf
        Easp.W strTemp
    End Sub

    Public Function HtmlFooter()
        Dim strTemp
        strTemp = ""
        strTemp = strTemp & "<!-- "& Easp.GetScriptTime(startTime) &" -->" & vbCrLf
        strTemp = strTemp & "</body>" & vbCrLf
        strTemp = strTemp & "</html>"
        HtmlFooter = strTemp
    End Function

    Public Sub LoadFooter()
        Dim strTemp
        strTemp = HtmlFooter()
        Easp.W strTemp
    End Sub

    '==============================
    '<param name="msgtitle">提示文字</param>
    '<param name="url">返回地址</param>
    '<param name="msgcss">CSS样式</param>
    '<param name="callback">JS回调函数</param>
    '==============================

    Public Sub JscriptMsg(ByVal msgtitle, ByVal url, ByVal msgcss, ByVal callback)
        Dim strTemp
        strTemp = ""
        strTemp = strTemp & "<script>" & vbCrLf
        strTemp = strTemp & "parent.jsprint('"& msgtitle &"', '"& url &"', '"& msgcss &"', "& callback &");" & vbCrLf
        strTemp = strTemp & "</script>"
        Easp.WE strTemp
    End Sub

    Public Sub ReturnDialogVal(ByVal HtmlId, ByVal Val)
        Dim strTemp
        strTemp = ""
        strTemp = strTemp & "<script>" & vbCrLf
        strTemp = strTemp & "ReturnDialogVal('"& HtmlId &"','"& Val &"');" & vbCrLf
        strTemp = strTemp & "</script>" & vbCrLf
        Easp.WE strTemp
    End Sub

    Public Sub CloseDialog(ByVal Tip, ByVal i)
        Dim strTemp
        strTemp = ""
        strTemp = strTemp & "<script>" & vbCrLf
        strTemp = strTemp & "DialogTip('"& Tip &"',"& i &");" & vbCrLf
        strTemp = strTemp & "</script>" & vbCrLf
        Easp.WE strTemp
    End Sub

    Public Function TopicShowList(ByVal ChannelId, ByVal TitleName, ByVal ListName, ByVal Val)
        Dim strTemp, oRs, arrList, i, IfSelect
        strTemp = "<select name="""& ListName &""" id="""& ListName &""">" & vbCrLf
        strTemp = strTemp & "<option value=""0"">"& TitleName &"</option>" & vbCrLf
        Set oRs = Easp.db.GR(TablePrefix & "Topic:Id,Title", " ChannelId = "& ChannelId &" ", " id Desc ")
        If Not Easp.IsN(oRs) Then
            arrList = oRs.GetRows()
        End If
        Easp.C oRs
        If IsArray(arrList) Then
            For i = 0 To UBound(arrList, 2)
                IfSelect = ""
                If Val > 0 Then
                    IfSelect = Easp.IIf(Trim(arrList(0, i)) = Trim(Val), " selected=""selected""", "")
                End If
                strTemp = strTemp & "<option value="""& arrList(0, i) &""""& IfSelect &">"& arrList(1, i) &"</option>" & vbCrLf
            Next
        End If
        strTemp = strTemp & "</select>" & vbCrLf
        TopicShowList = strTemp
    End Function

    Public Sub ExeDelHtmlFile(ByVal ChannelId, ByVal TabName, ByVal TextId)
        Dim oSQL, oRs, TempFile
        oSQL = "Select b.ViewHtmlPath,a.HtmlFile,a.Id,b.ViewHtmlPrefix,a.ClassId,a.Tag From ["& TabName &"] a,["& TablePrefix & "Type] b Where b.ChannelId = "& ChannelId &" "
        oSQL = oSQL & " And a.ClassId = b.id And a.Id in("& TextId &") "
        Set oRs = Easp.db.Exec(oSQL)
        If Not Easp.IsN(oRs) Then
            Easp.Use "fso"
            Do While Not oRs.EOF
                UpdateTypeNum ChannelId, TabName, oRs(4)
                UpdateTags ChannelId, TabName, oRs(5)
                TempFile = CmsFun.HtmlFileUrl(oRs(0) & oRs(3), oRs(1), oRs(2))
                If Easp.Fso.IsFile(TempFile) Then
                    Easp.Fso.DelFile TempFile
                End If
                oRs.MoveNext
            Loop
        End If
        Easp.db.C oRs
    End Sub

    Public Sub UpdateTypeNum(ByVal ChannelId, ByVal TabName, ByVal ClassId)
        Dim DataNum
        DataNum = CmsFun.ChkNumEric(Easp.db.RT(TabName, " ClassId = "& ClassId &" ", "Count(*)"))
        If DataNum > 0 Then
            Easp.db.UR TablePrefix & "Type", " ChannelId = "& ChannelId &" And Id = "& ClassId &" ", Array("DataNum:" & DataNum)
        End If
    End Sub

    Public Sub UpdateTags(ByVal ChannelId, ByVal TabName, ByVal Str)
        If Not Easp.IsN(Str) Then
            Str = Trim(Str)
            Str = Easp.RegReplace(Str, "(\s+)", ",")
            Dim taglist, i, tag, CountNum
            taglist = Split(Str, ",")
            If UBound(taglist) < 0 Then
                Exit Sub
            End If
            For i = 0 To UBound(taglist)
                tag = Easp.Safe(Trim(taglist(i)), "s")
                CountNum = CmsFun.ChkNumEric(Easp.db.RT(TabName, " ','+Tag+',' Like '%," & tag & ",%' ", "Count(Id)"))
                Easp.db.UR TablePrefix & "Tags", " ChannelId = "& ChannelId &" And Name = '"& tag &"' ", Array("Counts:" & CountNum)
            Next
        End If
    End Sub

    Public Sub LoadCreateIndex()
        LoadCreatePage "../create/Admin.Pc.Html.Asp?action=index"
    End Sub

    Public Sub LoadCreatePage(ByVal strUrlLink)
        Dim strHtml
        strHtml = "<iframe style=""display:none;"" src="""& strUrlLink &"""></iframe>"
        Easp.WC strHtml
    End Sub

End Class
%>