// // ==================================================================================================== /// <summary> /// Generate the content of a tab in the Edit Screen /// </summary> /// <param name="core"></param> /// <param name="adminData"></param> /// <param name="RecordID"></param> /// <param name="ContentID"></param> /// <param name="record_readOnly"></param> /// <param name="IsLandingPage"></param> /// <param name="IsRootPage"></param> /// <param name="EditTab"></param> /// <param name="EditorContext"></param> /// <param name="return_NewFieldList"></param> /// <param name="HelpCnt"></param> /// <param name="HelpIDCache"></param> /// <param name="helpDefaultCache"></param> /// <param name="HelpCustomCache"></param> /// <param name="AllowHelpMsgCustom"></param> /// <param name="helpIdIndex"></param> /// <returns></returns> public static string getTab(CoreController core, AdminDataModel adminData, EditorEnvironmentModel editorEnv, int RecordID, int ContentID, string EditTab) { string returnHtml = ""; try { // // ----- Open the panel if (adminData.adminContent.fields.Count <= 0) { // // There are no visible fiels, return empty LogController.logError(core, new GenericException("There is no metadata for this field.")); } else { // // ----- Build an index to sort the fields by EditSortOrder Dictionary <string, ContentFieldMetadataModel> sortingFields = new Dictionary <string, ContentFieldMetadataModel>(); foreach (var keyValuePair in adminData.adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; if (field.editTabName.ToLowerInvariant() == EditTab.ToLowerInvariant()) { if (AdminDataModel.isVisibleUserField(core, field.adminOnly, field.developerOnly, field.active, field.authorable, field.nameLc, adminData.adminContent.tableName)) { string AlphaSort = GenericController.getIntegerString(field.editSortPriority, 10) + "-" + GenericController.getIntegerString(field.id, 10); sortingFields.Add(AlphaSort, field); } } } // // ----- display the record fields bool AllowHelpIcon = core.visitProperty.getBoolean("AllowHelpIcon"); StringBuilderLegacyController resultBody = new StringBuilderLegacyController(); bool needUniqueEmailMessage = false; foreach (var kvp in sortingFields) { ContentFieldMetadataModel field = kvp.Value; string editorRow = EditorRowClass.getEditorRow(core, field, adminData, editorEnv); resultBody.add("<tr><td colspan=2>" + editorRow + "</td></tr>"); } // // ----- add the *Required Fields footer resultBody.add("<tr><td colspan=2 style=\"padding-top:10px;font-size:70%\"><div>* Field is required.</div><div>** Field must be unique.</div>"); if (needUniqueEmailMessage) { resultBody.add("<div>*** Field must be unique because this site allows login by email.</div>"); } resultBody.add("</td></tr>"); // // ----- close the panel returnHtml = AdminUIController.getEditPanel(core, false, "", "", AdminUIController.editTable(resultBody.text)); adminData.editSectionPanelCount += 1; resultBody = null; } } catch (Exception ex) { LogController.logError(core, ex); throw; } return(returnHtml); }
// // ==================================================================================================== /// <summary> /// Create all the tabs for the edit form /// </summary> /// <param name="core"></param> /// <param name="adminData"></param> /// <param name="readOnlyField"></param> /// <param name="IsLandingPage"></param> /// <param name="IsRootPage"></param> /// <param name="EditorContext"></param> /// <param name="TemplateIDForStyles"></param> /// <param name="fieldEditorList"></param> /// <param name="styleList"></param> /// <param name="styleOptionList"></param> /// <param name="emailIdForStyles"></param> /// <param name="IsTemplateTable"></param> /// <param name="editorAddonListJSON"></param> /// <returns></returns> public static void addContentTabs(CoreController core, AdminDataModel adminData, EditTabModel editTabs, EditorEnvironmentModel editorEnv) { try { // todo string IDList = ""; foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminData.adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; IDList = IDList + "," + field.id; } if (!string.IsNullOrEmpty(IDList)) { IDList = IDList.Substring(1); } // DataTable dt = core.db.executeQuery("select fieldid,helpdefault,helpcustom from ccfieldhelp where fieldid in (" + IDList + ") order by fieldid,id"); string[,] fieldHelpArray = core.db.convertDataTabletoArray(dt); int HelpCnt = 0; int[] HelpIDCache = { }; string[] helpDefaultCache = { }; string[] HelpCustomCache = { }; KeyPtrController helpIdIndex = new KeyPtrController(); if (fieldHelpArray.GetLength(0) > 0) { HelpCnt = fieldHelpArray.GetUpperBound(1) + 1; HelpIDCache = new int[HelpCnt + 1]; helpDefaultCache = new string[HelpCnt + 1]; HelpCustomCache = new string[HelpCnt + 1]; int fieldId = -1; int HelpPtr = 0; for (HelpPtr = 0; HelpPtr < HelpCnt; HelpPtr++) { fieldId = GenericController.encodeInteger(fieldHelpArray[0, HelpPtr]); int LastFieldId = 0; if (fieldId != LastFieldId) { LastFieldId = fieldId; HelpIDCache[HelpPtr] = fieldId; helpIdIndex.setPtr(fieldId.ToString(), HelpPtr); helpDefaultCache[HelpPtr] = GenericController.encodeText(fieldHelpArray[1, HelpPtr]); HelpCustomCache[HelpPtr] = GenericController.encodeText(fieldHelpArray[2, HelpPtr]); } } editorEnv.allowHelpMsgCustom = true; } // List <string> TabsFound = new List <string>(); foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminData.adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; if ((!field.editTabName.ToLowerInvariant().Equals("control info")) && (field.authorable) && (field.active) && (!TabsFound.Contains(field.editTabName.ToLowerInvariant()))) { TabsFound.Add(field.editTabName.ToLowerInvariant()); string editTabCaption = field.editTabName; if (string.IsNullOrEmpty(editTabCaption)) { editTabCaption = "Details"; } string tabContent = getTab(core, adminData, editorEnv, adminData.editRecord.id, adminData.adminContent.id, field.editTabName); if (!string.IsNullOrEmpty(tabContent)) { addCustomTab(core, editTabs, editTabCaption, tabContent); } } } } catch (Exception ex) { LogController.logError(core, ex); throw; } }
public static string getEditorRow(CoreController core, ContentFieldMetadataModel field, AdminDataModel adminData, EditorEnvironmentModel editorEnv) { string whyReadOnlyMsg = ""; Models.EditRecordModel editRecord = adminData.editRecord; object fieldValueObject = editRecord.fieldsLc[field.nameLc].value; string fieldValue_text = encodeText(fieldValueObject); int fieldRows = 1; string fieldHtmlId = field.nameLc + field.id.ToString(); string fieldCaption = field.caption; if (field.uniqueName) { fieldCaption = " **" + fieldCaption; } else { if (field.nameLc.ToLowerInvariant() == "email") { if ((adminData.adminContent.tableName.ToLowerInvariant() == "ccmembers") && ((core.siteProperties.getBoolean("allowemaillogin", false)))) { fieldCaption = " ***" + fieldCaption; editorEnv.needUniqueEmailMessage = true; } } } if (field.required) { fieldCaption = " *" + fieldCaption; } adminData.formInputCount = adminData.formInputCount + 1; bool fieldForceReadOnly = false; // // Read only Special Cases if (editorEnv.isRootPage) { // // -- page content metadata, these are the special fields switch (GenericController.toLCase(field.nameLc)) { case "active": { // // if active, it is read only -- if inactive, let them set it active. fieldForceReadOnly = encodeBoolean(fieldValueObject); if (fieldForceReadOnly) { whyReadOnlyMsg = " (disabled because you can not mark the landing page inactive)"; } break; } case "dateexpires": case "pubdate": case "datearchive": case "blocksection": case "archiveparentid": case "hidemenu": { // // These fields are read only on landing pages fieldForceReadOnly = true; whyReadOnlyMsg = " (disabled for the landing page)"; break; } case "allowinmenus": case "allowinchildlists": { fieldValueObject = "1"; fieldForceReadOnly = true; whyReadOnlyMsg = " (disabled for root pages)"; } break; default: { // do nothing break; } } } // // Special Case - ccemail table Alloweid should be disabled if siteproperty AllowLinkLogin is false // if (GenericController.toLCase(adminData.adminContent.tableName) == "ccemail" && GenericController.toLCase(field.nameLc) == "allowlinkeid") { if (!(core.siteProperties.getBoolean("AllowLinkLogin", true))) { fieldValueObject = "0"; fieldForceReadOnly = true; fieldValue_text = "0"; } } string EditorString = ""; bool editorReadOnly = (editorEnv.record_readOnly || field.readOnly || (editRecord.id != 0 && field.notEditable) || (fieldForceReadOnly)); AddonModel editorAddon = null; int fieldTypeDefaultEditorAddonId = 0; var fieldEditor = adminData.fieldTypeEditors.Find(x => (x.fieldTypeId == (int)field.fieldTypeId)); if (fieldEditor != null) { fieldTypeDefaultEditorAddonId = (int)fieldEditor.editorAddonId; editorAddon = DbBaseModel.create <AddonModel>(core.cpParent, fieldTypeDefaultEditorAddonId); } bool useEditorAddon = false; if (editorAddon != null) { // //-------------------------------------------------------------------------------------------- // ----- Custom Editor //-------------------------------------------------------------------------------------------- // core.docProperties.setProperty("editorName", field.nameLc); core.docProperties.setProperty("editorValue", fieldValue_text); core.docProperties.setProperty("editorFieldId", field.id); core.docProperties.setProperty("editorFieldType", (int)field.fieldTypeId); core.docProperties.setProperty("editorReadOnly", editorReadOnly); core.docProperties.setProperty("editorWidth", ""); core.docProperties.setProperty("editorHeight", ""); if (field.fieldTypeId.isOneOf(CPContentBaseClass.FieldTypeIdEnum.HTML, CPContentBaseClass.FieldTypeIdEnum.HTMLCode, CPContentBaseClass.FieldTypeIdEnum.FileHTML, CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode)) { // // include html related arguments core.docProperties.setProperty("editorAllowActiveContent", "1"); core.docProperties.setProperty("editorAddonList", editorEnv.editorAddonListJSON); core.docProperties.setProperty("editorStyles", editorEnv.styleList); core.docProperties.setProperty("editorStyleOptions", editorEnv.styleOptionList); } EditorString = core.addon.execute(editorAddon, new BaseClasses.CPUtilsBaseClass.addonExecuteContext { addonType = BaseClasses.CPUtilsBaseClass.addonContext.ContextEditor, errorContextMessage = "field editor id:" + editorAddon.id }); useEditorAddon = !string.IsNullOrEmpty(EditorString); if (useEditorAddon) { // // -- editor worked editorEnv.formFieldList += "," + field.nameLc; } else { // // -- editor failed, determine if it is missing (or inactive). If missing, remove it from the members preferences using (var csData = new CsModel(core)) { if (!csData.openSql("select id from ccaggregatefunctions where id=" + editorAddon.id)) { // // -- missing, not just inactive EditorString = ""; // // load user's editor preferences to fieldEditorPreferences() - this is the editor this user has picked when there are >1 // fieldId:addonId,fieldId:addonId,etc // with custom FancyBox form in edit window with button "set editor preference" // this button causes a 'refresh' action, reloads fields with stream without save // string tmpList = core.userProperty.getText("editorPreferencesForContent:" + adminData.adminContent.id, ""); int PosStart = GenericController.strInstr(1, "," + tmpList, "," + field.id + ":"); if (PosStart > 0) { int PosEnd = GenericController.strInstr(PosStart + 1, "," + tmpList, ","); if (PosEnd == 0) { tmpList = tmpList.left(PosStart - 1); } else { tmpList = tmpList.left(PosStart - 1) + tmpList.Substring(PosEnd - 1); } core.userProperty.setProperty("editorPreferencesForContent:" + adminData.adminContent.id, tmpList); } } } } } // // -- style for editor wrapper used to limit the width of some editors like integer string editorWrapperSyle = ""; if (!useEditorAddon) { bool IsEmptyList = false; //string NonEncodedLink = null; //string EncodedLink = null; // // if custom editor not used or if it failed // if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Redirect) { // // ----- Default Editor, Redirect fields (the same for normal/readonly/spelling) EditorString = AdminUIEditorController.getRedirectEditor(core, field, adminData, editRecord, fieldValue_text, editorReadOnly, fieldHtmlId, field.required); //string RedirectPath = core.appConfig.adminRoute; //if (field.redirectPath != "") { // RedirectPath = field.redirectPath; //} //RedirectPath = RedirectPath + "?" + RequestNameTitleExtension + "=" + GenericController.encodeRequestVariable(" For " + editRecord.nameLc + adminData.titleExtension) + "&" + RequestNameAdminDepth + "=" + (adminData.ignore_legacyMenuDepth + 1) + "&wl0=" + field.redirectId + "&wr0=" + editRecord.id; //if (field.redirectContentId != 0) { // RedirectPath = RedirectPath + "&cid=" + field.redirectContentId; //} else { // RedirectPath = RedirectPath + "&cid=" + ((editRecord.contentControlId.Equals(0)) ? adminData.adminContent.id : editRecord.contentControlId); //} //if (editRecord.id == 0) { // EditorString += ("[available after save]"); //} else { // RedirectPath = GenericController.strReplace(RedirectPath, "'", "\\'"); // EditorString += ("<a href=\"#\""); // EditorString += (" onclick=\" window.open('" + RedirectPath + "', '_blank', 'scrollbars=yes,toolbar=no,status=no,resizable=yes'); return false;\""); // EditorString += (">"); // EditorString += ("Open in New Window</A>"); //} } else if (editorReadOnly) { // //-------------------------------------------------------------------------------------------- // ----- Display fields as read only //-------------------------------------------------------------------------------------------- // if (!string.IsNullOrEmpty(whyReadOnlyMsg)) { whyReadOnlyMsg = "<span class=\"ccDisabledReason\">" + whyReadOnlyMsg + "</span>"; } switch (field.fieldTypeId) { case CPContentBaseClass.FieldTypeIdEnum.Text: case CPContentBaseClass.FieldTypeIdEnum.Link: case CPContentBaseClass.FieldTypeIdEnum.ResourceLink: { // // ----- Text Type EditorString += AdminUIEditorController.getTextEditor(core, field.nameLc, fieldValue_text, editorReadOnly, fieldHtmlId); editorEnv.formFieldList += "," + field.nameLc; break; } case CPContentBaseClass.FieldTypeIdEnum.Boolean: { // // ----- Boolean ReadOnly EditorString += AdminUIEditorController.getBooleanEditor(core, field.nameLc, GenericController.encodeBoolean(fieldValueObject), editorReadOnly, fieldHtmlId); editorEnv.formFieldList += "," + field.nameLc; editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.Lookup: { // // ----- Lookup, readonly if (field.lookupContentId != 0) { EditorString = AdminUIEditorController.getLookupContentEditor(core, field.nameLc, GenericController.encodeInteger(fieldValueObject), field.lookupContentId, ref IsEmptyList, editorReadOnly, fieldHtmlId, whyReadOnlyMsg, field.required, ""); editorEnv.formFieldList += "," + field.nameLc; editorWrapperSyle = "max-width:400px"; } else if (field.lookupList != "") { EditorString = AdminUIEditorController.getLookupListEditor(core, field.nameLc, encodeInteger(fieldValueObject), field.lookupList.Split(',').ToList(), editorReadOnly, fieldHtmlId, whyReadOnlyMsg, field.required); editorEnv.formFieldList += "," + field.nameLc; editorWrapperSyle = "max-width:400px"; } else { // // -- log exception but dont throw LogController.logWarn(core, new GenericException("Field [" + adminData.adminContent.name + "." + field.nameLc + "] is a Lookup field, but no LookupContent or LookupList has been configured")); EditorString += "[Selection not configured]"; } break; } case CPContentBaseClass.FieldTypeIdEnum.Date: { // // ----- date, readonly editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getDateTimeEditor(core, field.nameLc, encodeDate(fieldValueObject), editorReadOnly, fieldHtmlId, field.required, whyReadOnlyMsg); editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.MemberSelect: { // // ----- Member Select ReadOnly editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getMemberSelectEditor(core, field.nameLc, encodeInteger(fieldValueObject), field.memberSelectGroupId_get(core), field.memberSelectGroupName_get(core), editorReadOnly, fieldHtmlId, field.required, whyReadOnlyMsg); editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.ManyToMany: { // // Placeholder EditorString = AdminUIEditorController.getManyToManyEditor(core, field, "field" + field.id, fieldValue_text, editRecord.id, editorReadOnly, whyReadOnlyMsg); break; } case CPContentBaseClass.FieldTypeIdEnum.Currency: { // // ----- Currency ReadOnly editorEnv.formFieldList += "," + field.nameLc; EditorString += (HtmlController.inputCurrency(core, field.nameLc, encodeNumber(fieldValue_text), fieldHtmlId, "text form-control", editorReadOnly, false)); editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.Float: { // // ----- double/number/float editorEnv.formFieldList += "," + field.nameLc; EditorString += (HtmlController.inputNumber(core, field.nameLc, encodeNumber(fieldValue_text), fieldHtmlId, "text form-control", editorReadOnly, false)); editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.AutoIdIncrement: case CPContentBaseClass.FieldTypeIdEnum.Integer: { // // ----- Others that simply print editorEnv.formFieldList += "," + field.nameLc; EditorString += (HtmlController.inputInteger(core, field.nameLc, encodeInteger(fieldValue_text), fieldHtmlId, "text form-control", editorReadOnly, false)); editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.HTMLCode: case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: { // // edit html as html (see the code) editorEnv.formFieldList += "," + field.nameLc; EditorString += HtmlController.inputHidden(field.nameLc, fieldValue_text); fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10)); EditorString += HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, editorReadOnly, "form-control"); break; } case CPContentBaseClass.FieldTypeIdEnum.HTML: case CPContentBaseClass.FieldTypeIdEnum.FileHTML: { // // ----- HTML types readonly if (field.htmlContent) { // // edit html as html (see the code) editorEnv.formFieldList += "," + field.nameLc; EditorString += HtmlController.inputHidden(field.nameLc, fieldValue_text); fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10)); EditorString += HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, editorReadOnly, "form-control"); } else { // // edit html as wysiwyg readonly editorEnv.formFieldList += "," + field.nameLc; EditorString += AdminUIEditorController.getHtmlEditor(core, field.nameLc, fieldValue_text, editorEnv.editorAddonListJSON, editorEnv.styleList, editorEnv.styleOptionList, editorReadOnly, fieldHtmlId); } break; } case CPContentBaseClass.FieldTypeIdEnum.LongText: case CPContentBaseClass.FieldTypeIdEnum.FileText: { // // ----- LongText, TextFile editorEnv.formFieldList += "," + field.nameLc; EditorString += HtmlController.inputHidden(field.nameLc, fieldValue_text); fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10)); EditorString += HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, editorReadOnly, " form-control"); break; } case CPContentBaseClass.FieldTypeIdEnum.File: { // // ----- File ReadOnly editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getFileEditor(core, field.nameLc, fieldValue_text, field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg); break; } case CPContentBaseClass.FieldTypeIdEnum.FileImage: { // // ----- Image ReadOnly editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getImageEditor(core, field.nameLc, fieldValue_text, field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg); break; } default: { // // ----- Legacy text type -- not used unless something was missed editorEnv.formFieldList += "," + field.nameLc; EditorString += HtmlController.inputHidden(field.nameLc, fieldValue_text); if (field.password) { // // Password forces simple text box EditorString += HtmlController.inputText_Legacy(core, field.nameLc, "*****", 0, 0, fieldHtmlId, true, true, "password form-control"); } else if (!field.htmlContent) { // // not HTML capable, textarea with resizing if ((field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Text) && (fieldValue_text.IndexOf("\n") == -1) && (fieldValue_text.Length < 40)) { // // text field shorter then 40 characters without a CR EditorString += HtmlController.inputText_Legacy(core, field.nameLc, fieldValue_text, 1, 0, fieldHtmlId, false, true, "text form-control"); } else { // // longer text data, or text that contains a CR EditorString += HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, 10, -1, fieldHtmlId, false, true, " form-control"); } } else if (field.htmlContent) { // // HTMLContent true, and prefered fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".PixelHeight", 500)); EditorString += core.html.getFormInputHTML(field.nameLc, fieldValue_text, "500", "", false, true, editorEnv.editorAddonListJSON, editorEnv.styleList, editorEnv.styleOptionList); EditorString = "<div style=\"width:95%\">" + EditorString + "</div>"; } else { // // HTMLContent true, but text editor selected fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10)); EditorString += HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, editorReadOnly); } break; } } } else { // // -- Not Read Only - Display fields as form elements to be modified switch (field.fieldTypeId) { case CPContentBaseClass.FieldTypeIdEnum.Text: { // // ----- Text Type if (field.password) { EditorString += AdminUIEditorController.getPasswordEditor(core, field.nameLc, fieldValue_text, false, fieldHtmlId); } else { EditorString += AdminUIEditorController.getTextEditor(core, field.nameLc, fieldValue_text, false, fieldHtmlId); } editorEnv.formFieldList += "," + field.nameLc; break; } case CPContentBaseClass.FieldTypeIdEnum.Boolean: { // // ----- Boolean EditorString += AdminUIEditorController.getBooleanEditor(core, field.nameLc, encodeBoolean(fieldValueObject), false, fieldHtmlId); editorEnv.formFieldList += "," + field.nameLc; editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.Lookup: { // // ----- Lookup if (field.lookupContentId != 0) { EditorString = AdminUIEditorController.getLookupContentEditor(core, field.nameLc, encodeInteger(fieldValueObject), field.lookupContentId, ref IsEmptyList, field.readOnly, fieldHtmlId, whyReadOnlyMsg, field.required, ""); editorEnv.formFieldList += "," + field.nameLc; editorWrapperSyle = "max-width:400px"; } else if (field.lookupList != "") { EditorString = AdminUIEditorController.getLookupListEditor(core, field.nameLc, encodeInteger(fieldValueObject), field.lookupList.Split(',').ToList(), field.readOnly, fieldHtmlId, whyReadOnlyMsg, field.required); editorEnv.formFieldList += "," + field.nameLc; editorWrapperSyle = "max-width:400px"; } else { // // -- log exception but dont throw LogController.logWarn(core, new GenericException("Field [" + adminData.adminContent.name + "." + field.nameLc + "] is a Lookup field, but no LookupContent or LookupList has been configured")); EditorString += "[Selection not configured]"; } break; } case CPContentBaseClass.FieldTypeIdEnum.Date: { // // ----- Date editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getDateTimeEditor(core, field.nameLc, GenericController.encodeDate(fieldValueObject), field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg); editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.MemberSelect: { // // ----- Member Select editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getMemberSelectEditor(core, field.nameLc, encodeInteger(fieldValueObject), field.memberSelectGroupId_get(core), field.memberSelectGroupName_get(core), field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg); editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.ManyToMany: { // // Placeholder EditorString = AdminUIEditorController.getManyToManyEditor(core, field, "field" + field.id, fieldValue_text, editRecord.id, false, whyReadOnlyMsg); break; } case CPContentBaseClass.FieldTypeIdEnum.File: { // // ----- File editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getFileEditor(core, field.nameLc, fieldValue_text, field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg); break; } case CPContentBaseClass.FieldTypeIdEnum.FileImage: { // // ----- Image ReadOnly editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getImageEditor(core, field.nameLc, fieldValue_text, field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg); break; } case CPContentBaseClass.FieldTypeIdEnum.Currency: { // // ----- currency editorEnv.formFieldList += "," + field.nameLc; EditorString += AdminUIEditorController.getCurrencyEditor(core, field.nameLc, encodeNumberNullable(fieldValueObject), field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg); editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.Float: { // // ----- double/number/float editorEnv.formFieldList += "," + field.nameLc; EditorString += AdminUIEditorController.getNumberEditor(core, field.nameLc, encodeNumberNullable(fieldValueObject), field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg); editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.AutoIdIncrement: case CPContentBaseClass.FieldTypeIdEnum.Integer: { // // ----- Others that simply print editorEnv.formFieldList += "," + field.nameLc; EditorString += (HtmlController.inputInteger(core, field.nameLc, encodeIntegerNullable(fieldValue_text), fieldHtmlId, "text form-control", editorReadOnly, false)); editorWrapperSyle = "max-width:400px"; break; } case CPContentBaseClass.FieldTypeIdEnum.Link: { // // ----- Link (href value // editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getLinkEditor(core, field.nameLc, fieldValue_text, editorReadOnly, fieldHtmlId, field.required); break; } case CPContentBaseClass.FieldTypeIdEnum.ResourceLink: { // // ----- Resource Link (src value) // editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getLinkEditor(core, field.nameLc, fieldValue_text, editorReadOnly, fieldHtmlId, field.required); break; } case CPContentBaseClass.FieldTypeIdEnum.HTMLCode: case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: { // // View the content as Html, not wysiwyg editorEnv.formFieldList += "," + field.nameLc; EditorString = AdminUIEditorController.getHtmlCodeEditor(core, field.nameLc, fieldValue_text, editorReadOnly, fieldHtmlId); break; } case CPContentBaseClass.FieldTypeIdEnum.HTML: case CPContentBaseClass.FieldTypeIdEnum.FileHTML: { // // content is html editorEnv.formFieldList += "," + field.nameLc; if (field.htmlContent) { // // View the content as Html, not wysiwyg EditorString = AdminUIEditorController.getHtmlCodeEditor(core, field.nameLc, fieldValue_text, editorReadOnly, fieldHtmlId); } else { // // wysiwyg editor EditorString = AdminUIEditorController.getHtmlEditor(core, field.nameLc, fieldValue_text, editorEnv.editorAddonListJSON, editorEnv.styleList, editorEnv.styleOptionList, editorReadOnly, fieldHtmlId); } // break; } case CPContentBaseClass.FieldTypeIdEnum.LongText: case CPContentBaseClass.FieldTypeIdEnum.FileText: { // // -- Long Text, use text editor editorEnv.formFieldList += "," + field.nameLc; fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10)); EditorString = HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, false, "text form-control"); // break; } case CPContentBaseClass.FieldTypeIdEnum.FileCSS: { // // ----- CSS field editorEnv.formFieldList += "," + field.nameLc; fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10)); EditorString = HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, false, "styles form-control"); break; } case CPContentBaseClass.FieldTypeIdEnum.FileJavascript: { // // ----- Javascript field editorEnv.formFieldList += "," + field.nameLc; fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10)); EditorString = HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, false, "text form-control"); // break; } case CPContentBaseClass.FieldTypeIdEnum.FileXML: { // // ----- xml field editorEnv.formFieldList += "," + field.nameLc; fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10)); EditorString = HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, false, "text form-control"); // break; } default: { // // ----- Legacy text type -- not used unless something was missed // editorEnv.formFieldList += "," + field.nameLc; if (field.password) { // // Password forces simple text box EditorString = HtmlController.inputText_Legacy(core, field.nameLc, fieldValue_text, -1, -1, fieldHtmlId, true, false, "password form-control"); } else if (!field.htmlContent) { // // not HTML capable, textarea with resizing // if ((field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Text) && (fieldValue_text.IndexOf("\n", StringComparison.InvariantCulture) == -1) && (fieldValue_text.Length < 40)) { // // text field shorter then 40 characters without a CR // EditorString = HtmlController.inputText_Legacy(core, field.nameLc, fieldValue_text, 1, -1, fieldHtmlId, false, false, "text form-control"); } else { // // longer text data, or text that contains a CR // EditorString = HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, 10, -1, fieldHtmlId, false, false, "text form-control"); } } else if (field.htmlContent) { // // HTMLContent true, and prefered // if (string.IsNullOrEmpty(fieldValue_text)) { // // editor needs a starting p tag to setup correctly // fieldValue_text = HTMLEditorDefaultCopyNoCr; } fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".PixelHeight", 500)); EditorString += core.html.getFormInputHTML(field.nameLc, fieldValue_text, "500", "", false, true, editorEnv.editorAddonListJSON, editorEnv.styleList, editorEnv.styleOptionList); EditorString = "<div style=\"width:95%\">" + EditorString + "</div>"; } else { // // HTMLContent true, but text editor selected fieldRows = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10)); EditorString = HtmlController.inputTextarea(core, field.nameLc, HtmlController.encodeHtml(fieldValue_text), fieldRows, -1, fieldHtmlId, false, false, "text"); } break; } } } } // // assemble the editor row return(AdminUIController.getEditRow(core, EditorString, fieldCaption, field.helpDefault, field.required, false, fieldHtmlId, editorWrapperSyle)); }
// //======================================================================== /// <summary> /// Control edit tab /// </summary> /// <param name="core"></param> /// <param name="adminData"></param> /// <returns></returns> public static string get(CoreController core, AdminDataModel adminData, EditorEnvironmentModel editorEnv) { string result = null; try { bool disabled = false; // var tabPanel = new StringBuilderLegacyController(); if (string.IsNullOrEmpty(adminData.adminContent.name)) { // // Content not found or not loaded if (adminData.adminContent.id == 0) { // LogController.logError(core, new GenericException("No content definition was specified for this page")); return(HtmlController.p("No content was specified.")); } else { // // Content Definition was not specified LogController.logError(core, new GenericException("The content definition specified for this page [" + adminData.adminContent.id + "] was not found")); return(HtmlController.p("No content was specified.")); } } // // ----- Authoring status bool FieldRequired = false; List <string> TabsFound = new List <string>(); foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminData.adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; if ((field.editTabName.ToLowerInvariant().Equals("control info")) && (field.authorable) && (field.active)) { tabPanel.add(EditorRowClass.getEditorRow(core, field, adminData, editorEnv)); } } // // ----- RecordID { string fieldValue = (adminData.editRecord.id == 0) ? "(available after save)" : adminData.editRecord.id.ToString(); string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore", fieldValue, true, ""); string fieldHelp = "This is the unique number that identifies this record within this content."; tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Record Number", fieldHelp, true, false, "")); } // // -- Active { string htmlId = "fieldActive"; string fieldEditor = HtmlController.checkbox("active", adminData.editRecord.active, htmlId, disabled, "", adminData.editRecord.userReadOnly); string fieldHelp = "When unchecked, add-ons can ignore this record as if it was temporarily deleted."; tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Active", fieldHelp, false, false, htmlId)); } // // -- GUID { string guidSetHtmlId = "guidSet" + GenericController.getRandomInteger(core).ToString(); string guidInputHtmlId = "guidInput" + GenericController.getRandomInteger(core).ToString(); string fieldValue = GenericController.encodeText(adminData.editRecord.fieldsLc["ccguid"].value); string fieldEditor = ""; if (adminData.editRecord.userReadOnly) { // // -- readonly fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore", fieldValue, true, ""); } else if (string.IsNullOrEmpty(fieldValue)) { // // add a set button string setButton = "<input id=\"" + guidSetHtmlId + "\" type=\"submit\" value=\"Set\" class=\"btn btn-primary btn-sm\">"; string setButtonWrapped = "<div class=\"input-group-append\">" + setButton + "</div>"; string inputCell = AdminUIEditorController.getTextEditor(core, "ccguid", "", false, guidInputHtmlId); fieldEditor = HtmlController.div(inputCell + setButtonWrapped, "input-group"); string newGuid = GenericController.getGUID(true); string onClickFn = "function(e){e.preventDefault();e.stopPropagation();$('#" + guidInputHtmlId + "').val('" + newGuid + "');}"; string script = "$('body').on('click','#" + guidSetHtmlId + "'," + onClickFn + ")"; core.html.addScriptCode(script, "Admin edit control-info-tab guid set button"); } else { // // field is read-only except for developers fieldEditor = AdminUIEditorController.getTextEditor(core, "ccguid", fieldValue, !core.session.isAuthenticatedDeveloper(), guidInputHtmlId); } string FieldHelp = "This is a unique number that identifies this record globally. A GUID is not required, but when set it should never be changed. GUIDs are used to synchronize records. When empty, you can create a new guid. Only Developers can modify the guid."; tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "GUID", FieldHelp, false, false, guidInputHtmlId)); } // // ----- EID (Encoded ID) { if (GenericController.toUCase(adminData.adminContent.tableName) == GenericController.toUCase("ccMembers")) { string htmlId = "fieldGuid"; bool AllowEId = (core.siteProperties.getBoolean("AllowLinkLogin", true)) || (core.siteProperties.getBoolean("AllowLinkRecognize", true)); string fieldHelp = "This string is an authentication token that can be used in the URL for the next 15 minutes to log in as this user."; string fieldEditor = ""; if (!AllowEId) { fieldEditor = "(link login and link recognize are disabled in security preferences)"; } else if (adminData.editRecord.id == 0) { fieldEditor = "(available after save)"; } else { string eidQueryString = "eid=" + WebUtility.UrlEncode(SecurityController.encodeToken(core, adminData.editRecord.id, core.doc.profileStartTime.AddMinutes(15))); string sampleUrl = core.webServer.requestProtocol + core.webServer.requestDomain + "/" + core.siteProperties.serverPageDefault + "?" + eidQueryString; if (core.siteProperties.getBoolean("AllowLinkLogin", true)) { fieldHelp = " If " + eidQueryString + " is added to a url querystring for this site, the user be logged in as this person."; } else { fieldHelp = " If " + eidQueryString + " is added to a url querystring for this site, the user be recognized in as this person, but not logged in."; } fieldHelp += " To enable, disable or modify this feature, use the security tab on the Preferences page."; fieldHelp += "<br>For example: " + sampleUrl; fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_eid", eidQueryString, true, htmlId); } tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Member Link Login Querystring", fieldHelp, true, false, htmlId)); } } // // ----- Controlling Content { string HTMLFieldString = ""; string FieldHelp = "The content in which this record is stored. This is similar to a database table."; ContentFieldMetadataModel field = null; if (adminData.adminContent.fields.ContainsKey("contentcontrolid")) { field = adminData.adminContent.fields["contentcontrolid"]; // // if this record has a parent id, only include CDefs compatible with the parent record - otherwise get all for the table FieldHelp = GenericController.encodeText(field.helpMessage); FieldRequired = GenericController.encodeBoolean(field.required); int FieldValueInteger = (adminData.editRecord.contentControlId.Equals(0)) ? adminData.adminContent.id : adminData.editRecord.contentControlId; if (!core.session.isAuthenticatedAdmin()) { HTMLFieldString = HTMLFieldString + HtmlController.inputHidden("contentControlId", FieldValueInteger); } else { string RecordContentName = adminData.editRecord.contentControlId_Name; string TableName2 = MetadataController.getContentTablename(core, RecordContentName); int TableId = MetadataController.getRecordIdByUniqueName(core, "Tables", TableName2); // // Test for parentid int ParentId = 0; bool ContentSupportsParentId = false; if (adminData.editRecord.id > 0) { using (var csData = new CsModel(core)) { if (csData.openRecord(RecordContentName, adminData.editRecord.id)) { ContentSupportsParentId = csData.isFieldSupported("ParentID"); if (ContentSupportsParentId) { ParentId = csData.getInteger("ParentID"); } } } } bool IsEmptyList = false; if (core.session.isAuthenticatedAdmin()) { // // administrator, and either ( no parentid or does not support it), let them select any content compatible with the table string sqlFilter = "(ContentTableID=" + TableId + ")"; int contentCId = MetadataController.getRecordIdByUniqueName(core, ContentModel.tableMetadata.contentName, ContentModel.tableMetadata.contentName); HTMLFieldString += AdminUIEditorController.getLookupContentEditor(core, "contentcontrolid", FieldValueInteger, contentCId, ref IsEmptyList, adminData.editRecord.userReadOnly, "", "", true, sqlFilter); FieldHelp = FieldHelp + " (Only administrators have access to this control. Changing the Controlling Content allows you to change who can author the record, as well as how it is edited.)"; } } } if (string.IsNullOrEmpty(HTMLFieldString)) { HTMLFieldString = adminData.editRecord.contentControlId_Name; } tabPanel.add(AdminUIController.getEditRow(core, HTMLFieldString, "Controlling Content", FieldHelp, FieldRequired, false, "")); } // // ----- Created By { string FieldHelp = "The people account of the user who created this record."; string fieldValue = ""; if (adminData.editRecord == null) { fieldValue = "(not set)"; } else if (adminData.editRecord.id == 0) { fieldValue = "(available after save)"; } else if (adminData.editRecord.createdBy == null) { fieldValue = "(not set)"; } else { int FieldValueInteger = adminData.editRecord.createdBy.id; if (FieldValueInteger == 0) { fieldValue = "(not set)"; } else { using (var csData = new CsModel(core)) { csData.open("people", "(id=" + FieldValueInteger + ")", "name,active", false); if (!csData.ok()) { fieldValue = "#" + FieldValueInteger + ", (deleted)"; } else { fieldValue = "#" + FieldValueInteger + ", " + csData.getText("name"); if (!csData.getBoolean("active")) { fieldValue += " (inactive)"; } } csData.close(); } } } string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_createdBy", fieldValue, true, ""); tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Created By", FieldHelp, FieldRequired, false, "")); } // // ----- Created Date { string FieldHelp = "The date and time when this record was originally created."; string fieldValue = ""; if (adminData.editRecord == null) { fieldValue = "(not set)"; } else if (adminData.editRecord.id == 0) { fieldValue = "(available after save)"; } else { if (GenericController.encodeDateMinValue(adminData.editRecord.dateAdded) == DateTime.MinValue) { fieldValue = "(not set)"; } else { fieldValue = adminData.editRecord.dateAdded.ToString(); } } string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_createdDate", fieldValue, true, ""); tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Created Date", FieldHelp, FieldRequired, false, "")); } // // ----- Modified By { string FieldHelp = "The people account of the last user who modified this record."; string fieldValue = ""; if (adminData.editRecord == null) { fieldValue = "(not set)"; } else if (adminData.editRecord.id == 0) { fieldValue = "(available after save)"; } else if (adminData.editRecord.modifiedBy == null) { fieldValue = "(not set)"; } else { int FieldValueInteger = adminData.editRecord.modifiedBy.id; if (FieldValueInteger == 0) { fieldValue = "(not set)"; } else { using (var csData = new CsModel(core)) { csData.open("people", "(id=" + FieldValueInteger + ")", "name,active", false); if (!csData.ok()) { fieldValue = "#" + FieldValueInteger + ", (deleted)"; } else { fieldValue = "#" + FieldValueInteger + ", " + csData.getText("name"); if (!csData.getBoolean("active")) { fieldValue += " (inactive)"; } } csData.close(); } } } string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_modifiedBy", fieldValue, true, ""); tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Modified By", FieldHelp, FieldRequired, false, "")); } // // ----- Modified Date { string FieldHelp = "The date and time when this record was last modified."; string fieldValue = ""; if (adminData.editRecord == null) { fieldValue = "(not set)"; } else if (adminData.editRecord.id == 0) { fieldValue = "(available after save)"; } else { if (GenericController.encodeDateMinValue(adminData.editRecord.modifiedDate) == DateTime.MinValue) { fieldValue = "(not set)"; } else { fieldValue = adminData.editRecord.modifiedDate.ToString(); } } string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_modifiedBy", fieldValue, true, ""); tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Modified Date", FieldHelp, false, false, "")); } string s = AdminUIController.editTable(tabPanel.text); result = AdminUIController.getEditPanel(core, true, "Control Information", "", s); adminData.editSectionPanelCount += 1; tabPanel = null; } catch (Exception ex) { LogController.logError(core, ex); } return(result); }
// // ==================================================================================================== /// <summary> /// Create the tabs for editing a record /// </summary> /// <param name="adminData.content"></param> /// <param name="editRecord"></param> /// <returns></returns> public static string get(CoreController core, AdminDataModel adminData) { string returnHtml = ""; try { // if ((!core.doc.userErrorList.Count.Equals(0)) && adminData.editRecord.loaded) { // // block load if there was a user error and it is already loaded (assume error was from response ) } else if (adminData.adminContent.id <= 0) { // // Invalid Content Processor.Controllers.ErrorController.addUserError(core, "There was a problem identifying the content you requested. Please return to the previous form and verify your selection."); return(""); } else if (adminData.editRecord.loaded && !adminData.editRecord.saved) { // // File types need to be reloaded from the Db, because... // LoadDb - sets them to the path-page // LoadResponse - sets the blank if no change, filename if there is an upload // SaveEditRecord - if blank, no change. If a filename it saves the uploaded file // GetForm_Edit - expects the Db value to be in EditRecordValueVariants (path-page) // // xx This was added to bypass the load for the editrefresh case (reload the response so the editor preference can change) // xx I do not know why the following section says "reload even if it is loaded", but lets try this // foreach (var keyValuePair in adminData.adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; if ((keyValuePair.Value.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.File) || (keyValuePair.Value.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileImage)) { adminData.editRecord.fieldsLc[field.nameLc].value = adminData.editRecord.fieldsLc[field.nameLc].dbValue; } } } else { // // otherwise, load the record, even if it was loaded during a previous form process adminData.loadEditRecord(core, true); } if (!AdminDataModel.userHasContentAccess(core, ((adminData.editRecord.contentControlId.Equals(0)) ? adminData.adminContent.id : adminData.editRecord.contentControlId))) { Processor.Controllers.ErrorController.addUserError(core, "Your account on this system does not have access rights to edit this content."); return(""); } // // Setup Edit Referer string EditReferer = core.docProperties.getText(RequestNameEditReferer); if (string.IsNullOrEmpty(EditReferer)) { EditReferer = core.webServer.requestReferer; if (!string.IsNullOrEmpty(EditReferer)) { // // special case - if you are coming from the advanced search, go back to the list page EditReferer = GenericController.strReplace(EditReferer, "&af=39", ""); // // if referer includes AdminWarningMsg (admin hint message), remove it -- this edit may fix the problem int Pos = EditReferer.IndexOf("AdminWarningMsg=", StringComparison.CurrentCulture); if (Pos >= 0) { EditReferer = EditReferer.left(Pos - 2); } } } core.doc.addRefreshQueryString(RequestNameEditReferer, EditReferer); // // load user's editor preferences to fieldEditorPreferences() - this is the editor this user has picked when there are >1 // fieldId:addonId,fieldId:addonId,etc // with custom FancyBox form in edit window with button "set editor preference" // this button causes a 'refresh' action, reloads fields with stream without save // // // ----- determine contentType for editor // CPHtml5BaseClass.EditorContentType contentType; if (GenericController.toLCase(adminData.adminContent.name) == "email templates") { contentType = CPHtml5BaseClass.EditorContentType.contentTypeEmailTemplate; } else if (GenericController.toLCase(adminData.adminContent.tableName) == "cctemplates") { contentType = CPHtml5BaseClass.EditorContentType.contentTypeWebTemplate; } else if (GenericController.toLCase(adminData.adminContent.tableName) == "ccemail") { contentType = CPHtml5BaseClass.EditorContentType.contentTypeEmail; } else { contentType = CPHtml5BaseClass.EditorContentType.contentTypeWeb; } EditorEnvironmentModel editorEnv = new EditorEnvironmentModel { allowHelpMsgCustom = false, editorAddonListJSON = core.html.getWysiwygAddonList(contentType), isRootPage = adminData.adminContent.tableName.ToLowerInvariant().Equals(PageContentModel.tableMetadata.tableNameLower) && (adminData.editRecord.parentId == 0) && (adminData.editRecord.id != 0), needUniqueEmailMessage = false, record_readOnly = adminData.editRecord.userReadOnly, styleList = "", styleOptionList = "", formFieldList = "" }; // // ----- determine access details var userContentPermissions = PermissionController.getUserContentPermissions(core, adminData.adminContent); bool allowDelete = adminData.adminContent.allowDelete && userContentPermissions.allowDelete && (adminData.editRecord.id != 0); bool allowAdd = adminData.adminContent.allowAdd && userContentPermissions.allowAdd; var editButtonBarInfo = new EditButtonBarInfoClass(core, adminData, allowDelete, true, userContentPermissions.allowSave, allowAdd); // string adminContentTableNameLc = adminData.adminContent.tableName.ToLowerInvariant(); bool allowLinkAlias = adminContentTableNameLc.Equals(PageContentModel.tableMetadata.tableNameLower); bool allowPeopleGroups = adminContentTableNameLc.Equals(PersonModel.tableMetadata.tableNameLower);; // //-----Create edit page if (adminContentTableNameLc.Equals(EmailModel.tableMetadata.tableNameLower)) { // LogController.logTrace(core, "getFormEdit, treat as email, adminContentTableNameLower [" + adminContentTableNameLc + "]"); // // -- email bool emailSubmitted = false; bool emailSent = false; DateTime LastSendTestDate = DateTime.MinValue; bool AllowEmailSendWithoutTest = (core.siteProperties.getBoolean("AllowEmailSendWithoutTest", false)); if (adminData.editRecord.fieldsLc.ContainsKey("lastsendtestdate")) { LastSendTestDate = GenericController.encodeDate(adminData.editRecord.fieldsLc["lastsendtestdate"].value); } if (adminData.adminContent.id.Equals(ContentMetadataModel.getContentId(core, "System Email"))) { // LogController.logTrace(core, "getFormEdit, System email"); // // System Email emailSubmitted = false; if (adminData.editRecord.id != 0) { if (adminData.editRecord.fieldsLc.ContainsKey("testmemberid")) { if (encodeInteger(adminData.editRecord.fieldsLc["testmemberid"].value) == 0) { adminData.editRecord.fieldsLc["testmemberid"].value = core.session.user.id; } } } editButtonBarInfo.allowSave = (userContentPermissions.allowSave && adminData.editRecord.allowUserSave && (!emailSubmitted) && (!emailSent)); editButtonBarInfo.allowSendTest = ((!emailSubmitted) && (!emailSent)); } else if (adminData.adminContent.id.Equals(ContentMetadataModel.getContentId(core, "Conditional Email"))) { // // Conditional Email emailSubmitted = false; editorEnv.record_readOnly = adminData.editRecord.userReadOnly || emailSubmitted; if (adminData.editRecord.id != 0) { if (adminData.editRecord.fieldsLc.ContainsKey("submitted")) { emailSubmitted = GenericController.encodeBoolean(adminData.editRecord.fieldsLc["submitted"].value); } } editButtonBarInfo.allowActivate = !emailSubmitted && ((LastSendTestDate != DateTime.MinValue) || AllowEmailSendWithoutTest); editButtonBarInfo.allowDeactivate = emailSubmitted; editButtonBarInfo.allowSave = userContentPermissions.allowSave && adminData.editRecord.allowUserSave && !emailSubmitted; } else { // // Group Email if (adminData.editRecord.id != 0) { emailSubmitted = encodeBoolean(adminData.editRecord.fieldsLc["submitted"].value); emailSent = encodeBoolean(adminData.editRecord.fieldsLc["sent"].value); } editButtonBarInfo.allowSave = !emailSubmitted && (userContentPermissions.allowSave && adminData.editRecord.allowUserSave); editButtonBarInfo.allowSend = !emailSubmitted && ((LastSendTestDate != DateTime.MinValue) || AllowEmailSendWithoutTest); editButtonBarInfo.allowSendTest = !emailSubmitted; editorEnv.record_readOnly = adminData.editRecord.userReadOnly || emailSubmitted || emailSent; } } else if (adminContentTableNameLc.Equals(PageContentModel.tableMetadata.tableNameLower)) { // // Page Content // editButtonBarInfo.allowMarkReviewed = true; editButtonBarInfo.isPageContent = true; editButtonBarInfo.hasChildRecords = true; allowLinkAlias = true; } else { // // All other tables (User definined) var pageContentMetadata = ContentMetadataModel.createByUniqueName(core, "page content"); editButtonBarInfo.isPageContent = pageContentMetadata.isParentOf(core, adminData.adminContent.id); editButtonBarInfo.hasChildRecords = adminData.adminContent.containsField(core, "parentid"); editButtonBarInfo.allowMarkReviewed = core.db.isSQLTableField(adminData.adminContent.tableName, "DateReviewed"); } // // Print common form elements var Stream = new StringBuilderLegacyController(); Stream.add("\r<input type=\"hidden\" name=\"fieldEditorPreference\" id=\"fieldEditorPreference\" value=\"\">"); string editSectionButtonBar = AdminUIController.getSectionButtonBarForEdit(core, editButtonBarInfo); Stream.add(editSectionButtonBar); var headerInfo = new RecordEditHeaderInfoClass { recordId = adminData.editRecord.id, recordLockById = adminData.editRecord.editLock.editLockByMemberId, recordLockExpiresDate = encodeDate(adminData.editRecord.editLock.editLockExpiresDate), recordName = adminData.editRecord.nameLc }; string titleBarDetails = AdminUIController.getEditForm_TitleBarDetails(core, headerInfo, adminData.editRecord); Stream.add(AdminUIController.getSectionHeader(core, "", titleBarDetails)); { var editTabs = new EditTabModel(); EditViewTabList.addContentTabs(core, adminData, editTabs, editorEnv); if (allowPeopleGroups) { EditViewTabList.addCustomTab(core, editTabs, "Groups", GroupRuleEditor.get(core, adminData)); } if (allowLinkAlias) { EditViewTabList.addCustomTab(core, editTabs, "Link Aliases", LinkAliasEditor.getForm_Edit_LinkAliases(core, adminData, adminData.editRecord.userReadOnly)); } EditViewTabList.addCustomTab(core, editTabs, "Control Info", EditViewTabControlInfo.get(core, adminData, editorEnv)); Stream.add(editTabs.getTabs(core)); } Stream.add(editSectionButtonBar); Stream.add(HtmlController.inputHidden("FormFieldList", editorEnv.formFieldList)); returnHtml = wrapForm(core, Stream.text, adminData, AdminFormEdit); // // -- update page title if (adminData.editRecord.id == 0) { core.html.addTitle("Add " + adminData.adminContent.name); } else if (adminData.editRecord.nameLc == "") { core.html.addTitle("Edit #" + adminData.editRecord.id + " in " + adminData.editRecord.contentControlId_Name); } else { core.html.addTitle("Edit " + adminData.editRecord.nameLc + " in " + adminData.editRecord.contentControlId_Name); } } catch (Exception ex) { LogController.logError(core, ex); throw; } return(returnHtml); }