<% ' UltraApps Portal - FREE edition, Version 1.5 ' (C) Copyright 2001 by UltraApps ' This program may be used and modified for your own use ' so long as this copyright notice and this comment remain intact. ' You are not permitted to sell or distribute modified version of this software ' View files/license.html for full Legal Information ' ' Filename: Links.asp ' Generated with CodeCharge 2.0.1 '------------------------------- ' Links CustomIncludes begin %> <% ' Links CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "Links.asp" sTemplateFileName = "Links.html" '=============================== '=============================== ' Links PageSecurity begin ' Links PageSecurity end '=============================== '=============================== ' Links Open Event begin ' Links Open Event end '=============================== '=============================== ' Links OpenAnyPage Event begin ' Links OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' Links Show begin '=============================== ' Display page '------------------------------- ' Load HTML template for this page '------------------------------- LoadTemplate sAppPath & sTemplateFileName, "main" '------------------------------- ' Load HTML template of Header and Footer '------------------------------- LoadTemplate sHeaderFileName, "Header" LoadTemplate sFooterFileName, "Footer" '------------------------------- SetVar "FileName", sFileName '------------------------------- ' Step through each form '------------------------------- Header_Show Footer_Show Search_Show GeneralLinks_Show '------------------------------- ' Process page templates '------------------------------- Parse "Header", False Parse "Footer", False Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' Links Show end '------------------------------- ' Destroy all object variables '------------------------------- ' Links Close Event begin ' Links Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Display Search Form '------------------------------- Sub Search_Show() Dim sFormTitle: sFormTitle = "Search Links" Dim sActionFileName: sActionFileName = "Links.asp" '------------------------------- ' Search Open Event begin ' Search Open Event end '------------------------------- SetVar "FormTitle", sFormTitle SetVar "ActionPage", sActionFileName '------------------------------- ' Set variables with search parameters '------------------------------- fldsearch = GetParam("search") fldlink_category_id = GetParam("link_category_id") if sForm <> "Search" then if isempty(fldlink_category_id) then fldlink_category_id= "11" end if '------------------------------- ' Search Show begin '------------------------------- '------------------------------- ' Search Show Event begin ' Search Show Event end '------------------------------- SetVar "search", ToHTML(fldsearch) SetVar "SearchLBlink_category_id", "" SetVar "Selected", "" SetVar "ID", "" SetVar "Value", "Any" Parse "SearchLBlink_category_id", True openrs rslink_category_id, "select link_category_id, link_category_desc from link_categories order by 2" while not rslink_category_id.EOF SetVar "ID", GetValue(rslink_category_id, 0) : SetVar "Value", GetValue(rslink_category_id, 1) if cstr(GetValue(rslink_category_id, 0)) = cstr(fldlink_category_id) then SetVar "Selected", "SELECTED" else SetVar "Selected", "" Parse "SearchLBlink_category_id", True rslink_category_id.MoveNext wend set rslink_category_id = nothing '------------------------------- ' Search Show end '------------------------------- '------------------------------- ' Search Close Event begin ' Search Close Event end '------------------------------- Parse "FormSearch", False End Sub '=============================== '=============================== ' Display Grid Form '------------------------------- Sub GeneralLinks_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "General Links" Dim HasParam : HasParam = false Dim iSort : iSort = "" Dim iSorted : iSorted = "" Dim sDirection : sDirection = "" Dim sSortParams : sSortParams = "" Dim iRecordsPerPage : iRecordsPerPage = 20 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False Dim sActionFileName : sActionFileName = "LinkAdd.asp" SetVar "TransitParams", "" SetVar "FormParams", "link_category_id=" & ToURL(GetParam("link_category_id")) & "&search=" & ToURL(GetParam("search")) & "&" '------------------------------- ' Build WHERE statement '------------------------------- plink_category_id = GetParam("link_category_id") if IsNumeric(plink_category_id) and not isEmpty(plink_category_id) then plink_category_id = ToSQL(plink_category_id, "Number") else plink_category_id = Empty if not isEmpty(plink_category_id) then HasParam = true sWhere = sWhere & "l.[link_category_id]=" & plink_category_id end if psearch = GetParam("search") if not isEmpty(psearch) then if not (sWhere = "") then sWhere = sWhere & " and " HasParam = true sWhere = sWhere & "l.[link_desc] like '%" & replace(psearch, "'", "''") & "%'" end if if HasParam then sWhere = " AND (link_is_approved=1) AND (" & sWhere & ")" else sWhere = " AND link_is_approved=1" end if '------------------------------- ' Build ORDER BY statement '------------------------------- sOrder = " order by l.link_category_id Asc" iSort = GetParam("FormGeneralLinks_Sorting") iSorted = GetParam("FormGeneralLinks_Sorted") sDirection = "" if IsEmpty(iSort) then SetVar "Form_Sorting", "" else if iSort = iSorted then SetVar "Form_Sorting", "" sDirection = " DESC" sSortParams = "FormGeneralLinks_Sorting=" & iSort & "&FormGeneralLinks_Sorted=" & iSort & "&" else SetVar "Form_Sorting", iSort sDirection = " ASC" sSortParams = "FormGeneralLinks_Sorting=" & iSort & "&FormGeneralLinks_Sorted=" & "&" end if if iSort = 1 then sOrder = " order by l1.[link_category_desc]" & sDirection if iSort = 2 then sOrder = " order by l.[link_name]" & sDirection if iSort = 3 then sOrder = " order by l.[link_desc]" & sDirection if iSort = 4 then sOrder = " order by l.[link_address]" & sDirection end if '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select [l].[link_address] as l_link_address, " & _ "[l].[link_category_id] as l_link_category_id, " & _ "[l].[link_desc] as l_link_desc, " & _ "[l].[link_name] as l_link_name, " & _ "[l].[link_url] as l_link_url, " & _ "[l1].[link_category_id] as l1_link_category_id, " & _ "[l1].[link_category_desc] as l1_link_category_desc " & _ " from [links] l, [link_categories] l1" & _ " where [l1].[link_category_id]=l.[link_category_id] " '------------------------------- '------------------------------- ' GeneralLinks Open Event begin ' GeneralLinks Open Event end '------------------------------- '------------------------------- ' Assemble full SQL statement '------------------------------- sSQL = sSQL & sWhere & sOrder '------------------------------- SetVar "FormTitle", sFormTitle '------------------------------- ' Process the link to the record page '------------------------------- SetVar "FormAction", sActionFileName '------------------------------- '------------------------------- ' Process the parameters for sorting '------------------------------- SetVar "SortParams", sSortParams '------------------------------- '------------------------------- ' Open the recordset '------------------------------- openrs rs, sSQL '------------------------------- '------------------------------- ' Process empty recordset '------------------------------- if rs.eof then set rs = nothing SetVar "DListGeneralLinks", "" Parse "GeneralLinksNoRecords", False SetVar "GeneralLinksNavigator", "" Parse "FormGeneralLinks", False exit sub end if '------------------------------- '------------------------------- ' Initialize page counter and records per page '------------------------------- iRecordsPerPage = 20 iCounter = 0 '------------------------------- '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("FormGeneralLinks_Page") if IsEmpty(iPage) then iPage = 1 else iPage = CLng(iPage) while not rs.eof and iCounter < (iPage-1)*iRecordsPerPage rs.movenext iCounter = iCounter + 1 wend iCounter = 0 '------------------------------- '------------------------------- ' Display grid based on recordset '------------------------------- while not rs.EOF and iCounter < iRecordsPerPage '------------------------------- ' Create field variables based on database fields '------------------------------- fldlink_address = GetValue(rs, "l_link_address") fldlink_category_id = GetValue(rs, "l1_link_category_desc") fldlink_desc = GetValue(rs, "l_link_desc") fldlink_name = GetValue(rs, "l_link_name") fldlink_url = GetValue(rs, "l_link_url") '------------------------------- ' GeneralLinks Show begin '------------------------------- '------------------------------- ' GeneralLinks Show Event begin if fldlink_url <> "" then fldlink_name = "" & fldlink_name & "" ' GeneralLinks Show Event end '------------------------------- '------------------------------- ' Replace Template fields with database values '------------------------------- SetVar "link_category_id", ToHTML(fldlink_category_id) SetVar "link_name", fldlink_name SetVar "link_desc", ToHTML(fldlink_desc) SetVar "link_address", ToHTML(fldlink_address) SetVar "link_url", ToHTML(fldlink_url) Parse "DListGeneralLinks", True '------------------------------- ' GeneralLinks Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' GeneralLinks Navigation begin '------------------------------- bEof = rs.eof if rs.eof and iPage = 1 then SetVar "GeneralLinksNavigator", "" else if bEof then SetVar "GeneralLinksNavigatorLastPage", "_" else SetVar "NextPage", (iPage + 1) end if if iPage = 1 then SetVar "GeneralLinksNavigatorFirstPage", "_" else SetVar "PrevPage", (iPage - 1) end if SetVar "GeneralLinksCurrentPage", iPage Parse "GeneralLinksNavigator", False end if '------------------------------- ' GeneralLinks Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing SetVar "GeneralLinksNoRecords", "" Parse "FormGeneralLinks", False '------------------------------- ' GeneralLinks Close Event begin ' GeneralLinks Close Event end '------------------------------- End Sub '=============================== %>