<%option explicit%> <% ShopCheckAdmin "" '******************************* ' Version 6.50 Edits translate tables ' ' June 1, 2005 ' Input parameters ' which= ' specific record in table ' dbtable=translatecategories ' idfield=translateid ' categoryid= specific category '******************************* dim Addaction,Updateaction, Deleteaction dim rstemp dim which dim idfield dim dbtable, conn dim translatetable dim languages, langcount, url dim strlanguage, categoryid, catdescription 'dim helpfile 'helpfile="shopa_categoryhelp.htm" setsess "currenturl","shopa_edittranslatecategories.asp" Addaction=Request.form("add") Updateaction=Request.form("update") sError="" Deleteaction=request("delete") GetInputValues If DeleteAction<>"" then DeleteRecord end if EditOpenDatabase conn, database,dbtable If Addaction = "" and Updateaction = "" Then AdminPageHeader FormatEditHelpHeader SetDefaultvalues GenerateForm AdminPageTrailer Else AdminPageHeader FormatEditHelpHeader Validatefields if serror="" then UpdateRecord end if GenerateForm AdminPageTrailer end if Shopclosedatabase conn '************************ Sub GetInputValues ' ID, allows editing a record which=request.querystring("which") 'VP-ASP 6.09 - Precautionary Security Fix if which > "" then If not isnumeric(which) then shoperror "ID must be numeric" end if end if idfield=request.querystring("idfield") if idfield="" then idfield="translateid" end if dbtable= request.querystring("table") categoryid=request.querystring("categoryid") url=request("url") if url="" then url=getsess("currenturl") end if ValidateTable dim force force="Yes" Getlanguages languages, langcount, force End Sub ' Sub ValidateTable '******************************************** 'See if user has access to this table Dim UserTables, i dim tablecount if getconfig("XRestrictAdminTables")<>"Yes" then exit sub UserTables=GetSess("UserTables") If Isnull(UserTables) then exit sub end if if UserTables="" then exit Sub else UserTables=split(GetSess("UserTables"),",",-1,1) end if tablecount=ubound(UserTables) for i = 0 to tablecount if ucase(dbtable)=ucase(Usertables(i)) then exit sub end if next dbtable="" shoperror getlang("langEditSelectFail") end sub '******************************************************************************* ' Get the specific record and then generate form based on this record '******************************************************************************* Sub GenerateForm dim sqltemp if which <> "" then sqltemp="select * from " & dbtable sqltemp=sqltemp & " where " & idfield & "=" & which set rstemp=conn.execute(sqltemp) end if DisplayForm if which <> "" then rstemp.close set rstemp=nothing end if end Sub '**************************** Sub DisplayForm() if which <> "" then catdescription=rstemp("catdescription") strlanguage=rstemp("lang") categoryid=rstemp("categoryid") end if %>
<%shopwriteheader "Category Setup"%> <% if which<>"" then response.write "" end if response.write "" if which <> "" then response.write "" end if response.write "" %>
" & getlang("langadminadvanced") & " " & getlang("LangCommonEdit") & "Back To " & ucase(left(dbtable, 1)) & right(dbtable, len(dbtable) - 1) & "
<%shopwriteerror sError%>
<% response.write "
" 'VPASP 600 - ADD HTML EDITOR AddEditor "editform" GenerateDisplayHeader "Category Translation Information" GenerateDisplayBodyHeader 'VP-ASP 6.50 - Added buttons to top of page as well as bottom response.write "
" If which<>"" then Response.Write("    ") Response.Write("") Response.Write("  ") response.write "

" else Response.Write("") end if response.write "
" response.write "" Response.write tablerow & tablecolumn & getlang("LangLanguage") & tablecolumnend & tablecolumn GenerateselectNV languages,strlanguage,"lang",langcount, getlang("Langcommonselect") Response.write Tablecolumnend & TableRowEnd formateditrow "categoryid","categoryid",categoryid PCreateRowText getlang("LangProductDescription"),"catdescription",catdescription,2,"catdescription" Response.Write(TableDefEnd) response.write "
" If which<>"" then 'VPASP 600 - HTMLEDITOR If getconfig("xhtmleditor")="Yes" then Response.Write("    ") Response.Write("") else Response.Write("    ") Response.Write("") end if 'VP-ASP 6.50 - Moved Delete button to be on same line as Add and Update Response.Write("  ") response.write "

" else 'VPASP 600 - HTMLEDITOR If getconfig("xhtmleditor")="Yes" then Response.Write("") else Response.Write("") end if end if response.write "
" GenerateDisplayBodyFooter Response.Write("") gethelp "translatecategories" end sub '************ ' Sub UpdateRecord dim sqltemp, rc 'VP-ASP 6.50 - broadened defintion of IF statement to cover cases where xmysql hasn't been set if ucase(xdatabasetype) = "MYSQL" OR ucase(xdatabasetype) = "MYSQL351" OR getconfig("xMYSQL")="Yes" then MYSQLProcessrecord updateaction, conn, dbtable, idfield, which exit sub end if If updateaction<>"" then sqltemp="select * from " & dbtable sqltemp= sqltemp & " where " & idfield & "=" & which Set rstemp = Server.CreateObject("ADODB.Recordset") rstemp.open sqltemp, conn, 1, 3 rstemp.Update else Checkforduplicate rc if rc<>0 then exit sub Set rstemp = Server.CreateObject("ADODB.Recordset") rstemp.open dbtable, conn, adOpenKeyset, adLockOptimistic rstemp.AddNew end if GenerateUpdateSQL which = rstemp(idfield) rstemp.close set rstemp=nothing sError= sError & "
" & getlang("LangEdit03") & "" end sub ' ******** general Sql Sub GenerateUpdateSQL() Dim howmanyfields dim fieldname, fieldvalue, fieldtype dim i howmanyfields=rstemp.fields.count -1 rstemp.update for i=1 to howmanyfields fieldname = rstemp(i).name fieldtype=rstemp(i).type fieldvalue = request.form(fieldname) EUpdatefield fieldname,fieldvalue next rstemp.update end sub Sub EUpdateField (fieldname, fieldvalue) on error resume next if fieldvalue="" then rstemp(Fieldname)=NULL exit sub end if if ucase(fieldvalue)="NULL" then rstemp(Fieldname)=NULL else rstemp(Fieldname)=fieldvalue end if end sub '********************************************************************** ' Pre Fill in initial value from parent record '********************************************************************** Sub Setdefaultvalues dim sql, rs If categoryid="" then exit sub if which<>"" then exit sub sql="select * from categories where categoryid=" & categoryid Set rs=conn.execute(sql) if not rs.eof then catdescription=rs("catdescription") end if closerecordset rs end sub Sub DeleteRecord dim myconn EditOpenDatabase myconn, database,dbtable dim sql, url sql="delete from " & dbtable & " where " & idfield & "=" & which myconn.execute(sql) shopclosedatabase myconn url="shopa_editdisplay.asp?table=" & dbtable responseredirect url end sub '************************************************************************* ' New to find which table and which record '************************************************************************* Sub GetFormFields end sub Sub GetExistingProduct dim rs, sql sql="Select " & realname & " from " & table & " where " & idfield & "=" & recordid response.flush set rs=myconn.execute(sql) if not rs.eof then textdata=rs(realname) end if closerecordset rs end sub Sub PCreateRowText (caption, fieldname, fieldvalue, rows, realname) dim url, htmlurl, linkurl url="shopa_edittranslate.asp?which=" & which htmlurl="shopa_htmledit.asp?which=" & which & "&idfield=translateid&table=translatecategories&fieldname=" & realname htmlurl=htmlurl & "&url=" & server.urlencode(url) Linkurl="" & "HTML edit" & "" Response.write tablerow & tablecolumn & caption response.write tablecolumnend response.write "" 'FormatEditHelp fieldname, helpfile response.write "" end sub '*************************************************************** ' Get languages from language file or array ' Do not include default laqnguage '***************************************************************** Sub Getlanguages (languages, langcount, force) dim cid, name,catSQL,i, conn, defaultlang dim maxlangs, catrs,mylink langcount=0 maxlangs=20 defaultlang=lcase(getconfig("xlanguage")) Redim languages(maxlangs) ShopOpenDatabase conn catSQL="SELECT lang from languages GROUP BY lang" set catrs=conn.execute(catsql) Do While Not catrs.EOF and langcountdefaultlang then languages(langcount)=name langcount=langcount+1 end if catrs.MoveNext loop closerecordset catrs ShopCloseDatabase conn end sub '************************************************************************** ' check categoryid and language match on adding a record '************************************************************************** Sub Checkforduplicate (rc) rc=0 dim strlanguage, rs categoryid=request("categoryid") strlanguage=request("lang") sql="select * from " & dbtable & " where lang='"& strlanguage & "'" sql = sql & " and categoryid=" & categoryid set rs=conn.execute(sql) if not rs.eof then sError= sError & "
" & Getlang("langrecordexists") & "" rc=4 end if closerecordset rs end sub Sub Validatefields dim strlanguage, rs, categoryid categoryid=request("categoryid") 'VP-ASP 6.09 - Precautionary Security Fix if categoryid > "" then If not isnumeric(categoryid) then sError= sError & "
" & "categoryid must be numeric" end if end if strlanguage=request("lang") if strlanguage=getlang("langcommonselect") then strlanguage="" end if if strlanguage="" then sError= sError & "
" & getlang("LangLanguage") & " " & getlang("langcustrequired") end if if categoryid="" then sError= sError & "
" & "categoryid " & getlang("langcustrequired") end if end sub %>
"'" 'VPASP 600 - ADD HTML EDITOR If getconfig("xhtmleditor")="Yes" then addHTMLEditor fieldname, fieldvalue, "editform" else response.write "" end if response.write "