/// <summary> /// Creates a new instance of cultural route constraint for specific site. /// </summary> /// <param name="siteName">The code name of the site.</param> public SiteCultureConstraint(string siteName) { var siteCultureNames = CultureSiteInfoProvider.GetSiteCultureCodes(siteName); // Ignore case for culture comparison (both 'en-US' and 'en-us' are ok) allowedCultureNames = new HashSet <string>(siteCultureNames, StringComparer.InvariantCultureIgnoreCase); }
/// <summary> /// Helper that fills in the NodeItemBuilderSetting based on the SiteName and configured options. /// </summary> /// <param name="SiteName">The Site Name</param> /// <param name="CheckingForUpdates">If Updates should be checked or not, triggering recursive checking</param> /// <param name="CheckEntireTree">If the entire tree should be checked</param> /// <param name="BuildSiblings">If siblings should be checked</param> /// <param name="BuildChildren">If Children Should be checked</param> /// <param name="BuildDescendents">If Descdendents should be checked</param> /// <returns>The NodeItemBuilderSetting with Site, Cultures and Default culture already set.</returns> private static NodeItemBuilderSettings GetNodeItemBuilderSettings(string SiteName, bool CheckingForUpdates, bool CheckEntireTree, bool BuildSiblings, bool BuildChildren, bool BuildDescendents) { return(CacheHelper.Cache(cs => { if (cs.Cached) { cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { "cms.site|byname|" + SiteName, "cms.siteculture|all", "cms.settingskey|byname|CMSDefaultCultureCode", "cms.settingskey|byname|GenerateCultureVariationUrlSlugs", }); } // Loop through Cultures and start rebuilding pages SiteInfo Site = SiteInfoProvider.GetSiteInfo(SiteName); string DefaultCulture = SettingsKeyInfoProvider.GetValue("CMSDefaultCultureCode", new SiteInfoIdentifier(SiteName)); bool GenerateCultureVariationUrlSlugs = SettingsKeyInfoProvider.GetBoolValue("GenerateCultureVariationUrlSlugs", new SiteInfoIdentifier(SiteName)); var BaseMacroResolver = MacroResolver.GetInstance(true); BaseMacroResolver.AddAnonymousSourceData(new object[] { Site }); // Now build URL slugs for the default language always. List <string> Cultures = CultureSiteInfoProvider.GetSiteCultureCodes(SiteName); return new NodeItemBuilderSettings(Cultures, DefaultCulture, GenerateCultureVariationUrlSlugs, BaseMacroResolver, CheckingForUpdates, CheckEntireTree, BuildSiblings, BuildChildren, BuildDescendents, SiteName); }, new CacheSettings(1440, "GetNodeItemBuilderSettings", SiteName, CheckingForUpdates, CheckEntireTree, BuildSiblings, BuildChildren, BuildDescendents))); }
/// <summary> /// Gets sorted site cultures where preferred culture has top priority and default culture second. /// </summary> private string[] GetSiteCultures() { var sortedCultures = new List <string> { LocalizationContext.PreferredCultureCode, CultureHelper.GetDefaultCultureCode(currentSiteName) }; sortedCultures.AddRange(CultureSiteInfoProvider.GetSiteCultureCodes(currentSiteName)); return(sortedCultures.Distinct(StringComparer.OrdinalIgnoreCase).ToArray()); }
/// <summary> /// Gets sorted site cultures where preferred culture has top priority and default culture second. /// </summary> private string[] GetSiteCultures() { CMSList <string> sortedCultures = new CMSList <string>(false, true); sortedCultures.Add(LocalizationContext.PreferredCultureCode, CultureHelper.GetDefaultCultureCode(currentSiteName)); foreach (var culture in CultureSiteInfoProvider.GetSiteCultureCodes(currentSiteName)) { sortedCultures.Add(culture); } return(sortedCultures.ToArray()); }
public LanguageSelectorItem[] GetUrlsForLanguageSelector(string aliasPath) { var siteCultureCodes = CultureSiteInfoProvider.GetSiteCultureCodes(SiteContext.CurrentSiteName); var tree = new TreeProvider(MembershipContext.AuthenticatedUser); var documents = tree.SelectNodes() .Path(aliasPath, PathTypeEnum.Explicit) .OnSite(SiteContext.CurrentSiteName) .AllCultures(); var selectorItems = new List <LanguageSelectorItem>(siteCultureCodes.Count); foreach (var code in siteCultureCodes) { var localizedName = CultureInfoProvider.GetCultureInfo(code).CultureShortName; var localizedFound = false; foreach (var document in documents) { if (document.DocumentCulture == code) { localizedFound = true; selectorItems.Add(new LanguageSelectorItem { Code = code, Language = localizedName, Url = document.DocumentUrlPath + "?lang=" + code }); } } if (!localizedFound) { selectorItems.Add(new LanguageSelectorItem { Code = code, Language = localizedName, Url = "/?lang=" + code }); } } return(selectorItems.ToArray()); }
/// <summary> /// Loads all existing product departments as filtering options into the department drop-down list. /// </summary> private void InitializeDepartments() { // Gets all product departments from the system's database var ClassNames = "SME.Event"; var siteCode = CultureSiteInfoProvider.GetSiteCultureCodes(SiteContext.CurrentSiteName)[0].ToString(); var documents = TreeHelper.GetDocuments(SiteContext.CurrentSiteName, string.Empty, siteCode, false, ClassNames, string.Empty, string.Empty, 0, true, 0, "EventType, EventID"); // Checks that at least one product department exists if (!DataHelper.DataSourceIsEmpty(documents)) { // Binds the departments to the drop-down list this.drpDepartment.DataSource = documents; this.drpDepartment.DataTextField = "EventType"; this.drpDepartment.DataValueField = "EventID"; this.drpDepartment.DataBind(); // Adds the default '(all)' option this.drpDepartment.Items.Insert(0, new ListItem("(all)", "##ALL##")); } }
/// <summary> /// Updates the current Group or creates new if no GroupID is present. /// </summary> public void SaveData() { if (!CheckPermissions("cms.groups", PERMISSION_MANAGE, GroupID)) { return; } // Validate form entries string errorMessage = ValidateForm(); if (!String.IsNullOrEmpty(errorMessage)) { // Display error message ShowError(errorMessage); return; } try { bool newGroup = false; // Update existing item if (groupInfo == null) { groupInfo = new GroupInfo(); newGroup = true; } // Trim display name and code name string displayName = txtDisplayName.Text.Trim(); string codeName = txtCodeName.Text.Trim(); if (displayName != groupInfo.GroupDisplayName) { // Refresh a breadcrumb if used in the tabs layout ScriptHelper.RefreshTabHeader(Page, displayName); } if (DisplayAdvanceOptions) { // Update Group fields groupInfo.GroupDisplayName = displayName; groupInfo.GroupName = codeName; groupInfo.GroupNodeGUID = ValidationHelper.GetGuid(groupPageURLElem.Value, Guid.Empty); } if (AllowChangeGroupDisplayName && IsLiveSite) { groupInfo.GroupDisplayName = displayName; } groupInfo.GroupDescription = txtDescription.Text; groupInfo.GroupAccess = GetGroupAccess(); groupInfo.GroupSiteID = SiteID; groupInfo.GroupApproveMembers = GetGroupApproveMembers(); groupInfo.GroupSendJoinLeaveNotification = chkJoinLeave.Checked; groupInfo.GroupSendWaitingForApprovalNotification = chkWaitingForApproval.Checked; groupPictureEdit.UpdateGroupPicture(groupInfo); // If new group was created if (newGroup) { // Set columns GroupCreatedByUserID and GroupApprovedByUserID to current user var user = MembershipContext.AuthenticatedUser; if (user != null) { groupInfo.GroupCreatedByUserID = user.UserID; groupInfo.GroupApprovedByUserID = user.UserID; groupInfo.GroupApproved = true; } } if (!IsLiveSite && (groupInfo.GroupNodeGUID == Guid.Empty)) { plcStyleSheetSelector.Visible = false; } // Save theme int selectedSheetID = ValidationHelper.GetInteger(ctrlSiteSelectStyleSheet.Value, 0); if (plcStyleSheetSelector.Visible) { if (groupInfo.GroupNodeGUID != Guid.Empty) { // Save theme for every site culture var cultures = CultureSiteInfoProvider.GetSiteCultureCodes(SiteContext.CurrentSiteName); if (cultures != null) { TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Return class name of selected tree node TreeNode treeNode = tree.SelectSingleNode(groupInfo.GroupNodeGUID, TreeProvider.ALL_CULTURES, SiteContext.CurrentSiteName); if (treeNode != null) { // Return all culture version of node DataSet ds = tree.SelectNodes(SiteContext.CurrentSiteName, null, TreeProvider.ALL_CULTURES, false, treeNode.NodeClassName, "NodeGUID ='" + groupInfo.GroupNodeGUID + "'", String.Empty, -1, false); if (!DataHelper.DataSourceIsEmpty(ds)) { // Loop through all nodes foreach (DataRow dr in ds.Tables[0].Rows) { // Create node and set tree provider for user validation TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["className"], String.Empty), dr); node.TreeProvider = tree; // Update stylesheet id if set if (selectedSheetID == 0) { node.DocumentStylesheetID = 0; node.DocumentInheritsStylesheet = true; } else { node.DocumentStylesheetID = selectedSheetID; } node.Update(); } } } } } } if (!IsLiveSite && (groupInfo.GroupNodeGUID != Guid.Empty)) { plcStyleSheetSelector.Visible = true; } if (plcOnline.Visible) { // On-line marketing setting is visible => set flag according to checkbox groupInfo.GroupLogActivity = chkLogActivity.Checked; } else { // On-line marketing setting is not visible => set flag to TRUE as default value groupInfo.GroupLogActivity = true; } // Save Group in the database GroupInfoProvider.SetGroupInfo(groupInfo); groupPictureEdit.GroupInfo = groupInfo; txtDisplayName.Text = groupInfo.GroupDisplayName; txtCodeName.Text = groupInfo.GroupName; // Flush cached information DocumentContext.CurrentDocument = null; DocumentContext.CurrentPageInfo = null; // Display information on success ShowChangesSaved(); // If new group was created if (newGroup) { GroupID = groupInfo.GroupID; RaiseOnSaved(); } } catch (Exception ex) { // Display error message ShowError(GetString("general.saveerror"), ex.Message, null); } }
public SiteCultureConstraint(string siteName) { var siteCultureNames = CultureSiteInfoProvider.GetSiteCultureCodes(siteName); _allowedCultureNames = new HashSet <string>(siteCultureNames, StringComparer.InvariantCultureIgnoreCase); }