Module Links

#Region "  ADRESY PROHLIZECE V ADMINISTRACI  "

    '# Uvodni strana 100

    Public Const gadrUvodniStrana As String = "/Uvodni-strana.html"
    Public Const gadrUvodniStrana_slider As String = "/Uvodni-strana-slider.html"
    Public Const gadrUvodniStrana_slider_upravit As String = "/Uvodni-strana-slider-upravit.html"
    Public Const gadrUvodniStrana_slider_odstranit As String = "/Uvodni-strana-slider-odstranit.html"

    '# Aktuality

    Public Const gadrAktuality As String = "/Aktuality-seznam.html"
    Public Const gadrAktuality_upravit As String = "/Aktuality-upravit.html"
    Public Const gadrAktuality_odstranit As String = "/Aktuality-odstranit.html"

    Public Const gadrAktuality_foto_upravit As String = "/Aktuality-foto-upravit.html"
    Public Const gadrAktuality_foto_odstranit As String = "/Aktuality-foto-odstranit.html"

    '# Reference 200

    Public Const gadrProjekty_kategorie_seznam As String = "/Reference-kategorie-seznam.html"
    Public Const gadrProjekty_kategorie_upravit As String = "/Reference-kategorie-upravit.html"
    Public Const gadrProjekty_kategorie_odstranit As String = "/Reference-kategorie-odstranit.html"

    Public Const gadrProjekty_seznam As String = "/Reference-seznam.html"
    Public Const gadrProjekt_upravit As String = "/Reference-upravit.html"
    Public Const gadrProjekt_foto_upravit As String = "/Reference-foto-upravit.html"
    Public Const gadrProjekt_foto_odstranit As String = "/Reference-foto-odstranit.html"
    Public Const gadrProjekt_odstranit As String = "/Reference-odstranit.html"

    '# Sluzby 300

    Public Const gadrSluzby As String = "/Sluzby-seznam.html"
    Public Const gadrSluzby_upravit As String = "/Sluzby-upravit.html"
    Public Const gadrSluzby_odstranit As String = "/Sluzby-odstranit.html"

    '# O nas 400

    Public Const gadrOnas As String = "/Onas-seznam.html"
    Public Const gadrOnas_upravit As String = "/Onas-upravit.html"
    Public Const gadrOnas_odstranit As String = "/Onas-odstranit.html"

    '# Kontakt 500

    Public Const gadrKontakt As String = "/Kontakt.html"

    Public Const gadrLide_seznam As String = "/Lide-seznam.html"
    Public Const gadrLide_nadpis_upravit As String = "/Lide-nadpis-upravit.html"
    Public Const gadrLide_podnadpis_upravit As String = "/Lide-podnadpis-upravit.html"
    Public Const gadrLide_upravit As String = "/Lide-upravit.html"
    Public Const gadrLide_odstranit As String = "/Lide-odstranit.html"

    '# Nastaveni

    Public Const gadrNastaveni As String = "/Nastaveni.html"

#End Region

    Public gTopMenuSelected As _TopMenu

	Enum _TopMenu

		UvodniStrana = 1
		Aktuality = 2
        Projekty = 3
        Sluzby = 4
        Onas = 5
        Kontakt = 6

        Nastaveni = 9

    End Enum

    Public gSubMenuSelected As _SubMenu

    Enum _SubMenu

        UvodniStrana_Zaznam = 1
        UvodniStrana_Slider = 2

        Projekty_zaznamy = 5
        Projekty_roky = 6

        Kontakt_kontaktni_udaje = 10
        Kontakt_lide = 11

    End Enum

    ''' <summary>
    ''' Typy stranek v prezentaci
    ''' </summary>
    Enum _Stranka_Typ

        Zakladni = 1 'Zakladni stranka slozena z bloku

    End Enum

    ''' <summary>
    ''' Typy bloku na zakladni strance
    ''' </summary>
    Enum _Stranka_Zakladni_Bloky

        Zakladni = 1
        Fotografie = 2
        Soubory = 3

    End Enum

    Function GetLink(sTopMenu As _TopMenu) As String

        If sTopMenu = _TopMenu.UvodniStrana Then
            Return gadrUvodniStrana

        ElseIf sTopMenu = _TopMenu.Aktuality Then
            Return gadrAktuality

        ElseIf sTopMenu = _TopMenu.Projekty Then
            Return gadrProjekty_seznam

        ElseIf sTopMenu = _TopMenu.Sluzby Then
            Return gadrSluzby

        ElseIf sTopMenu = _TopMenu.Onas Then
            Return gadrOnas

        ElseIf sTopMenu = _TopMenu.Kontakt Then
            Return gadrKontakt

        ElseIf sTopMenu = _TopMenu.Nastaveni Then
			Return gadrNastaveni

		End If

		Return ""

	End Function

#Region "  ULOZIT ADRESU A TITULEK STRANKY  "

    Function SaveLink(iStrankaID As Int32, iZaznamID As Int16, sTitle As String, sLink As String, Optional sTopMenuText As String = "", Optional sDescription As String = "", Optional sH1 As String = "") As String

        Dim pDoc As New PCSolution.Document
        Dim DS As DataTable

        sLink = pDoc.OdstranitDiakritiku(sLink, "-")

        Dim iNumber As Int16 = 1
        Dim s As String = sLink

        DS = DB.ExecuteSelectCommand("SELECT * FROM [nastaveni].[adresy] WHERE strankaid = '" & iStrankaID & "' AND zaznamid = '" & iZaznamID &
                                     "' AND lang = '" & _Language & "'")

        '# Vytvorit jedinecnou adresu v cele databazi
        Do
            Dim DSAdresa As DataTable
            If DS.Rows.Count > 0 Then
                DSAdresa = DB.ExecuteSelectCommand("SELECT * FROM [nastaveni].[adresy] WHERE adresa = '" & s & "' AND shortid <> " & DS.Rows(0)("shortid"))
            Else
                DSAdresa = DB.ExecuteSelectCommand("SELECT * FROM [nastaveni].[adresy] WHERE adresa = '" & s & "'")
            End If

            If DSAdresa.Rows.Count = 0 Then
                sLink = s
                Exit Do
            Else
                s = sLink & "-" & iNumber
                iNumber += 1
            End If
        Loop
        '@

        sTitle = _PrevestTextNaBezpecny(sTitle)
        sLink = _PrevestTextNaBezpecny(sLink)
        sTopMenuText = _PrevestTextNaBezpecny(sTopMenuText)

        If DS.Rows.Count = 0 Then

            DB.ExecuteCommand("INSERT INTO [nastaveni].[adresy] (strankaid, zaznamid, titulek, adresa, hornimenu, h1, description, lang) VALUES (" &
                              iStrankaID & ", " & iZaznamID & ", '" & sTitle & "', '" & sLink & "', '" & sTopMenuText & "', '" & sH1 & "', '" & sDescription & "', '" & _Language & "')")

        Else

            DB.ExecuteCommand("UPDATE [nastaveni].[adresy] SET " &
                               "titulek = '" & sTitle & "', " &
                               "hornimenu = '" & sTopMenuText & "', " &
                               "h1 = '" & sH1 & "', " &
                               "description = '" & sDescription & "', " &
                               "adresa = '" & sLink & "' " &
                               "WHERE shortid = " & DS.Rows(0)("shortid"))

        End If

        Return sLink

    End Function


    ''' <summary>
    ''' Pouze pro rocnik ID v projektech
    ''' </summary>
    ''' <returns></returns>
    Function SaveLinkRocnik(iStrankaID As Int32, iZaznamID As Int16, iRocnikID As Int16, sTitle As String, sLink As String, Optional sTopMenuText As String = "", Optional sDescription As String = "", Optional sH1 As String = "") As String

        Dim pDoc As New PCSolution.Document
        Dim DS As DataTable

        sLink = pDoc.OdstranitDiakritiku(sLink, "-")

        Dim iNumber As Int16 = 1
        Dim s As String = sLink

        DS = DB.ExecuteSelectCommand("SELECT * FROM [nastaveni].[adresy] WHERE strankaid = '" & iStrankaID & "' AND rocnikid = '" & iRocnikID &
                                     "' AND lang = '" & _Language & "'")

        '# Vytvorit jedinecnou adresu v cele databazi
        Do
            Dim DSAdresa As DataTable
            If DS.Rows.Count > 0 Then
                DSAdresa = DB.ExecuteSelectCommand("SELECT * FROM [nastaveni].[adresy] WHERE adresa = '" & s & "' AND shortid <> " & DS.Rows(0)("shortid"))
            Else
                DSAdresa = DB.ExecuteSelectCommand("SELECT * FROM [nastaveni].[adresy] WHERE adresa = '" & s & "'")
            End If

            If DSAdresa.Rows.Count = 0 Then
                sLink = s
                Exit Do
            Else
                s = sLink & "-" & iNumber
                iNumber += 1
            End If
        Loop
        '@

        sTitle = _PrevestTextNaBezpecny(sTitle)
        sLink = _PrevestTextNaBezpecny(sLink)
        sTopMenuText = _PrevestTextNaBezpecny(sTopMenuText)

        If DS.Rows.Count = 0 Then

            DB.ExecuteCommand("INSERT INTO [nastaveni].[adresy] (strankaid, zaznamid, rocnikid, titulek, adresa, hornimenu, h1, description, lang) VALUES (" &
                              iStrankaID & ", 0, " & iRocnikID & ", '" & sTitle & "', '" & sLink & "', '" & sTopMenuText & "', '" & sH1 & "', '" & sDescription & "', '" & _Language & "')")

        Else

            DB.ExecuteCommand("UPDATE [nastaveni].[adresy] SET " &
                               "titulek = '" & sTitle & "', " &
                               "hornimenu = '" & sTopMenuText & "', " &
                               "h1 = '" & sH1 & "', " &
                               "description = '" & sDescription & "', " &
                               "adresa = '" & sLink & "' " &
                               "WHERE shortid = " & DS.Rows(0)("shortid"))

        End If

        Return sLink

    End Function

#End Region

#Region "  NACIST ADRESU A TITULEK STRANKY  "

    Sub LoadLink(iStrankaID As Int32, iZaznamID As Int16, ByRef sTitle As String, ByRef sLink As String, Optional ByRef sTopMenuText As String = "", Optional ByRef sDescription As String = "", Optional ByRef sH1 As String = "")

        Dim DS As DataTable

        DS = DB.ExecuteSelectCommand("SELECT * FROM [nastaveni].[adresy] WHERE strankaid = '" & iStrankaID & "' AND zaznamid = '" & iZaznamID & "' AND lang = '" & _Language & "'")
        If DS.Rows.Count = 0 Then Exit Sub


        sTitle = DS.Rows(0)("titulek")
        sLink = DS.Rows(0)("adresa")
        sTopMenuText = DS.Rows(0)("hornimenu")
        sDescription = DS.Rows(0)("description")
        sH1 = DS.Rows(0)("h1")

    End Sub


    ''' <summary>
    ''' Pouze pro rocnik ID v projektech
    ''' </summary>
    Sub LoadLinkRocnik(iStrankaID As Int32, iZaznamID As Int16, iRocnikID As Int32, ByRef sTitle As String, ByRef sLink As String, Optional ByRef sTopMenuText As String = "", Optional ByRef sDescription As String = "", Optional ByRef sH1 As String = "")

        Dim DS As DataTable

        DS = DB.ExecuteSelectCommand("SELECT * FROM [nastaveni].[adresy] WHERE strankaid = '" & iStrankaID & "' AND rocnikid = '" & iRocnikID & "' AND lang = '" & _Language & "'")
        If DS.Rows.Count = 0 Then Exit Sub


        sTitle = DS.Rows(0)("titulek")
        sLink = DS.Rows(0)("adresa")
        sTopMenuText = DS.Rows(0)("hornimenu")
        sDescription = DS.Rows(0)("description")
        sH1 = DS.Rows(0)("h1")

    End Sub

#End Region

End Module
