<% '----------------------------------------------------------- '-- TITLE: IMAGE FUNCTIONS '-- AUTHOR: MALCOLM ELSWORTH [malcolm@electricputty.co.uk] '-- LAST MODIFIED: 02-05-06 '-- (C) ELECTRIC PUTTY LIMITED '----------------------------------------------------------- dim cat_id cat_id = request("cat_id") '----------------------------------------------------------- '-- WRITE OUT ALL IMAGES '----------------------------------------------------------- function viewAllCategories() if len(confirmMsg) > 0 then response.write("

" & confirmMsg & "

") else response.write("

 

" & VbCrLf) end if response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) dim thisCatID dim thisCatName dim thisCatChildren rowClass = "odd" call writeCatTable(0,openTreeBranches,0) response.write("
Category nameEditDelete
") set rs = nothing response.write("
" & VbCrLf) response.write("" & VbCrLf) response.write("

 

" & VbCrLf) response.write("
" & VbCrLf) end function function writeCatTable(parent_id,openTreeBranches,depth) openCategories = split(openTreeBranches,",") strSQL = ""&_ "SELECT c.*, "&_ "(SELECT count(cc.cat_id) FROM epcms_categories cc WHERE cc.cat_parentid = c.cat_id) as cat_children "&_ "FROM epcms_categories c "&_ "WHERE c.cat_parentid = " & parent_id & " ORDER BY c.cat_name" Set rs = LoadRSFromDB(strSQL) if not rs.EOF then loopCount = 1 Do While not rs.EOF thisCatID = rs("cat_id") thisCatName = rs("cat_name") thisCatChildren = rs("cat_children") response.write("" & VbCrLf) response.write("") call writeCatTree(thisCatChildren, thisCatID, depth, openTreeBranches) response.write(thisCatName & "" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) if rowClass = "odd" then rowClass = "even" else rowClass = "odd" end if loopCount = loopCount + 1 if IDisInArray(thisCatID, openCategories) then call writeCatTable(thisCatID, openTreeBranches, depth + 1) end if rs.movenext Loop else response.write("

There are currently no categories in the system

") end if end function function writeCatTree(thisHasChildren,thisCatID, depth, currentParentList) if depth > 0 then response.write("") end if oldParentList = split(currentParentList,",") if cint(thisHasChildren) > 0 then if IDisInArray(thisCatID, oldParentList) then for n = 0 to ubound(oldParentList) if cint(oldParentList(n)) <> cint(thisCatID) then if n = 0 then newParentList = newParentList & oldParentList(n) else newParentList = newParentList & "," & oldParentList(n) end if end if next response.write("") else response.write("") end if else response.write("") end if end function function IDisInArray(c_ID,c_array) dim tempValue tempValue = false if isArray(c_array) then for n=0 to ubound(c_array) if len(c_array(n)) then if cint(c_array(n)) = cint(c_ID) then tempValue = true end if end if next end if IDisInArray = tempValue end function '----------------------------------------------------------- '-- FUNCTION TO ADD/EDIT IMAGE DETAILS '----------------------------------------------------------- function addEditCategory(cat_id) dim this_process dim this_screenTitle if len(cat_id) > 0 then strSQL = "Select * from epcms_categories where cat_id = " & cat_id Set rs = LoadRSFromDB(strSQL) if not rs.EOF then this_cat_id = cat_id this_process = "update" this_formAction = "Update category" this_cat_parentid = rs("cat_parentid") this_cat_name = rs("cat_name") this_cat_desc = rs("cat_desc") end if set rs = nothing this_screenTitle = "Edit category info" else this_process = "add" this_formAction = "Add category" this_cat_id = "" this_cat_parentid = request("newCatParent") this_cat_name = request("newCatName") this_cat_desc = request("newCatDesc") this_screenTitle = "Add category" end if response.write("

" & this_screenTitle & "

" & VbCrLf) if len(errorMsg) then call writeCategoryErrorMessages() end if response.write("
" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("

 

" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("

 

" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("

 

" & VbCrLf) response.write("" & VbCrLf) response.write("" & VbCrLf) response.write("

 

" & VbCrLf) response.write("
" & VbCrLf) end function function createCategoryDropDown(parent_id,depth,selectedCat) strSQL = "Select * from epcms_categories where cat_parentid = " & parent_id Set rs = LoadRSFromDB(strSQL) if not rs.EOF then do while not rs.EOF thisCatID = rs("cat_id") thisCatName = rs("cat_name") response.write("" & VbCrLf) call createCategoryDropDown(thisCatID, depth + 1, selectedCat) rs.movenext loop end if set rs = nothing end function '----------------------------------------------------------- '-- FUNCTION TO WRITE ERROR MESSAGES '----------------------------------------------------------- sub writeCategoryErrorMessages() select case errorMsg case "CatNameZeroLength" response.write("

You must enter a category name

" & VbCrLf) end select end sub %>