| [5] | 1 | <cfsetting enablecfoutputonly=true showdebugoutput=false> |
|---|
| 2 | <cfprocessingdirective pageencoding="utf-8"> |
|---|
| 3 | <!--- |
|---|
| 4 | Name : C:\projects\blogcfc5\client\admin\spryproxy.cfm |
|---|
| 5 | Author : Raymond Camden |
|---|
| 6 | Created : 07/11/06 |
|---|
| 7 | Last Updated : 07/16/06 |
|---|
| 8 | History : two changes in relation to differences in bd.net. (rkc 7/16/06) |
|---|
| 9 | ---> |
|---|
| 10 | |
|---|
| 11 | <cffunction name="queryToXML" returnType="string" access="public" output="false" hint="Converts a query to XML"> |
|---|
| 12 | <cfargument name="data" type="query" required="true"> |
|---|
| 13 | <cfargument name="rootelement" type="string" required="true"> |
|---|
| 14 | <cfargument name="itemelement" type="string" required="true"> |
|---|
| 15 | <cfargument name="cDataCols" type="string" required="false" default=""> |
|---|
| 16 | |
|---|
| 17 | <cfset var s = createObject('java','java.lang.StringBuffer')> |
|---|
| 18 | |
|---|
| 19 | <cfset var col = ""> |
|---|
| 20 | <cfset var columns = arguments.data.columnlist> |
|---|
| 21 | <cfset var txt = ""> |
|---|
| 22 | |
|---|
| 23 | <cfset s.append("<?xml version=""1.0"" encoding=""UTF-8""?>")> |
|---|
| 24 | <cfset s.append("<#arguments.rootelement#>")> |
|---|
| 25 | |
|---|
| 26 | <cfloop query="arguments.data"> |
|---|
| 27 | <cfset s.append("<#arguments.itemelement#>")> |
|---|
| 28 | |
|---|
| 29 | <cfloop index="col" list="#columns#"> |
|---|
| 30 | <cfset txt = arguments.data[col][currentRow]> |
|---|
| 31 | <cfif isSimpleValue(txt)> |
|---|
| 32 | <cfif listFindNoCase(arguments.cDataCols, col)> |
|---|
| 33 | <cfset txt = "<![CDATA[" & txt & "]]" & ">"> |
|---|
| 34 | <cfelse> |
|---|
| 35 | <cfset txt = xmlFormat(txt)> |
|---|
| 36 | </cfif> |
|---|
| 37 | <cfelse> |
|---|
| 38 | <cfset txt = ""> |
|---|
| 39 | </cfif> |
|---|
| 40 | |
|---|
| 41 | <cfset s.append("<#ucase(col)#>#txt#</#ucase(col)#>")> |
|---|
| 42 | |
|---|
| 43 | </cfloop> |
|---|
| 44 | |
|---|
| 45 | <cfset s.append("</#arguments.itemelement#>")> |
|---|
| 46 | </cfloop> |
|---|
| 47 | |
|---|
| 48 | <cfset s.append("</#arguments.rootelement#>")> |
|---|
| 49 | |
|---|
| 50 | <cfif structKeyExists(server, "bluedragon")> |
|---|
| 51 | <cfreturn toString(s.toString())> |
|---|
| 52 | <cfelse> |
|---|
| 53 | <cfreturn s.toString()> |
|---|
| 54 | </cfif> |
|---|
| 55 | </cffunction> |
|---|
| 56 | |
|---|
| 57 | <cfparam name="url.method" default=""> |
|---|
| 58 | |
|---|
| 59 | <cfswitch expression="#url.method#"> |
|---|
| 60 | |
|---|
| 61 | <cfcase value="getcategories"> |
|---|
| 62 | <cfset categories = application.blog.getCategories()> |
|---|
| 63 | <cfcontent type="text/xml; charset=utf-8"><cfoutput>#queryToXML(categories, "categories", "category")#</cfoutput> |
|---|
| 64 | </cfcase> |
|---|
| 65 | |
|---|
| 66 | <cfcase value="getentries"> |
|---|
| 67 | <cfif structKeyExists(url, "category")> |
|---|
| 68 | <cfset params = structNew()> |
|---|
| 69 | <cfset params.byCat = url.category> |
|---|
| 70 | <cfset params.mode = "short"> |
|---|
| 71 | <cfset params.maxEntries = 9999999> |
|---|
| 72 | <cfset entryData = application.blog.getEntries(params)> |
|---|
| 73 | <cfset entries = entryData.entries> |
|---|
| 74 | <cfquery name="entries" dbtype="query"> |
|---|
| 75 | select id, title, posted |
|---|
| 76 | from entries |
|---|
| 77 | </cfquery> |
|---|
| 78 | <cfcontent type="text/xml; charset=utf-8"><cfoutput>#queryToXML(entries, "entries", "entry")#</cfoutput> |
|---|
| 79 | |
|---|
| 80 | </cfif> |
|---|
| 81 | </cfcase> |
|---|
| 82 | |
|---|
| 83 | </cfswitch> |
|---|
| 84 | |
|---|
| 85 | <cfsetting enablecfoutputonly=false> |
|---|