/// <summary> /// Loads the item types. /// </summary> private void LoadItemTypes() { //item type can be changed by the project admin and the company admin. bool canEdit = !IsReadOnly && DisplayMode == CompleteItemHeaderDisplayMode.ItemDetails; divItemTypeSelect.Visible = canEdit; divItemTypeStatic.Visible = !canEdit; Data.ItemType itemType = this.GetBL <ItemBriefBL>().GetItemType(this.ItemTypeId); if (canEdit) { this.ddItemTypes.Items.Clear(); List <Data.ItemType> itemTypeList = Utils.GetALLItemTypes(); this.ddItemTypes.Items.Add(new ListItem(itemType.Name, ItemTypeId.ToString(CultureInfo.InvariantCulture))); ddItemTypes.SelectedIndex = 0; if (itemTypeList.Count > 0) { this.ddItemTypes.AddItemGroup("Change to:"); } foreach (var it in itemTypeList.OrderBy(it => it.Name)) { if (it.ItemTypeId != this.ItemTypeId) { this.ddItemTypes.Items.Add(new ListItem(it.Name, it.ItemTypeId.ToString(CultureInfo.InvariantCulture))); } } } else if (itemType != null) { lblItemType.Text = itemType.Name; } }
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 Page_Load(object sender, EventArgs e) { //PortalSettings ps = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; PortalSettings ps = Utility.GetPortalSettings(PortalId); Response.ContentType = "text/xml"; Response.ContentEncoding = Encoding.UTF8; var sw = new StringWriter(CultureInfo.InvariantCulture); var wr = new XmlTextWriter(sw); wr.WriteStartElement("rss"); wr.WriteAttributeString("version", "2.0"); wr.WriteAttributeString("xmlns:wfw", "http://wellformedweb.org/CommentAPI/"); wr.WriteAttributeString("xmlns:slash", "http://purl.org/rss/1.0/modules/slash/"); wr.WriteAttributeString("xmlns:dc", "http://purl.org/dc/elements/1.1/"); wr.WriteAttributeString("xmlns:trackback", "http://madskills.com/public/xml/rss/module/trackback/"); wr.WriteStartElement("channel"); wr.WriteElementString("title", ps.PortalName); if (ps.PortalAlias.HTTPAlias.IndexOf("http://", StringComparison.OrdinalIgnoreCase) == -1) { wr.WriteElementString("link", "http://" + ps.PortalAlias.HTTPAlias); } else { wr.WriteElementString("link", ps.PortalAlias.HTTPAlias); } wr.WriteElementString("description", "RSS Feed for " + ps.PortalName); wr.WriteElementString("ttl", "120"); //TODO: look into options for how to display the "Title" of the RSS feed var dt = new DataTable { Locale = CultureInfo.InvariantCulture }; if (DisplayType == "ItemListing" || DisplayType == null) { dt = ItemId == -1 ? DataProvider.Instance().GetMostRecent(ItemTypeId, NumberOfItems, PortalId) : DataProvider.Instance().GetMostRecentByCategoryId(ItemId, ItemTypeId, NumberOfItems, PortalId); } else if (DisplayType == "CategoryFeature") { DataSet ds = DataProvider.Instance().GetParentItems(ItemId, PortalId, RelationshipTypeId); dt = ds.Tables[0]; } else if (DisplayType == "TagFeed") { if (AllowTags && _tagQuery != null && _tagQuery.Count > 0) { string tagCacheKey = Utility.CacheKeyPublishTag + PortalId + ItemTypeId.ToString(CultureInfo.InvariantCulture) + _qsTags; // +"PageId"; dt = DataCache.GetCache(tagCacheKey) as DataTable; if (dt == null) { //ToDo: we need to make getitemsfromtags use the numberofitems value dt = Tag.GetItemsFromTags(PortalId, _tagQuery); //TODO: we should sort the tags //TODO: should we set a 5 minute cache on RSS? DataCache.SetCache(tagCacheKey, dt, DateTime.Now.AddMinutes(5)); Utility.AddCacheKey(tagCacheKey, PortalId); } } } if (dt != null) { DataView dv = dt.DefaultView; if (dv.Table.Columns.IndexOf("dateColumn") > 0) { dv.Table.Columns.Add("dateColumn", typeof(DateTime)); foreach (DataRowView dr in dv) { dr["dateColumn"] = Convert.ToDateTime(dr["startdate"]); } dv.Sort = " dateColumn desc "; } for (int i = 0; i < dv.Count; i++) { //DataRow r = dt.Rows[i]; DataRow r = dv[i].Row; wr.WriteStartElement("item"); // wr.WriteElementString("slash:comments", objArticle.CommentCount.ToString()); // wr.WriteElementString("wfw:commentRss", "http://" & Request.Url.Host & Me.ResolveUrl("RssComments.aspx?TabID=" & m_tabID & "&ModuleID=" & m_moduleID & "&ArticleID=" & objArticle.ArticleID.ToString()).Replace(" ", "%20")); // wr.WriteElementString("trackback:ping", "http://" & Request.Url.Host & Me.ResolveUrl("Tracking/Trackback.aspx?ArticleID=" & objArticle.ArticleID.ToString() & "&PortalID=" & _portalSettings.PortalId.ToString() & "&TabID=" & _portalSettings.ActiveTab.TabID.ToString()).Replace(" ", "%20")); string title = String.Empty, description = String.Empty, childItemId = String.Empty, thumbnail = String.Empty, guid = String.Empty, author = string.Empty; DateTime startDate = DateTime.MinValue; if (DisplayType == null || string.Equals(DisplayType, "ItemListing", StringComparison.OrdinalIgnoreCase) || string.Equals(DisplayType, "TagFeed", StringComparison.OrdinalIgnoreCase)) { title = r["ChildName"].ToString(); description = r["ChildDescription"].ToString(); childItemId = r["ChilditemId"].ToString(); guid = r["itemVersionIdentifier"].ToString(); startDate = (DateTime)r["StartDate"]; thumbnail = r["Thumbnail"].ToString(); author = r["Author"].ToString(); //UserController uc = new UserController(); //UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(r["AuthorUserId"].ToString())); //if(ui!=null) //author = ui.DisplayName; } else if (string.Equals(DisplayType, "CategoryFeature", StringComparison.OrdinalIgnoreCase)) { title = r["Name"].ToString(); description = r["Description"].ToString(); childItemId = r["itemId"].ToString(); guid = r["itemVersionIdentifier"].ToString(); startDate = (DateTime)r["StartDate"]; thumbnail = r["Thumbnail"].ToString(); author = r["Author"].ToString(); //UserController uc = new UserController(); //UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(r["AuthorUserId"].ToString())); //if (ui != null) //author = ui.DisplayName; } if (!Uri.IsWellFormedUriString(thumbnail, UriKind.Absolute) && thumbnail != string.Empty) { var thumnailLink = new Uri(Request.Url, ps.HomeDirectory + thumbnail); thumbnail = thumnailLink.ToString(); } wr.WriteElementString("title", title); //if the item isn't disabled add the link if (!Utility.IsDisabled(Convert.ToInt32(childItemId, CultureInfo.InvariantCulture), PortalId)) { wr.WriteElementString("link", Utility.GetItemLinkUrl(childItemId, PortalId)); } //wr.WriteElementString("description", Utility.StripTags(this.Server.HtmlDecode(description))); description = Utility.ReplaceTokens(description); wr.WriteElementString("description", Server.HtmlDecode(description)); //wr.WriteElementString("author", Utility.StripTags(this.Server.HtmlDecode(author))); wr.WriteElementString("thumbnail", thumbnail); wr.WriteElementString("dc:creator", author); wr.WriteElementString("pubDate", startDate.ToUniversalTime().ToString("r", CultureInfo.InvariantCulture)); //file attachment enclosure ItemVersionSetting attachmentSetting = ItemVersionSetting.GetItemVersionSetting(Convert.ToInt32(r["ItemVersionId"].ToString()), "ArticleSettings", "ArticleAttachment", PortalId); if (attachmentSetting != null) { if (attachmentSetting.PropertyValue.Length > 7) { //var fileController = new FileController(); var fileManager = new FileManager(); int fileId = Convert.ToInt32(attachmentSetting.PropertyValue.Substring(7)); var fi = fileManager.GetFile(fileId); //fileController.GetFileById(fileId, PortalId); string fileurl = "http://" + PortalSettings.PortalAlias.HTTPAlias + PortalSettings.HomeDirectory + fi.Folder + fi.FileName; wr.WriteStartElement("enclosure"); wr.WriteAttributeString("url", fileurl); wr.WriteAttributeString("length", fi.Size.ToString()); wr.WriteAttributeString("type", fi.ContentType); wr.WriteEndElement(); } } wr.WriteStartElement("guid"); wr.WriteAttributeString("isPermaLink", "false"); wr.WriteString(guid); //wr.WriteString(itemVersionId); wr.WriteEndElement(); wr.WriteEndElement(); } } wr.WriteEndElement(); wr.WriteEndElement(); Response.Write(sw.ToString()); }