var inputParameters = application.ADF.data.duplicateStruct(arguments.parameters); var currentValue = arguments.value; // the field's current value var layoutOptions = ArrayNew(1); var newOption = structNew(); var currOptionName = ''; var i = 0; var pageLayoutScript = ""; var pageLayoutData = StructNew(); var vFilePath = "ram://#arguments.fieldName#_page_layout_options.ini"; var v = 1; var vFieldCnt = 0; var vFieldData = StructNew(); var vFld = ""; var bCnt = 0; var fKey = 0; var groupsAPI = Server.CommonSpot.ObjectFactory.getObject("Groups"); var groupQry = groupsAPI.getNamesGivenIDs(request.user.GroupList); var userGroupName = ""; var userGroupNameFix = ""; var q = 1; var defaultData = StructNew(); var renderedData = StructNew(); var renderedErrors = ArrayNew(1); var fld = ""; var cfgFieldLabel = ""; var opt = ""; var cfgOptionValue = ""; var cfgOptionName = ""; var securityGroups = ""; var thumbImgPath = ""; var currentPageID = StructKeyExists(request.params,"pageID") ? request.params.pageid : structKeyExists(request.page,"id") ? request.page.id : 0; var allowedPageIDlist = ""; // Layout by Layout setting var disabledPageIDlist = ""; // All Layouts Setting ( overrides allowedPageIDList ) var addLayoutOption = false; var hideAllLayoutOptions = false; inputParameters = setDefaultParameters(argumentCollection=arguments); if ( StructKeyExists(inputParameters,"pageLayoutScript") ) pageLayoutScript = inputParameters.pageLayoutScript; // Write INI config data to a RAM Disk File FileWrite(vFilePath,pageLayoutScript); // Read the INI config data from RAM and serialize it into a Structure pageLayoutData = parseINI(vFilePath); // Loop over the pageLayoutData built from the INI config data if ( !StructIsEmpty(pageLayoutData) AND StructKeyExists(pageLayoutData,"config") ) { // Are disabledPages been configured? if ( StructKeyExists(pageLayoutData.config,"DisabledPages") AND LEN(TRIM(pageLayoutData.config.DisabledPages)) ) disabledPageIDlist = pageLayoutData.config.DisabledPages; if ( ListFind(disabledPageIDlist, currentPageID) GT 0 ) hideAllLayoutOptions = true; //WriteDump(var=hideAllLayoutOptions,expand=false,label="hideAllLayoutOptions"); if ( StructKeyExists(pageLayoutData.config,"ImagesPath") AND LEN(TRIM(pageLayoutData.config.ImagesPath)) ) thumbImgPath = pageLayoutData.config.ImagesPath; if ( StructKeyExists(pageLayoutData.config,"Options") AND LEN(TRIM(pageLayoutData.config.Options)) ) { for ( v=1; v LTE ListLen(pageLayoutData.config.Options); v=v+1 ) { // Set the add to false for each interation addLayoutOption = false; // Get the List Item vFld = ListGetAt(pageLayoutData.config.Options,v); // Make sure it has underscores instead of spaces vFld = TRIM(REREPLACE(vFld,"[\s]","_","all")); //WriteDump(var=vFld,expand=false,label="vFld"); if ( StructKeyExists(pageLayoutData,vFld) AND IsStruct(pageLayoutData[vFld]) ) { // Add the name Key with the Option value pageLayoutData[vFld]["name"] = vFld; // If a full ["imageUrl"] has been define for this item ... use it. // Although if an ["image"] parameter is passed in will override the defined ["imageURL"] // - so create the imageURL from the imagePath and image values if ( StructKeyExists(pageLayoutData[vFld],"image") AND LEN(TRIM(pageLayoutData[vFld]["image"])) ) pageLayoutData[vFld]["imageUrl"] = thumbImgPath & pageLayoutData[vFld]["image"]; // But after all that... set an imageURL to empty string if an imageURL has not been created (or passed in) if ( !StructKeyExists(pageLayoutData[vFld],"imageUrl") ) pageLayoutData[vFld]["imageUrl"] = ""; // Check for security settings to show or hide specific layout options securityGroups = ""; if ( StructKeyExists(pageLayoutData[vFld],"security") AND LEN(TRIM(pageLayoutData[vFld]["security"])) ) securityGroups = pageLayoutData[vFld]["security"]; else if ( StructKeyExists(pageLayoutData[vFld],"allowedgroups") AND LEN(TRIM(pageLayoutData[vFld]["allowedgroups"])) ) securityGroups = pageLayoutData[vFld]["allowedgroups"]; if ( LEN(TRIM(securityGroups)) ) { // Do the Group Check for the currently logged in user userGroupName = ""; for ( q=1; q LTE groupQry.RecordCount; q=q+1 ) { userGroupName = TRIM(LCASE(groupQry.name[q])); userGroupNameFix = TRIM(LCASE(REREPLACE(groupQry.name[q],"[\s]","_","all"))); if( ListFindNoCase(securityGroups, userGroupName) OR ListFindNoCase(securityGroups, userGroupNameFix) ) { addLayoutOption = true; break; } } } else if ( StructKeyExists(pageLayoutData[vFld],"allowedpages") AND LEN(TRIM(pageLayoutData[vFld]["allowedpages"])) ) { allowedPageIDlist = pageLayoutData[vFld]["allowedpages"]; if ( ListFind(allowedPageIDlist, currentPageID) ) addLayoutOption = true; } else addLayoutOption = true; if ( addLayoutOption ) ArrayAppend(layoutOptions,pageLayoutData[vFld]); } } } } //WriteDump(currentValue); //WriteDump(pageLayoutScript); //WriteDump(currentPageID); //WriteDump(var=request.params,expand=false,label="params"); //WriteDump(var=pageLayoutData,expand=false,label="pageLayoutData"); //WriteDump(var=vFieldData,expand=false,label="vFieldData"); //WriteDump(var=vFieldCnt,expand=false,label="vFieldCnt"); //WriteDump(var=layoutOptions,expand=false,label="layoutOptions"); renderStyles(argumentCollection=arguments); renderJSFunctions(argumentCollection=arguments);
Layout options are not avaiable for this page.

var cftHeaderCSS = ''; application.ADF.scripts.addHeaderCSS(cftHeaderCSS,"TERTIARY"); var cftFooterJS = ''; application.ADF.scripts.addFooterJS(cftFooterJS,"TERTIARY"); var inputParameters = duplicate(arguments.parameters); if ( NOT StructKeyExists(inputParameters, "layoutScript") ) inputParameters.layoutScript = ""; // Validate if the property field has been defined if ( NOT StructKeyExists(inputParameters, "fldID") OR LEN(inputParameters.fldID) LTE 0 ) inputParameters.fldID = arguments.fieldName; return inputParameters; /* parseINI(iniPath) Parses a textfile in the INI format and returns a structure of variables grouped by sections */ public struct function parseINI(iniPath) { try { var retData = {}; var prop = ""; var section = ""; var sections = getProfileSections(arguments.iniPath); // If there are no sections in the ini file, return a single level struct of name=value pairs if ( StructIsEmpty(sections) ) { return parseSimpleINI(iniPath=arguments.iniPath); } for (section in sections) { retData[section] = {}; for (prop in listToArray(sections[section])) { // PT GAC - Make sure props that start with pounds are not included if ( Left(prop,1) NEQ "##" ) retData[section][prop] = getProfileString(arguments.iniPath, section, prop); } } return retData; } catch( java.io.FileNotFoundException e ) { throw(type="layout_configurator.parseINI.filenotfound", message="Ini file not found in path '#arguments.iniPath#'"); } catch (any e) { throw(type="layout_configurator.parseINI.error", message=e.getMessage()); } } /* parseSimpleINI Parses a simple INI file that contains name=value pairs with no sections and returns a single level struct */ private struct function parseSimpleINI(iniPath) { var iniFile = FileOpen(arguments.iniPath, "read", "utf-8"); var line = ""; var retData = {}; while( !FileIsEOF(iniFile) ) { line = fileReadLine(iniFile); // Ignore empty (spacer) lines, as well as comment lines (;) if (len(line) && left(trim(line), 1) != ";") { retData[trim(listFirst(line, "="))] = trim(listLast(line, "=")); } } FileClose(iniFile); return retData; } // Requires a Build of CommonSpot 10 higher than 10.0.0.313 public numeric function getMinHeight() { if (structKeyExists(arguments.parameters, "heightValue") && isNumeric(arguments.parameters.heightValue) && arguments.parameters.heightValue > 0) return arguments.parameters.heightValue; // always px return 0; } // Requires a Build of CommonSpot 10 higher than 10.0.0.313 public numeric function getMinWidth() { if ( structKeyExists(arguments.parameters, "widthValue") && isNumeric(arguments.parameters.widthValue) && arguments.parameters.widthValue > 0) return arguments.parameters.widthValue + 160; // 150 is default label width, plus some slack // always px return 0; } private boolean function isMultiline() { return true; } /* IMPORTANT: Since loadResourceDependencies() is using ADF.scripts loadResources methods, getResourceDependencies() and loadResourceDependencies() must stay in sync by accounting for all of required resources for this Custom Field Type. */ public void function loadResourceDependencies() { // Load registered Resources via the ADF scripts_2_0 application.ADF.scripts.loadJQuery(noConflict=true); } public string function getResourceDependencies() { return "jQuery"; }