Пример #1
0
        private bool IsPagePublished(PageNode node, CultureInfo culture)
        {
            PageData pageData = node.GetPageData(culture);

            if (SystemManager.CurrentContext.AppSettings.Multilingual && culture.Equals(SystemManager.CurrentContext.AppSettings.DefaultFrontendLanguage) && pageData.PublishedTranslations.Count == 0 && pageData.Visible)
            {
                return(true);
            }
            return(pageData.IsPublishedInCulture(culture));
        }
Пример #2
0
        public void Delete_PageNodeIsNull_ThrowsException()
        {
            //arrange
            PageNode pageNode = null;

            //act+ assert
            Assert.That(() => _pageNodeService.Delete(pageNode),
                        Throws.Exception.TypeOf <ArgumentException>()
                        .With.Message.EqualTo(Messages.PageNodeCannotBeNull));
        }
Пример #3
0
        private void ProductsList_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
        {
            if (e.Item is RadListViewDataItem)
            {
                HtmlControl    heading3     = e.Item.FindControl("ProductTitle") as HtmlControl;
                DynamicContent productItem  = ((RadListViewDataItem)e.Item).DataItem as DynamicContent;
                string         productTitle = String.Empty;

                if (productItem != null)
                {
                    productTitle = productItem.GetString("Title");
                }

                if (heading3 != null)
                {
                    if (productTitle.StartsWith("EU"))
                    {
                        HtmlGenericControl span = new HtmlGenericControl("span");
                        span.Attributes.Add("class", productNameSpanClass);
                        string  firstPart  = productTitle.Substring(0, 2);
                        string  secondPart = productTitle.Substring(2);
                        Literal literalEU  = new Literal();
                        literalEU.Text = firstPart;
                        heading3.Controls.Add(literalEU);

                        span.InnerText = secondPart;
                        heading3.Controls.Add(span);
                    }
                    else
                    {
                        Literal productTitleLtl = new Literal();
                        productTitleLtl.Text = productTitle;
                        heading3.Controls.Add(productTitleLtl);
                    }
                }

                //Add NavigateUrl to Policy Coverage link
                HyperLink policyCoverageLink     = e.Item.FindControl("PolicyCoverageLink") as HyperLink;
                PageNode  policyCoveragePageNode = productItem.GetValue("PolicyCoverageLandingPage") as PageNode;

                if (policyCoverageLink != null && policyCoveragePageNode != null)
                {
                    policyCoverageLink.NavigateUrl = PagesUtilities.GetPageUrlByPageNode(policyCoveragePageNode);
                }

                //Add NavigateUrl to Read More link
                HyperLink readMoreLink     = e.Item.FindControl("ReadMoreLink") as HyperLink;
                PageNode  readMorePageNode = productItem.GetValue("ReadMoreLandingPage") as PageNode;

                if (readMoreLink != null && readMorePageNode != null)
                {
                    readMoreLink.NavigateUrl = PagesUtilities.GetPageUrlByPageNode(readMorePageNode);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 导入 JSON 文件,生成 Treeview 节点
        /// </summary>
        /// <param name="app"></param>
        /// <param name="tvwAppdata"></param>
        public static AppNode ImportNode(KNXApp app /*, TreeView tv, UIEditor.Entity.ViewNode.PropertiesChangedDelegate proChangedDelegate*/)
        {
            AppNode appNode = null;

            if (app != null)
            {
                //tvwAppdata.BeginUpdate();
                //tvwAppdata.Nodes.Clear();

                appNode = new AppNode(app);

                //tvwAppdata.Nodes.Add(appNode);

                if (app.Areas != null && app.Areas.Count > 0)
                {
                    foreach (KNXArea itemArea in app.Areas)
                    {
                        var areaNode = new AreaNode(itemArea);
                        appNode.Nodes.Add(areaNode);

                        if (itemArea.Rooms != null && itemArea.Rooms.Count > 0)
                        {
                            foreach (KNXRoom itemRoom in itemArea.Rooms)
                            {
                                var roomNode = new RoomNode(itemRoom);
                                areaNode.Nodes.Add(roomNode);

                                if (itemRoom.Pages != null && itemRoom.Pages.Count > 0)
                                {
                                    foreach (KNXPage itemPage in itemRoom.Pages)
                                    {
                                        var pageNode = new PageNode(itemPage);
                                        //pageNode.PropertiesChangedEvent += proChangedDelegate;
                                        roomNode.Nodes.Add(pageNode);

                                        // 给页面添加控件
                                        if (itemPage.Controls != null && itemPage.Controls.Count > 0)
                                        {
                                            foreach (var item in itemPage.Controls)
                                            {
                                                AddControlNode(pageNode, item /*, proChangedDelegate*/);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                //tvwAppdata.EndUpdate();
            }

            return(appNode);
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositeC1SiteMapNode"/> class.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="node">The node.</param>
        /// <param name="data">The data.</param>
        /// <param name="level">The level of the page.</param>
        public CompositeC1SiteMapNode(CompositeC1SiteMapProvider provider, PageNode node, DataConnection data, int level)
            : base(provider, node.Id.ToString(), node.Url, node.MenuTitle, node.Description)
        {
            DocumentTitle = node.Title;
            Depth         = level;
            LastModified  = node.ChangedDate;
            Priority      = 5;

            PageNode = node;
            Culture  = data.CurrentLocale;
        }
Пример #6
0
        private void tabControl_Selected(object sender, TabControlEventArgs e)
        {
            TabPage page = e.TabPage;

            if (null != page)
            {
                PageNode node = page.Tag as PageNode;
                this.curSTPage = node.panel as STPage;
                SetSelectedNode(node);
            }
        }
Пример #7
0
        public override Node VisitPage([NotNull] PageContext context)
        {
            var page = new PageNode(context.Start, context.LABEL().GetText());

            foreach (SectionContext section in context.section())
            {
                page.AddChild(Visit(section));
            }

            return(page);
        }
        public static IList <string> GetPageURLs(PageNode pageNode)
        {
            var pageUrls = new List <string>();

            foreach (var pageDataUrl in pageNode?.Urls)
            {
                pageUrls?.Add(pageDataUrl.Url.Split('/').Last()?.ToLower());
            }

            return(pageUrls);
        }
Пример #9
0
        public MicroServicesPublishingPageBuilderTests()
        {
            fakeSitefinityManagerProxy   = A.Fake <ISitefinityManagerProxy>();
            fakeSitefinityPageDataProxy  = A.Fake <ISitefinityPageDataProxy>();
            fakeSitefinityPageNodeProxy  = A.Fake <ISitefinityPageNodeProxy>();
            fakeDynamicContentExtensions = A.Fake <IDynamicContentExtensions>();

            dummyPublishedDate = DateTime.Now;
            dummyPageNode      = new PageNode();
            dummyPageData      = new PageData();
        }
Пример #10
0
 private void WriteContentPageSitemap(XmlTextWriter writer, PageNode page)
 {
     if (page.ChildPages.Any())
     {
         foreach (PageNode node in page.ChildPages)
         {
             WriteContentPageSitemap(writer, node);
         }
     }
     WriteSitemapNode(writer, BaseUrl + page.Url, page.ChangedDate);
 }
Пример #11
0
 private static void Iterate(PageNode rootNode, StringBuilder builder, int depth)
 {
     foreach (var childNode in rootNode.ChildNodes)
     {
         builder.AppendLine(" ".PadLeft(depth * 2) + childNode.Url);
         if (childNode.ChildNodes.Any())
         {
             Iterate(childNode, builder, depth + 1);
         }
     }
 }
Пример #12
0
        private static IEnumerable <PageNode> AncestorPageNodes(PageNode pageNode)
        {
            var ancestors = new List <PageNode>();

            while (pageNode.ParentPage != null)
            {
                pageNode = pageNode.ParentPage; // crawl up
                ancestors.Add(pageNode);
            }

            return(ancestors);
        }
Пример #13
0
        public override object Visit(PageNode page)
        {
            var pageViewModel = new PageViewModel(page.Label);

            PageViewModels.Add(pageViewModel);
            foreach (var sectionNode in page.ChildNodes)
            {
                pageViewModel.Sections.Sections.Add(sectionNode.Accept(this) as SectionViewModel);
            }

            return(null);
        }
Пример #14
0
 /// <summary>
 /// Sets the current page
 /// </summary>
 /// <param name="page">The pagenode</param>
 public void SetActivePage(PageNode page)
 {
     try
     {
         this.page            = page;
         this.currentPageData = page.GetPageData();
         this.pageHandler     = (Page)SystemManager.CurrentHttpContext.CurrentHandler;
     } catch (Exception e)
     {
         SetModelInvalid("Failed to set active page");
     }
 }
Пример #15
0
        /// <summary>
        /// Republish a page.
        /// </summary>
        /// <param name="pageTitle">The page title.</param>
        public void RepublishPage(string pageTitle)
        {
            PageManager pm = PageManager.GetManager();

            PageNode page = pm.GetPageNodes().FirstOrDefault(pn => pn.Title == pageTitle);

            var pageData = page.GetPageData();
            var master   = pm.PagesLifecycle.GetMaster(pageData);

            pm.PagesLifecycle.Publish(master);
            pm.SaveChanges();
        }
Пример #16
0
        public string ProcessPageNode(PageNode page)
        {
            var rawContent   = _markdown.Transform(page.GetRawContent());
            var templateFile = "~/" + page.Template + ".cshtml";
            var template     = Razor.GetTemplate(templateFile);
            var pageModel    = new PageModel(page, rawContent, page.PageLists);

            return(Razor.ExecuteContent(template,
                                        model: pageModel,
                                        viewbag: page.Properties
                                        ).Result);
        }
Пример #17
0
        private void AddPageNode(TreeNode roomNode)
        {
            if (roomNode != null && roomNode.Name == MyConst.View.KnxRoomType)
            {
                PageNode node = new PageNode();
                roomNode.Nodes.Add(node);

                node.CreateTwinsPageNode();

                TreeViewChangedEventNotify(node, EventArgs.Empty);
            }
        }
Пример #18
0
        public static bool IsCaseStudy(this PageNode page)
        {
            // Fix for SF Revision History system
            if (page == null)
            {
                return(false);
            }

            var contentType = page.GetValue("PageContentType");

            return(contentType != null && contentType.ToString() == "Case Study");
        }
Пример #19
0
        public void Create_PageNodeIsNull_ThrowsException()
        {
            //arrange
            PageNode pageNode = null;

            _dbContextMock.Setup(x => x.GetDbSet <PageNode>()).Returns(new InMemoryDbSet <PageNode>());

            //act + assert
            Assert.That(() => _propertyService.Create(pageNode, null),
                        Throws.Exception.TypeOf <ArgumentNullException>()
                        .With.Message.EqualTo(string.Format(Ensure.ArgumentIsNullMessageFormatMessage, "pageNode")));
        }
        private void PopilateProductsList()
        {
            PageNode productsPage = PagesUtilities.GetPageNodeByTitle("products");
            var      childNodes   = productsPage.Nodes;

            if (productsPage != null && childNodes.Count > 0)
            {
                this.productsList.ItemDataBound += ProductsList_ItemDataBound;
                this.productsList.DataSource     = childNodes;
                this.productsList.DataBind();
            }
        }
        private MicroServicesPublishingPageData BuildPreViewPageData(PageNode pageNode, PageData pageData, PageDraft pageDraft)
        {
            var microServicesPublishingPageData = BuildBasePageData(pageNode, pageData);

            var pageDraftControls = pageDraft.Controls.Where(c => c.Caption == Digital.Core.Constants.ContentBlock);

            foreach (var pageDraftControl in pageDraftControls)
            {
                microServicesPublishingPageData.Content += sitefinityManagerProxy.GetControlContent(pageDraftControl);
            }

            return(microServicesPublishingPageData);
        }
Пример #22
0
 // If pageMgr is passed => recursive build
 public PageTree(PageNode n, PageManager pageMgr = null)
 {
     root     = n;
     filterIn = true;
     if (pageMgr != null)
     {
         children = pageMgr.GetPageNodes().Where(p => p.ParentId == root.Id).Select <PageNode, PageTree>(pn => new PageTree(pn, pageMgr)).ToList();
     }
     else
     {
         children = new List <PageTree>();
     }
 }
Пример #23
0
 //TODOne: VisitPage(): Set current.Next = new Node, then set current = current.Next (you could use MoveForward() here, but feels weird)
 public void VisitPage(string desc)
 {
     if (first == null) // edge case, generating first new page.
     {
         first   = new PageNode(desc);
         current = first;
     }
     else //otherwise, just add a new node to the end.
     {
         current.Next = new PageNode(desc);
         current      = current.Next;
     }
 }
Пример #24
0
        private void FillPages()
        {
            PageNode rootNode = BuildPageTree(_summaries);

            foreach (PageNode pageNode in rootNode.Children)
            {
                TreeNode node = _tvPages.Nodes.Add(pageNode.Page.title);
                node.Tag = pageNode.Page;
                FillChildNodes(pageNode, node);
            }
            _lblProgress.Visible = false;
            _btnOK.Enabled       = true;
        }
Пример #25
0
        protected virtual string ResolveDefaultSiteUrl(PageNode actualPageNode, CultureInfo cultureInfo)
        {
            var  pageUrl            = actualPageNode.GetFullUrl(cultureInfo, false, false);
            var  pageUrlWithCulture = this.UrlService.ResolveUrl(pageUrl, cultureInfo);
            Guid rootNodeId         = actualPageNode.RootNodeId != Guid.Empty ? actualPageNode.RootNodeId : actualPageNode.Id;

            var site            = SystemManager.CurrentContext.MultisiteContext.GetSiteBySiteMapRoot(rootNodeId);
            var siteUrl         = this.GetSiteUrl(site);
            var relativeItemUrl = RouteHelper.ResolveUrl(pageUrlWithCulture, UrlResolveOptions.CurrentRequestRelative);
            var result          = string.Concat(VirtualPathUtility.RemoveTrailingSlash(siteUrl), relativeItemUrl);

            return(result);
        }
Пример #26
0
        /// <summary>
        /// Gets the page nodes by ids.
        /// </summary>
        /// <param name="pageNodeIds">The page node ids.</param>
        /// <returns></returns>
        public static IList <PageNode> GetPageNodesByIds(Guid[] pageNodeIds)
        {
            PageManager      pageManager = PageManager.GetManager();
            IList <PageNode> pageNodes   = new List <PageNode>();

            foreach (var pageNodeId in pageNodeIds)
            {
                PageNode node = pageManager.GetPageNode(pageNodeId);
                pageNodes.Add(node);
            }

            return(pageNodes);
        }
Пример #27
0
        public ChapterObject ParseChapterObject(string content)
        {
            HtmlDocument ChapterObjectDocument = new HtmlDocument();

            ChapterObjectDocument.LoadHtml(content);

            ChapterObject      ParsedChapterObject = new ChapterObject();
            HtmlNodeCollection PageNodes           = ChapterObjectDocument.GetElementbyId("page_select").SelectNodes(".//option");

            if (PageNodes != null && PageNodes.Count > 0)
            {
                foreach (HtmlNode PageNode in PageNodes)
                {
                    HtmlNode PrevNode      = PageNode.SelectSingleNode(".//preceding-sibling::option"),
                                  NextNode = PageNode.SelectSingleNode(".//following-sibling::option");

                    UInt32 PageNumber  = UInt32.Parse(PageNode.NextSibling.InnerText.Substring(5));
                    String PageUrl     = PageNode.Attributes["value"].Value,
                           NextPageUrl = (NextNode != null) ? NextNode.Attributes["value"].Value : null,
                           PrevPageUrl = (PrevNode != null) ? PrevNode.Attributes["value"].Value : null;

                    if (!String.IsNullOrWhiteSpace(PageUrl))
                    {
                        String PageHash = PageUrl.Split('#').Last().Split('_').First();
                        PageUrl = String.Format("https://bato.to/areader?id={0}&p={1}&supress_webtoon=t", PageHash, PageNumber);
                    }

                    if (!String.IsNullOrWhiteSpace(NextPageUrl))
                    {
                        String PageHash = NextPageUrl.Split('#').Last().Split('_').First();
                        NextPageUrl = String.Format("https://bato.to/areader?id={0}&p={1}&supress_webtoon=t", PageHash, PageNumber + 1);
                    }

                    if (!String.IsNullOrWhiteSpace(PrevPageUrl))
                    {
                        String PageHash = PrevPageUrl.Split('#').Last().Split('_').First();
                        PrevPageUrl = String.Format("https://bato.to/areader?id={0}&p={1}&supress_webtoon=t", PageHash, PageNumber - 1);
                    }

                    ParsedChapterObject.Pages.Add(new PageObject()
                    {
                        PageNumber = PageNumber,
                        Url        = PageUrl,
                        NextUrl    = NextPageUrl,
                        PrevUrl    = PrevPageUrl
                    });
                }
            }

            return(ParsedChapterObject);
        }
Пример #28
0
        /// <summary>
        /// Denies a specific page permissions for selected role.
        /// </summary>
        /// <param name="roleName">The role name.</param>
        /// <param name="roleProvider">The role provider name.</param>
        /// <param name="pageTitle">The page title.</param>
        public void DenyPermissionsForRole(string roleName, string roleProvider, string pageTitle)
        {
            RoleManager roleManager = RoleManager.GetManager(roleProvider);
            var         role        = roleManager.GetRole(roleName);

            PageManager pagemanager = PageManager.GetManager();
            PageNode    mypage      = pagemanager.GetPageNodes().FirstOrDefault(pn => pn.Title == pageTitle);

            if (mypage != null)
            {
                pagemanager.BreakPermiossionsInheritance(mypage);
                pagemanager.SaveChanges();

                if (role != null)
                {
                    var perm = pagemanager.GetPermissions()
                               .Where(p =>
                                      p.SetName == SecurityConstants.Sets.Pages.SetName &&
                                      p.PrincipalId == role.Id &&
                                      p.ObjectId == mypage.Id)
                               .SingleOrDefault();

                    if (perm == null)
                    {
                        perm = pagemanager.CreatePermission(
                            SecurityConstants.Sets.Pages.SetName,
                            mypage.Id,
                            role.Id);

                        mypage.Permissions.Add(perm);
                    }

                    perm = pagemanager.GetPermission(
                        SecurityConstants.Sets.Pages.SetName,
                        mypage.Id,
                        role.Id);

                    perm.DenyActions(
                        false,
                        SecurityConstants.Sets.Pages.View,
                        SecurityConstants.Sets.Pages.Create,
                        SecurityConstants.Sets.Pages.Modify,
                        SecurityConstants.Sets.Pages.CreateChildControls,
                        SecurityConstants.Sets.Pages.EditContent,
                        SecurityConstants.Sets.Pages.ChangeOwner,
                        SecurityConstants.Sets.Pages.Delete);

                    pagemanager.SaveChanges();
                }
            }
        }
        protected void InstallPages(SiteInitializer initializer)
        {
            var pageManager = initializer.PageManager;
            var moduleNode  = pageManager.GetPageNode(SiteInitializer.DesignNodeId);

            PageNode templateImporterNode = pageManager.GetPageNodes().Where(p => p.Id == TemplateImporterModule.TemplateImporterPageGroupID).SingleOrDefault();

            if (templateImporterNode == null)
            {
                templateImporterNode = initializer.CreatePageNode(TemplateImporterModule.TemplateImporterPageGroupID, moduleNode, NodeType.Group);

                templateImporterNode.Name                     = TemplateImporterModule.ModuleName;
                templateImporterNode.ShowInNavigation         = true;
                templateImporterNode.Attributes["ModuleName"] = TemplateImporterModule.ModuleName;
                templateImporterNode.Title                    = TemplateImporterModule.ModuleName;
                templateImporterNode.UrlName                  = TemplateImporterModule.ModuleName;
                templateImporterNode.Description              = "Module for importing Template packages";
            }

            var landingPage = pageManager.GetPageNodes().SingleOrDefault(p => p.Id == this.LandingPageId);

            if (landingPage == null)
            {
                var pageInfo = new PageDataElement()
                {
                    PageId      = this.LandingPageId,
                    Name        = "TemplateImporter",
                    MenuName    = "TemplateImporter Module",
                    UrlName     = "TemplateImporter",
                    Description = "TemplateImporterLandingPageDescription",
                    HtmlTitle   = "Template Importer",
                    //ResourceClassId = typeof(TemplateImporterResources).Name,
                    IncludeScriptManager = true,
                    ShowInNavigation     = false,
                    EnableViewState      = false,
                    TemplateName         = SiteInitializer.BackendTemplateName,
                };

                pageInfo.Parameters["ModuleName"] = TemplateImporterModule.ModuleName;

                TemplateImporterServerControl control = new TemplateImporterServerControl();

                Control[] pageControls = new Control[]
                {
                    control
                };

                initializer.CreatePageFromConfiguration(pageInfo, templateImporterNode, pageControls);
            }
        }
Пример #30
0
        /// <summary>
        /// Linearization requires that each page has it's own resource dictionary
        /// </summary>
        /// <param name="pages"></param>
        /// <returns></returns>
        private PageNode BuildLinearizedPageTree(List <PdfPage> pages)
        {
            var root = new PageNode();

            foreach (var page in pages)
            {
                var pageToAdd = this.BuildPage(page);
                pageToAdd.Resources = page.GetResources();
                pageToAdd.Parent    = root;
                root.Kids.Add(pageToAdd);
            }

            return(root);
        }
 protected override string ResolvePageUrl(PageNode pageNode, CultureInfo targetCulture, bool useNewImplementation)
 {
     return string.Empty;
 }
 protected virtual string ResolvePageUrl(PageNode pageNode, CultureInfo targetCulture, bool useNewImplementation)
 {
     return this.urlService.ResolvePageUrl(pageNode, targetCulture, true);
 }
Пример #33
0
 protected virtual string ResolveDefaultSiteUrl(PageNode actualPageNode, CultureInfo cultureInfo)
 {
     var fullUrl = actualPageNode.GetFullUrl(cultureInfo, false, false);
     var siteUrl = this.UrlService.ResolveUrl(fullUrl, cultureInfo);
     siteUrl = RouteHelper.ResolveUrl(siteUrl, UrlResolveOptions.Absolute);
     return siteUrl;
 }
Пример #34
0
 private void PublishPage(PageNode page)
 {
     var pageData = page.GetPageData();
     var master = this.PageManager.PagesLifecycle.GetMaster(pageData);
     this.PageManager.PagesLifecycle.Publish(master);
     this.PageManager.SaveChanges();
 }