public static string GetCulturedUrlByTabName(string keyName, int portalId, string language) { try { var objTabController = new DotNetNuke.Entities.Tabs.TabController(); var tab = objTabController.GetTabByName(keyName, portalId); if (tab != null) { Locale locale = LocaleController.Instance.GetLocale(language); var culturedTab = objTabController.GetTabByCulture(tab.TabID, portalId, locale); if (culturedTab != null) { return(Globals.NavigateURL(culturedTab.TabID)); } } return(string.Empty); } catch (Exception ee) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ee); return(string.Empty); } }
public static string GetCulturedUrlByTabName(string keyName) { var objTabController = new DotNetNuke.Entities.Tabs.TabController(); var tab = objTabController.GetTabByName(keyName, PortalController.GetCurrentPortalSettings().PortalId); if (tab != null) { var culturedTab = objTabController.GetTabByCulture(tab.TabID, PortalController.GetCurrentPortalSettings().PortalId, LocaleController.Instance.GetCurrentLocale(PortalController.GetCurrentPortalSettings().PortalId)); if (culturedTab != null) { return(Globals.NavigateURL(culturedTab.TabID)); } } return(string.Empty); }
/// <summary> /// Finds a culture-specific homepage tabid for a non-default language /// </summary> /// <param name="defaultCulture">The default culture of the portal</param> /// <param name="cultureCode"></param> /// <param name="defaultHomeTabId">The default home page tab id</param> /// <param name="portalId"></param> /// <returns>THe valid home page tabid for the portalid and culture</returns> /// <remarks>Note if no specific home page found for the culture, will return defaultHomeTabId back</remarks> internal static int GetHomePageTabIdForCulture(string defaultCulture, int portalId, string cultureCode, int defaultHomeTabId) { int homeTabId = defaultHomeTabId; if (String.Compare(defaultCulture, cultureCode, StringComparison.OrdinalIgnoreCase) != 0) { //not the default culture, so there could be a different home page for the different cultulre in 5.5+ builds var tc = new TabController(); var cultureLocale = new Locale { Code = cultureCode, Fallback = cultureCode, Text = cultureCode }; TabInfo tab = tc.GetTabByCulture(defaultHomeTabId, portalId, cultureLocale); if (tab != null) { //this is the culture specific tab of the home page homeTabId = tab.TabID; } } return homeTabId; }
/// <summary> /// SaveTabData saves the Tab to the Database /// </summary> /// <remarks> /// </remarks> /// <param name = "strAction">The action to perform "edit" or "add"</param> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// [jlucarino] 2/26/2009 Added CreatedByUserID and LastModifiedByUserID /// </history> private int SaveTabData(string strAction) { string strIcon = ctlIcon.Url; string strIconLarge = ctlIconLarge.Url; var objTabs = new TabController(); Tab.TabName = txtTabName.Text; Tab.Title = txtTitle.Text; Tab.Description = txtDescription.Text; Tab.KeyWords = txtKeyWords.Text; Tab.IsVisible = chkMenu.Checked; Tab.DisableLink = chkDisableLink.Checked; TabInfo parentTab = null; if (cboParentTab.SelectedItem != null) { var parentTabId = cboParentTab.SelectedItemValueAsInt; var controller = new TabController(); parentTab = controller.GetTab(parentTabId, -1, false); } if (parentTab != null) { Tab.PortalID = parentTab.PortalID; Tab.ParentId = parentTab.TabID; } else { Tab.ParentId = Null.NullInteger; } Tab.IconFile = strIcon; Tab.IconFileLarge = strIconLarge; Tab.IsDeleted = false; Tab.Url = ctlURL.Url; Tab.TabPermissions.Clear(); if (Tab.PortalID != Null.NullInteger) { Tab.TabPermissions.AddRange(dgPermissions.Permissions); } Tab.Terms.Clear(); Tab.Terms.AddRange(termsSelector.Terms); Tab.SkinSrc = pageSkinCombo.SelectedValue; Tab.ContainerSrc = pageContainerCombo.SelectedValue; Tab.TabPath = Globals.GenerateTabPath(Tab.ParentId, Tab.TabName); //Check for invalid string invalidType; if (!TabController.IsValidTabName(Tab.TabName, out invalidType)) { ShowWarningMessage(string.Format(Localization.GetString(invalidType, LocalResourceFile), Tab.TabName)); return Null.NullInteger; } //Validate Tab Path if (!IsValidTabPath(Tab, Tab.TabPath)) { return Null.NullInteger; } //Set Culture Code var positionTabId = Null.NullInteger; if (cboPositionTab.SelectedItem != null) { positionTabId = Int32.Parse(cboPositionTab.SelectedItem.Value); } if (strAction != "edit") { if (PortalSettings.ContentLocalizationEnabled) { switch (cultureTypeList.SelectedValue) { case "Localized": var defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId); Tab.CultureCode = defaultLocale.Code; break; case "Culture": Tab.CultureCode = PortalSettings.CultureCode; break; default: Tab.CultureCode = Null.NullString; break; } var tabLocale = LocaleController.Instance.GetLocale(Tab.CultureCode) ?? LocaleController.Instance.GetDefaultLocale(PortalId); //Fix parent if (Tab.ParentId > Null.NullInteger) { parentTab = objTabs.GetTab(Tab.ParentId, PortalId, false); if (parentTab.CultureCode != Tab.CultureCode) { parentTab = objTabs.GetTabByCulture(Tab.ParentId, PortalId, tabLocale); } if (parentTab != null) { Tab.ParentId = parentTab.TabID; } } //Fix position TabId if (positionTabId > Null.NullInteger) { var positionTab = objTabs.GetTab(positionTabId, PortalId, false); if (positionTab.CultureCode != Tab.CultureCode) { positionTab = objTabs.GetTabByCulture(positionTabId, PortalId, tabLocale); } if (positionTab != null) { positionTabId = positionTab.TabID; } } } else { Tab.CultureCode = Null.NullString; } } //Validate Tab Path if (string.IsNullOrEmpty(strAction)) { var tabID = TabController.GetTabByTabPath(Tab.PortalID, Tab.TabPath, Tab.CultureCode); if (tabID != Null.NullInteger) { var existingTab = objTabs.GetTab(tabID, PortalId, false); if (existingTab != null && existingTab.IsDeleted) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabRecycled", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); } else { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } return Null.NullInteger; } } Tab.StartDate = datepickerStartDate.SelectedDate != null ? datepickerStartDate.SelectedDate.Value : Null.NullDate; Tab.EndDate = datepickerEndDate.SelectedDate != null ? datepickerEndDate.SelectedDate.Value : Null.NullDate; if (Tab.StartDate > Null.NullDate && Tab.EndDate > Null.NullDate && Tab.StartDate.AddDays(1) >= Tab.EndDate) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("InvalidTabDates", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return Null.NullInteger; } if (!valRefreshInterval.IsValid) { return Null.NullInteger; } Tab.RefreshInterval = txtRefreshInterval.Text == "" ? Null.NullInteger : Convert.ToInt32(txtRefreshInterval.Text); if (!valPriorityRequired.IsValid || !valPriority.IsValid) { return Null.NullInteger; } Tab.SiteMapPriority = float.Parse(txtPriority.Text); Tab.PageHeadText = txtPageHeadText.Text; Tab.IsSecure = chkSecure.Checked; Tab.PermanentRedirect = chkPermanentRedirect.Checked; UpdateTabSettings(Tab); if (strAction == "edit") { // trap circular tab reference if (cboParentTab.SelectedItem != null && Tab.TabID != cboParentTab.SelectedItemValueAsInt && !IsCircularReference(cboParentTab.SelectedItemValueAsInt, Tab.PortalID)) { objTabs.UpdateTab(Tab); if (IsHostMenu && Tab.PortalID != Null.NullInteger) { //Host Tab moved to Portal so clear Host cache objTabs.ClearCache(Null.NullInteger); } if (!IsHostMenu && Tab.PortalID == Null.NullInteger) { //Portal Tab moved to Host so clear portal cache objTabs.ClearCache(PortalId); } } } else { if (positionTabId == Null.NullInteger) { Tab.TabID = objTabs.AddTab(Tab); } else { if (rbInsertPosition.SelectedValue == "After" && positionTabId > Null.NullInteger) { Tab.TabID = objTabs.AddTabAfter(Tab, positionTabId); } else if (rbInsertPosition.SelectedValue == "Before" && positionTabId > Null.NullInteger) { Tab.TabID = objTabs.AddTabBefore(Tab, positionTabId); } else { Tab.TabID = objTabs.AddTab(Tab); } } //Create Localized versions if (PortalSettings.ContentLocalizationEnabled && cultureTypeList.SelectedValue == "Localized") { objTabs.CreateLocalizedCopies(Tab); //Refresh tab _tab = objTabs.GetTab(Tab.TabID, Tab.PortalID, true); } var copyTabId = cboCopyPage.Visible && cboCopyPage.SelectedItem != null ? cboCopyPage.SelectedItemValueAsInt : Null.NullInteger; if (copyTabId != Null.NullInteger) { var objModules = new ModuleController(); ModuleInfo objModule; CheckBox chkModule; RadioButton optCopy; RadioButton optReference; TextBox txtCopyTitle; foreach (DataGridItem objDataGridItem in grdModules.Items) { chkModule = (CheckBox)objDataGridItem.FindControl("chkModule"); if (chkModule.Checked) { var intModuleID = Convert.ToInt32(grdModules.DataKeys[objDataGridItem.ItemIndex]); optCopy = (RadioButton)objDataGridItem.FindControl("optCopy"); optReference = (RadioButton)objDataGridItem.FindControl("optReference"); txtCopyTitle = (TextBox)objDataGridItem.FindControl("txtCopyTitle"); objModule = objModules.GetModule(intModuleID, copyTabId, false); ModuleInfo newModule = null; if ((objModule != null)) { //Clone module as it exists in the cache and changes we make will update the cached object newModule = objModule.Clone(); newModule.TabID = Tab.TabID; newModule.DefaultLanguageGuid = Null.NullGuid; newModule.CultureCode = Tab.CultureCode; newModule.ModuleTitle = txtCopyTitle.Text; if (!optReference.Checked) { newModule.ModuleID = Null.NullInteger; objModules.InitialModulePermission(newModule, newModule.TabID, 0); } newModule.ModuleID = objModules.AddModule(newModule); if (optCopy.Checked) { if (!string.IsNullOrEmpty(newModule.DesktopModule.BusinessControllerClass)) { var objObject = Reflection.CreateObject(newModule.DesktopModule.BusinessControllerClass, newModule.DesktopModule.BusinessControllerClass); if (objObject is IPortable) { var content = Convert.ToString(((IPortable)objObject).ExportModule(intModuleID)); if (!string.IsNullOrEmpty(content)) { ((IPortable)objObject).ImportModule(newModule.ModuleID, content, newModule.DesktopModule.Version, UserInfo.UserID); } } } } } if (optReference.Checked) { //Make reference copies on secondary language foreach (var m in objModule.LocalizedModules.Values) { var newLocalizedModule = m.Clone(); var localizedTab = Tab.LocalizedTabs[m.CultureCode]; newLocalizedModule.TabID = localizedTab.TabID; newLocalizedModule.CultureCode = localizedTab.CultureCode; newLocalizedModule.ModuleTitle = txtCopyTitle.Text; newLocalizedModule.DefaultLanguageGuid = newModule.UniqueId; newLocalizedModule.ModuleID = objModules.AddModule(newLocalizedModule); } } } } } else { // create the page from a template if (cboTemplate.SelectedItem != null && cboTemplate.SelectedItem.Value != Null.NullInteger.ToString()) { var xmlDoc = new XmlDocument(); try { // open the XML file var folder = FolderManager.Instance.GetFolder(cboFolders.SelectedItemValueAsInt); if (folder != null) xmlDoc.Load(PortalSettings.HomeDirectoryMapPath + folder.FolderPath + cboTemplate.SelectedValue); } catch (Exception ex) { Exceptions.LogException(ex); Skin.AddModuleMessage(this, Localization.GetString("BadTemplate", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return Null.NullInteger; } TabController.DeserializePanes(xmlDoc.SelectSingleNode("//portal/tabs/tab/panes"), Tab.PortalID, Tab.TabID, PortalTemplateModuleAction.Ignore, new Hashtable()); //save tab permissions RibbonBarManager.DeserializeTabPermissions(xmlDoc.SelectNodes("//portal/tabs/tab/tabpermissions/permission"), Tab); var tabIndex = 0; var exceptions = string.Empty; foreach (XmlNode tabNode in xmlDoc.SelectSingleNode("//portal/tabs").ChildNodes) { //Create second tab onward tabs. Note first tab is already created above. if (tabIndex > 0) { try { TabController.DeserializeTab(tabNode, null, PortalId, PortalTemplateModuleAction.Replace); } catch (Exception ex) { Exceptions.LogException(ex); exceptions += string.Format("Template Tab # {0}. Error {1}<br/>", tabIndex + 1, ex.Message); } } else { if (string.IsNullOrEmpty(Tab.SkinSrc) && !String.IsNullOrEmpty(XmlUtils.GetNodeValue(tabNode, "skinsrc", ""))) { Tab.SkinSrc = XmlUtils.GetNodeValue(tabNode, "skinsrc", ""); } if (string.IsNullOrEmpty(Tab.ContainerSrc) && !String.IsNullOrEmpty(XmlUtils.GetNodeValue(tabNode, "containersrc", ""))) { Tab.ContainerSrc = XmlUtils.GetNodeValue(tabNode, "containersrc", ""); } objTabs.UpdateTab(Tab); } tabIndex++; } if (!string.IsNullOrEmpty(exceptions)) { Skin.AddModuleMessage(this, exceptions, ModuleMessage.ModuleMessageType.RedError); return Null.NullInteger; } } } } // url tracking var objUrls = new UrlController(); objUrls.UpdateUrl(PortalId, ctlURL.Url, ctlURL.UrlType, 0, Null.NullDate, Null.NullDate, ctlURL.Log, ctlURL.Track, Null.NullInteger, ctlURL.NewWindow); //Clear the Tab's Cached modules DataCache.ClearModuleCache(TabId); //Update Cached Tabs as TabPath may be needed before cache is cleared TabInfo tempTab; if (new TabController().GetTabsByPortal(PortalId).TryGetValue(Tab.TabID, out tempTab)) { tempTab.TabPath = Tab.TabPath; } //Update Custom Url if (!Tab.IsSuperTab) { var tabUrl = Tab.TabUrls.SingleOrDefault(t => t.IsSystem && t.HttpStatus == "200" && t.SeqNum == 0); var url = urlTextBox.Text; if (!String.IsNullOrEmpty(url)) { if (!url.StartsWith("/")) { url = "/" + url; } string currentUrl = String.Empty; var friendlyUrlSettings = new FriendlyUrlSettings(PortalId); if (Tab.TabID > -1 && !Tab.IsSuperTab) { var baseUrl = Globals.AddHTTP(PortalAlias.HTTPAlias) + "/Default.aspx?TabId=" + Tab.TabID; var path = AdvancedFriendlyUrlProvider.ImprovedFriendlyUrl(Tab, baseUrl, Globals.glbDefaultPage, PortalAlias.HTTPAlias, false, //dnndev-27493 :we want any custom Urls that apply friendlyUrlSettings, Guid.Empty); currentUrl = path.Replace(Globals.AddHTTP(PortalAlias.HTTPAlias), ""); } if (url != currentUrl) { if (tabUrl == null) { tabUrl = new TabUrlInfo() { TabId = Tab.TabID, SeqNum = 0, PortalAliasId = -1, PortalAliasUsage = PortalAliasUsageType.Default, QueryString = String.Empty, Url = url, HttpStatus = "200", IsSystem = true }; } else { tabUrl.Url = url; } //Delete any redirects to the same url foreach (var redirecturl in TestableTabController.Instance.GetTabUrls(Tab.TabID, Tab.PortalID)) { if (redirecturl.Url == url && redirecturl.HttpStatus != "200") { TestableTabController.Instance.DeleteTabUrl(redirecturl, Tab.PortalID, false); } } //Save url TestableTabController.Instance.SaveTabUrl(tabUrl, PortalId, true); } } else { if (tabUrl != null) { TestableTabController.Instance.DeleteTabUrl(tabUrl, PortalId, true); } } } return Tab.TabID; }
/// <summary> /// SaveTabData saves the Tab to the Database /// </summary> /// <remarks> /// </remarks> /// <param name = "strAction">The action to perform "edit" or "add"</param> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// [jlucarino] 2/26/2009 Added CreatedByUserID and LastModifiedByUserID /// </history> private int SaveTabData(string strAction) { string strIcon; string strIconLarge; strIcon = ctlIcon.Url; strIconLarge = ctlIconLarge.Url; var objTabs = new TabController(); Tab.TabName = txtTabName.Text; Tab.Title = txtTitle.Text; Tab.Description = txtDescription.Text; Tab.KeyWords = txtKeyWords.Text; Tab.IsVisible = chkMenu.Checked; Tab.DisableLink = chkDisableLink.Checked; TabInfo parentTab = null; if (cboParentTab.SelectedItem != null) { var parentTabID = Int32.Parse(cboParentTab.SelectedItem.Value); var controller = new TabController(); parentTab = controller.GetTab(parentTabID, -1, false); } if (parentTab != null) { Tab.PortalID = parentTab.PortalID; Tab.ParentId = parentTab.TabID; } else { Tab.ParentId = Null.NullInteger; } Tab.IconFile = strIcon; Tab.IconFileLarge = strIconLarge; Tab.IsDeleted = false; Tab.Url = ctlURL.Url; Tab.TabPermissions.Clear(); if (Tab.PortalID != Null.NullInteger) { Tab.TabPermissions.AddRange(dgPermissions.Permissions); } Tab.Terms.Clear(); Tab.Terms.AddRange(termsSelector.Terms); Tab.SkinSrc = pageSkinCombo.SelectedValue; Tab.ContainerSrc = pageContainerCombo.SelectedValue; Tab.TabPath = Globals.GenerateTabPath(Tab.ParentId, Tab.TabName); //Check for invalid if (!IsValidTabName(Tab.TabName)) { return Null.NullInteger; } //Validate Tab Path if (!IsValidTabPath(Tab, Tab.TabPath)) { return Null.NullInteger; } //Set Culture Code var positionTabID = Null.NullInteger; if (cboPositionTab.SelectedItem != null) { positionTabID = Int32.Parse(cboPositionTab.SelectedItem.Value); } if (strAction != "edit") { if (PortalSettings.ContentLocalizationEnabled) { switch (cultureTypeList.SelectedValue) { case "Localized": var defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId); Tab.CultureCode = defaultLocale.Code; break; case "Culture": Tab.CultureCode = PortalSettings.CultureCode; break; default: Tab.CultureCode = Null.NullString; break; } var tabLocale = LocaleController.Instance.GetLocale(Tab.CultureCode) ?? LocaleController.Instance.GetDefaultLocale(PortalId); //Fix parent if (Tab.ParentId > Null.NullInteger) { parentTab = objTabs.GetTab(Tab.ParentId, PortalId, false); if (parentTab.CultureCode != Tab.CultureCode) { parentTab = objTabs.GetTabByCulture(Tab.ParentId, PortalId, tabLocale); } Tab.ParentId = parentTab.TabID; } //Fix position TabId if (positionTabID > Null.NullInteger) { var positionTab = objTabs.GetTab(positionTabID, PortalId, false); if (positionTab.CultureCode != Tab.CultureCode) { positionTab = objTabs.GetTabByCulture(positionTabID, PortalId, tabLocale); } positionTabID = positionTab.TabID; } } else { Tab.CultureCode = Null.NullString; } } //Validate Tab Path if (string.IsNullOrEmpty(strAction)) { var tabID = TabController.GetTabByTabPath(Tab.PortalID, Tab.TabPath, Tab.CultureCode); if (tabID != Null.NullInteger) { var existingTab = objTabs.GetTab(tabID, PortalId, false); if (existingTab != null && existingTab.IsDeleted) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabRecycled", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); } else { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } return Null.NullInteger; } } Tab.StartDate = datepickerStartDate.SelectedDate != null ? datepickerStartDate.SelectedDate.Value : Null.NullDate; Tab.EndDate = datepickerEndDate.SelectedDate != null ? datepickerEndDate.SelectedDate.Value : Null.NullDate; if (Tab.StartDate > Null.NullDate && Tab.EndDate > Null.NullDate && Tab.StartDate.AddDays(1) >= Tab.EndDate) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("InvalidTabDates", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return Null.NullInteger; } if (txtRefreshInterval.Text.Length > 0 && Regex.IsMatch(txtRefreshInterval.Text, "^\\d+$")) { Tab.RefreshInterval = Convert.ToInt32(txtRefreshInterval.Text); } Tab.SiteMapPriority = float.Parse(txtPriority.Text); Tab.PageHeadText = txtPageHeadText.Text; Tab.IsSecure = chkSecure.Checked; Tab.PermanentRedirect = chkPermanentRedirect.Checked; if (strAction == "edit") { // trap circular tab reference if (cboParentTab.SelectedItem != null && Tab.TabID != Int32.Parse(cboParentTab.SelectedItem.Value) && !IsCircularReference(Int32.Parse(cboParentTab.SelectedItem.Value), Tab.PortalID)) { objTabs.UpdateTab(Tab); if (IsHostMenu && Tab.PortalID != Null.NullInteger) { //Host Tab moved to Portal so clear Host cache objTabs.ClearCache(Null.NullInteger); } if (!IsHostMenu && Tab.PortalID == Null.NullInteger) { //Portal Tab moved to Host so clear portal cache objTabs.ClearCache(PortalId); } UpdateTabSettings(Tab.TabID); } // add or copy } else { if (positionTabID == Null.NullInteger) { Tab.TabID = objTabs.AddTab(Tab); } else { if (rbInsertPosition.SelectedValue == "After" && positionTabID > Null.NullInteger) { Tab.TabID = objTabs.AddTabAfter(Tab, positionTabID); } else if (rbInsertPosition.SelectedValue == "Before" && positionTabID > Null.NullInteger) { Tab.TabID = objTabs.AddTabBefore(Tab, positionTabID); } else { Tab.TabID = objTabs.AddTab(Tab); } } UpdateTabSettings(Tab.TabID); //Create Localized versions if (PortalSettings.ContentLocalizationEnabled && cultureTypeList.SelectedValue == "Localized") { objTabs.CreateLocalizedCopies(Tab); //Refresh tab _tab = objTabs.GetTab(Tab.TabID, Tab.PortalID, true); } var copyTabId = Int32.Parse(cboCopyPage.SelectedItem.Value); if (copyTabId != -1) { var objModules = new ModuleController(); ModuleInfo objModule; CheckBox chkModule; RadioButton optCopy; RadioButton optReference; TextBox txtCopyTitle; foreach (DataGridItem objDataGridItem in grdModules.Items) { chkModule = (CheckBox)objDataGridItem.FindControl("chkModule"); if (chkModule.Checked) { var intModuleID = Convert.ToInt32(grdModules.DataKeys[objDataGridItem.ItemIndex]); optCopy = (RadioButton)objDataGridItem.FindControl("optCopy"); optReference = (RadioButton)objDataGridItem.FindControl("optReference"); txtCopyTitle = (TextBox)objDataGridItem.FindControl("txtCopyTitle"); objModule = objModules.GetModule(intModuleID, copyTabId, false); ModuleInfo newModule = null; if ((objModule != null)) { //Clone module as it exists in the cache and changes we make will update the cached object newModule = objModule.Clone(); if (!optReference.Checked) { newModule.ModuleID = Null.NullInteger; } newModule.TabID = Tab.TabID; newModule.DefaultLanguageGuid = Null.NullGuid; newModule.CultureCode = Tab.CultureCode; newModule.ModuleTitle = txtCopyTitle.Text; newModule.ModuleID = objModules.AddModule(newModule); if (optCopy.Checked) { if (!string.IsNullOrEmpty(newModule.DesktopModule.BusinessControllerClass)) { var objObject = Reflection.CreateObject(newModule.DesktopModule.BusinessControllerClass, newModule.DesktopModule.BusinessControllerClass); if (objObject is IPortable) { var content = Convert.ToString(((IPortable)objObject).ExportModule(intModuleID)); if (!string.IsNullOrEmpty(content)) { ((IPortable)objObject).ImportModule(newModule.ModuleID, content, newModule.DesktopModule.Version, UserInfo.UserID); } } } } } if (optReference.Checked) { //Make reference copies on secondary language foreach (var m in objModule.LocalizedModules.Values) { var newLocalizedModule = m.Clone(); var localizedTab = Tab.LocalizedTabs[m.CultureCode]; newLocalizedModule.TabID = localizedTab.TabID; newLocalizedModule.CultureCode = localizedTab.CultureCode; newLocalizedModule.ModuleTitle = txtCopyTitle.Text; newLocalizedModule.DefaultLanguageGuid = newModule.UniqueId; newLocalizedModule.ModuleID = objModules.AddModule(newLocalizedModule); } } } } } else { // create the page from a template if (cboTemplate.SelectedItem != null && cboTemplate.SelectedItem.Value != Null.NullInteger.ToString()) { var xmlDoc = new XmlDocument(); try { // open the XML file xmlDoc.Load(PortalSettings.HomeDirectoryMapPath + cboFolders.SelectedValue + cboTemplate.SelectedValue); } catch (Exception ex) { Exceptions.LogException(ex); UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("BadTemplate", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return Null.NullInteger; } TabController.DeserializePanes(xmlDoc.SelectSingleNode("//portal/tabs/tab/panes"), Tab.PortalID, Tab.TabID, PortalTemplateModuleAction.Ignore, new Hashtable()); //save tab permissions RibbonBarManager.DeserializeTabPermissions(xmlDoc.SelectNodes("//portal/tabs/tab/tabpermissions/permission"), Tab); var tabIndex = 0; var exceptions = string.Empty; foreach (XmlNode tabNode in xmlDoc.SelectSingleNode("//portal/tabs").ChildNodes) { //Create second tab onward tabs. Note first tab is already created above. if(tabIndex > 0) { try { TabController.DeserializeTab(tabNode, null, PortalId, PortalTemplateModuleAction.Replace); } catch (Exception ex) { Exceptions.LogException(ex); exceptions += string.Format("Template Tab # {0}. Error {1}<br/>", tabIndex + 1, ex.Message); } } tabIndex++; } if (!string.IsNullOrEmpty(exceptions)) { UI.Skins.Skin.AddModuleMessage(this, exceptions, ModuleMessage.ModuleMessageType.RedError); return Null.NullInteger; } } } } // url tracking var objUrls = new UrlController(); objUrls.UpdateUrl(PortalId, ctlURL.Url, ctlURL.UrlType, 0, Null.NullDate, Null.NullDate, ctlURL.Log, ctlURL.Track, Null.NullInteger, ctlURL.NewWindow); //Clear the Tab's Cached modules DataCache.ClearModuleCache(TabId); //Update Cached Tabs as TabPath may be needed before cache is cleared TabInfo tempTab; if (new TabController().GetTabsByPortal(PortalId).TryGetValue(Tab.TabID, out tempTab)) { tempTab.TabPath = Tab.TabPath; } //Update Translation Status objTabs.UpdateTranslationStatus(Tab, translatedCheckbox.Checked); return Tab.TabID; }
private List<ModuleInfo> GetChildModules(int tabId, string cultureCode) { var modules = new List<ModuleInfo>(); var tabCtrl = new TabController(); Locale locale = LocaleController.Instance.GetLocale(cultureCode); if (locale != null) { modules = (from kvp in tabCtrl.GetTabByCulture(tabId, PortalSettings.PortalId, locale).ChildModules where !kvp.Value.IsDeleted select kvp.Value).ToList(); } return modules; }
private void BindData(bool refresh) { if (refresh) { LoadData(); } var tabController = new TabController(); modulesListBox.Items.Clear(); tabsListBox.Items.Clear(); foreach (ModuleInfo module in DeletedModules) { if (String.IsNullOrEmpty(module.ModuleTitle)) { module.ModuleTitle = module.DesktopModule.FriendlyName; } var locale = LocaleController.Instance.GetLocale(module.CultureCode); TabInfo tab = locale != null ? tabController.GetTabByCulture(module.TabID, PortalId, locale) : tabController.GetTab(module.TabID, PortalId, false); if (tab == null) { modulesListBox.Items.Add(new ListItem(module.ModuleTitle + " - " + module.LastModifiedOnDate, module.TabID + "-" + module.ModuleID)); } else if (tab.TabID == module.TabID) { modulesListBox.Items.Add(new ListItem(tab.TabName + " - " + module.ModuleTitle + " - " + module.LastModifiedOnDate, module.TabID + "-" + module.ModuleID)); } } foreach (var tab in DeletedTabs) { var item = new ListItem(tab.IndentedTabName + " - " + tab.LastModifiedOnDate, tab.TabID.ToString()); item.Attributes.Add("ParentId", tab.ParentId.ToString()); tabsListBox.Items.Add(item); } cmdRestoreTab.Enabled = (DeletedTabs.Count > 0); cmdDeleteTab.Enabled = (DeletedTabs.Count > 0); cmdRestoreModule.Enabled = (modulesListBox.Items.Count > 0); cmdDeleteModule.Enabled = (modulesListBox.Items.Count > 0); cmdEmpty.Enabled = DeletedTabs.Count > 0 || modulesListBox.Items.Count > 0; }
private void BindData(bool refresh) { if (refresh) { LoadData(); } var tabController = new TabController(); modulesListBox.Items.Clear(); tabsListBox.Items.Clear(); foreach (ModuleInfo module in DeletedModules) { if (String.IsNullOrEmpty(module.ModuleTitle)) { module.ModuleTitle = module.DesktopModule.FriendlyName; } var locale = LocaleController.Instance.GetLocale(module.CultureCode); TabInfo tab = locale != null ? tabController.GetTabByCulture(module.TabID, PortalId, locale) : tabController.GetTab(module.TabID, PortalId, false); if (tab == null) { modulesListBox.Items.Add(new ListItem(module.ModuleTitle, module.TabID + "-" + module.ModuleID)); } else if (tab.TabID == module.TabID) { modulesListBox.Items.Add(new ListItem(tab.TabName + " - " + module.ModuleTitle, module.TabID + "-" + module.ModuleID)); } } tabsListBox.DataSource = DeletedTabs; tabsListBox.DataBind(); cmdRestoreTab.Enabled = (DeletedTabs.Count > 0); cmdDeleteTab.Enabled = (DeletedTabs.Count > 0); cmdRestoreModule.Enabled = (modulesListBox.Items.Count > 0); cmdDeleteModule.Enabled = (modulesListBox.Items.Count > 0); cmdEmpty.Enabled = DeletedTabs.Count > 0 || modulesListBox.Items.Count > 0; }
/// <summary> /// Remaps the Special Pages such as Home, Profile, Search /// to their localized versions /// </summary> /// <remarks> /// </remarks> public void MapLocalizedSpecialPages(int portalId, string cultureCode) { TabController tabCont = new TabController(); DataCache.ClearHostCache(true); DataProvider.Instance().EnsureLocalizationExists(portalId, cultureCode); PortalInfo defaultPortal = GetPortal(portalId, GetPortalDefaultLanguage(portalId)); PortalInfo targetPortal = GetPortal(portalId, cultureCode); Locale targetLocale = LocaleController.Instance.GetLocale(cultureCode); TabInfo tempTab; if ((defaultPortal.HomeTabId != Null.NullInteger)) { tempTab = tabCont.GetTabByCulture(defaultPortal.HomeTabId, portalId, targetLocale); if (tempTab != null) { targetPortal.HomeTabId = tempTab.TabID; } } if ((defaultPortal.LoginTabId != Null.NullInteger)) { tempTab = tabCont.GetTabByCulture(defaultPortal.LoginTabId, portalId, targetLocale); if (tempTab != null) { targetPortal.LoginTabId = tempTab.TabID; } } if ((defaultPortal.RegisterTabId != Null.NullInteger)) { tempTab = tabCont.GetTabByCulture(defaultPortal.RegisterTabId, portalId, targetLocale); if (tempTab != null) { targetPortal.RegisterTabId = tempTab.TabID; } } if ((defaultPortal.SplashTabId != Null.NullInteger)) { tempTab = tabCont.GetTabByCulture(defaultPortal.SplashTabId, portalId, targetLocale); if (tempTab != null) { targetPortal.SplashTabId = tempTab.TabID; } } if ((defaultPortal.UserTabId != Null.NullInteger)) { tempTab = tabCont.GetTabByCulture(defaultPortal.UserTabId, portalId, targetLocale); if (tempTab != null) { targetPortal.UserTabId = tempTab.TabID; } } if ((defaultPortal.SearchTabId != Null.NullInteger)) { tempTab = tabCont.GetTabByCulture(defaultPortal.SearchTabId, portalId, targetLocale); if (tempTab != null) { targetPortal.SearchTabId = tempTab.TabID; } } UpdatePortalInfo(targetPortal, false); }
private string ResolvePageLink(int id, string defaultValue) { var tabController = new TabController(); // 2016-03-03 before issue #710 //var tabInfo = tabController.GetTab(linkId); //if (tabInfo == null) // return defaultValue; //return tabInfo.TabPath; //ownerPortalSettings = SxcInstance. var tabInfo = tabController.GetTab(id); if (tabInfo == null) return defaultValue; var portalSettings = PortalSettings.Current; // Get full PortalSettings (with portal alias) if module sharing is active if (PortalSettings.Current != null && PortalSettings.Current.PortalId != tabInfo.PortalID) //{ portalSettings = new PortalSettings(tabInfo.PortalID); //var portalAlias = ownerPortalSettings.PrimaryAlias ?? TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(tabInfo.PortalID).First(); //portalSettings = new PortalSettings(id, portalAlias); //} if(portalSettings == null) return defaultValue; // var tabInfo = tabController.GetTab(id, portalSettings.PortalId, false); // if (tabInfo == null) return defaultValue; if (tabInfo.CultureCode != "" && tabInfo.CultureCode != PortalSettings.Current.CultureCode) { var cultureTabInfo = tabController.GetTabByCulture(tabInfo.TabID, tabInfo.PortalID, LocaleController.Instance.GetLocale(PortalSettings.Current.CultureCode)); if (cultureTabInfo != null) tabInfo = cultureTabInfo; } // Exception in AdvancedURLProvider because ownerPortalSettings.PortalAlias is null return Globals.NavigateURL(tabInfo.TabID, portalSettings, "", new string[] {});// + urlParams; }
/// <summary> /// Loads deleted tabs and modules into the lists /// </summary> /// <remarks> /// </remarks> /// <history> /// [VMasanas] 18/08/2004 /// [VMasanas] 20/08/2004 Update display information for deleted modules to: /// ModuleFriendlyName: ModuleTitle - Tab: TabName /// </history> private void BindData() { var objModules = new ModuleController(); var objTabs = new TabController(); TabInfo objTab; ModuleInfo objModule; int intModule; lstModules.Items.Clear(); lstTabs.Items.Clear(); var currentLocale = LocaleController.Instance.GetCurrentLocale(PortalId); var arrDeletedTabs = new ArrayList(); TabCollection tabsList; if (modeButtonList.SelectedValue == "ALL") { tabsList = objTabs.GetTabsByPortal(PortalId); } else { tabsList = objTabs.GetTabsByPortal(PortalId).WithCulture(currentLocale.Code, true); } foreach (var tab in tabsList.Values) { if (tab.IsDeleted) { arrDeletedTabs.Add(tab); } } var arrModules = objModules.GetModules(PortalId); for (intModule = 0; intModule <= arrModules.Count - 1; intModule++) { objModule = (ModuleInfo) arrModules[intModule]; if (objModule.IsDeleted && (modeButtonList.SelectedValue == "ALL" || objModule.CultureCode == currentLocale.Code)) { if (String.IsNullOrEmpty(objModule.ModuleTitle)) { objModule.ModuleTitle = objModule.DesktopModule.FriendlyName; } var locale = LocaleController.Instance.GetLocale(objModule.CultureCode); if (locale != null) { objTab = objTabs.GetTabByCulture(objModule.TabID, PortalId, locale); } else { objTab = objTabs.GetTab(objModule.TabID, PortalId, false); } if (objTab == null) { lstModules.Items.Add(new ListItem(objModule.ModuleTitle, objModule.TabID + "-" + objModule.ModuleID)); } else if (objTab.TabID == objModule.TabID) { lstModules.Items.Add(new ListItem(objTab.TabName + " - " + objModule.ModuleTitle, objModule.TabID + "-" + objModule.ModuleID)); } } } lstTabs.DataSource = arrDeletedTabs; lstTabs.DataBind(); cmdRestoreTab.Enabled = (arrDeletedTabs.Count > 0); cmdDeleteTab.Enabled = (arrDeletedTabs.Count > 0); cmdRestoreModule.Enabled = (lstModules.Items.Count > 0); cmdDeleteModule.Enabled = (lstModules.Items.Count > 0); cmdEmpty.Enabled = arrDeletedTabs.Count > 0 || lstModules.Items.Count > 0; }
/// <summary> /// Resolves File and Page values /// For example, File:123 or Page:123 /// </summary> public static string ResolveHyperlinkValues(string value, PortalSettings ownerPortalSettings) { var resultString = value; var regularExpression = Regex.Match(resultString, @"^(?<type>(file|page)):(?<id>[0-9]+)(?<params>(\?|\#).*)?$", RegexOptions.IgnoreCase); if (!regularExpression.Success) return value; var fileManager = FileManager.Instance; var tabController = new TabController(); var type = regularExpression.Groups["type"].Value.ToLower(); var id = int.Parse(regularExpression.Groups["id"].Value); var urlParams = regularExpression.Groups["params"].Value ?? ""; switch (type) { case "file": var fileInfo = fileManager.GetFile(id); if (fileInfo != null) resultString = (fileInfo.StorageLocation == (int)FolderController.StorageLocationTypes.InsecureFileSystem ? Path.Combine(ownerPortalSettings.HomeDirectory, fileInfo.RelativePath) + urlParams : fileManager.GetUrl(fileInfo)); break; case "page": var portalSettings = PortalSettings.Current; // Get full PortalSettings (with portal alias) if module sharing is active if (PortalSettings.Current != null && PortalSettings.Current.PortalId != ownerPortalSettings.PortalId) { var portalAlias = ownerPortalSettings.PrimaryAlias ?? TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(ownerPortalSettings.PortalId).First(); portalSettings = new PortalSettings(id, portalAlias); } var tabInfo = tabController.GetTab(id, ownerPortalSettings.PortalId, false); if (tabInfo != null) { if (tabInfo.CultureCode != "" && tabInfo.CultureCode != PortalSettings.Current.CultureCode) { var cultureTabInfo = tabController.GetTabByCulture(tabInfo.TabID, tabInfo.PortalID, LocaleController.Instance.GetLocale(PortalSettings.Current.CultureCode)); if (cultureTabInfo != null) tabInfo = cultureTabInfo; } // Exception in AdvancedURLProvider because ownerPortalSettings.PortalAlias is null resultString = Globals.NavigateURL(tabInfo.TabID, portalSettings, "", new string[] { }) + urlParams; } break; } return resultString; }