Пример #1
0
        public static SitePage GetPage(string pageIdOrNameOrShortUrl)
        {
            var page = PageProvider.GetPageByName(pageIdOrNameOrShortUrl);

            if (page == null)
            {
                page = PageProvider.GetPageByShortUrl(pageIdOrNameOrShortUrl);
            }
            if (page == null)
            {
                page = PageProvider.GetPageById(pageIdOrNameOrShortUrl);
            }
            if (page != null)
            {
                page.Controls = PageProvider.GetControls(page.PageId).ToArray();
                SitePage sp = new SitePage();
                sp.Page = page;
                if (!string.IsNullOrEmpty(page.TemplateName))
                {
                    string tn = page.TemplateName;
                    LinkedList <PageTemplate>     llt  = new LinkedList <PageTemplate>();
                    LinkedListNode <PageTemplate> last = null;
                    while (!string.IsNullOrEmpty(tn))
                    {
                        var t = PageTemplateProvider.GetTemplate(page.SiteId, tn);
                        if (t != null)
                        {
                            t.Controls = PageTemplateProvider.GetControls(t.SiteId, t.TemplateName).ToArray();
                            tn         = t.ParentTemplateName;
                            if (last == null)
                            {
                                last = llt.AddLast(t);
                            }
                            else
                            {
                                last = llt.AddBefore(last, t);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    sp.Templates = llt;
                }
                return(sp);
            }
            return(null);
        }
Пример #2
0
 public static SitePage GetPage(string pageIdOrNameOrShortUrl)
 {
     var page = PageProvider.GetPageByName(pageIdOrNameOrShortUrl);
     if (page == null)
         page = PageProvider.GetPageByShortUrl(pageIdOrNameOrShortUrl);
     if(page == null)
         page = PageProvider.GetPageById(pageIdOrNameOrShortUrl);
     if (page != null)
     {
         page.Controls = PageProvider.GetControls(page.PageId).ToArray();
         SitePage sp = new SitePage();
         sp.Page = page;
         if (!string.IsNullOrEmpty(page.TemplateName))
         {
             string tn = page.TemplateName;
             LinkedList<PageTemplate> llt = new LinkedList<PageTemplate>();
             LinkedListNode<PageTemplate> last = null;
             while (!string.IsNullOrEmpty(tn))
             {
                 var t = PageTemplateProvider.GetTemplate(page.SiteId, tn);
                 if (t != null)
                 {
                     t.Controls = PageTemplateProvider.GetControls(t.SiteId, t.TemplateName).ToArray();
                     tn = t.ParentTemplateName;
                     if (last == null)
                     {
                         last = llt.AddLast(t);
                     }
                     else
                     {
                         last = llt.AddBefore(last, t);
                     }
                 }
                 else
                 {
                     break;
                 }
             }
             sp.Templates = llt;
         }
         return sp;
     }
     return null;
 }