本文整理汇总了C#中DotNetNuke.Entities.Tabs.TabController.GetTabsByPortal方法的典型用法代码示例。如果您正苦于以下问题:C# TabController.GetTabsByPortal方法的具体用法?C# TabController.GetTabsByPortal怎么用?C# TabController.GetTabsByPortal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Tabs.TabController
的用法示例。
在下文中一共展示了TabController.GetTabsByPortal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUrls
/// <summary>
/// Includes page urls on the sitemap
/// </summary>
/// <remarks>
/// Pages that are included:
/// - are not deleted
/// - are not disabled
/// - are normal pages (not links,...)
/// - are visible (based on date and permissions)
/// </remarks>
public override List<SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
{
var objTabs = new TabController();
SitemapUrl pageUrl = null;
var urls = new List<SitemapUrl>();
useLevelBasedPagePriority = bool.Parse(PortalController.GetPortalSetting("SitemapLevelMode", portalId, "False"));
minPagePriority = float.Parse(PortalController.GetPortalSetting("SitemapMinPriority", portalId, "0.1"), CultureInfo.InvariantCulture);
includeHiddenPages = bool.Parse(PortalController.GetPortalSetting("SitemapIncludeHidden", portalId, "True"));
this.ps = ps;
foreach (TabInfo objTab in objTabs.GetTabsByPortal(portalId).Values)
{
if (!objTab.IsDeleted && !objTab.DisableLink && objTab.TabType == TabType.Normal && (Null.IsNull(objTab.StartDate) || objTab.StartDate < DateTime.Now) &&
(Null.IsNull(objTab.EndDate) || objTab.EndDate > DateTime.Now) && IsTabPublic(objTab.TabPermissions))
{
if (includeHiddenPages || objTab.IsVisible)
{
pageUrl = GetPageUrl(objTab, (ps.ContentLocalizationEnabled) ? objTab.CultureCode : null);
urls.Add(pageUrl);
}
}
}
return urls;
}
示例2: FindMessageTab
//This method is copied from user skin object
private int FindMessageTab()
{
var tabController = new TabController();
var moduleController = new ModuleController();
//On brand new install the new Message Center Module is on the child page of User Profile Page
//On Upgrade to 6.2.0, the Message Center module is on the User Profile Page
var profileTab = tabController.GetTab(PortalSettings.UserTabId, PortalSettings.PortalId, false);
if (profileTab != null)
{
var childTabs = tabController.GetTabsByPortal(profileTab.PortalID).DescendentsOf(profileTab.TabID);
foreach (TabInfo tab in childTabs)
{
foreach (KeyValuePair<int, ModuleInfo> kvp in moduleController.GetTabModules(tab.TabID))
{
var module = kvp.Value;
if (module.DesktopModule.FriendlyName == "Message Center")
{
return tab.TabID;
}
}
}
}
//default to User Profile Page
return PortalSettings.UserTabId;
}
示例3: GetSearchDocuments
/// -----------------------------------------------------------------------------
/// <summary>
/// Returns the collection of SearchDocuments populated with Tab MetaData for the given portal.
/// </summary>
/// <param name="portalId"></param>
/// <param name="startDate"></param>
/// <returns></returns>
/// <history>
/// [vnguyen] 04/16/2013 created
/// </history>
/// -----------------------------------------------------------------------------
public override IEnumerable<SearchDocument> GetSearchDocuments(int portalId, DateTime startDate)
{
var searchDocuments = new List<SearchDocument>();
var tabController = new TabController();
var tabs = tabController.GetTabsByPortal(portalId).AsList().Where(t => ((t.TabSettings["AllowIndex"] == null) ||
(t.TabSettings["AllowIndex"] != null && t.TabSettings["AllowIndex"].ToString().ToLower() != "false")) &&
t.LastModifiedOnDate > startDate);
try
{
foreach (var tab in tabs)
{
var searchDoc = new SearchDocument
{
SearchTypeId = TabSearchTypeId,
UniqueKey = Constants.TabMetaDataPrefixTag + tab.TabID,
TabId = tab.TabID,
PortalId = tab.PortalID,
CultureCode = tab.CultureCode,
ModifiedTimeUtc = tab.LastModifiedOnDate,
Body = tab.PageHeadText,
Description = tab.Description
};
searchDoc.Keywords.Add("keywords", tab.KeyWords);
//Using TabName for searchDoc.Title due to higher prevalence and relavency || TabTitle will be stored as a keyword
searchDoc.Title = tab.TabName;
searchDoc.Keywords.Add("title", tab.Title);
if (tab.Terms != null && tab.Terms.Count > 0)
{
searchDoc.Tags = tab.Terms.Select(t => t.Name);
}
Logger.Trace("TabIndexer: Search document for metaData added for page [" + tab.Title + " tid:" + tab.TabID + "]");
searchDocuments.Add(searchDoc);
}
}
catch (Exception ex)
{
Exceptions.Exceptions.LogException(ex);
}
return searchDocuments;
}
示例4: TryToResolveOneLinkToInternalDnnCode
/// <summary>
/// Will take a link like http:\\... to a file or page and try to return a DNN-style info like
/// Page:35 or File:43003
/// </summary>
/// <param name="potentialFilePath"></param>
/// <returns></returns>
public string TryToResolveOneLinkToInternalDnnCode(string potentialFilePath)
{
var portalInfo = PortalSettings.Current; //PortalController.Instance.GetCurrentPortalSettings();
// Try file reference
var fileInfo = FileManager.Instance.GetFile(portalInfo.PortalId, potentialFilePath);
if (fileInfo != null)
return "File:" + fileInfo.FileId;
// Try page / tab ID
var tabController = new TabController();
var tabCollection = tabController.GetTabsByPortal(portalInfo.PortalId);
var tabInfo = tabCollection.Select(tab => tab.Value)
.Where(tab => tab.TabPath == potentialFilePath)
.FirstOrDefault();
if (tabInfo != null)
return "Page:" + tabInfo.TabID;
return potentialFilePath;
}
示例5: HasViewPermission
public override bool HasViewPermission(SearchResult searchResult)
{
var viewable = false;
if (searchResult.ModuleId > 0)
{
//Get All related tabIds from moduleId (while minimizing DB access; using caching)
var tabController = new TabController();
var moduleId = searchResult.ModuleId;
// The next call has over 30% performance enhancement over the above one
var tabModules = tabController.GetTabsByPortal(searchResult.PortalId).Values
.SelectMany(tabinfo => tabinfo.ChildModules.Where(kv => kv.Key == moduleId)).Select(m => m.Value);
foreach (ModuleInfo module in tabModules)
{
var tab = tabController.GetTab(module.TabID, searchResult.PortalId, false);
if (!module.IsDeleted && !tab.IsDeleted && TabPermissionController.CanViewPage(tab))
{
//Check If authorised to View Module
if (ModulePermissionController.CanViewModule(module))
{
//Verify against search document permissions
if (string.IsNullOrEmpty(searchResult.Permissions) || PortalSecurity.IsInRoles(searchResult.Permissions))
{
viewable = true;
if (string.IsNullOrEmpty(searchResult.Url))
{
searchResult.Url = TestableGlobals.Instance.NavigateURL(module.TabID, string.Empty, searchResult.QueryString);
}
break;
}
}
}
}
}
else
{
viewable = true;
}
return viewable;
}
示例6: GetNonTranslatedPages
public HttpResponseMessage GetNonTranslatedPages(string languageCode)
{
var request = HttpContext.Current.Request;
var locale = new LocaleController().GetLocale(languageCode);
List<PageDto> pages = new List<PageDto>();
if (!IsDefaultLanguage(locale.Code))
{
TabController ctl = new TabController();
var nonTranslated = (from t in ctl.GetTabsByPortal(PortalSettings.PortalId).WithCulture(locale.Code, false).Values where !t.IsTranslated && !t.IsDeleted select t);
foreach (TabInfo page in nonTranslated)
{
pages.Add(new PageDto()
{
Name = page.TabName,
ViewUrl = DotNetNuke.Common.Globals.NavigateURL(page.TabID),
EditUrl = DotNetNuke.Common.Globals.NavigateURL(page.TabID, "Tab", "action=edit", "returntabid=" + PortalSettings.ActiveTab.TabID)
});
}
}
return Request.CreateResponse(HttpStatusCode.OK, pages);
}
示例7: RewriteUrl
//.........这里部分代码省略.........
portal.HomeTabId + "&portalid=" + portalID + "&ctl=login");
}
}
return;
}
if (tabPath == "/register.aspx")
{
if (portal.RegisterTabId > Null.NullInteger)
{
if (!string.IsNullOrEmpty(requestQuery))
{
RewriterUtils.RewriteUrl(app.Context,
"~/" + Globals.glbDefaultPage + "?TabID=" +
portal.RegisterTabId + "&portalid=" + portalID + "&" +
requestQuery);
}
else
{
RewriterUtils.RewriteUrl(app.Context,
"~/" + Globals.glbDefaultPage + "?TabID=" +
portal.RegisterTabId + "&portalid=" + portalID);
}
}
else
{
if (!string.IsNullOrEmpty(requestQuery))
{
RewriterUtils.RewriteUrl(app.Context,
"~/" + Globals.glbDefaultPage + "?TabID=" +
portal.HomeTabId + "&portalid=" + portalID +
"&ctl=Register&" + requestQuery);
}
else
{
RewriterUtils.RewriteUrl(app.Context,
"~/" + Globals.glbDefaultPage + "?TabID=" +
portal.HomeTabId + "&portalid=" + portalID +
"&ctl=Register");
}
}
return;
}
if (tabPath == "/terms.aspx")
{
if (!string.IsNullOrEmpty(requestQuery))
{
RewriterUtils.RewriteUrl(app.Context,
"~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
"&portalid=" + portalID + "&ctl=Terms&" + requestQuery);
}
else
{
RewriterUtils.RewriteUrl(app.Context,
"~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
"&portalid=" + portalID + "&ctl=Terms");
}
return;
}
if (tabPath == "/privacy.aspx")
{
if (!string.IsNullOrEmpty(requestQuery))
{
RewriterUtils.RewriteUrl(app.Context,
"~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
"&portalid=" + portalID + "&ctl=Privacy&" + requestQuery);
}
else
{
RewriterUtils.RewriteUrl(app.Context,
"~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
"&portalid=" + portalID + "&ctl=Privacy");
}
return;
}
tabPath = tabPath.Replace("/", "//");
tabPath = tabPath.Replace(".aspx", "");
var objTabController = new TabController();
TabCollection objTabs = objTabController.GetTabsByPortal(tabPath.StartsWith("//host") ? Null.NullInteger : portalID);
foreach (KeyValuePair<int, TabInfo> kvp in objTabs)
{
if ((kvp.Value.IsDeleted == false && kvp.Value.TabPath.ToLower() == tabPath))
{
if ((!String.IsNullOrEmpty(app.Request.Url.Query)))
{
RewriterUtils.RewriteUrl(app.Context,
"~/" + Globals.glbDefaultPage + "?TabID=" + kvp.Value.TabID +
"&" + app.Request.Url.Query.TrimStart('?'));
}
else
{
RewriterUtils.RewriteUrl(app.Context,
"~/" + Globals.glbDefaultPage + "?TabID=" + kvp.Value.TabID);
}
return;
}
}
}
}
}
}
示例8: MakeNeutral_Click
protected void MakeNeutral_Click(object sender, EventArgs e)
{
var t = new TabController();
if (t.GetTabsByPortal(PortalId).WithParentId(_tab.TabID).Count == 0)
{
var defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId);
t.ConvertTabToNeutralLanguage(PortalId, _tab.TabID, defaultLocale.Code, true);
Response.Redirect(Request.RawUrl, false);
}
}
示例9: UpdateWorkflow
/// -----------------------------------------------------------------------------
/// <summary>
/// UpdateWorkFlow updates the currently active Workflow
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="WorkFlowType">The type of workflow (Module | Page | Site)</param>
/// <param name = "WorkflowID">The ID of the Workflow</param>
/// <param name="ObjectID">The ID of the object to apply the update to (depends on WorkFlowType)</param>
/// <param name="ReplaceExistingSettings">Should existing settings be overwritten?</param>
/// <history>
/// </history>
/// -----------------------------------------------------------------------------
public void UpdateWorkflow(int ObjectID, string WorkFlowType, int WorkflowID, bool ReplaceExistingSettings)
{
var tabController = new TabController();
var moduleController = new ModuleController();
switch (WorkFlowType)
{
case "Module":
moduleController.UpdateModuleSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
break;
case "Page":
tabController.UpdateTabSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
if (ReplaceExistingSettings)
{
//Get All Modules on the current Tab
foreach (var kvp in moduleController.GetTabModules(ObjectID))
{
ClearModuleSettings(kvp.Value);
}
}
break;
case "Site":
PortalController.UpdatePortalSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
if (ReplaceExistingSettings)
{
//Get All Tabs aon the Site
foreach (var kvp in tabController.GetTabsByPortal(ObjectID))
{
tabController.DeleteTabSetting(kvp.Value.TabID, "WorkFlowID");
}
//Get All Modules in the current Site
foreach (ModuleInfo objModule in moduleController.GetModules(ObjectID))
{
ClearModuleSettings(objModule);
}
}
break;
}
}
示例10: GetTabs
public static Dictionary<int, TabInfo> GetTabs(int portalId, bool includeStdUrls, PortalSettings portalSettings, FriendlyUrlSettings settings)
{
var tc = new TabController();
//811 : friendly urls for admin/host tabs
var tabs = new Dictionary<int, TabInfo>();
var portalTabs = tc.GetTabsByPortal(portalId);
var hostTabs = tc.GetTabsByPortal(-1);
foreach (TabInfo tab in portalTabs.Values)
{
tabs[tab.TabID] = tab;
}
if (settings.FriendlyAdminHostUrls)
{
foreach (TabInfo tab in hostTabs.Values)
{
tabs[tab.TabID] = tab;
}
}
return tabs;
}
示例11: GetPageDescendantsInternal
private IEnumerable<ItemDto> GetPageDescendantsInternal(int portalId, int parentId, int sortOrder, string searchText)
{
List<TabInfo> tabs;
if (portalId == -1)
{
portalId = GetActivePortalId(parentId);
}
else
{
if (!IsPortalIdValid(portalId)) return new List<ItemDto>();
}
Func<TabInfo, bool> searchFunc;
if (String.IsNullOrEmpty(searchText))
{
searchFunc = page => true;
}
else
{
searchFunc = page => page.LocalizedTabName.IndexOf(searchText, StringComparison.InvariantCultureIgnoreCase) > -1;
}
if (portalId > -1)
{
var includeHiddenTabs = PortalSettings.UserInfo.IsSuperUser || PortalSettings.UserInfo.IsInRole("Administrators");
tabs =
TabController.GetPortalTabs(portalId, Null.NullInteger, false, null, includeHiddenTabs, false, false, true, false)
.Where(tab => searchFunc(tab) && tab.ParentId == parentId && !tab.DisableLink)
.OrderBy(tab => tab.TabOrder)
.ToList();
}
else
{
if (PortalSettings.UserInfo.IsSuperUser)
{
var tabController = new TabController();
tabs = tabController.GetTabsByPortal(-1).AsList()
.Where(tab => searchFunc(tab) && tab.ParentId == parentId && !tab.IsDeleted && !tab.DisableLink)
.OrderBy(tab => tab.TabOrder)
.ToList();
}
else
{
return new List<ItemDto>();
}
}
var pages = tabs.Select(tab => new ItemDto {
Key = tab.TabID.ToString(CultureInfo.InvariantCulture),
Value = tab.LocalizedTabName,
HasChildren = tab.HasChildren,
Selectable = true
});
return ApplySort(pages, sortOrder);
}
示例12: MoveTab
private bool MoveTab(TabInfo tab, TabInfo targetTab, Position position)
{
//Validate Tab Path
if (!IsValidTabPath(tab, Globals.GenerateTabPath((targetTab == null) ? Null.NullInteger : targetTab.TabID, tab.TabName)))
{
return false;
}
var tabController = new TabController();
//get current siblings of moving tab
var siblingTabs = GetSiblingTabs(tab);
int siblingCount = siblingTabs.Count;
//move all current siblings of moving tab one level up in order
int tabIndex = GetIndexOfTab(tab, siblingTabs);
UpdateTabOrder(siblingTabs, tabIndex + 1, siblingCount - 1, -2);
//get siblings of new position
siblingTabs = GetSiblingTabs(targetTab);
siblingCount = siblingTabs.Count;
//First make sure the list of siblings at the new position is sorted and spaced
UpdateTabOrder(siblingTabs, tab.CultureCode, 2);
//Find Index position of new positin in the Sibling List
var targetIndex = GetIndexOfTab(targetTab, siblingTabs);
switch (position)
{
case Position.Above:
targetIndex = targetIndex - 1;
break;
case Position.Below:
break;
}
//We need to update the taborder for items that were after that position
UpdateTabOrder(siblingTabs, targetIndex + 1, siblingCount - 1, 2);
//Get the descendents of old tab position now before the new parentid is updated
var descendantTabs = tabController.GetTabsByPortal(tab.PortalID).DescendentsOf(tab.TabID);
//Update the current Tab to reflect new parent id and new taborder
tab.ParentId = targetTab.ParentId;
tabController.UpdateTab(tab);
//Update the moving tabs level and tabpath
tab.Level = targetTab.Level;
//Update TabOrder as the previous UpdateTab call pushes the tab to the bottom
switch (position)
{
case Position.Above:
tab.TabOrder = targetTab.TabOrder - 2;
break;
case Position.Below:
tab.TabOrder = targetTab.TabOrder + 1;
break;
}
UpdateTabOrder(tab, true);
//Update the Descendents of the moving tab
UpdateDescendantLevel(descendantTabs, tab.Level + 1);
ShowSuccessMessage(string.Format(Localization.GetString("TabMoved", LocalResourceFile), tab.TabName));
return true;
}
示例13: ParseTemplate
//.........这里部分代码省略.........
}
// settings, roles, folders and files can only be specified in portal templates, will be ignored on the admin template
if( !isAdminTemplate )
{
// parse roles if available
node = xmlDoc.SelectSingleNode( "//portal/roles" );
if( node != null )
{
ParseRoles( node, PortalId, AdministratorId, ref AdministratorRoleId, ref RegisteredRoleId, ref SubscriberRoleId );
}
// create required roles if not already created
if( AdministratorRoleId == -1 )
{
AdministratorRoleId = CreateRole( PortalId, "Administrators", "Portal Administrators", 0F, 0, "M", 0F, 0, "N", false, false );
}
if( RegisteredRoleId == -1 )
{
RegisteredRoleId = CreateRole( PortalId, "Registered Users", "Registered Users", 0F, 0, "M", 0F, 0, "N", false, true );
}
if( SubscriberRoleId == -1 )
{
SubscriberRoleId = CreateRole( PortalId, "Subscribers", "A public role for portal subscriptions", 0F, 0, "M", 0F, 0, "N", true, true );
}
objrole.AddUserRole( PortalId, AdministratorId, AdministratorRoleId, Null.NullDate, Null.NullDate );
objrole.AddUserRole( PortalId, AdministratorId, RegisteredRoleId, Null.NullDate, Null.NullDate );
objrole.AddUserRole( PortalId, AdministratorId, SubscriberRoleId, Null.NullDate, Null.NullDate );
// parse portal folders
node = xmlDoc.SelectSingleNode( "//portal/folders" );
if( node != null )
{
ParseFolders( node, PortalId );
}
// force creation of root folder if not present on template
FolderController objController = new FolderController();
if( objController.GetFolder( PortalId, "" ) == null )
{
int folderid = objController.AddFolder( PortalId, "", (int)FolderController.StorageLocationTypes.InsecureFileSystem, true, false );
PermissionController objPermissionController = new PermissionController();
ArrayList arr = objPermissionController.GetPermissionByCodeAndKey( "SYSTEM_FOLDER", "" );
foreach( PermissionInfo objpermission in arr )
{
FileSystemUtils.SetFolderPermission( PortalId, folderid, objpermission.PermissionID, AdministratorRoleId, "" );
if( objpermission.PermissionKey == "READ" )
{
// add READ permissions to the All Users Role
FileSystemUtils.SetFolderPermission( PortalId, folderid, objpermission.PermissionID, int.Parse( Globals.glbRoleAllUsers ), "" );
}
}
}
// parse portal settings if available only for new portals
node = xmlDoc.SelectSingleNode( "//portal/settings" );
if( node != null & IsNewPortal )
{
ParsePortalSettings( node, PortalId );
}
// update portal setup
PortalInfo objportal = null;
objportal = GetPortal( PortalId );
UpdatePortalSetup( PortalId, AdministratorId, AdministratorRoleId, RegisteredRoleId, objportal.SplashTabId, objportal.HomeTabId, objportal.LoginTabId, objportal.UserTabId, objportal.AdminTabId );
//Remove Exising Tabs if doing a "Replace"
if( mergeTabs == PortalTemplateModuleAction.Replace )
{
TabController objTabs = new TabController();
TabInfo objTab = null;
foreach( KeyValuePair<int, TabInfo> tabPair in objTabs.GetTabsByPortal( PortalId ) )
{
objTab = tabPair.Value;
if( !objTab.IsAdminTab )
{
//soft delete Tab
objTab.TabName = objTab.TabName + "_old";
objTab.IsDeleted = true;
objTabs.UpdateTab( objTab );
//Delete all Modules
ModuleController objModules = new ModuleController();
ModuleInfo objModule = null;
foreach( KeyValuePair<int, ModuleInfo> modulePair in objModules.GetTabModules( objTab.TabID ) )
{
objModule = modulePair.Value;
objModules.DeleteTabModule( objModule.TabID, objModule.ModuleID );
}
}
}
}
}
// parse portal tabs
node = xmlDoc.SelectSingleNode( "//portal/tabs" );
if( node != null )
{
ParseTabs( node, PortalId, isAdminTemplate, mergeTabs, IsNewPortal );
}
}
示例14: cmdUpdate_Click
protected void cmdUpdate_Click(object sender, EventArgs e)
{
try
{
if (UserInfo.IsSuperUser)
{
//Update Language
if (Language == null)
{
_Language = LocaleController.Instance.GetLocale(languageComboBox.SelectedValue);
if (_Language == null)
{
_Language = new Locale();
Language.Code = languageComboBox.SelectedValue;
}
}
Language.Fallback = fallBackComboBox.SelectedValue;
Language.Text = CultureInfo.CreateSpecificCulture(Language.Code).NativeName;
Localization.SaveLanguage(Language);
}
if (!IsLanguageEnabled(Language.Code))
{
//Add language to portal
Localization.AddLanguageToPortal(PortalId, Language.LanguageId, true);
}
string roles = Null.NullString;
if (IsAddMode)
{
roles = string.Format("Administrators;{0}", string.Format("Translator ({0})", Language.Code));
}
else
{
foreach (string role in translatorRoles.SelectedRoleNames)
{
roles += role + ";";
}
roles = roles.TrimEnd(';');
}
PortalController.UpdatePortalSetting(PortalId, string.Format("DefaultTranslatorRoles-{0}", Language.Code), roles);
var tabCtrl = new TabController();
TabCollection tabs = tabCtrl.GetTabsByPortal(PortalId).WithCulture(Language.Code, false);
if (PortalSettings.ContentLocalizationEnabled && tabs.Count == 0)
{
//Create Localized Pages
foreach (TabInfo t in tabCtrl.GetCultureTabList(PortalId))
{
tabCtrl.CreateLocalizedCopy(t, Language);
}
var portalCtl = new PortalController();
portalCtl.MapLocalizedSpecialPages(PortalId, Language.Code);
}
Response.Redirect(Globals.NavigateURL(), true);
//Module failed to load
}
catch (Exception exc)
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
示例15: enabledCheckbox_CheckChanged
protected void enabledCheckbox_CheckChanged(object sender, EventArgs e)
{
try
{
if ((sender) is DnnCheckBox)
{
var enabledCheckbox = (DnnCheckBox) sender;
int languageId = int.Parse(enabledCheckbox.CommandArgument);
Locale locale = LocaleController.Instance.GetLocale(languageId);
Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId);
Dictionary<string, Locale> enabledLanguages = LocaleController.Instance.GetLocales(PortalId);
var tabController = new TabController();
var localizedTabs = PortalSettings.ContentLocalizationEnabled ?
tabController.GetTabsByPortal(PortalId).WithCulture(locale.Code, false).AsList() : new List<TabInfo>();
var redirectUrl = string.Empty;
if (enabledCheckbox.Enabled)
{
// do not touch default language
if (enabledCheckbox.Checked)
{
if (!enabledLanguages.ContainsKey(locale.Code))
{
//Add language to portal
Localization.AddLanguageToPortal(PortalId, languageId, true);
}
//restore the tabs and modules
var moduleController = new ModuleController();
foreach (var tab in localizedTabs)
{
tabController.RestoreTab(tab, PortalSettings);
moduleController.GetTabModules(tab.TabID).Values.ToList().ForEach(moduleController.RestoreModule);
}
}
else
{
//remove language from portal
Localization.RemoveLanguageFromPortal(PortalId, languageId);
//if the disable language is current language, should redirect to default language.
if(locale.Code.Equals(Thread.CurrentThread.CurrentUICulture.ToString(), StringComparison.InvariantCultureIgnoreCase))
{
redirectUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID,
PortalSettings.ActiveTab.IsSuperTab,
PortalSettings, "", defaultLocale.Code);
}
//delete the tabs in this language
foreach (var tab in localizedTabs)
{
tab.DefaultLanguageGuid = Guid.Empty;
tabController.SoftDeleteTab(tab.TabID, PortalSettings);
}
}
}
//Redirect to refresh page (and skinobjects)
if (string.IsNullOrEmpty(redirectUrl))
{
redirectUrl = Globals.NavigateURL();
}
Response.Redirect(redirectUrl, true);
}
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}