PageRenderTime 47ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/wheels/global/cfml.cfm

http://cfwheels.googlecode.com/
ColdFusion | 242 lines | 214 code | 24 blank | 4 comment | 0 complexity | 650a9e51ca779e0d73a56878b5c0045a MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
  1. <cffunction name="$namedReadLock" returntype="any" access="public" output="false">
  2. <cfargument name="name" type="string" required="true">
  3. <cfargument name="object" type="any" required="true">
  4. <cfargument name="method" type="string" required="true">
  5. <cfargument name="args" type="struct" required="false" default="#StructNew()#">
  6. <cfargument name="timeout" type="numeric" required="false" default="30">
  7. <cfset var loc = {}>
  8. <cflock name="#arguments.name#" type="readonly" timeout="#arguments.timeout#">
  9. <cfset loc.returnValue = $invoke(componentReference=arguments.object, method=arguments.method, invokeArgs=arguments.args)>
  10. </cflock>
  11. <cfreturn loc.returnValue>
  12. </cffunction>
  13. <cffunction name="$doubleCheckedLock" returntype="any" access="public" output="false">
  14. <cfargument name="name" type="string" required="true">
  15. <cfargument name="condition" type="string" required="true">
  16. <cfargument name="execute" type="string" required="true">
  17. <cfargument name="conditionArgs" type="struct" required="false" default="#StructNew()#">
  18. <cfargument name="executeArgs" type="struct" required="false" default="#StructNew()#">
  19. <cfargument name="timeout" type="numeric" required="false" default="30">
  20. <cfset var loc = {}>
  21. <cfset loc.returnValue = $invoke(method=arguments.condition, invokeArgs=arguments.conditionArgs)>
  22. <cfif IsBoolean(loc.returnValue) AND NOT loc.returnValue>
  23. <cflock name="#arguments.name#" timeout="#arguments.timeout#">
  24. <cfset loc.returnValue = $invoke(method=arguments.condition, invokeArgs=arguments.conditionArgs)>
  25. <cfif IsBoolean(loc.returnValue) AND NOT loc.returnValue>
  26. <cfset loc.returnValue = $invoke(method=arguments.execute, invokeArgs=arguments.executeArgs)>
  27. </cfif>
  28. </cflock>
  29. </cfif>
  30. <cfreturn loc.returnValue>
  31. </cffunction>
  32. <cffunction name="$simpleLock" returntype="any" access="public" output="false">
  33. <cfargument name="execute" type="string" required="true">
  34. <cfargument name="executeArgs" type="struct" required="false" default="#StructNew()#">
  35. <cfargument name="timeout" type="numeric" required="false" default="30">
  36. <cfset var loc = {}>
  37. <cfset loc.lockArgs = Duplicate(arguments)>
  38. <cfset StructDelete(loc.lockArgs, "execute")>
  39. <cfset StructDelete(loc.lockArgs, "executeArgs")>
  40. <cfset arguments.executeArgs.$locked = true>
  41. <cflock attributeCollection="#loc.lockArgs#">
  42. <cfinvoke method="#arguments.execute#" argumentCollection="#arguments.executeArgs#" returnvariable="loc.returnValue">
  43. </cflock>
  44. <cfif StructKeyExists(loc, "returnValue")>
  45. <cfreturn loc.returnValue>
  46. </cfif>
  47. </cffunction>
  48. <cffunction name="$setting" returntype="void" access="public" output="false">
  49. <cfsetting attributeCollection="#arguments#">
  50. </cffunction>
  51. <cffunction name="$image" returntype="struct" access="public" output="false">
  52. <cfset var returnValue = {}>
  53. <cfset arguments.structName = "returnValue">
  54. <cfimage attributeCollection="#arguments#">
  55. <cfreturn returnValue>
  56. </cffunction>
  57. <cffunction name="$mail" returntype="void" access="public" output="false">
  58. <cfset var loc = {}>
  59. <cfif StructKeyExists(arguments, "mailparts")>
  60. <cfset loc.mailparts = arguments.mailparts>
  61. <cfset StructDelete(arguments, "mailparts")>
  62. </cfif>
  63. <cfif StructKeyExists(arguments, "mailparams")>
  64. <cfset loc.mailparams = arguments.mailparams>
  65. <cfset StructDelete(arguments, "mailparams")>
  66. </cfif>
  67. <cfif StructKeyExists(arguments, "tagContent")>
  68. <cfset loc.tagContent = arguments.tagContent>
  69. <cfset StructDelete(arguments, "tagContent")>
  70. </cfif>
  71. <cfmail attributeCollection="#arguments#">
  72. <cfif StructKeyExists(loc, "mailparams")>
  73. <cfloop array="#loc.mailparams#" index="loc.i">
  74. <cfmailparam attributeCollection="#loc.i#">
  75. </cfloop>
  76. </cfif>
  77. <cfif StructKeyExists(loc, "mailparts")>
  78. <cfloop array="#loc.mailparts#" index="loc.i">
  79. <cfset loc.innerTagContent = loc.i.tagContent>
  80. <cfset StructDelete(loc.i, "tagContent")>
  81. <cfmailpart attributeCollection="#loc.i#">
  82. #loc.innerTagContent#
  83. </cfmailpart>
  84. </cfloop>
  85. </cfif>
  86. <cfif StructKeyExists(loc, "tagContent")>
  87. #loc.tagContent#
  88. </cfif>
  89. </cfmail>
  90. </cffunction>
  91. <cffunction name="$zip" returntype="any" access="public" output="false">
  92. <cfzip attributeCollection="#arguments#">
  93. </cfzip>
  94. </cffunction>
  95. <cffunction name="$cache" returntype="any" access="public" output="false">
  96. <cfcache attributeCollection="#arguments#">
  97. </cffunction>
  98. <cffunction name="$content" returntype="any" access="public" output="false">
  99. <cfcontent attributeCollection="#arguments#">
  100. </cffunction>
  101. <cffunction name="$header" returntype="void" access="public" output="false">
  102. <cfheader attributeCollection="#arguments#">
  103. </cffunction>
  104. <cffunction name="$abort" returntype="void" access="public" output="false">
  105. <cfabort attributeCollection="#arguments#">
  106. </cffunction>
  107. <cffunction name="$include" returntype="void" access="public" output="false">
  108. <cfargument name="template" type="string" required="true">
  109. <cfset var loc = {}>
  110. <cfinclude template="../../#LCase(arguments.template)#">
  111. </cffunction>
  112. <cffunction name="$includeAndOutput" returntype="void" access="public" output="true">
  113. <cfargument name="template" type="string" required="true">
  114. <cfset var loc = {}>
  115. <cfinclude template="../../#LCase(arguments.template)#">
  116. </cffunction>
  117. <cffunction name="$includeAndReturnOutput" returntype="string" access="public" output="false">
  118. <cfargument name="$template" type="string" required="true">
  119. <cfset var loc = {}>
  120. <cfif StructKeyExists(arguments, "$type") AND arguments.$type IS "partial">
  121. <!--- make it so the developer can reference passed in arguments in the loc scope if they prefer --->
  122. <cfset loc = arguments>
  123. </cfif>
  124. <!--- we prefix returnValue with "wheels" here to make sure the variable does not get overwritten in the included template --->
  125. <cfsavecontent variable="loc.wheelsReturnValue"><cfinclude template="../../#LCase(arguments.$template)#"></cfsavecontent>
  126. <cfreturn loc.wheelsReturnValue>
  127. </cffunction>
  128. <cffunction name="$directory" returntype="any" access="public" output="false">
  129. <cfset var returnValue = "">
  130. <cfset arguments.name = "returnValue">
  131. <cfdirectory attributeCollection="#arguments#">
  132. <cfreturn returnValue>
  133. </cffunction>
  134. <cffunction name="$file" returntype="any" access="public" output="false">
  135. <cfset var returnValue = "">
  136. <cfset arguments.variable = "returnValue">
  137. <cffile attributeCollection="#arguments#">
  138. <cfreturn returnValue>
  139. </cffunction>
  140. <cffunction name="$throw" returntype="void" access="public" output="false">
  141. <cfthrow attributeCollection="#arguments#">
  142. </cffunction>
  143. <cffunction name="$invoke" returntype="any" access="public" output="false">
  144. <cfset var loc = {}>
  145. <cfset arguments.returnVariable = "loc.returnValue">
  146. <cfif StructKeyExists(arguments, "componentReference")>
  147. <cfset arguments.component = arguments.componentReference>
  148. <cfset StructDelete(arguments, "componentReference")>
  149. <cfelseif NOT StructKeyExists(variables, arguments.method)>
  150. <!--- this is done so that we can call dynamic methods via "onMissingMethod" on the object (we need to pass in the object for this so it can call methods on the "this" scope instead) --->
  151. <cfset arguments.component = this>
  152. </cfif>
  153. <cfif StructKeyExists(arguments, "invokeArgs")>
  154. <cfset arguments.argumentCollection = arguments.invokeArgs>
  155. <cfset StructDelete(arguments, "invokeArgs")>
  156. </cfif>
  157. <cfinvoke attributeCollection="#arguments#">
  158. <cfif StructKeyExists(loc, "returnValue")>
  159. <cfreturn loc.returnValue>
  160. </cfif>
  161. </cffunction>
  162. <cffunction name="$location" returntype="void" access="public" output="false">
  163. <cfargument name="delay" type="boolean" required="false" default="false">
  164. <cfset StructDelete(arguments, "$args", false)>
  165. <cfif NOT arguments.delay>
  166. <cfset StructDelete(arguments, "delay", false)>
  167. <cfif arguments.url Contains "?" AND arguments.url Contains "##">
  168. <!--- fix for cflocation anchor bug --->
  169. <cfset arguments.url = Replace(arguments.url, "##", "&##")>
  170. </cfif>
  171. <cflocation attributeCollection="#arguments#">
  172. </cfif>
  173. </cffunction>
  174. <cffunction name="$htmlhead" returntype="void" access="public" output="false">
  175. <cfhtmlhead attributeCollection="#arguments#">
  176. </cffunction>
  177. <cffunction name="$dbinfo" returntype="any" access="public" output="false">
  178. <cfset var loc = {}>
  179. <cfset arguments.name = "loc.returnValue">
  180. <cfif NOT Len(arguments.username)>
  181. <cfset StructDelete(arguments, "username")>
  182. </cfif>
  183. <cfif NOT Len(arguments.password)>
  184. <cfset StructDelete(arguments, "password")>
  185. </cfif>
  186. <cfdbinfo attributeCollection="#arguments#">
  187. <cfreturn loc.returnValue>
  188. </cffunction>
  189. <cffunction name="$dump" returntype="void" access="public" output="true">
  190. <cfargument name="var" type="any" required="true">
  191. <cfargument name="abort" type="boolean" required="false" default="true">
  192. <cfdump var="#arguments.var#">
  193. <cfif arguments.abort>
  194. <cfabort>
  195. </cfif>
  196. </cffunction>
  197. <cffunction name="$objectcache" returntype="void" access="public" output="false">
  198. <cfobjectcache attributeCollection="#arguments#">
  199. </cffunction>
  200. <cffunction name="$wddx" returntype="any" access="public" output="false">
  201. <cfargument name="input" type="any" required="true">
  202. <cfargument name="action" type="string" required="false" default="cfml2wddx">
  203. <cfargument name="useTimeZoneInfo" type="boolean" required="false" default="true">
  204. <cfset var loc = {}>
  205. <cfset arguments.output = "loc.output">
  206. <cfwddx attributeCollection="#arguments#">
  207. <cfif StructKeyExists(loc, "output")>
  208. <cfreturn loc.output>
  209. </cfif>
  210. </cffunction>
  211. <cffunction name="$structDelete" returntype="void" access="public" output="false">
  212. <cfargument name="myStruct" type="struct" required="true">
  213. <cfargument name="keys" type="string" required="true">
  214. <cfset var loc = {}>
  215. <cfloop list="#arguments.keys#" index="loc.i">
  216. <cfset StructDelete(arguments.myStruct, loc.i, false)>
  217. </cfloop>
  218. </cffunction>