private void BindData() { // TODO: NLevels number of items is not currently used // TODO: figure out how to get the treeview to use the sorted datatable // Removed caching because heirarchy lost great-grandchildren and lower after coming back out of the cache var root = ItemRelationship.GetAllChildrenNLevels(this.ItemId, this.numberOfLevels, -1, this.PortalId); // GetAllChildrenNLevels gives back a tree with two root nodes, we only need one root = root.FirstNode; // add the parent category to the list first. if (this.showParentItem) { Category parentItem = Category.GetCategory(this.ItemId, this.PortalId); if (parentItem != null) { var parentItemNode = new TreeNode(parentItem.Name) { Tag = parentItem.ItemId }; foreach (TreeNode node in root.Nodes) { parentItemNode.Nodes.Add(node); } root = new TreeNode(); root.Nodes.Add(parentItemNode); } } this.FillNLevelList(root, this.phNLevels); }
private void LoadDefaultTextHtmlCategoryDropDown() { ItemRelationship.DisplayCategoryHierarchy(this.ddlDefaultTextHtmlCategory, -1, this.PortalId, false); var li = new ListItem(Localization.GetString("ChooseOne", this.LocalSharedResourceFile), "-1"); this.ddlDefaultTextHtmlCategory.Items.Insert(0, li); }
// protected void rlCategorySort_Reorder(object sender, EventArgs e) /* * private void UpdateDataTable(DataTable dt) * { * DataTable newTable = dt.Clone(); * * foreach (ReorderListItem rli in rlCategorySort.Items) * { * Label lblRelationshipId = (Label)rli.FindControl("lblItemRelationshipId"); * int itemrelationshipid = Convert.ToInt32(lblRelationshipId.Text); * foreach (DataRow dr in dt.Rows) * { * if (Convert.ToInt32(dr["ItemRelationshipId"]) == itemrelationshipid) * { * dr["SortOrder"] = rli.ItemIndex; * } * } * } * * } */ protected void lbSaveSort_Click(object sender, EventArgs e) { this._sortItems = this.Session[SortList] as List <ItemRelationshipSort>; this._unsortedItems = this.Session[UnSortedList] as List <ItemRelationshipSort>; if (this._sortItems != null) { foreach (ItemRelationshipSort irs in this._sortItems) { // int itemRelationshipId, sortorder = 0; ItemRelationship.UpdateItemRelationship(irs.ItemRelationshipId, this._sortItems.IndexOf(irs) + 1); } } // modify the sort order of any items we've removed from the SortList if (this._unsortedItems != null) { foreach (ItemRelationshipSort irs in this._unsortedItems) { // int itemRelationshipId, sortorder = 0; ItemRelationship.UpdateItemRelationship(irs.ItemRelationshipId, 0); } } this.Session.Remove(SortList); this.Session.Remove(UnSortedList); this.lblMessage.Visible = true; this.lblMessage.Text = Localization.GetString("SaveSuccess", this.LocalResourceFile); this.pnlSortList.Visible = false; if (this._windowClose) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "close window", "window.close();", true); } }
private void FillDropDown() { ItemRelationship.DisplayCategoryHierarchy(this.cboCategories, -1, this.PortalId, false); var li = new ListItem(Localization.GetString("ChooseOne", this.LocalResourceFile), "-1"); this.cboCategories.Items.Insert(0, li); li = this.cboCategories.Items.FindByValue(this.CategoryId.ToString(CultureInfo.InvariantCulture)); if (li != null) { li.Selected = true; } this.cboWorkflow.Visible = this.UseApprovals; this.lblWorkflow.Visible = this.UseApprovals; if (this.UseApprovals) { this.cboWorkflow.DataSource = DataProvider.Instance().GetApprovalStatusTypes(this.PortalId); this.cboWorkflow.DataValueField = "ApprovalStatusID"; this.cboWorkflow.DataTextField = "ApprovalStatusName"; this.cboWorkflow.DataBind(); li = this.cboWorkflow.Items.FindByText(ApprovalStatus.Waiting.Name); if (li != null) { li.Selected = true; } } }
private void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int id = CategoryId; ItemRelationship.DisplayCategoryHierarchy(ddlCategoryList, id, PortalId, true); if (id == -1) { ddlCategoryList.Items.Insert(0, new ListItem(Localization.GetString("AllCategories", LocalResourceFile), "-1")); } divSearchCategorySelection.Visible = ShowCategorySelection() && ddlCategoryList.Items.Count > 1; if (String.IsNullOrEmpty(txtCategorySearch.Text)) { txtCategorySearch.Text = Localization.GetString("txtCategorySearch", LocalResourceFile); } string searchValue = Request.QueryString["search"]; if (!string.IsNullOrEmpty(searchValue)) { divSearchResults.Visible = true; txtCategorySearch.Text = searchValue; BindData(); } } }
public void UpdateAvailableItems() { //am I looking for children or items if (!_allowSearch) { if (_flatView && _allowSearch) { //get all item types //this._itemTypeId lstItems.DataSource = Item.GetItems(_itemTypeId, PortalId); lstItems.DataTextField = "listName"; lstItems.DataValueField = "itemId"; DataBind(); ListItem li = lstItems.Items.FindByValue(ItemId.ToString(CultureInfo.InvariantCulture)); lstItems.Items.Remove(li); } else { lstItems.Items.Clear(); var ir = new ItemRelationship { ParentItemId = _parentItemId, ItemTypeId = _itemTypeId, RelationshipTypeId = _listRelationshipTypeId }; ir.DisplayChildren(lstItems, PortalId, ExcludeCircularRelationships ? VersionInfoObject.ItemId : (int?)null); } } //look for children }
public void BuildRelationships(bool exportAll) { XmlNode publishNode = this._doc.SelectSingleNode("publish"); XmlNode relationshipsNode = this._doc.CreateElement("relationships"); List <ItemRelationship> relationships = exportAll ? ItemRelationship.GetAllRelationshipsByPortalId(this._portalId) : ItemRelationship.GetAllRelationships(this._moduleId); foreach (ItemRelationship relationship in relationships) { relationship.CorrectDates(); string xml = relationship.SerializeObjectToXml(); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); // strip off namespace and schema XmlNode node = xmlDoc.SelectSingleNode("relationship"); node.Attributes.Remove(node.Attributes["xmlns:xsd"]); node.Attributes.Remove(node.Attributes["xmlns:xsi"]); relationshipsNode.AppendChild(this._doc.ImportNode(node, true)); } publishNode.AppendChild(this._doc.ImportNode(relationshipsNode, true)); }
public override void LoadSettings() { try { this.ddlViewOptions.Items.Add( new ListItem( Localization.GetString(ArticleViewOption.Title.ToString(), this.LocalResourceFile), ArticleViewOption.Title.ToString())); this.ddlViewOptions.Items.Add( new ListItem( Localization.GetString(ArticleViewOption.Abstract.ToString(), this.LocalResourceFile), ArticleViewOption.Abstract.ToString())); this.ddlViewOptions.Items.Add( new ListItem( Localization.GetString(ArticleViewOption.TitleAndThumbnail.ToString(), this.LocalResourceFile), ArticleViewOption.TitleAndThumbnail.ToString())); this.ddlViewOptions.Items.Add( new ListItem( Localization.GetString(ArticleViewOption.Thumbnail.ToString(), this.LocalResourceFile), ArticleViewOption.Thumbnail.ToString())); ItemRelationship.DisplayCategoryHierarchy(this.ddlCategoryList, -1, this.PortalId, false); object o = this.Settings["cfCategoryId"]; if (o != null && Engage.Utility.HasValue(o.ToString())) { ListItem li = this.ddlCategoryList.Items.FindByValue(o.ToString()); if (li != null) { li.Selected = true; } } o = this.Settings["cfDisplayOption"]; if (o != null && Engage.Utility.HasValue(o.ToString())) { ListItem li = this.ddlViewOptions.Items.FindByValue(o.ToString()); if (li != null) { li.Selected = true; } } o = this.Settings["cfEnableRss"]; bool enableRss; if (o != null && bool.TryParse(o.ToString(), out enableRss)) { this.chkEnableRss.Checked = enableRss; } o = this.Settings["cfRandomize"]; bool randomize; if (o != null && bool.TryParse(o.ToString(), out randomize)) { this.chkRandomize.Checked = randomize; } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private void Page_Load(object sender, EventArgs e) { try { // check VI for null then set information if (!this.Page.IsPostBack) { // localize the itemrelationship controls this.LocalizeControl(); // get the relationshipId and populate relationships ArrayList alItemRelationships = ItemRelationship.GetItemRelationships( this.VersionInfoObject.ItemId, this.VersionInfoObject.ItemVersionId, this.CreateRelationshipTypeId, false); foreach (ItemRelationship ir in alItemRelationships) { string parentName = ItemType.GetItemName(ir.ParentItemId); if (this._enableDates) { // add dates to the viewstate this.SetAdditionalSetting( "startDate", Utility.GetInvariantDateTime(ir.StartDate), ir.ParentItemId.ToString(CultureInfo.InvariantCulture)); this.SetAdditionalSetting( "endDate", Utility.GetInvariantDateTime(ir.EndDate), ir.ParentItemId.ToString(CultureInfo.InvariantCulture)); } var li = new ListItem(ir.ParentItemId + "-" + parentName, ir.ParentItemId.ToString(CultureInfo.InvariantCulture)); this.lstSelectedItems.Items.Add(li); } if (this._enableSortOrder) { this.trUpImage.Visible = true; this.trDownImage.Visible = true; } if (this._allowSearch) { this.pnlItemSearch.Visible = true; } if (this.AvailableSelectionMode == ListSelectionMode.Single) { this.lstSelectedItems.Rows = 1; this.lstSelectedItems.CssClass += " Publish_ParentCategory"; } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
protected void btnAddCategories_Click(object sender, EventArgs e) { //get our list of articles based on the search DataSet ds; ds = DataProvider.Instance().GetAdminKeywordSearch(txtTagSearch.Text, ItemType.Article.GetId(), ApprovalStatus.Approved.GetId(), PortalId); int articleCount; articleCount = 0; DataTable allArticles = ds.Tables[0]; foreach (DataRow dr in allArticles.Rows) { articleCount++; Article a = Article.GetArticle(Convert.ToInt32(dr["itemId"], CultureInfo.InvariantCulture), PortalId, true, true, true); if (a != null) { //create a relationship var irel = new ItemRelationship { RelationshipTypeId = RelationshipType.ItemToParentCategory.GetId() }; int ids = Convert.ToInt32(cboCategories.SelectedValue); a.Relationships.Clear(); //check for parent category, if none then add a relationship for Top Level Item if (ids > 0) { irel.ParentItemId = ids; a.Relationships.Add(irel); } int relids = Convert.ToInt32(cboRelatedCategory.SelectedValue); var irc = new ItemRelationship { RelationshipTypeId = RelationshipType.ItemToRelatedCategory.GetId() }; if (relids > 0) { irc.ParentItemId = relids; a.Relationships.Add(irc); } a.Save(UserId); } } }
protected void lbMoveToSort_Click(object sender, EventArgs e) { // ReorderDataTable(); this._sortItems = this.Session[SortList] as List <ItemRelationshipSort>; this._unsortedItems = this.Session[UnSortedList] as List <ItemRelationshipSort>; DataTable selectedRelationship = ItemRelationship.GetItemRelationshipByItemRelationshipId( Convert.ToInt32(this.lbCategoryItems.SelectedValue, CultureInfo.InvariantCulture)).Tables[0]; foreach (DataRow dr in selectedRelationship.Rows) { var irs = new ItemRelationshipSort { ItemRelationshipId = Convert.ToInt32(dr["ItemRelationshipId"], CultureInfo.InvariantCulture), SortOrder = Convert.ToInt32(dr["SortOrder"], CultureInfo.InvariantCulture), Name = dr["Name"].ToString() }; // If we've previously removed this from the _sortItems list we need to remove it from our session list of UnSorted items if (this._unsortedItems != null) { if (this._unsortedItems.Contains(irs)) { this._unsortedItems.Remove(irs); } } if (this._sortItems != null) { this._sortItems.Add(irs); } // remove item from original list } ListItem li = this.lbCategoryItems.SelectedItem; this.lbCategoryItems.Items.Remove(li); // Util.Utility.SortDataTableSingleParam(dt, "SortOrder ASC"); // get the already sorted items for a category this.rlCategorySort.DataSource = this._sortItems; this.rlCategorySort.DataBind(); this.Session[UnSortedList] = this._unsortedItems; this.Session[SortList] = this._sortItems; }
private void FillDropDown() { ItemRelationship.DisplayCategoryHierarchy(cboCategories, -1, PortalId, false); var li = new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-1"); cboCategories.Items.Insert(0, li); ItemRelationship.DisplayCategoryHierarchy(cboRelatedCategory, -1, PortalId, false); var li2 = new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-1"); cboRelatedCategory.Items.Insert(0, li2); }
protected void cmdDelete_Click(object sender, EventArgs e) { bool itemExists = false; txtMessage.Visible = true; if (ItemId > -1) { //Using GetItemTypeId as substitute for IfExists if (Item.GetItemTypeId(ItemId, PortalId) > -1) { itemExists = true; DataSet children = ItemRelationship.GetAllChildren(ItemId, Util.RelationshipType.ItemToParentCategory.GetId(), PortalId); bool hasChildren = children.Tables.Count > 0 && children.Tables[0].Rows.Count > 0; if (!hasChildren) { //Item.DeleteItem(ItemId); Item.DeleteItem(ItemId, PortalId); txtMessage.Text = Localization.GetString("DeleteSuccess", LocalResourceFile); //Util.Utility.ClearPublishCache(PortalId); } else { var errorMessage = new StringBuilder(); errorMessage.AppendFormat("{0}{1}", Localization.GetString("DeleteFailureHasChildren", LocalResourceFile), Environment.NewLine); foreach (DataRow row in children.Tables[0].Rows) { int itemId;// = 0; if (int.TryParse(row["itemId"].ToString(), out itemId)) { errorMessage.AppendFormat(CultureInfo.CurrentCulture, "{0} ({1}, id: {2}){3}", row["name"], Item.GetItemType(ItemId, PortalId), itemId, Environment.NewLine); } else { errorMessage.AppendFormat(CultureInfo.CurrentCulture, "{0} (id: {1}){2}", row["name"], row["itemId"], Environment.NewLine); } } txtMessage.Text = errorMessage.ToString(); } } } if (!itemExists) { txtMessage.Text = Localization.GetString("DeleteFailure", LocalResourceFile); } ShowOnlyMessage(); }
private void FillDropDown() { ItemRelationship.DisplayCategoryHierarchy(cboCategories, -1, PortalId, false); ListItem li = new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-1"); this.cboCategories.Items.Insert(0, li); //module settings for CC API CommunityCreditService cs = new CommunityCreditService(Settings["AffiliateCode"].ToString(), Settings["AffiliateKey"].ToString()); CommunityCredit.Components.PointCategoryCollection pcc = cs.GetPointCategories(); foreach (PointCategory pcat in pcc) { cboCCCategories.Items.Add(new ListItem(pcat.Code, pcat.ID.ToString())); } }
//private string CategoryName //{ // get // { // Category c = Category.GetCategory(ItemId, PortalId); // return c.Name; // } //} private void FillDropDowns() { ItemRelationship.DisplayCategoryHierarchy(cboItemType, CategoryId, PortalId, false); var li = new ListItem(Localization.GetString("ChooseOne", LocalSharedResourceFile), "-1"); cboItemType.Items.Insert(0, li); cboWorkflow.Visible = UseApprovals; lblWorkflow.Visible = UseApprovals; if (UseApprovals) { cboWorkflow.DataSource = DataProvider.Instance().GetApprovalStatusTypes(PortalId); cboWorkflow.DataValueField = "ApprovalStatusID"; cboWorkflow.DataTextField = "ApprovalStatusName"; cboWorkflow.DataBind(); li = cboWorkflow.Items.FindByText(ApprovalStatus.Approved.Name); if (li != null) { li.Selected = true; } } }
public override void LoadSettings() { _customDisplaySettings = new CustomDisplaySettings(Settings, TabModuleId); try { ddlItemTypeList.DataTextField = "Name"; ddlItemTypeList.DataValueField = "ItemTypeId"; ddlItemTypeList.DataSource = Item.GetItemTypes(PortalId); ddlItemTypeList.DataBind(); ddlItemTypeList.Items.Insert(0, new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-2")); ddlItemTypeList.Items.Insert(1, new ListItem(Localization.GetString("CategoriesAndArticles", LocalResourceFile), "-1")); ListItem li = ddlItemTypeList.Items.FindByValue(_customDisplaySettings.ItemTypeId.ToString(CultureInfo.InvariantCulture)); li.Selected = true; li = new ListItem(Localization.GetString(DisplayOption.Title.ToString(), LocalResourceFile), DisplayOption.Title.ToString()) { Selected = _customDisplaySettings.DisplayOptionTitle }; chkDisplayOptions.Items.Add(li); li = new ListItem(Localization.GetString(DisplayOption.Author.ToString(), LocalResourceFile), DisplayOption.Author.ToString()) { Selected = _customDisplaySettings.DisplayOptionAuthor }; chkDisplayOptions.Items.Add(li); li = new ListItem(Localization.GetString(DisplayOption.Date.ToString(), LocalResourceFile), DisplayOption.Date.ToString()) { Selected = _customDisplaySettings.DisplayOptionDate }; chkDisplayOptions.Items.Add(li); li = new ListItem(Localization.GetString(DisplayOption.Abstract.ToString(), LocalResourceFile), DisplayOption.Abstract.ToString()) { Selected = _customDisplaySettings.DisplayOptionAbstract }; chkDisplayOptions.Items.Add(li); li = new ListItem(Localization.GetString(DisplayOption.Thumbnail.ToString(), LocalResourceFile), DisplayOption.Thumbnail.ToString()) { Selected = _customDisplaySettings.DisplayOptionThumbnail }; chkDisplayOptions.Items.Add(li); li = new ListItem(Localization.GetString(DisplayOption.ReadMore.ToString(), LocalResourceFile), DisplayOption.ReadMore.ToString()) { Selected = _customDisplaySettings.DisplayOptionReadMore }; chkDisplayOptions.Items.Add(li); li = new ListItem(Localization.GetString(DisplayOption.Stats.ToString(), LocalResourceFile), DisplayOption.Stats.ToString()) { Selected = _customDisplaySettings.DisplayOptionStats }; chkDisplayOptions.Items.Add(li); int maxItems = _customDisplaySettings.MaxDisplayItems; if (maxItems > -1) { txtMaxItems.Text = maxItems.ToString(CultureInfo.InvariantCulture); } txtMaxItems.Enabled = (maxItems > -1); chkShowAll.Checked = (maxItems == -1); ItemRelationship.DisplayCategoryHierarchy(ddlCategory, -1, PortalId, false); if (ddlItemTypeList.SelectedValue != ItemType.Article.GetId().ToString(CultureInfo.InvariantCulture) && ddlCategory.Items.FindByValue("-1") == null) { ddlCategory.Items.Insert(0, new ListItem(Localization.GetString("NoCategory", LocalResourceFile), TopLevelCategoryItemType.Category.GetId().ToString(CultureInfo.InvariantCulture))); //ddlItemTypeList.Items.Insert(1, new ListItem(Localization.GetString("CategoriesAndArticles", LocalResourceFile), "-1")); } if (_customDisplaySettings.CategoryId > 0) { li = ddlCategory.Items.FindByValue(_customDisplaySettings.CategoryId.ToString(CultureInfo.InvariantCulture)); if (li != null) { li.Selected = true; } } if (ddlCategory.SelectedValue == "-1" || ddlCategory.SelectedValue == TopLevelCategoryItemType.Category.GetId().ToString(CultureInfo.InvariantCulture)) { lblShowParent.Visible = false; chkShowParent.Visible = false; lblShowParentDescription.Visible = false; chkShowParentDescription.Visible = false; } else { lblShowParent.Visible = true; chkShowParent.Visible = true; } chkShowParent.Checked = _customDisplaySettings.ShowParent; chkShowParentDescription.Checked = _customDisplaySettings.ShowParentDescription; chkRelatedItem.Checked = _customDisplaySettings.GetParentFromQueryString; chkRelatedItemLevel.Checked = _customDisplaySettings.GetRelatedChildren; chkAllowPaging.Checked = _customDisplaySettings.AllowPaging; ddlSortOption.Items.Add(new ListItem(Localization.GetString("TitleSort", LocalResourceFile), CustomDisplaySettings.TitleSort)); ddlSortOption.Items.Add(new ListItem(Localization.GetString("DateSort", LocalResourceFile), CustomDisplaySettings.DateSort)); ddlSortOption.Items.Add(new ListItem(Localization.GetString("LastUpdatedSort", LocalResourceFile), CustomDisplaySettings.LastUpdatedSort)); ddlSortOption.Items.Add(new ListItem(Localization.GetString("StartDateSort", LocalResourceFile), CustomDisplaySettings.StartDateSort)); if (ModuleBase.IsViewTrackingEnabledForPortal(PortalId) && ddlItemTypeList.SelectedValue == ItemType.Article.GetId().ToString(CultureInfo.InvariantCulture)) { //only show this if the Portal is configured to track views and the item type is Article. hk ddlSortOption.Items.Add(new ListItem(Localization.GetString("MostPopularSort", LocalResourceFile), CustomDisplaySettings.MostPopularSort)); } li = ddlSortOption.Items.FindByValue(_customDisplaySettings.SortOption); if (li != null) { li.Selected = true; } li = rbSortDirection.Items.FindByValue(_customDisplaySettings.SortDirection); if (li != null) { li.Selected = true; } txtDateFormat.Text = _customDisplaySettings.DateFormat; chkEnableRss.Checked = _customDisplaySettings.EnableRss; chkUseCustomSort.Checked = _customDisplaySettings.UseCustomSort; lnkSortCategory.NavigateUrl = BuildSortUrl(); lnkSortCategory.Target = "_blank"; } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private void CmdUpdateClick(object sender, EventArgs e) { try { var av = (Article)VersionInfoObject; txtMessage.Text = string.Empty; bool error = false; //Removed the check for the Item Description length as we no longer have a restriction on this //if (TextBoxMaxLengthExceeded(this.itemEditControl.DescriptionText, "Article Description", 4000)) //{ // error = true; //} if (TextBoxMaxLengthExceeded(txtVersionDescription.Text, "Version Description", 8000)) { error = true; } if (!parentCategoryRelationship.IsValid) { error = true; txtMessage.Text += Localization.GetString("ErrorSelectCategory.Text", LocalResourceFile); } if (!itemApprovalStatus.IsValid && itemApprovalStatus.Visible) { error = true; txtMessage.Text += Localization.GetString("ErrorApprovalStatus.Text", LocalResourceFile); } if (!itemEditControl.IsValid) { error = true; txtMessage.Text += itemEditControl.ErrorMessage; } if (Convert.ToInt32(ddlDisplayTabId.SelectedValue, CultureInfo.InvariantCulture) > -1) { VersionInfoObject.DisplayTabId = Convert.ToInt32(ddlDisplayTabId.SelectedValue, CultureInfo.InvariantCulture); } else { error = true; txtMessage.Text += Localization.GetString("ErrorDisplayPage.Text", LocalResourceFile); } if (error) { txtMessage.Visible = true; return; } av.ArticleText = TeArticleText.Text; av.VersionDescription = txtVersionDescription.Text; av.VersionNumber = txtVersionNumber.Text; av.Description = itemEditControl.DescriptionText; //we need to look at making moduleid be configurable at anytime, not just on item creation, this makes previewing items impossible //if (av.IsNew) int newModuleId = Utility.GetModuleIdFromDisplayTabId(VersionInfoObject.DisplayTabId, PortalId, Utility.DnnFriendlyModuleName); if (newModuleId > 0) { VersionInfoObject.ModuleId = newModuleId; } else { newModuleId = Utility.GetModuleIdFromDisplayTabId(VersionInfoObject.DisplayTabId, PortalId, Utility.DnnFriendlyModuleNameTextHTML); if (newModuleId > 0) { VersionInfoObject.ModuleId = newModuleId; } } //create a relationship var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId() }; int[] ids = parentCategoryRelationship.GetSelectedItemIds(); //check for parent category, if none then add a relationship for Top Level Item if (ids.Length > 0) { irel.ParentItemId = ids[0]; VersionInfoObject.Relationships.Add(irel); } foreach (int i in relatedCategoryRelationships.GetSelectedItemIds()) { var irco = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(), ParentItemId = i }; av.Relationships.Add(irco); } if (AllowTags) { av.Tags.Clear(); //Add the tags to the ItemTagCollection foreach (Tag t in Tag.ParseTags(tagEntryControl.TagList, PortalId)) { ItemTag it = ItemTag.Create(); it.TagId = Convert.ToInt32(t.TagId, CultureInfo.InvariantCulture); av.Tags.Add(it); } } if (av.Description == string.Empty) { //trim article text to populate description if (!Utility.HasValue(av.Description) || !Utility.HasValue(av.MetaDescription)) { string description = DotNetNuke.Common.Utilities.HtmlUtils.StripTags(av.ArticleText, false); if (!Utility.HasValue(av.Description)) av.Description = Utility.TrimDescription(3997, description) + "...";// description + "..."; } } //auto populate the meta description if it's not populated already if (!Utility.HasValue(av.MetaDescription)) { string description = DotNetNuke.Common.Utilities.HtmlUtils.StripTags(av.Description, false); av.MetaDescription = Utility.TrimDescription(399, description); } //Save the ItemVersionSettings SaveSettings(); //approval status av.ApprovalStatusId = chkUseApprovals.Checked && UseApprovals ? itemApprovalStatus.ApprovalStatusId : ApprovalStatus.Approved.GetId(); VersionInfoObject.Save(UserId); string returnUrl = Server.UrlDecode(Request.QueryString["returnUrl"]); if (!Utility.HasValue(returnUrl)) { Response.Redirect(Globals.NavigateURL(TabId, "", "", "ctl=" + Utility.AdminContainer, "mid=" + ModuleId.ToString(CultureInfo.InvariantCulture), "adminType=itemCreated", "itemId=" + VersionInfoObject.ItemId.ToString(CultureInfo.InvariantCulture)), true); } else { Response.Redirect(returnUrl); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
public override void LoadSettings() { try { ddlViewOptions.Items.Add(new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-1")); ddlViewOptions.Items.Add(new ListItem(Localization.GetString(ArticleViewOption.Title.ToString(), LocalResourceFile), ArticleViewOption.Title.ToString())); ddlViewOptions.Items.Add(new ListItem(Localization.GetString(ArticleViewOption.Abstract.ToString(), LocalResourceFile), ArticleViewOption.Abstract.ToString())); ddlViewOptions.Items.Add(new ListItem(Localization.GetString(ArticleViewOption.TitleAndThumbnail.ToString(), LocalResourceFile), ArticleViewOption.TitleAndThumbnail.ToString())); ddlViewOptions.Items.Add(new ListItem(Localization.GetString(ArticleViewOption.Thumbnail.ToString(), LocalResourceFile), ArticleViewOption.Thumbnail.ToString())); ddlChildDisplay.Items.Add(new ListItem(Localization.GetString("ShowAll", LocalResourceFile), "ShowAll")); ddlChildDisplay.Visible = false; lblChooseChildDisplay.Visible = false; ddlSortOption.Items.Add(new ListItem(Localization.GetString("AlphaAscending", LocalResourceFile), "Alpha Ascending")); ddlSortOption.Items.Add(new ListItem(Localization.GetString("AlphaDescending", LocalResourceFile), "Alpha Descending")); ddlSortOption.Items.Add(new ListItem(Localization.GetString("CreatedAscending", LocalResourceFile), "Created Ascending")); ddlSortOption.Items.Add(new ListItem(Localization.GetString("CreatedDescending", LocalResourceFile), "Created Descending")); ddlSortOption.Items.Add(new ListItem(Localization.GetString("LastUpdatedAscending", LocalResourceFile), "Last Updated Ascending")); ddlSortOption.Items.Add(new ListItem(Localization.GetString("LastUpdatedDescending", LocalResourceFile), "Last Updated Descending")); ddlItemTypeList.DataTextField = "Name"; ddlItemTypeList.DataValueField = "ItemTypeId"; ddlItemTypeList.DataSource = Item.GetItemTypes(PortalId); ddlItemTypeList.DataBind(); ddlItemTypeList.Items.Insert(0, new ListItem(Localization.GetString("All", LocalResourceFile), "-1")); ItemRelationship.DisplayCategoryHierarchy(ddlCategoryList, -1, PortalId, false); //ddlCategoryList.Items.Insert(0,new ListItem(Localization.GetString("TopLevel", LocalResourceFile), TopLevelCategoryItemType.Category.GetId().ToString())); object o = Settings["cdItemTypeId"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { ListItem li = ddlItemTypeList.Items.FindByValue(o.ToString()); if (li != null) { li.Selected = true; } } o = Settings["cdCategoryId"]; if (o != null && !String.IsNullOrEmpty(o.ToString())) { ListItem li = ddlCategoryList.Items.FindByValue(o.ToString()); if (li != null) { li.Selected = true; } } o = Settings["cdDisplayOption"]; if (o != null && !String.IsNullOrEmpty(o.ToString())) { ListItem li = ddlViewOptions.Items.FindByValue(o.ToString()); if (li != null) { li.Selected = true; } } o = Settings["cdChildDisplayOption"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { ListItem li = ddlChildDisplay.Items.FindByValue(o.ToString()); if (li != null) { li.Selected = true; } } o = Settings["cdSortOption"]; if (o != null && !String.IsNullOrEmpty(o.ToString())) { ListItem li = ddlSortOption.Items.FindByValue(o.ToString()); if (li != null) { li.Selected = true; } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
bool IMetaWeblog.UpdatePost(string postid, string username, string password, Post post, bool publish) { LocatePortal(Context.Request); DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password); if (ui.UserID > 0) { Article a = Article.GetArticle(Convert.ToInt32(postid), _portalId, true, true,true); a.Description = post.description; a.ArticleText = post.description; a.Name = post.title; a.VersionDescription = Localization.GetString("MetaBlogApi", LocalResourceFile); var pc = new List<Publish.Category>(); foreach (string s in post.categories) { Publish.Category c = Publish.Category.GetCategory(s, PortalId); pc.Add(c); } //remove all existing categories a.Relationships.Clear(); //add the parent category if (pc.Count > 0) { var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId(), ParentItemId = pc[0].ItemId }; a.Relationships.Add(irel); } //add any extra categories if (pc.Count > 1) { for (int i = 1; i < pc.Count; i++) { var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(), ParentItemId = pc[i].ItemId }; a.Relationships.Add(irel); } } //remove existing tags a.Tags.Clear(); //check for tags if (post.mt_keywords.Trim() != string.Empty) { //split tags foreach (Tag t in Tag.ParseTags(post.mt_keywords, _portalId)) { ItemTag it = ItemTag.Create(); it.TagId = Convert.ToInt32(t.TagId, CultureInfo.InvariantCulture); a.Tags.Add(it); } } if (post.mt_excerpt != null && post.mt_excerpt.Trim() != string.Empty) { a.Description = post.mt_excerpt; } // handle approval process if (ModuleBase.UseApprovalsForPortal(_portalId)) { if (ui.IsInRole(HostController.Instance.GetString(Utility.PublishAdminRole + _portalId)) || ui.IsSuperUser) { a.ApprovalStatusId = ApprovalStatus.Approved.GetId(); } else if (ui.IsInRole(HostController.Instance.GetString(Utility.PublishAuthorRole + _portalId))) { a.ApprovalStatusId = ApprovalStatus.Waiting.GetId(); } } a.Save(ui.UserID); return true; } throw new XmlRpcFaultException(0, Localization.GetString("FailedToUpdatePost.Text", LocalResourceFile)); }
public void UpdateAvailableItems() { // am I looking for children or items if (!this._allowSearch) { if (this._flatView && this._allowSearch) { // get all item types // this._itemTypeId this.lstItems.DataSource = Item.GetItems(this._itemTypeId, this.PortalId); this.lstItems.DataTextField = "listName"; this.lstItems.DataValueField = "itemId"; this.DataBind(); ListItem li = this.lstItems.Items.FindByValue(this.ItemId.ToString(CultureInfo.InvariantCulture)); this.lstItems.Items.Remove(li); } else { this.lstItems.Items.Clear(); var ir = new ItemRelationship { ParentItemId = this._parentItemId, ItemTypeId = this._itemTypeId, RelationshipTypeId = this._listRelationshipTypeId }; ir.DisplayChildren(this.lstItems, this.PortalId, this.ExcludeCircularRelationships ? this.VersionInfoObject.ItemId : (int?)null); } } // look for children }
/// <summary> /// Fills the ParentCategoryDropDownList control. /// </summary> private void FillParentCategoryDropDown() { ItemRelationship.DisplayCategoryHierarchy(this.ParentCategoryDropDownList, -1, this.PortalId, false); }
public override void LoadSettings() { try { //we want to allow for both articles and categories to be selected here, all the time CJH //if (CategoryId != -1) //{ DataBindItemTypeList(); ListItem li = ddlItemTypeList.Items.FindByValue(ItemTypeId.ToString(CultureInfo.InvariantCulture)); if (li != null) { li.Selected = true; } //} ////if the category is top level, only allow Category for the item type, there are only categories under top level. BD //else //{ // ddlItemTypeList.Items.Add(new ListItem(ItemType.Category.Name, ItemType.Category.GetId().ToString(CultureInfo.InvariantCulture))); //} ddlDataType.Items.Add(new ListItem(Localization.GetString("ItemListing", LocalResourceFile), "Item Listing")); if (ModuleBase.IsViewTrackingEnabledForPortal(PortalId)) { ddlDataType.Items.Add(new ListItem(Localization.GetString("MostPopular", LocalResourceFile), "Most Popular")); } ddlDataType.Items.Add(new ListItem(Localization.GetString("MostRecent", LocalResourceFile), "Most Recent")); li = ddlDataType.Items.FindByValue(DataType); if (li != null) { li.Selected = true; } ddlDisplayFormat.Items.Add(new ListItem(Localization.GetString(ArticleViewOption.Title.ToString(), LocalResourceFile), ArticleViewOption.Title.ToString())); ddlDisplayFormat.Items.Add(new ListItem(Localization.GetString(ArticleViewOption.Abstract.ToString(), LocalResourceFile), ArticleViewOption.Abstract.ToString())); ddlDisplayFormat.Items.Add(new ListItem(Localization.GetString(ArticleViewOption.TitleAndThumbnail.ToString(), LocalResourceFile), ArticleViewOption.TitleAndThumbnail.ToString())); ddlDisplayFormat.Items.Add(new ListItem(Localization.GetString(ArticleViewOption.Thumbnail.ToString(), LocalResourceFile), ArticleViewOption.Thumbnail.ToString())); li = ddlDisplayFormat.Items.FindByValue(DataDisplayFormat); if (li != null) { li.Selected = true; } txtMaxItems.Text = MaxDisplayItems.ToString(CultureInfo.CurrentCulture); ItemRelationship.DisplayCategoryHierarchy(ddlCategory, -1, PortalId, false); ddlCategory.Items.Insert(0, new ListItem(Localization.GetString("NoCategory", LocalResourceFile), "-1")); ListItem liCat = ddlCategory.Items.FindByValue(CategoryId.ToString(CultureInfo.InvariantCulture)); if (liCat != null) { liCat.Selected = true; } if (ddlDataType.SelectedValue == "Most Recent") { chkEnableRss.Visible = true; lblEnableRss.Visible = true; } else { chkEnableRss.Visible = false; lblEnableRss.Visible = false; } chkEnableRss.Checked = EnableRss; if (ddlCategory.SelectedValue == "-1") { lblShowParent.Visible = false; chkShowParent.Visible = false; } else { lblShowParent.Visible = true; chkShowParent.Visible = true; } chkShowParent.Checked = ShowParent; } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
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); } }
/// <summary> /// Fills <see cref="CategoriesDropDownList"/> with the list of categories. /// </summary> private void FillCategoryDropDown() { CategoriesDropDownList.Items.Clear(); ItemRelationship.DisplayCategoryHierarchy(CategoriesDropDownList, -1, PortalId, false); CategoriesDropDownList.Items.Insert(0, new ListItem(Localization.GetString("ChooseOne", Utility.LocalSharedResourceFile), "")); }
public override void LoadSettings() { base.LoadSettings(); try { object o = this.Settings["csMaxResults"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { this.txtResults.Text = o.ToString(); } o = this.Settings["csPerPage"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { this.txtPage.Text = o.ToString(); } o = this.Settings["csTitleLength"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { this.txtTitle.Text = o.ToString(); } o = this.Settings["csDescriptionLength"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { this.txtDescription.Text = o.ToString(); } o = this.Settings["csSearchEmptyRedirectUrl"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { this.txtSearchUrl.Text = o.ToString(); } ItemRelationship.DisplayCategoryHierarchy(this.ddlCategorySearchList, -1, this.PortalId, false); this.ddlCategorySearchList.Items.Insert(0, new ListItem(Localization.GetString("AllCategories", this.LocalResourceFile), "-1")); o = this.Settings["csCategoryId"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { ListItem li = this.ddlCategorySearchList.Items.FindByValue(o.ToString()); if (li != null) { li.Selected = true; } } this.chkDescription.Checked = false; o = this.Settings["csShowDescription"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { this.chkDescription.Checked = o.ToString().Equals("Y"); } this.chkAllowCategorySelection.Checked = true; o = this.Settings["csAllowCategorySelection"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { this.chkAllowCategorySelection.Checked = o.ToString().Equals("Y"); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private void CmdUpdateClick(object sender, EventArgs e) { try { var av = (Article)VersionInfoObject; txtMessage.Text = string.Empty; bool error = false; //Removed the check for the Item Description length as we no longer have a restriction on this //if (TextBoxMaxLengthExceeded(this.itemEditControl.DescriptionText, "Article Description", 4000)) //{ // error = true; //} if (TextBoxMaxLengthExceeded(txtVersionDescription.Text, "Version Description", 8000)) { error = true; } if (!parentCategoryRelationship.IsValid) { error = true; txtMessage.Text += Localization.GetString("ErrorSelectCategory.Text", LocalResourceFile); } if (!itemApprovalStatus.IsValid && itemApprovalStatus.Visible) { error = true; txtMessage.Text += Localization.GetString("ErrorApprovalStatus.Text", LocalResourceFile); } if (!itemEditControl.IsValid) { error = true; txtMessage.Text += itemEditControl.ErrorMessage; } if (Convert.ToInt32(ddlDisplayTabId.SelectedValue, CultureInfo.InvariantCulture) > -1) { VersionInfoObject.DisplayTabId = Convert.ToInt32(ddlDisplayTabId.SelectedValue, CultureInfo.InvariantCulture); } else { error = true; txtMessage.Text += Localization.GetString("ErrorDisplayPage.Text", LocalResourceFile); } if (error) { txtMessage.Visible = true; return; } av.ArticleText = TeArticleText.Text; av.VersionDescription = txtVersionDescription.Text; av.VersionNumber = txtVersionNumber.Text; av.Description = itemEditControl.DescriptionText; //we need to look at making moduleid be configurable at anytime, not just on item creation, this makes previewing items impossible //if (av.IsNew) int newModuleId = Utility.GetModuleIdFromDisplayTabId(VersionInfoObject.DisplayTabId, PortalId, Utility.DnnFriendlyModuleName); if (newModuleId > 0) { VersionInfoObject.ModuleId = newModuleId; } else { newModuleId = Utility.GetModuleIdFromDisplayTabId(VersionInfoObject.DisplayTabId, PortalId, Utility.DnnFriendlyModuleNameTextHTML); if (newModuleId > 0) { VersionInfoObject.ModuleId = newModuleId; } } //create a relationship var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId() }; int[] ids = parentCategoryRelationship.GetSelectedItemIds(); //check for parent category, if none then add a relationship for Top Level Item if (ids.Length > 0) { irel.ParentItemId = ids[0]; VersionInfoObject.Relationships.Add(irel); } foreach (int i in relatedCategoryRelationships.GetSelectedItemIds()) { var irco = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(), ParentItemId = i }; av.Relationships.Add(irco); } if (AllowTags) { av.Tags.Clear(); //Add the tags to the ItemTagCollection foreach (Tag t in Tag.ParseTags(tagEntryControl.TagList, PortalId)) { ItemTag it = ItemTag.Create(); it.TagId = Convert.ToInt32(t.TagId, CultureInfo.InvariantCulture); av.Tags.Add(it); } } if (av.Description == string.Empty) { //trim article text to populate description if (!Utility.HasValue(av.Description) || !Utility.HasValue(av.MetaDescription)) { string description = DotNetNuke.Common.Utilities.HtmlUtils.StripTags(av.ArticleText, false); if (!Utility.HasValue(av.Description)) { av.Description = Utility.TrimDescription(3997, description) + "...";// description + "..."; } } } //auto populate the meta description if it's not populated already if (!Utility.HasValue(av.MetaDescription)) { string description = DotNetNuke.Common.Utilities.HtmlUtils.StripTags(av.Description, false); av.MetaDescription = Utility.TrimDescription(399, description); } //Save the ItemVersionSettings SaveSettings(); //approval status av.ApprovalStatusId = chkUseApprovals.Checked && UseApprovals ? itemApprovalStatus.ApprovalStatusId : ApprovalStatus.Approved.GetId(); VersionInfoObject.Save(UserId); string returnUrl = Server.UrlDecode(Request.QueryString["returnUrl"]); if (!Utility.HasValue(returnUrl)) { Response.Redirect(Globals.NavigateURL(TabId, "", "", "ctl=" + Utility.AdminContainer, "mid=" + ModuleId.ToString(CultureInfo.InvariantCulture), "adminType=itemCreated", "itemId=" + VersionInfoObject.ItemId.ToString(CultureInfo.InvariantCulture)), true); } else { Response.Redirect(returnUrl); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private void BindData() { //TODO: NLevels number of items is not currently used //ToDO: figure out how to get the treeview to use the sorted datatable string cacheKey = Utility.CacheKeyPublishCategoryNLevels + ItemId; // +"PageId"; var root = DataCache.GetCache(cacheKey) as System.Windows.Forms.TreeNode; if (root == null) { root = ItemRelationship.GetAllChildrenNLevels(ItemId, nLevels, -1, PortalId); if (root != null) { DataCache.SetCache(cacheKey, root, DateTime.Now.AddMinutes(CacheTime)); Utility.AddCacheKey(cacheKey, PortalId); } } //add the parent category to the list first. if (showParentItem) { Category parentItem = Category.GetCategory(ItemId, PortalId); #region showparent if (parentItem != null) { phNLevels.Controls.Add(new LiteralControl("<ul>")); phNLevels.Controls.Add(new LiteralControl("<li>")); var hlParent = new HyperLink(); if (parentItem.Disabled == false) { hlParent.NavigateUrl = GetItemLinkUrl(parentItem.ItemId); } hlParent.Text = parentItem.Name; if (highlightCurrentItem) { int itemId;//=0; object o = Request.QueryString["ItemId"]; if (o != null && int.TryParse(o.ToString(), out itemId)) { if (itemId == parentItem.ItemId) { hlParent.CssClass = HighlightCssClass; } } } phNLevels.Controls.Add(hlParent); phNLevels.Controls.Add(new LiteralControl("</li>")); FillNLevelList(root, phNLevels); phNLevels.Controls.Add(new LiteralControl("</ul>")); } else { FillNLevelList(root, phNLevels); } #endregion } else { FillNLevelList(root, phNLevels); } }
protected void cmdDelete_Click(object sender, EventArgs e) { txtMessage.Visible = true; bool itemExists = false; if (ItemId > -1) { //Using GetItemTypeId as substitute for IfExists if (Item.GetItemTypeId(ItemId, PortalId) > -1) { itemExists = true; bool inUse = false; var modulesInUse = new StringBuilder(); var mc = new ModuleController(); ArrayList modules = mc.GetModulesByDefinition(PortalId, Utility.DnnFriendlyModuleName); foreach (ModuleInfo module in modules) { Hashtable settings = module.TabModuleSettings; if (settings.ContainsKey("DisplayType") && settings["DisplayType"].ToString() == "ArticleDisplay") { int articleId; if (settings.ContainsKey("adArticleId") && int.TryParse(settings["adArticleId"].ToString(), out articleId)) { if (articleId == ItemId) { inUse = true; modulesInUse.AppendFormat("{0} ({1}){2}", module.ModuleTitle, module.TabID, Environment.NewLine); break; } } } } ArrayList featuredRelationships = ItemRelationship.GetItemChildRelationships(ItemId, Util.RelationshipType.ItemToFeaturedItem.GetId()); bool isFeatured = featuredRelationships.Count > 0; if (!inUse && !isFeatured) { //Item.DeleteItem(ItemId); Item.DeleteItem(ItemId, PortalId); txtMessage.Text = Localization.GetString("DeleteSuccess", LocalResourceFile); } else { var errorMessage = new StringBuilder(); if (inUse) { errorMessage.AppendFormat("{0}{1}", Localization.GetString("DeleteFailureInUse", LocalResourceFile), Environment.NewLine); errorMessage.Append(modulesInUse.ToString()); } if (isFeatured) { errorMessage.AppendFormat("{0}{1}", Localization.GetString("DeleteFailureIsFeatured", LocalResourceFile), Environment.NewLine); foreach (ItemRelationship rel in featuredRelationships) { Category parentCategory = Category.GetCategory(rel.ChildItemId, PortalId); errorMessage.AppendFormat("{0}{1}", parentCategory.Name, Environment.NewLine); } } txtMessage.Text = errorMessage.ToString(); } } } if (!itemExists) { txtMessage.Text = Localization.GetString("DeleteFailure", LocalResourceFile); } ShowOnlyMessage(); }
bool IMetaWeblog.UpdatePost(string postid, string username, string password, Post post, bool publish) { LocatePortal(Context.Request); DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password); if (ui.UserID > 0) { Article a = Article.GetArticle(Convert.ToInt32(postid), _portalId, true, true, true); a.Description = post.description; a.ArticleText = post.description; a.Name = post.title; a.VersionDescription = Localization.GetString("MetaBlogApi", LocalResourceFile); var pc = new List <Publish.Category>(); foreach (string s in post.categories) { Publish.Category c = Publish.Category.GetCategory(s, PortalId); pc.Add(c); } //remove all existing categories a.Relationships.Clear(); //add the parent category if (pc.Count > 0) { var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId(), ParentItemId = pc[0].ItemId }; a.Relationships.Add(irel); } //add any extra categories if (pc.Count > 1) { for (int i = 1; i < pc.Count; i++) { var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(), ParentItemId = pc[i].ItemId }; a.Relationships.Add(irel); } } //remove existing tags a.Tags.Clear(); //check for tags if (post.mt_keywords.Trim() != string.Empty) { //split tags foreach (Tag t in Tag.ParseTags(post.mt_keywords, _portalId)) { ItemTag it = ItemTag.Create(); it.TagId = Convert.ToInt32(t.TagId, CultureInfo.InvariantCulture); a.Tags.Add(it); } } if (post.mt_excerpt != null && post.mt_excerpt.Trim() != string.Empty) { a.Description = post.mt_excerpt; } // handle approval process if (ModuleBase.UseApprovalsForPortal(_portalId)) { if (ui.IsInRole(HostController.Instance.GetString(Utility.PublishAdminRole + _portalId)) || ui.IsSuperUser) { a.ApprovalStatusId = ApprovalStatus.Approved.GetId(); } else if (ui.IsInRole(HostController.Instance.GetString(Utility.PublishAuthorRole + _portalId))) { a.ApprovalStatusId = ApprovalStatus.Waiting.GetId(); } } a.Save(ui.UserID); return(true); } throw new XmlRpcFaultException(0, Localization.GetString("FailedToUpdatePost.Text", LocalResourceFile)); }
public override void LoadSettings() { try { ItemRelationship.DisplayCategoryHierarchy(this.ddlCategoryList, -1, this.PortalId, false); this.ddlCategoryList.Items.Insert(0, new ListItem(Localization.GetString("ChooseOne", this.LocalResourceFile), "-1")); this.ddlCategoryList.Items.Insert( 1, new ListItem( Localization.GetString("TopLevel", this.LocalResourceFile), TopLevelCategoryItemType.Category.GetId().ToString(CultureInfo.InvariantCulture))); object o = this.Settings["nLevels"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { this.txtNLevels.Text = o.ToString(); } // o = Settings["mItems"]; // if (o != null && !string.IsNullOrEmpty(o.ToString())) // { // txtMItems.Text = o.ToString(); // } // chkHighlightCurrentItem o = this.Settings["HighlightCurrentItem"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { this.chkHighlightCurrentItem.Checked = Convert.ToBoolean(o.ToString(), CultureInfo.InvariantCulture); } o = this.Settings["ShowParentItem"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { this.chkShowParentItem.Checked = Convert.ToBoolean(o.ToString(), CultureInfo.InvariantCulture); } o = this.Settings["nCategoryId"]; if (o != null && !string.IsNullOrEmpty(o.ToString())) { ListItem li = this.ddlCategoryList.Items.FindByValue(o.ToString()); if (li != null) { li.Selected = true; } } // if (string.IsNullOrEmpty(OrderString)) // { // o = Settings["nSortOrder"]; // if (o != null) // { // OrderString = Settings["nSortOrder"].ToString(); // } // } // else // { // o = OrderString; // } // if (o != null && !string.IsNullOrEmpty(o.ToString()) ) // { // DataTable dt = GetAllChildrenDataTable(); // if (dt != null) // { // lstItems.DataSource = Utility.SortDataTable(dt, o.ToString()); // lstItems.DataBind(); // } // } // else // { // DataTable dt = GetAllChildrenDataTable(); // if (dt != null) // { // lstItems.DataSource = dt; // lstItems.DataBind(); // } // } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
///<summary> /// Add a new blog post /// </summary> /// <param name="blogid">Blogid</param> /// <param name="username">username</param> /// <param name="password">password</param> /// <param name="post">post</param> /// <param name="publish">publish</param> string IMetaWeblog.AddPost(string blogid, string username, string password, Post post, bool publish) { LocatePortal(Context.Request); DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password); if (ui != null) { //TODO: we need a default category for users, then we can allow theme detection in WLW var pc = new List <Publish.Category>(); foreach (string s in post.categories) { Publish.Category c = Publish.Category.GetCategory(s, PortalId); pc.Add(c); } //This only works for the first category, how should we handle other categories? if (pc.Count < 1) { Publish.Category c = Publish.Category.GetCategory(ModuleBase.DefaultCategoryForPortal(PortalId), PortalId); pc.Add(c); } if (pc.Count > 0) { //get description //string description = post.description.Substring(0,post.description.IndexOf(" //look for <!--pagebreak--> Article a = Article.Create(post.title, post.description, post.description, ui.UserID, pc[0].ItemId, pc[0].ModuleId, pc[0].PortalId); //TODO: check if dateCreated is a valid date //TODO: date Created is coming in as UTC time //TODO: re-enable Date created //a.StartDate = post.dateCreated.ToString(); a.VersionDescription = Localization.GetString("MetaBlogApi", LocalResourceFile); if (pc.Count > 1) { for (int i = 1; i < pc.Count; i++) { var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(), ParentItemId = pc[i].ItemId }; a.Relationships.Add(irel); } } //check for tags if (post.mt_keywords != null && post.mt_keywords.Trim() != string.Empty) { //split tags foreach (Tag t in Tag.ParseTags(post.mt_keywords, _portalId)) { ItemTag it = ItemTag.Create(); it.TagId = Convert.ToInt32(t.TagId, CultureInfo.InvariantCulture); a.Tags.Add(it); } } if (post.mt_excerpt != null && post.mt_excerpt.Trim() != string.Empty) { a.Description = post.mt_excerpt; } // handle approval process if (ModuleBase.UseApprovalsForPortal(_portalId)) { if (ui.IsInRole(HostController.Instance.GetString(Utility.PublishAdminRole + _portalId)) || ui.IsSuperUser) { a.ApprovalStatusId = ApprovalStatus.Approved.GetId(); } else if (ui.IsInRole(HostController.Instance.GetString(Utility.PublishAuthorRole + _portalId))) { a.ApprovalStatusId = ApprovalStatus.Waiting.GetId(); } } a.Save(ui.UserID); return(a.ItemId.ToString()); } throw new XmlRpcFaultException(0, Localization.GetString("PostCategoryFailed.Text", LocalResourceFile)); } throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile)); }
///<summary> /// Add a new blog post /// </summary> /// <param name="blogid">Blogid</param> /// <param name="username">username</param> /// <param name="password">password</param> /// <param name="post">post</param> /// <param name="publish">publish</param> string IMetaWeblog.AddPost(string blogid, string username, string password, Post post, bool publish) { LocatePortal(Context.Request); DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password); if (ui != null) { //TODO: we need a default category for users, then we can allow theme detection in WLW var pc = new List<Publish.Category>(); foreach (string s in post.categories) { Publish.Category c = Publish.Category.GetCategory(s, PortalId); pc.Add(c); } //This only works for the first category, how should we handle other categories? if (pc.Count < 1) { Publish.Category c = Publish.Category.GetCategory(ModuleBase.DefaultCategoryForPortal(PortalId), PortalId); pc.Add(c); } if (pc.Count > 0) { //get description //string description = post.description.Substring(0,post.description.IndexOf(" //look for <!--pagebreak--> Article a = Article.Create(post.title, post.description, post.description, ui.UserID, pc[0].ItemId, pc[0].ModuleId, pc[0].PortalId); //TODO: check if dateCreated is a valid date //TODO: date Created is coming in as UTC time //TODO: re-enable Date created //a.StartDate = post.dateCreated.ToString(); a.VersionDescription = Localization.GetString("MetaBlogApi", LocalResourceFile); if (pc.Count > 1) { for (int i = 1; i < pc.Count; i++) { var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(), ParentItemId = pc[i].ItemId }; a.Relationships.Add(irel); } } //check for tags if (post.mt_keywords!=null && post.mt_keywords.Trim() != string.Empty) { //split tags foreach (Tag t in Tag.ParseTags(post.mt_keywords, _portalId)) { ItemTag it = ItemTag.Create(); it.TagId = Convert.ToInt32(t.TagId, CultureInfo.InvariantCulture); a.Tags.Add(it); } } if (post.mt_excerpt!=null && post.mt_excerpt.Trim() != string.Empty) { a.Description = post.mt_excerpt; } // handle approval process if (ModuleBase.UseApprovalsForPortal(_portalId)) { if (ui.IsInRole(HostController.Instance.GetString(Utility.PublishAdminRole + _portalId)) || ui.IsSuperUser) { a.ApprovalStatusId = ApprovalStatus.Approved.GetId(); } else if (ui.IsInRole(HostController.Instance.GetString(Utility.PublishAuthorRole + _portalId))) { a.ApprovalStatusId = ApprovalStatus.Waiting.GetId(); } } a.Save(ui.UserID); return a.ItemId.ToString(); } throw new XmlRpcFaultException(0, Localization.GetString("PostCategoryFailed.Text", LocalResourceFile)); } throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile)); }