private void LoadControlType() { this.UseCache = false; if (this.ItemVersionId == -1) { this.BindItemData(true); } else { this.BindItemData(); } // Item Edit this.itemEditControl = (ItemEdit)this.LoadControl(ItemControlToLoad); this.itemEditControl.ModuleConfiguration = this.ModuleConfiguration; this.itemEditControl.ID = Path.GetFileNameWithoutExtension(ItemControlToLoad); this.itemEditControl.VersionInfoObject = this.VersionInfoObject; this.phItemEdit.Controls.Add(this.itemEditControl); if (SecurityFilter.IsSecurityEnabled(this.PortalId)) { this.trCategoryPermissions.Visible = true; this.categoryPermissions = (CategoryPermissions)this.LoadControl("../CategoryControls/CategoryPermissions.ascx"); this.categoryPermissions.CategoryId = this.VersionInfoObject.ItemId; this.categoryPermissions.ModuleConfiguration = this.ModuleConfiguration; this.phCategoryPermissions.Controls.Add(this.categoryPermissions); } // Parent Category this.parentCategoryRelationships = (ItemRelationships)this.LoadControl("../controls/ItemRelationships.ascx"); this.parentCategoryRelationships.ExcludeCircularRelationships = true; this.parentCategoryRelationships.ModuleConfiguration = this.ModuleConfiguration; this.parentCategoryRelationships.LocalResourceFile = this.ItemRelationshipResourceFile; this.parentCategoryRelationships.VersionInfoObject = this.VersionInfoObject; this.parentCategoryRelationships.ListRelationshipTypeId = RelationshipType.ItemToParentCategory.GetId(); this.parentCategoryRelationships.CreateRelationshipTypeId = RelationshipType.ItemToParentCategory.GetId(); this.parentCategoryRelationships.AvailableSelectionMode = ListSelectionMode.Single; this.parentCategoryRelationships.FlatView = true; this.parentCategoryRelationships.ItemTypeId = ItemType.Category.GetId(); this.phParentCategory.Controls.Add(this.parentCategoryRelationships); // Related Categories // this.irRelated = (ItemRelationships)LoadControl("../controls/ItemRelationships.ascx"); // this.irRelated.ModuleConfiguration = ModuleConfiguration; // this.irRelated.LocalResourceFile = ItemRelationshipResourceFile; // this.irRelated.VersionInfoObject = VersionInfoObject; // this.irRelated.ListRelationshipTypeId = RelationshipType.ItemToRelatedCategory.GetId(); // this.irRelated.CreateRelationshipTypeId = RelationshipType.ItemToRelatedCategory.GetId(); // this.irRelated.AvailableSelectionMode = ListSelectionMode.Multiple; // this.irRelated.FlatView = true; // this.irRelated.ItemTypeId = ItemType.Category.GetId(); // this.phParentCategory.Controls.Add(this.irRelated); // Featured Articles this.featuredArticlesRelationships = (ItemRelationships)this.LoadControl("../controls/ItemRelationships.ascx"); this.featuredArticlesRelationships.ModuleConfiguration = this.ModuleConfiguration; this.featuredArticlesRelationships.VersionInfoObject = this.VersionInfoObject; this.featuredArticlesRelationships.LocalResourceFile = this.ItemRelationshipResourceFile; this.featuredArticlesRelationships.ListRelationshipTypeId = RelationshipType.ItemToParentCategory.GetId(); this.featuredArticlesRelationships.CreateRelationshipTypeId = RelationshipType.ItemToFeaturedItem.GetId(); this.featuredArticlesRelationships.AvailableSelectionMode = ListSelectionMode.Multiple; this.featuredArticlesRelationships.FlatView = true; this.featuredArticlesRelationships.EnableDates = true; this.featuredArticlesRelationships.AllowSearch = true; this.featuredArticlesRelationships.EnableSortOrder = true; this.featuredArticlesRelationships.ItemTypeId = ItemType.Article.GetId(); this.phFeaturedArticles.Controls.Add(this.featuredArticlesRelationships); // load approval status this.itemApprovalStatus = (ItemApproval)this.LoadControl(ApprovalControlToLoad); this.itemApprovalStatus.ModuleConfiguration = this.ModuleConfiguration; this.itemApprovalStatus.ID = Path.GetFileNameWithoutExtension(ApprovalControlToLoad); this.itemApprovalStatus.VersionInfoObject = this.VersionInfoObject; this.phApproval.Controls.Add(this.itemApprovalStatus); }
private void CmdUpdateClick(object sender, EventArgs e) { try { this.txtMessage.Text = string.Empty; bool error = false; // create a relationship var irel = new ItemRelationship { RelationshipTypeId = RelationshipType.ItemToParentCategory.GetId() }; int[] ids = this.parentCategoryRelationships.GetSelectedItemIds(); // check for parent category, if none then add a relationship for Top Level Item if (ids.Length == 0) { // add relationship to TLC irel.RelationshipTypeId = RelationshipType.CategoryToTopLevelCategory.GetId(); irel.ParentItemId = TopLevelCategoryItemType.Category.GetId(); this.VersionInfoObject.Relationships.Add(irel); } else { irel.ParentItemId = ids[0]; this.VersionInfoObject.Relationships.Add(irel); } // check for parent category, if none then add a relationship for Top Level Item // foreach (int i in this.irRelated.GetSelectedItemIds()) // { // ItemRelationship irco = ItemRelationship.Create(); // irco.RelationshipTypeId = RelationshipType.ItemToRelatedCategory.GetId(); // irco.ParentItemId = i; // VersionInfoObject.Relationships.Add(irco); // } if (this.itemEditControl.IsValid == false) { error = true; this.txtMessage.Text += this.itemEditControl.ErrorMessage; } if (Convert.ToInt32(this.ddlDisplayTabId.SelectedValue, CultureInfo.InvariantCulture) < -1) { error = true; this.txtMessage.Text += Localization.GetString("ChooseAPage", this.LocalResourceFile); } if (Convert.ToInt32(this.ddlChildDisplayTabId.SelectedValue, CultureInfo.InvariantCulture) == -1) { error = true; this.txtMessage.Text += Localization.GetString("ChooseChildPage", this.LocalResourceFile); } if (!this.itemApprovalStatus.IsValid) { this.txtMessage.Text += Localization.GetString("ChooseApprovalStatus", this.LocalResourceFile); } if (error) { this.txtMessage.Visible = true; return; } this.VersionInfoObject.Description = this.itemEditControl.DescriptionText; // auto populate the meta description if it's not populated already if (!Engage.Utility.HasValue(this.VersionInfoObject.MetaDescription)) { string description = HtmlUtils.StripTags(this.VersionInfoObject.Description, false); this.VersionInfoObject.MetaDescription = Utility.TrimDescription(399, description); } if (this.VersionInfoObject.IsNew) { this.VersionInfoObject.ModuleId = this.ModuleId; } int sortCount = 0; foreach (int i in this.featuredArticlesRelationships.GetSelectedItemIds()) { var irArticleso = new ItemRelationship { RelationshipTypeId = RelationshipType.ItemToFeaturedItem.GetId(), ParentItemId = i }; if ( Engage.Utility.HasValue(this.featuredArticlesRelationships.GetAdditionalSetting("startDate", i.ToString(CultureInfo.InvariantCulture)))) { irArticleso.StartDate = this.featuredArticlesRelationships.GetAdditionalSetting( "startDate", i.ToString(CultureInfo.InvariantCulture)); } if (Engage.Utility.HasValue(this.featuredArticlesRelationships.GetAdditionalSetting("endDate", i.ToString(CultureInfo.InvariantCulture)))) { irArticleso.EndDate = this.featuredArticlesRelationships.GetAdditionalSetting( "endDate", i.ToString(CultureInfo.InvariantCulture)); } irArticleso.SortOrder = sortCount; sortCount++; this.VersionInfoObject.Relationships.Add(irArticleso); } this.SaveSettings(); // approval status if (this.chkUseApprovals.Checked && this.UseApprovals) { this.VersionInfoObject.ApprovalStatusId = this.itemApprovalStatus.ApprovalStatusId; } else { this.VersionInfoObject.ApprovalStatusId = ApprovalStatus.Approved.GetId(); } this.VersionInfoObject.Save(this.UserId); if (SecurityFilter.IsSecurityEnabled(this.PortalId)) { this.categoryPermissions.CategoryId = this.VersionInfoObject.ItemId; this.categoryPermissions.Save(); } if (this.chkResetChildDisplayTabs.Checked) { ((Category)this.VersionInfoObject).CascadeChildDisplayTab(this.UserId); } string returnUrl = this.Server.UrlDecode(this.Request.QueryString["returnUrl"]); if (!Engage.Utility.HasValue(returnUrl)) { this.Response.Redirect( Globals.NavigateURL( this.TabId, string.Empty, string.Empty, "ctl=" + Utility.AdminContainer, "mid=" + this.ModuleId, "adminType=itemCreated", "itemId=" + this.VersionInfoObject.ItemId), true); } else { this.Response.Redirect(returnUrl); } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }