diff --git a/build/build-ortushq.properties b/build/build-ortushq.properties index c091f7b04..507cd0967 100644 --- a/build/build-ortushq.properties +++ b/build/build-ortushq.properties @@ -9,8 +9,8 @@ artifact.dir=${artifact.baseDir}${distro.groupID}/${distro.name} dist.dir=${artifact.dir}/${commandbox.version} #debian+rpm repos -rpm.repo=${artifact.baseDir}/RPMS/noarch -deb.repo=${artifact.baseDir}/debs/noarch +rpm.repo=${artifact.baseDir}/RPMS-be/noarch +deb.repo=${artifact.baseDir}/debs-be/noarch rpm.repo.stable=${artifact.baseDir}/RPMS-stable/noarch deb.repo.stable=${artifact.baseDir}/debs-stable/noarch #mvn.type=snapshot# \ No newline at end of file diff --git a/build/build.properties b/build/build.properties index c4d16972f..88c8206dd 100644 --- a/build/build.properties +++ b/build/build.properties @@ -10,16 +10,16 @@ java.debug=true #dependencies dependencies.dir=${basedir}/lib -cfml.version=5.2.7.63 -cfml.loader.version=2.1.11 +cfml.version=5.2.8.50 +cfml.loader.version=2.1.14 cfml.cli.version=${cfml.loader.version}.${cfml.version} lucee.version=${cfml.version} lucee.config.version=5.2.4.37 jre.version=1.8.0_162 -launch4j.version=3.11 +launch4j.version=3.12 runwar.version=3.8.1-SNAPSHOT -jline.version=3.7.0 -jgit.version=4.11.0.201803080745-r +jline.version=3.8.2 +jgit.version=5.0.1.201806211838-r #build locations build.type=localdev @@ -43,7 +43,7 @@ deb.repo.stable=${dist.dir}/debs-stable/noarch #mvn.type=snapshot #remote repos -ortus.repoURL=http://integration.stg.ortussolutions.com/artifacts +ortus.repoURL=https://downloads.ortussolutions.com ortus.repoPRDURL=https://downloads.ortussolutions.com #apidocs properties diff --git a/build/build.xml b/build/build.xml index 8dabca850..5eaac423e 100644 --- a/build/build.xml +++ b/build/build.xml @@ -16,8 +16,8 @@ External Dependencies: - - + + @@ -51,11 +51,13 @@ External Dependencies: - + + + @@ -111,13 +113,13 @@ External Dependencies: - - - - - - - + + + + + + + @@ -146,8 +148,9 @@ External Dependencies: - + @@ -235,6 +238,7 @@ External Dependencies: + @@ -285,9 +289,139 @@ External Dependencies: - + This is a stable build, let's compress these jars! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -776,9 +910,10 @@ External Dependencies: + + - @@ -799,6 +934,8 @@ External Dependencies: + + @@ -942,8 +1079,8 @@ External Dependencies: - - + + diff --git a/src/cfml/system/BaseCommand.cfc b/src/cfml/system/BaseCommand.cfc index 49f290001..306e15625 100644 --- a/src/cfml/system/BaseCommand.cfc +++ b/src/cfml/system/BaseCommand.cfc @@ -10,7 +10,6 @@ */ component accessors="true" singleton { - // DI property name="CR"; property name="formatterUtil"; property name="fileSystemUtil"; @@ -21,6 +20,7 @@ component accessors="true" singleton { property name="parser"; property name="SystemSettings"; property name="job"; + property name="exitCode"; /** * Constructor @@ -38,7 +38,7 @@ component accessors="true" singleton { variables.SystemSettings = wirebox.getInstance( "SystemSettings" ); variables.job = wirebox.getInstance( "interactiveJob" ); - hasErrored = false; + variables.exitCode = 0; return this; } @@ -52,10 +52,18 @@ component accessors="true" singleton { return wirebox.getInstance( argumentCollection = arguments ); } + function getExitCode() { + return variables.exitCode; + } + + function setExitCode( exitCode ) { + variables.exitCode = arguments.exitCode; + } + // Called prior to each execution to reset any state stored in the CFC function reset() { print.clear(); - hasErrored = false; + variables.exitCode = 0; } // Get the result. This will be called if the run() method doesn't return anything @@ -173,8 +181,7 @@ component accessors="true" singleton { print.line().toConsole(); } - setExitCode( exitCode ); - hasErrored = true; + setExitCode( arguments.exitCode ); if( arguments.clearPrintBuffer ) { // Wipe print.clear(); @@ -190,17 +197,7 @@ component accessors="true" singleton { * Tells you if the error() method has been called on this command. **/ function hasError() { - return hasErrored; - } - - /** - * Sets the OS exit code - **/ - function setExitCode( required string exitCode ) { - if( arguments.exitCode != 0 ) { - hasErrored = true; - } - return shell.setExitCode( arguments.exitCode ); + return variables.exitCode != 0; } /** diff --git a/src/cfml/system/Bootstrap.cfm b/src/cfml/system/Bootstrap.cfm index 2250c6bca..ea23669bb 100644 --- a/src/cfml/system/Bootstrap.cfm +++ b/src/cfml/system/Bootstrap.cfm @@ -11,6 +11,7 @@ I am a CFM because the CLI seems to need a .cfm file to call This file will stay running the entire time the shell is open ---> + @@ -127,21 +128,6 @@ This file will stay running the entire time the shell is open silent = bufferedReader.ready(); inStream = system.in; - // If we're piping in data, let's grab it and treat it as commands. - // system.in should work directly, but Windows was blocking forever and not reading the InputStream - // So we'll create our own input stream with a line break at the end - if( silent ) { - piped = []; - // If data is piped to CommandBox, it will be in this buffered reader - while ( bufferedReader.ready() ) { - // Read all the lines and append them together. - piped.append( bufferedReader.readLine() ); - } - // Build a string with a line for each line read from the standard input. - piped = piped.toList( chr( 10 ) ) & chr( 10 ); - inStream = createObject("java","java.io.ByteArrayInputStream").init(piped.getBytes()); - } - // Create the shell shell = application.wirebox.getInstance( name='Shell', initArguments={ asyncLoad=!silent, inStream=inStream, outputStream=system.out } ); diff --git a/src/cfml/system/Quotes.txt b/src/cfml/system/Quotes.txt index 25fd93b34..eb369aeff 100644 --- a/src/cfml/system/Quotes.txt +++ b/src/cfml/system/Quotes.txt @@ -139,4 +139,7 @@ Skip "Are you sure?" prompts in most commands with the "--force" flag Premature cleverness is the root of all evil You can create ad-hoc aliases for common commands or sets of commands A unicorn smiles each time someone downloads commandbox-bullet-train -CommandBox makes you feel like a wizard. \ No newline at end of file +CommandBox makes you feel like a wizard. +In the unlikely event of a water landing, CLI can be used as a flotation device +Let me see those Jazz Hands! +Have brainstorms so big they leave your hair windswept \ No newline at end of file diff --git a/src/cfml/system/Shell.cfc b/src/cfml/system/Shell.cfc index 6038d638c..aa2fd2e03 100644 --- a/src/cfml/system/Shell.cfc +++ b/src/cfml/system/Shell.cfc @@ -25,7 +25,8 @@ component accessors="true" singleton { property name="Util" inject="wirebox.system.core.util.Util"; property name="CommandHighlighter" inject="CommandHighlighter"; property name="REPLHighlighter" inject="REPLHighlighter"; - + property name="configService" inject="configService"; + property name='systemSettings' inject='SystemSettings'; /** * The java jline reader class. @@ -172,6 +173,8 @@ component accessors="true" singleton { **/ Shell function setExitCode( required string exitCode ) { createObject( 'java', 'java.lang.System' ).setProperty( 'cfml.cli.exitCode', arguments.exitCode ); + // Keep a more readable version in sync for people to acces via the shell + createObject( 'java', 'java.lang.System' ).setProperty( 'exitCode', exitCode ); return this; } @@ -488,43 +491,32 @@ component accessors="true" singleton { /** * Runs the shell thread until exit flag is set - * @input.hint command line to run if running externally + * @silent Supress prompt **/ - Boolean function run( input="", silent=false ) { - + Boolean function run( silent=false ) { // init reload to false, just in case variables.reloadshell = false; try{ - // Get input stream - if( arguments.input != "" ){ - arguments.input &= chr(10); - var inStream = createObject( "java", "java.io.ByteArrayInputStream" ).init( arguments.input.getBytes() ); - variables.reader.setInput( inStream ); - } // setup bell enabled + keep running flags // variables.reader.setBellEnabled( true ); variables.keepRunning = true; var line =""; - if( !arguments.silent ) { - // Set default prompt on reader - setPrompt(); - } // while keep running while( variables.keepRunning ){ - // check if running externally - if( arguments.input != "" ){ - variables.keepRunning = false; - } try { var interceptData = { prompt : variables.shellPrompt }; getInterceptorService().announceInterception( 'prePrompt', interceptData ); + if( arguments.silent ) { + interceptData.prompt = ''; + } + // Shell stops on this line while waiting for user input if( arguments.silent ) { line = variables.reader.readLine( interceptData.prompt, javacast( "char", ' ' ) ); @@ -540,8 +532,13 @@ component accessors="true" singleton { // User hits Ctrl-D. Murder the shell dead. } catch( org.jline.reader.EndOfFileException var e ) { - variables.reader.getTerminal().writer().print( variables.print.boldGreenLine( 'Goodbye!' ) ); - variables.reader.getTerminal().writer().flush(); + + // Only output this if a user presses Ctrl-D, EOF can also happen if piping an actual file of input into the shell. + if( !arguments.silent ) { + variables.reader.getTerminal().writer().print( variables.print.boldGreenLine( 'Goodbye!' ) ); + variables.reader.getTerminal().writer().flush(); + } + variables.keepRunning = false; continue; } @@ -840,6 +837,24 @@ component accessors="true" singleton { return ''; } + + + /** + * Is the current terminal interactive? + * @returns boolean + **/ + function isTerminalInteractive() { + // Check for config setting called "nonInteractiveShell" + if( configService.settingExists( 'nonInteractiveShell' ) && isBoolean( configService.getSetting( "nonInteractiveShell" ) ) ) { + return !configService.getSetting( "nonInteractiveShell" ); + // Next check for an Environment Variable called "CI" that is set + } else if( systemSettings.getSystemSetting( 'CI', '__NOT_SET__' ) != '__NOT_SET__' ) { + return false; + // Default to true + } else { + return true; + } + } /** * print an error to the console diff --git a/src/cfml/system/config/server-icons/folder.png b/src/cfml/system/config/server-icons/folder.png new file mode 100644 index 000000000..9d767da23 Binary files /dev/null and b/src/cfml/system/config/server-icons/folder.png differ diff --git a/src/cfml/system/config/server-icons/open.png b/src/cfml/system/config/server-icons/open.png new file mode 100644 index 000000000..a767821a3 Binary files /dev/null and b/src/cfml/system/config/server-icons/open.png differ diff --git a/src/cfml/system/config/urlrewrite.xml b/src/cfml/system/config/urlrewrite.xml index 0b1bd1855..d773fcc9d 100644 --- a/src/cfml/system/config/urlrewrite.xml +++ b/src/cfml/system/config/urlrewrite.xml @@ -5,8 +5,10 @@ Generic Front-Controller URLs ^/(flex2gateway|flashservices/gateway|messagebroker|lucee|rest|cfide|CFIDE|cfformgateway|jrunscripts|cf_scripts)/.* - + ^/tuckey-status + + ^/pms$ ^/favicon.ico - - - - - - - - instance = { - cacheProvider = arguments.cacheProvider - }; - return this; - - - - - - - - - - - - var targetMixer = structnew(); - var key = ""; - + /** + * Build a unique hash from an incoming request context + * + * @event A request context object + */ + string function getUniqueHash( required event ){ + var incomingHash = hash( + arguments.event.getCollection().filter( function( key, value ){ + // Remove event, not needed for hashing purposes + return ( key != "event" ); + } ).toString() + ); + var targetMixer = { // Get the original incoming context hash - targetMixer['incomingHash'] = arguments.event.getValue(name="cbox_incomingContextHash",private=true); - + "incomingHash" = incomingHash, // Multi-Host support - targetMixer['cgihost'] = cgi.http_host; - - // Incorporate Routed Structs - structAppend(targetMixer, arguments.event.getRoutedStruct(),true); - - // Return unique identifier - return hash(targetMixer.toString()); - - - - - - - - - - var myStruct = structnew(); - var x =1; - + "cgihost" = cgi.http_host + }; + + // Incorporate Routed Structs + structAppend( targetMixer, arguments.event.getRoutedStruct(), true ); + + // Return unique identifier + return hash( targetMixer.toString() ); + } + + /** + * Build a unique hash according to an incoming query string, mostly used when calling the clear functions of + * cache providers + * + * @args A querystring based argument collection + */ + function buildHash( required string args ){ + var virtualRC = {}; + arguments.args + .listToArray( "&" ) + .each( function( item ){ + virtualRC[ item.getToken( 1, "=" ).trim() ] = urlDecode( item.getToken( 2, "=" ).trim() ); + } ); + + //writeDump( var = "==> Hash Args Struct: #virtualRC.toString()#", output="console" ); + var myStruct = { + // Get the original incoming context hash according to incoming arguments + "incomingHash" = hash( virtualRC.toString() ), // Multi-Host support - myStruct['cgihost'] = cgi.http_host; - - //Build structure from arg list - for(x=1;x lte listlen(arguments.args,"&"); x=x+1){ - myStruct[trim(listFirst(listGetAt(arguments.args, x, "&"),'='))] = urlDecode(trim(listLast(listGetAt(arguments.args, x, "&"),'='))); - } - - //return hash - return hash(myStruct.toString()); - - - - - - - - - - - - var key = ""; - - key = buildBasicCacheKey(argumentCollection=arguments) & getUniqueHash(arguments.targetContext); - - return key; - - - - - - - - - - - - var key = ""; - - key = buildBasicCacheKey(argumentCollection=arguments) & buildHash(arguments.targetArgs); - - return key; - - - - - - - - - - - var key = ""; - - key = instance.cacheProvider.getEventCacheKeyPrefix() & arguments.targetEvent & "-" & arguments.keySuffix & "-"; - - return key; - - + "cgihost" = cgi.http_host + }; + + // return hash from cache key struct + return hash( myStruct.toString() ); + } + + /** + * Build an event key according to passed in params + * + * @keySuffix The key suffix used in the cache key + * @targetEvent The targeted ColdBox event executed + * @targetContext The targeted request context object + */ + string function buildEventKey( required keySuffix, required targetEvent, required targetContext ){ + return buildBasicCacheKey( argumentCollection=arguments ) & getUniqueHash( arguments.targetContext ); + } + + /** + * Build an event key according to passed in params + * + * @keySuffix The key suffix used in the cache key + * @targetEvent The targeted ColdBox event executed + * @targetArgs A query string based argument collection like a query string + */ + string function buildEventKeyNoContext( required keySuffix, required targetEvent, required targetArgs ){ + return buildBasicCacheKey( argumentCollection=arguments ) & buildHash( arguments.targetArgs ); + } + + /** + * Builds a basic cache key without the hash component + * @keySuffix The key suffix used + * @targetEvent The targetged ColdBox event string + */ + string function buildBasicCacheKey( required keySuffix, required targetEvent ){ + return variables.cacheProvider.getEventCacheKeyPrefix() & arguments.targetEvent & "-" & arguments.keySuffix & "-"; + } - - \ No newline at end of file +} \ No newline at end of file diff --git a/src/cfml/system/wirebox/system/core/dynamic/BeanPopulator.cfc b/src/cfml/system/wirebox/system/core/dynamic/BeanPopulator.cfc index 22816aee2..d35d7c9b8 100644 --- a/src/cfml/system/wirebox/system/core/dynamic/BeanPopulator.cfc +++ b/src/cfml/system/wirebox/system/core/dynamic/BeanPopulator.cfc @@ -1,462 +1,511 @@ - - - - - - - - - mixerUtil = createObject("component","wirebox.system.core.dynamic.MixerUtil").init(); - - return this; - - - - - - - - - - - - - - - - - - - - - // Inflate JSON - arguments.memento = deserializeJSON( arguments.JSONString ); - - // populate and return - return populateFromStruct(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - var key = ""; - var childElements = ""; - var x = 1; - - // determine XML - if( isSimpleValue(arguments.xml) ){ - arguments.xml = xmlParse( arguments.xml ); +/** + * Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp + * www.ortussolutions.com + * --- + * This is a bean populator that binds different types of data to a bean. + */ +component{ + + /** + * Constructor + */ + function init(){ + variables.mixerUtil = new wirebox.system.core.dynamic.MixerUtil(); + variables.util = new wirebox.system.core.util.Util(); + return this; + } + + /** + * Populate a named or instantiated instance from a Json string + * + * @target The target to populate + * @JSONString The JSON string to populate the object with. It has to be valid JSON and also a structure with name-key value pairs. + * @scope Use scope injection instead of setters population. Ex: scope=variables.instance. + * @trustedSetter If set to true, the setter method will be called even if it does not exist in the bean + * @include A list of keys to include in the population + * @exclude A list of keys to exclude in the population + * @ignoreEmpty Ignore empty values on populations, great for ORM population + * @nullEmptyInclude A list of keys to NULL when empty + * @nullEmptyExclude A list of keys to NOT NULL when empty + * @composeRelationships Automatically attempt to compose relationships from memento + * + * @return The target populated with the packet + */ + function populateFromJson( + required target, + required string JSONString, + string scope="", + boolean trustedSetter=false, + string include="", + string exclude="", + boolean ignoreEmpty=false, + string nullEmptyInclude="", + string nullEmptyExclude="", + boolean composeRelationships=false + ){ + // Inflate JSON + arguments.memento = deserializeJSON( arguments.JSONString ); + + // populate and return + return populateFromStruct( argumentCollection=arguments ); + } + + /** + * Populate a named or instantiated instance from an XML Packet + * + * @target The target to populate + * @xml The XML string or packet to populate the target with + * @root The XML root element to start from, else defaults to XMLRoot + * @scope Use scope injection instead of setters population. Ex: scope=variables.instance. + * @trustedSetter If set to true, the setter method will be called even if it does not exist in the bean + * @include A list of keys to include in the population + * @exclude A list of keys to exclude in the population + * @ignoreEmpty Ignore empty values on populations, great for ORM population + * @nullEmptyInclude A list of keys to NULL when empty + * @nullEmptyExclude A list of keys to NOT NULL when empty + * @composeRelationships Automatically attempt to compose relationships from memento + * + * @return The target populated with the packet + */ + function populateFromXML( + required target, + required xml, + string root="", + string scope="", + boolean trustedSetter=false, + string include="", + string exclude="", + boolean ignoreEmpty=false, + string nullEmptyInclude="", + string nullEmptyExclude="", + boolean composeRelationships=false + ){ + // determine XML object or string? + if( isSimpleValue( arguments.xml ) ){ + arguments.xml = xmlParse( arguments.xml ); + } + + // check root else default to XMLRoot + if( NOT len( arguments.root ) ){ + arguments.root = "XMLRoot"; + } + + // check children else don't do anything, we can't populate + if( NOT structKeyExists( arguments.xml[ arguments.root ], "XMLChildren" ) ){ + return; + } + + arguments.memento = {}; + // Have to do it this way as ACF11 parsing sucks on structs and member functions + var xmlRoot = arguments.xml[ arguments.root ]; + // Populate memento from XML + xmlRoot + .XMLChildren + .each( function( item ){ + memento[ item.XMLName ] = trim( item.XMLText ); + } ); + + return populateFromStruct( argumentCollection=arguments ); + } + + /** + * Populate a named or instantiated instance from a Query object + * + * @target The target to populate + * @qry The query to populate the object with + * @rowNumber The row number to use for population, defaults to 1 + * @scope Use scope injection instead of setters population. Ex: scope=variables.instance. + * @trustedSetter If set to true, the setter method will be called even if it does not exist in the bean + * @include A list of keys to include in the population + * @exclude A list of keys to exclude in the population + * @ignoreEmpty Ignore empty values on populations, great for ORM population + * @nullEmptyInclude A list of keys to NULL when empty + * @nullEmptyExclude A list of keys to NOT NULL when empty + * @composeRelationships Automatically attempt to compose relationships from memento + * + * @return The target populated with the packet + */ + function populateFromQuery( + required target, + required query qry, + numeric rowNumber="1", + string scope="", + boolean trustedSetter=false, + string include="", + string exclude="", + boolean ignoreEmpty=false, + string nullEmptyInclude="", + string nullEmptyExclude="", + boolean composeRelationships=false + ){ + arguments.memento = structnew(); + listToArray( arguments.qry.columnList ) + .each( function( item ){ + memento[ item ] = qry[ item ][ rowNumber ]; + } ); + + //populate bean and return + return populateFromStruct( argumentCollection=arguments ); + } + + /** + * Populate a named or instantiated instance from a Query object using a column prefix + * + * @target The target to populate + * @qry The query to populate the object with + * @prefix The prefix used to filter, Example: 'user_' would apply to the following columns: 'user_id' and 'user_name' but not 'address_id'. + * @rowNumber The row number to use for population, defaults to 1 + * @scope Use scope injection instead of setters population. Ex: scope=variables.instance. + * @trustedSetter If set to true, the setter method will be called even if it does not exist in the bean + * @include A list of keys to include in the population + * @exclude A list of keys to exclude in the population + * @ignoreEmpty Ignore empty values on populations, great for ORM population + * @nullEmptyInclude A list of keys to NULL when empty + * @nullEmptyExclude A list of keys to NOT NULL when empty + * @composeRelationships Automatically attempt to compose relationships from memento + * + * @return The target populated with the packet + */ + function populateFromQueryWithPrefix( + required target, + required query qry, + required string prefix, + numeric rowNumber="1", + string scope="", + boolean trustedSetter=false, + string include="", + string exclude="", + boolean ignoreEmpty=false, + string nullEmptyInclude="", + string nullEmptyExclude="", + boolean composeRelationships=false + ){ + var prefixLength = len( arguments.prefix ); + + arguments.memento = structnew(); + listToArray( arguments.qry.columnList ) + .filter( function( item ){ + return ( left( item, prefixLength ) == prefix ); + } ) + .each( function( item ){ + var trueColumnName = item.replaceNocase( prefix, "" ); + memento[ trueColumnName ] = qry[ item ][ rowNumber ]; + } ); + + //populate bean and return + return populateFromStruct( argumentCollection=arguments ); + } + + /** + * Populate a named or instantiated instance from a struct object using a key prefix + * + * @target The target to populate + * @memento The structure to populate the target with + * @prefix The prefix used to filter, Example: 'user_' would apply to the following columns: 'user_id' and 'user_name' but not 'address_id'. + * @scope Use scope injection instead of setters population. Ex: scope=variables.instance. + * @trustedSetter If set to true, the setter method will be called even if it does not exist in the bean + * @include A list of keys to include in the population + * @exclude A list of keys to exclude in the population + * @ignoreEmpty Ignore empty values on populations, great for ORM population + * @nullEmptyInclude A list of keys to NULL when empty + * @nullEmptyExclude A list of keys to NOT NULL when empty + * @composeRelationships Automatically attempt to compose relationships from memento + * + * @return The target populated with the packet + */ + function populateFromStructWithPrefix( + required target, + required struct memento, + required string prefix, + string scope="", + boolean trustedSetter=false, + string include="", + string exclude="", + boolean ignoreEmpty=false, + string nullEmptyInclude="", + string nullEmptyExclude="", + boolean composeRelationships=false + ){ + var prefixLength = len( arguments.prefix ); + var newMemento = {}; + + arguments.memento + .filter( function( key, value ){ + return( left( key, prefixLength ) == prefix ); + } ) + .each( function( key, value ){ + newMemento[ key.replaceNoCase( prefix, "" ) ] = value; + } ); + + //populate bean and return + arguments.memento = newMemento; + return populateFromStruct( argumentCollection=arguments ); + } + + /** + * Populate a named or instantiated instance from a struct object using a key prefix + * + * @target The target to populate + * @memento The structure to populate the target with + * @scope Use scope injection instead of setters population. Ex: scope=variables.instance. + * @trustedSetter If set to true, the setter method will be called even if it does not exist in the bean + * @include A list of keys to include in the population + * @exclude A list of keys to exclude in the population + * @ignoreEmpty Ignore empty values on populations, great for ORM population + * @nullEmptyInclude A list of keys to NULL when empty + * @nullEmptyExclude A list of keys to NOT NULL when empty + * @composeRelationships Automatically attempt to compose relationships from memento + * + * @return The target populated with the packet + */ + function populateFromStruct( + required target, + required struct memento, + string scope="", + boolean trustedSetter=false, + string include="", + string exclude="", + boolean ignoreEmpty=false, + string nullEmptyInclude="", + string nullEmptyExclude="", + boolean composeRelationships=false + ){ + var beanInstance = arguments.target; + var key = ""; + var pop = true; + var scopeInjection = false; + var udfCall = ""; + var args = ""; + var nullValue = false; + var propertyValue = ""; + var relationalMeta = ""; + + try{ + + // Determine Method of population + if( structKeyExists(arguments,"scope") and len(trim(arguments.scope)) neq 0 ){ + scopeInjection = true; + mixerUtil.start( beanInstance ); } - // check root - if( NOT len(arguments.root) ){ - arguments.root = "XMLRoot"; + // If composing relationships, get target metadata + if( arguments.composeRelationships ) { + relationalMeta = getRelationshipMetaData( arguments.target ); } - // check children - if( NOT structKeyExists(arguments.xml[arguments.root],"XMLChildren") ){ - return; - } - - // prepare memento - arguments.memento = structnew(); - - // iterate and build struct of data - childElements = arguments.xml[arguments.root].XMLChildren; - for(x=1; x lte arrayLen(childElements); x=x+1){ - arguments.memento[ childElements[x].XMLName ] = trim(childElements[x].XMLText); - } - - return populateFromStruct(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - //by default to take values from first row of the query - var row = arguments.RowNumber; - //columns array - var cols = listToArray(arguments.qry.columnList); - var i = 1; - - arguments.memento = structnew(); - - //build the struct from the query row - for(i = 1; i lte arraylen(cols); i = i + 1){ - arguments.memento[cols[i]] = arguments.qry[cols[i]][row]; - } - - //populate bean and return - return populateFromStruct(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - // Create a struct including only those keys that match the prefix. - //by default to take values from first row of the query - var row = arguments.rowNumber; - var cols = listToArray(arguments.qry.columnList); - var i = 1; - var n = arrayLen(cols); - var prefixLength = len(arguments.prefix); - var trueColumnName = ""; - - arguments.memento = structNew(); - - //build the struct from the query row - for(i = 1; i LTE n; i = i + 1){ - if ( left(cols[i], prefixLength) EQ arguments.prefix ) { - trueColumnName = right(cols[i], len(cols[i]) - prefixLength); - arguments.memento[trueColumnName] = arguments.qry[cols[i]][row]; + // Populate Bean + for(key in arguments.memento){ + // init population flag + pop = true; + // init nullValue flag and shortcut to property value + // conditional with StructKeyExist, to prevent language issues with Null value checking of struct keys in ACF + if ( structKeyExists( arguments.memento, key) ){ + nullValue = false; + propertyValue = arguments.memento[ key ]; + + } else { + nullValue = true; + propertyValue = JavaCast( "null", "" ); } - } - //populate bean and return - return populateFromStruct(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - var key = ""; - var newMemento = structNew(); - var prefixLength = len( arguments.prefix ); - var trueName = ""; - - //build the struct from the query row - for( key in arguments.memento ){ - // only add prefixed keys - if ( left( key, prefixLength ) EQ arguments.prefix ) { - trueName = right( key, len( key ) - prefixLength ); - newMemento[ trueName ] = arguments.memento[ key ]; + // Include List? + if( len(arguments.include) AND NOT listFindNoCase(arguments.include,key) ){ + pop = false; } - } - - // override memento - arguments.memento = newMemento; - - //populate bean and return - return populateFromStruct( argumentCollection=arguments ); - - - - - - - - - - - - - - - - - - - var beanInstance = arguments.target; - var key = ""; - var pop = true; - var scopeInjection = false; - var udfCall = ""; - var args = ""; - var nullValue = false; - var propertyValue = ""; - var relationalMeta = ""; - - try{ - - // Determine Method of population - if( structKeyExists(arguments,"scope") and len(trim(arguments.scope)) neq 0 ){ - scopeInjection = true; - mixerUtil.start( beanInstance ); + // Exclude List? + if( len(arguments.exclude) AND listFindNoCase(arguments.exclude,key) ){ + pop = false; } - - // If composing relationships, get target metadata - if( arguments.composeRelationships ) { - relationalMeta = getRelationshipMetaData( arguments.target ); + // Ignore Empty? Check added for real Null value + if( arguments.ignoreEmpty and not IsNull(propertyValue) and isSimpleValue(arguments.memento[key]) and not len( trim( arguments.memento[key] ) ) ){ + pop = false; } - // Populate Bean - for(key in arguments.memento){ - // init population flag - pop = true; - // init nullValue flag and shortcut to property value - // conditional with StructKeyExist, to prevent language issues with Null value checking of struct keys in ACF - if ( structKeyExists( arguments.memento, key) ){ - nullValue = false; - propertyValue = arguments.memento[ key ]; - - } else { - nullValue = true; - propertyValue = JavaCast( "null", "" ); - } - - // Include List? - if( len(arguments.include) AND NOT listFindNoCase(arguments.include,key) ){ - pop = false; + // Pop? + if( pop ){ + // Scope Injection? + if( scopeInjection ){ + beanInstance.populatePropertyMixin(propertyName=key,propertyValue=propertyValue,scope=arguments.scope); } - // Exclude List? - if( len(arguments.exclude) AND listFindNoCase(arguments.exclude,key) ){ - pop = false; - } - // Ignore Empty? Check added for real Null value - if( arguments.ignoreEmpty and not IsNull(propertyValue) and isSimpleValue(arguments.memento[key]) and not len( trim( arguments.memento[key] ) ) ){ - pop = false; - } - - // Pop? - if( pop ){ - // Scope Injection? - if( scopeInjection ){ - beanInstance.populatePropertyMixin(propertyName=key,propertyValue=propertyValue,scope=arguments.scope); + // Check if setter exists, evaluate is used, so it can call on java/groovy objects + else if( structKeyExists( beanInstance, "set" & key ) or arguments.trustedSetter ){ + // top-level null settings + if( arguments.nullEmptyInclude == "*" ) { + nullValue = true; } - // Check if setter exists, evaluate is used, so it can call on java/groovy objects - else if( structKeyExists( beanInstance, "set" & key ) or arguments.trustedSetter ){ - // top-level null settings - if( arguments.nullEmptyInclude == "*" ) { - nullValue = true; - } - if( arguments.nullEmptyExclude == "*" ) { - nullValue = false; - } - // Is property in empty-to-null include list? - if( ( len( arguments.nullEmptyInclude ) && listFindNoCase( arguments.nullEmptyInclude, key ) ) ) { - nullValue = true; + if( arguments.nullEmptyExclude == "*" ) { + nullValue = false; + } + // Is property in empty-to-null include list? + if( ( len( arguments.nullEmptyInclude ) && listFindNoCase( arguments.nullEmptyInclude, key ) ) ) { + nullValue = true; + } + // Is property in empty-to-null exclude list, or is exclude list "*"? + if( ( len( arguments.nullEmptyExclude ) AND listFindNoCase( arguments.nullEmptyExclude, key ) ) ){ + nullValue = false; + } + // Is value nullable (e.g., simple, empty string)? If so, set null... + // short circuit evealuaton of IsNull added, so it won't break IsSimpleValue with Real null values. Real nulls are already set. + if( !IsNull(propertyValue) && isSimpleValue( propertyValue ) && !len( trim( propertyValue ) ) && nullValue ) { + propertyValue = JavaCast( "null", "" ); + } + + var getEntityMap = function(){ + if( find( "2018", server.coldfusion.productVersion ) ){ + return arrayToList( ORMGetSessionFactory().getMetaModel().getAllEntityNames() ).listToArray(); + } else { + return structKeyArray( ORMGetSessionFactory().getAllClassMetadata() ); } - // Is property in empty-to-null exclude list, or is exclude list "*"? - if( ( len( arguments.nullEmptyExclude ) AND listFindNoCase( arguments.nullEmptyExclude, key ) ) ){ - nullValue = false; + }; + + // If property isn't null, try to compose the relationship + if( !isNull( propertyValue ) && composeRelationships && structKeyExists( relationalMeta, key ) ) { + // get valid, known entity name list + var validEntityNames = getEntityMap(); + var targetEntityName = ""; + /** + * The only info we know about the relationships are the property names and the cfcs + * CFC setting can be relative, so can't assume that component lookup will work + * APPROACH + * 1.) Easy: If property name of relationship is a valid entity name, use that + * 2.) Harder: If property name is not a valid entity name (e.g., one-to-many, many-to-many), use cfc name + * 3.) Nuclear: If neither above works, try by component meta data lookup. Won't work if using relative paths!!!! + */ + + // 1.) name match + if( validEntityNames.findNoCase( key ) ){ + targetEntityName = key; } - // Is value nullable (e.g., simple, empty string)? If so, set null... - // short circuit evealuaton of IsNull added, so it won't break IsSimpleValue with Real null values. Real nulls are already set. - if( !IsNull(propertyValue) && isSimpleValue( propertyValue ) && !len( trim( propertyValue ) ) && nullValue ) { - propertyValue = JavaCast( "null", "" ); + // 2.) attempt match on CFC metadata + else if( validEntityNames.findNoCase( listLast( relationalMeta[ key ].cfc, "." ) ) ) { + targetEntityName = listLast( relationalMeta[ key ].cfc, "." ); } - - var getEntityMap = function(){ - if( find( "2018", server.coldfusion.productVersion ) ){ - return arrayToList( ORMGetSessionFactory().getMetaModel().getAllEntityNames() ).listToArray(); - } else { - return structKeyArray( ORMGetSessionFactory().getAllClassMetadata() ); - } - }; - - // If property isn't null, try to compose the relationship - if( !isNull( propertyValue ) && composeRelationships && structKeyExists( relationalMeta, key ) ) { - // get valid, known entity name list - var validEntityNames = getEntityMap(); - var targetEntityName = ""; - /** - * The only info we know about the relationships are the property names and the cfcs - * CFC setting can be relative, so can't assume that component lookup will work - * APPROACH - * 1.) Easy: If property name of relationship is a valid entity name, use that - * 2.) Harder: If property name is not a valid entity name (e.g., one-to-many, many-to-many), use cfc name - * 3.) Nuclear: If neither above works, try by component meta data lookup. Won't work if using relative paths!!!! - */ - - // 1.) name match - if( validEntityNames.findNoCase( key ) ){ - targetEntityName = key; + // 3.) component lookup + else { + try { + targetEntityName = getComponentMetaData( relationalMeta[ key ].cfc ).entityName; } - // 2.) attempt match on CFC metadata - else if( validEntityNames.findNoCase( listLast( relationalMeta[ key ].cfc, "." ) ) ) { - targetEntityName = listLast( relationalMeta[ key ].cfc, "." ); + catch( any e ) { + throw(type="BeanPopulator.PopulateBeanException", + message="Error populating bean #getMetaData(beanInstance).name# relationship of #key#. The component #relationalMeta[ key ].cfc# could not be found.", + detail="#e.Detail#
#e.message#
#e.tagContext.toString()#"); } - // 3.) component lookup - else { - try { - targetEntityName = getComponentMetaData( relationalMeta[ key ].cfc ).entityName; - } - catch( any e ) { - throw(type="BeanPopulator.PopulateBeanException", - message="Error populating bean #getMetaData(beanInstance).name# relationship of #key#. The component #relationalMeta[ key ].cfc# could not be found.", - detail="#e.Detail#
#e.message#
#e.tagContext.toString()#"); - } - } - // if targetEntityName was successfully found - if( len( targetEntityName) ) { - // array or struct type (one-to-many, many-to-many) - if( listContainsNoCase( "one-to-many,many-to-many", relationalMeta[ key ].fieldtype ) ) { - // Support straight-up lists and convert to array - if( isSimpleValue( propertyValue ) ) { - propertyValue = listToArray( propertyValue ); - } - var relType = structKeyExists( relationalMeta[ key ], "type" ) && relationalMeta[ key ].type != "any" ? relationalMeta[ key ].type : 'array'; - var manyMap = reltype=="struct" ? {} : []; - // loop over array - for( var relValue in propertyValue ) { - // for type of array - if( relType=="array" ) { - // add composed relationship to array - arrayAppend( manyMap, EntityLoadByPK( targetEntityName, relValue ) ); - } - // for type of struct - else { - // make sure structKeyColumn is defined in meta - if( structKeyExists( relationalMeta[ key ], "structKeyColumn" ) ) { - // load the value - var item = EntityLoadByPK( targetEntityName, relValue ); - var structKeyColumn = relationalMeta[ key ].structKeyColumn; - var keyValue = ""; - // try to get struct key value from entity - if( !isNull( item ) ) { - try { - keyValue = invoke( item, "get#structKeyColumn#" ); - } - catch( Any e ) { - throw( - type = "BeanPopulator.PopulateBeanException", - message = "Error populating bean #getMetaData( beanInstance ).name# relationship of #key#. The structKeyColumn #structKeyColumn# could not be resolved.", - detail = "#e.Detail#
#e.message#
#e.tagContext.toString()#"); - } + } + // if targetEntityName was successfully found + if( len( targetEntityName) ) { + // array or struct type (one-to-many, many-to-many) + if( listContainsNoCase( "one-to-many,many-to-many", relationalMeta[ key ].fieldtype ) ) { + // Support straight-up lists and convert to array + if( isSimpleValue( propertyValue ) ) { + propertyValue = listToArray( propertyValue ); + } + var relType = structKeyExists( relationalMeta[ key ], "type" ) && relationalMeta[ key ].type != "any" ? relationalMeta[ key ].type : 'array'; + var manyMap = reltype=="struct" ? {} : []; + // loop over array + for( var relValue in propertyValue ) { + // for type of array + if( relType=="array" ) { + // add composed relationship to array + arrayAppend( manyMap, EntityLoadByPK( targetEntityName, relValue ) ); + } + // for type of struct + else { + // make sure structKeyColumn is defined in meta + if( structKeyExists( relationalMeta[ key ], "structKeyColumn" ) ) { + // load the value + var item = EntityLoadByPK( targetEntityName, relValue ); + var structKeyColumn = relationalMeta[ key ].structKeyColumn; + var keyValue = ""; + // try to get struct key value from entity + if( !isNull( item ) ) { + try { + keyValue = invoke( item, "get#structKeyColumn#" ); } - // if the structKeyColumn value was found... - if( len( keyValue ) ) { - manyMap[ keyValue ] = item; + catch( Any e ) { + throw( + type = "BeanPopulator.PopulateBeanException", + message = "Error populating bean #getMetaData( beanInstance ).name# relationship of #key#. The structKeyColumn #structKeyColumn# could not be resolved.", + detail = "#e.Detail#
#e.message#
#e.tagContext.toString()#"); } } + // if the structKeyColumn value was found... + if( len( keyValue ) ) { + manyMap[ keyValue ] = item; + } } } - // set main property value to the full array of entities - propertyValue = manyMap; } - // otherwise, simple value; load relationship (one-to-one, many-to-one) - else { - if( isSimpleValue( propertyValue ) && trim( propertyValue ) != "" ) { - propertyValue = EntityLoadByPK( targetEntityName, propertyValue ); - } + // set main property value to the full array of entities + propertyValue = manyMap; + } + // otherwise, simple value; load relationship (one-to-one, many-to-one) + else { + if( isSimpleValue( propertyValue ) && trim( propertyValue ) != "" ) { + propertyValue = EntityLoadByPK( targetEntityName, propertyValue ); } - } // if target entity name found - } - // Populate the property as a null value - if( isNull( propertyValue ) ) { - // Finally...set the value - invoke( beanInstance, "set#key#", [ JavaCast( 'null', '' ) ] ); - } - // Populate the property as the value obtained whether simple or related - else { - invoke( beanInstance, "set#key#", [ propertyValue ] ); - } + } + } // if target entity name found + } + // Populate the property as a null value + if( isNull( propertyValue ) ) { + // Finally...set the value + invoke( beanInstance, "set#key#", [ JavaCast( 'null', '' ) ] ); + } + // Populate the property as the value obtained whether simple or related + else { + invoke( beanInstance, "set#key#", [ propertyValue ] ); + } - } // end if setter or scope injection - }// end if prop ignored + } // end if setter or scope injection + }// end if prop ignored - }//end for loop - return beanInstance; + }//end for loop + return beanInstance; + } + catch( Any e ){ + if( isNull( propertyValue ) ) { + arguments.keyTypeAsString = "NULL"; } - catch( Any e ){ - if( isNull( propertyValue ) ) { - arguments.keyTypeAsString = "NULL"; - } - else if ( isObject( propertyValue ) OR isCustomFunction( propertyValue )){ - arguments.keyTypeAsString = getMetaData( propertyValue ).name; - } - else{ - arguments.keyTypeAsString = propertyValue.getClass().toString(); - } - throw(type="BeanPopulator.PopulateBeanException", - message="Error populating bean #getMetaData(beanInstance).name# with argument #key# of type #arguments.keyTypeAsString#.", - detail="#e.Detail#
#e.message#
#e.tagContext.toString()#"); + else if ( isObject( propertyValue ) OR isCustomFunction( propertyValue )){ + arguments.keyTypeAsString = getMetaData( propertyValue ).name; } -
-
- - - - - - var meta = {}; - // get array of properties - var stopRecursions= [ "lucee.Component", "WEB-INF.cftags.component" ]; - var properties = getUtil().getInheritedMetaData( arguments.target, stopRecursions ).properties; - - // loop over properties - for( var i = 1; i <= arrayLen( properties ); i++ ) { - var property = properties[ i ]; - // if property has a name, a fieldtype, and is not the ID, add to maps - if( structKeyExists( property, "fieldtype" ) && - structKeyExists( property, "name" ) && - !listFindNoCase( "id,column", property.fieldtype ) ) { - meta[ property.name ] = property; - } + else{ + arguments.keyTypeAsString = propertyValue.getClass().toString(); } - return meta; - - - - - - - - -
\ No newline at end of file + throw( + type = "BeanPopulator.PopulateBeanException", + message = "Error populating bean #getMetaData( beanInstance ).name# with argument #key# of type #arguments.keyTypeAsString#.", + detail = "#e.Detail#
#e.message#
#e.tagContext.toString()#" + ); + } + } + + /** + * Prepares a structure of target relational meta data + * + * @target The target to work on + */ + private struct function getRelationshipMetaData( required target ){ + var meta = {}; + // get array of properties + var stopRecursions= [ "lucee.Component", "WEB-INF.cftags.component" ]; + // Collect property metadata + variables.util + .getInheritedMetaData( arguments.target, stopRecursions ) + .properties + .filter( function( item ){ + return ( + item.keyExists( "fieldType" ) && + item.keyExists( "name" ) && + !listFindNoCase( "id,column", item.fieldtype ) + ); + } ) + .each( function( item ){ + meta[ item.name ] = item; + } ); + + return meta; + } + +} \ No newline at end of file diff --git a/src/cfml/system/wirebox/system/core/dynamic/HTMLHelper.cfc b/src/cfml/system/wirebox/system/core/dynamic/HTMLHelper.cfc deleted file mode 100644 index 3fa0fcefd..000000000 --- a/src/cfml/system/wirebox/system/core/dynamic/HTMLHelper.cfc +++ /dev/null @@ -1,2012 +0,0 @@ - - - - - - - - - variables.controller = arguments.controller; - - return this; - - - - - - - - - - - var str = ''; - if( arguments.addToHeader ){ - $htmlhead( str ); - } else { - return str; - } - - - - - - - - - var str = ''; - if( arguments.addToHeader ){ - $htmlhead( str ); - } else { - return str; - } - - - - - - - - - - - var sb = createObject("java","java.lang.StringBuilder").init(''); - var x = 1; - var thisAsset = ""; - var event = controller.getRequestService().getContext(); - var asyncStr = ""; - var deferStr = ""; - - // Global location settings - var jsPath = ""; - var cssPath = ""; - if( settingExists("htmlhelper_js_path") ){ jsPath = getSetting('htmlhelper_js_path'); } - if( settingExists("htmlhelper_css_path") ){ cssPath = getSetting('htmlhelper_css_path'); } - - // Async HTML5 attribute - if( arguments.async ){ asyncStr = " async='async'"; } - // Defer HTML5 attribute - if( arguments.defer ){ deferStr = " defer='defer'"; } - - // request assets storage - event.paramValue(name="cbox_assets",value="",private=true); - - for(x=1; x lte listLen(arguments.asset); x=x+1){ - thisAsset = trim( listGetAt( arguments.asset, x ) ); - // Is asset already loaded - if( NOT listFindNoCase(event.getValue(name="cbox_assets",private=true),thisAsset) ){ - - // Load Asset - if( findNoCase(".js", thisAsset) ){ - sb.append(''); - } - else{ - sb.append(''); - } - - // Store It as Loaded - event.setValue(name="cbox_assets",value=listAppend(event.getValue(name="cbox_assets",private=true),thisAsset),private=true); - } - } - - //Load it - if( arguments.sendToHeader AND len(sb.toString())){ - $htmlhead(sb.toString()); - } - else{ - return sb.toString(); - } - - - - - - - ",arguments.count)> - - - - - - - - - - - - - #arguments.title#"> - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init( "<#arguments.tag#" ); - - // append tag attributes - flattenAttributes( arguments, "tag,content", buffer ).append( '>#arguments.content#' ); - - return buffer.toString(); - - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init("#arguments.text#' ); - - return buffer.toString(); - - - - - - - - - - - - - - - var buffer = createObject( "java", "java.lang.StringBuilder" ).init( "#arguments.text#' ); - - return buffer.toString(); - - - - - - - - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init("'); - - //Load it - if( arguments.sendToHeader AND len(buffer.toString())){ - $htmlhead(buffer.toString()); - } - else{ - return buffer.toString(); - } - - - - - - - - - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init("'); - - return buffer.toString(); - - - - - - - - - - - - - - - - - - - - - - - - - - - var str = createObject( "java", "java.lang.StringBuilder" ).init( '' ); - var attrs = ""; - var key = ""; - - // ID Normalization - normalizeID( arguments ); - - // Start Table - str.append( "" ); - - // Buffer Reference - arguments.buffer = str; - - // Convert Query To Table Body - if( isQuery( arguments.data ) ){ - queryToTable( argumentCollection=arguments ); - } - // Convert Array to Table Body - else if( isArray( arguments.data ) and arrayLen( arguments.data ) ){ - var firstMetadata = getMetadata( arguments.data[ 1 ] ); - // Check for array of ORM Object - if( - isObject( arguments.data[ 1 ] ) - AND - structKeyExists( firstMetadata, "persistent" ) && firstMetadata.persistent - ){ - arguments.data = entityToQuery( arguments.data ); - queryToTable( argumentCollection=arguments ); - } - // Array of objects, discover properties via metadata - else if ( isObject( arguments.data[ 1 ] ) ){ - objectsToTable( argumentCollection = arguments ); - } - // array of structs go here - else{ - arrayToTable( argumentCollection=arguments ); - } - } - - // Finalize table - str.append( "" ); - - return str.toString(); - - - - - - - - - - - - var x = 1; - var buffer = createObject("java","java.lang.StringBuilder").init(""); - var tmpType = ""; - - // prep type - if( arguments.type eq "equiv" ){ arguments.type = "http-equiv"; }; - - // Array of structs or simple value - if( isSimpleValue(arguments.name) ){ - buffer.append(''); - } - - if(isArray(arguments.name)){ - for(x=1; x lte arrayLen(arguments.name); x=x+1 ){ - if( NOT structKeyExists(arguments.name[x], "type") ){ - arguments.name[x].type = "name"; - } - if( arguments.name[x].type eq "equiv" ){ - arguments.name[x].type = "http-equiv"; - } - if ( structKeyExists(arguments.name[x], "property") ) { - buffer.append(''); - } else { - buffer.append(''); - } - } - } - - //Load it - if( arguments.sendToHeader AND len(buffer.toString())){ - $htmlhead(buffer.toString()); - } - else{ - return buffer.toString(); - } - - - - - - - - switch( arguments.type ){ - case 'html5' : { return ''; } - case 'xhtml11' : { return ''; } - case 'xhtml1-strict' : { return ''; } - case 'xhtml1-trans' : { return ''; } - case 'xhtml1-frame' : { return ''; } - case 'html4-strict' : { return ''; } - case 'html4-trans' : { return ''; } - case 'html4-frame' : { return ''; } - } - - - - - - - - - - // Cleanup and slugify the string - var slug = lcase( trim( arguments.str ) ); - slug = replaceList( slug, '#chr(228)#,#chr(252)#,#chr(246)#,#chr(223)#', 'ae,ue,oe,ss' ); - slug = reReplace( slug, "[^a-z0-9-\s#arguments.allow#]", "", "all" ); - slug = trim ( reReplace( slug, "[\s-]+", " ", "all" ) ); - slug = reReplace( slug, "\s", "-", "all" ); - - // is there a max length restriction - if( arguments.maxlength ){ slug = left( slug, arguments.maxlength ); } - - return slug; - - - - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init("'); - - return buffer.toString(); - - - - - - - - - - - - - - - - - - var video = createObject("java","java.lang.StringBuilder").init("'); - return video.toString(); - } - - // create source tags - video.append(">"); - for(x=1; x lte arrayLen(arguments.src); x++){ - arguments.src[x] = prepareBaseLink(arguments.noBaseURL, arguments.src[x]); - video.append(''); - } - video.append(""); - - return video.toString(); - - - - - - - - - - - - - - - var audio = createObject("java","java.lang.StringBuilder").init("'); - return audio.toString(); - } - - // create source tags - audio.append(">"); - for(x=1; x lte arrayLen(arguments.src); x++){ - arguments.src[x] = prepareBaseLink(arguments.noBaseURL, arguments.src[x]); - audio.append(''); - } - audio.append(""); - - return audio.toString(); - - - - - - - - - - - var canvas = createObject("java","java.lang.StringBuilder").init(""); - - return canvas.toString(); - - - - - - - - - - - - - - var formBuffer = createObject( "java", "java.lang.StringBuilder" ).init( "" ); - - // If we wanted to use PUT, PATCH, or DELETE, spoof the HTTP method - // by including a hidden field in the form that ColdBox will look for. - if ( len( desiredMethod ) ) { - formBuffer.append( "" ); - } - - return formBuffer.toString(); - - - - - - "> - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init('"); - - // add Legend? - if( len(arguments.legend) ){ - buffer.append("#arguments.legend#"); - } - - return buffer.toString(); - - - - - - "> - - - - - - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init(''); - - // get content - if( NOT len(content) ){ arguments.content = makePretty(arguments.field); } - arguments.for = arguments.field; - - if (labelMode == 0 || labelMode == 1) { - // wrapper? - wrapTag(buffer,arguments.wrapper,0,arguments.wrapperAttrs); - - // create label tag - buffer.append(""); - } - - if (labelMode == 0 || labelMode == 2) { - buffer.append("#arguments.content#"); - //wrapper? - wrapTag(buffer,arguments.wrapper,1); - } - - return buffer.toString(); - - - - - - - - - - - - - - - - - - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init(''); - - // ID Normalization - normalizeID(arguments); - // group wrapper? - wrapTag(buffer,arguments.groupWrapper,0,arguments.groupWrapperAttrs); - // label? - if( len(arguments.label) ){ buffer.append( this.label(field=arguments.id,content=arguments.label,wrapper=arguments.labelWrapper,wrapperAttrs=arguments.labelWrapperAttrs,class=arguments.labelClass, - labelMode = (arguments.inputInsideLabel ? 1 : 0), labelAttrs=arguments.labelAttrs) ); } - - //wrapper? - wrapTag(buffer,arguments.wrapper,0,arguments.wrapperAttrs); - - // disabled fix - if( arguments.disabled ){ arguments.disabled = "disabled"; } - else{ arguments.disabled = ""; } - // readonly fix - if( arguments.readonly ){ arguments.readonly = "readonly"; } - else{ arguments.readonly = ""; } - - // Entity Binding? - bindValue(arguments); - - // create textarea - buffer.append("#arguments.value#"); - - //wrapper? - wrapTag(buffer,arguments.wrapper,1); - // group wrapper? - wrapTag(buffer,arguments.groupWrapper,1); - return buffer.toString(); - - - - - - - - - - - - - - - - - - - - - - - arguments.type="password"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - - - - arguments.type="url"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - - - - arguments.type="email"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - - arguments.type="hidden"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - - - - arguments.type="text"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init(''); - - // ID Normalization - normalizeID(arguments); - // group wrapper? - wrapTag(buffer,arguments.groupWrapper,0,arguments.groupWrapperAttrs); - // label? - if( len(arguments.label) ){ buffer.append( this.label(field=arguments.id,content=arguments.label,wrapper=arguments.labelWrapper,wrapperAttrs=arguments.labelWrapperAttrs,class=arguments.labelClass, - labelMode = (arguments.inputInsideLabel ? 1 : 0), labelAttrs=arguments.labelAttrs) ); } - - //wrapper? - wrapTag(buffer,arguments.wrapper,0,arguments.wrapperAttrs); - - // disabled fix - if( arguments.disabled ){ arguments.disabled = "disabled"; } - else{ arguments.disabled = ""; } - - // create textarea - buffer.append("#arguments.value#"); - - //wrapper? - wrapTag(buffer,arguments.wrapper,1); - - // close label tag if inputInsideLabel? - if (len(arguments.label) && arguments.inputInsideLabel) { - buffer.append( this.label(field=arguments.id, content=arguments.label, wrapper=arguments.labelWrapper, labelMode = 2) ); // close the label tag if we have one opened - } - - // group wrapper? - wrapTag(buffer,arguments.groupWrapper,1); - return buffer.toString(); - - - - - - - - - - - - - - - - - - - - - arguments.type="file"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - - - - arguments.type="checkbox"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - - - - arguments.type="radio"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - arguments.type="submit"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - arguments.type="reset"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - - - - - - - - - arguments.type="image"; - return inputField(argumentCollection=arguments); - - - - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init(''); - var val = ""; - var nameVal = ""; - var x = 1; - var qColumns = ""; - var thisName = ""; - var thisValue = ""; - - // check if an array? So we can do array of objects check - if( isArray(arguments.values) AND arrayLen(arguments.values) ){ - // Check first element for an object, if it is then convert to query - if( isObject(arguments.values[1]) ){ - arguments.values = entityToQuery(arguments.values); - } - } - // is this a simple value, if so, inflate it - if( isSimpleValue(arguments.values) ){ - arguments.values = listToArray(arguments.values); - } - - // setup local variables - val = arguments.values; - nameVal = arguments.values; - - // query normalization? - if( isQuery(val) ){ - // check if column sent? Else select the first column - if( NOT len(column) ){ - // select the first one - qColumns = listToArray( arguments.values.columnList ); - arguments.column = qColumns[1]; - } - // column for values - val = getColumnArray(arguments.values,arguments.column); - nameVal = val; - // name column values - if( len(arguments.nameColumn) ){ - nameVal = getColumnArray(arguments.values,arguments.nameColumn); - } - } - - // values - for(x=1; x lte arrayLen(val); x++){ - - thisValue = val[x]; - thisName = nameVal[x]; - - // struct normalizing - if( isStruct( val[x] ) ){ - // Default - thisName = thisValue; - - // check for value? - if( structKeyExists(val[x], "value") ){ thisValue = val[x].value; } - if( structKeyExists(val[x], "name") ){ thisName = val[x].name; } - - // Check if we have a column to use for the default value - if( structKeyExists( val[x], arguments.column ) ){ thisValue = val[x][column]; } - - // Do we have name column - if( len( arguments.nameColumn ) ){ - if( structKeyExists( val[x], arguments.nameColumn ) ){ thisName = val[x][nameColumn]; } - } - else{ - if( structKeyExists( val[x], arguments.column ) ){ thisName = val[x][column]; } - } - - } - - // create option - buffer.append('"); - - } - - return buffer.toString(); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init(''); - - // ID Normalization - normalizeID(arguments); - // group wrapper? - wrapTag(buffer,arguments.groupWrapper,0,arguments.groupWrapperAttrs); - // label? - if( len(arguments.label) ){ buffer.append( this.label(field=arguments.id,content=arguments.label,wrapper=arguments.labelWrapper,wrapperAttrs=arguments.labelWrapperAttrs,class=arguments.labelClass, labelAttrs=arguments.labelAttrs) ); } - - //wrapper? - wrapTag(buffer,arguments.wrapper,0,arguments.wrapperAttrs); - - // disabled fix - if( arguments.disabled ){ arguments.disabled = "disabled"; } - else{ arguments.disabled = ""; } - // multiple fix - if( arguments.multiple ){ arguments.multiple = "multiple"; } - else{ arguments.multiple = ""; } - - // create select - buffer.append(""); - - // binding of option - bindValue(arguments); - if( structKeyExists(arguments,"value") AND len(arguments.value) ){ - arguments.selectedValue = arguments.value; - } - - // options, are they inflatted already or do we inflate - if( isSimpleValue(arguments.options) AND findnocase("",arguments.options) ){ - buffer.append( arguments.options ); - } - else{ - buffer.append( this.options(arguments.options,arguments.column,arguments.nameColumn,arguments.selectedIndex,arguments.selectedValue) ); - } - - // finalize select - buffer.append(""); - - //wrapper? - wrapTag(buffer,arguments.wrapper,1); - - // close label tag if inputInsideLabel - if (len(arguments.label) && arguments.inputInsideLabel) { - buffer.append( this.label(field=arguments.id, content=arguments.label, wrapper=arguments.labelWrapper, labelMode = 2) ); // close the label tag if we have one opened - } - - // group wrapper? - wrapTag(buffer,arguments.groupWrapper, 1); - - return buffer.toString(); - - - - - - - - - - - - - - - - - - - - - - - - - - var buffer = createObject( "java", "java.lang.StringBuilder" ).init( '' ); - var excludeList = "label,wrapper,labelWrapper,groupWrapper,labelClass,labelAttrs,inputInsideLabel,bind,bindProperty"; - - // ID Normalization - normalizeID( arguments ); - // group wrapper? - wrapTag( buffer, arguments.groupWrapper, 0, arguments.groupWrapperAttrs ); - // label? - if( len( arguments.label ) ){ buffer.append( this.label( field=arguments.id, content=arguments.label, wrapper=arguments.labelWrapper, wrapperAttrs=arguments.labelWrapperAttrs, class=arguments.labelClass, - labelMode = (arguments.inputInsideLabel ? 1 : 0), labelAttrs=arguments.labelAttrs ) ); } - //wrapper? - wrapTag( buffer, arguments.wrapper, 0, arguments.wrapperAttrs ); - - // disabled fix - if( arguments.disabled ){ arguments.disabled = "disabled"; } - else{ arguments.disabled = ""; } - // checked fix - if( arguments.checked ){ arguments.checked = "checked"; } - else{ arguments.checked = ""; } - // readonly fix - if( arguments.readonly ){ arguments.readonly = "readonly"; } - else{ arguments.readonly = ""; } - - // binding? - bindValue( arguments ); - - // create textarea - buffer.append("" ); - - //wrapper? - wrapTag( buffer, arguments.wrapper, 1 ); - - // close label tag if inputInsideLabel - if (len(arguments.label) && arguments.inputInsideLabel) { - buffer.append( this.label(field=arguments.id, content=arguments.label, wrapper=arguments.labelWrapper, labelMode = 2) ); // close the label tag if we have one opened - } - - // group wrapper? - wrapTag( buffer, arguments.groupWrapper, 1 ); - - return buffer.toString(); - - - - - - - - - - - - - - - - - - - - - - - var buffer = createObject("java","java.lang.StringBuilder").init(''); - var md = getMetadata( arguments.entity ); - var x = 1; - var y = 1; - var prop = ""; - var args = {}; - var loc = {}; - - // if no properties just return. - if( NOT structKeyExists(md,"properties") ){ return ""; } - - // iterate properties array - for(x=1; x lte arrayLen(md.properties); x++ ){ - prop = md.properties[x]; - - // setup some defaults - loc.persistent = true; - loc.ormtype = "string"; - loc.fieldType = "column"; - loc.insert = true; - loc.update = true; - loc.formula = ""; - loc.readonly = false; - if( structKeyExists(prop,"persistent") ){ loc.persistent = prop.persistent; } - if( structKeyExists(prop,"ormtype") ){ loc.ormtype = prop.ormtype; } - if( structKeyExists(prop,"fieldType") ){ loc.fieldType = prop.fieldType; } - if( structKeyExists(prop,"insert") ){ loc.insert = prop.insert; } - if( structKeyExists(prop,"update") ){ loc.update = prop.update; } - if( structKeyExists(prop,"formula") ){ loc.formula = prop.formula; } - if( structKeyExists(prop,"readonly") ){ loc.readonly = prop.readonly; } - - // html 5 data items - arguments["data-ormtype"] = loc.ormtype; - arguments["data-insert"] = loc.insert; - arguments["data-update"] = loc.update; - - // continue on non-persistent ones or formulas or readonly - loc.orm = ORMGetSession(); - if( NOT loc.persistent OR len(loc.formula) OR loc.readOnly OR - ( loc.orm.contains(arguments.entity) AND NOT loc.update ) OR - ( NOT loc.orm.contains(arguments.entity) AND NOT loc.insert ) - ){ continue; } - - switch(loc.fieldType){ - //primary key as hidden field - case "id" : { - args = { - name=prop.name,bind=arguments.entity - }; - buffer.append( hiddenField(argumentCollection=args) ); - break; - } - case "many-to-many" : { - // A new or persisted entity? If new, then skip out - if( NOT loc.orm.contains(arguments.entity) OR NOT arguments.showRelations){ - break; - } - - // prepare lookup args - loc.criteria = {}; - loc.sortorder = ""; - loc.column = ""; - loc.nameColumn = ""; - loc.selectColumn = ""; - loc.values = []; - loc.relArray = []; - arguments["data-ormtype"] = "many-to-many"; - - // is key found in manytoone arg - if( structKeyExists(arguments.manytomany, prop.name) ){ - if( structKeyExists(arguments.manytomany[prop.name],"valueColumn") ){ loc.column = arguments.manytomany[prop.name].valueColumn; } - else{ - throw(message="The 'valueColumn' property is missing from the '#prop.name#' relationship data, which is mandatory", - detail="A structure of data to help with many to one relationships on how they are presented. Possible key values for each key are [valuecolumn='',namecolumn='',criteria={},sortorder=string,selectColumn='']. Example: {criteria={productid=1},sortorder='Department desc'}", - type="EntityFieldsInvalidRelationData"); - } - if( structKeyExists(arguments.manytomany[prop.name],"nameColumn") ){ loc.nameColumn = arguments.manytomany[prop.name].nameColumn; } - else{ - loc.nameColumn = arguments.manytomany[prop.name].valueColumn; - } - if( structKeyExists(arguments.manytomany[prop.name],"criteria") ){ loc.criteria = arguments.manytomany[prop.name].criteria; } - if( structKeyExists(arguments.manytomany[prop.name],"sortorder") ){ loc.sortorder = arguments.manytomany[prop.name].sortorder; } - if( structKeyExists(arguments.manytomany[prop.name],"selectColumn") ){ loc.selectColumn = arguments.manytomany[prop.name].selectColumn; } - } - else{ - throw(message="There is no many to many information for the '#prop.name#' relationship in the entityFields() arguments. Please make sure you create one", - detail="A structure of data to help with many to one relationships on how they are presented. Possible key values for each key are [valuecolumn='',namecolumn='',criteria={},sortorder=string,selectColumn='']. Example: {criteria={productid=1},sortorder='Department desc'}", - type="EntityFieldsInvalidRelationData"); - } - - // values should be an array of objects, so let's convert them - loc.relArray = invoke( arguments.entity, "get#prop.name#" ); - - if( isNull(loc.relArray) ){ loc.relArray = []; } - if( NOT len(loc.selectColumn) AND arrayLen(loc.relArray) ){ - // if select column is empty, then select first property as select value, not perfect but hey better than nothing - loc.selectColumn = getMetadata( loc.relArray[1] ).properties[1].name; - } - // iterate and select - for(y=1; y lte arrayLen(loc.relArray); y++){ - loc.values.append( - invoke( loc.relArray[ y ], "get#loc.selectColumn#" ) - ); - } - // generation args - args = { - name=prop.name, options=entityLoad( prop.cfc, loc.criteria, loc.sortorder ), column=loc.column, nameColumn=loc.nameColumn, - multiple=true, label=prop.name, labelwrapper=arguments.labelWrapper, labelWrapperAttrs=arguments.labelWrapperAttrs, labelClass=arguments.labelClass, wrapper=arguments.fieldwrapper, wrapperAttrs=arguments.fieldWrapperAttrs, - groupWrapper=arguments.groupWrapper, groupWrapper=arguments.groupWrapperAttrs, labelAttrs=arguments.labelAttrs, inputInsideLabel=arguments.inputInsideLabel, selectedValue=arrayToList( loc.values ) - }; - structAppend(args,arguments); - buffer.append( this.select(argumentCollection=args) ); - break; - } - // one to many display - case "one-to-many" : { - // A new or persisted entity? If new, then skip out - if( NOT loc.orm.contains(arguments.entity) OR NOT arguments.showRelations){ - break; - } - arguments["data-ormtype"] = "one-to-many"; - // We just show them as a nice table because we are not scaffolding, just display - // values should be an array of objects, so let's convert them - loc.relArray = invoke( arguments.entity, "get#prop.name#" ); - if( isNull(loc.relArray) ){ loc.relArray = []; } - - // Label Generation - args = { - field=prop.name, wrapper=arguments.labelWrapper, class=arguments.labelClass, inputInsideLabel=arguments.inputInsideLabel - }; - structAppend(args,arguments); - buffer.append( this.label(argumentCollection=args) ); - - // Table Generation - if( arrayLen(loc.relArray) ){ - args = { - name=prop.name, data=loc.relArray - }; - structAppend(args,arguments); - buffer.append( this.table(argumentCollection=args) ); - } - else{ - buffer.append("

None Found

"); - } - - break; - } - // one to many display - case "one-to-one" : { - // A new or persisted entity? If new, then skip out - if( NOT loc.orm.contains(arguments.entity) OR NOT arguments.showRelations){ - break; - } - - arguments["data-ormtype"] = "one-to-one"; - // We just show them as a nice table because we are not scaffolding, just display - // values should be an array of objects, so let's convert them - loc.data = invoke( arguments.entity, "get#prop.name#" ); - if( isNull(loc.data) ){ loc.relArray = []; } - else{ loc.relArray = [ loc.data ]; } - - // Label Generation - args = { - field=prop.name, wrapper=arguments.labelWrapper, class=arguments.labelClass, inputInsideLabel=arguments.inputInsideLabel - }; - structAppend(args,arguments); - buffer.append( this.label(argumentCollection=args) ); - - // Table Generation - if( arrayLen(loc.relArray) ){ - args = { - name=prop.name, data=loc.relArray - }; - structAppend(args,arguments); - buffer.append( this.table(argumentCollection=args) ); - } - else{ - buffer.append("

None Found

"); - } - break; - } - // many to one - case "many-to-one" : { - // A new or persisted entity? If new, then skip out - if( NOT loc.orm.contains(arguments.entity) OR NOT arguments.showRelations){ - break; - } - arguments["data-ormtype"] = "many-to-one"; - // prepare lookup args - loc.criteria = {}; - loc.sortorder = ""; - loc.column = ""; - loc.nameColumn = ""; - // is key found in manytoone arg - if( structKeyExists(arguments.manytoone, prop.name) ){ - // Verify the valueColumn which is mandatory - if( structKeyExists(arguments.manytoone[prop.name],"valueColumn") ){ loc.column = arguments.manytoone[prop.name].valueColumn; } - else{ - throw(message="The 'valueColumn' property is missing from the '#prop.name#' relationship data, which is mandatory", - detail="A structure of data to help with many to one relationships on how they are presented. Possible key values for each key are [valuecolumn='',namecolumn='',criteria={},sortorder=string]. Example: {criteria={productid=1},sortorder='Department desc'}", - type="EntityFieldsInvalidRelationData"); - } - if( structKeyExists(arguments.manytoone[prop.name],"nameColumn") ){ loc.nameColumn = arguments.manytoone[prop.name].nameColumn; } - else { loc.nameColumn = arguments.manytoone[prop.name].valueColumn; } - if( structKeyExists(arguments.manytoone[prop.name],"criteria") ){ loc.criteria = arguments.manytoone[prop.name].criteria; } - if( structKeyExists(arguments.manytoone[prop.name],"sortorder") ){ loc.sortorder = arguments.manytoone[prop.name].sortorder; } - } - else{ - throw(message="There is no many to one information for the '#prop.name#' relationship in the entityFields() arguments. Please make sure you create one", - detail="A structure of data to help with many to one relationships on how they are presented. Possible key values for each key are [valuecolumn='',namecolumn='',criteria={},sortorder=string]. Example: {criteria={productid=1},sortorder='Department desc'}", - type="EntityFieldsInvalidRelationData"); - } - // generation args - args = { - name=prop.name, options=entityLoad( prop.cfc, loc.criteria, loc.sortorder ), - column=loc.column, nameColumn=loc.nameColumn, - label=prop.name, bind=arguments.entity, labelwrapper=arguments.labelWrapper, labelWrapperAttrs=arguments.labelWrapperAttrs, labelClass=arguments.labelClass, - wrapper=arguments.fieldwrapper, wrapperAttrs=arguments.fieldWrapperAttrs, groupWrapper=arguments.groupWrapper, groupWrapperAttrs=arguments.groupWrapperAttrs, - inputInsideLabel=arguments.inputInsideLabel - }; - structAppend(args,arguments); - buffer.append( this.select(argumentCollection=args) ); - break; - } - // columns - case "column" : { - - // booleans? - if( structKeyExists(prop,"ormtype") and prop.ormtype eq "boolean"){ - // boolean select or radio buttons - if( arguments.booleanSelect ){ - args = { - name=prop.name, options=[true,false], label=prop.name, bind=arguments.entity, labelwrapper=arguments.labelWrapper, labelWrapperAttrs=arguments.labelWrapperAttrs, labelClass=arguments.labelClass, - wrapper=arguments.fieldwrapper, wrapperAttrs=arguments.wrapperAttrs, groupWrapper=arguments.groupWrapper, groupWrapperAttrs=arguments.groupWrapperAttrs, inputInsideLabel=arguments.inputInsideLabel - }; - structAppend(args,arguments); - buffer.append( this.select(argumentCollection=args) ); - } - else{ - args = { - name=prop.name, value="true", label="True", bind=arguments.entity, labelwrapper=arguments.labelWrapper, labelWrapperAttrs=arguments.labelWrapperAttrs, labelClass=arguments.labelClass, - groupWrapper=arguments.groupWrapper, groupWrapperAttrs = arguments.groupWrapperAttrs, wrapper=arguments.fieldWrapper, wrapperAttrs=arguments.fieldWrapperAttrs,inputInsideLabel=arguments.inputInsideLabel - }; - structAppend(args,arguments); - buffer.append( this.radioButton(argumentCollection=args) ); - args.value="false"; - args.label="false"; - buffer.append( this.radioButton(argumentCollection=args) ); - } - continue; - } - // text args - args = { - name=prop.name, label=prop.name, bind=arguments.entity, labelwrapper=arguments.labelWrapper, labelWrapperAttrs=arguments.labelWrapperAttrs, labelClass=arguments.labelClass, - wrapper=arguments.fieldwrapper, wrapperAttrs=arguments.fieldWrapperAttrs, groupWrapper=arguments.groupWrapper, groupWrapperAttrs=arguments.groupWrapperAttrs, inputInsideLabel=arguments.inputInsideLabel - }; - structAppend(args,arguments); - // text and textarea fields - if( len(arguments.textareas) AND listFindNoCase(arguments.textareas, prop.name) ){ - buffer.append( this.textarea(argumentCollection=args) ); - } - else{ - buffer.append( this.textfield(argumentCollection=args) ); - } - }// end case column - - }// end switch - - }// end for loop - - return buffer.toString(); -
-
- - - - - - - - - - addAsset( - elixirPath( arguments.fileName, arguments.buildDirectory ), - arguments.sendToHeader, - arguments.async, - arguments.defer - ); - - - - - - - - - - var includesLocation = controller.getSetting( "IncludesConvention", true ); - var event = getRequestContext(); - var mapping = ( useModuleRoot && len( event.getCurrentModule() ) ) ? - event.getModuleRoot() : - controller.getSetting( "appMapping" ); - var filePath = expandPath( "#mapping#/#includesLocation#/#arguments.buildDirectory#/rev-manifest.json" ); - var href = "#mapping#/#includesLocation#/#arguments.fileName#"; - - if ( ! fileExists( filePath ) ) { - return href; - } - - var fileContents = fileRead( filePath ); - if ( ! isJSON( fileContents ) ) { - return href; - } - - var json = deserializeJSON( fileContents ); - if ( ! structKeyExists( json, arguments.fileName ) ) { - return href; - } - - return "#mapping#/#includesLocation#/#arguments.buildDirectory#/#json[ arguments.fileName ]#"; - - - - - - - - - - - - - var str = arguments.buffer; - var attrs = ""; - var x = 1; - var y = 1; - var key = ""; - - var firstMetadata = getMetadata( arguments.data[ 1 ] ); - var properties = structKeyExists( firstMetadata, "properties" ) ? firstMetadata.properties : []; - - for( var thisProperty in properties ){ - // Display headers? - if( passIncludeExclude( thisProperty.name, arguments.includes, arguments.excludes ) ){ - str.append( "#thisProperty.name#" ); - } - } - str.append( "" ); - - // Render Body - str.append( "" ); - - for( var thisRecord in arguments.data ){ - str.append( "" ); - for( var thisProperty in properties ){ - // Display headers? - if( passIncludeExclude( thisProperty.name, arguments.includes, arguments.excludes ) ){ - str.append( "#invoke( thisRecord, "get#thisProperty.name#" )#" ); - } - } - str.append( "" ); - } - - - - - - - - - - - var str = arguments.buffer; - var attrs = ""; - var x = 1; - var y = 1; - var key = ""; - var cols = structKeyArray( data[ 1 ] ); - - // Render Headers - for(x=1; x lte arrayLen(cols); x=x+1){ - // Display? - if( passIncludeExclude(cols[x],arguments.includes,arguments.excludes) ){ - str.append("#cols[x]#"); - } - } - str.append(""); - - // Render Body - str.append(""); - for(x=1; x lte arrayLen(arguments.data); x=x+1){ - str.append(""); - for(y=1; y lte arrayLen(cols); y=y+1){ - // Display? - if( passIncludeExclude(cols[y],arguments.includes,arguments.excludes) ){ - str.append("#arguments.data[x][cols[y]]#"); - } - } - str.append(""); - } - - - - - - - - - - - var str = arguments.buffer; - var cols = listToArray(arguments.data.columnList); - var x = 1; - var y = 1; - - // Render Headers - for(x=1; x lte arrayLen(cols); x=x+1){ - // Display? - if( passIncludeExclude(cols[x],arguments.includes,arguments.excludes) ){ - str.append("#cols[x]#"); - } - } - str.append(""); - - // Render Body - str.append(""); - for(x=1; x lte arguments.data.recordcount; x=x+1){ - str.append(""); - for(y=1; y lte arrayLen(cols); y=y+1){ - // Display? - if( passIncludeExclude(cols[y],arguments.includes,arguments.excludes) ){ - str.append("#arguments.data[cols[y]][x]#"); - } - } - str.append(""); - } - - - - - - - - - - - var val = arguments.values; - var x = 1; - var str = createObject("java","java.lang.StringBuilder").init(""); - var br = chr(13); - var args = ""; - - // list or array or query? - if( isSimpleValue(val) ){ val = listToArray(val); } - if( isQuery(val) ){ val = getColumnArray(val,arguments.column); } - - // start tag - str.append("<#arguments.tag#"); - // flatten extra attributes via arguments - flattenAttributes(arguments,"tag,values,column",str).append(">"); - - // values - for(x=1; x lte arrayLen(val); x=x+1){ - - if( isArray(val[x]) ){ - str.append( toHTMLList(arguments.tag,val[x],arguments.column) ); - } - else{ - str.append("
  • #val[x]#
  • "); - } - - } - - str.append(""); - return str.toString(); -
    -
    - - - - - - var entityValue = ""; - - // binding? - if( isObject( arguments.args.bind ) ){ - // do we have a bindProperty, else default it from the name - if( NOT len( arguments.args.bindProperty ) ){ - - // check if name exists else throw exception - if( NOT structKeyExists( arguments.args, "name" ) OR NOT len( arguments.args.name ) ){ - throw( type="HTMLHelper.NameBindingException", message="The 'name' argument was not passed and not binding property was passed, so we can't bind dude!" ); - } - - // bind name property - arguments.args.bindProperty = arguments.args.name; - } - - // entity value - entityValue = invoke( arguments.args.bind, "get#arguments.args.bindProperty#" ); - if( isNull( entityValue ) ){ - entityValue = ""; - } - // Verify if the value is an entity, if it is, then use the 'column' to retrieve the value - if( isObject( entityValue ) ){ - entityValue = invoke( entityValue, "get#arguments.args.column#" ); - } - - // If radio or checkbox button, check it - if( structKeyExists( arguments.args, "type" ) AND listFindNoCase( "radio,checkbox", arguments.args.type ) ){ - // is incoming value eq to property value with boolean aspects - if( structKeyExists( arguments.args, "value" ) and - isBoolean( arguments.args.value ) and - yesNoFormat( arguments.args.value ) EQ yesNoFormat( entityValue ) ){ - arguments.args.checked = true; - } - // else with no boolean evals - else if( structKeyExists( arguments.args, "value" ) and arguments.args.value EQ entityValue ){ - arguments.args.checked = true; - } - } - else{ - // If there is no incoming value, then bind it - arguments.args.value = entityValue; - } - } - - - - - - - - if( structKeyExists(arguments.args,"name") AND len(arguments.args.name) AND NOT structKeyExists(arguments.args,"id") ){ - arguments.args.id = arguments.args.name; - } - - - - - - - - - - - // Only do if we have length - if( len( arguments.tag ) ){ - // Starting or ending? - if( arguments.end ){ - arguments.buffer.append( "" ); - } else { - arguments.buffer.append( "<#arguments.tag#" ); - if (!isNull(arguments.attrs)) { - for (var attr in structKeyArray(arguments.attrs)) { - arguments.buffer.append(' ' & attr & '="' & structFind(arguments.attrs,attr) & '"'); - } - } - arguments.buffer.append(">"); - } - } - - - - - - - - return ucase( left( arguments.text, 1 ) ) & removeChars( lcase( replace( arguments.text, "_", " ") ), 1, 1 ); - - - - - - - - - var baseURL = replacenocase( controller.getRequestService().getContext().getSESbaseURL() ,"index.cfm",""); - // return if base is eempty - if( NOT len(baseURL) ){ return arguments.src; } - - // Check if we have a base URL - if( arguments.noBaseURL eq FALSE and NOT find("://",arguments.src)){ - arguments.src = baseURL & "/" & arguments.src; - } - return arguments.src; - - - - - - - - - - var disp = true; - // Include List? - if( len(arguments.includes) AND NOT listFindNoCase(arguments.includes,arguments.value) ){ - disp = false; - } - // Exclude List? - if( len(arguments.excludes) AND listFindNoCase(arguments.excludes,arguments.value) ){ - disp = false; - } - return disp; - - - - - - - - - - var key = ""; - var datakey = ""; - - // global exclusions - arguments.excludes &= ",fieldWrapper,labelWrapper,wrapperAttrs,fieldWrapperAttrs,labelWrapperAttrs,groupWrapperAttrs,entity,booleanSelect,textareas,manytoone,onetomany,sendToHeader,bind,inputInsideLabel,labelAttrs"; - - for(key in arguments.target){ - // Excludes - if( len( arguments.excludes ) AND listFindNoCase( arguments.excludes, key ) ){ - continue; - } - // Normal Keys - if( structKeyExists( arguments.target, key ) AND isSimpleValue( arguments.target[ key ] ) AND len( arguments.target[ key ] ) ){ - arguments.buffer.append(' #lcase( key )#="#HTMLEditFormat( arguments.target[ key ] )#"'); - } - // data keys - if( isStruct( arguments.target[ key ] ) ){ - for( dataKey in arguments.target[ key ] ){ - if( isSimplevalue( arguments.target[ key ][ dataKey ] ) AND len( arguments.target[ key ][ dataKey ] ) ){ - arguments.buffer.append(' #lcase( key )#-#lcase( dataKey )#="#HTMLEditFormat( arguments.target[ key ][ datakey ] )#"'); - } - } - } - - } - - return arguments.buffer; - - - - - - - - - - - - - - - - - - - - - - - - - - - var arValues = []; - - if( arguments.qry.recordcount ){ - for( var i = 1; i LTE arguments.qry.recordcount; i++){ - ArrayAppend( arValues, arguments.qry[ arguments.columnName ][ i ] ); - } - } - - return arValues; - - - - - - - - - -
    diff --git a/src/cfml/system/wirebox/system/core/util/Util.cfc b/src/cfml/system/wirebox/system/core/util/Util.cfc index de46943d9..c1ae5898a 100644 --- a/src/cfml/system/wirebox/system/core/util/Util.cfc +++ b/src/cfml/system/wirebox/system/core/util/Util.cfc @@ -26,7 +26,10 @@ Description : return arguments.in.reduce( function( result, item, index ){ - var target = result ?: structNew(); + var target = {}; + if( !isNull( result ) ){ + target = result; + } target[ index ] = item; return target; } ); diff --git a/src/cfml/system/wirebox/system/ioc/Builder.cfc b/src/cfml/system/wirebox/system/ioc/Builder.cfc index 6c725940c..df1aeb3eb 100644 --- a/src/cfml/system/wirebox/system/ioc/Builder.cfc +++ b/src/cfml/system/wirebox/system/ioc/Builder.cfc @@ -658,7 +658,7 @@ * @return The target object */ function toVirtualInheritance( required mapping, required target, required targetMapping ){ - var excludedProperties = "$super,$wbaopmixed,$mixed,$WBAOPTARGETMAPPING,$WBAOPTARGETS,this,init"; + var excludedProperties = "$super,$wbaopmixed,$mixed,this,init"; // Check if the base mapping has been discovered yet if( NOT arguments.mapping.isDiscovered() ){ @@ -716,8 +716,15 @@ target.injectPropertyMixin( propertyName, propertyValue ); // Do we need to do automatic generic getter/setters if( generateAccessors and baseProperties.keyExists( propertyName ) ){ - target[ "get" & propertyName ] = variables.genericGetter; - target[ "set" & propertyName ] = variables.genericSetter; + + if( ! structKeyExists( target, "get#propertyName#" ) ){ + target.injectMixin( "get" & propertyName, variables.genericGetter ); + } + + if( ! structKeyExists( target, "set#propertyName#" ) ){ + target.injectMixin( "set" & propertyName, variables.genericSetter ); + } + } } ); @@ -725,16 +732,6 @@ arguments.target.$super = baseObject; return arguments.target; - /** - * NOT NEEDED ANYMORE SINCE WE NOW COPY OVER THE STATE OF THE OBJECT - // Verify if we need to init the virtualized object - if( structKeyExists( arguments.target, "$superInit" ) ){ - // get super constructor arguments. - constructorArgs = buildArgumentCollection( arguments.mapping, arguments.mapping.getDIConstructorArguments(), baseObject ); - // Init the virtualized inheritance - arguments.target.$superInit( argumentCollection=constructorArgs ); - } - **/ } /** diff --git a/src/cfml/system/wirebox/system/ioc/Injector.cfc b/src/cfml/system/wirebox/system/ioc/Injector.cfc index 9e515d05c..1609a98e0 100644 --- a/src/cfml/system/wirebox/system/ioc/Injector.cfc +++ b/src/cfml/system/wirebox/system/ioc/Injector.cfc @@ -126,7 +126,7 @@ component serializable="false" accessors="true" implements="wirebox.system.ioc.I // Scope Storages variables.scopeStorage = new wirebox.system.core.collections.ScopeStorage(); // Version - variables.version = "5.0.0-snapshot"; + variables.version = "5.1.4+741"; // The Configuration Binder object variables.binder = ""; // ColdBox Application Link @@ -196,6 +196,9 @@ component serializable="false" accessors="true" implements="wirebox.system.ioc.I variables.eventManager = variables.coldbox.getInterceptorService(); } + // Create and Configure Event Manager + configureEventManager(); + // Store binder object built accordingly to our binder building procedures variables.binder = buildBinder( arguments.binder, arguments.properties ); @@ -207,8 +210,6 @@ component serializable="false" accessors="true" implements="wirebox.system.ioc.I configureCacheBox( variables.binder.getCacheBoxConfig() ); } - // Create and Configure Event Manager - configureEventManager(); // Register All Custom Listeners registerListeners(); // Create our object builder @@ -265,6 +266,11 @@ component serializable="false" accessors="true" implements="wirebox.system.ioc.I // Notify Listeners variables.eventManager.processState( "beforeInjectorShutdown", iData ); + // Check if binder has onShutdown convention + if( structKeyExists( variables.binder, "onShutdown" ) ){ + variables.binder.onShutdown(); + } + // Is parent linked if( isObject( variables.parent ) ){ variables.parent.shutdown(); @@ -338,8 +344,8 @@ component serializable="false" accessors="true" implements="wirebox.system.ioc.I // Check if the mapping has been discovered yet, and if it hasn't it must be autowired enabled in order to process. if( NOT mapping.isDiscovered() ){ try { - // process inspection of instance - mapping.process( binder=variables.binder, injector=this ); + // process inspection of instance + mapping.process( binder=variables.binder, injector=this ); } catch( any e ) { // Remove bad mapping var mappings = variables.binder.getMappings(); @@ -1134,16 +1140,12 @@ component serializable="false" accessors="true" implements="wirebox.system.ioc.I // Use or create event manager if( isColdBoxLinked() && isObject( variables.eventManager ) ){ // Link Interception States - variables.eventManager.appendInterceptionPoints( arrayToList(variables.eventStates) ); + variables.eventManager.appendInterceptionPoints( variables.eventStates ); return this; } // create event manager variables.eventManager = new wirebox.system.core.events.EventPoolManager( variables.eventStates ); - // Debugging - if( variables.log.canDebug() ){ - variables.log.debug( "Registered injector's event manager with the following event states: #variables.eventStates.toString()#" ); - } return this; } @@ -1160,6 +1162,11 @@ component serializable="false" accessors="true" implements="wirebox.system.ioc.I arguments.binder = createObject( "component", arguments.binder ); } + // Inject Environment Support + arguments.binder[ "getSystemSetting" ] = variables.utility.getSystemSetting; + arguments.binder[ "getSystemProperty" ] = variables.utility.getSystemProperty; + arguments.binder[ "getEnv" ] = variables.utility.getEnv; + // Check if data CFC or binder family if( NOT isInstanceOf( arguments.binder, "wirebox.system.ioc.config.Binder" ) ){ // simple data cfc, create native binder and decorate data CFC @@ -1169,7 +1176,7 @@ component serializable="false" accessors="true" implements="wirebox.system.ioc.I properties = arguments.properties ); } else { - // else init the binder and configur it + // else init the binder and configure it var nativeBinder = arguments.binder.init( injector=this, properties=arguments.properties ); // Configure it nativeBinder.configure(); diff --git a/src/cfml/system/wirebox/system/ioc/config/Binder.cfc b/src/cfml/system/wirebox/system/ioc/config/Binder.cfc index 78f56fb6c..b04789c73 100644 --- a/src/cfml/system/wirebox/system/ioc/config/Binder.cfc +++ b/src/cfml/system/wirebox/system/ioc/config/Binder.cfc @@ -390,7 +390,7 @@ Description : // copy parent class's memento instance, exclude alias, name and path for( var mapping in getCurrentMapping() ) { - mapping.processMemento( getMapping( arguments.alias ).getMemento(), "alias,name,path" ); + mapping.processMemento( getMapping( arguments.alias ).getMemento(), "alias,name" ); } return this; @@ -1009,12 +1009,12 @@ Description : return ( !thisMapping.isDiscovered() ); } ).each( function( key, thisMapping ){ try { - // process the metadata - thisMapping.process( binder=this, injector=instance.injector ); - // is it eager? - if( thisMapping.isEagerInit() ){ - instance.injector.getInstance( thisMapping.getName() ); - } + // process the metadata + thisMapping.process( binder=this, injector=instance.injector ); + // is it eager? + if( thisMapping.isEagerInit() ){ + instance.injector.getInstance( thisMapping.getName() ); + } } catch( any e ) { // Remove bad mapping instance.mappings.delete( key ); @@ -1106,4 +1106,4 @@ Description : - \ No newline at end of file + diff --git a/src/cfml/system/wirebox/system/ioc/config/DefaultBinder.cfc b/src/cfml/system/wirebox/system/ioc/config/DefaultBinder.cfc index 5e16ffe29..1f4fa0ab0 100644 --- a/src/cfml/system/wirebox/system/ioc/config/DefaultBinder.cfc +++ b/src/cfml/system/wirebox/system/ioc/config/DefaultBinder.cfc @@ -23,7 +23,7 @@ component extends="wirebox.system.ioc.config.Binder"{ // configFile = "wirebox.system.ioc.config.CacheBox", An optional configuration file to use for loading CacheBox // cacheFactory = "" A reference to an already instantiated CacheBox CacheFactory // classNamespace = "" A class path namespace to use to create CacheBox: Default=wirebox.system.cache or wirebox.system.cache - }, + }, // Name of a CacheBox cache to store metadata in to speed up start time. // Since metadata is already stored in memory, this is only useful for a disk, etc cache that persists across restarts. diff --git a/src/cfml/system/wirebox/system/ioc/config/Mapping.cfc b/src/cfml/system/wirebox/system/ioc/config/Mapping.cfc index 5f90e4765..457905232 100644 --- a/src/cfml/system/wirebox/system/ioc/config/Mapping.cfc +++ b/src/cfml/system/wirebox/system/ioc/config/Mapping.cfc @@ -97,73 +97,78 @@ Description : var x = 1; - var key = ""; // if excludes is passed as an array, convert to list - if(isArray(arguments.excludes)){ - arguments.excludes = arrayToList(arguments.excludes); + if( isArray( arguments.excludes ) ){ + arguments.excludes = arrayToList( arguments.excludes ); } // append incoming memento data - for(key in arguments.memento){ + for( var key in arguments.memento ){ // if current key is in excludes list, skip and continue to next loop - if(listFindNoCase(arguments.excludes, key)){ + if( listFindNoCase( arguments.excludes, key ) ){ continue; } - switch(key){ + switch( key ){ - //process cache properties - case "cache" : - { - setCacheProperties(argumentCollection=arguments.memento.cache ); + // process cache properties + case "cache" : { + setCacheProperties( argumentCollection=arguments.memento.cache ); break; } - //process constructor args - case "DIConstructorArgs" : - { - for(x=1; x lte arrayLen(arguments.memento.DIConstructorArgs); x++){ - addDIConstructorArgument(argumentCollection=arguments.memento.DIConstructorArgs[x] ); + // process constructor args + case "DIConstructorArgs" : { + for( x=1; x lte arrayLen( arguments.memento.DIConstructorArgs ); x++ ){ + addDIConstructorArgument( argumentCollection=arguments.memento.DIConstructorArgs[ x ] ); } break; } - //process properties - case "DIProperties" : - { - for(x=1; x lte arrayLen(arguments.memento.DIProperties); x++){ - addDIProperty(argumentCollection=arguments.memento.DIProperties[x] ); + // process properties + case "DIProperties" : { + for( x=1; x lte arrayLen( arguments.memento.DIProperties ); x++){ + addDIProperty( argumentCollection=arguments.memento.DIProperties[ x ] ); } break; } - //process DISetters + // process DISetters case "DISetters" : { - for(x=1; x lte arrayLen(arguments.memento.DISetters); x++){ - addDISetter(argumentCollection=arguments.memento.DISetters[x] ); + for( x=1; x lte arrayLen( arguments.memento.DISetters ); x++){ + addDISetter( argumentCollection=arguments.memento.DISetters[ x ] ); + } + break; } - break; + + // process DIMethodArgs + case "DIMethodArgs" : { + for( x=1; x lte arrayLen( arguments.memento.DIMethodArgs ); x++){ + addDIMethodArgument( argumentCollection=arguments.memento.DIMethodArgs[ x ] ); + } + break; } - //process DIMethodArgs - case "DIMethodArgs" : - { - for(x=1; x lte arrayLen(arguments.memento.DIMethodArgs); x++){ - addDIMethodArgument(argumentCollection=arguments.memento.DIMethodArgs[x] ); + // process path + case "path" : { + // Only override if it doesn't exist or empty + if( !instance.keyExists( "path" ) OR !len( instance.path ) ){ + instance[ "path" ] = arguments.memento[ "path" ]; } break; } default:{ - instance[key] = arguments.memento[key]; + instance[ key ] = arguments.memento[ key ]; + break; } }// end switch - } + return this; @@ -389,8 +394,8 @@ Description : var x = 1; // check if already registered, if it is, just return for(x=1; x lte arrayLen(instance.DIConstructorArgs); x++){ - if( structKeyExists( arguments, "name" ) AND structKeyExists( instance.DIConstructorArgs[x], "name" ) AND - instance.DIConstructorArgs[x].name eq arguments.name ){ return this;} + if( structKeyExists( arguments, "name" ) AND structKeyExists( instance.DIConstructorArgs[ x ], "name" ) AND + instance.DIConstructorArgs[ x ].name eq arguments.name ){ return this;} } // Register new constructor argument. structAppend(def, arguments, true); @@ -414,8 +419,8 @@ Description : var x = 1; // check if already registered, if it is, just return for(x=1; x lte arrayLen(instance.DIMethodArgs); x++){ - if( structKeyExists(instance.DIMethodArgs[x],"name") AND - instance.DIMethodArgs[x].name eq arguments.name ){ return this;} + if( structKeyExists(instance.DIMethodArgs[ x ],"name") AND + instance.DIMethodArgs[ x ].name eq arguments.name ){ return this;} } structAppend(def, arguments, true); arrayAppend( instance.DIMethodArgs, def ); @@ -475,7 +480,7 @@ Description : // check if already registered, if it is, just return for(x=1; x lte arrayLen(instance.DISetters); x++){ - if( instance.DISetters[x].name eq arguments.name ){ return this;} + if( instance.DISetters[ x ].name eq arguments.name ){ return this;} } // Remove scope for setter injection def.scope = ""; @@ -597,7 +602,7 @@ Description : } else{ var produceMetadataUDF = function() { return injector.getUtil().getInheritedMetaData(instance.path, binder.getStopRecursions()); }; - + // Are we caching metadata? if( len( binder.getMetadataCache() ) ) { // Get from cache or produce on demand @@ -666,7 +671,7 @@ Description : instance.alias.addAll( thisAliases ); // register alias references on binder for(x=1; x lte arrayLen(thisAliases); x++){ - mappings[ thisAliases[x] ] = this; + mappings[ thisAliases[ x ] ] = this; } } @@ -825,22 +830,22 @@ Description : // Loop over each property and identify injectable properties for(x=1; x lte ArrayLen(md.properties); x=x+1 ){ // Check if property not discovered or if inject annotation is found - if( structKeyExists(md.properties[x],"inject") ){ + if( structKeyExists(md.properties[ x ],"inject") ){ // prepare default params, we do this so we do not alter the md as it is cached by cf params = { - scope="variables", inject="model", name=md.properties[x].name, required=true, type="any" + scope="variables", inject="model", name=md.properties[ x ].name, required=true, type="any" }; // default property type if( structKeyExists( md.properties[ x ], "type" ) ){ params.type = md.properties[ x ].type; } // default injection scope, if not found in object - if( structKeyExists(md.properties[x],"scope") ){ - params.scope = md.properties[x].scope; + if( structKeyExists(md.properties[ x ],"scope") ){ + params.scope = md.properties[ x ].scope; } // Get injection if it exists - if( len(md.properties[x].inject) ){ - params.inject = md.properties[x].inject; + if( len(md.properties[ x ].inject) ){ + params.inject = md.properties[ x ].inject; } // Get required if( structKeyExists( md.properties[ x ], "required" ) and isBoolean( md.properties[ x ].required ) ){ @@ -860,33 +865,33 @@ Description : // Verify Processing or do we continue to next iteration for processing // This is to avoid overriding by parent trees in inheritance chains - if( structKeyExists(arguments.dependencies, md.functions[x].name) ){ + if( structKeyExists(arguments.dependencies, md.functions[ x ].name) ){ continue; } // Constructor Processing if found - if( md.functions[x].name eq instance.constructor ){ + if( md.functions[ x ].name eq instance.constructor ){ // Loop Over Arguments to process them for dependencies - for(y=1;y lte arrayLen(md.functions[x].parameters); y++){ + for(y=1;y lte arrayLen(md.functions[ x ].parameters); y++){ // prepare params as we do not alter md as cf caches it params = { - required = false, inject="model", name=md.functions[x].parameters[y].name, type="any" + required = false, inject="model", name=md.functions[ x ].parameters[y].name, type="any" }; // check type annotation if( structKeyExists( md.functions[ x ].parameters[ y ], "type" ) ){ params.type = md.functions[ x ].parameters[ y ].type; } // Check required annotation - if( structKeyExists(md.functions[x].parameters[y], "required") ){ - params.required = md.functions[x].parameters[y].required; + if( structKeyExists(md.functions[ x ].parameters[y], "required") ){ + params.required = md.functions[ x ].parameters[y].required; } // Check injection annotation, if not found then no injection - if( structKeyExists(md.functions[x].parameters[y],"inject") ){ + if( structKeyExists(md.functions[ x ].parameters[y],"inject") ){ // Check if inject has value, else default it to 'model' or 'id' namespace - if( len(md.functions[x].parameters[y].inject) ){ - params.inject = md.functions[x].parameters[y].inject; + if( len(md.functions[ x ].parameters[y].inject) ){ + params.inject = md.functions[ x ].parameters[y].inject; } // ADD Constructor argument @@ -898,34 +903,34 @@ Description : } // add constructor to found list, so it is processed only once in recursions - arguments.dependencies[md.functions[x].name] = "constructor"; + arguments.dependencies[md.functions[ x ].name] = "constructor"; } // Setter discovery, MUST be inject annotation marked to be processed. - if( left(md.functions[x].name,3) eq "set" AND structKeyExists(md.functions[x],"inject")){ + if( left(md.functions[ x ].name,3) eq "set" AND structKeyExists(md.functions[ x ],"inject")){ // setup setter params in order to avoid touching the md struct as cf caches it - params = {inject="model",name=right(md.functions[x].name, Len(md.functions[x].name)-3)}; + params = {inject="model",name=right(md.functions[ x ].name, Len(md.functions[ x ].name)-3)}; // Check DSL marker if it has a value else use default of Model - if( len(md.functions[x].inject) ){ - params.inject = md.functions[x].inject; + if( len(md.functions[ x ].inject) ){ + params.inject = md.functions[ x ].inject; } // Add to setter to mappings and recursion lookup addDISetter(name=params.name,dsl=params.inject); - arguments.dependencies[md.functions[x].name] = "setter"; + arguments.dependencies[md.functions[ x ].name] = "setter"; } // Provider Methods Discovery - if( structKeyExists( md.functions[x], "provider") AND len(md.functions[x].provider)){ - addProviderMethod(md.functions[x].name, md.functions[x].provider); - arguments.dependencies[md.functions[x].name] = "provider"; + if( structKeyExists( md.functions[ x ], "provider") AND len(md.functions[ x ].provider)){ + addProviderMethod(md.functions[ x ].name, md.functions[ x ].provider); + arguments.dependencies[md.functions[ x ].name] = "provider"; } // onDIComplete Method Discovery - if( structKeyExists( md.functions[x], "onDIComplete") ){ - arrayAppend(instance.onDIComplete, md.functions[x].name ); - arguments.dependencies[md.functions[x].name] = "onDIComplete"; + if( structKeyExists( md.functions[ x ], "onDIComplete") ){ + arrayAppend(instance.onDIComplete, md.functions[ x ].name ); + arguments.dependencies[md.functions[ x ].name] = "onDIComplete"; } }//end loop of functions diff --git a/src/cfml/system/wirebox/system/logging/LogBox.cfc b/src/cfml/system/wirebox/system/logging/LogBox.cfc index 05aa59c15..1da0d56d9 100644 --- a/src/cfml/system/wirebox/system/logging/LogBox.cfc +++ b/src/cfml/system/wirebox/system/logging/LogBox.cfc @@ -11,7 +11,7 @@ */ component accessors="true"{ - + /** * The LogBox unique ID */ @@ -21,12 +21,12 @@ component accessors="true"{ * The LogBox operating version */ property name="version"; - + /** * The appender registration map */ property name="appenderRegistry" type="struct"; - + /** * The Logger registration map */ @@ -66,8 +66,8 @@ component accessors="true"{ // Category Appenders variables.categoryAppenders = ""; // Version - variables.version = "5.0.0-snapshot"; - + variables.version = "5.1.4+741"; + // Link incoming ColdBox argument variables.coldbox = arguments.coldbox; @@ -79,7 +79,7 @@ component accessors="true"{ /** * Configure logbox for operation. You can also re-configure LogBox programmatically. Basically we register all appenders here and all categories - * + * * @config The LogBoxConfig object to use to configure this instance of LogBox: wirebox.system.logging.config.LogBoxConfig * @config.doc_generic wirebox.system.logging.config.LogBoxConfig */ @@ -109,7 +109,7 @@ component accessors="true"{ levelMax = rootConfig.levelMax, appenders = getAppendersMap( rootConfig.appenders ) }; - + //Save in Registry variables.loggerRegistry = { "ROOT" = new wirebox.system.logging.Logger( argumentCollection=args ) @@ -119,7 +119,7 @@ component accessors="true"{ /** * Get the root logger object - * + * * @return wirebox.system.logging.Logger */ function getRootLogger(){ @@ -128,16 +128,16 @@ component accessors="true"{ /** * Get a logger object configured with a category name and appenders. If not configured, then it reverts to the root logger defined for this instance of LogBox - * + * * @category The category name to use in this logger or pass in the target object will log from and we will inspect the object and use its metadata name - * + * * @return wirebox.system.logging.Logger */ function getLogger( required category ){ var root = getRootLogger(); // is category object? - if( isObject( arguments.category ) ){ + if( isObject( arguments.category ) ){ arguments.category = getMetadata( arguments.category ).name; } @@ -202,7 +202,7 @@ component accessors="true"{ /** * Register a new appender object in the appender registry. - * + * * @name A unique name for the appender to register. Only unique names can be registered per variables. * @class The appender's class to register. We will create, init it and register it for you. * @properties The structure of properties to configure this appender with. @@ -222,9 +222,9 @@ component accessors="true"{ if( !structKeyExists( variables.appenderRegistry, arguments.name ) ){ lock name="#variables.logboxID#.registerappender.#name#" type="exclusive" timeout="15" throwOnTimeout="true"{ - + if( !structKeyExists( variables.appenderRegistry, arguments.name ) ){ - + // Create appender and linking var oAppender = new "#arguments.class#"( argumentCollection=arguments ); oAppender.setColdBox( variables.coldbox ); @@ -247,7 +247,7 @@ component accessors="true"{ /** * Get a parent logger according to category convention inheritance. If not found, it returns the root logger. - * + * * @category The category name to investigate for parents */ private function locateCategoryParentLogger( required category ){ @@ -278,20 +278,24 @@ component accessors="true"{ /** * Get a map of appenders by list. Usually called to get a category of appenders - * + * * @appenders The list of appenders to get */ struct function getAppendersMap( required appenders ){ var results = arguments.appenders .listToArray() .reduce( function( result, item, index ){ - var target = result ?: structNew(); + var target = {}; + if( !isNull( arguments.result ) ){ + target = result; + } target[ item ] = variables.appenderRegistry[ item ]; return target; } ); - return results ?: structnew(); + + return ( isNull( results ) ? structNew() : results ); } - + /** * Get Utility Object */ diff --git a/src/java/cliloader/Util.java b/src/java/cliloader/Util.java index 97c6c7da7..fd7f01547 100644 --- a/src/java/cliloader/Util.java +++ b/src/java/cliloader/Util.java @@ -5,12 +5,12 @@ * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library. */ @@ -104,16 +104,16 @@ public static void ensureJavaVersion(){ Thread.sleep( 5000 ); System.exit( 1 ); } - + String jVer = System.getProperty("java.version"); if( jVer.startsWith( "9" ) || jVer.startsWith( "10" ) || jVer.startsWith( "11" ) ) { System.out.println( "It looks like you're using Java 9, 10, or higher, which CommandBox doesn't support!" ); - System.out.println( "If your PC needs this version of Java installed, then place a folder called 'JRE' with Java 8 in the same direcotry as your box binary." ); + System.out.println( "If your PC needs this version of Java installed, then place a folder called 'JRE' with Java 8 in the same directory as your box binary." ); System.out.println( "We'll be working on Java 9+ support soon!" ); Thread.sleep( 5000 ); System.exit( 1 ); } - + } catch ( java.lang.ClassNotFoundException e ) { System.out.println( "Could not load NIO! Are we running on Java 7 or 8? Sorry, exiting..." ); @@ -263,7 +263,7 @@ public static void checkIfJarsLocked( File libDir, String nameContains ){ Thread.sleep( 5000 ); System.exit( 1 ); } - + } catch ( Exception e ) { System.err.println( "" ); System.err.println( "CommandBox is having problems deleting your previous jars to complete the upgrade." ); @@ -291,7 +291,7 @@ public static void removePreviousLibs( File libDir ){ Thread.sleep( 5000 ); System.exit( 1 ); } - + } catch ( Exception e ) { System.err.println( "" ); System.err.println( "CommandBox could not delete the jar [" + previous.getAbsolutePath() + "]" ); @@ -418,7 +418,7 @@ public static int writeStreamTo( final InputStream input, } return answer; } - + public static void deleteDirectory(File f) throws IOException { if (f.isDirectory()) { for (File c : f.listFiles()) @@ -427,5 +427,5 @@ public static void deleteDirectory(File f) throws IOException { if (!f.delete()) throw new FileNotFoundException("Failed to delete file: " + f); } - + }