Changeset 277
- Timestamp:
- 12/19/06 16:36:34 (2 years ago)
- Location:
- framework/trunk
- Files:
-
- 1 added
- 4 modified
-
fuseboxApplication.cfc (modified) (3 diffs)
-
fuseboxPlugin.cfc (modified) (8 diffs)
-
myFusebox.cfc (modified) (1 diff)
-
skeleton/fusebox.xml.cfm (modified) (2 diffs)
-
skeleton/plugins/example_plugin.cfm (added)
Legend:
- Unmodified
- Added
- Removed
-
framework/trunk/fuseboxApplication.cfc
r276 r277 93 93 hint="I am the myFusebox data structure." /> 94 94 95 <!--- update to ticket 139--->95 <!--- fixed ticket 73 ---> 96 96 <cfset var myVersion = "5.0.1.#REReplace('$LastChangedRevision$','[^0-9]','','all')#" /> 97 97 … … 660 660 </cfif> 661 661 <cfif structKeyExists(children[i].xmlAttributes,"relative")> 662 <cfif listFind("true,false,yes,no",children[ 1].xmlAttributes.relative) eq 0>662 <cfif listFind("true,false,yes,no",children[i].xmlAttributes.relative) eq 0> 663 663 <cfthrow type="fusebox.badGrammar.invalidAttributeValue" 664 664 message="Attribute has invalid value" … … 882 882 <cfset nn = arrayLen(children[i].xmlChildren) /> 883 883 <cfloop from="1" to="#nn#" index="j"> 884 <cfset plugin = createObject("component","fuseboxPlugin").init(phase,children[i].xmlChildren[j],this ) />884 <cfset plugin = createObject("component","fuseboxPlugin").init(phase,children[i].xmlChildren[j],this,variables.lexicons) /> 885 885 <cfset this.plugins[plugin.getName()][phase] = plugin /> 886 886 <cfif not structKeyExists(this.pluginphases,phase)> -
framework/trunk/fuseboxPlugin.cfc
r262 r277 59 59 <cfargument name="fbApp" type="fuseboxApplication" required="true" 60 60 hint="I am the fusebox application object." /> 61 <cfargument name="lexicons" type="struct" required="true" 62 hint="I am the lexicons declared in the fusebox.xml file that are available as custom attributes." /> 61 63 62 64 <cfset var i = 0 /> 63 65 <cfset var n = arrayLen(arguments.pluginXML.xmlChildren) /> 64 66 <cfset var attr = 0 /> 65 <cfset var n Attrs = 2/>67 <cfset var ns = "" /> 66 68 <cfset var verbChildren = arrayNew(1) /> 67 69 <cfset var factory = arguments.fbApp.getFuseactionFactory() /> … … 78 80 <cfset variables.name = arguments.pluginXML.xmlAttributes.name /> 79 81 <cfset variables.fuseboxApplication = arguments.fbApp /> 82 <cfset variables.customAttribs = structNew() /> 80 83 81 84 <cfif not structKeyExists(arguments.pluginXML.xmlAttributes,"template")> … … 91 94 <cfif structKeyExists(arguments.pluginXML.xmlAttributes,"path")> 92 95 <cfset this.path = this.path & replace(arguments.pluginXML.xmlAttributes.path,"\","/","all") /> 93 <cfset nAttrs = 3 />94 96 </cfif> 95 97 <cfif right(this.path,1) is not "/"> 96 98 <cfset this.path = this.path & "/" /> 97 99 </cfif> 100 101 <!--- look for any valid custom attributes ---> 102 <cfloop collection="#arguments.pluginXML.xmlAttributes#" item="attr"> 103 <cfswitch expression="#attr#"> 104 105 <cfcase value="name,template,path"> 106 <!--- already processed ---> 107 </cfcase> 108 109 <cfdefaultcase> 110 111 <cfif listLen(attr,":") eq 2> 112 <!--- looks like a custom attribute: ---> 113 <cfset ns = listFirst(attr,":") /> 114 <cfif structKeyExists(arguments.lexicons,ns)> 115 <cfset customAttribs[ns][listLast(attr,":")] = arguments.pluginXML.xmlAttributes[attr] /> 116 <cfelse> 117 <cfthrow type="fusebox.badGrammar.undeclaredNamespace" 118 message="Undeclared lexicon namespace" 119 detail="The lexicon prefix '#ns#' was found on a custom attribute in the '#getName()#' plugin declaration in fusebox.xml but no such lexicon namespace has been declared." /> 120 </cfif> 121 122 <cfelseif arguments.fbApp.strictMode> 123 <cfthrow type="fusebox.badGrammar.unexpectedAttributes" 124 message="Unexpected attributes" 125 detail="Unexpected attribute '#attr#' found in the '#getName()#' plugin declaration in fusebox.xml." /> 126 </cfif> 127 128 </cfdefaultcase> 129 130 </cfswitch> 131 </cfloop> 132 98 133 <cfset variables.template = arguments.pluginXML.xmlAttributes.template /> 99 134 <cfif len(variables.template) lt 4 or right(variables.template,4) is not ext> … … 107 142 <cfset this.rootpath = REreplace(this.rootpath,"[^\.:/]*/\.\./","") /> 108 143 </cfloop> 109 <cfif arguments.fbApp.strictMode and structCount(arguments.pluginXML.xmlAttributes) neq nAttrs> 110 <cfthrow type="fusebox.badGrammar.unexpectedAttributes" 111 message="Unexpected attributes" 112 detail="Unexpected attributes were found in the '#getName()#' plugin declaration in fusebox.xml." /> 113 </cfif> 144 114 145 <cfset variables.parameters = arguments.pluginXML.xmlChildren /> 115 146 <cfset variables.paramVerbs = structNew() /> 116 147 <cfloop from="1" to="#n#" index="i"> 148 117 149 <cfif not structKeyExists(variables.parameters[i].xmlAttributes,"name")> 118 150 <cfthrow type="fusebox.badGrammar.requiredAttributeMissing" … … 120 152 detail="The attribute 'name' is required, for a 'parameter' to the '#getName()#' plugin declaration in fusebox.xml." /> 121 153 </cfif> 154 122 155 <cfif not structKeyExists(variables.parameters[i].xmlAttributes,"value")> 123 156 <cfthrow type="fusebox.badGrammar.requiredAttributeMissing" … … 125 158 detail="The attribute 'value' is required, for a 'parameter' to the '#getName()#' plugin declaration in fusebox.xml." /> 126 159 </cfif> 160 127 161 <cfif arguments.fbApp.strictMode and structCount(variables.parameters[i].xmlAttributes) neq 2> 128 162 <cfthrow type="fusebox.badGrammar.unexpectedAttributes" … … 130 164 detail="Unexpected attributes were found in the '#variables.parameters[i].xmlAttributes.name#' parameter of the '#getName()#' plugin declaration in fusebox.xml." /> 131 165 </cfif> 166 132 167 <cfset attr = structNew() /> 133 168 <cfset attr.name = "myFusebox.plugins.#getName()#.parameters." & variables.parameters[i].xmlAttributes.name /> 134 169 <cfset attr.value = variables.parameters[i].xmlAttributes.value /> 135 170 <cfset variables.paramVerbs[i] = factory.create("set",this,attr,verbChildren) /> 171 136 172 </cfloop> 137 173 <cfelse> … … 194 230 </cffunction> 195 231 232 <cffunction name="getCustomAttributes" returntype="struct" access="public" output="false" 233 hint="I return the custom (namespace-qualified) attributes for this plugin tag."> 234 <cfargument name="ns" type="string" required="true" 235 hint="I am the namespace prefix whose attributes should be returned." /> 236 237 <cfif structKeyExists(variables.customAttribs,arguments.ns)> 238 <!--- we structCopy() this so folks can't poke values back into the metadata! ---> 239 <cfreturn structCopy(variables.customAttribs[arguments.ns]) /> 240 <cfelse> 241 <cfreturn structNew() /> 242 </cfif> 243 244 </cffunction> 245 196 246 </cfcomponent> -
framework/trunk/myFusebox.cfc
r276 r277 51 51 <cfcomponent hint="I provide the per-request myFusebox data structure and some convenience methods."> 52 52 <cfscript> 53 // update to ticket 13953 // fixed ticket 73 54 54 this.version.runtime = "5.0.1.#REReplace('$LastChangedRevision$','[^0-9]','','all')#"; 55 55 -
framework/trunk/skeleton/fusebox.xml.cfm
r266 r277 4 4 Example fusebox.xml control file. Shows how to define circuits, classes, 5 5 parameters and global fuseactions. 6 7 This is just a test namespace for the plugin custom attribute example 6 8 --> 7 <fusebox >9 <fusebox xmlns:test="test"> 8 10 <circuits> 9 11 <!-- illustrates defaults for parent ("") and relative ("true") --> … … 53 55 <phase name="preProcess"> 54 56 <!-- 55 <plugin name="prePP" template=" preProcess">56 <parameter name=" abc" value="123" />57 <plugin name="prePP" template="example_plugin" test:abc="123"> 58 <parameter name="def" value="456" /> 57 59 </plugin> 58 60 -->
