/// <summary> /// Deletes customTableItem. Called when the "Delete item" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool DeleteCustomTableItem() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text%'"; // Get the data DataSet customTableItems = customTableProvider.GetItems(customTableClassName, where, null); if (!DataHelper.DataSourceIsEmpty(customTableItems)) { // Loop through the individual items foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows) { // Create object from DataRow CustomTableItem deleteCustomTableItem = new CustomTableItem(customTableItemDr, customTableClassName); // Delete custom table item from database deleteCustomTableItem.Delete(); } return(true); } } return(false); }
/// <summary> /// Executes custom grid actions. /// </summary> /// <param name="actionName">Name of the action</param> /// <param name="actionArgument">Argument for the action</param> private void Control_OnAction(string actionName, object actionArgument) { switch (actionName) { case "delete": if (QueriesCanBeModified) { QueryInfo queryInfo = QueryInfoProvider.GetQueryInfo(ValidationHelper.GetInteger(actionArgument, 0)); DataClassInfo classInfo = ((DataClassInfo)Page.EditedObjectParent); if ((queryInfo != null) && (classInfo != null) && (queryInfo.ClassID == classInfo.ClassID)) { queryInfo.Delete(); } else { CMSPage.RedirectToInformation("editedobject.notexists"); } } else { Control.ShowError(ResHelper.GetString("cms.query.customization.deletedisabled")); } break; } }
protected void Page_Load(object sender, EventArgs e) { FieldEditor.FormType = FormTypeEnum.BizForm; FieldEditor.Visible = false; if (FormInfo != null) { // Get form class info DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(FormInfo.FormClassID); if (dci != null) { if (dci.ClassIsCoupledClass) { // Setup the field editor CurrentMaster.BodyClass += " FieldEditorBody"; FieldEditor.Visible = true; FieldEditor.ClassName = dci.ClassName; FieldEditor.Mode = FieldEditorModeEnum.BizFormDefinition; FieldEditor.OnAfterDefinitionUpdate += FieldEditor_OnAfterDefinitionUpdate; FieldEditor.OnFieldNameChanged += FieldEditor_OnFieldNameChanged; } else { ShowError(GetString("EditTemplateFields.ErrorIsNotCoupled")); } } } ScriptHelper.HideVerticalTabs(this); }
/// <summary> /// Gets the class to which belongs currently edited query or the query that's being created. /// </summary> private DataClassInfo GetClass() { DataClassInfo classInfo = null; if ((Query == null) && (QueryID > 0)) { Query = QueryInfo.Provider.Get(QueryID); } if (Query != null) { if (Query.ClassID > 0) { classInfo = DataClassInfoProvider.GetDataClassInfo(Query.ClassID); } if ((classInfo == null) && ClassID > 0) { classInfo = DataClassInfoProvider.GetDataClassInfo(ClassID); } if ((classInfo == null) && !String.IsNullOrEmpty(ClassName)) { classInfo = DataClassInfoProvider.GetDataClassInfo(ClassName); } } return(classInfo); }
/// <summary> /// Page load. /// </summary> protected void Page_Load(object sender, EventArgs e) { if (CustomTableId > 0) { // Get form info dci = DataClassInfoProvider.GetDataClassInfo(CustomTableId); if (dci != null) { if (dci.ClassEditingPageURL != String.Empty) { editItemPage = dci.ClassEditingPageURL; } customTableForm.OnBeforeDataRetrieval += customTableForm_OnBeforeDataRetrieval; customTableForm.OnAfterSave += customTableForm_OnAfterSave; } } // Show message about successful save if (!RequestHelper.IsPostBack() && QueryHelper.GetBoolean("saved", false)) { customTableForm.ShowChangesSaved(); } }
/// <summary> /// Rebuilds all URL Routes for nodes which use this class across all sites. /// </summary> /// <param name="ClassName">The Class Name</param> public static void RebuildRoutesByClass(string ClassName) { DataClassInfo Class = GetClass(ClassName); foreach (string SiteName in SiteInfoProvider.GetSites().Select(x => x.SiteName)) { // Get NodeItemBuilderSettings NodeItemBuilderSettings BuilderSettings = GetNodeItemBuilderSettings(SiteName, true, true, true, true, true); // Build all, gather nodes of any Node that is of this type of class, check for updates. List <int> NodeIDs = DocumentHelper.GetDocuments() .WhereEquals("NodeClassID", Class.ClassID) .OnSite(new SiteInfoIdentifier(SiteName)) .CombineWithDefaultCulture() .Distinct() .Columns("NodeID") .OrderBy("NodeLevel, NodeOrder") .Select(x => x.NodeID) .ToList(); // Check all parent nodes for changes foreach (int NodeID in NodeIDs) { RebuildRoutesByNode(NodeID, BuilderSettings); } } }
protected void Page_Load(object sender, EventArgs e) { CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; // Get form info BizFormInfo formInfo = EditedObject as BizFormInfo; if (formInfo == null) { return; } // Get class of the form DataClassInfo classInfo = DataClassInfoProvider.GetDataClassInfo(formInfo.FormClassID); // Load mapping dialog control and initialize it plcMapping.Controls.Clear(); mapControl = (CMSUserControl)Page.LoadUserControl("~/CMSModules/ContactManagement/Controls/UI/Contact/MappingDialog.ascx"); if (mapControl != null) { mapControl.ID = "ctrlMapping"; mapControl.SetValue("classname", classInfo.ClassName); mapControl.SetValue("allowoverwrite", classInfo.ClassContactOverwriteEnabled); plcMapping.Controls.Add(mapControl); } if (!RequestHelper.IsPostBack()) { // Initialize checkbox value and mapping dialog visibility chkLogActivity.Checked = formInfo.FormLogActivity; } }
protected void Page_Load(object sender, EventArgs e) { CurrentMaster.BodyClass += " FieldEditorBody"; string className = null; DataClassInfo dci = null; // Get class id from url classId = QueryHelper.GetInteger("classid", 0); dci = DataClassInfoProvider.GetDataClass(classId); FieldEditor.Visible = false; if (dci != null) { className = dci.ClassName; if (dci.ClassIsCoupledClass) { // Set field editor FieldEditor.Visible = true; FieldEditor.ClassName = className; FieldEditor.Mode = FieldEditorModeEnum.SystemTable; FieldEditor.OnFieldNameChanged += FieldEditor_OnFieldNameChanged; } else { ShowError(GetString("EditTemplateFields.ErrorIsNotCoupled")); FieldEditor.Visible = false; } } }
/// <summary> /// Page load. /// </summary> protected void Page_Load(object sender, EventArgs e) { if (CustomTableId > 0) { // Get form info dci = DataClassInfoProvider.GetDataClass(CustomTableId); if (dci != null) { customTableForm.ShowPrivateFields = true; if (dci.ClassEditingPageURL != String.Empty) { editItemPage = dci.ClassEditingPageURL; } customTableForm.OnAfterSave += customTableForm_OnAfterSave; customTableForm.OnBeforeSave += customTableForm_OnBeforeSave; } } // Show message about successful save if (QueryHelper.GetString("saved", String.Empty) != String.Empty) { lblInfo.Text = GetString("general.changessaved"); lblInfo.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { CurrentMaster.BodyClass += " FieldEditorBody"; string className = null; bool isCoupledClass = false; DataClassInfo dci = null; classId = ValidationHelper.GetInteger(Request.QueryString["documenttypeid"], 0); dci = DataClassInfoProvider.GetDataClass(classId); FieldEditor.Visible = false; if (dci != null) { className = dci.ClassName; isCoupledClass = dci.ClassIsCoupledClass; if (dci.ClassIsCoupledClass) { FieldEditor.Visible = true; FieldEditor.ClassName = className; FieldEditor.Mode = FieldEditorModeEnum.ClassFormDefinition; FieldEditor.OnFieldNameChanged += FieldEditor_OnFieldNameChanged; } else { pnlError.Visible = true; FieldEditor.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { CurrentMaster.Title.TitleText = GetString("customtable.data.viewitemtitle"); Page.Title = CurrentMaster.Title.TitleText; CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_CustomTables/viewitem.png"); // Get custom table id from url int customTableId = QueryHelper.GetInteger("customtableid", 0); // Get custom table item id int itemId = QueryHelper.GetInteger("itemid", 0); DataClassInfo dci = DataClassInfoProvider.GetDataClass(customTableId); // Set edited object EditedObject = dci; if (dci != null) { // Check 'Read' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.customtables", "Read") && !CMSContext.CurrentUser.IsAuthorizedPerClassName(dci.ClassName, "Read")) { RedirectToAccessDenied("cms.customtables", "Read"); } CustomTableItemProvider ctProvider = new CustomTableItemProvider(CMSContext.CurrentUser); CustomTableItem item = ctProvider.GetItem(itemId, dci.ClassName); customTableViewItem.CustomTableItem = item; } }
public async Task CreateContentType(DataClassInfo contentType) { try { SyncLog.LogEvent(EventType.INFORMATION, "KenticoKontentPublishing", "CREATECONTENTTYPE", contentType.ClassDisplayName); var endpoint = $"/types"; var payload = new { name = contentType.ClassDisplayName.LimitedTo(ELEMENT_MAXLENGTH), code_name = contentType.ClassName.LimitedTo(ELEMENT_MAXLENGTH), external_id = GetPageTypeExternalId(contentType.ClassGUID), content_groups = GetContentTypeGroups(contentType), elements = GetContentTypeElements(contentType), }; await ExecuteWithoutResponse(endpoint, HttpMethod.Post, payload); } catch (Exception ex) { SyncLog.LogException("KenticoKontentPublishing", "CREATECONTENTTYPE", ex); throw; } }
private IEnumerable <object> GetContentTypeGroups(DataClassInfo contentType) { return(new[] { new { name = CONTENT, external_id = GetGroupExternalId(contentType.ClassGUID, CONTENT_GUID) }, new { name = UNSORTED_ATTACHMENTS_NAME, external_id = GetGroupExternalId(contentType.ClassGUID, UNSORTED_ATTACHMENTS_GUID) }, new { name = TaxonomySync.CATEGORIES, external_id = GetGroupExternalId(contentType.ClassGUID, TaxonomySync.CATEGORIES_GUID) }, new { name = RELATED_PAGES_NAME, external_id = GetGroupExternalId(contentType.ClassGUID, RELATED_PAGES_GUID) }, }); }
/// <summary> /// Actions handler - saves the changes. /// </summary> protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e) { // Update the form object and its class BizFormInfo form = EditedObject as BizFormInfo; if ((form != null) && (mapControl != null)) { if (plcMapping.Visible) { // Update mapping of the form class only if mapping dialog is visible DataClassInfo classInfo = DataClassInfoProvider.GetDataClassInfo(form.FormClassID); if (classInfo != null) { classInfo.ClassContactOverwriteEnabled = ValidationHelper.GetBoolean(mapControl.GetValue("allowoverwrite"), false); classInfo.ClassContactMapping = ValidationHelper.GetString(mapControl.GetValue("mappingdefinition"), string.Empty); DataClassInfoProvider.SetDataClassInfo(classInfo); } } // Update the form form.FormLogActivity = chkLogActivity.Checked; BizFormInfoProvider.SetBizFormInfo(form); // Show save information ShowChangesSaved(); } }
protected void Page_Load(object sender, EventArgs e) { // Check the current user currentUser = CMSContext.CurrentUser; if (currentUser == null) { return; } // Check 'Read' permission if (currentUser.IsAuthorizedPerResource("cms.blog", "Read")) { readBlogs = true; } if (!RequestHelper.IsPostBack()) { this.drpBlogs.Items.Add(new ListItem(GetString("general.selectall"), "##ALL##")); this.drpBlogs.Items.Add(new ListItem(GetString("blog.selectmyblogs"), "##MYBLOGS##")); } // No cms.blog doc. type if (DataClassInfoProvider.GetDataClass("cms.blog") == null) { RedirectToInformation(GetString("blog.noblogdoctype")); } this.CurrentMaster.DisplaySiteSelectorPanel = true; gridBlogs.OnDataReload += gridBlogs_OnDataReload; gridBlogs.ZeroRowsText = GetString("general.nodatafound"); gridBlogs.ShowActionsMenu = true; gridBlogs.Columns = "BlogID, BlogName, NodeID, DocumentCulture"; // Get all possible columns to retrieve IDataClass nodeClass = DataClassFactory.NewDataClass("CMS.Tree"); DocumentInfo di = new DocumentInfo(); BlogInfo bi = new BlogInfo(); gridBlogs.AllColumns = SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(bi.ColumnNames.ToArray()), SqlHelperClass.MergeColumns(di.ColumnNames.ToArray())), SqlHelperClass.MergeColumns(nodeClass.ColumnNames.ToArray())); DataClassInfo dci = DataClassInfoProvider.GetDataClass("cms.blogpost"); string classId = ""; StringBuilder script = new StringBuilder(); if (dci != null) { classId = dci.ClassID.ToString(); } // Get script to redirect to new blog post page script.Append("function NewPost(parentId, culture) {", " if (parentId != 0) {", " parent.parent.parent.location.href = \"", ResolveUrl("~/CMSDesk/default.aspx"), "?section=content&action=new&nodeid=\" + parentId + \"&classid=", classId, " &culture=\" + culture;", "}}"); // Generate javascript code ltlScript.Text = ScriptHelper.GetScript(script.ToString()); }
protected void Page_Load(object sender, EventArgs e) { int classId = QueryHelper.GetInteger("classid", 0); if (classId > 0) { dci = DataClassInfoProvider.GetDataClass(classId); } // Initializes page title string[,] breadcrumbs = new string[2,3]; breadcrumbs[0, 0] = GetString("systbl.header.listlink"); breadcrumbs[0, 1] = "~/CMSModules/SystemTables/Pages/Development/SystemTable/List.aspx"; breadcrumbs[0, 2] = "_parent"; breadcrumbs[1, 0] = (dci != null) ? dci.ClassDisplayName : String.Empty; breadcrumbs[1, 1] = ""; breadcrumbs[1, 2] = ""; CurrentMaster.Title.Breadcrumbs = breadcrumbs; CurrentMaster.Title.HelpTopicName = "system_tables_fields"; CurrentMaster.Title.HelpName = "helpTopic"; if (!RequestHelper.IsPostBack()) { // Initialize menu InitializeMenu(classId); } }
private void GenerateCode(DataClassInfo dataClass) { if (UseBindingTemplates(dataClass)) { var infoTemplate = DataEngineCodeTemplateGenerator.GetBindingInfoCodeTemplate(dataClass); txtInfoCode.Text = infoTemplate.TransformText(); hdnInfoClassName.Value = infoTemplate.InfoClassName; var infoProviderInterfaceTemplate = DataEngineCodeTemplateGenerator.GetBindingInfoProviderInterfaceCodeTemplate(dataClass); txtInfoProviderInterfaceCode.Text = infoProviderInterfaceTemplate.TransformText(); hdnInfoProviderInterfaceName.Value = infoProviderInterfaceTemplate.InfoProviderInterfaceName; var infoProviderTemplate = DataEngineCodeTemplateGenerator.GetBindingInfoProviderCodeTemplate(dataClass); txtInfoProviderCode.Text = infoProviderTemplate.TransformText(); hdnInfoProviderClassName.Value = infoProviderTemplate.InfoProviderClassName; } else { var infoTemplate = DataEngineCodeTemplateGenerator.GetInfoCodeTemplate(dataClass); txtInfoCode.Text = infoTemplate.TransformText(); hdnInfoClassName.Value = infoTemplate.InfoClassName; var infoProviderInterfaceTemplate = DataEngineCodeTemplateGenerator.GetInfoProviderInterfaceCodeTemplate(dataClass); txtInfoProviderInterfaceCode.Text = infoProviderInterfaceTemplate.TransformText(); hdnInfoProviderInterfaceName.Value = infoProviderInterfaceTemplate.InfoProviderInterfaceName; var infoProviderTemplate = DataEngineCodeTemplateGenerator.GetInfoProviderCodeTemplate(dataClass); txtInfoProviderCode.Text = infoProviderTemplate.TransformText(); hdnInfoProviderClassName.Value = infoProviderTemplate.InfoProviderClassName; } }
public void GenerateDefaultTransformation(DefaultTransformationTypeEnum transformCode) { if (String.IsNullOrEmpty(ClassName)) { ClassName = DataClassInfoProvider.GetClassName(ClassID); } // Gets Xml schema of the document type DataClassInfo dci = DataClassInfoProvider.GetDataClass(ClassName); string formDef = string.Empty; if (dci != null) { formDef = dci.ClassFormDefinition; } // Gets transformation type TransformationTypeEnum transformType = TransformationInfoProvider.GetTransformationTypeEnum(drpType.SelectedValue); // Writes the result to the text box if (transformType == TransformationTypeEnum.Html) { txtCode.Visible = false; tbWysiwyg.Visible = true; tbWysiwyg.ResolvedValue = TransformationInfoProvider.GenerateTransformationCode(formDef, transformType, ClassName, transformCode); } else { tbWysiwyg.Visible = false; txtCode.Visible = true; txtCode.Text = TransformationInfoProvider.GenerateTransformationCode(formDef, transformType, ClassName, transformCode); } }
/// <summary> /// Initializes DocumentType edit menu. /// </summary> /// <param name="docTypeId">DocumentTypeID</param> protected void InitializeMenu(DataClassInfo classObj) { int i = 0; InitTabs("content"); SetTab(i++, GetString("general.general"), "DocumentType_Edit_General.aspx?documenttypeid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'general_tab18');"); // If document type is container if (classObj.ClassIsCoupledClass) { SetTab(i++, GetString("general.fields"), "DocumentType_Edit_Fields.aspx?documenttypeid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'fields_tab2');"); SetTab(i++, GetString("general.form"), "DocumentType_Edit_Form.aspx?documenttypeid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'form_tab3');"); } SetTab(i++, GetString("DocumentType_Edit_Header.Transformations"), "DocumentType_Edit_Transformation_List.aspx?documenttypeid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'transformations_tab');"); SetTab(i++, GetString("DocumentType_Edit_Header.Queries"), "DocumentType_Edit_Query_List.aspx?documenttypeid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'queries_tab');"); SetTab(i++, GetString("DocumentType_Edit_Header.ChildTypes"), "DocumentType_Edit_ChildTypes.aspx?documenttypeid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'child_types_tab');"); SetTab(i++, GetString("general.sites"), "DocumentType_Edit_Sites.aspx?documenttypeid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'sites_tab7');"); if (ModuleEntry.IsModuleLoaded(ModuleEntry.ECOMMERCE)) { SetTab(i++, GetString("DocumentType_Edit_Header.Ecommerce"), ResolveUrl("~/CMSModules/Ecommerce/Pages/Development/DocumentTypes/DocumentType_Edit_Ecommerce.aspx") + "?documenttypeid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'e_commerce_tab');"); } // If document type is not container if (classObj.ClassIsCoupledClass) { SetTab(i++, GetString("doc.header.altforms"), ResolveUrl("~/CMSModules/DocumentTypes/Pages/AlternativeForms/AlternativeForms_List.aspx?classid=" + classObj.ClassID), "SetHelpTopic('helpTopic', 'alternative_forms');"); SetTab(i++, GetString("srch.fields"), "DocumentType_Edit_SearchFields.aspx?documenttypeid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'search_fields');"); } SetTab(i++, GetString("general.documents"), "DocumentType_Edit_Documents.aspx?documenttypeid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'doctype_documents');"); }
/// <summary> /// Validates entries. /// </summary> /// <returns>Returns empty string on success and error message otherwise</returns> private string ValidateForm() { string errMsg = String.Empty; if (CurrentClass != null) { // Validate using validators errMsg = new Validator().NotEmpty(txtCodeNameName.Text, rfvCodeNameName.ErrorMessage).NotEmpty(txtCodeNameNamespace.Text, rfvCodeNameNamespace.ErrorMessage). NotEmpty(txtDisplayName.Text, rfvDisplayName.ErrorMessage).IsIdentifier(txtCodeNameNamespace.Text, GetString("general.invalidcodename")). IsCodeName(txtCodeNameName.Text, GetString("general.invalidcodename")).Result; string classFullName = txtCodeNameNamespace.Text + "." + txtCodeNameName.Text; // Check if class with specified code name already exist DataClassInfo existingDataClass = DataClassInfoProvider.GetDataClass(classFullName); if (existingDataClass != null) { if (CurrentClass.ClassID != existingDataClass.ClassID) { errMsg = ResHelper.GetString("sysdev.class_edit_gen.codenameunique"); } } } return(errMsg); }
/// <summary> /// Loads custom properties to given list. /// </summary> /// <param name="properties">ArrayList to load properties to</param> private void LoadCustomProperties(ArrayList properties) { properties.Clear(); // Load DataClass DataClassInfo productClass = DataClassInfoProvider.GetDataClassInfo("ecommerce.sku"); if (productClass != null) { // Load XML definition FormInfo fi = FormHelper.GetFormInfo(productClass.ClassName, false); // Get all fields List <IField> itemList = fi.GetFormElements(true, true, true); if (itemList != null) { FormFieldInfo formField; // Store each field to array foreach (object item in itemList) { if (item is FormFieldInfo) { formField = ((FormFieldInfo)(item)); properties.Add(formField); } } } } }
protected void Page_Load(object sender, EventArgs e) { CurrentMaster.BodyClass += " FieldEditorBody"; // Get classId from query string classId = QueryHelper.GetInteger("objectid", 0); DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(classId); FieldEditor.Visible = false; if (dci != null) { string className = dci.ClassName; // Init field editor if (dci.ClassIsCoupledClass) { FieldEditor.Visible = true; FieldEditor.ClassName = className; FieldEditor.Mode = FieldEditorModeEnum.ClassFormDefinition; FieldEditor.OnFieldNameChanged += FieldEditor_OnFieldNameChanged; } else { ShowWarning(GetString("EditTemplateFields.ErrorIsNotCoupled")); FieldEditor.Visible = false; } } ScriptHelper.HideVerticalTabs(this); }
/// <summary> /// OK button click handler. /// </summary> void ClassFields_OnSaved(object sender, EventArgs e) { if (dci == null) { dci = DataClassInfoProvider.GetDataClass(this.ItemID); } if (dci != null) { dci.ClassSearchTitleColumn = drpTitleField.SelectedValue; dci.ClassSearchContentColumn = drpContentField.SelectedValue; if (drpImageField.SelectedValue != "0") { dci.ClassSearchImageColumn = drpImageField.SelectedValue; } else { dci.ClassSearchImageColumn = DBNull.Value.ToString(); } dci.ClassSearchCreationDateColumn = drpDateField.SelectedValue; DataClassInfoProvider.SetDataClass(dci); RaiseOnSaved(); } // Display a message if (!string.IsNullOrEmpty(lblInfo.ResourceString) || !string.IsNullOrEmpty(lblInfo.Text)) { lblInfo.Visible = true; } if ((this.ClassFields.Changed) && (!String.IsNullOrEmpty(RebuildIndexResourceString))) { lblRebuildInfo.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { PageTitle.TitleText = GetString("customtable.data.viewitemtitle"); Page.Title = PageTitle.TitleText; // Get custom table id from url int customTableId = QueryHelper.GetInteger("customtableid", 0); // Get custom table item id int itemId = QueryHelper.GetInteger("itemid", 0); DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(customTableId); // Set edited object EditedObject = dci; if (dci == null) { return; } // Check 'Read' permission if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser)) { RedirectToAccessDenied("cms.customtables", "Read"); } CustomTableItem item = CustomTableItemProvider.GetItem(itemId, dci.ClassName); customTableViewItem.CustomTableItem = item; }
/// <summary> /// Gets the custom table item and moves it up. Called when the "Get and move item up" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool GetAndMoveCustomTableItemUp() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text'"; int topN = 1; string columns = "ItemID"; // Get the data set according to the parameters DataSet dataSet = customTableProvider.GetItems(customTableClassName, where, null, topN, columns); if (!DataHelper.DataSourceIsEmpty(dataSet)) { // Get the custom table item ID int itemID = ValidationHelper.GetInteger(dataSet.Tables[0].Rows[0][0], 0); // Move the item up customTableProvider.MoveItemUp(itemID, customTableClassName); return(true); } } return(false); }
protected void Page_Load(object sender, EventArgs e) { int customTableId = QueryHelper.GetInteger("customTableId", 0); if (customTableId > 0) { DataClassInfo classInfo = DataClassInfoProvider.GetDataClass(customTableId); // Set edited object SetEditedObject(classInfo, null); // If class exists if (classInfo != null) { // Initializes PageTitle InitBreadcrumbs(2); SetBreadcrumb(0, GetString("customtable.list.title"), ResolveUrl("~/CMSModules/CustomTables/CustomTable_List.aspx"), "_parent", null); SetBreadcrumb(1, classInfo.ClassDisplayName, null, null, null); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ShowContent", ScriptHelper.GetScript("function ShowContent(contentLocation) { parent.content.location.href = contentLocation; }")); // Initialize menu InitializeMenu(classInfo); } } }
/// <summary> /// Creates custom table item. Called when the "Create item" button is pressed. /// </summary> private bool CreateCustomTableItem() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); // Prepare the parameters string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Create new custom table item CustomTableItem newCustomTableItem = new CustomTableItem(customTableClassName, customTableProvider); // Set the ItemText field value newCustomTableItem.SetValue("ItemText", "New text"); // Insert the custom table item into database newCustomTableItem.Insert(); return(true); } return(false); }
/// <summary> /// Initializes CustomTable edit menu. /// </summary> protected void InitializeMenu(DataClassInfo classObj) { InitTabs("content"); SetTab(0, GetString("general.general"), "CustomTable_Edit_General.aspx?customtableid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'CustomTable_Edit_General');"); SetTab(1, GetString("general.fields"), "CustomTable_Edit_Fields.aspx?customtableid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'CustomTable_Edit_Fields');"); SetTab(2, GetString("general.form"), "CustomTable_Edit_Form.aspx?customtableid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'CustomTable_Edit_Form');"); SetTab(3, GetString("general.Transformations"), "CustomTable_Edit_Transformation_List.aspx?customtableid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'CustomTable_Edit_Transformation_List');"); SetTab(4, GetString("general.Queries"), "CustomTable_Edit_Query_List.aspx?customtableid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'CustomTable_Edit_Query_List');"); SetTab(5, GetString("general.sites"), "CustomTable_Edit_Sites.aspx?customtableid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'CustomTable_Edit_Sites');"); SetTab(6, GetString("customtable.header.altforms"), "AlternativeForms/AlternativeForms_List.aspx?classid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'alternative_forms');"); SetTab(7, GetString("srch.fields"), "CustomTable_Edit_SearchFields.aspx?classid=" + classObj.ClassID, "SetHelpTopic('helpTopic', 'CustomTable_Edit_SearchFields');"); string dataListPage = null; // If is specific (custom) list page defined, add query parameters for list page (table ID + site manager flag) if (!String.IsNullOrEmpty(classObj.ClassListPageURL)) { // Use specific list page dataListPage = URLHelper.AddParameterToUrl(classObj.ClassListPageURL.Trim(), "customtableid", classObj.ClassID.ToString()); dataListPage = URLHelper.AddParameterToUrl(dataListPage, "sm", "1"); } else { // Use default list page dataListPage = "Tools/CustomTable_Data_List.aspx?sm=1&customtableid=" + classObj.ClassID; } SetTab(8, GetString("customtable.header.data"), dataListPage, "SetHelpTopic('helpTopic', 'custom_tables_data');"); }
public async Task DeleteContentType(DataClassInfo contentType) { try { SyncLog.LogEvent(EventType.INFORMATION, "KenticoKontentPublishing", "DELETECONTENTTYPE", contentType.ClassDisplayName); var externalId = GetPageTypeExternalId(contentType.ClassGUID); var endpoint = $"/types/external-id/{HttpUtility.UrlEncode(externalId)}"; await ExecuteWithoutResponse(endpoint, HttpMethod.Delete); } catch (HttpException ex) { if (ex.GetHttpCode() == 404) { // May not be there yet, 404 is OK return; } throw; } catch (Exception ex) { SyncLog.LogException("KenticoKontentPublishing", "DELETECONTENTTYPE", ex); throw; } }
/// <summary> /// Loads form layout of document, systemtable or alternative form. /// </summary> private void LoadData() { if (DataClassID > 0) { if (!IsAlternative) { classInfo = DataClassInfoProvider.GetDataClassInfo(DataClassID); UIContext.EditedObject = classInfo; } else { altFormInfo = AlternativeFormInfoProvider.GetAlternativeFormInfo(ObjectID); UIContext.EditedObject = altFormInfo; } if (!RequestHelper.IsPostBack()) { LayoutTypeEnum layoutType = LayoutTypeEnum.Html; InitTypeSelector(); if (!IsAlternative) { if (classInfo != null) { // Load layout of document or systemtable FormLayout = classInfo.ClassFormLayout; layoutType = classInfo.ClassFormLayoutType; } } else { if (altFormInfo != null) { // Load layout of alternative form FormLayout = altFormInfo.FormLayout; layoutType = altFormInfo.FormLayoutType; } } radCustomLayout.Checked = LayoutIsSet; drpLayoutType.SelectedValue = layoutType.ToString(); // Switch visibility of layout editors based on layout type plcHTML.Visible = drpLayoutType.SelectedValue.EqualsCSafe(LayoutTypeEnum.Html.ToString(), StringComparison.InvariantCultureIgnoreCase); plcASCX.Visible = !plcHTML.Visible; } if (radCustomLayout.Checked) { InitDialog(); } radAutoLayout.Checked = !radCustomLayout.Checked; } else { UIContext.EditedObject = null; } }
protected void Page_Load(object sender, EventArgs e) { // Check license LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.ContactManagement); // Init header actions string[,] actions = new string[1, 11]; actions[0, 0] = HeaderActions.TYPE_SAVEBUTTON; actions[0, 1] = GetString("General.Save"); actions[0, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png"); actions[0, 6] = "save"; actions[0, 8] = "true"; CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; CurrentMaster.HeaderActions.Actions = actions; // Get data class info DataClassInfo classInfo = (DataClassInfo)EditedObject; if (classInfo == null) { return; } // Load mapping dialog control and initialize it plcMapping.Controls.Clear(); mapControl = (CMSUserControl)Page.LoadUserControl("~/CMSModules/ContactManagement/Controls/UI/Contact/MappingDialog.ascx"); if (mapControl != null) { mapControl.ID = "ctrlMapping"; mapControl.SetValue("classname", classInfo.ClassName); mapControl.SetValue("allowoverwrite", classInfo.ClassContactOverwriteEnabled); mapControl.IsLiveSite = false; plcMapping.Controls.Add(mapControl); } }
protected void btnOK_Click(object sender, EventArgs e) { dci = DataClassInfoProvider.GetDataClassInfo(docTypeId); if (dci != null) { // Set checkboxes dci.ClassIsProductSection = chkIsProductSection.Checked; dci.ClassIsProduct = chkIsProduct.Checked; if (dci.ClassIsProduct) { dci.ClassSKUDefaultDepartmentName = departmentElem.SelectedName; dci.ClassSKUDefaultProductType = (string)productTypeElem.Value; } try { // Save changes to database DataClassInfoProvider.SetDataClassInfo(dci); ShowChangesSaved(); } catch (Exception ex) { ShowError(ex.Message); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); btnSaveCode.Click += SaveCode; try { mDataClass = GetDataClassFromContext(); mFolderBasePath = String.Format("~/{0}/CMSClasses", SystemContext.IsWebApplicationProject ? "Old_App_Code" : "App_Code"); if (!RequestHelper.IsPostBack()) { if (ContentItemCodeGenerator.Internal.CanGenerateItemClass(mDataClass)) { txtItemCode.Text = ContentItemCodeGenerator.Internal.GenerateItemClass(mDataClass); } if (ContentItemCodeGenerator.Internal.CanGenerateItemProviderClass(mDataClass)) { txtProviderCode.Text = ContentItemCodeGenerator.Internal.GenerateItemProviderClass(mDataClass); } else { pnlGeneratedCode.CssClass = null; pnlItemCode.CssClass = null; pnlProviderCode.Visible = false; } ucSavePath.Value = mFolderBasePath; if (Directory.Exists(mFolderBasePath)) { ucSavePath.DefaultPath = mFolderBasePath; } } } catch (Exception exception) { CoreServices.EventLog.LogException("Content item code generator", "Initialize", exception); btnSaveCode.Enabled = false; var message = GetString("general.exception"); ShowError(message); } }
protected void Page_Load(object sender, EventArgs e) { int classId = QueryHelper.GetInteger("objectid", 0); dci = DataClassInfoProvider.GetDataClassInfo(classId); // Set edited object EditedObject = dci; CurrentMaster.BodyClass += " FieldEditorBody"; btnGenerateGuid = new HeaderAction { Tooltip = GetString("customtable.GenerateGUID"), Text = GetString("customtable.GenerateGUIDField"), Visible = false, CommandName = "createguid", OnClientClick = "return confirm(" + ScriptHelper.GetLocalizedString("customtable.generateguidconfirmation") + ");" }; FieldEditor.HeaderActions.AddAction(btnGenerateGuid); FieldEditor.HeaderActions.ActionPerformed += (s, ea) => { if (ea.CommandName == "createguid") CreateGUID(); }; // Class exists if (dci != null) { className = dci.ClassName; if (dci.ClassIsCoupledClass) { FieldEditor.Visible = true; FieldEditor.ClassName = className; FieldEditor.Mode = FieldEditorModeEnum.CustomTable; FieldEditor.OnFieldNameChanged += FieldEditor_OnFieldNameChanged; FieldEditor.OnAfterDefinitionUpdate += FieldEditor_OnAfterDefinitionUpdate; } else { FieldEditor.ShowError(GetString("customtable.ErrorNoFields")); } } ScriptHelper.HideVerticalTabs(this); }
protected void Page_Load(object sender, EventArgs e) { docTypeId = QueryHelper.GetInteger("objectid", 0); dci = DataClassInfoProvider.GetDataClassInfo(docTypeId); // Get class fields if (dci == null) { return; } var fi = FormHelper.GetFormInfo(dci.ClassName, false); fi.GetFields(true, true); if (!RequestHelper.IsPostBack()) { // Set checkboxes chkIsProduct.Checked = dci.ClassIsProduct; chkIsProductSection.Checked = dci.ClassIsProductSection; // Select specified department if (string.IsNullOrEmpty(dci.ClassSKUDefaultDepartmentName)) { departmentElem.SelectedID = dci.ClassSKUDefaultDepartmentID; } else { departmentElem.SelectedName = dci.ClassSKUDefaultDepartmentName; } // Select default product type productTypeElem.Value = dci.ClassSKUDefaultProductType; } pnlDefaultSelection.Visible = chkIsProduct.Checked; }
private string UpdateDependencies(DataClassInfo dci, TableManager tm, FormFieldInfo updatedFieldInfo, out bool updateInheritedForms) { updateInheritedForms = false; string error = null; if (dci != null) { // Update XML definition dci.ClassFormDefinition = FormDefinition; // When updating existing field if ((ffi != null) && (dci.ClassNodeNameSource == ffi.Name)) { // Update ClassNodeNameSource field dci.ClassNodeNameSource = updatedFieldInfo.Name; } bool isNotDummyOrField = (SelectedItemType != FieldEditorSelectedItemEnum.Field) || !updatedFieldInfo.IsDummyField; if (isNotDummyOrField) { // Update XML schema dci.ClassXmlSchema = tm.GetXmlSchema(dci.ClassTableName); } // Update changes in DB try { // Save the data class DataClassInfoProvider.SetDataClassInfo(dci); updateInheritedForms = true; } catch (Exception ex) { EventLogProvider.LogException("FieldEditor", "SAVE", ex); error = ex.Message; } if ((SelectedItemType == FieldEditorSelectedItemEnum.Field) && !updatedFieldInfo.IsDummyField) { // Generate default view SqlGenerator.GenerateDefaultView(dci, mMode == FieldEditorModeEnum.BizFormDefinition ? SiteContext.CurrentSiteName : null); QueryInfoProvider.ClearDefaultQueries(dci, true, true); } // Updates custom views if (isNotDummyOrField && ((mMode == FieldEditorModeEnum.SystemTable) || (mMode == FieldEditorModeEnum.ClassFormDefinition)) && IsDatabaseChangeRequired(ffi, updatedFieldInfo)) { error = RefreshViews(tm, dci); } } else { error = GetString("FieldEditor.ClassNotFound"); } return error; }
/// <summary> /// Initialize filter. /// </summary> public void Initialize() { if (!String.IsNullOrEmpty(SelectedValue)) { switch (FilterMode) { case SettingsObjectType.TRANSFORMATION: TransformationInfo ti = TransformationInfoProvider.GetTransformation(SelectedValue); if (ti != null) { mSelectedClass = DataClassInfoProvider.GetDataClass(ti.TransformationClassID); } break; case SettingsObjectType.QUERY: Query q = QueryProvider.GetQuery(SelectedValue, false); if (q != null) { mSelectedClass = DataClassInfoProvider.GetDataClass(q.QueryClassId); } break; } // If selected object is under custom class, change selected class type if (mSelectedClass != null) { if (mSelectedClass.ClassIsCustomTable) { lblDocType.Text = ResHelper.GetString("queryselection.customtable"); ListItem selectedItem = ControlsHelper.FindItemByValue(drpClassType, "customtables", false); // Select item which is already loaded in drop-down list if (selectedItem != null) { drpClassType.SelectedValue = selectedItem.Value; } } uniSelector.Value = mSelectedClass.ClassID; } } }
private string RefreshViews(TableManager tm, DataClassInfo dci) { string errorMessage = null; try { tm.RefreshCustomViews(dci.ClassTableName); if (dci.ClassName.EqualsCSafe("cms.document", StringComparison.InvariantCultureIgnoreCase) || dci.ClassName.EqualsCSafe("cms.tree", StringComparison.InvariantCultureIgnoreCase)) { tm.RefreshDocumentViews(); } } catch (Exception ex) { EventLogProvider.LogException("FieldEditor", "REFRESHVIEWS", ex); errorMessage = ResHelper.GetString("fieldeditor.refreshingviewsfailed"); } return errorMessage; }
private void RemoveFieldFromAlternativeForms(DataClassInfo formClassInfo) { string where = GetAlternativeFormsWhere(formClassInfo); // Update alternative forms var altforms = AlternativeFormInfoProvider.GetAlternativeForms(where, null); foreach (AlternativeFormInfo afi in altforms) { afi.FormDefinition = FormHelper.RemoveFieldFromAlternativeDefinition(afi.FormDefinition, SelectedItemName, lstAttributes.SelectedIndex); AlternativeFormInfoProvider.SetAlternativeFormInfo(afi); } }
/// <summary> /// Creates breadcrumbs /// </summary> /// <param name="siteManager">Indicates if used in SM</param> /// <param name="classInfo">Class info</param> /// <param name="listPage">List page URL</param> /// <param name="customTableId">Custom table ID</param> /// <param name="itemId">Item ID</param> private void CreateBreadcrumbs(bool siteManager, DataClassInfo classInfo, string listPage, int customTableId, int itemId) { // Initializes page title if (!siteManager) { PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem { Text = GetString("customtable.list.title"), RedirectUrl = "~/CMSModules/Customtables/Tools/CustomTable_List.aspx" }); } PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem { Text = classInfo.ClassDisplayName, RedirectUrl = listPage + "?objectid=" + customTableId + (siteManager ? "&sm=1" : String.Empty) }); PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem { Text = itemId > 0 ? GetString("customtable.data.Edititem") : GetString("customtable.data.NewItem") }); // Do not include type as breadcrumbs suffix UIHelper.SetBreadcrumbsSuffix(""); }
/// <summary> /// Initializes the custom table /// </summary> /// <param name="dci">DataClassInfo of the custom table</param> /// <param name="fi">Form info</param> /// <param name="tm">Table manager</param> private void InitCustomTable(DataClassInfo dci, FormInfo fi, TableManager tm) { // Created by if (chkItemCreatedBy.Checked && !fi.FieldExists("ItemCreatedBy")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = "ItemCreatedBy"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Created by"); ffi.DataType = FieldDataType.Integer; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = true; fi.AddFormItem(ffi); } // Created when if (chkItemCreatedWhen.Checked && !fi.FieldExists("ItemCreatedWhen")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = "ItemCreatedWhen"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Created when"); ffi.DataType = FieldDataType.DateTime; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = true; fi.AddFormItem(ffi); } // Modified by if (chkItemModifiedBy.Checked && !fi.FieldExists("ItemModifiedBy")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = "ItemModifiedBy"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Modified by"); ffi.DataType = FieldDataType.Integer; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = true; fi.AddFormItem(ffi); } // Modified when if (chkItemModifiedWhen.Checked && !fi.FieldExists("ItemModifiedWhen")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = "ItemModifiedWhen"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Modified when"); ffi.DataType = FieldDataType.DateTime; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = true; fi.AddFormItem(ffi); } // Item order if (chkItemOrder.Checked && !fi.FieldExists("ItemOrder")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = "ItemOrder"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Order"); ffi.DataType = FieldDataType.Integer; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = true; fi.AddFormItem(ffi); } // GUID if (chkItemGUID.Checked && !fi.FieldExists("ItemGUID")) { var ffiGuid = CreateGuidField(); fi.AddFormItem(ffiGuid); } // Update table structure - columns could be added bool old = TableManager.UpdateSystemFields; TableManager.UpdateSystemFields = true; string schema = fi.GetXmlDefinition(); tm.UpdateTableByDefinition(dci.ClassTableName, schema); TableManager.UpdateSystemFields = old; // Update xml schema and form definition dci.ClassFormDefinition = schema; dci.ClassXmlSchema = tm.GetXmlSchema(dci.ClassTableName); using (CMSActionContext context = new CMSActionContext()) { // Disable logging into event log context.LogEvents = false; DataClassInfoProvider.SetDataClassInfo(dci); } }
/// <summary> /// Updates DataClassInfo and modifies database accordingly. /// </summary> /// <param name="dci">DataClassInfo</param> /// <param name="fi">Form info</param> private void UpdateDataClass(DataClassInfo dci, FormInfo fi) { // Update definition dci.ClassFormDefinition = fi.GetXmlDefinition(); // Update database structure DataClassInfoProvider.EnsureDatabaseStructure(dci, true); DataClassInfoProvider.SetDataClassInfo(dci); }
protected void btnOK_Click(object sender, EventArgs e) { // Validate form string errorMessage = ValidateForm(); if (errorMessage == "") { dci = DataClassInfoProvider.GetDataClassInfo(docTypeId); if (dci != null) { // Set checkboxes dci.ClassCreateSKU = chkGenerateSKU.Checked; dci.ClassIsProductSection = chkIsProductSection.Checked; dci.ClassIsProduct = chkIsProduct.Checked; if (dci.ClassIsProduct) { #region "Set mappings" // Handle image path field SetValueFromDropDown("SKUImagePath", drpImage); // Handle name field SetValueFromDropDown("SKUName", drpName); // Handle weight field SetValueFromDropDown("SKUWeight", drpWeight); // Handle height field SetValueFromDropDown("SKUHeight", drpHeight); // Handle width field SetValueFromDropDown("SKUWidth", drpWidth); // Handle depth field SetValueFromDropDown("SKUDepth", drpDepth); // Handle price field SetValueFromDropDown("SKUPrice", drpPrice); // Handle description field SetValueFromDropDown("SKUShortDescription", drpShortDescription); // Handle description field SetValueFromDropDown("SKUDescription", drpDescription); // Handle custom properties fields foreach (RepeaterItem item in repCustomProperties.Items) { var field = CustomProperties[item.ItemIndex] as FormFieldInfo; if (field != null) { var drp = item.FindControl(field.Name) as CMSDropDownList; if (drp != null) { SetValueFromDropDown(field.Name, drp); } } } #endregion // Set document type product defaults dci.ClassSKUDefaultDepartmentName = departmentElem.SelectedName; dci.ClassSKUDefaultProductType = (string)productTypeElem.Value; } try { // Save changes to database DataClassInfoProvider.SetDataClassInfo(dci); ShowChangesSaved(); } catch (Exception ex) { errorMessage = ex.Message; } } } // Show error message if (errorMessage != "") { ShowError(errorMessage); } }
private bool DeleteCustomTableItem(DataClassInfo customTable) { try { if (customTable != null) { // Prepares the parameters string where = ""; // Gets the data DataSet customTableItems = _customTableProvider.GetItems(customTable.ClassName, where, null); if (!DataHelper.DataSourceIsEmpty(customTableItems)) { // Loops through the individual items foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows) { // Creates object from DataRow CustomTableItem deleteCustomTableItem = CustomTableItem.New(customTableItemDr, customTable.ClassName); // Deletes custom table item from database if (RadioButtonAll.Checked) deleteCustomTableItem.Delete(); } EventLogProvider.LogInformation("CustomTable", "Import delete", "Delete sucess"); return true; } } } catch (Exception e) { EventLogProvider.LogInformation("CustomTable", "Import delete error", e.Message); } return false; }
protected void Page_Load(object sender, EventArgs e) { // Get custom table id from url customTableId = QueryHelper.GetInteger("customtableid", 0); dci = DataClassInfoProvider.GetDataClassInfo(customTableId); // Set edited object EditedObject = dci; // If class exists and is custom table if ((dci != null) && dci.ClassIsCustomTable) { // Ensure that object belongs to current site or user has access to site manager if (!CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) && (dci.AssignedSites[SiteContext.CurrentSiteName] == null)) { RedirectToInformation(GetString("general.notassigned")); } PageTitle.TitleText = GetString("customtable.data.selectdisplayedfields"); CurrentMaster.DisplayActionsPanel = true; // Check 'Read' permission if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser)) { ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName)); plcContent.Visible = false; return; } HeaderActions.AddAction(new HeaderAction { Text = GetString("UniSelector.SelectAll"), OnClientClick = "ChangeFields(true); return false;", ButtonStyle = ButtonStyle.Default, }); HeaderActions.AddAction(new HeaderAction { Text = GetString("UniSelector.DeselectAll"), OnClientClick = "ChangeFields(false); return false;", ButtonStyle = ButtonStyle.Default, }); if (!RequestHelper.IsPostBack()) { Hashtable reportFields = new Hashtable(); // Get report fields if (!String.IsNullOrEmpty(dci.ClassShowColumns)) { reportFields.Clear(); foreach (string field in dci.ClassShowColumns.Split(';')) { // Add field key to hastable reportFields[field] = null; } } // Get columns names FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, false); var columnNames = fi.GetColumnNames(false); if (columnNames != null) { MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + dci.ClassName); FormFieldInfo ffi; ListItem item; foreach (string name in columnNames) { ffi = fi.GetFormField(name); // Add checkboxes to the list item = new ListItem(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(GetFieldCaption(ffi, name, resolver))), name); if (reportFields.Contains(name)) { // Select checkbox if field is reported item.Selected = true; } chkListFields.Items.Add(item); } } } } else { ShowError(GetString("customtable.notcustomtable")); CurrentMaster.FooterContainer.Visible = false; } }
private Boolean CreateCustomTableItem(DataClassInfo customTable,DataRow dr) { if (customTable != null) { // Creates new custom table item CustomTableItem newCustomTableItem = CustomTableItem.New(customTable.ClassName, _customTableProvider); // Sets the ItemText field value try { if (_customTable == null) _customTable = (Session["_customTable"] != null ? (DataSet)Session["_customTable"] : null); int i = 0; if (_customTable!=null) { foreach (DataColumn column in _customTable.Tables[0].Columns) { if (column.ColumnName.LastIndexOf("Item") == -1) { string temp=""; object aaa=default_value(column.ColumnName,out temp); aaa = (aaa != null ? aaa : null); if (aaa != null) { object vl=null; /* if (default_value_int(column.ColumnName)) { vl = double_parse(dr[aaa.ToString()].ToString().Trim().Replace("$", "").Replace(",", "")); } else { if (column.ColumnName == "Views") vl = int_parse(dr[aaa.ToString()].ToString().Trim()); else if (column.ColumnName == "Featured") vl = bool_parse(dr[aaa.ToString()].ToString().Trim()); else if (column.ColumnName == "Model") vl = dr[aaa.ToString()].ToString().Trim().Split('"')[0]; else vl = dr[aaa.ToString()].ToString().Trim(); } */ try { vl = type_field(dr[aaa.ToString()].ToString()); if(vl!=null) newCustomTableItem.SetValue(column.ColumnName, vl); } catch (Exception exx) { Literal1.Text += "<p>- Column " + temp + " error:" + exx.Message + "</p>"; } } } } newCustomTableItem.Insert(); return true; } } catch (Exception e) { Literal1.Text += e.Message + "<br>"; return false; } } return false; }
protected void Page_Load(object sender, EventArgs e) { CurrentMaster.Title.TitleText = GetString("customtable.data.selectdisplayedfields"); CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_CustomTables/selectfields.png"); CurrentMaster.DisplayActionsPanel = true; // Get custom table id from url customTableId = QueryHelper.GetInteger("customtableid", 0); dci = DataClassInfoProvider.GetDataClass(customTableId); // Set edited object EditedObject = dci; // If class exists if (dci != null) { // Check 'Read' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.customtables", "Read") && !CMSContext.CurrentUser.IsAuthorizedPerClassName(dci.ClassName, "Read")) { lblError.Visible = true; lblError.Text = String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName); plcContent.Visible = false; return; } btnSelectAll.Text = GetString("UniSelector.SelectAll"); btnUnSelectAll.Text = GetString("UniSelector.DeselectAll"); Hashtable reportFields = new Hashtable(); FormInfo fi = null; if (!RequestHelper.IsPostBack()) { btnOk.Text = GetString("General.OK"); btnCancel.Text = GetString("General.Cancel"); // Get report fields if (!String.IsNullOrEmpty(dci.ClassShowColumns)) { reportFields.Clear(); foreach (string field in dci.ClassShowColumns.Split(';')) { // Add field key to hastable reportFields[field] = null; } } // Get columns names fi = FormHelper.GetFormInfo(dci.ClassName, false); string[] columnNames = fi.GetColumnNames(); if (columnNames != null) { foreach (string name in columnNames) { FormFieldInfo ffi = fi.GetFormField(name); // Add checkboxes to the list ListItem item = new ListItem(ResHelper.LocalizeString(GetFieldCaption(ffi, name)), name); if (reportFields.Contains(name)) { // Select checkbox if field is reported item.Selected = true; } chkListFields.Items.Add(item); } } } } }
/// <summary> /// Initializes class. /// </summary> /// <param name="dci">DataClassInfo</param> /// <param name="fi">Form info</param> private void InitClass(DataClassInfo dci, FormInfo fi) { // Get class code name var pkName = txtPKName.Text.Trim(); var codeName = pkName.Substring(0, pkName.Length - 2); // Guid if (chkClassGuid.Checked && !fi.FieldExists(codeName + "Guid")) { fi.AddFormItem(CreateGuidField(codeName + "Guid")); } // Last modified if (chkClassLastModified.Checked && !fi.FieldExists(codeName + "LastModified")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = codeName + "LastModified"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Last modified"); ffi.DataType = FieldDataType.DateTime; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, String.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, String.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = false; fi.AddFormItem(ffi); } UpdateDataClass(dci, fi); }
protected void Page_Load(object sender, EventArgs e) { // Check 'ReadData' permission CheckPermissions("ReadData"); // Register scripts ScriptHelper.RegisterDialogScript(Page); if (mShowSelectFieldsButton) { ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" + ResolveUrl("~/CMSModules/BizForms/Tools/BizForm_Edit_Data_SelectFields.aspx") + "?formid=" + formId + "' ,'BizFormFields', 500, 500); }")); } ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "Edit", ScriptHelper.GetScript( "function EditRecord(formId, recordId) { " + " document.location.replace('" + ResolveUrl("~/CMSModules/BizForms/Tools/BizForm_Edit_EditRecord.aspx") + "?formID=' + formId + '&formRecordID=' + recordId); } ")); // Initialize unigrid gridData.OnExternalDataBound += gridData_OnExternalDataBound; gridData.OnLoadColumns += gridData_OnLoadColumns; gridData.OnAction += gridData_OnAction; if (bfi != null) { dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID); if (dci != null) { className = dci.ClassName; // Set alternative form and data container gridData.ObjectType = BizFormItemProvider.GetObjectType(className); gridData.FilterFormName = className + "." + "filter"; gridData.FilterFormData = bfi; // Get primary column name gridData.OrderBy = primaryColumn = GetPrimaryColumn(FormInfo, bfi.FormName); } } }
/// <summary> /// Saves form layout. /// </summary> protected bool SaveData() { if (!IsAuthorizedForAscxEditing()) { ShowError(GetString("EditCode.NotAllowed")); return false; } bool saved = false; bool deleted = false; // Get form layout string layout = FormLayout; // Delete layout if editor is hidden if (!CustomLayoutEnabled) { deleted = LayoutIsSet; layout = null; } if (DataClassID > 0) { if (!IsAlternative) { classInfo = DataClassInfoProvider.GetDataClassInfo(DataClassID); UIContext.EditedObject = classInfo; if (classInfo != null) { // Update dataclass form layout and save object classInfo.ClassFormLayout = layout; classInfo.ClassFormLayoutType = LayoutHelper.GetLayoutTypeEnum(drpLayoutType.SelectedValue); DataClassInfoProvider.SetDataClassInfo(classInfo); saved = true; } } else { altFormInfo = AlternativeFormInfoProvider.GetAlternativeFormInfo(ObjectID); UIContext.EditedObject = altFormInfo; if (altFormInfo != null) { // Update alternative form layout and save object altFormInfo.FormLayout = layout; altFormInfo.FormLayoutType = LayoutHelper.GetLayoutTypeEnum(drpLayoutType.SelectedValue); AlternativeFormInfoProvider.SetAlternativeFormInfo(altFormInfo); saved = true; } } // Display info if successfully saved if (saved) { if (!deleted) { ShowChangesSaved(); } else { ShowConfirmation(GetString("DocumentType_Edit_Form.LayoutDeleted")); } } } else { UIContext.EditedObject = null; } return true; }
protected void Page_Load(object sender, EventArgs e) { // Register script files ScriptHelper.RegisterScriptFile(this, @"~/CMSModules/Content/CMSDesk/ContentEditFrameset.js"); bool checkCulture = false; bool splitViewSupported = false; nodeId = QueryHelper.GetInteger("nodeid", 0); string action = QueryHelper.GetString("action", "edit").ToLowerCSafe(); switch (action) { // New dialog / new page form case "new": int classId = QueryHelper.GetInteger("classid", 0); if (classId <= 0) { // Get by class name if specified string className = QueryHelper.GetString("classname", string.Empty); if (className != string.Empty) { classInfo = DataClassInfoProvider.GetDataClass(className); if (classInfo != null) { classId = classInfo.ClassID; } } } nodeId = QueryHelper.GetInteger("parentnodeid", 0); if (classId > 0) { viewpage = ResolveUrl("~/CMSModules/Content/CMSDesk/Edit/Edit.aspx"); // Check if document type is allowed under parent node if (nodeId > 0) { // Get the node TreeNode = Tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); if (TreeNode != null) { if (!DataClassInfoProvider.IsChildClassAllowed(ValidationHelper.GetInteger(TreeNode.GetValue("NodeClassID"), 0), classId)) { viewpage = "~/CMSModules/Content/CMSDesk/NotAllowed.aspx?action=child"; } } } // Use product page when product type is selected classInfo = classInfo ?? DataClassInfoProvider.GetDataClass(classId); if ((classInfo != null) && (classInfo.ClassIsProduct)) { viewpage = ResolveUrl("~/CMSModules/Ecommerce/Pages/Tools/Products/Product_New.aspx"); } } else { if (nodeId > 0) { viewpage = "~/CMSModules/Ecommerce/Pages/Tools/Products/New_ProductOrSection.aspx"; } else { viewpage = "~/CMSModules/Ecommerce/Pages/Tools/Products/Product_New.aspx?parentNodeId=0"; } } break; case "delete": // Delete dialog viewpage = "~/CMSModules/Content/CMSDesk/Delete.aspx"; break; default: // Edit mode viewpage = "~/CMSModules/Content/CMSDesk/Edit/edit.aspx?mode=editform"; splitViewSupported = true; // Ensure class info if ((classInfo == null) && (Node != null)) { classInfo = DataClassInfoProvider.GetDataClass(Node.NodeClassName); } // Check explicit editing page url if ((classInfo != null) && !string.IsNullOrEmpty(classInfo.ClassEditingPageURL)) { viewpage = URLHelper.AppendQuery(ResolveUrl(classInfo.ClassEditingPageURL), URLHelper.Url.Query); } checkCulture = true; break; } // If culture version should be checked, check if (checkCulture) { // Check (and ensure) the proper content culture CheckPreferredCulture(true); // Check split mode bool isSplitMode = CMSContext.DisplaySplitMode; bool combineWithDefaultCulture = !isSplitMode && SiteInfoProvider.CombineWithDefaultCulture(CMSContext.CurrentSiteName); TreeNode = Tree.SelectSingleNode(nodeId, CultureCode, combineWithDefaultCulture); if (TreeNode == null) { // Document does not exist -> redirect to new culture version creation dialog viewpage = "~/CMSModules/Content/CMSDesk/New/NewCultureVersion.aspx"; } } // Apply the additional transformations to the view page URL viewpage = URLHelper.AppendQuery(viewpage, URLHelper.Url.Query); viewpage = URLHelper.RemoveParameterFromUrl(viewpage, "mode"); viewpage = URLHelper.AddParameterToUrl(viewpage, "mode", "productssection"); viewpage = ResolveUrl(viewpage); viewpage = URLHelper.AddParameterToUrl(viewpage, "hash", QueryHelper.GetHash(viewpage)); // Split mode enabled if (splitViewSupported && CMSContext.DisplaySplitMode && (TreeNode != null) && (action == "edit" || action == "preview" || (TreeNode.IsPublished && action == "livesite"))) { viewpage = GetSplitViewUrl(viewpage); } }
/// <summary> /// Updates the inherited class fields if the class is inherited /// </summary> /// <param name="dci">DataClassInfo to update</param> private static void UpdateInheritedClass(DataClassInfo dci) { // Ensure inherited fields if (dci.ClassInheritsFromClassID > 0) { var parentCi = DataClassInfoProvider.GetDataClassInfo(dci.ClassInheritsFromClassID); if (parentCi != null) { FormHelper.UpdateInheritedClass(parentCi, dci); } } }
protected void Page_Load(object sender, EventArgs e) { int classId = QueryHelper.GetInteger("customtableid", 0); dci = DataClassInfoProvider.GetDataClass(classId); // Set edited object EditedObject = dci; CurrentMaster.BodyClass += " FieldEditorBody"; // Class exists if (dci != null) { className = dci.ClassName; if (dci.ClassIsCoupledClass) { FieldEditor.Visible = true; FieldEditor.ClassName = className; FieldEditor.Mode = FieldEditorModeEnum.CustomTable; FieldEditor.OnFieldNameChanged += FieldEditor_OnFieldNameChanged; btnGUID.Text = GetString("customtable.GenerateGUID"); btnGUID.Click += btnGUID_Click; } else { lblError.Text = GetString("customtable.ErrorNoFields"); } } }
/// <summary> /// Initializes the custom table /// </summary> /// <param name="dci">DataClassInfo of the custom table</param> /// <param name="fi">Form info</param> private void InitCustomTable(DataClassInfo dci, FormInfo fi) { // Created by if (chkItemCreatedBy.Checked && !fi.FieldExists("ItemCreatedBy")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = "ItemCreatedBy"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Created by"); ffi.DataType = FieldDataType.Integer; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = true; fi.AddFormItem(ffi); } // Created when if (chkItemCreatedWhen.Checked && !fi.FieldExists("ItemCreatedWhen")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = "ItemCreatedWhen"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Created when"); ffi.DataType = FieldDataType.DateTime; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = true; fi.AddFormItem(ffi); } // Modified by if (chkItemModifiedBy.Checked && !fi.FieldExists("ItemModifiedBy")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = "ItemModifiedBy"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Modified by"); ffi.DataType = FieldDataType.Integer; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = true; fi.AddFormItem(ffi); } // Modified when if (chkItemModifiedWhen.Checked && !fi.FieldExists("ItemModifiedWhen")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = "ItemModifiedWhen"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Modified when"); ffi.DataType = FieldDataType.DateTime; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = true; fi.AddFormItem(ffi); } // Item order if (chkItemOrder.Checked && !fi.FieldExists("ItemOrder")) { FormFieldInfo ffi = new FormFieldInfo(); // Fill FormInfo object ffi.Name = "ItemOrder"; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Order"); ffi.DataType = FieldDataType.Integer; ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty); ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty); ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe(); ffi.PrimaryKey = false; ffi.System = true; ffi.Visible = false; ffi.Size = 0; ffi.AllowEmpty = true; fi.AddFormItem(ffi); } // GUID if (chkItemGUID.Checked && !fi.FieldExists("ItemGUID")) { fi.AddFormItem(CreateGuidField("ItemGUID")); } UpdateDataClass(dci, fi); }
protected void Page_Load(object sender, EventArgs e) { // Check 'ReadForm' and 'EditData' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm")) { RedirectToCMSDeskAccessDenied("cms.form", "ReadForm"); } currentUser = CMSContext.CurrentUser; // get form id from url formId = QueryHelper.GetInteger("formid", 0); BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId); EditedObject = bfi; if (bfi != null) { imgSave.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png"); mSave = GetString("general.save"); AttachmentTitle.TitleText = GetString("general.attachments"); // Control initialization ltlConfirmDelete.Text = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("Bizform_Edit_Autoresponder.ConfirmDelete") + "\">"; drpEmailField.SelectedIndexChanged += new EventHandler(drpEmailField_SelectedIndexChanged); // Init attachment storage AttachmentList.SiteID = CMSContext.CurrentSiteID; AttachmentList.AllowPasteAttachments = true; AttachmentList.ObjectID = bfi.FormID; AttachmentList.ObjectType = FormObjectType.BIZFORM; AttachmentList.Category = MetaFileInfoProvider.OBJECT_CATEGORY_FORM_LAYOUT; // Initialize HTML editor InitHTMLEditor(); if (!RequestHelper.IsPostBack()) { // Get bizform class object formClassObj = DataClassInfoProvider.GetDataClass(bfi.FormClassID); if (formClassObj != null) { // Enable or disable form EnableDisableForm(bfi.FormConfirmationTemplate); // Fill list of available fields FillFieldsList(); // Load dropdownlist with form text fields FormInfo fi = FormHelper.GetFormInfo(formClassObj.ClassName, false); drpEmailField.DataSource = fi.GetFields(FormFieldDataTypeEnum.Text); drpEmailField.DataBind(); drpEmailField.Items.Insert(0, new ListItem(GetString("bizform_edit_autoresponder.emptyemailfield"), "")); // Try to select specified field ListItem li = drpEmailField.Items.FindByValue(bfi.FormConfirmationEmailField); if (li != null) { li.Selected = true; } // Load email subject and emailfrom address txtEmailFrom.Text = bfi.FormConfirmationSendFromEmail; txtEmailSubject.Text = bfi.FormConfirmationEmailSubject; } else { // Disable form by default EnableDisableForm(null); } } } }
/// <summary> /// Loads form layout of document, bizform, systemtable or alternative form. /// </summary> protected void LoadData() { if (DataClassID > 0) { if (!IsAlternative) { classInfo = DataClassInfoProvider.GetDataClassInfo(DataClassID); UIContext.EditedObject = classInfo; } else { altFormInfo = AlternativeFormInfoProvider.GetAlternativeFormInfo(ObjectID); UIContext.EditedObject = altFormInfo; } if (!RequestHelper.IsPostBack()) { LayoutTypeEnum layoutType = LayoutTypeEnum.Html; InitTypeSelector(); if (!IsAlternative) { if (classInfo != null) { // Load layout of document, bizform or systemtable FormLayout = classInfo.ClassFormLayout; layoutType = classInfo.ClassFormLayoutType; } } else { if (altFormInfo != null) { // Load layout of alternative form FormLayout = altFormInfo.FormLayout; layoutType = altFormInfo.FormLayoutType; } } radCustomLayout.Checked = LayoutIsSet; drpLayoutType.SelectedValue = layoutType.ToString(); // Switch visibility of layout editors based on layout type plcHTML.Visible = drpLayoutType.SelectedValue.EqualsCSafe(LayoutTypeEnum.Html.ToString(), StringComparison.InvariantCultureIgnoreCase); plcASCX.Visible = !plcHTML.Visible; } if (radCustomLayout.Checked) { InitDialog(); } radAutoLayout.Checked = !radCustomLayout.Checked; } else { UIContext.EditedObject = null; } }