// //============================================================================= // 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 static string get(CPClass cp) { string tempGetForm_HouseKeepingControl = null; try { // StringBuilderLegacyController Content = new StringBuilderLegacyController(); string Copy = null; string SQL = null; string Button = null; int PagesTotal = 0; string Caption = null; DateTime DateValue = default(DateTime); string AgeInDays = null; int ArchiveRecordAgeDays = 0; string ArchiveTimeOfDay = null; bool ArchiveAllowFileClean = false; string ButtonList = ""; string Description = null; // Button = cp.core.docProperties.getText(RequestNameButton); if (Button == ButtonCancel) { // // // return(cp.core.webServer.redirect("/" + cp.core.appConfig.adminRoute, "HouseKeepingControl, Cancel Button Pressed")); } else if (!cp.core.session.isAuthenticatedAdmin()) { // // // ButtonList = ButtonCancel; Content.add(AdminUIController.getFormBodyAdminOnly()); } else { // string tableBody = ""; // // Set defaults // ArchiveRecordAgeDays = (cp.core.siteProperties.getInteger("ArchiveRecordAgeDays", 0)); ArchiveTimeOfDay = cp.core.siteProperties.getText("ArchiveTimeOfDay", "12:00:00 AM"); ArchiveAllowFileClean = (cp.core.siteProperties.getBoolean("ArchiveAllowFileClean", false)); // // Process Requests // switch (Button) { case ButtonOK: case ButtonSave: // ArchiveRecordAgeDays = cp.core.docProperties.getInteger("ArchiveRecordAgeDays"); cp.core.siteProperties.setProperty("ArchiveRecordAgeDays", GenericController.encodeText(ArchiveRecordAgeDays)); // ArchiveTimeOfDay = cp.core.docProperties.getText("ArchiveTimeOfDay"); cp.core.siteProperties.setProperty("ArchiveTimeOfDay", ArchiveTimeOfDay); // ArchiveAllowFileClean = cp.core.docProperties.getBoolean("ArchiveAllowFileClean"); cp.core.siteProperties.setProperty("ArchiveAllowFileClean", GenericController.encodeText(ArchiveAllowFileClean)); break; } // if (Button == ButtonOK) { return(cp.core.webServer.redirect("/" + cp.core.appConfig.adminRoute, "StaticPublishControl, OK Button Pressed")); } // // ----- Status // tableBody += HtmlController.tableRowStart() + "<td colspan=\"3\" class=\"ccPanel3D ccAdminEditSubHeader\"><b>Status</b>" + tableCellEnd + kmaEndTableRow; // // ----- Visits Found // PagesTotal = 0; SQL = "SELECT Count(ID) as Result FROM ccVisits;"; using (var csData = new CsModel(cp.core)) { csData.openSql(SQL); if (csData.ok()) { PagesTotal = csData.getInteger("Result"); } } tableBody += AdminUIController.getEditRowLegacy(cp.core, SpanClassAdminNormal + PagesTotal, "Visits Found", "", false, false, ""); // // ----- Oldest Visit // Copy = "unknown"; AgeInDays = "unknown"; using (var csData = new CsModel(cp.core)) { SQL = cp.core.db.getSQLSelect("ccVisits", "DateAdded", "", "ID", "", 1); csData.openSql(SQL); if (csData.ok()) { DateValue = csData.getDate("DateAdded"); if (DateValue != DateTime.MinValue) { Copy = GenericController.encodeText(DateValue); AgeInDays = GenericController.encodeText(encodeInteger(Math.Floor(encodeNumber(cp.core.doc.profileStartTime - DateValue)))); } } } tableBody += (AdminUIController.getEditRowLegacy(cp.core, SpanClassAdminNormal + Copy + " (" + AgeInDays + " days)", "Oldest Visit", "", false, false, "")); // // ----- Viewings Found // PagesTotal = 0; SQL = "SELECT Count(ID) as result FROM ccViewings;"; using (var csData = new CsModel(cp.core)) { csData.openSql(SQL); if (csData.ok()) { PagesTotal = csData.getInteger("Result"); } csData.close(); } tableBody += (AdminUIController.getEditRowLegacy(cp.core, SpanClassAdminNormal + PagesTotal, "Viewings Found", "", false, false, "")); // tableBody += (HtmlController.tableRowStart() + "<td colspan=\"3\" class=\"ccPanel3D ccAdminEditSubHeader\"><b>Options</b>" + tableCellEnd + kmaEndTableRow); // Caption = "Archive Age"; Copy = HtmlController.inputText_Legacy(cp.core, "ArchiveRecordAgeDays", ArchiveRecordAgeDays.ToString(), -1, 20) + " Number of days to keep visit records. 0 disables housekeeping."; tableBody += (AdminUIController.getEditRowLegacy(cp.core, Copy, Caption)); // Caption = "Housekeeping Time"; Copy = HtmlController.inputText_Legacy(cp.core, "ArchiveTimeOfDay", ArchiveTimeOfDay, -1, 20) + " The time of day when record deleting should start."; tableBody += (AdminUIController.getEditRowLegacy(cp.core, Copy, Caption)); // Caption = "Purge Content Files"; Copy = HtmlController.checkbox("ArchiveAllowFileClean", ArchiveAllowFileClean) + " Delete Contensive content files with no associated database record."; tableBody += (AdminUIController.getEditRowLegacy(cp.core, Copy, Caption)); // Content.add(AdminUIController.editTable(tableBody)); Content.add(HtmlController.inputHidden(rnAdminSourceForm, AdminformHousekeepingControl)); ButtonList = ButtonCancel + ",Refresh," + ButtonSave + "," + ButtonOK; } // Caption = "Data Housekeeping Control"; Description = "This tool is used to control the database record housekeeping process. This process deletes visit history records, so care should be taken before making any changes."; tempGetForm_HouseKeepingControl = AdminUIController.getToolBody(cp.core, Caption, ButtonList, "", false, false, Description, "", 0, Content.text); // cp.core.html.addTitle(Caption); } catch (Exception ex) { LogController.logError(cp.core, ex); } return(tempGetForm_HouseKeepingControl); }