private void TabFromScreen(NewsArticlesFriendlyUrlProviderInfo provider, RepeaterItem item, Hashtable allHashTables) { if (item != null) { HiddenField hdnTabid = (HiddenField)item.FindControl("hdnTabId"); if (hdnTabid != null) { string tabIdStr = hdnTabid.Value; //get the values from the drop downs SetHashTableFromDropDownValue(tabIdStr, item, allHashTables, "articleUrlStyle", "ddlArticleUrlStyle"); SetHashTableFromDropDownValue(tabIdStr, item, allHashTables, "articleUrlSource", "ddlArticleUrlSource"); SetHashTableFromDropDownValue(tabIdStr, item, allHashTables, "categoryUrlStyle", "ddlCategoryUrlStyle"); SetHashTableFromDropDownValue(tabIdStr, item, allHashTables, "authorUrlStyle", "ddlAuthorUrlStyle"); SetHashTableFromDropDownValue(tabIdStr, item, allHashTables, "pageUrlStyle", "ddlPageUrlStyle"); int tabIdInt = -1; if (int.TryParse(tabIdStr, out tabIdInt)) { if (tabIdInt > -1) { //check if tabis marked as the noDnnPagePath CheckBox chkNoDnnPagePath = (CheckBox)item.FindControl("chkNoDnnPagePath"); if (chkNoDnnPagePath != null && chkNoDnnPagePath.Checked) { provider.Settings["NoDnnPagePathTabId"] = tabIdInt.ToString(); } } } } } }
private void SetProviderProperty(NewsArticlesFriendlyUrlProviderInfo provider, Hashtable allHashtables, string providerPropertyName, string attributeName) { //use reflection to get the property System.Reflection.PropertyInfo settingProperty = provider.GetType().GetProperty(providerPropertyName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (settingProperty != null && settingProperty.CanWrite) { //get hash table from list of all hashtables for all settings Hashtable settingHashTable = (Hashtable)allHashtables[attributeName]; //get delimited string of all contents of setting hash table string settingValue = GetDelimitedString(settingHashTable, ",", ";"); //set provider property with hashtable values settingProperty.SetValue(provider, settingValue, null); } }
/// <summary> /// Constructor for the NewsArticles Url Provider. This is called by the Url Master module when loading the Provider /// </summary> /// <param name="name">Name is supplied from the web.config file, and specifies the unique name of the provider</param> /// <param name="attributes">Attributes are the xml attributes from the file</param> /// <param name="portalId">The portalId is supplied for the calling portal. Each instance of the provider is portal specific.</param> // public NewsArticlesFriendlyUrlProvider(string name, NameValueCollection attributes, int portalId): base(name, attributes, portalId) public NewsArticlesFriendlyUrlProvider() : base() { var attributes = this.GetProviderPortalSettings(); //look for an attribute specifying which tab the module //will not use a page path for. There can only be one //tab specified per portal (because there is no page path, then it //can only be a single page, as the way of determining one dnn //page from another isn't in the reuqested Url) string noDnnPagePathTabRaw = attributes["noDnnPagePathTabId"]; int.TryParse(noDnnPagePathTabRaw, out _noDnnPagePathTabId); _urlPath = attributes["urlPath"]; bool.TryParse(attributes["redirectUrls"], out _redirectUrls); string startingArticleIdRaw = attributes["startingArticleId"]; if (!int.TryParse(startingArticleIdRaw, out _startingArticleId)) { _startingArticleId = 0; } var prInfo = new NewsArticlesFriendlyUrlProviderInfo(); //read in the different url styles for this instance _tabUrlOptions = new Dictionary <int, TabUrlOptions>(); var articleUrlStyles = TabUrlOptions.GetHashTableFromSetting(attributes["articleUrlStyle"], out _articleUrlStyle); var articleUrlSource = TabUrlOptions.GetHashTableFromSetting(attributes["articleUrlSource"], out _articleUrlSource); var pageUrlStyles = TabUrlOptions.GetHashTableFromSetting(attributes["pageUrlStyle"], out _pageUrlStyle); var authorUrlStyles = TabUrlOptions.GetHashTableFromSetting(attributes["authorUrlStyle"], out _authorUrlStyle); var categoryUrlStyles = TabUrlOptions.GetHashTableFromSetting(attributes["categoryUrlStyle"], out _categoryUrlStyle); if (prInfo.AllTabs) { _tabUrlOptions.Add(-1, new TabUrlOptions(-1, _startingArticleId, articleUrlStyles, articleUrlSource, pageUrlStyles, authorUrlStyles, categoryUrlStyles)); } foreach (int tabId in prInfo.TabIds) { //create a tab option for each set tab TabUrlOptions urlOptions = new TabUrlOptions(tabId, _startingArticleId, articleUrlStyles, articleUrlSource, pageUrlStyles, authorUrlStyles, categoryUrlStyles); _tabUrlOptions.Add(tabId, urlOptions); } }