private string GetLists() { StringBuilder sb = new StringBuilder(); DotNetNuke.Common.Lists.ListController lists = new DotNetNuke.Common.Lists.ListController(); //Dim list As DotNetNuke DotNetNuke.Common.Lists.ListInfoCollection lc = lists.GetListInfoCollection(string.Empty, string.Empty, PortalId); foreach (DotNetNuke.Common.Lists.ListInfo l in lc) { if (l.PortalID == PortalId) { sb.Append("{"); sb.Append(Utilities.JSON.Pair("listname", l.Name)); sb.Append(","); sb.Append(Utilities.JSON.Pair("listid", l.Key)); sb.Append("},"); } } string sOut = sb.ToString(); if (sOut.EndsWith(",")) { sOut = sOut.Substring(0, sOut.Length - 1); sOut = "[" + sOut + "]"; } return(sOut); }
protected override void OnInit (EventArgs e) { base.OnInit (e); // set URL for cancel button linkCancel.NavigateUrl = Globals.NavigateURL (); // Add the "are you sure" message to the delete button click event cmdDelete.Attributes.Add ("onClick", "javascript:return confirm('" + Localization.GetString ("DeleteItem") + "');"); // Configure categories entry as a list or textbox, based on user settings if (DocumentsSettings.UseCategoriesList) { // Configure category entry as a list lstCategory.Visible = true; txtCategory.Visible = false; // Populate categories list var _with1 = new DotNetNuke.Common.Lists.ListController (); lstCategory.DataSource = _with1.GetListEntryInfoItems (DocumentsSettings.CategoriesListName); lstCategory.DataTextField = "Text"; lstCategory.DataValueField = "Value"; lstCategory.DataBind (); lstCategory.Items.Insert (0, new System.Web.UI.WebControls.ListItem (Localization.GetString ("None_Specified"), "-1")); } else { // Configure category entry as a free-text entry lstCategory.Visible = false; txtCategory.Visible = true; } }
private void CreateCountryCheckBoxList(Control container, XmlNode xmlNod) { try { var cbl = new CheckBoxList(); cbl = (CheckBoxList)GenXmlFunctions.AssignByReflection(cbl, xmlNod); var selected = false; if (xmlNod.Attributes != null && (xmlNod.Attributes["selected"] != null)) { if (xmlNod.Attributes["selected"].InnerText.ToLower() == "true") { selected = true; } } var objCtrl = new DotNetNuke.Common.Lists.ListController(); var tList = objCtrl.GetListEntryInfoDictionary("Country"); foreach (var tItem in tList) { var li = new ListItem(); li.Text = tItem.Value.Text; li.Value = tItem.Key; li.Selected = selected; cbl.Items.Add(li); } cbl.DataBinding += CbListDataBinding; container.Controls.Add(cbl); } catch (Exception e) { var lc = new Literal(); lc.Text = e.ToString(); container.Controls.Add(lc); } }
private string GetLists() { StringBuilder sb = new StringBuilder(); DotNetNuke.Common.Lists.ListController lists = new DotNetNuke.Common.Lists.ListController(); //Dim list As DotNetNuke DotNetNuke.Common.Lists.ListInfoCollection lc = lists.GetListInfoCollection(string.Empty, string.Empty, PortalId); foreach (DotNetNuke.Common.Lists.ListInfo l in lc) { if (l.PortalID == PortalId) { sb.Append("{"); sb.Append(Utilities.JSON.Pair("listname", l.Name)); sb.Append(","); sb.Append(Utilities.JSON.Pair("listid", l.Key)); sb.Append("},"); } } string sOut = sb.ToString(); if (sOut.EndsWith(",")) { sOut = sOut.Substring(0, sOut.Length - 1); sOut = "[" + sOut + "]"; } return sOut; }
private string LoadTopic() { int topicId = -1; int forumId = -1; if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"])) { topicId = int.Parse(Params["topicid"].ToString()); } if (topicId > 0) { TopicsController tc = new TopicsController(); TopicInfo t = tc.Topics_Get(PortalId, ModuleId, topicId); Data.ForumsDB db = new Data.ForumsDB(); forumId = db.Forum_GetByTopicId(topicId); ForumController fc = new ForumController(); Forum f = fc.Forums_Get(PortalId, -1, forumId, this.UserId, true, false, -1); if (f != null) { if (Permissions.HasPerm(f.Security.ModEdit, ForumUser.UserRoles)) { StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.Append(Utilities.JSON.Pair("topicid", t.TopicId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("subject", t.Content.Subject)); sb.Append(","); sb.Append(Utilities.JSON.Pair("authorid", t.Content.AuthorId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("locked", t.IsLocked.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("pinned", t.IsPinned.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("priority", t.Priority.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("status", t.StatusId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("forumid", forumId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("forumname", f.ForumName)); sb.Append(","); sb.Append(Utilities.JSON.Pair("tags", t.Tags)); sb.Append(","); sb.Append(Utilities.JSON.Pair("categories", t.Categories)); sb.Append(","); sb.Append("\"properties\":["); string sCats = string.Empty; if (f.Properties != null) { int i = 0; foreach (PropertiesInfo p in f.Properties) { sb.Append("{"); sb.Append(Utilities.JSON.Pair("propertyid", p.PropertyId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("datatype", p.DataType)); sb.Append(","); sb.Append(Utilities.JSON.Pair("propertyname", p.Name)); sb.Append(","); string pvalue = p.DefaultValue; foreach (PropertiesInfo tp in t.TopicProperties) { if (tp.PropertyId == p.PropertyId) { pvalue = tp.DefaultValue; } } sb.Append(Utilities.JSON.Pair("propertyvalue", pvalue)); if (p.DataType.Contains("list")) { sb.Append(",\"listdata\":["); if (p.DataType.Contains("list|categories")) { using (IDataReader dr = DataProvider.Instance().Tags_List(PortalId, f.ModuleId, true, 0, 200, "ASC", "TagName", forumId, f.ForumGroupId)) { dr.NextResult(); while (dr.Read()) { sCats += "{"; sCats += Utilities.JSON.Pair("id", dr["TagId"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("name", dr["TagName"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("selected", IsSelected(dr["TagName"].ToString(), t.Categories).ToString()); sCats += "},"; } dr.Close(); } if (! (string.IsNullOrEmpty(sCats))) { sCats = sCats.Substring(0, sCats.Length - 1); } sb.Append(sCats); } else { DotNetNuke.Common.Lists.ListController lists = new DotNetNuke.Common.Lists.ListController(); string lName = p.DataType.Substring(p.DataType.IndexOf("|") + 1); DotNetNuke.Common.Lists.ListEntryInfoCollection lc = lists.GetListEntryInfoCollection(lName, string.Empty); int il = 0; foreach (DotNetNuke.Common.Lists.ListEntryInfo l in lc) { sb.Append("{"); sb.Append(Utilities.JSON.Pair("itemId", l.Value)); sb.Append(","); sb.Append(Utilities.JSON.Pair("itemName", l.Text)); sb.Append("}"); il += 1; if (il < lc.Count) { sb.Append(","); } } } sb.Append("]"); } sb.Append("}"); i += 1; if (i < f.Properties.Count) { sb.Append(","); } } } sb.Append("],\"categories\":["); sCats = string.Empty; using (IDataReader dr = DataProvider.Instance().Tags_List(PortalId, f.ModuleId, true, 0, 200, "ASC", "TagName", forumId, f.ForumGroupId)) { dr.NextResult(); while (dr.Read()) { sCats += "{"; sCats += Utilities.JSON.Pair("id", dr["TagId"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("name", dr["TagName"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("selected", IsSelected(dr["TagName"].ToString(), t.Categories).ToString()); sCats += "},"; } dr.Close(); } if (! (string.IsNullOrEmpty(sCats))) { sCats = sCats.Substring(0, sCats.Length - 1); } sb.Append(sCats); sb.Append("]"); sb.Append("}"); return BuildOutput(sb.ToString(), OutputCodes.Success, true, true); } } } return BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false); }
private string LoadTopic() { int topicId = -1; int forumId = -1; if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"])) { topicId = int.Parse(Params["topicid"].ToString()); } if (topicId > 0) { TopicsController tc = new TopicsController(); TopicInfo t = tc.Topics_Get(PortalId, ModuleId, topicId); Data.ForumsDB db = new Data.ForumsDB(); forumId = db.Forum_GetByTopicId(topicId); ForumController fc = new ForumController(); Forum f = fc.Forums_Get(PortalId, -1, forumId, this.UserId, true, false, -1); if (f != null) { if (Permissions.HasPerm(f.Security.ModEdit, ForumUser.UserRoles)) { StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.Append(Utilities.JSON.Pair("topicid", t.TopicId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("subject", t.Content.Subject)); sb.Append(","); sb.Append(Utilities.JSON.Pair("authorid", t.Content.AuthorId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("locked", t.IsLocked.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("pinned", t.IsPinned.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("priority", t.Priority.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("status", t.StatusId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("forumid", forumId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("forumname", f.ForumName)); sb.Append(","); sb.Append(Utilities.JSON.Pair("tags", t.Tags)); sb.Append(","); sb.Append(Utilities.JSON.Pair("categories", t.Categories)); sb.Append(","); sb.Append("\"properties\":["); string sCats = string.Empty; if (f.Properties != null) { int i = 0; foreach (PropertiesInfo p in f.Properties) { sb.Append("{"); sb.Append(Utilities.JSON.Pair("propertyid", p.PropertyId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("datatype", p.DataType)); sb.Append(","); sb.Append(Utilities.JSON.Pair("propertyname", p.Name)); sb.Append(","); string pvalue = p.DefaultValue; foreach (PropertiesInfo tp in t.TopicProperties) { if (tp.PropertyId == p.PropertyId) { pvalue = tp.DefaultValue; } } sb.Append(Utilities.JSON.Pair("propertyvalue", pvalue)); if (p.DataType.Contains("list")) { sb.Append(",\"listdata\":["); if (p.DataType.Contains("list|categories")) { using (IDataReader dr = DataProvider.Instance().Tags_List(PortalId, f.ModuleId, true, 0, 200, "ASC", "TagName", forumId, f.ForumGroupId)) { dr.NextResult(); while (dr.Read()) { sCats += "{"; sCats += Utilities.JSON.Pair("id", dr["TagId"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("name", dr["TagName"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("selected", IsSelected(dr["TagName"].ToString(), t.Categories).ToString()); sCats += "},"; } dr.Close(); } if (!(string.IsNullOrEmpty(sCats))) { sCats = sCats.Substring(0, sCats.Length - 1); } sb.Append(sCats); } else { DotNetNuke.Common.Lists.ListController lists = new DotNetNuke.Common.Lists.ListController(); string lName = p.DataType.Substring(p.DataType.IndexOf("|") + 1); DotNetNuke.Common.Lists.ListEntryInfoCollection lc = lists.GetListEntryInfoCollection(lName, string.Empty); int il = 0; foreach (DotNetNuke.Common.Lists.ListEntryInfo l in lc) { sb.Append("{"); sb.Append(Utilities.JSON.Pair("itemId", l.Value)); sb.Append(","); sb.Append(Utilities.JSON.Pair("itemName", l.Text)); sb.Append("}"); il += 1; if (il < lc.Count) { sb.Append(","); } } } sb.Append("]"); } sb.Append("}"); i += 1; if (i < f.Properties.Count) { sb.Append(","); } } } sb.Append("],\"categories\":["); sCats = string.Empty; using (IDataReader dr = DataProvider.Instance().Tags_List(PortalId, f.ModuleId, true, 0, 200, "ASC", "TagName", forumId, f.ForumGroupId)) { dr.NextResult(); while (dr.Read()) { sCats += "{"; sCats += Utilities.JSON.Pair("id", dr["TagId"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("name", dr["TagName"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("selected", IsSelected(dr["TagName"].ToString(), t.Categories).ToString()); sCats += "},"; } dr.Close(); } if (!(string.IsNullOrEmpty(sCats))) { sCats = sCats.Substring(0, sCats.Length - 1); } sb.Append(sCats); sb.Append("]"); sb.Append("}"); return(BuildOutput(sb.ToString(), OutputCodes.Success, true, true)); } } } return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false)); }
public static Dictionary<String, String> GetRegionList(String countrycode, String dnnlistname = "Region") { var resxpath = StoreSettings.NBrightBuyPath() + "/App_LocalResources/RegionNames.ascx.resx"; var parentkey = "Country." + countrycode; var objCtrl = new DotNetNuke.Common.Lists.ListController(); var tList = objCtrl.GetListEntryInfoDictionary(dnnlistname, parentkey); var rtnDic = new Dictionary<String, String>(); foreach (var r in tList) { var datavalue = r.Value; var regionname = DnnUtils.GetLocalizedString(datavalue.Text, resxpath, Utils.GetCurrentCulture()); if (String.IsNullOrEmpty(regionname)) regionname = datavalue.Text; rtnDic.Add(datavalue.Key, regionname); } return rtnDic; }
public static Dictionary<String, String> GetCountryList(String dnnlistname = "Country") { var resxpath = StoreSettings.NBrightBuyPath() + "/App_LocalResources/CountryNames.ascx.resx"; var objCtrl = new DotNetNuke.Common.Lists.ListController(); var tList = objCtrl.GetListEntryInfoDictionary(dnnlistname); var rtnDic = new Dictionary<String, String>(); var xmlNodeList = StoreSettings.Current.SettingsInfo.XMLDoc.SelectNodes("genxml/checkboxlist/countrycodelist/chk[@value='True']"); if (xmlNodeList != null) { foreach (XmlNode xmlNoda in xmlNodeList) { if (xmlNoda.Attributes != null) { if (xmlNoda.Attributes.GetNamedItem("data") != null) { var datavalue = xmlNoda.Attributes["data"].Value; //use the data attribute if there if (tList.ContainsKey(datavalue)) { var countryname = DnnUtils.GetLocalizedString(datavalue, resxpath, Utils.GetCurrentCulture()); if (String.IsNullOrEmpty(countryname)) countryname = tList[datavalue].Text; rtnDic.Add(datavalue.Replace(dnnlistname + ":", ""),countryname); } } } } } var sortlist = StoreSettings.Current.Get("countrysortorder"); if (sortlist == "") return rtnDic; var rtnSort = new Dictionary<String, String>(); var s = sortlist.Split(';'); foreach (var c in s) { if (c != "") { if (rtnDic.ContainsKey(c)) { var d = rtnDic[c]; rtnSort.Add(c,d); rtnDic.Remove(c); } } } foreach (var c in rtnDic) { rtnSort.Add(c.Key,c.Value); } return rtnSort; }
public void LoadLists () { var _with2 = new DotNetNuke.Common.Lists.ListController (); foreach (DotNetNuke.Common.Lists.ListInfo objList in _with2.GetListInfoCollection()) { if (!objList.SystemList) { // for some reason, the "DataType" is not marked as a system list, but we want to exclude that one too if (objList.DisplayName != "DataType") { cboCategoriesList.Items.Add (new ListItem (objList.DisplayName, objList.DisplayName)); } } } if (cboCategoriesList.Items.Count == 0) { lstNoListsAvailable.Text = Localization.GetString ("msgNoListsAvailable.Text", base.LocalResourceFile); lstNoListsAvailable.Visible = true; } }