// //======================================================================== // public static string get(CoreController core, AdminDataModel adminData) { string result = null; try { string editorRow = ""; editorRow = AdminUIEditorController.getGroupRuleEditor(core, adminData); result = AdminUIController.getEditPanel(core, true, "Group Membership", "", editorRow); adminData.editSectionPanelCount += 1; } catch (Exception ex) { LogController.logError(core, ex); } return(result); }
// public EditButtonBarInfoClass(CoreController core, AdminDataModel adminData, bool allowDelete, bool allowRefresh, bool allowSave, bool allowAdd) { allowActivate = false; this.allowAdd = (allowAdd && adminData.adminContent.allowAdd && adminData.editRecord.getAllowUserAdd()); allowCancel = true; allowCreateDuplicate = allowAdd && (adminData.editRecord.id != 0); allowDeactivate = false; this.allowDelete = allowDelete && adminData.editRecord.allowUserDelete && core.session.isAuthenticatedDeveloper(); allowMarkReviewed = false; this.allowRefresh = allowRefresh; this.allowSave = (allowSave && adminData.editRecord.allowUserSave); allowSend = false; allowSendTest = false; hasChildRecords = false; isPageContent = false; contentId = adminData.adminContent.id; }
public ActionResult AdminLogin(AdminLoginModel ad) { var admindata = new AdminDataModel(); admindata.GetAdminData(); admindata.admin_user = ad.admin_username; admindata.admin_pass = ad.admin_password; if (admindata != null && admindata.admin_pass == ad.admin_password) { FormsAuthentication.SetAuthCookie("admin_password", false); return(RedirectToAction("Index", "AdminOperations")); } else { ViewBag.ErrorMessage = "Kullanıcı bulunamadı. Lütfen blgilerinizi kontrol ediniz."; return(RedirectToAction("Index", "Home")); } }
public ActionResult EditDetails(AdminDataModel dt) { CASDatabaseEntities db = new CASDatabaseEntities(); Admin objAdmin = new Admin(); var id = Convert.ToInt32(Session["UserID"]); var getData = db.Admins.Where(a => a.UserID == id).FirstOrDefault(); if (ModelState.IsValid) { if (getData != null) { getData.FirstName = dt.FirstName; getData.LastName = dt.LastName; getData.Gender = dt.Gender; getData.Address = dt.Address; } else { objAdmin.FirstName = dt.FirstName; objAdmin.LastName = dt.LastName; objAdmin.Gender = dt.Gender; objAdmin.Address = dt.Address; db.Admins.Add(objAdmin); } db.SaveChanges(); } var checkName = db.Admins.Where(a => a.UserID == id).FirstOrDefault(); if (checkName.FirstName != null) { Session["Name"] = checkName.FirstName; } else { Session["Name"] = null; } Session["ID"] = checkName.AdminID; return(View(dt)); }
public ActionResult EditDetails() { CASDatabaseEntities db = new CASDatabaseEntities(); AdminDataModel dt = new AdminDataModel(); var id = Convert.ToInt32(Session["UserID"]); var getData = db.Admins.Where(a => a.UserID == id).FirstOrDefault(); if (getData != null) { dt.FirstName = getData.FirstName; dt.LastName = getData.LastName; dt.Gender = getData.Gender; dt.Address = getData.Address; } else { dt.FirstName = null; } return(View(dt)); }
// //======================================================================== // private static string wrapForm(CoreController core, string innerHtml, AdminDataModel adminData, int AdminFormID) { try { core.html.addScriptCode("var docLoaded=false", "Form loader"); core.html.addScriptCode_onLoad("docLoaded=true;", "Form loader"); string result = Environment.NewLine + "<!-- block --><div class=\"d-none\"><input type=password name=\"password_block\" value=\"\"><input type=text name=\"username_block\" value=\"\"></div><!-- end block -->"; result += Environment.NewLine + "<input TYPE=\"hidden\" NAME=\"" + rnAdminSourceForm + "\" VALUE=\"" + AdminFormID + "\">"; result += Environment.NewLine + "<input TYPE=\"hidden\" NAME=\"" + RequestNameTitleExtension + "\" VALUE=\"" + adminData.titleExtension + "\">"; result += Environment.NewLine + "<input TYPE=\"hidden\" NAME=\"" + RequestNameAdminDepth + "\" VALUE=\"" + adminData.ignore_legacyMenuDepth + "\">"; result += Environment.NewLine + "<input TYPE=\"hidden\" NAME=\"FormEmptyFieldList\" ID=\"FormEmptyFieldList\" VALUE=\",\">"; result += innerHtml; return(HtmlController.form(core, result, new CPBase.BaseModels.HtmlAttributesForm() { onsubmit = "cj.admin.saveEmptyFieldList('FormEmptyFieldList')", autocomplete = false })); } catch (Exception ex) { LogController.logError(core, ex); return(innerHtml); } }
// //================================================================================= // //================================================================================= // public static string get(CPClass cp, CoreController core, AdminDataModel adminData) { string returnForm = ""; try { // string SearchValue = null; FindWordMatchEnum MatchOption = 0; int FormFieldPtr = 0; int FormFieldCnt = 0; ContentMetadataModel CDef = null; string FieldName = null; StringBuilderLegacyController Stream = new StringBuilderLegacyController(); int FieldPtr = 0; bool RowEven = false; string RQS = null; string[] FieldNames = { }; string[] FieldCaption = { }; int[] fieldId = null; CPContentBaseClass.FieldTypeIdEnum[] fieldTypeId = { }; string[] FieldValue = { }; int[] FieldMatchOptions = { }; int FieldMatchOption = 0; string[] FieldLookupContentName = { }; string[] FieldLookupList = { }; int ContentId = 0; int FieldCnt = 0; int FieldSize = 0; int RowPointer = 0; string LeftButtons = ""; string ButtonBar = null; string Title = null; string TitleBar = null; string Content = null; // // Process last form // string Button = core.docProperties.getText("button"); IndexConfigClass IndexConfig = null; if (!string.IsNullOrEmpty(Button)) { switch (Button) { case ButtonSearch: IndexConfig = IndexConfigClass.get(core, adminData); FormFieldCnt = core.docProperties.getInteger("fieldcnt"); if (FormFieldCnt > 0) { for (FormFieldPtr = 0; FormFieldPtr < FormFieldCnt; FormFieldPtr++) { FieldName = GenericController.toLCase(core.docProperties.getText("fieldname" + FormFieldPtr)); MatchOption = (FindWordMatchEnum)core.docProperties.getInteger("FieldMatch" + FormFieldPtr); switch (MatchOption) { case FindWordMatchEnum.MatchEquals: case FindWordMatchEnum.MatchGreaterThan: case FindWordMatchEnum.matchincludes: case FindWordMatchEnum.MatchLessThan: SearchValue = core.docProperties.getText("FieldValue" + FormFieldPtr); break; default: SearchValue = ""; break; } if (!IndexConfig.findWords.ContainsKey(FieldName)) { // // fieldname not found, save if not FindWordMatchEnum.MatchIgnore // if (MatchOption != FindWordMatchEnum.MatchIgnore) { IndexConfig.findWords.Add(FieldName, new IndexConfigFindWordClass { Name = FieldName, MatchOption = MatchOption, Value = SearchValue }); } } else { // // fieldname was found // IndexConfig.findWords[FieldName].MatchOption = MatchOption; IndexConfig.findWords[FieldName].Value = SearchValue; } } } GetHtmlBodyClass.setIndexSQL_SaveIndexConfig(cp, core, IndexConfig); return(string.Empty); case ButtonCancel: return(string.Empty); } } IndexConfig = IndexConfigClass.get(core, adminData); Button = "CriteriaSelect"; RQS = core.doc.refreshQueryString; // // ----- ButtonBar // if (adminData.ignore_legacyMenuDepth > 0) { LeftButtons += AdminUIController.getButtonPrimary(ButtonClose, "window.close();"); } else { LeftButtons += AdminUIController.getButtonPrimary(ButtonCancel); } LeftButtons += AdminUIController.getButtonPrimary(ButtonSearch); ButtonBar = AdminUIController.getSectionButtonBar(core, LeftButtons, ""); // // ----- TitleBar // Title = adminData.adminContent.name; Title = Title + " Advanced Search"; string TitleDescription = "<div>Enter criteria for each field to identify and select your results. The results of a search will have to have all of the criteria you enter.</div>"; TitleBar = AdminUIController.getSectionHeader(core, Title, TitleDescription); // // ----- List out all fields // CDef = ContentMetadataModel.createByUniqueName(core, adminData.adminContent.name); FieldSize = 100; Array.Resize(ref FieldNames, FieldSize + 1); Array.Resize(ref FieldCaption, FieldSize + 1); Array.Resize(ref fieldId, FieldSize + 1); Array.Resize(ref fieldTypeId, FieldSize + 1); Array.Resize(ref FieldValue, FieldSize + 1); Array.Resize(ref FieldMatchOptions, FieldSize + 1); Array.Resize(ref FieldLookupContentName, FieldSize + 1); Array.Resize(ref FieldLookupList, FieldSize + 1); foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminData.adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; if (FieldPtr >= FieldSize) { FieldSize = FieldSize + 100; Array.Resize(ref FieldNames, FieldSize + 1); Array.Resize(ref FieldCaption, FieldSize + 1); Array.Resize(ref fieldId, FieldSize + 1); Array.Resize(ref fieldTypeId, FieldSize + 1); Array.Resize(ref FieldValue, FieldSize + 1); Array.Resize(ref FieldMatchOptions, FieldSize + 1); Array.Resize(ref FieldLookupContentName, FieldSize + 1); Array.Resize(ref FieldLookupList, FieldSize + 1); } FieldName = GenericController.toLCase(field.nameLc); FieldNames[FieldPtr] = FieldName; FieldCaption[FieldPtr] = field.caption; fieldId[FieldPtr] = field.id; fieldTypeId[FieldPtr] = field.fieldTypeId; if (fieldTypeId[FieldPtr] == CPContentBaseClass.FieldTypeIdEnum.Lookup) { ContentId = field.lookupContentId; if (ContentId > 0) { FieldLookupContentName[FieldPtr] = MetadataController.getContentNameByID(core, ContentId); } FieldLookupList[FieldPtr] = field.lookupList; } // // set prepoplate value from indexconfig // if (IndexConfig.findWords.ContainsKey(FieldName)) { FieldValue[FieldPtr] = IndexConfig.findWords[FieldName].Value; FieldMatchOptions[FieldPtr] = (int)IndexConfig.findWords[FieldName].MatchOption; } FieldPtr += 1; } FieldCnt = FieldPtr; // // Add headers to stream // returnForm = returnForm + "<table border=0 width=100% cellspacing=0 cellpadding=4>"; // RowPointer = 0; for (FieldPtr = 0; FieldPtr < FieldCnt; FieldPtr++) { returnForm = returnForm + HtmlController.inputHidden("fieldname" + FieldPtr, FieldNames[FieldPtr]); RowEven = ((RowPointer % 2) == 0); FieldMatchOption = FieldMatchOptions[FieldPtr]; switch (fieldTypeId[FieldPtr]) { case CPContentBaseClass.FieldTypeIdEnum.Date: // // Date returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not empty</div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchEquals).ToString(), FieldMatchOption.ToString(), "") + "=</div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchGreaterThan).ToString(), FieldMatchOption.ToString(), "") + "></div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchLessThan).ToString(), FieldMatchOption.ToString(), "") + "<</div>" + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputDate(core, "fieldvalue" + FieldPtr, encodeDate(FieldValue[FieldPtr])).Replace(">", " onFocus=\"ccAdvSearchText\">") + "</div>" + "</div>" + "</td>" + "</tr>"; break; case CPContentBaseClass.FieldTypeIdEnum.Currency: case CPContentBaseClass.FieldTypeIdEnum.Float: case CPContentBaseClass.FieldTypeIdEnum.Integer: case CPContentBaseClass.FieldTypeIdEnum.AutoIdIncrement: // // -- Numeric - changed FindWordMatchEnum.MatchEquals to MatchInclude to be compatible with Find Search returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not empty</div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.matchincludes).ToString(), FieldMatchOption.ToString(), "n" + FieldPtr) + "=</div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchGreaterThan).ToString(), FieldMatchOption.ToString(), "") + "></div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchLessThan).ToString(), FieldMatchOption.ToString(), "") + "<</div>" + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputText_Legacy(core, "fieldvalue" + FieldPtr, FieldValue[FieldPtr], 1, 5, "", false, false, "ccAdvSearchText").Replace(">", " onFocus=\"var e=getElementById('n" + FieldPtr + "');e.checked=1;\">") + "</div>" + "</div>" + "</td>" + "</tr>"; RowPointer += 1; break; case CPContentBaseClass.FieldTypeIdEnum.File: case CPContentBaseClass.FieldTypeIdEnum.FileImage: // // File // returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not empty</div>" + "</div>" + "</td>" + "</tr>"; RowPointer = RowPointer + 1; break; case CPContentBaseClass.FieldTypeIdEnum.Boolean: // // Boolean // returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchTrue).ToString(), FieldMatchOption.ToString(), "") + "true</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchFalse).ToString(), FieldMatchOption.ToString(), "") + "false</div>" + "</div>" + "</td>" + "</tr>"; break; case CPContentBaseClass.FieldTypeIdEnum.Text: case CPContentBaseClass.FieldTypeIdEnum.LongText: case CPContentBaseClass.FieldTypeIdEnum.HTML: case CPContentBaseClass.FieldTypeIdEnum.HTMLCode: case CPContentBaseClass.FieldTypeIdEnum.FileHTML: case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: case CPContentBaseClass.FieldTypeIdEnum.FileCSS: case CPContentBaseClass.FieldTypeIdEnum.FileJavascript: case CPContentBaseClass.FieldTypeIdEnum.FileXML: // // Text // returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not empty</div>" + "<div style=\"display:block;float:left;width:150px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.matchincludes).ToString(), FieldMatchOption.ToString(), "t" + FieldPtr) + "includes</div>" + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputText_Legacy(core, "fieldvalue" + FieldPtr, FieldValue[FieldPtr], 1, 5, "", false, false, "ccAdvSearchText").Replace(">", " onFocus=\"var e=getElementById('t" + FieldPtr + "');e.checked=1;\">") + "</div>" + "</div>" + "</td>" + "</tr>"; RowPointer = RowPointer + 1; break; case CPContentBaseClass.FieldTypeIdEnum.Lookup: case CPContentBaseClass.FieldTypeIdEnum.MemberSelect: // // Lookup returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not empty</div>" + "<div style=\"display:block;float:left;width:150px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.matchincludes).ToString(), FieldMatchOption.ToString(), "t" + FieldPtr) + "includes</div>" + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputText_Legacy(core, "fieldvalue" + FieldPtr, FieldValue[FieldPtr], 1, 5, "", false, false, "ccAdvSearchText").Replace(">", " onFocus=\"var e=getElementById('t" + FieldPtr + "'); e.checked= 1;\">") + "</div>" + "</div>" + "</td>" + "</tr>"; RowPointer = RowPointer + 1; break; } } returnForm = returnForm + HtmlController.tableRowStart(); returnForm = returnForm + HtmlController.tableCellStart("120", 1, RowEven, "right") + "<img src=" + cdnPrefix + "images/spacer.gif width=120 height=1></td>"; returnForm = returnForm + HtmlController.tableCellStart("99%", 1, RowEven, "left") + "<img src=" + cdnPrefix + "images/spacer.gif width=1 height=1></td>"; returnForm = returnForm + kmaEndTableRow; returnForm = returnForm + "</table>"; Content = returnForm; // // Assemble LiveWindowTable Stream.add(ButtonBar); Stream.add(TitleBar); Stream.add(Content); Stream.add(ButtonBar); Stream.add("<input type=hidden name=fieldcnt VALUE=" + FieldCnt + ">"); Stream.add("<input type=hidden name=" + RequestNameAdminSubForm + " VALUE=" + AdminFormIndex_SubFormAdvancedSearch + ">"); returnForm = HtmlController.form(core, Stream.text); core.html.addTitle(adminData.adminContent.name + " Advanced Search"); } catch (Exception ex) { LogController.logError(core, ex); throw; } return(returnForm); }
// //======================================================================== /// <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); }
// //=========================================================================== // public static string get(CoreController core, AdminDataModel adminData, IndexConfigClass indexConfig, PermissionController.UserContentPermissions userContentPermissions, string sql, DataSourceModel dataSource, Dictionary <string, bool> FieldUsedInColumns, Dictionary <string, bool> IsLookupFieldValid) { try { bool allowDelete = (adminData.adminContent.allowDelete) && (userContentPermissions.allowDelete) && (indexConfig.allowDelete); var DataTable_HdrRow = new StringBuilder("<tr>"); // // Row Number Column DataTable_HdrRow.Append("<td width=20 align=center valign=bottom class=\"small ccAdminListCaption\">Row</td>"); // // Edit Column DataTable_HdrRow.Append("<td width=20 align=center valign=bottom class=\"small ccAdminListCaption\">Edit</td>"); // // Delete Select Box Columns if (!allowDelete) { DataTable_HdrRow.Append("<td width=20 align=center valign=bottom class=\"small ccAdminListCaption\"><input TYPE=CheckBox disabled=\"disabled\"></td>"); } else { DataTable_HdrRow.Append("<td width=20 align=center valign=bottom class=\"small ccAdminListCaption\"><input TYPE=CheckBox OnClick=\"CheckInputs('DelCheck',this.checked);\"></td>"); } // // -- create header int ColumnWidthTotal = 0; foreach (var column in indexConfig.columns) { if (column.Width < 1) { column.Width = 1; } ColumnWidthTotal += column.Width; } foreach (var column in indexConfig.columns) { // // ----- print column headers - anchored so they sort columns // int ColumnWidth = encodeInteger((100 * column.Width) / (double)ColumnWidthTotal); // // if this is a current sort ,add the reverse flag // StringBuilder buttonHref = new StringBuilder(); buttonHref.Append("/" + core.appConfig.adminRoute + "?" + rnAdminForm + "=" + AdminFormIndex + "&SetSortField=" + column.Name + "&RT=0&" + RequestNameTitleExtension + "=" + GenericController.encodeRequestVariable(adminData.titleExtension) + "&cid=" + adminData.adminContent.id + "&ad=" + adminData.ignore_legacyMenuDepth); if (!indexConfig.sorts.ContainsKey(column.Name)) { buttonHref.Append("&SetSortDirection=1"); } else { switch (indexConfig.sorts[column.Name].direction) { case 1: { buttonHref.Append("&SetSortDirection=2"); break; } case 2: { buttonHref.Append("&SetSortDirection=0"); break; } default: { // nothing break; } } } // // -- column header includes WherePairCount if (!adminData.wherePair.Count.Equals(0)) { int ptr = 0; foreach (var kvp in adminData.wherePair) { if (!string.IsNullOrWhiteSpace(kvp.Key)) { buttonHref.Append("&wl" + ptr + "=" + GenericController.encodeRequestVariable(kvp.Value)); buttonHref.Append("&wr" + ptr + "=" + GenericController.encodeRequestVariable(kvp.Value)); ptr++; } } } string buttonFace = adminData.adminContent.fields[column.Name.ToLowerInvariant()].caption; buttonFace = GenericController.strReplace(buttonFace, " ", " "); string SortTitle = "Sort A-Z"; // if (indexConfig.sorts.ContainsKey(column.Name)) { string sortSuffix = ((indexConfig.sorts.Count < 2) ? "" : indexConfig.sorts[column.Name].order.ToString()); switch (indexConfig.sorts[column.Name].direction) { case 1: { buttonFace = iconArrowDown + sortSuffix + " " + buttonFace; SortTitle = "Sort Z-A"; break; } case 2: { buttonFace = iconArrowUp + sortSuffix + " " + buttonFace; SortTitle = "Remove Sort"; break; } default: { // nothing break; } } } if (indexConfig.allowColumnSort) { buttonFace = HtmlController.a(buttonFace, new CPBase.BaseModels.HtmlAttributesA() { title = SortTitle, href = buttonHref.ToString(), @class = "ccAdminListCaption" }); } adminData.buttonObjectCount += 1; DataTable_HdrRow.Append("<td width=\"" + ColumnWidth + "%\" valign=bottom align=left class=\"small ccAdminListCaption\">"); DataTable_HdrRow.Append(buttonFace); DataTable_HdrRow.Append("</td>"); } DataTable_HdrRow.Append("</tr>"); // // -- generic admin url for edit and add links string adminEditPresetArgQsList = ""; string adminUrlBase = "\\" + core.appConfig.adminRoute + "?" + rnAdminAction + "=" + Constants.AdminActionNop + "&cid=" + adminData.adminContent.id + "&" + RequestNameTitleExtension + "=" + GenericController.encodeRequestVariable(adminData.titleExtension) + "&ad=" + adminData.ignore_legacyMenuDepth + "&" + rnAdminSourceForm + "=" + adminData.adminForm + "&" + rnAdminForm + "=" + AdminFormEdit; if (!adminData.wherePair.Count.Equals(0)) { int WhereCount = 0; foreach (var kvp in adminData.wherePair) { adminEditPresetArgQsList += "&" + encodeRequestVariable(kvp.Key) + "=" + GenericController.encodeRequestVariable(kvp.Value); WhereCount++; } adminUrlBase += adminEditPresetArgQsList; } // // -- output data rows var dataTableRows = new StringBuilder(); string rowColor = ""; int rowNumber = 0; int rowNumberLast = 0; using (var csData = new CsModel(core)) { if (csData.openSql(sql, dataSource.name, indexConfig.recordsPerPage, indexConfig.pageNumber)) { rowNumber = indexConfig.recordTop; rowNumberLast = indexConfig.recordTop + indexConfig.recordsPerPage; // // --- Print out the records while ((csData.ok()) && (rowNumber < rowNumberLast)) { int recordId = csData.getInteger("ID"); if (rowColor == "class=\"ccAdminListRowOdd\"") { rowColor = "class=\"ccAdminListRowEven\""; } else { rowColor = "class=\"ccAdminListRowOdd\""; } // // -- new row dataTableRows.Append(Environment.NewLine + "<tr>"); // // --- row number column dataTableRows.Append("<td align=right " + rowColor + ">" + (rowNumber + 1).ToString() + "</td>"); // // --- edit column dataTableRows.Append("<td align=center " + rowColor + ">" + getRecordEditAnchorTag(adminUrlBase + "&id=" + recordId) + "</td>"); // // --- Delete Checkbox Columns if (allowDelete) { dataTableRows.Append("<td align=center " + rowColor + "><input TYPE=CheckBox NAME=row" + rowNumber + " VALUE=1 ID=\"DelCheck\"><input type=hidden name=rowid" + rowNumber + " VALUE=" + recordId + "></span></td>"); } else { dataTableRows.Append("<td align=center " + rowColor + "><input TYPE=CheckBox disabled=\"disabled\" NAME=row" + rowNumber + " VALUE=1><input type=hidden name=rowid" + rowNumber + " VALUE=" + recordId + "></span></td>"); } // // --- field columns foreach (var column in indexConfig.columns) { string columnNameLc = column.Name.ToLowerInvariant(); if (FieldUsedInColumns.ContainsKey(columnNameLc)) { if (FieldUsedInColumns[columnNameLc]) { dataTableRows.Append((Environment.NewLine + "<td valign=\"middle\" " + rowColor + " align=\"left\">" + SpanClassAdminNormal)); dataTableRows.Append(getGridCell(core, adminData, column.Name, csData, IsLookupFieldValid[columnNameLc], GenericController.toLCase(adminData.adminContent.tableName) == "ccemail")); dataTableRows.Append((" </span></td>")); } } } dataTableRows.Append(("\n </tr>")); csData.goNext(); rowNumber = rowNumber + 1; } dataTableRows.Append("<input type=hidden name=rowcnt value=" + rowNumber + ">"); // // --- print out the stuff at the bottom // int RecordTop_NextPage = indexConfig.recordTop; if (csData.ok()) { RecordTop_NextPage = rowNumber; } int RecordTop_PreviousPage = indexConfig.recordTop - indexConfig.recordsPerPage; if (RecordTop_PreviousPage < 0) { RecordTop_PreviousPage = 0; } } } // // Header at bottom // if (rowColor == "class=\"ccAdminListRowOdd\"") { rowColor = "class=\"ccAdminListRowEven\""; } else { rowColor = "class=\"ccAdminListRowOdd\""; } string blankRow = "<tr><td colspan=" + (indexConfig.columns.Count + 3) + " " + rowColor + " style=\"text-align:left ! important;\">{msg}</td></tr>"; if (rowNumber == 0) { // // -- No records found dataTableRows.Append(blankRow.Replace("{msg}", "----- no records were found -----")); } else { if (rowNumber < rowNumberLast) { // // --End of list dataTableRows.Append(blankRow.Replace("{msg}", "----- end of list -----")); } } if (indexConfig.allowAddRow) { // // optional AddRow foreach (var addTag in getRecordAddAnchorTag(core, adminData.adminContent.name, adminEditPresetArgQsList, false, userContentPermissions.allowAdd)) { dataTableRows.Append(blankRow.Replace("{msg}", addTag)); } } // // Add another header to the data rows // dataTableRows.Append(DataTable_HdrRow.ToString()); // var DataTable_FindRow = new StringBuilder(); if (indexConfig.allowFind) { // // ----- DataTable_FindRow // DataTable_FindRow.Append("<tr><td colspan=" + (3 + indexConfig.columns.Count) + " style=\"background-color:black;height:1;\"></td></tr>"); DataTable_FindRow.Append("<tr>"); DataTable_FindRow.Append("<td valign=\"middle\" colspan=3 width=\"60\" class=\"ccPanel\" align=center style=\"vertical-align:middle;padding:8px;text-align:center ! important;\">"); DataTable_FindRow.Append(AdminUIController.getButtonPrimary(ButtonFind, "", false, "FindButton") + "</td>"); int ColumnPointer = 0; var listOfMatches = new List <FindWordMatchEnum> { FindWordMatchEnum.matchincludes, FindWordMatchEnum.MatchEquals, FindWordMatchEnum.MatchTrue, FindWordMatchEnum.MatchFalse }; foreach (var column in indexConfig.columns) { string FieldName = GenericController.toLCase(column.Name); string FindWordValue = ""; if (indexConfig.findWords.ContainsKey(FieldName)) { var findWord = indexConfig.findWords[FieldName]; if (listOfMatches.Any(s => findWord.MatchOption.Equals(s))) { FindWordValue = findWord.Value; } } DataTable_FindRow.Append(Environment.NewLine + "<td valign=\"middle\" align=\"center\" class=\"ccPanel3DReverse\" style=\"padding:8px;\">" + "<input type=hidden name=\"FindName" + ColumnPointer + "\" value=\"" + FieldName + "\">" + "<input class=\"form-control findInput\" onkeypress=\"KeyCheck(event);\" type=text id=\"F" + ColumnPointer + "\" name=\"FindValue" + ColumnPointer + "\" value=\"" + FindWordValue + "\" style=\"padding-right:.2rem;padding-left:.2rem;\">" + "</td>"); ColumnPointer += 1; } DataTable_FindRow.Append("</tr>"); } // // Assemble DataTable // string grid = "" + "<table ID=\"DataTable\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"Background-Color:white;\">" + DataTable_HdrRow + dataTableRows + DataTable_FindRow + "</table>"; return(grid); } catch (Exception ex) { LogController.logError(core, ex); return(HtmlController.div("There was an error creating the record list.")); } }
// //================================================================================= /// <summary> /// Load the index config, if it is empty, setup defaults /// </summary> /// <param name="core"></param> /// <param name="adminData"></param> /// <returns></returns> public static IndexConfigClass get(CoreController core, AdminDataModel adminData) { IndexConfigClass returnIndexConfig = new IndexConfigClass { contentID = adminData.adminContent.id, activeOnly = false, lastEditedByMe = false, lastEditedToday = false, lastEditedPast7Days = false, lastEditedPast30Days = false, loaded = true, open = false, pageNumber = 1, recordsPerPage = Constants.RecordsPerPageDefault, recordTop = 0, groupList = new string[groupListCntMax], groupListCnt = 0, columns = new List <IndexConfigColumnClass>(), sorts = new Dictionary <string, IndexConfigSortClass>(), findWords = new Dictionary <string, IndexConfigFindWordClass>(), allowDelete = true, allowFind = true, allowAddRow = false, allowColumnSort = true }; try { // // Setup Member Properties string ConfigList = core.userProperty.getText(AdminDataModel.IndexConfigPrefix + encodeText(adminData.adminContent.id), ""); if (!string.IsNullOrEmpty(ConfigList)) { // // load values // ConfigList += Environment.NewLine; string[] ConfigListLines = GenericController.splitNewLine(ConfigList); int Ptr = 0; while (Ptr < ConfigListLines.GetUpperBound(0)) { // // check next line // string ConfigListLine = GenericController.toLCase(ConfigListLines[Ptr]); if (!string.IsNullOrEmpty(ConfigListLine)) { if (ConfigListLine.Equals("columns")) { Ptr += 1; while (!string.IsNullOrEmpty(ConfigListLines[Ptr])) { string Line = ConfigListLines[Ptr]; string[] LineSplit = Line.Split('\t'); if (LineSplit.GetUpperBound(0) > 0) { string fieldName = LineSplit[0].Trim().ToLowerInvariant(); if (!string.IsNullOrWhiteSpace(fieldName)) { if (adminData.adminContent.fields.ContainsKey(fieldName)) { returnIndexConfig.columns.Add(new IndexConfigColumnClass { Name = fieldName, Width = GenericController.encodeInteger(LineSplit[1]), SortDirection = 0, SortPriority = 0 }); } } } Ptr += 1; } } else if (ConfigListLine.Equals("sorts")) { Ptr += 1; int orderPtr = 0; while (!string.IsNullOrEmpty(ConfigListLines[Ptr])) { string[] LineSplit = ConfigListLines[Ptr].Split('\t'); if (LineSplit.GetUpperBound(0) == 1) { string fieldName = LineSplit[0].Trim().ToLowerInvariant(); if (!string.IsNullOrWhiteSpace(fieldName)) { returnIndexConfig.sorts.Add(fieldName, new IndexConfigSortClass { fieldName = fieldName, direction = ((LineSplit[1] == "1") ? 1 : 2), order = ++orderPtr }); } } Ptr += 1; } } } Ptr += 1; } if (returnIndexConfig.recordsPerPage <= 0) { returnIndexConfig.recordsPerPage = Constants.RecordsPerPageDefault; } } // // Setup Visit Properties ConfigList = core.visitProperty.getText(AdminDataModel.IndexConfigPrefix + encodeText(adminData.adminContent.id), ""); if (!string.IsNullOrEmpty(ConfigList)) { // // load values ConfigList += Environment.NewLine; string[] ConfigListLines = GenericController.splitNewLine(ConfigList); int Ptr = 0; while (Ptr < ConfigListLines.GetUpperBound(0)) { // // check next line string ConfigListLine = GenericController.toLCase(ConfigListLines[Ptr]); if (!string.IsNullOrEmpty(ConfigListLine)) { switch (ConfigListLine) { case "findwordlist": Ptr += 1; while (!string.IsNullOrEmpty(ConfigListLines[Ptr])) { string Line = ConfigListLines[Ptr]; string[] LineSplit = Line.Split('\t'); if (LineSplit.GetUpperBound(0) > 1) { returnIndexConfig.findWords.Add(LineSplit[0], new IndexConfigFindWordClass { Name = LineSplit[0], Value = LineSplit[1], MatchOption = (FindWordMatchEnum)GenericController.encodeInteger(LineSplit[2]) }); } Ptr += 1; } break; case "grouplist": Ptr += 1; while ((Ptr < ConfigListLines.GetUpperBound(0)) && !string.IsNullOrEmpty(ConfigListLines[Ptr])) { if (returnIndexConfig.groupListCnt < groupListCntMax) { returnIndexConfig.groupList[returnIndexConfig.groupListCnt] = ConfigListLines[Ptr]; returnIndexConfig.groupListCnt += 1; } Ptr += 1; } break; case "cdeflist": Ptr += 1; returnIndexConfig.subCDefID = GenericController.encodeInteger(ConfigListLines[Ptr]); break; case "indexfiltercategoryid": // -- remove deprecated value Ptr += 1; break; case "indexfilteractiveonly": returnIndexConfig.activeOnly = true; break; case "indexfilterlasteditedbyme": returnIndexConfig.lastEditedByMe = true; break; case "indexfilterlasteditedtoday": returnIndexConfig.lastEditedToday = true; break; case "indexfilterlasteditedpast7days": returnIndexConfig.lastEditedPast7Days = true; break; case "indexfilterlasteditedpast30days": returnIndexConfig.lastEditedPast30Days = true; break; case "indexfilteropen": returnIndexConfig.open = true; break; case "recordsperpage": Ptr += 1; returnIndexConfig.recordsPerPage = GenericController.encodeInteger(ConfigListLines[Ptr]); if (returnIndexConfig.recordsPerPage <= 0) { returnIndexConfig.recordsPerPage = 50; } returnIndexConfig.recordTop = DbController.getStartRecord(returnIndexConfig.recordsPerPage, returnIndexConfig.pageNumber); break; case "pagenumber": Ptr += 1; returnIndexConfig.pageNumber = GenericController.encodeInteger(ConfigListLines[Ptr]); if (returnIndexConfig.pageNumber <= 0) { returnIndexConfig.pageNumber = 1; } returnIndexConfig.recordTop = DbController.getStartRecord(returnIndexConfig.recordsPerPage, returnIndexConfig.pageNumber); break; default: break; } } Ptr += 1; } if (returnIndexConfig.recordsPerPage <= 0) { returnIndexConfig.recordsPerPage = Constants.RecordsPerPageDefault; } } // // Setup defaults if not loaded // if ((returnIndexConfig.columns.Count == 0) && (adminData.adminContent.adminColumns.Count > 0)) { foreach (var keyValuePair in adminData.adminContent.adminColumns) { returnIndexConfig.columns.Add(new IndexConfigColumnClass { Name = keyValuePair.Value.Name.ToLowerInvariant(), Width = keyValuePair.Value.Width }); } } } catch (Exception ex) { LogController.logError(core, ex); throw; } return(returnIndexConfig); }
// //======================================================================== // public static string getForm_Edit_LinkAliases(CoreController core, AdminDataModel adminData, bool readOnlyField) { string tempGetForm_Edit_LinkAliases = null; try { // // Link Alias value from the admin data // string TabDescription = "Link Aliases are URLs used for this content that are more friendly to users and search engines. If you set the Link Alias field, this name will be used on the URL for this page. If you leave the Link Alias blank, the page name will be used. Below is a list of names that have been used previously and are still active. All of these entries when used in the URL will resolve to this page. The first entry in this list will be used to create menus on the site. To move an entry to the top, type it into the Link Alias field and save."; string tabContent = " "; if (!core.siteProperties.allowLinkAlias) { // // Disabled // TabDescription = "<p>The Link Alias feature is currently disabled. To enable Link Aliases, check the box marked 'Allow Link Alias' on the Page Settings page found on the Navigator under 'Settings'.</p><p>" + TabDescription + "</p>"; } else { // // Link Alias Field // string linkAlias = ""; if (adminData.adminContent.fields.ContainsKey("linkalias")) { linkAlias = GenericController.encodeText(adminData.editRecord.fieldsLc["linkalias"].value); } StringBuilderLegacyController form = new StringBuilderLegacyController(); form.add("<tr><td class=\"ccAdminEditCaption\">" + SpanClassAdminSmall + "Link Alias</td>"); form.add("<td class=\"ccAdminEditField\" align=\"left\" colspan=\"2\">" + SpanClassAdminNormal); if (readOnlyField) { form.add(linkAlias); } else { form.add(HtmlController.inputText_Legacy(core, "LinkAlias", linkAlias)); } form.add("</span></td></tr>"); // // Override Duplicates // form.add("<tr><td class=\"ccAdminEditCaption\">" + SpanClassAdminSmall + "Override Duplicates</td>"); form.add("<td class=\"ccAdminEditField\" align=\"left\" colspan=\"2\">" + SpanClassAdminNormal); if (readOnlyField) { form.add("No"); } else { form.add(HtmlController.checkbox("OverrideDuplicate", false)); } form.add("</span></td></tr>"); // // Table of old Link Aliases // // todo int LinkCnt = 0; string LinkList = ""; using (var csData = new CsModel(core)) { csData.open("Link Aliases", "pageid=" + adminData.editRecord.id, "ID Desc", true, 0, "name"); while (csData.ok()) { LinkList += "<div style=\"margin-left:4px;margin-bottom:4px;\">" + HtmlController.encodeHtml(csData.getText("name")) + "</div>"; LinkCnt += 1; csData.goNext(); } } if (LinkCnt > 0) { form.add("<tr><td class=\"ccAdminEditCaption\">" + SpanClassAdminSmall + "Previous Link Alias List</td>"); form.add("<td class=\"ccAdminEditField\" align=\"left\" colspan=\"2\">" + SpanClassAdminNormal); form.add(LinkList); form.add("</span></td></tr>"); } tabContent = AdminUIController.editTable(form.text); } // tempGetForm_Edit_LinkAliases = AdminUIController.getEditPanel(core, true, "Link Aliases", TabDescription, tabContent); adminData.editSectionPanelCount += 1; } catch (Exception ex) { LogController.logError(core, ex); } return(tempGetForm_Edit_LinkAliases); }
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)); }
// //============================================================================= // Export the Admin List form results //============================================================================= // public static string get(CoreController core, AdminDataModel adminData) { string result = ""; try { // bool AllowContentAccess = false; string ButtonCommaList = ""; string ExportName = null; string Description = null; string Content = ""; string Button = null; int RecordLimit = 0; int recordCnt = 0; string sqlFieldList = ""; string SQLFrom = ""; string SQLWhere = ""; string SQLOrderBy = ""; bool IsLimitedToSubContent = false; string ContentAccessLimitMessage = ""; Dictionary <string, bool> FieldUsedInColumns = new Dictionary <string, bool>(); Dictionary <string, bool> IsLookupFieldValid = new Dictionary <string, bool>(); IndexConfigClass IndexConfig = null; string SQL = null; bool IsRecordLimitSet = false; string RecordLimitText = null; var cacheNameList = new List <string>(); DataSourceModel datasource = DataSourceModel.create(core.cpParent, adminData.adminContent.dataSourceId, ref cacheNameList); // // ----- Process Input // Button = core.docProperties.getText("Button"); if (Button == ButtonCancelAll) { // // Cancel out to the main page // return(core.webServer.redirect("?", "CancelAll button pressed on Index Export")); } else if (Button != ButtonCancel) { // // get content access rights // var userContentPermissions = PermissionController.getUserContentPermissions(core, adminData.adminContent); if (!userContentPermissions.allowEdit) { // // You must be a content manager of this content to use this tool // Content = "" + "<p>You must be a content manager of " + adminData.adminContent.name + " to use this tool. Hit Cancel to return to main admin page.</p>" + HtmlController.inputHidden(RequestNameAdminSubForm, AdminFormIndex_SubFormExport) + ""; ButtonCommaList = ButtonCancelAll; } else { IsRecordLimitSet = false; if (string.IsNullOrEmpty(Button)) { // // Set Defaults // ExportName = ""; RecordLimit = 0; RecordLimitText = ""; } else { ExportName = core.docProperties.getText("ExportName"); RecordLimitText = core.docProperties.getText("RecordLimit"); if (!string.IsNullOrEmpty(RecordLimitText)) { IsRecordLimitSet = true; RecordLimit = GenericController.encodeInteger(RecordLimitText); } } if (string.IsNullOrEmpty(ExportName)) { ExportName = adminData.adminContent.name + " export for " + core.session.user.name; } // // Get the SQL parts // IndexConfig = IndexConfigClass.get(core, adminData); ListView.setIndexSQL(core, adminData, IndexConfig, ref AllowContentAccess, ref sqlFieldList, ref SQLFrom, ref SQLWhere, ref SQLOrderBy, ref IsLimitedToSubContent, ref ContentAccessLimitMessage, ref FieldUsedInColumns, IsLookupFieldValid); if (!AllowContentAccess) { // // This should be caught with check earlier, but since I added this, and I never make mistakes, I will leave this in case there is a mistake in the earlier code // Processor.Controllers.ErrorController.addUserError(core, "Your account does not have access to any records in '" + adminData.adminContent.name + "'."); } else { // // Get the total record count // SQL = "select count(" + adminData.adminContent.tableName + ".ID) as cnt from " + SQLFrom + " where " + SQLWhere; using (var csData = new CsModel(core)) { csData.openSql(SQL, datasource.name); if (csData.ok()) { recordCnt = csData.getInteger("cnt"); } } // // Build the SQL // SQL = "select"; if (IsRecordLimitSet && (datasource.dbTypeId != DataSourceTypeODBCMySQL)) { SQL += " Top " + RecordLimit; } SQL += " " + adminData.adminContent.tableName + ".* From " + SQLFrom + " WHERE " + SQLWhere; if (!string.IsNullOrEmpty(SQLOrderBy)) { SQL += " Order By" + SQLOrderBy; } if (IsRecordLimitSet && (datasource.dbTypeId == DataSourceTypeODBCMySQL)) { SQL += " Limit " + RecordLimit; } // // Assumble the SQL // if (recordCnt == 0) { // // There are no records to request // Content = "" + "<p>This selection has no records. Hit Cancel to return to the " + adminData.adminContent.name + " list page.</p>" + HtmlController.inputHidden(RequestNameAdminSubForm, AdminFormIndex_SubFormExport) + ""; ButtonCommaList = ButtonCancel; } else if (Button == ButtonRequestDownload) { // // Request the download // var ExportCSVAddon = DbBaseModel.create <AddonModel>(core.cpParent, addonGuidExportCSV); if (ExportCSVAddon == null) { LogController.logError(core, new GenericException("ExportCSV addon not found. Task could not be added to task queue.")); } else { var docProperties = new Dictionary <string, string> { { "sql", SQL }, { "datasource", "default" } }; var cmdDetail = new TaskModel.CmdDetailClass { addonId = ExportCSVAddon.id, addonName = ExportCSVAddon.name, args = docProperties }; TaskSchedulerController.addTaskToQueue(core, cmdDetail, false, ExportName, "export_" + adminData.adminContent.name.Replace(" ", "_") + ".csv"); } // Content = "" + "<p>Your export has been requested and will be available shortly in the <a href=\"?" + rnAdminForm + "=" + AdminFormDownloads + "\">Download Manager</a>. Hit Cancel to return to the " + adminData.adminContent.name + " list page.</p>" + HtmlController.inputHidden(RequestNameAdminSubForm, AdminFormIndex_SubFormExport) + ""; // ButtonCommaList = ButtonCancel; } else { // // no button or refresh button, Ask are you sure // Content += HtmlController.div( HtmlController.label("Export Name", "export-name") + HtmlController.inputText(core, "ExportName", ExportName, "form-control", "export-name") , "form-group"); Content += HtmlController.div( HtmlController.label("Records Found", "records-found") + HtmlController.inputText(core, "RecordCnt", recordCnt.ToString(), "form-control", "records-found", true) , "form-group"); Content += HtmlController.div( HtmlController.label("Record Limit", "record-limit") + HtmlController.inputText(core, "RecordLimit", RecordLimitText, "form-control", "record-limit") , "form-group"); if (core.session.isAuthenticatedDeveloper()) { Content += HtmlController.div( HtmlController.label("Results SQL", "export-query") + HtmlController.inputTextarea(core, "sql", SQL, 4, -1, "export-query", false, false, "form-control") , "form-group"); } // Content = "" //+ "\r<style>" //+ cr2 + ".exportTblCaption {width:100px;}" //+ cr2 + ".exportTblInput {}" //+ "\r</style>" + Content + HtmlController.inputHidden(RequestNameAdminSubForm, AdminFormIndex_SubFormExport) + ""; ButtonCommaList = ButtonCancel + "," + ButtonRequestDownload; if (core.session.isAuthenticatedDeveloper()) { ButtonCommaList = ButtonCommaList + "," + ButtonRefresh; } } } } // Description = "<p>This tool creates an export of the current admin list page results. If you would like to download the current results, select a format and press OK. Your search results will be submitted for export. Your download will be ready shortly in the download manager. To exit without requesting an output, hit Cancel.</p>"; result = AdminUIController.getToolBody(core, adminData.adminContent.name + " Export", ButtonCommaList, "", false, false, Description, "", 10, Content); } } catch (Exception ex) { LogController.logError(core, ex); } return(result); }
// // ==================================================================================================== /// <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; } }
// //======================================================================== /// <summary> /// Display a field in the admin index form /// </summary> /// <param name="core"></param> /// <param name="adminData"></param> /// <param name="fieldName"></param> /// <param name="CS"></param> /// <param name="IsLookupFieldValid"></param> /// <param name="IsEmailContent"></param> /// <returns></returns> public static string getGridCell(CoreController core, AdminDataModel adminData, string fieldName, CsModel csData, bool IsLookupFieldValid, bool IsEmailContent) { try { var Stream = new StringBuilderLegacyController(); var field = adminData.adminContent.fields[fieldName.ToLowerInvariant()]; if (field.password) { // // -- do not list password fields Stream.add("****"); } else { int Pos = 0; switch (field.fieldTypeId) { case CPContentBaseClass.FieldTypeIdEnum.File: case CPContentBaseClass.FieldTypeIdEnum.FileImage: { string filename = csData.getText(field.nameLc); filename = GenericController.strReplace(filename, "\\", "/"); Pos = filename.LastIndexOf("/") + 1; if (Pos != 0) { filename = filename.Substring(Pos); } Stream.add(filename); break; } case CPContentBaseClass.FieldTypeIdEnum.Lookup: { if (IsLookupFieldValid) { Stream.add(csData.getText("LookupTable" + field.id + "Name")); } else if (field.lookupList != "") { string[] lookups = field.lookupList.Split(','); int LookupPtr = csData.getInteger(field.nameLc) - 1; if (LookupPtr <= lookups.GetUpperBound(0)) { if (LookupPtr >= 0) { Stream.add(lookups[LookupPtr]); } } } else { Stream.add(" "); } break; } case CPContentBaseClass.FieldTypeIdEnum.MemberSelect: { if (IsLookupFieldValid) { Stream.add(csData.getText("LookupTable" + field.id + "Name")); } else { Stream.add(csData.getText(field.nameLc)); } break; } case CPContentBaseClass.FieldTypeIdEnum.Boolean: { if (csData.getBoolean(field.nameLc)) { Stream.add("yes"); } else { Stream.add("no"); } break; } case CPContentBaseClass.FieldTypeIdEnum.Currency: { string fieldValueText = csData.getText(field.nameLc); if (string.IsNullOrWhiteSpace(fieldValueText)) { Stream.add(fieldValueText); break; } Stream.add(string.Format("{0:C}", csData.getNumber(field.nameLc))); break; } case CPContentBaseClass.FieldTypeIdEnum.LongText: case CPContentBaseClass.FieldTypeIdEnum.HTML: case CPContentBaseClass.FieldTypeIdEnum.HTMLCode: { string fieldValueText = csData.getText(field.nameLc); if (fieldValueText.Length > 50) { fieldValueText = fieldValueText.left(50) + "[more]"; } Stream.add(fieldValueText); break; } case CPContentBaseClass.FieldTypeIdEnum.FileText: case CPContentBaseClass.FieldTypeIdEnum.FileCSS: case CPContentBaseClass.FieldTypeIdEnum.FileXML: case CPContentBaseClass.FieldTypeIdEnum.FileJavascript: case CPContentBaseClass.FieldTypeIdEnum.FileHTML: case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: { string filename = csData.getText(field.nameLc); if (!string.IsNullOrEmpty(filename)) { string Copy = core.cdnFiles.readFileText(filename); Stream.add(Copy); } break; } case CPContentBaseClass.FieldTypeIdEnum.Redirect: case CPContentBaseClass.FieldTypeIdEnum.ManyToMany: { Stream.add("n/a"); break; } case CPContentBaseClass.FieldTypeIdEnum.Date: { // // -- if minvalue, use blank, if no time-part, do short-date DateTime cellValueDate = csData.getDate(field.nameLc); if (cellValueDate.Equals(DateTime.MinValue)) { Stream.add(""); } else if (cellValueDate.Equals(cellValueDate.Date)) { Stream.add(cellValueDate.ToShortDateString()); } else { Stream.add(cellValueDate.ToString()); } break; } default: { string valueString = csData.getText(field.nameLc); if (string.IsNullOrWhiteSpace(valueString)) { Stream.add(valueString); break; } Stream.add(csData.getText(field.nameLc)); break; } } } return(HtmlController.encodeHtml(Stream.text)); } catch (Exception ex) { LogController.logError(core, ex); throw; } }
// // ==================================================================================================== /// <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); }
// //============================================================================= // Print the Configure Index Form //============================================================================= // public static string get(CPClass cp, CoreController core, AdminDataModel adminData) { string result = ""; try { // todo refactor out ContentMetadataModel adminContent = adminData.adminContent; string Button = core.docProperties.getText(RequestNameButton); if (Button == ButtonOK) { // // -- Process OK, remove subform from querystring and return empty cp.Doc.AddRefreshQueryString(RequestNameAdminSubForm, ""); return(result); } // // Load Request if (Button == ButtonReset) { // // -- Process reset core.userProperty.setProperty(AdminDataModel.IndexConfigPrefix + adminContent.id.ToString(), ""); } IndexConfigClass IndexConfig = IndexConfigClass.get(core, adminData); int ToolsAction = core.docProperties.getInteger("dta"); int TargetFieldId = core.docProperties.getInteger("fi"); string TargetFieldName = core.docProperties.getText("FieldName"); int ColumnPointer = core.docProperties.getInteger("dtcn"); const string RequestNameAddField = "addfield"; string FieldNameToAdd = GenericController.toUCase(core.docProperties.getText(RequestNameAddField)); const string RequestNameAddFieldId = "addfieldID"; int FieldIDToAdd = core.docProperties.getInteger(RequestNameAddFieldId); bool normalizeSaveLoad = core.docProperties.getBoolean("NeedToReloadConfig"); bool AllowContentAutoLoad = false; StringBuilderLegacyController Stream = new StringBuilderLegacyController(); string Title = "Set Columns: " + adminContent.name; string Description = "Use the icons to add, remove and modify your personal column prefernces for this content (" + adminContent.name + "). Hit OK when complete. Hit Reset to restore your column preferences for this content to the site's default column preferences."; Stream.add(AdminUIController.getHeaderTitleDescription(Title, Description)); // //-------------------------------------------------------------------------------- // Process actions //-------------------------------------------------------------------------------- // if (adminContent.id != 0) { var CDef = ContentMetadataModel.create(core, adminContent.id); int ColumnWidthTotal = 0; if (ToolsAction != 0) { // // Block contentautoload, then force a load at the end // AllowContentAutoLoad = (core.siteProperties.getBoolean("AllowContentAutoLoad", true)); core.siteProperties.setProperty("AllowContentAutoLoad", false); bool reloadMetadata = false; int SourceContentId = 0; string SourceName = null; // // Make sure the FieldNameToAdd is not-inherited, if not, create new field // if (FieldIDToAdd != 0) { foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; if (field.id == FieldIDToAdd) { if (field.inherited) { SourceContentId = field.contentId; SourceName = field.nameLc; // // -- copy the field using (var CSSource = new CsModel(core)) { if (CSSource.open("Content Fields", "(ContentID=" + SourceContentId + ")and(Name=" + DbController.encodeSQLText(SourceName) + ")")) { using (var CSTarget = new CsModel(core)) { if (CSTarget.insert("Content Fields")) { CSSource.copyRecord(CSTarget); CSTarget.set("ContentID", adminContent.id); reloadMetadata = true; } } } } } break; } } } // // Make sure all fields are not-inherited, if not, create new fields // foreach (var column in IndexConfig.columns) { ContentFieldMetadataModel field = adminContent.fields[column.Name.ToLowerInvariant()]; if (field.inherited) { SourceContentId = field.contentId; SourceName = field.nameLc; using (var CSSource = new CsModel(core)) { if (CSSource.open("Content Fields", "(ContentID=" + SourceContentId + ")and(Name=" + DbController.encodeSQLText(SourceName) + ")")) { using (var CSTarget = new CsModel(core)) { if (CSTarget.insert("Content Fields")) { CSSource.copyRecord(CSTarget); CSTarget.set("ContentID", adminContent.id); reloadMetadata = true; } } } } } } // // get current values for Processing // foreach (var column in IndexConfig.columns) { ColumnWidthTotal += column.Width; } // // ----- Perform any actions first // switch (ToolsAction) { case ToolsActionAddField: { // // Add a field to the index form // if (FieldIDToAdd != 0) { IndexConfigColumnClass column = null; foreach (var columnx in IndexConfig.columns) { columnx.Width = encodeInteger((columnx.Width * 80) / (double)ColumnWidthTotal); } { column = new IndexConfigColumnClass(); using (var csData = new CsModel(core)) { if (csData.openRecord("Content Fields", FieldIDToAdd)) { column.Name = csData.getText("name"); column.Width = 20; } } IndexConfig.columns.Add(column); normalizeSaveLoad = true; } } // break; } case ToolsActionRemoveField: { // // Remove a field to the index form int columnWidthTotal = 0; var dstColumns = new List <IndexConfigColumnClass>(); foreach (var column in IndexConfig.columns) { if (column.Name != TargetFieldName.ToLowerInvariant()) { dstColumns.Add(column); columnWidthTotal += column.Width; } } IndexConfig.columns = dstColumns; normalizeSaveLoad = true; break; } case ToolsActionMoveFieldLeft: { if (IndexConfig.columns.First().Name != TargetFieldName.ToLowerInvariant()) { int listIndex = 0; foreach (var column in IndexConfig.columns) { if (column.Name == TargetFieldName.ToLowerInvariant()) { break; } listIndex += 1; } IndexConfig.columns.swap(listIndex, listIndex - 1); normalizeSaveLoad = true; } break; } case ToolsActionMoveFieldRight: { if (IndexConfig.columns.Last().Name != TargetFieldName.ToLowerInvariant()) { int listIndex = 0; foreach (var column in IndexConfig.columns) { if (column.Name == TargetFieldName.ToLowerInvariant()) { break; } listIndex += 1; } IndexConfig.columns.swap(listIndex, listIndex + 1); normalizeSaveLoad = true; } break; } case ToolsActionExpand: { foreach (var column in IndexConfig.columns) { if (column.Name == TargetFieldName.ToLowerInvariant()) { column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 1.1); } else { column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 0.9); } } normalizeSaveLoad = true; break; } case ToolsActionContract: { foreach (var column in IndexConfig.columns) { if (column.Name != TargetFieldName.ToLowerInvariant()) { column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 1.1); } else { column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 0.9); } } normalizeSaveLoad = true; break; } } // // Reload CDef if it changed // if (reloadMetadata) { core.clearMetaData(); core.cache.invalidateAll(); CDef = ContentMetadataModel.createByUniqueName(core, adminContent.name); } // // save indexconfig // if (normalizeSaveLoad) { // // Normalize the widths of the remaining columns ColumnWidthTotal = 0; foreach (var column in IndexConfig.columns) { ColumnWidthTotal += column.Width; } foreach (var column in IndexConfig.columns) { column.Width = encodeInteger((1000 * column.Width) / (double)ColumnWidthTotal); } GetHtmlBodyClass.setIndexSQL_SaveIndexConfig(cp, core, IndexConfig); IndexConfig = IndexConfigClass.get(core, adminData); } } // //-------------------------------------------------------------------------------- // Display the form //-------------------------------------------------------------------------------- // Stream.add("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"99%\"><tr>"); Stream.add("<td width=\"5%\"> </td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>10%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>20%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>30%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>40%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>50%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>60%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>70%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>80%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>90%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>100%</nobr></td>"); Stream.add("<td width=\"4%\" align=\"center\"> </td>"); Stream.add("</tr></table>"); // Stream.add("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"99%\"><tr>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("</tr></table>"); // // print the column headers // ColumnWidthTotal = 0; int InheritedFieldCount = 0; if (IndexConfig.columns.Count > 0) { // // Calc total width // foreach (var column in IndexConfig.columns) { ColumnWidthTotal += column.Width; } if (ColumnWidthTotal > 0) { Stream.add("<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"90%\">"); // // -- header Stream.add("<tr>"); int ColumnWidth = 0; int fieldId = 0; string Caption = null; foreach (var column in IndexConfig.columns) { // // print column headers - anchored so they sort columns // ColumnWidth = encodeInteger(100 * (column.Width / (double)ColumnWidthTotal)); ContentFieldMetadataModel field = adminContent.fields[column.Name.ToLowerInvariant()]; fieldId = field.id; Caption = field.caption; if (field.inherited) { Caption = Caption + "*"; InheritedFieldCount = InheritedFieldCount + 1; } Stream.add("<td class=\"small\" width=\"" + ColumnWidth + "%\" valign=\"top\" align=\"left\" style=\"background-color:white;border: 1px solid #555;\">" + Caption + "</td>"); } Stream.add("</tr>"); // // -- body Stream.add("<tr>"); foreach (var column in IndexConfig.columns) { // // print column headers - anchored so they sort columns // ColumnWidth = encodeInteger(100 * (column.Width / (double)ColumnWidthTotal)); ContentFieldMetadataModel field = adminContent.fields[column.Name.ToLowerInvariant()]; fieldId = field.id; Caption = field.caption; if (field.inherited) { Caption = Caption + "*"; InheritedFieldCount = InheritedFieldCount + 1; } int ColumnPtr = 0; string link = "?" + core.doc.refreshQueryString + "&FieldName=" + HtmlController.encodeHtml(field.nameLc) + "&fi=" + fieldId + "&dtcn=" + ColumnPtr + "&" + RequestNameAdminSubForm + "=" + AdminFormIndex_SubFormSetColumns; Stream.add("<td width=\"" + ColumnWidth + "%\" valign=\"top\" align=\"left\">"); Stream.add(HtmlController.div(AdminUIController.getDeleteLink(link + "&dta=" + ToolsActionRemoveField), "text-center")); Stream.add(HtmlController.div(AdminUIController.getArrowRightLink(link + "&dta=" + ToolsActionMoveFieldRight), "text-center")); Stream.add(HtmlController.div(AdminUIController.getArrowLeftLink(link + "&dta=" + ToolsActionMoveFieldLeft), "text-center")); Stream.add(HtmlController.div(AdminUIController.getExpandLink(link + "&dta=" + ToolsActionExpand), "text-center")); Stream.add(HtmlController.div(AdminUIController.getContractLink(link + "&dta=" + ToolsActionContract), "text-center")); Stream.add("</td>"); } Stream.add("</tr>"); Stream.add("</table>"); } } // // ----- If anything was inherited, put up the message // if (InheritedFieldCount > 0) { Stream.add("<p class=\"ccNormal\">* This field was inherited from the Content Definition's Parent. Inherited fields will automatically change when the field in the parent is changed. If you alter these settings, this connection will be broken, and the field will no longer inherit it's properties.</P class=\"ccNormal\">"); } // // ----- now output a list of fields to add // if (CDef.fields.Count == 0) { Stream.add(SpanClassAdminNormal + "This Content Definition has no fields</span><br>"); } else { foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; // // display the column if it is not in use if ((IndexConfig.columns.Find(x => x.Name == field.nameLc) == null)) { if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.File) { // // file can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileText) { // // filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (text file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileHTML) { // // filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (html file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode) { // // filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (html code file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileCSS) { // // css filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (css file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileXML) { // // xml filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (xml file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileJavascript) { // // javascript filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (javascript file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.LongText) { // // can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (long text field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.HTML) { // // can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (html field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileImage) { // // can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (image field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Redirect) { // // can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (redirect field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.ManyToMany) { // // many to many can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (many-to-many field)")); } else { // // can be used as column header string link = "?" + core.doc.refreshQueryString + "&fi=" + field.id + "&dta=" + ToolsActionAddField + "&" + RequestNameAddFieldId + "=" + field.id + "&" + RequestNameAdminSubForm + "=" + AdminFormIndex_SubFormSetColumns; Stream.add(HtmlController.div(AdminUIController.getPlusLink(link, " " + field.caption))); } } } } } // //-------------------------------------------------------------------------------- // print the content tables that have index forms to Configure //-------------------------------------------------------------------------------- // core.siteProperties.setProperty("AllowContentAutoLoad", GenericController.encodeText(AllowContentAutoLoad)); string Content = "" + Stream.text + HtmlController.inputHidden("cid", adminContent.id.ToString()) + HtmlController.inputHidden(rnAdminForm, "1") + HtmlController.inputHidden(RequestNameAdminSubForm, AdminFormIndex_SubFormSetColumns) + ""; // // -- assemble form result = AdminUIController.getToolForm(core, Content, ButtonOK + "," + ButtonReset); core.html.addTitle(Title); } catch (Exception ex) { LogController.logError(core, ex); } return(result); }