Exemple #1
0
        public IList <PageLayout> GetPageLayouts()
        {
            rrLock.EnterUpgradeableReadLock();

            try
            {
                if ((pageLayouts == null) || (DateTime.Now.Subtract(lastLoad).TotalSeconds) > cacheInterval)
                {
                    rrLock.EnterWriteLock();
                    try
                    {
                        if (pageLayouts == null)
                        {
                            pageLayouts = new List <PageLayout>();
                            //SPWeb currentWeb = SPContext.Current.Web;
                            //SPWeb rootWeb = currentWeb.Site.RootWeb;

                            SPList PageLayoutLib = SPContext.Current.Site.GetCatalog(SPListTemplateType.MasterPageCatalog);

                            SPQuery oQuery = new SPQuery();
                            oQuery.Query = string.Format("<Where><Contains><FieldRef Name=\"FileLeafRef\" /><Value Type=\"File\">.aspx</Value></Contains></Where><OrderBy><FieldRef Name=\"FileLeafRef\" /></OrderBy>");
                            SPListItemCollection colListItems = PageLayoutLib.GetItems(oQuery);

                            foreach (SPListItem pageLayoutItem in colListItems)
                            {
                                try
                                {
                                    PageLayout pageLayout = PageLayout.CreatePageLayout();
                                    pageLayout.UniqueId    = pageLayoutItem.UniqueId;
                                    pageLayout.Id          = pageLayoutItem.ID;
                                    pageLayout.Name        = pageLayoutItem.Name;
                                    pageLayout.Title       = pageLayout.Name.Replace(".aspx", "").TrimEnd();
                                    pageLayout.Url         = pageLayoutItem.Url;
                                    pageLayout.Icon        = "/_catalogs/masterpage/Preview Images/" + pageLayout.Title + "_32.png";
                                    pageLayout.Preview     = "/_catalogs/masterpage/Preview Images/" + pageLayout.Title + "_preview.png";
                                    pageLayout.Description = "Description:\n " + pageLayout.Description;
                                    ContentTypeIdFieldValue contentType = pageLayoutItem[BuildFieldId.PublishingAssociatedContentType] as ContentTypeIdFieldValue;
                                    //ContentTypeIdFieldValue contentType = pageLayoutItem["ows_ContentTypeId"] as ContentTypeIdFieldValue;
                                    if (contentType != null)
                                    {
                                        pageLayout.ContenTypeId     = contentType.Id;
                                        pageLayout.ContentTypeGroup = contentType.StoredGroup;
                                        pageLayouts.Add(pageLayout);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    ex.ToString();
                                }
                            }
                        }
                    }
                    finally
                    {
                        rrLock.ExitWriteLock();
                    }
                }
                return(pageLayouts);
            }
            finally
            {
                rrLock.ExitUpgradeableReadLock();
            }
        }
Exemple #2
0
        public string GetPageLayoutContent(int Id)
        {
            PageLayout layout = GetPageLayout(Id);

            return(GetPageLayoutContent(layout));
        }
Exemple #3
0
        public string GetPageLayoutContent(string Name)
        {
            PageLayout layout = GetPageLayout(Name);

            return(GetPageLayoutContent(layout));
        }
Exemple #4
0
        public string GetPageLayoutContent(Guid UniqueId)
        {
            PageLayout layout = GetPageLayout(UniqueId);

            return(GetPageLayoutContent(layout));
        }