// //============================================================================= // Create a child content //============================================================================= // public static string get(CPClass cp) { string result = ""; try { // bool IsEmptyList = false; int ParentContentId = 0; string ChildContentName = ""; int ChildContentId = 0; bool AddAdminMenuEntry = false; StringBuilderLegacyController Content = new StringBuilderLegacyController(); string FieldValue = null; bool NewGroup = false; int GroupId = 0; string NewGroupName = ""; string Button = null; string Caption = null; string Description = ""; string ButtonList = ""; bool BlockForm = false; // Button = cp.core.docProperties.getText(RequestNameButton); if (Button == ButtonCancel) { // // // return(cp.core.webServer.redirect("/" + cp.core.appConfig.adminRoute, "GetContentChildTool, Cancel Button Pressed")); } else if (!cp.core.session.isAuthenticatedAdmin()) { // // // ButtonList = ButtonCancel; Content.add(AdminUIController.getFormBodyAdminOnly()); } else { // if (Button != ButtonOK) { // // Load defaults // ParentContentId = cp.core.docProperties.getInteger("ParentContentID"); if (ParentContentId == 0) { ParentContentId = ContentMetadataModel.getContentId(cp.core, "Page Content"); } AddAdminMenuEntry = true; GroupId = 0; } else { // // Process input // ParentContentId = cp.core.docProperties.getInteger("ParentContentID"); var parentContentMetadata = ContentMetadataModel.create(cp.core, ParentContentId); ChildContentName = cp.core.docProperties.getText("ChildContentName"); AddAdminMenuEntry = cp.core.docProperties.getBoolean("AddAdminMenuEntry"); GroupId = cp.core.docProperties.getInteger("GroupID"); NewGroup = cp.core.docProperties.getBoolean("NewGroup"); NewGroupName = cp.core.docProperties.getText("NewGroupName"); // if ((parentContentMetadata == null) || (string.IsNullOrEmpty(ChildContentName))) { Processor.Controllers.ErrorController.addUserError(cp.core, "You must select a parent and provide a child name."); } else { // // Create Definition // Description = Description + "<div> </div>" + "<div>Creating content [" + ChildContentName + "] from [" + parentContentMetadata.name + "]</div>"; var childContentMetadata = parentContentMetadata.createContentChild(cp.core, ChildContentName, cp.core.session.user.id); ChildContentId = ContentMetadataModel.getContentId(cp.core, ChildContentName); // // Create Group and Rule // if (NewGroup && (!string.IsNullOrEmpty(NewGroupName))) { using (var csData = new CsModel(cp.core)) { csData.open("Groups", "name=" + DbController.encodeSQLText(NewGroupName)); if (csData.ok()) { Description = Description + "<div>Group [" + NewGroupName + "] already exists, using existing group.</div>"; GroupId = csData.getInteger("ID"); } else { Description = Description + "<div>Creating new group [" + NewGroupName + "]</div>"; csData.close(); csData.insert("Groups"); if (csData.ok()) { GroupId = csData.getInteger("ID"); csData.set("Name", NewGroupName); csData.set("Caption", NewGroupName); } } } } if (GroupId != 0) { using (var csData = new CsModel(cp.core)) { csData.insert("Group Rules"); if (csData.ok()) { Description = Description + "<div>Assigning group [" + MetadataController.getRecordName(cp.core, "Groups", GroupId) + "] to edit content [" + ChildContentName + "].</div>"; csData.set("GroupID", GroupId); csData.set("ContentID", ChildContentId); } } } // // Add Admin Menu Entry // if (AddAdminMenuEntry) { // // Add Navigator entries } // Description = Description + "<div> </div>" + "<div>Your new content is ready. <a href=\"?" + rnAdminForm + "=22\">Click here</a> to create another Content Definition, or hit [Cancel] to return to the main menu.</div>"; ButtonList = ButtonCancel; BlockForm = true; } cp.core.clearMetaData(); cp.core.cache.invalidateAll(); } // // Get the form // if (!BlockForm) { string tableBody = ""; // FieldValue = "<select size=\"1\" name=\"ParentContentID\" ID=\"\"><option value=\"\">Select One</option>"; FieldValue = FieldValue + GetContentChildTool_Options(cp, 0, ParentContentId); FieldValue = FieldValue + "</select>"; tableBody += AdminUIController.getEditRowLegacy(cp.core, FieldValue, "Parent Content Name", "", false, false, ""); // FieldValue = HtmlController.inputText_Legacy(cp.core, "ChildContentName", ChildContentName, 1, 40); tableBody += AdminUIController.getEditRowLegacy(cp.core, FieldValue, "New Child Content Name", "", false, false, ""); // FieldValue = "" + HtmlController.inputRadio("NewGroup", false.ToString(), NewGroup.ToString()) + cp.core.html.selectFromContent("GroupID", GroupId, "Groups", "", "", "", ref IsEmptyList) + "(Select a current group)" + "<br>" + HtmlController.inputRadio("NewGroup", true.ToString(), NewGroup.ToString()) + HtmlController.inputText_Legacy(cp.core, "NewGroupName", NewGroupName) + "(Create a new group)"; tableBody += AdminUIController.getEditRowLegacy(cp.core, FieldValue, "Content Manager Group", "", false, false, ""); // Content.add(AdminUIController.editTable(tableBody)); Content.add("</td></tr>" + kmaEndTable); // ButtonList = ButtonOK + "," + ButtonCancel; } Content.add(HtmlController.inputHidden(rnAdminSourceForm, AdminFormContentChildTool)); } // Caption = "Create Content Definition"; Description = "<div>This tool is used to create content definitions that help segregate your content into authorable segments.</div>" + Description; result = AdminUIController.getToolBody(cp.core, Caption, ButtonList, "", false, false, Description, "", 0, Content.text); } catch (Exception ex) { LogController.logError(cp.core, ex); } return(result); }
// // ==================================================================================================== // public override string adminHint(string innerHtml) => HtmlController.adminHint(cp.core, innerHtml);
public override string SelectList(string htmlName, string htmlValue, string optionList) { return(HtmlController.selectFromList(cp.core, htmlName, GenericController.encodeInteger(htmlValue), optionList.Split(',').ToList(), "", "")); }
public override string p(string innerHtml) => HtmlController.p(innerHtml);
public override string ul(string innerHtml) => HtmlController.ul(innerHtml);
public override string InputText(string htmlName) => HtmlController.inputText_Legacy(cp.core, htmlName, "", -1, 20, "", false, false, "", 255);
// // ==================================================================================================== // public override string p(string innerHtml, string htmlName, string htmlClass, string htmlId) => HtmlController.p(innerHtml, htmlClass, htmlId);
// public override string h6(string innerHtml, string htmlName, string htmlClass) => HtmlController.genericBlockTag("h6", innerHtml, htmlClass);
// public override string h6(string innerHtml) => HtmlController.genericBlockTag("h6", innerHtml);
// // ========================================================================================== // public override string h5(string innerHtml, string htmlName, string htmlClass, string htmlId) => HtmlController.genericBlockTag("h5", innerHtml, htmlClass, htmlId);
// public override string h5(string innerHtml, string htmlName) => HtmlController.genericBlockTag("h5", innerHtml);
// public override string h1(string innerHtml) => HtmlController.h1(innerHtml);
public override string div(string innerHtml) => HtmlController.div(innerHtml);
// //======================================================================== /// <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); }
public override string InputFile(string htmlName) => HtmlController.inputFile(htmlName);
public override string Hidden(string htmlName, string htmlValue) => HtmlController.inputHidden(htmlName, htmlValue);
public override string InputText(string htmlName, string htmlValue, int maxLength) => HtmlController.inputText_Legacy(cp.core, htmlName, htmlValue, -1, 20, "", false, false, "", maxLength);
// // ==================================================================================================== // public override string Indent(string sourceHtml, int tabCnt) => HtmlController.indent(sourceHtml, tabCnt);
public override string li(string innerHtml) => HtmlController.li(innerHtml);
public override string Indent(string sourceHtml) => HtmlController.indent(sourceHtml);
public override string p(string innerHtml, string htmlName) => HtmlController.p(innerHtml);
public override string InputDate(string htmlName, DateTime htmlValue, int maxLength, string htmlClass) => HtmlController.inputDate(cp.core, htmlName, htmlValue, "", "", htmlClass);
public override string ul(string innerHtml, string htmlName, string htmlClass) => HtmlController.ul(innerHtml, htmlClass);
public override string InputDate(string htmlName, DateTime htmlValue) => HtmlController.inputDate(cp.core, htmlName, htmlValue);
public override string RadioBox(string htmlName, string htmlValue, string currentValue) { return(HtmlController.inputRadio(htmlName, htmlValue, currentValue)); }
public override string InputDate(string htmlName) => HtmlController.inputDate(cp.core, htmlName, null);
// // ========================================================================================== // public override string SelectList(string htmlName, string htmlValue, string optionList, string noneCaption, string htmlClass, string htmlId) { return(HtmlController.selectFromList(cp.core, htmlName, GenericController.encodeInteger(htmlValue), optionList.Split(',').ToList(), noneCaption, htmlId, htmlClass)); }
public override string InputFile(string htmlName, string htmlClass) => HtmlController.inputFile(htmlName, "", htmlClass);
// // ==================================================================================================== // public override string Button(string htmlName, string htmlValue, string htmlClass, string htmlId) => HtmlController.inputSubmit(htmlValue, htmlName, htmlId, "", false, htmlClass);
// //============================================================================= // Create a child content //============================================================================= // private string GetForm_CreateChildContent(CoreController core) { string result = ""; try { int ParentContentId = 0; string ChildContentName = ""; bool AddAdminMenuEntry = false; StringBuilderLegacyController Stream = new StringBuilderLegacyController(); string ButtonList = ButtonCancel + "," + ButtonRun; // Stream.add(AdminUIController.getHeaderTitleDescription("Create a Child Content from a Content Definition", "This tool creates a Content Definition based on another Content Definition.")); // // print out the submit form if (core.docProperties.getText("Button") != "") { // // Process input // ParentContentId = core.docProperties.getInteger("ParentContentID"); var parentContentMetadata = ContentMetadataModel.create(core, ParentContentId); ChildContentName = core.docProperties.getText("ChildContentName"); AddAdminMenuEntry = core.docProperties.getBoolean("AddAdminMenuEntry"); // Stream.add(SpanClassAdminSmall); if ((parentContentMetadata == null) || (string.IsNullOrEmpty(ChildContentName))) { Stream.add("<p>You must select a parent and provide a child name.</p>"); } else { // // Create Definition // Stream.add("<P>Creating content [" + ChildContentName + "] from [" + parentContentMetadata + "]"); var childContentMetadata = parentContentMetadata.createContentChild(core, ChildContentName, core.session.user.id); // Stream.add("<br>Reloading Content Definitions..."); core.cache.invalidateAll(); core.clearMetaData(); Stream.add("<br>Finished</P>"); } Stream.add("</SPAN>"); } Stream.add(SpanClassAdminNormal); // Stream.add("Parent Content Name<br>"); Stream.add(core.html.selectFromContent("ParentContentID", ParentContentId, "Content", "")); Stream.add("<br><br>"); // Stream.add("Child Content Name<br>"); Stream.add(HtmlController.inputText_Legacy(core, "ChildContentName", ChildContentName, 1, 40)); Stream.add("<br><br>"); // Stream.add("Add Admin Menu Entry under Parent's Menu Entry<br>"); Stream.add(HtmlController.checkbox("AddAdminMenuEntry", AddAdminMenuEntry)); Stream.add("<br><br>"); // //Stream.Add( core.main_GetFormInputHidden(RequestNameAdminForm, AdminFormToolCreateChildContent) Stream.add("</SPAN>"); // result = AdminUIController.getToolForm(core, Stream.text, ButtonList); } catch (Exception ex) { LogController.logError(core, ex); } return(result); }