application.ADF.scripts.loadJQuery(noConflict=true); application.ADF.scripts.loadJQueryUI(); application.ADF.scripts.loadFontAwesome(); //application.ADF.scripts.loadJQueryHighlightTextArea(); // Variable for the version of the field - Display in Props UI. fieldVersion = "1.2.4"; // initialize some of the attributes variables typeid = attributes.typeid; prefix = attributes.prefix; formname = attributes.formname; currentValues = attributes.currentValues; fieldID = ''; formID = attributes.formid; elementFormName = ""; fieldPropsEnabled = false; widgetScriptEditorEnabled = false; widgetScriptDirExists = false; errorMsg = ""; siteDir = request.site.dir; /* WidgetScript INI folder Defaults */ widgetDefaultName = ""; widgetDefaultDir = "/_cs_widgets"; widgetConfigDir = "/config"; /* WidgetScript INI file Defaults */ scriptFileExt = "ini"; scriptFileName = ""; scriptFileNameCustom = ""; scriptFilePath = ""; fullScriptDir = ""; fullScriptPath = ""; fullScriptPathCustom = ""; fullScriptName = ""; fullScriptNameCustom = ""; // Is this a valid dlgType? switch (dlgtype) { case 'customelement': case 'metadata': fieldPropsEnabled = true; break; default: fieldPropsEnabled = false; } if ( fieldPropsEnabled ) { // Is this a new field? if ( StructKeyExists(attributes,"fieldid") AND IsNumeric(attributes.fieldid) AND attributes.fieldid GT 0 ) fieldid = attributes.fieldid; // If fieldid is a valid number or is greater than 0 we can enable the widget script editor if ( IsNumeric(fieldid) AND fieldid GT 0 ) widgetScriptEditorEnabled = true; // Get the Element Form Name for the specific form type elementFormName = getElementFormName(elementType=dlgtype,formID=attributes.formid); if ( LEN(TRIM(elementFormName)) EQ 0 ) { errorMsg = "The Element Form name could not be resolved from provided Form ID!"; fieldPropsEnabled = false; } else { // Build the Widget defualt name widgetDefaultName = LCASE(TRIM(REREPLACENOCASE(elementFormName,"[^A-Za-z0-9]","-","all"))); // Build the Widget default script path widgetScriptDefaultDir = widgetDefaultDir & "/" & widgetDefaultName & widgetConfigDir & "/"; fieldPropsEnabled = true; } } //Setup the default values defaultValues = StructNew(); defaultValues.widgetScriptDirPath = widgetScriptDefaultDir; defaultValues.widgetScriptDirStatus = ""; defaultValues.widgetScript = defaultScriptText(); defaultValues.widgetScriptStatus = ""; // Check if widgetScriptDirPath is defined and matches the default value if ( StructKeyExists(currentValues,"widgetScriptDirPath") ) { // Clear the saved Dir STATUS value if ( StructKeyExists(currentValues,"widgetScriptDirStatus") ) currentValues.widgetScriptDirStatus = ""; if ( LEN(TRIM(currentValues.widgetScriptDirPath)) EQ 0 ) { defaultValues.widgetScriptDirStatus = "new"; widgetScriptEditorEnabled = false; } else if ( currentValues.widgetScriptDirPath EQ defaultValues.widgetScriptDirPath ) defaultValues.widgetScriptDirStatus = "default"; else defaultValues.widgetScriptDirStatus = "custom"; } else { defaultValues.widgetScriptDirStatus = "new"; widgetScriptEditorEnabled = false; } //This will override the default values with the current values. //In normal use this should not need to be modified. currentValueArray = StructKeyArray(currentValues); for(i=1;i<=ArrayLen(currentValueArray);i++){ //If there is a default value set AND there is a current value set update the default value with the current value if ( StructKeyExists(defaultValues,currentValueArray[i]) ) { defaultValues[currentValueArray[i]] = currentValues[currentValueArray[i]]; } } if ( fieldPropsEnabled ) { if ( widgetScriptEditorEnabled ) { // Build the WidgetScript config file name form the Form Name scriptFileName = widgetDefaultName & "-" & attributes.fieldid; scriptFileNameCustom = scriptFileName & "_custom"; // Build the INI file for Widget Configuration Form Fields scriptFilePath = defaultValues.widgetScriptDirPath; if ( Left(scriptFilePath,1) EQ "/" ) siteDir = reReplace(request.site.dir,"/$",""); if ( Right(scriptFilePath,1) NEQ "/" ) scriptFilePath = scriptFilePath & "/"; fullScriptDir = siteDir & scriptFilePath; fullScriptName = scriptFileName & "." & scriptFileExt; fullScriptPath = siteDir & scriptFilePath & fullScriptName; fullScriptNameCustom = scriptFileNameCustom & "." & scriptFileExt; fullScriptPathCustom = siteDir & scriptFilePath & fullScriptNameCustom; // Check if Directory Exists if ( DirectoryExists(fullScriptDir) ) widgetScriptDirExists = true; // If the INI file does not exist, create it and the folders needed if ( !FileExists(fullScriptPath) ) { if ( StructKeyExists(currentValues,"widgetScript") ) fileWriteData = fixSavedDataFileSectionBrackets(str=defaultValues.widgetScript); else fileWriteData = fixDefaultDataFileSectionBrackets(str=defaultValues.widgetScript); fileWriteStatus = application.ADF.utils.writeINIfile(filePath=fullScriptPath,dataString=fileWriteData,overwrite=false,charSet="utf-8"); } defaultValues.widgetScript = FileRead(fullScriptPath,"utf-8"); defaultValues.widgetScript = fixDisplaySectionBrackets(str=defaultValues.widgetScript); } else { // This Field is new... so display the default WigetScript syntax // - Unless currentValues contains some existing widgetScript info if ( !StructKeyExists(currentValues,"widgetScript") ) defaultValues.widgetScript = defaultScriptText(); } // Get the cfmlEngine type cfmlEngine = server.coldfusion.productname; if ( !FindNoCase(cfmlEngine,'ColdFusion Server') ) { // For Lucee Inject Extra linebreaks before each open bracket (since the textarea removes them) //defaultValues.widgetScript = REReplace(defaultValues.widgetScript, "(\r\n|\n\r|\n|\r)(\[)","&##013;&##010;&##013;&##010;[", "all"); /* &##013;&##010; */ //defaultValues.widgetScript = REReplace(defaultValues.widgetScript, "(\r\n|\n\r|\n|\r)(##\[)","&##013;&##010;&##013;&##010;##[", "all"); /* &##013;&##010; */ } } application.ADF.scripts.addHeaderCSS(cftWidgetConfigCSS,"TERTIARY"); application.ADF.scripts.addFooterJS(cftWidgetConfigJS,"TERTIARY");
Enter the relative path to this Widget's config directory.
Example: /_cs_widgets/{widget-name}/config/
Note: The required folders will be created if they don't already exist.
 
Save the WidgetScript Directory relative path above and reopen this dialog
to edit the WidgetScript syntax for this widget!
Override File: #fullScriptNameCustom#
Enter the WidgetScript Syntax used to generate the Widget's Option Fields configuration file.
WidgetScript Syntax Help:
- Use semi-colons (;) to delimit options. eg. optionvalue1;optionvalue2;optionvalue3
- Use pipes (|) to delimit value/label pairs. eg. optionvalue1|Option Label 1;optionvalue2|Option Label 2
Save the WidgetScript Directory relative path above and reopen this dialog
to add the WidgetScript syntax for this widget!
 

ADF Custom Field v#fieldVersion#
This Field is not compatible with this Form type!
#errorMsg#
var retStr = ""; var infoObj = ''; var infoObjType = ''; var argData = StructNew(); var infoData = ''; var infoMethod = ''; var argName = ''; var infoDataKey = ''; var validFormType = false; switch (arguments.elementType) { case 'customelement': infoObjType = "CustomElement"; infoMethod = "getInfo"; argName = "elementID"; infoDataKey = "name"; validFormType = true; break; case 'metadata': infoObjType = 'MetadataForm'; infoMethod = "getForms"; argName = "ID"; infoDataKey = "formName"; validFormType = true; break; case 'simpleform': // this is here so we remember this dlgtype validFormType = false; break; default: validFormType = false; } if ( validFormType ) { argData[argName] = arguments.formid; infoObj = Server.CommonSpot.ObjectFactory.getObject(infoObjType); // Get the Element Info based on element type infoData = getElementInfo(objType=infoObjType,methodName=infoMethod,args=argData); if ( StructKeyExists(infoData,infoDataKey) ) retStr = infoData[infoDataKey]; } return retStr; var result = ''; var methodResult = ""; var infoObj = ''; var allowedElementTypes = "CustomElement,MetadataForm"; var allowedMethods = "getInfo,getForms"; var methodAllowed = false; if ( ListFind(allowedElementTypes,arguments.objType) ) { infoObj = Server.CommonSpot.ObjectFactory.getObject(arguments.objType); methodAllowed = true; } else methodAllowed = false; if ( methodAllowed AND ListFind(allowedMethods,arguments.methodName) ) methodAllowed = true; else methodAllowed = false; [Config] fields=Theme [Theme] group_all= default= // Get the cfmlEngine type var cfmlEngine = server.coldfusion.productname; if ( !FindNoCase(cfmlEngine,'ColdFusion Server') ) { arguments.str = REReplace(arguments.str, "(\r\n|\n\r|\n|\r)(\[)","&##013;&##010;[", "all"); arguments.str = REReplace(arguments.str, "(\r\n|\n\r|\n|\r)(##\[)","&##013;&##010;##[", "all"); } return arguments.str; // Get the cfmlEngine type var cfmlEngine = server.coldfusion.productname; if ( !FindNoCase(cfmlEngine,'ColdFusion Server') ) { arguments.str = REReplace(arguments.str, "(\r\n|\n\r|\n|\r)(\[)","#CHR(13)##CHR(10)#[", "all"); arguments.str = REReplace(arguments.str, "(\r\n|\n\r|\n|\r)(##\[)","#CHR(13)##CHR(10)###[", "all"); } return arguments.str; // Get the cfmlEngine type var cfmlEngine = server.coldfusion.productname; if ( !FindNoCase(cfmlEngine,'ColdFusion Server') ) { arguments.str = REReplace(arguments.str, "(\r\n|\n\r|\n|\r)(\[)","#CHR(13)##CHR(10)##CHR(13)##CHR(10)#[", "all"); arguments.str = REReplace(arguments.str, "(\r\n|\n\r|\n|\r)(##\[)","#CHR(13)##CHR(10)##CHR(13)##CHR(10)###[", "all"); } return arguments.str;