예제 #1
0
        private static PageReference CreateOrganisationalUnitFolderPage(IContentRepository contentRepository, ContentReference parent)
        {
            OrganisationalUnitFolderPage defaultPageData = contentRepository.GetDefault <OrganisationalUnitFolderPage>(parent, typeof(OrganisationalUnitFolderPage).GetPageType().ID, LanguageSelector.AutoDetect().Language);

            defaultPageData.PageName   = ORGANISATIONAL_UNIT_FOLDER_NAME;
            defaultPageData.URLSegment = UrlSegment.CreateUrlSegment(defaultPageData);
            return(contentRepository.Save(defaultPageData, SaveAction.Publish, AccessLevel.Publish).ToPageReference());
        }
예제 #2
0
        private PageReference CreateDatePage(IContentRepository contentRepository, ContentReference parent, string name, DateTime startPublish)
        {
            BlogListPage defaultPageData = contentRepository.GetDefault <BlogListPage>(parent, typeof(BlogListPage).GetPageType().ID, LanguageSelector.AutoDetect().Language);

            defaultPageData.PageName     = name;
            defaultPageData.Heading      = name;
            defaultPageData.StartPublish = startPublish;
            defaultPageData.URLSegment   = UrlSegment.CreateUrlSegment(defaultPageData);
            return(contentRepository.Save(defaultPageData, SaveAction.Publish, AccessLevel.Publish).ToPageReference());
        }
예제 #3
0
        private static PageReference CreateOrganisationalUnitFolderPage(IContentRepository contentRepository, ContentReference parent)
        {
            OrganisationalUnitFolderPage defaultPageData = contentRepository.GetDefault <OrganisationalUnitFolderPage>(parent, typeof(OrganisationalUnitFolderPage).GetPageType().ID, LanguageSelector.AutoDetect().Language);

            defaultPageData.PageName        = ORGANISATIONAL_UNIT_FOLDER_NAME;
            defaultPageData.URLSegment      = UrlSegment.CreateUrlSegment(defaultPageData);
            defaultPageData.MenuDescription = "Containing all the organisational units for the compare service";
            defaultPageData.MenuTitle       = "Organisational units for the compare service";
            defaultPageData.VisibleInMenu   = false;
            return(contentRepository.Save(defaultPageData, SaveAction.Publish, AccessLevel.Publish).ToPageReference());
        }
예제 #4
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);
            }
        }
예제 #5
0
        /// <summary>
        /// Copies the selected workroom template to create an active workrooms.
        /// Sets up the name of the new workroom.
        /// </summary>
        /// <param name="templateRef">A reference to the selected workroom template</param>
        /// <returns>The new workroom startpage.</returns>
        private PageData CopyAndSetUpWorkroomPage(PageReference templateRef)
        {
            //Copy page structure wihout access check of source pages since the user might not have read access to the template pages.
            PageReference newWorkroomRef = DataFactory.Instance.Copy(templateRef, CurrentPageLink, AccessLevel.NoAccess, AccessLevel.Publish, true, false);
            PageData      newWorkroom    = DataFactory.Instance.GetPage(newWorkroomRef).CreateWritableClone();

            newWorkroom.PageName = NewWorkroomName.Text.ToSafeString();
            newWorkroom[_mainBodyPropertyName] = NewWorkroomDescription.Text.ToSafeString();
            newWorkroom.URLSegment             = String.Empty;

            newWorkroom.URLSegment          = UrlSegment.CreateUrlSegment(newWorkroom);
            newWorkroom["WorkroomTemplate"] = templateRef;
            newWorkroom.VisibleInMenu       = true;
            DataFactory.Instance.Save(newWorkroom, SaveAction.Publish);

            return(newWorkroom);
        }