// // // // public static string main_GetRemoteQueryKey(CoreController core, string SQL, string dataSourceName = "default", int maxRows = 1000) { string remoteKey = ""; if (maxRows == 0) { maxRows = 1000; } using (var cs = new CsModel(core)) { cs.insert("Remote Queries"); if (cs.ok()) { remoteKey = getGUIDNaked(); cs.set("remotekey", remoteKey); cs.set("datasourceid", MetadataController.getRecordIdByUniqueName(core, "Data Sources", dataSourceName)); cs.set("sqlquery", SQL); cs.set("maxRows", maxRows); cs.set("dateexpires", DbController.encodeSQLDate(core.doc.profileStartTime.AddDays(1))); cs.set("QueryTypeID", QueryTypeSQL); cs.set("VisitId", core.session.visit.id); } cs.close(); } // return(remoteKey); }
// //==================================================================================================== // public static string getActiveEditor(CoreController core, string ContentName, int RecordID, string FieldName, string FormElements = "") { // int ContentID = 0; string Copy = null; string Stream = ""; string ButtonPanel = null; string EditorPanel = null; string PanelCopy = null; string intContentName = null; int intRecordId = 0; string strFieldName = null; // intContentName = GenericController.encodeText(ContentName); intRecordId = GenericController.encodeInteger(RecordID); strFieldName = GenericController.encodeText(FieldName); // EditorPanel = ""; ContentID = Models.Domain.ContentMetadataModel.getContentId(core, intContentName); if ((ContentID < 1) || (intRecordId < 1) || (string.IsNullOrEmpty(strFieldName))) { PanelCopy = SpanClassAdminNormal + "The information you have selected can not be accessed.</span>"; EditorPanel = EditorPanel + core.html.getPanel(PanelCopy); } else { intContentName = MetadataController.getContentNameByID(core, ContentID); if (!string.IsNullOrEmpty(intContentName)) { using (var csData = new CsModel(core)) { csData.open(intContentName, "ID=" + intRecordId); if (!csData.ok()) { PanelCopy = SpanClassAdminNormal + "The information you have selected can not be accessed.</span>"; EditorPanel = EditorPanel + core.html.getPanel(PanelCopy); } else { Copy = csData.getText(strFieldName); EditorPanel = EditorPanel + HtmlController.inputHidden("Type", FormTypeActiveEditor); EditorPanel = EditorPanel + HtmlController.inputHidden("cid", ContentID); EditorPanel = EditorPanel + HtmlController.inputHidden("ID", intRecordId); EditorPanel = EditorPanel + HtmlController.inputHidden("fn", strFieldName); EditorPanel = EditorPanel + GenericController.encodeText(FormElements); EditorPanel = EditorPanel + core.html.getFormInputHTML("ContentCopy", Copy, "3", "45", false, true); ButtonPanel = core.html.getPanelButtons(ButtonCancel + "," + ButtonSave); EditorPanel = EditorPanel + ButtonPanel; } csData.close(); } } } Stream = Stream + core.html.getPanelHeader("Contensive Active Content Editor"); Stream = Stream + core.html.getPanel(EditorPanel); Stream = HtmlController.form(core, Stream); return(Stream); }
// //==================================================================================================== /// <summary> /// Process the active editor form /// </summary> /// <param name="core"></param> public static void processActiveEditor(CoreController core) { // string Button = null; int ContentID = 0; string ContentName = null; int RecordID = 0; string FieldName = null; string ContentCopy = null; // Button = core.docProperties.getText("Button"); switch (Button) { case ButtonCancel: // // ----- Do nothing, the form will reload with the previous contents // break; case ButtonSave: // // ----- read the form fields // ContentID = core.docProperties.getInteger("cid"); RecordID = core.docProperties.getInteger("id"); FieldName = core.docProperties.getText("fn"); ContentCopy = core.docProperties.getText("ContentCopy"); // // ----- convert editor active edit icons // ContentCopy = ActiveContentController.processWysiwygResponseForSave(core, ContentCopy); // // ----- save the content // ContentName = MetadataController.getContentNameByID(core, ContentID); if (!string.IsNullOrEmpty(ContentName)) { using (var csData = new CsModel(core)) { csData.open(ContentName, "ID=" + DbController.encodeSQLNumber(RecordID), "", false); if (csData.ok()) { csData.set(FieldName, ContentCopy); } csData.close(); } } break; } }
// //===================================================================================================== /// <summary> /// Clear the Approved Authoring Control /// </summary> /// <param name="ContentName"></param> /// <param name="RecordID"></param> /// <param name="authoringControl"></param> /// <param name="MemberID"></param> public static void clearAuthoringControl(CoreController core, string ContentName, int RecordID, AuthoringControls authoringControl, int MemberID) { try { string Criteria = getAuthoringControlCriteria(core, ContentName, RecordID) + "And(ControlType=" + authoringControl + ")"; switch (authoringControl) { case AuthoringControls.Editing: MetadataController.deleteContentRecords(core, "Authoring Controls", Criteria + "And(CreatedBy=" + DbController.encodeSQLNumber(MemberID) + ")", MemberID); break; case AuthoringControls.Submitted: case AuthoringControls.Approved: case AuthoringControls.Modified: MetadataController.deleteContentRecords(core, "Authoring Controls", Criteria, MemberID); break; } } catch (Exception ex) { LogController.logError(core, ex); throw; } }
// //============================================================================= // public void verifyRegistrationFormPage(CoreController core) { try { MetadataController.deleteContentRecords(core, "Form Pages", "name=" + DbController.encodeSQLText("Registration Form")); using (var csData = new CsModel(core)) { if (!csData.open("Form Pages", "name=" + DbController.encodeSQLText("Registration Form"))) { // // create Version 1 template - just to main_Get it started // if (csData.insert("Form Pages")) { csData.set("name", "Registration Form"); string Copy = "" + Environment.NewLine + "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">" + Environment.NewLine + "{{REPEATSTART}}<tr><td align=right style=\"height:22px;\">{{CAPTION}} </td><td align=left>{{FIELD}}</td></tr>{{REPEATEND}}" + Environment.NewLine + "<tr><td align=right><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=135 height=1></td><td width=\"100%\"> </td></tr>" + Environment.NewLine + "<tr><td colspan=2> <br>" + core.html.getPanelButtons(ButtonRegister) + "</td></tr>" + Environment.NewLine + "</table>"; csData.set("Body", Copy); Copy = "" + "1" + Environment.NewLine + "Registered\r\ntrue" + Environment.NewLine + "1,First Name,true,FirstName" + Environment.NewLine + "1,Last Name,true,LastName" + Environment.NewLine + "1,Email Address,true,Email" + Environment.NewLine + "1,Phone,true,Phone" + Environment.NewLine + "2,Please keep me informed of news and events,false,Subscribers" + ""; csData.set("Instructions", Copy); } } } } catch (Exception ex) { LogController.logError(core, ex); } }
// //==================================================================================================== /// <summary> /// Process manual changes needed for special cases /// </summary> /// <param name="isDelete"></param> /// <param name="contentName"></param> /// <param name="recordId"></param> /// <param name="recordName"></param> /// <param name="recordParentID"></param> /// <param name="useContentWatchLink"></param> public static void processAfterSave(CoreController core, bool isDelete, string contentName, int recordId, string recordName, int recordParentID, bool useContentWatchLink) { try { PageContentModel.markReviewed(core.cpParent, recordId); string tableName = MetadataController.getContentTablename(core, contentName); // // -- invalidate the specific cache for this record core.cache.invalidateDbRecord(recordId, tableName); // string tableNameLower = tableName.ToLower(CultureInfo.InvariantCulture); if (tableNameLower == AddonCollectionModel.tableMetadata.tableNameLower) { // // -- addon collection processAfterSave_AddonCollection(core, isDelete, contentName, recordId, recordName, recordParentID, useContentWatchLink); } else if (tableNameLower == LinkForwardModel.tableMetadata.tableNameLower) { // // -- link forward core.routeMapCacheClear(); } else if (tableNameLower == LinkAliasModel.tableMetadata.tableNameLower) { // // -- link alias core.routeMapCacheClear(); } else if (tableNameLower == AddonModel.tableMetadata.tableNameLower) { // // -- addon core.routeMapCacheClear(); } else if (tableNameLower == PersonModel.tableMetadata.tableNameLower) { // // -- PersonModel var person = PersonModel.create <PersonModel>(core.cpParent, recordId); if (person != null) { if (isDelete) { LogController.addSiteActivity(core, "deleting user #" + recordId + " (" + recordName + ")", recordId, person.organizationId); } else { LogController.addSiteActivity(core, "saving changes to user #" + recordId + " (" + recordName + ")", recordId, person.organizationId); } } } else if (tableNameLower == OrganizationModel.tableMetadata.tableNameLower) { // // -- Log Activity for changes to people and organizattions if (isDelete) { LogController.addSiteActivity(core, "deleting organization #" + recordId + " (" + recordName + ")", 0, recordId); } else { LogController.addSiteActivity(core, "saving changes to organization #" + recordId + " (" + recordName + ")", 0, recordId); } } else if (tableNameLower == SitePropertyModel.tableMetadata.tableNameLower) { // // -- Site Properties switch (GenericController.toLCase(recordName)) { case "allowlinkalias": PageContentModel.invalidateCacheOfTable <PageContentModel>(core.cpParent); break; case "sectionlandinglink": PageContentModel.invalidateCacheOfTable <PageContentModel>(core.cpParent); break; case Constants._siteproperty_serverPageDefault_name: PageContentModel.invalidateCacheOfTable <PageContentModel>(core.cpParent); break; } } else if (tableNameLower == PageContentModel.tableMetadata.tableNameLower) { // // -- set ChildPagesFound true for parent page if (recordParentID > 0) { if (!isDelete) { core.db.executeNonQuery("update ccpagecontent set ChildPagesfound=1 where ID=" + recordParentID); } } if (isDelete) { // // Clear the Landing page and page not found site properties if (recordId == GenericController.encodeInteger(core.siteProperties.getText("PageNotFoundPageID", "0"))) { core.siteProperties.setProperty("PageNotFoundPageID", "0"); } if (recordId == core.siteProperties.landingPageID) { core.siteProperties.setProperty("landingPageId", "0"); } // // Delete Link Alias entries with this PageID core.db.executeNonQuery("delete from cclinkAliases where PageID=" + recordId); } DbBaseModel.invalidateCacheOfRecord <PageContentModel>(core.cpParent, recordId); } else if (tableNameLower == LibraryFilesModel.tableMetadata.tableNameLower) { // // -- processAfterSave_LibraryFiles(core, isDelete, contentName, recordId, recordName, recordParentID, useContentWatchLink); } // // Process Addons marked to trigger a process call on content change // Dictionary <string, string> instanceArguments; bool onChangeAddonsAsync = core.siteProperties.getBoolean("execute oncontentchange addons async", false); using (var csData = new CsModel(core)) { int contentId = ContentMetadataModel.getContentId(core, contentName); csData.open("Add-on Content Trigger Rules", "ContentID=" + contentId, "", false, 0, "addonid"); string Option_String = null; if (isDelete) { instanceArguments = new Dictionary <string, string> { { "action", "contentdelete" }, { "contentid", contentId.ToString() }, { "recordid", recordId.ToString() } }; Option_String = "" + Environment.NewLine + "action=contentdelete" + Environment.NewLine + "contentid=" + contentId + Environment.NewLine + "recordid=" + recordId + ""; } else { instanceArguments = new Dictionary <string, string> { { "action", "contentchange" }, { "contentid", contentId.ToString() }, { "recordid", recordId.ToString() } }; Option_String = "" + Environment.NewLine + "action=contentchange" + Environment.NewLine + "contentid=" + contentId + Environment.NewLine + "recordid=" + recordId + ""; } while (csData.ok()) { var addon = DbBaseModel.create <AddonModel>(core.cpParent, csData.getInteger("Addonid")); if (addon != null) { if (onChangeAddonsAsync) { // // -- execute addon async core.addon.executeAsync(addon, instanceArguments); } else { // // -- execute addon core.addon.execute(addon, new CPUtilsBaseClass.addonExecuteContext { addonType = CPUtilsBaseClass.addonContext.ContextOnContentChange, backgroundProcess = false, errorContextMessage = "", argumentKeyValuePairs = instanceArguments }); } } csData.goNext(); } } } catch (Exception ex) { LogController.logError(core, ex); } }
// //==================================================================================================== // public static string exportAscii_GetAsciiExport(CoreController core, string ContentName, int PageSize, int PageNumber) { string result = ""; try { string Delimiter = null; string Copy = ""; string TableName = null; string FieldNameVariant = null; string FieldName = null; string UcaseFieldName = null; string iContentName = null; System.Text.StringBuilder sb = new System.Text.StringBuilder(); string TestFilename; // TestFilename = "AsciiExport" + GenericController.getRandomInteger(core) + ".txt"; // iContentName = GenericController.encodeText(ContentName); if (PageSize == 0) { PageSize = 1000; } if (PageNumber == 0) { PageNumber = 1; } // // ----- Check for special case iContentNames // core.webServer.setResponseContentType("text/plain"); core.html.enableOutputBuffer(false); TableName = DbController.getDbObjectTableName(MetadataController.getContentTablename(core, iContentName)); switch (GenericController.toUCase(TableName)) { case "CCMEMBERS": // // ----- People and member content export // if (!core.session.isAuthenticatedAdmin()) { sb.Append("Warning: You must be a site administrator to export this information."); } else { using (var csData = new CsModel(core)) { csData.open(iContentName, "", "ID", false, 0, "", PageSize, PageNumber); // // ----- print out the field names // if (csData.ok()) { sb.Append("\"EID\""); Delimiter = ","; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { FieldName = GenericController.encodeText(FieldNameVariant); UcaseFieldName = GenericController.toUCase(FieldName); if ((UcaseFieldName != "USERNAME") && (UcaseFieldName != "PASSWORD")) { sb.Append(Delimiter + "\"" + FieldName + "\""); } FieldNameVariant = csData.getNextFieldName(); } sb.Append(Environment.NewLine); } // // ----- print out the values // while (csData.ok()) { if (!(csData.getBoolean("Developer"))) { Copy = SecurityController.encodeToken(core, csData.getInteger("ID"), core.doc.profileStartTime.AddDays(30)); sb.Append("\"" + Copy + "\""); Delimiter = ","; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { FieldName = GenericController.encodeText(FieldNameVariant); UcaseFieldName = GenericController.toUCase(FieldName); if ((UcaseFieldName != "USERNAME") && (UcaseFieldName != "PASSWORD")) { Copy = csData.getText(FieldName); if (!string.IsNullOrEmpty(Copy)) { Copy = GenericController.strReplace(Copy, "\"", "'"); Copy = GenericController.strReplace(Copy, Environment.NewLine, " "); Copy = GenericController.strReplace(Copy, "\r", " "); Copy = GenericController.strReplace(Copy, "\n", " "); } sb.Append(Delimiter + "\"" + Copy + "\""); } FieldNameVariant = csData.getNextFieldName(); } sb.Append(Environment.NewLine); } csData.goNext(); } } } // End Case break; default: // // ----- All other content // if (!core.session.isAuthenticatedContentManager(iContentName)) { sb.Append("Error: You must be a content manager to export this data."); } else { using (var csData = new CsModel(core)) { csData.open(iContentName, "", "ID", false, 0, "", PageSize, PageNumber); // // ----- print out the field names if (csData.ok()) { Delimiter = ""; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { core.wwwFiles.appendFile(TestFilename, Delimiter + "\"" + FieldNameVariant + "\""); Delimiter = ","; FieldNameVariant = csData.getNextFieldName(); } core.wwwFiles.appendFile(TestFilename, Environment.NewLine); } // // ----- print out the values while (csData.ok()) { Delimiter = ""; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { switch (csData.getFieldTypeId(GenericController.encodeText(FieldNameVariant))) { case CPContentBaseClass.FieldTypeIdEnum.FileText: case CPContentBaseClass.FieldTypeIdEnum.FileCSS: case CPContentBaseClass.FieldTypeIdEnum.FileXML: case CPContentBaseClass.FieldTypeIdEnum.FileJavascript: case CPContentBaseClass.FieldTypeIdEnum.FileHTML: case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: Copy = csData.getTextEncoded(GenericController.encodeText(FieldNameVariant)); break; case CPContentBaseClass.FieldTypeIdEnum.Lookup: Copy = csData.getText(GenericController.encodeText(FieldNameVariant)); break; case CPContentBaseClass.FieldTypeIdEnum.Redirect: case CPContentBaseClass.FieldTypeIdEnum.ManyToMany: break; default: Copy = csData.getText(GenericController.encodeText(FieldNameVariant)); break; } if (!string.IsNullOrEmpty(Copy)) { Copy = GenericController.strReplace(Copy, "\"", "'"); Copy = GenericController.strReplace(Copy, Environment.NewLine, " "); Copy = GenericController.strReplace(Copy, "\r", " "); Copy = GenericController.strReplace(Copy, "\n", " "); } core.wwwFiles.appendFile(TestFilename, Delimiter + "\"" + Copy + "\""); Delimiter = ","; FieldNameVariant = csData.getNextFieldName(); } core.wwwFiles.appendFile(TestFilename, Environment.NewLine); csData.goNext(); } } } break; } result = core.wwwFiles.readFileText(TestFilename); core.wwwFiles.deleteFile(TestFilename); } catch (Exception ex) { LogController.logError(core, ex); } return(result); }
// //====================================================================================================== // public static void installNode(CoreController core, XmlNode AddonNode, string AddonGuidFieldName, int CollectionID, ref bool return_UpgradeOK, ref string return_ErrorMessage, ref bool collectionIncludesDiagnosticAddons) { // todo - return bool return_ErrorMessage = ""; return_UpgradeOK = true; try { string Basename = GenericController.toLCase(AddonNode.Name); if ((Basename == "page") || (Basename == "process") || (Basename == "addon") || (Basename == "add-on")) { bool IsFound = false; string addonName = XmlController.getXMLAttribute(core, ref IsFound, AddonNode, "name", "No Name"); if (string.IsNullOrEmpty(addonName)) { addonName = "No Name"; } string addonGuid = XmlController.getXMLAttribute(core, ref IsFound, AddonNode, "guid", addonName); if (string.IsNullOrEmpty(addonGuid)) { addonGuid = addonName; } string navTypeName = XmlController.getXMLAttribute(core, ref IsFound, AddonNode, "type", ""); int navTypeId = getListIndex(navTypeName, navTypeIDList); if (navTypeId == 0) { navTypeId = NavTypeIDAddon; } using (var cs = new CsModel(core)) { string Criteria = "(" + AddonGuidFieldName + "=" + DbController.encodeSQLText(addonGuid) + ")"; cs.open(AddonModel.tableMetadata.contentName, Criteria, "", false); if (cs.ok()) { // // Update the Addon // LogController.logInfo(core, MethodInfo.GetCurrentMethod().Name + ", UpgradeAppFromLocalCollection, GUID match with existing Add-on, Updating Add-on [" + addonName + "], Guid [" + addonGuid + "]"); } else { // // not found by GUID - search name against name to update legacy Add-ons // cs.close(); Criteria = "(name=" + DbController.encodeSQLText(addonName) + ")and(" + AddonGuidFieldName + " is null)"; cs.open(AddonModel.tableMetadata.contentName, Criteria, "", false); if (cs.ok()) { LogController.logInfo(core, MethodInfo.GetCurrentMethod().Name + ", UpgradeAppFromLocalCollection, Add-on name matched an existing Add-on that has no GUID, Updating legacy Aggregate Function to Add-on [" + addonName + "], Guid [" + addonGuid + "]"); } } if (!cs.ok()) { // // not found by GUID or by name, Insert a new addon // cs.close(); cs.insert(AddonModel.tableMetadata.contentName); if (cs.ok()) { LogController.logInfo(core, MethodInfo.GetCurrentMethod().Name + ", UpgradeAppFromLocalCollection, Creating new Add-on [" + addonName + "], Guid [" + addonGuid + "]"); } } if (!cs.ok()) { // // Could not create new Add-on // LogController.logInfo(core, MethodInfo.GetCurrentMethod().Name + ", UpgradeAppFromLocalCollection, Add-on could not be created, skipping Add-on [" + addonName + "], Guid [" + addonGuid + "]"); } else { int addonId = cs.getInteger("ID"); MetadataController.deleteContentRecords(core, "Add-on Include Rules", "addonid=" + addonId); MetadataController.deleteContentRecords(core, "Add-on Content Trigger Rules", "addonid=" + addonId); // cs.set("collectionid", CollectionID); cs.set(AddonGuidFieldName, addonGuid); cs.set("name", addonName); cs.set("navTypeId", navTypeId); var ArgumentList = new StringBuilder(); var StyleSheet = new StringBuilder(); if (AddonNode.ChildNodes.Count > 0) { foreach (XmlNode Addonfield in AddonNode.ChildNodes) { if (!(Addonfield is XmlComment)) { XmlNode PageInterface = Addonfield; string fieldName = null; string FieldValue = ""; switch (GenericController.toLCase(Addonfield.Name)) { case "activexdll": { // // This is handled in BuildLocalCollectionFolder // break; } case "editors": { // // list of editors // foreach (XmlNode TriggerNode in Addonfield.ChildNodes) { // int fieldTypeId = 0; string fieldType = null; switch (GenericController.toLCase(TriggerNode.Name)) { case "type": { fieldType = TriggerNode.InnerText; fieldTypeId = MetadataController.getRecordIdByUniqueName(core, "Content Field Types", fieldType); if (fieldTypeId > 0) { using (var CS2 = new CsModel(core)) { Criteria = "(addonid=" + addonId + ")and(contentfieldTypeID=" + fieldTypeId + ")"; CS2.open("Add-on Content Field Type Rules", Criteria); if (!CS2.ok()) { CS2.insert("Add-on Content Field Type Rules"); } if (CS2.ok()) { CS2.set("addonid", addonId); CS2.set("contentfieldTypeID", fieldTypeId); } } } break; } default: { // do nothing break; } } } break; } case "processtriggers": { // // list of events that trigger a process run for this addon // foreach (XmlNode TriggerNode in Addonfield.ChildNodes) { switch (GenericController.toLCase(TriggerNode.Name)) { case "contentchange": { int TriggerContentId = 0; string ContentNameorGuid = TriggerNode.InnerText; if (string.IsNullOrEmpty(ContentNameorGuid)) { ContentNameorGuid = XmlController.getXMLAttribute(core, ref IsFound, TriggerNode, "guid", ""); if (string.IsNullOrEmpty(ContentNameorGuid)) { ContentNameorGuid = XmlController.getXMLAttribute(core, ref IsFound, TriggerNode, "name", ""); } } using (var CS2 = new CsModel(core)) { Criteria = "(ccguid=" + DbController.encodeSQLText(ContentNameorGuid) + ")"; CS2.open("Content", Criteria); if (!CS2.ok()) { Criteria = "(ccguid is null)and(name=" + DbController.encodeSQLText(ContentNameorGuid) + ")"; CS2.open("content", Criteria); } if (CS2.ok()) { TriggerContentId = CS2.getInteger("ID"); } } if (TriggerContentId != 0) { using (var CS2 = new CsModel(core)) { Criteria = "(addonid=" + addonId + ")and(contentid=" + TriggerContentId + ")"; CS2.open("Add-on Content Trigger Rules", Criteria); if (!CS2.ok()) { CS2.insert("Add-on Content Trigger Rules"); if (CS2.ok()) { CS2.set("addonid", addonId); CS2.set("contentid", TriggerContentId); } } CS2.close(); } } break; } default: { // do nothing break; } } } break; } case "scripting": { // // include add-ons - NOTE - import collections must be run before interfaces // when importing a collectin that will be used for an include int scriptinglanguageid = (int)AddonController.ScriptLanguages.VBScript; string ScriptingLanguage = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "language", "").ToLowerInvariant(); if (ScriptingLanguage.Equals("javascript") || ScriptingLanguage.Equals("jscript")) { scriptinglanguageid = (int)AddonController.ScriptLanguages.Javascript; } cs.set("scriptinglanguageid", scriptinglanguageid); string ScriptingEntryPoint = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "entrypoint", ""); cs.set("ScriptingEntryPoint", ScriptingEntryPoint); int ScriptingTimeout = GenericController.encodeInteger(XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "timeout", "5000")); cs.set("ScriptingTimeout", ScriptingTimeout); string ScriptingCode = ""; foreach (XmlNode ScriptingNode in Addonfield.ChildNodes) { switch (GenericController.toLCase(ScriptingNode.Name)) { case "code": { ScriptingCode += ScriptingNode.InnerText; break; } default: { // do nothing break; } } } cs.set("ScriptingCode", ScriptingCode); break; } case "activexprogramid": { // // save program id // FieldValue = Addonfield.InnerText; cs.set("ObjectProgramID", FieldValue); break; } case "navigator": { // // create a navigator entry with a parent set to this // cs.save(); string menuNameSpace = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "NameSpace", ""); if (!string.IsNullOrEmpty(menuNameSpace)) { string NavIconTypeString = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "type", ""); if (string.IsNullOrEmpty(NavIconTypeString)) { NavIconTypeString = "Addon"; } BuildController.verifyNavigatorEntry(core, new MetadataMiniCollectionModel.MiniCollectionMenuModel { menuNameSpace = menuNameSpace, name = addonName, adminOnly = false, developerOnly = false, newWindow = false, active = true, addonName = addonName, navIconType = NavIconTypeString, navIconTitle = addonName }, CollectionID); } break; } case "argument": case "argumentlist": { // // multiple argumentlist elements are concatinated with crlf ArgumentList.Append(Addonfield.InnerText.Trim(' ') + Environment.NewLine); break; } case "style": { // // import exclusive style // string NodeName = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "name", ""); string NewValue = encodeText(Addonfield.InnerText).Trim(' '); if (NewValue.left(1) != "{") { NewValue = "{" + NewValue; } if (NewValue.Substring(NewValue.Length - 1) != "}") { NewValue += "}"; } StyleSheet.Append(NodeName + " " + NewValue + Environment.NewLine); break; } case "stylesheet": case "styles": { // // import exclusive stylesheet if more then whitespace // string test = Addonfield.InnerText; test = strReplace(test, " ", ""); test = strReplace(test, "\r", ""); test = strReplace(test, "\n", ""); test = strReplace(test, "\t", ""); if (!string.IsNullOrEmpty(test)) { StyleSheet.Append(Addonfield.InnerText + Environment.NewLine); } break; } case "template": case "content": case "admin": { // // these add-ons will be "non-developer only" in navigation // fieldName = Addonfield.Name; FieldValue = Addonfield.InnerText; if (!cs.isFieldSupported(fieldName)) { // // Bad field name - need to report it somehow // } else { cs.set(fieldName, FieldValue); if (GenericController.encodeBoolean(Addonfield.InnerText)) { // // if template, admin or content - let non-developers have navigator entry // } } break; } case "icon": { // // icon // FieldValue = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "link", ""); if (!string.IsNullOrEmpty(FieldValue)) { // // Icons can be either in the root of the website or in content files // FieldValue = GenericController.strReplace(FieldValue, "\\", "/"); // make it a link, not a file if (GenericController.strInstr(1, FieldValue, "://") != 0) { // // the link is an absolute URL, leave it link this // } else { if (FieldValue.left(1) != "/") { // // make sure it starts with a slash to be consistance // FieldValue = "/" + FieldValue; } if (FieldValue.left(17) == "/contensivefiles/") { // // in content files, start link without the slash // FieldValue = FieldValue.Substring(17); } } cs.set("IconFilename", FieldValue); { cs.set("IconWidth", GenericController.encodeInteger(XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "width", "0"))); cs.set("IconHeight", GenericController.encodeInteger(XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "height", "0"))); cs.set("IconSprites", GenericController.encodeInteger(XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "sprites", "0"))); } } break; } case "includeaddon": case "includeadd-on": case "include addon": case "include add-on": { // // processed in phase2 of this routine, after all the add-ons are installed // break; } case "form": { // // The value of this node is the xml instructions to create a form. Take then // entire node, children and all, and save them in the formxml field. // this replaces the settings add-on type, and soo to be report add-on types as well. // this removes the ccsettingpages and settingcollectionrules, etc. // { cs.set("formxml", Addonfield.InnerXml); } break; } case "javascript": case "javascriptinhead": { // // these all translate to JSFilename // fieldName = "jsfilename"; cs.set(fieldName, Addonfield.InnerText); break; } case "iniframe": { // // typo - field is inframe // fieldName = "inframe"; cs.set(fieldName, Addonfield.InnerText); break; } case "diagnostic": { bool fieldValue = encodeBoolean(Addonfield.InnerText); cs.set("diagnostic", fieldValue); collectionIncludesDiagnosticAddons = collectionIncludesDiagnosticAddons || fieldValue; break; } case "category": { if (!string.IsNullOrWhiteSpace(Addonfield.InnerText)) { AddonCategoryModel category = DbBaseModel.createByUniqueName <AddonCategoryModel>(core.cpParent, Addonfield.InnerText); if (category == null) { category = DbBaseModel.addDefault <AddonCategoryModel>(core.cpParent); category.name = Addonfield.InnerText; category.save(core.cpParent); } cs.set("addonCategoryId", category.id); } break; } case "instancesettingprimarycontentid": { int lookupContentId = 0; if (!string.IsNullOrWhiteSpace(Addonfield.InnerText)) { ContentModel lookupContent = DbBaseModel.createByUniqueName <ContentModel>(core.cpParent, Addonfield.InnerText); if (lookupContent != null) { lookupContentId = lookupContent.id; } } cs.set("instancesettingprimarycontentid", lookupContentId); break; } default: { // // All the other fields should match the Db fields // fieldName = Addonfield.Name; FieldValue = Addonfield.InnerText; if (!cs.isFieldSupported(fieldName)) { // // Bad field name - need to report it somehow // LogController.logError(core, new ApplicationException("bad field found [" + fieldName + "], in addon node [" + addonName + "], of collection [" + MetadataController.getRecordName(core, "add-on collections", CollectionID) + "]")); } else { cs.set(fieldName, FieldValue); } break; } } } } } cs.set("ArgumentList", ArgumentList.ToString()); cs.set("StylesFilename", StyleSheet.ToString()); } cs.close(); } } } catch (Exception ex) { LogController.logError(core, ex); throw; } }