internal override void GetActiveForumsReplies(int tabId, out FriendlyUrlInfoCol urls) { urls = new FriendlyUrlInfoCol(); var dr = SqlHelper.ExecuteReader(_connectionString, CommandType.Text, "select oldpostid, newreplyid, nr.topicid, nr.ContentId from " + GetFullyQualifiedName("dnntoaf_replies") + " r join " + GetFullyQualifiedName("ActiveForums_Replies") + " nr on (r.newreplyid=nr.replyid)"); while (dr.Read()) { var url = new FriendlyUrlInfo(); if (!Convert.IsDBNull(dr["newReplyId"])) { url.newId = Convert.ToInt32(dr["newReplyId"]); } if (!Convert.IsDBNull(dr["oldPostId"])) { url.itemId = (int)dr["oldPostId"]; } if (!Convert.IsDBNull(dr["TopicId"])) { url.newParentId = Convert.ToInt32(dr["TopicId"]); } if (!Convert.IsDBNull(dr["ContentId"])) { url.newContentId = Convert.ToInt32(dr["ContentId"]); } urls.Add(url); } dr.Close(); dr.Dispose(); }
internal override void GetSocialUrls(int portalId, out FriendlyUrlInfoCol urls) { urls = new FriendlyUrlInfoCol(); string sp = GetFullyQualifiedName("GetSocialUrls"); SqlParameter[] parms = new SqlParameter[1]; parms[0] = new SqlParameter("@portalId", portalId); SqlDataReader rdr = SqlHelper.ExecuteReader(_connectionString, CommandType.StoredProcedure, sp, parms); while (rdr.Read()) { FriendlyUrlInfo url = new FriendlyUrlInfo(); if (!Convert.IsDBNull(rdr["UrlFragment1"])) { url.UrlFragment1 = (string)rdr["UrlFragment1"]; } if (!Convert.IsDBNull(rdr["UrlFragment2"])) { url.UrlFragment2 = (string)rdr["UrlFragment2"]; } if (!Convert.IsDBNull(rdr["ItemType"])) { url.ItemType = (string)rdr["ItemType"]; } if (!Convert.IsDBNull(rdr["ItemId"])) { url.ItemId = (int)rdr["ItemId"]; } //add to collection urls.Add(url); } rdr.Close(); rdr.Dispose(); }
internal override void GetActiveForumsThreads(int tabId, out FriendlyUrlInfoCol urls) { urls = new FriendlyUrlInfoCol(); var dr = SqlHelper.ExecuteReader(_connectionString, CommandType.Text, "select * from " + GetFullyQualifiedName("dnntoaf_topics")); while (dr.Read()) { var url = new FriendlyUrlInfo(); if (!Convert.IsDBNull(dr["newTopicId"])) { url.newId = Convert.ToInt32(dr["newTopicId"]); } if (!Convert.IsDBNull(dr["oldPostId"])) { url.itemId = (int)dr["oldPostId"]; } urls.Add(url); } dr.Close(); dr.Dispose(); }
private static void BuildUrlIndexes(int portalId, SocialUrlProvider provider, FriendlyUrlOptions options, out Hashtable friendlyUrlIndex, out Hashtable queryStringIndex) { friendlyUrlIndex = new Hashtable(); queryStringIndex = new Hashtable(); //call database procedure to get list of FriendlyUrlInfoCol itemUrls = null; Data.DataProvider.Instance().GetSocialUrls(portalId, out itemUrls); List <TabInfo> childTabs = null; TabController tc = new TabController(); TabInfo groupParentTab = null; string groupParentTabPath = null; //get a list of child tabs for this request if (provider.GroupPagePathTabId > 0 && provider.HideGroupPagePath) { childTabs = DotNetNuke.Entities.Tabs.TabController.GetTabsByParent(provider.GroupPagePathTabId, portalId); groupParentTab = tc.GetTab(provider.GroupPagePathTabId, portalId, false); groupParentTabPath = provider.CleanNameForUrl(groupParentTab.TabName, options); } if (itemUrls != null) { //build up the dictionary foreach (FriendlyUrlInfo itemUrl in itemUrls) { //friendly url index - look up by entryid, find Url string furlKey = itemUrl.ItemKey; string furlValue = MakeItemFriendlyUrl(itemUrl, provider, options); if (friendlyUrlIndex.ContainsKey(furlKey) == false) { friendlyUrlIndex.Add(furlKey, furlValue); } //querystring index - look up by url, find querystring for the item string qsKey = furlValue.ToLower(); //the querystring lookup is the friendly Url value - but converted to lower case string itemQueryString = "&" + itemUrl.QueryStringKey + "=" + itemUrl.ItemId.ToString(); //the querystring that is rewritten for the url string qsValue = itemQueryString; //when not including the dnn page path into the friendly Url, then include the tabid in the querystring if (itemUrl.ItemType.ToLower() == "group" && provider.HideGroupPagePath == true && provider.GroupPagePathTabId > 0) { qsValue = "?TabId=" + provider.GroupPagePathTabId.ToString() + qsValue; } if (queryStringIndex.ContainsKey(qsKey) == false) { queryStringIndex.Add(qsKey, qsValue); } //if the options aren't standard, also add in some other versions that will identify the right entry but will get redirected if (options.PunctuationReplacement != "") { FriendlyUrlOptions altOptions = options.Clone(); altOptions.PunctuationReplacement = ""; //how the urls look with no replacement string altQsKey = MakeItemFriendlyUrl(itemUrl, provider, altOptions).ToLower(); //keys are always lowercase if (altQsKey != qsKey) { if (queryStringIndex.ContainsKey(altQsKey) == false) { queryStringIndex.Add(altQsKey, qsValue); } } } //now repeat for the child tabs if (childTabs != null && childTabs.Count > 0 && groupParentTab != null) { //derive the path of the child tabs in with the parent tab, and build up a set of urls that include the group name and the child tab name foreach (TabInfo childTab in childTabs) { string childPath = provider.CleanNameForUrl(childTab.TabName, options);//gets the cleaned tab name childPath = furlValue + "/" + provider.EnsureNotLeadingChar("/", childPath); //the child path is the user + the child tab path //add rewriting values string cpQsValue = "?TabId=" + childTab.TabID.ToString() + itemQueryString; string cpQsKey = childPath.ToLower(); if (queryStringIndex.ContainsKey(cpQsKey) == false) { queryStringIndex.Add(cpQsKey, cpQsValue); } //add friendly url paths string cpFurlKey = "t" + childTab.TabID.ToString() + furlKey; string cpFurlValue = childPath; if (friendlyUrlIndex.ContainsKey(cpFurlKey) == false) { friendlyUrlIndex.Add(cpFurlKey, cpFurlValue); } //add alternatives if (options.PunctuationReplacement != "") { FriendlyUrlOptions altOptions = options.Clone(); altOptions.PunctuationReplacement = ""; //how the urls look with no replacement string altQsKey = childPath + "/" + MakeItemFriendlyUrl(itemUrl, provider, altOptions).ToLower(); //keys are always lowercase if (altQsKey != qsKey) { if (queryStringIndex.ContainsKey(altQsKey) == false) { queryStringIndex.Add(altQsKey, cpQsValue); } } } } } } } }
/// <summary> /// Returns list of Urls related to your module /// </summary> /// <param name="tabId">The tabid the module is on.</param> /// <param name="entries">out parameter returns a zero-n list of NewsArticles Urls</param> /// <remarks>Example only - this call can be anything you like.</remarks> internal abstract void GetNewsArticlesItemsForTab(int tabId, TabUrlOptions urlOptions, out FriendlyUrlInfoCol urls, out NewsArticleOptions naOptions);
internal override void GetNewsArticlesItemsForTab(int tabId, TabUrlOptions urlOptions, out FriendlyUrlInfoCol urls, out NewsArticleOptions naOptions) { urls = new FriendlyUrlInfoCol(); string sp = GetFullyQualifiedName("GetNewsArticlesEntriesForTab"); SqlParameter[] parms = new SqlParameter[2]; parms[0] = new SqlParameter("@TabId", tabId); if (urlOptions != null) { parms[1] = new SqlParameter("@startingArticleId", urlOptions.StartingArticleId); } else { parms[1] = new SqlParameter("@startingArticleId", 0); } //call the db SqlDataReader rdr = SqlHelper.ExecuteReader(_connectionString, CommandType.StoredProcedure, sp, parms); //work out which url fragment to use string articleFragmentName = ""; string pageFragmentName = ""; string authorFragmentName = ""; GetFragmentNames(urlOptions, out articleFragmentName, out pageFragmentName, out authorFragmentName); while (rdr.Read()) { FriendlyUrlInfo fuf = new FriendlyUrlInfo(); BindReaderToFriendlyUrl(ref fuf, rdr, pageFragmentName, articleFragmentName, authorFragmentName); urls.Add(fuf); } //get any options in the mix naOptions = new NewsArticleOptions(); if (rdr.NextResult()) { /*AlwaysShowPageID False * SEOShorternID ID * SEOUrlMode Shorterned * TitleReplacementType Dash*/ //set defaults - module settings may not be there naOptions.TitleReplacement = "-"; while (rdr.Read()) { string settingName = (string)rdr["SettingName"]; string settingValue = (string)rdr["SettingValue"]; if (settingName != null) { switch (settingName.ToLower()) { case "seoshorternid": naOptions.SeoShortenId = settingValue; break; case "seourlmode": naOptions.SeoUrlMode = settingValue; break; case "titlereplacementtype": if (settingValue.ToLower() == "dash") { naOptions.TitleReplacement = "-"; } else { naOptions.TitleReplacement = "_"; } break; case "alwaysshowpageid": bool result = false; bool.TryParse(settingValue, out result); naOptions.AlwaysShowPageId = result; break; } } else { //no value, use defaults naOptions.TitleReplacement = "-"; naOptions.AlwaysShowPageId = false; } } } rdr.Close(); rdr.Dispose(); }
private static void BuildUrlIndexes(int tabId, int portalId, NewsArticlesModuleProvider provider, FriendlyUrlOptions options, TabUrlOptions urlOptions, out Hashtable friendlyUrlIndex, out Hashtable queryStringIndex) { if (urlOptions == null) { urlOptions = new TabUrlOptions(); urlOptions.RedirectOtherStyles = true; } friendlyUrlIndex = new Hashtable(); queryStringIndex = new Hashtable(); //call database procedure to get list of FriendlyUrlInfoCol itemUrls = null; NewsArticleOptions naOptions = null; //list of module settings for the NA module if (tabId > 0 && portalId > -1) //927 : don't call db for tabid -1, it doesn't exist { Data.DataProvider.Instance().GetNewsArticlesItemsForTab(tabId, urlOptions, out itemUrls, out naOptions); options.PunctuationReplacement = naOptions.TitleReplacement;//override value with NA setting Dictionary <string, string> categoryParents = new Dictionary <string, string>(); if (itemUrls != null) { //build up the dictionary foreach (FriendlyUrlInfo itemUrl in itemUrls) { string furlKey = itemUrl.FUrlKey; //querystring index - look up by url, find querystring for the item string furlValue = MakeItemFriendlyUrl(itemUrl, provider, options, urlOptions); string qsKey = furlValue.ToLower();//the querystring lookup is the friendly Url value - but converted to lower case string qsValue = null; string itemId = itemUrl.itemId.ToString(); string parentId = itemUrl.parentId.ToString(); switch (itemUrl.itemType.ToLower()) { case "article": qsValue = "&articleType=ArticleView&articleId=" + itemId; //the querystring is just the entryId parameter break; case "page": qsValue = "&articleType=ArticleView&pageId=" + itemId + "&articleId=" + parentId; break; case "author": qsValue = "&articleType=AuthorView&authorId=" + itemId; break; case "category": qsValue = "&articleType=CategoryView&categoryId=" + itemId; if (parentId != "-1" && urlOptions.CategoryStyle == CategoryUrlStyle.CatHierarchy) { //this category has a parent categoryParents.Add(furlKey, itemUrl.FUrlPrefix + parentId); } break; case "archive": if (parentId == "-1") { //yearly qsValue = "&articleType=ArchiveView&year=" + itemId; } else { //monthly qsValue = "&articleType=ArchiveView&year=" + parentId + "&month=" + itemUrl.urlNum.ToString(); //url num holds the month } break; } //when not including the dnn page path into the friendly Url, then include the tabid in the querystring if (provider.AlwaysUsesDnnPagePath(portalId) == false) { qsValue = "?TabId=" + tabId.ToString() + qsValue; } string suffix = ""; AddUniqueUrlToIndex(furlKey, ref qsKey, qsValue, portalId, queryStringIndex, options, true, out suffix); //if the suffix for the qsKey was changed, we need to add it to the friendly url used for the friendly url index furlValue += suffix; //friendly url index - look up by entryid, find Url //check to see if friendly url matches any page paths if (friendlyUrlIndex.ContainsKey(furlKey) == false)//shouldn't return duplicate because content is controlled by module logic { friendlyUrlIndex.Add(furlKey, furlValue); } //if the options aren't standard, also add in some other versions that will identify the right entry but will get redirected if (options.PunctuationReplacement != "") { FriendlyUrlOptions altOptions = options.Clone(); altOptions.PunctuationReplacement = ""; //how the urls look with no replacement string altQsKey = MakeItemFriendlyUrl(itemUrl, provider, altOptions, urlOptions).ToLower(); //keys are always lowercase string altQsValue = qsValue + "&do301=true&&rr=Title_Space_Replacement"; AddUniqueUrlToIndex(furlKey, ref altQsKey, altQsValue, portalId, queryStringIndex, options, false, out suffix); } //now build the alternative for the redirects if (urlOptions.RedirectOtherStyles) { TabUrlOptions tempOptions = urlOptions.Clone(); if (urlOptions.ArticleStyle == ArticleUrlStyle.BlogStyle) { tempOptions.ArticleStyle = ArticleUrlStyle.TitleStyle; } else { tempOptions.ArticleStyle = ArticleUrlStyle.BlogStyle; } //get the Url for this alternate style string altArtQsKey = MakeItemFriendlyUrl(itemUrl, provider, options, tempOptions).ToLower(); string altArtQsValue = qsValue += "&do301=true&rr=Wrong_Article_Style"; AddUniqueUrlToIndex(furlKey, ref altArtQsKey, altArtQsValue, portalId, queryStringIndex, options, false, out suffix); } } //go back and recursively check for category parents to be updated if (categoryParents != null && categoryParents.Count > 0) { Dictionary <string, string> updates = new Dictionary <string, string>(); //reallocate the friendly urls recursively so that categories include their parent path foreach (string furlKey in categoryParents.Keys) { //got the key for the friendly url //now find the parent string parentKey = categoryParents[furlKey]; string childPath = (string)friendlyUrlIndex[furlKey]; string parentPath = GetParentPath(furlKey, parentKey, childPath, ref categoryParents, ref friendlyUrlIndex); if (parentPath != null) { childPath = parentPath + "/" + childPath; } updates.Add(furlKey, childPath);//don't update until all done } //now process the update list and update any values that had hierarchial categories foreach (string key in updates.Keys) { string oldVal = (string)friendlyUrlIndex[key]; string qsKey = oldVal.ToLower(); if (queryStringIndex.ContainsKey(qsKey)) { //update the querystring index string qsVal = (string)queryStringIndex[qsKey]; queryStringIndex.Remove(qsKey); queryStringIndex.Add(updates[key].ToLower(), qsVal); } //update the new friendly url index friendlyUrlIndex[key] = updates[key]; } } } } }
/// <summary> /// Returns list of Urls related to your module /// </summary> /// <param name="tabId">The tabid the module is on.</param> /// <param name="entries">out parameter returns a zero-n list of DNNSocialUrlProvider Urls</param> /// <remarks>Example only - this call can be anything you like.</remarks> internal abstract void GetSocialUrls(int portalid, out FriendlyUrlInfoCol urls);
private static void BuildUrlIndexes(int tabId, int portalId, ActiveForumsModuleProvider provider, FriendlyUrlOptions options, out Hashtable friendlyUrlIndex, out Hashtable queryStringIndex) { friendlyUrlIndex = new Hashtable(); queryStringIndex = new Hashtable(); //call database procedure to get list of FriendlyUrlInfoCol itemUrls = null; Data.DataProvider.Instance().GetActiveForumsGroups(tabId, out itemUrls); if (itemUrls != null) { //build up the dictionary for Groups foreach (FriendlyUrlInfo itemUrl in itemUrls) { //friendly url index - look up by entryid, find Url string furlKey = "groupi" + itemUrl.itemId.ToString(); //string furlValue = MakeItemFriendlyUrl(itemUrl, provider, options); if (friendlyUrlIndex.ContainsKey(furlKey) == false) { friendlyUrlIndex.Add(furlKey, "afg/" + itemUrl.newId); } ////querystring index - look up by url, find querystring for the item //string qsKey = furlValue.ToLower();//the querystring lookup is the friendly Url value - but converted to lower case //string qsValue = "&afg=" + itemUrl.itemId.ToString();//the querystring is just the entryId parameter ////when not including the dnn page path into the friendly Url, then include the tabid in the querystring //if (provider.AlwaysUsesDnnPagePath(portalId) == false) // qsValue = "?TabId=" + tabId.ToString() + qsValue; //if (queryStringIndex.ContainsKey(qsKey) == false) // queryStringIndex.Add(qsKey, qsValue); ////if the options aren't standard, also add in some other versions that will identify the right entry but will get redirected //if (options.PunctuationReplacement != "") //{ // FriendlyUrlOptions altOptions = options.Clone(); // altOptions.PunctuationReplacement = "";//how the urls look with no replacement // string altQsKey = MakeItemFriendlyUrl(itemUrl, provider, altOptions).ToLower();//keys are always lowercase // if (altQsKey != qsKey) // { // if (queryStringIndex.ContainsKey(altQsKey) == false) // queryStringIndex.Add(altQsKey, qsValue); // } //} } } Data.DataProvider.Instance().GetActiveForumsForums(tabId, out itemUrls); if (itemUrls != null) { //build up the dictionary for Groups foreach (FriendlyUrlInfo itemUrl in itemUrls) { //friendly url index - look up by entryid, find Url string furlKey = "forumi" + itemUrl.itemId.ToString(); //string furlValue = MakeItemFriendlyUrl(itemUrl, provider, options); if (friendlyUrlIndex.ContainsKey(furlKey) == false) { friendlyUrlIndex.Add(furlKey, "aff/" + itemUrl.newId); } ////querystring index - look up by url, find querystring for the item //string qsKey = furlValue.ToLower();//the querystring lookup is the friendly Url value - but converted to lower case //string qsValue = "&aff=" + itemUrl.itemId.ToString();//the querystring is just the entryId parameter ////when not including the dnn page path into the friendly Url, then include the tabid in the querystring //if (provider.AlwaysUsesDnnPagePath(portalId) == false) // qsValue = "?TabId=" + tabId.ToString() + qsValue; //if (queryStringIndex.ContainsKey(qsKey) == false) // queryStringIndex.Add(qsKey, qsValue); ////if the options aren't standard, also add in some other versions that will identify the right entry but will get redirected //if (options.PunctuationReplacement != "") //{ // FriendlyUrlOptions altOptions = options.Clone(); // altOptions.PunctuationReplacement = "";//how the urls look with no replacement // string altQsKey = MakeItemFriendlyUrl(itemUrl, provider, altOptions).ToLower();//keys are always lowercase // if (altQsKey != qsKey) // { // if (queryStringIndex.ContainsKey(altQsKey) == false) // queryStringIndex.Add(altQsKey, qsValue); // } //} } } Data.DataProvider.Instance().GetActiveForumsThreads(tabId, out itemUrls); if (itemUrls != null) { //build up the dictionary for Groups foreach (FriendlyUrlInfo itemUrl in itemUrls) { //friendly url index - look up by entryid, find Url string furlKey = "threadi" + itemUrl.itemId.ToString(); //string furlValue = MakeItemFriendlyUrl(itemUrl, provider, options); if (friendlyUrlIndex.ContainsKey(furlKey) == false) { friendlyUrlIndex.Add(furlKey, "aft/" + itemUrl.newId); } ////querystring index - look up by url, find querystring for the item //string qsKey = furlValue.ToLower();//the querystring lookup is the friendly Url value - but converted to lower case //string qsValue = "&aft=" + itemUrl.itemId.ToString();//the querystring is just the entryId parameter ////when not including the dnn page path into the friendly Url, then include the tabid in the querystring //if (provider.AlwaysUsesDnnPagePath(portalId) == false) // qsValue = "?TabId=" + tabId.ToString() + qsValue; //if (queryStringIndex.ContainsKey(qsKey) == false) // queryStringIndex.Add(qsKey, qsValue); ////if the options aren't standard, also add in some other versions that will identify the right entry but will get redirected //if (options.PunctuationReplacement != "") //{ // FriendlyUrlOptions altOptions = options.Clone(); // altOptions.PunctuationReplacement = "";//how the urls look with no replacement // string altQsKey = MakeItemFriendlyUrl(itemUrl, provider, altOptions).ToLower();//keys are always lowercase // if (altQsKey != qsKey) // { // if (queryStringIndex.ContainsKey(altQsKey) == false) // queryStringIndex.Add(altQsKey, qsValue); // } //} } } Data.DataProvider.Instance().GetActiveForumsReplies(tabId, out itemUrls); if (itemUrls != null) { //build up the dictionary for Groups foreach (FriendlyUrlInfo itemUrl in itemUrls) { //friendly url index - look up by entryid, find Url string furlKey = "replyi" + itemUrl.itemId.ToString(); //string furlValue = MakeItemFriendlyUrl(itemUrl, provider, options); if (friendlyUrlIndex.ContainsKey(furlKey) == false) { friendlyUrlIndex.Add(furlKey, "aft/" + itemUrl.newParentId + "#" + itemUrl.newContentId); } ////querystring index - look up by url, find querystring for the item //string qsKey = furlValue.ToLower();//the querystring lookup is the friendly Url value - but converted to lower case //string qsValue = "&aft=" + itemUrl.itemId.ToString();//the querystring is just the entryId parameter ////when not including the dnn page path into the friendly Url, then include the tabid in the querystring //if (provider.AlwaysUsesDnnPagePath(portalId) == false) // qsValue = "?TabId=" + tabId.ToString() + qsValue; //if (queryStringIndex.ContainsKey(qsKey) == false) // queryStringIndex.Add(qsKey, qsValue); //if the options aren't standard, also add in some other versions that will identify the right entry but will get redirected //if (options.PunctuationReplacement != "") //{ // FriendlyUrlOptions altOptions = options.Clone(); // altOptions.PunctuationReplacement = "";//how the urls look with no replacement // string altQsKey = MakeItemFriendlyUrl(itemUrl, provider, altOptions).ToLower();//keys are always lowercase // if (altQsKey != qsKey) // { // if (queryStringIndex.ContainsKey(altQsKey) == false) // queryStringIndex.Add(altQsKey, qsValue); // } //} } } }
internal abstract void GetActiveForumsReplies(int tabId, out FriendlyUrlInfoCol urls);