Exemplo n.º 1
0
        /// <summary>
        /// Initializes the language link.
        /// Checks the number of available and enabled languages. If more than two,
        /// populates a dropdown-menu with the available and enabled languages.
        /// Otherwise sets the link to the not currently active language.
        /// </summary>
        private void SetLanguage()
        {
            PageDataCollection languageBranches = DataFactory.Instance.GetLanguageBranches(CurrentPage.PageLink);

            //Filter so pages with Replacement language is filtered away.
            new FilterReplacementLanguage().Filter(languageBranches);

            if (languageBranches.Count > 2)
            {
                LanguageList.Visible = LanguageListLabel.Visible = LanguageButton.Visible = LanguageList.Parent.Visible = true;
                foreach (PageData languageBranch in languageBranches.Where(p => p.LanguageID != CurrentPage.LanguageID && LanguageBranch.Load(p.LanguageID).Enabled))
                {
                    LanguageList.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(languageBranch.LanguageID).NativeName, languageBranch.LanguageID));
                }
            }
            else
            {
                foreach (PageData languageBranch in languageBranches.Where(p => p.LanguageID != CurrentPage.LanguageID && LanguageBranch.Load(p.LanguageID).Enabled))
                {
                    Language.Visible     = Language.Parent.Visible = true;
                    Language.NavigateUrl = EPiServer.UriSupport.AddLanguageSelection(languageBranch.LinkURL, languageBranch.LanguageID);
                    Language.Text        = Translate(new CultureInfo(languageBranch.LanguageID).NativeName);
                    break;
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Filters the specified pages.
 /// </summary>
 /// <param name="pages">The pages.</param>
 public void Filter(PageDataCollection pages)
 {
     var output = new PageDataCollection();
     pages.Where(x => !this.notAllowedPageTypes.Any(k => k == x.PageTypeName)).ToList().ForEach(l => output.Add(l));
     pages.Clear();
     output.ToList().ForEach(x => pages.Add(x));
 }
Exemplo n.º 3
0
        public void PageType_Filter(object sender, FilterEventArgs e)
        {
            if (_pagesToShow == null || !_pagesToShow.Any())
            {
                e.Pages.RemoveRange(0, e.Pages.Count);
                return;
            }

            var clone = new PageDataCollection(e.Pages);
            foreach (var page in clone.Where(p => !_pagesToShow.Contains(p.PageLink.ID)))
            {
                e.Pages.Remove(page);
            }
        }
Exemplo n.º 4
0
        public void PageType_Filter(object sender, FilterEventArgs e)
        {
            if (_pagesToShow == null || !_pagesToShow.Any())
            {
                e.Pages.RemoveRange(0, e.Pages.Count);
                return;
            }

            var clone = new PageDataCollection(e.Pages);

            foreach (var page in clone.Where(p => !_pagesToShow.Contains(p.PageLink.ID)))
            {
                e.Pages.Remove(page);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Set statistics to the tag pages. Adds a tag page if required.
        /// Also deletes any tag pages if the corresponding category has been deleted manually.
        /// </summary>
        /// <param name="tagStats">The usage statistics collection.</param>
        /// <param name="startPage">The start page for the blog.</param>
        /// <param name="isTeamLevel">If set to <c>true</c> we are on a team level blog.</param>
        private static void SetStatsToPages(Dictionary <string, int> tagStats, PageData startPage, bool isTeamLevel)
        {
            if (startPage[BlogUtility.TagContainerPropertyName] == null)
            {
                return;
            }

            PageData                 tagContainer = DataFactory.Instance.GetPage((PageReference)startPage[BlogUtility.TagContainerPropertyName]);
            PageDataCollection       tagPages     = DataFactory.Instance.GetChildren(tagContainer.PageLink);
            PageData                 tagPage;
            Dictionary <string, int> tagCloudValues = CreateTagCloudValues(tagStats);

            foreach (string key in tagStats.Keys)
            {
                if (FindPageByName(key, tagPages, out tagPage))
                {
                    if (tagStats[key] > 0)
                    {
                        tagPage = tagPage.CreateWritableClone();
                        tagPage[BlogUtility.UsageStatisticsPropertyName] = tagStats[key];
                        tagPage[BlogUtility.TagCloudValuePropertyName]   = tagCloudValues[key];
                        DataFactory.Instance.Save(tagPage, SaveAction.Publish, AccessLevel.NoAccess);
                    }
                    else
                    {
                        DataFactory.Instance.Delete(tagPage.PageLink, true, AccessLevel.NoAccess);
                    }
                }
                else if (tagStats[key] > 0)
                {
                    //Create tag Page
                    tagPage            = DataFactory.Instance.GetDefaultPageData(tagContainer.PageLink, BlogUtility.ListPageTypeName);
                    tagPage.PageName   = key;
                    tagPage.URLSegment = UrlSegment.CreateUrlSegment(tagPage);
                    tagPage[BlogUtility.IsTagListingPropertyName]    = true;
                    tagPage[BlogUtility.IsTeamLevelPropertyName]     = isTeamLevel;
                    tagPage[BlogUtility.UsageStatisticsPropertyName] = tagStats[key];
                    tagPage[BlogUtility.TagCloudValuePropertyName]   = tagCloudValues[key];
                    DataFactory.Instance.Save(tagPage, SaveAction.Publish, AccessLevel.NoAccess);
                }
            }

            //If a category has been deleted we should remove its corresponding tag page.
            foreach (PageData page in tagPages.Where(p => !tagStats.ContainsKey(p.PageName)))
            {
                DataFactory.Instance.Delete(page.PageLink, true, AccessLevel.NoAccess);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Populates the CheckBoxList from the page collection.
        /// </summary>
        private void DataBindVisibilityList()
        {
            PageReference pageLink = GetListPageLink();

            if (!PageReference.IsNullOrEmpty(pageLink))
            {
                VisibilityList.Items.Clear();

                PageDataCollection pages = GetChildren(pageLink);
                EPiServer.Filters.FilterForVisitor.Filter(pages);

                foreach (PageData page in pages.Where(p => !p.PageLink.CompareToIgnoreWorkID(CurrentPage.PageLink)))
                {
                    ListItem item = new ListItem(page.PageName, page.PageLink.ToString());
                    item.Selected = page.VisibleInMenu;
                    VisibilityList.Items.Add(item);
                }
            }
        }
Exemplo n.º 7
0
 public static PageDataCollection AsTyped(this PageDataCollection pages)
 {
     return(new PageDataCollection(pages.Where(page => page != null).Select(PageTypeResolver.Instance.ConvertToTyped)));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Goes through the collection of pages and checks for a matching page by page name.
 /// </summary>
 /// <param name="name">The page name to search for.</param>
 /// <param name="pages">The PageDataCollection to search in.</param>
 /// <param name="pageToReturn">Any successful match.</param>
 /// <returns>True if page is found, otherwise false</returns>
 private static bool FindPageByName(string name, PageDataCollection pages, out PageData pageToReturn)
 {
     pageToReturn = pages.Where(p => p.PageName.Equals(name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
     return(pageToReturn != null);
 }
Exemplo n.º 9
0
 //Removes any events that has an EventStopDate that is in the past.
 private static PageDataCollection ClearObsoleteEvents(PageDataCollection upcomingEvents)
 {
     return(new PageDataCollection(upcomingEvents.Where(p => ((DateTime)p["EventStopDate"]) > DateTime.Now)));
 }