| 1 | <!--- |
|---|
| 2 | Fusebox Software License |
|---|
| 3 | Version 1.0 |
|---|
| 4 | |
|---|
| 5 | Copyright (c) 2003, 2004, 2005, 2006 The Fusebox Corporation. All rights reserved. |
|---|
| 6 | |
|---|
| 7 | Redistribution and use in source and binary forms, with or without modification, are permitted |
|---|
| 8 | provided that the following conditions are met: |
|---|
| 9 | |
|---|
| 10 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions |
|---|
| 11 | and the following disclaimer. |
|---|
| 12 | |
|---|
| 13 | 2. Redistributions in binary form or otherwise encrypted form must reproduce the above copyright |
|---|
| 14 | notice, this list of conditions and the following disclaimer in the documentation and/or other |
|---|
| 15 | materials provided with the distribution. |
|---|
| 16 | |
|---|
| 17 | 3. The end-user documentation included with the redistribution, if any, must include the following |
|---|
| 18 | acknowledgment: |
|---|
| 19 | |
|---|
| 20 | "This product includes software developed by the Fusebox Corporation (http://www.fusebox.org/)." |
|---|
| 21 | |
|---|
| 22 | Alternately, this acknowledgment may appear in the software itself, if and wherever such |
|---|
| 23 | third-party acknowledgments normally appear. |
|---|
| 24 | |
|---|
| 25 | 4. The names "Fusebox" and "Fusebox Corporation" must not be used to endorse or promote products |
|---|
| 26 | derived from this software without prior written (non-electronic) permission. For written |
|---|
| 27 | permission, please contact fusebox@fusebox.org. |
|---|
| 28 | |
|---|
| 29 | 5. Products derived from this software may not be called "Fusebox", nor may "Fusebox" appear in |
|---|
| 30 | their name, without prior written (non-electronic) permission of the Fusebox Corporation. For |
|---|
| 31 | written permission, please contact fusebox@fusebox.org. |
|---|
| 32 | |
|---|
| 33 | If one or more of the above conditions are violated, then this license is immediately revoked and |
|---|
| 34 | can be re-instated only upon prior written authorization of the Fusebox Corporation. |
|---|
| 35 | |
|---|
| 36 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|---|
| 37 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|---|
| 38 | DISCLAIMED. IN NO EVENT SHALL THE FUSEBOX CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
|---|
| 39 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|---|
| 40 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
|---|
| 41 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|---|
| 42 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|---|
| 43 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 44 | |
|---|
| 45 | ------------------------------------------------------------------------------- |
|---|
| 46 | |
|---|
| 47 | This software consists of voluntary contributions made by many individuals on behalf of the |
|---|
| 48 | Fusebox Corporation. For more information on Fusebox, please see <http://www.fusebox.org/>. |
|---|
| 49 | |
|---|
| 50 | ---> |
|---|
| 51 | <!--- |
|---|
| 52 | Fusebox Software License |
|---|
| 53 | Version 1.0 |
|---|
| 54 | |
|---|
| 55 | Copyright (c) 2005 The Fusebox Corporation. All rights reserved. |
|---|
| 56 | |
|---|
| 57 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
|---|
| 58 | |
|---|
| 59 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
|---|
| 60 | |
|---|
| 61 | 2. Redistributions in binary form or otherwise encrypted form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. |
|---|
| 62 | |
|---|
| 63 | 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: |
|---|
| 64 | |
|---|
| 65 | "This product includes software developed by the Fusebox Corporation (http://www.fusebox.org/)." |
|---|
| 66 | |
|---|
| 67 | Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. |
|---|
| 68 | |
|---|
| 69 | 4. The names "Fusebox" and "Fusebox Corporation" must not be used to endorse or promote products derived from this software without prior written (non-electronic) permission. For written permission, please contact fusebox@fusebox.org. |
|---|
| 70 | |
|---|
| 71 | 5. Products derived from this software may not be called "Fusebox", nor may "Fusebox" appear in their name, without prior written (non-electronic) permission of the Fusebox Corporation. For written permission, please contact fusebox@fusebox.org. |
|---|
| 72 | |
|---|
| 73 | If one or more of the above conditions are violated, then this license is immediately revoked and can be re-instated only upon prior written authorization of the Fusebox Corporation. |
|---|
| 74 | |
|---|
| 75 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FUSEBOX CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 76 | |
|---|
| 77 | ------------------------------------------------------------------------------- |
|---|
| 78 | |
|---|
| 79 | This software consists of voluntary contributions made by many individuals on behalf of the Fusebox Corporation. For more information on Fusebox, please see <http://www.fusebox.org/>. |
|---|
| 80 | |
|---|
| 81 | ---> |
|---|
| 82 | <cfcomponent> |
|---|
| 83 | <cfscript> |
|---|
| 84 | this.version.runtime = "unknown"; |
|---|
| 85 | this.version.loader = "unknown"; |
|---|
| 86 | this.version.transformer = "unknown"; |
|---|
| 87 | this.version.parser = "unknown"; |
|---|
| 88 | |
|---|
| 89 | this.version.runtime = "5.0.0.A.2"; |
|---|
| 90 | |
|---|
| 91 | this.thisCircuit = ""; |
|---|
| 92 | this.thisFuseaction = ""; |
|---|
| 93 | this.thisPlugin = ""; |
|---|
| 94 | this.thisPhase = ""; |
|---|
| 95 | this.plugins = structNew(); |
|---|
| 96 | this.parameters = structNew(); |
|---|
| 97 | |
|---|
| 98 | // the basic default is development mode |
|---|
| 99 | this.parameters.load = true; |
|---|
| 100 | this.parameters.clean = false; // don't delete parsed files by default |
|---|
| 101 | this.parameters.parse = true; |
|---|
| 102 | this.parameters.parseall = false; // don't compile all fuseactions by default |
|---|
| 103 | this.parameters.execute = true; |
|---|
| 104 | |
|---|
| 105 | this.parameters.userProvidedLoadParameter = false; |
|---|
| 106 | this.parameters.userProvidedCleanParameter = false; |
|---|
| 107 | this.parameters.userProvidedParseParameter = false; |
|---|
| 108 | this.parameters.userProvidedParseAllParameter = false; |
|---|
| 109 | this.parameters.userProvidedExecuteParameter = false; |
|---|
| 110 | </cfscript> |
|---|
| 111 | |
|---|
| 112 | <cffunction name="init" returntype="myFusebox" access="public" output="false"> |
|---|
| 113 | <cfargument name="appKey" type="string" required="true" /> |
|---|
| 114 | <cfargument name="attributes" type="struct" required="true" /> |
|---|
| 115 | |
|---|
| 116 | <cfset var theFusebox = structNew() /> |
|---|
| 117 | |
|---|
| 118 | <cfset variables.appKey = arguments.appKey /> |
|---|
| 119 | <cfset variables.attributes = arguments.attributes /> |
|---|
| 120 | |
|---|
| 121 | <!--- we can't guarantee the fusebox exists in application scope yet... ---> |
|---|
| 122 | <cfif structKeyExists(application,variables.appKey)> |
|---|
| 123 | <cfset theFusebox = application[variables.appKey] /> |
|---|
| 124 | </cfif> |
|---|
| 125 | |
|---|
| 126 | <!--- default myFusebox.parameters depending on "mode" of the application set in fusebox.xml ---> |
|---|
| 127 | <cfif structKeyExists(theFusebox,"mode")> |
|---|
| 128 | <cfswitch expression="#theFusebox.mode#"> |
|---|
| 129 | <cfcase value="development"> |
|---|
| 130 | <cfset this.parameters.load = true /> |
|---|
| 131 | <cfset this.parameters.parse = true /> |
|---|
| 132 | <cfset this.parameters.execute = true /> |
|---|
| 133 | </cfcase> |
|---|
| 134 | <!--- FB5: new option - loading is slower so it's worth not loading everything ---> |
|---|
| 135 | <cfcase value="development-no-load"> |
|---|
| 136 | <cfset this.parameters.load = false /> |
|---|
| 137 | <cfset this.parameters.parse = true /> |
|---|
| 138 | <cfset this.parameters.execute = true /> |
|---|
| 139 | </cfcase> |
|---|
| 140 | <!--- FB5: new option - loading is slower so it's worth having a parse-only mode ---> |
|---|
| 141 | <cfcase value="development-parse-only"> |
|---|
| 142 | <cfset this.parameters.load = false /> |
|---|
| 143 | <cfset this.parameters.parse = true /> |
|---|
| 144 | <cfset this.parameters.execute = true /> |
|---|
| 145 | </cfcase> |
|---|
| 146 | <cfcase value="production"> |
|---|
| 147 | <cfset this.parameters.load = false /> |
|---|
| 148 | <cfset this.parameters.parse = false /> |
|---|
| 149 | <cfset this.parameters.execute = true /> |
|---|
| 150 | </cfcase> |
|---|
| 151 | </cfswitch> |
|---|
| 152 | </cfif> |
|---|
| 153 | |
|---|
| 154 | <!--- did the user pass in any special "fuseboxDOT" parameters for this request? ---> |
|---|
| 155 | <!--- If so, process them ---> |
|---|
| 156 | <!--- note: only if attributes.fusebox.password matches the application password ---> |
|---|
| 157 | <cfif structKeyExists(theFusebox,"password") and structKeyExists(variables.attributes,'fusebox.password') and |
|---|
| 158 | theFusebox.password is variables.attributes['fusebox.password']> |
|---|
| 159 | <!--- FB5: does a load and wipes the parsed files out ---> |
|---|
| 160 | <cfif structKeyExists(variables.attributes,'fusebox.loadclean') and isBoolean(variables.attributes['fusebox.loadclean'])> |
|---|
| 161 | <cfset this.parameters.load = variables.attributes['fusebox.loadclean'] /> |
|---|
| 162 | <cfset this.parameters.clean = variables.attributes['fusebox.loadclean'] /> |
|---|
| 163 | <cfset this.parameters.userProvidedLoadParameter = true /> |
|---|
| 164 | <cfset this.parameters.userProvidedCleanParameter = true /> |
|---|
| 165 | </cfif> |
|---|
| 166 | <cfif structKeyExists(variables.attributes,'fusebox.load') and isBoolean(variables.attributes['fusebox.load'])> |
|---|
| 167 | <cfset this.parameters.load = variables.attributes['fusebox.load'] /> |
|---|
| 168 | <cfset this.parameters.userProvidedLoadParameter = true /> |
|---|
| 169 | </cfif> |
|---|
| 170 | <cfif structKeyExists(variables.attributes,'fusebox.parseall') and isBoolean(variables.attributes['fusebox.parseall'])> |
|---|
| 171 | <cfset this.parameters.parse = variables.attributes['fusebox.parseall'] /> |
|---|
| 172 | <cfset this.parameters.parseall = variables.attributes['fusebox.parseall'] /> |
|---|
| 173 | <cfif this.parameters.parseall> |
|---|
| 174 | <cfset this.parameters.load = true /> |
|---|
| 175 | </cfif> |
|---|
| 176 | <cfset this.parameters.userProvidedParseParameter = true /> |
|---|
| 177 | <cfset this.parameters.userProvidedParseAllParameter = true /> |
|---|
| 178 | </cfif> |
|---|
| 179 | <cfif structKeyExists(variables.attributes,'fusebox.parse') and isBoolean(variables.attributes['fusebox.parse'])> |
|---|
| 180 | <cfset this.parameters.parse = variables.attributes['fusebox.parse'] /> |
|---|
| 181 | <cfset this.parameters.userProvidedParseParameter = true /> |
|---|
| 182 | </cfif> |
|---|
| 183 | <cfif structKeyExists(variables.attributes,'fusebox.execute') and isBoolean(variables.attributes['fusebox.execute'])> |
|---|
| 184 | <cfset this.parameters.execute = variables.attributes['fusebox.execute'] /> |
|---|
| 185 | <cfset this.parameters.userProvidedExecuteParameter = true /> |
|---|
| 186 | </cfif> |
|---|
| 187 | </cfif> |
|---|
| 188 | |
|---|
| 189 | <!--- |
|---|
| 190 | force a load if the runtime and core versions differ: this allows a new |
|---|
| 191 | version to be dropped in and the framework will automatically reload! |
|---|
| 192 | ---> |
|---|
| 193 | <cfif structKeyExists(theFusebox,"getVersion") and |
|---|
| 194 | isCustomFunction(theFusebox.getVersion)> |
|---|
| 195 | <cfif this.version.runtime is not theFusebox.getVersion()> |
|---|
| 196 | <cfset this.parameters.load = true /> |
|---|
| 197 | </cfif> |
|---|
| 198 | <cfelse> |
|---|
| 199 | <!--- hmm, doesn't look like the core is present (or it's not FB5 Alpha 2 or higher) ---> |
|---|
| 200 | <cfset this.parameters.load = true /> |
|---|
| 201 | </cfif> |
|---|
| 202 | |
|---|
| 203 | <!--- if the fusebox doesn't already exist we definitely want to reload ---> |
|---|
| 204 | <cfif structKeyExists(theFusebox,"isFullyLoaded") and |
|---|
| 205 | theFusebox.isFullyLoaded> |
|---|
| 206 | <!--- if fully loaded, leave the load parameter alone ---> |
|---|
| 207 | <cfelse> |
|---|
| 208 | <cfset this.parameters.load = true /> |
|---|
| 209 | </cfif> |
|---|
| 210 | |
|---|
| 211 | <cfreturn this /> |
|---|
| 212 | </cffunction> |
|---|
| 213 | |
|---|
| 214 | <cffunction name="getApplication" returntype="fuseboxApplication" access="public" output="false"> |
|---|
| 215 | |
|---|
| 216 | <!--- |
|---|
| 217 | this is a bit of a hack since we're accessing application scope directly |
|---|
| 218 | but it's probably cleaner than exposing a method to allow fuseboxApplication |
|---|
| 219 | to inject itself back into myFusebox during compileRequest()... |
|---|
| 220 | ---> |
|---|
| 221 | <cfreturn application[variables.appKey] /> |
|---|
| 222 | |
|---|
| 223 | </cffunction> |
|---|
| 224 | |
|---|
| 225 | <cffunction name="getCurrentCircuit" returntype="fuseboxBaseCircuit" access="public" output="false"> |
|---|
| 226 | |
|---|
| 227 | <cfreturn getApplication().circuits[this.thisCurrent] /> |
|---|
| 228 | |
|---|
| 229 | </cffunction> |
|---|
| 230 | |
|---|
| 231 | <cffunction name="getCurrentFuseaction" returntype="fuseboxBaseAction" access="public" output="false"> |
|---|
| 232 | |
|---|
| 233 | <cfreturn getCurrentCircuit().fuseactions[this.thisFuseaction] /> |
|---|
| 234 | |
|---|
| 235 | </cffunction> |
|---|
| 236 | |
|---|
| 237 | <cffunction name="overrideAttributes" returntype="void" access="public" output="false"> |
|---|
| 238 | <cfargument name="scope" type="struct" required="true" /> |
|---|
| 239 | |
|---|
| 240 | <cfset structAppend(variables.attributes,arguments.scope,true) /> |
|---|
| 241 | |
|---|
| 242 | </cffunction> |
|---|
| 243 | |
|---|
| 244 | </cfcomponent> |
|---|