/// <summary> /// Create a content metadata field with all default values /// </summary> /// <param name="fieldName"></param> /// <returns></returns> public static ContentFieldMetadataModel createDefault(CoreController core, string fieldName, CPContentBaseClass.FieldTypeIdEnum fieldType) { var fieldMeta = new ContentFieldMetadataModel { active = true, adminOnly = false, authorable = true, blockAccess = false, caption = fieldName, contentId = 0, developerOnly = false, editSortPriority = 9999, editTabName = "", fieldTypeId = fieldType, htmlContent = false, indexColumn = 0, indexSortDirection = 0, indexSortOrder = 0, indexWidth = "", installedByCollectionGuid = "", isBaseField = false, lookupContentId = 0, lookupList = "", manyToManyContentId = 0, manyToManyRuleContentId = 0, manyToManyRulePrimaryField = "", manyToManyRuleSecondaryField = "", password = false, readOnly = false, redirectContentId = 0, redirectId = "", redirectPath = "", required = false, scramble = false, textBuffered = false, uniqueName = false }; fieldMeta.memberSelectGroupId_set(core, 0); fieldMeta.nameLc = fieldName.ToLowerInvariant(); fieldMeta.set_redirectContentName(core, ""); fieldMeta.set_manyToManyContentName(core, ""); fieldMeta.set_manyToManyRuleContentName(core, ""); return(fieldMeta); }
// //======================================================================== /// <summary> /// verify a fieldmetadata fields (ccfields) exists, given a real database field. Verifies the ccfield record /// </summary> /// <param name="contentName"></param> /// <param name="fieldName"></param> /// <param name="ADOFieldType"></param> public static void verifyContentFieldFromSqlTableField(CoreController core, ContentMetadataModel contentMetadata, string fieldName, int ADOFieldType) { try { // string logMsgContext = "Verifying content field from db field data, [" + fieldName + "] in table [" + contentMetadata.tableName + "]"; // ContentFieldMetadataModel field = new ContentFieldMetadataModel { fieldTypeId = core.db.getFieldTypeIdByADOType(ADOFieldType), caption = fieldName, editSortPriority = 1000, readOnly = false, authorable = true, adminOnly = false, developerOnly = false, textBuffered = false, htmlContent = false, contentId = contentMetadata.id }; // switch (GenericController.toUCase(fieldName)) { // // --- Core fields // case "NAME": field.caption = "Name"; field.editSortPriority = 100; break; case "ACTIVE": field.caption = "Active"; field.editSortPriority = 200; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.Boolean; field.defaultValue = "1"; break; case "DATEADDED": field.caption = "Created"; field.readOnly = true; field.editSortPriority = 5020; break; case "CREATEDBY": field.caption = "Created By"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.Lookup; field.set_lookupContentName(core, "Members"); field.readOnly = true; field.editSortPriority = 5030; break; case "MODIFIEDDATE": field.caption = "Modified"; field.readOnly = true; field.editSortPriority = 5040; break; case "MODIFIEDBY": field.caption = "Modified By"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.Lookup; field.set_lookupContentName(core, "Members"); field.readOnly = true; field.editSortPriority = 5050; break; case "ID": field.caption = "Number"; field.readOnly = true; field.editSortPriority = 5060; field.authorable = true; field.adminOnly = false; field.developerOnly = true; break; case "CONTENTCONTROLID": field.caption = "Content Definition"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.Lookup; field.set_lookupContentName(core, "Content"); field.editSortPriority = 5070; field.authorable = true; field.readOnly = false; field.adminOnly = true; field.developerOnly = true; break; case "CREATEKEY": field.caption = "CreateKey"; field.readOnly = true; field.editSortPriority = 5080; field.authorable = false; // // --- fields related to body content // break; case "HEADLINE": field.caption = "Headline"; field.editSortPriority = 1000; field.htmlContent = false; break; case "DATESTART": field.caption = "Date Start"; field.editSortPriority = 1100; break; case "DATEEND": field.caption = "Date End"; field.editSortPriority = 1200; break; case "PUBDATE": field.caption = "Publish Date"; field.editSortPriority = 1300; break; case "ORGANIZATIONID": field.caption = "Organization"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.Lookup; field.set_lookupContentName(core, "Organizations"); field.editSortPriority = 2005; field.authorable = true; field.readOnly = false; break; case "COPYFILENAME": field.caption = "Copy"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.FileHTML; field.textBuffered = true; field.editSortPriority = 2010; break; case "BRIEFFILENAME": field.caption = "Overview"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.FileHTML; field.textBuffered = true; field.editSortPriority = 2020; field.htmlContent = false; break; case "IMAGEFILENAME": field.caption = "Image"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.File; field.editSortPriority = 2040; break; case "THUMBNAILFILENAME": field.caption = "Thumbnail"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.File; field.editSortPriority = 2050; break; case "CONTENTID": field.caption = "Content"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.Lookup; field.set_lookupContentName(core, "Content"); field.readOnly = false; field.editSortPriority = 2060; // // --- Record Features // break; case "PARENTID": field.caption = "Parent"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.Lookup; field.set_lookupContentName(core, contentMetadata.name); field.readOnly = false; field.editSortPriority = 3000; break; case "MEMBERID": field.caption = "Member"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.Lookup; field.set_lookupContentName(core, "Members"); field.readOnly = false; field.editSortPriority = 3005; break; case "CONTACTMEMBERID": field.caption = "Contact"; field.fieldTypeId = CPContentBaseClass.FieldTypeIdEnum.Lookup; field.set_lookupContentName(core, "Members"); field.readOnly = false; field.editSortPriority = 3010; break; case "ALLOWBULKEMAIL": field.caption = "Allow Bulk Email"; field.editSortPriority = 3020; break; case "ALLOWSEEALSO": field.caption = "Allow See Also"; field.editSortPriority = 3030; break; case "ALLOWFEEDBACK": field.caption = "Allow Feedback"; field.editSortPriority = 3040; field.authorable = false; break; case "SORTORDER": field.caption = "Alpha Sort Order"; field.editSortPriority = 3050; // // --- Display only information // break; case "VIEWINGS": field.caption = "Viewings"; field.readOnly = true; field.editSortPriority = 5000; field.defaultValue = "0"; break; case "CLICKS": field.caption = "Clicks"; field.readOnly = true; field.editSortPriority = 5010; field.defaultValue = "0"; break; } contentMetadata.verifyContentField(core, field, true, logMsgContext); } catch (Exception ex) { LogController.logError(core, ex); throw; } }