Esempio n. 1
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;

            PublishingWeb pWeb           = PublishingWeb.GetPublishingWeb(site.RootWeb);
            bool          pageNotCreated = !pWeb.GetPublishingPages().Cast <PublishingPage>().Any(p => p.Name == pageName);

            if (pageNotCreated)
            {
                //если такой страницы еще нет - создаем ее
                PublishingPage pPage = pWeb.GetPublishingPages().Add(pageName, null);

                pPage.CheckOut();

                using (Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager wpManager = site.RootWeb.GetLimitedWebPartManager(pPage.Url, PersonalizationScope.Shared))
                {
                    ResultScriptWebPart searchResults = GetImportedWebPart(site, wpName) as ResultScriptWebPart;
                    searchResults.Title      = wpTitle;
                    searchResults.ChromeType = PartChromeType.None;

                    wpManager.AddWebPart(searchResults, "Top", 0);
                }

                pPage.CheckIn(string.Empty);
            }
        }
Esempio n. 2
0
 private void EnsurePageCheckOut(PublishingPage page)
 {
     if (page.ListItem.ParentList.ForceCheckout)
     {
         // Only check out if we are forced to do so
         if (page.ListItem.File.CheckOutType == SPFile.SPCheckOutType.None)
         {
             // Only check out if not already checked out
             page.CheckOut();
         }
         else
         {
             this.logger.Warn("Page " + page.Uri.AbsoluteUri + " is already checked out - skipping FolderMaker checkout.");
         }
     }
 }
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb web = properties.Feature.Parent as SPWeb;

            if (web != null)
            {
                if (PublishingWeb.IsPublishingWeb(web))
                {
                    PublishingWeb  pubWeb = PublishingWeb.GetPublishingWeb(web);
                    PublishingPage page   = pubWeb.GetPublishingPages()[PartnerLandingPageUrl];

                    if (page == null)
                    {
                        SPContentTypeId contentTypeId     = new SPContentTypeId(welcomePageLayoutContentTypeId);
                        PageLayout[]    layouts           = pubWeb.GetAvailablePageLayouts(contentTypeId);
                        PageLayout      welcomePageLayout = layouts[0];

                        page = pubWeb.GetPublishingPages().Add(PartnerLandingPageFileName, welcomePageLayout);
                    }
                    else
                    {
                        page.CheckOut();
                    }

                    page.ListItem[titleFieldId]                  = PartnerLandingPageTile;
                    page.ListItem[DescriptionField]              = Resources.PageDescription;
                    page.ListItem[pageContentFieldId]            = Resources.PageContent;
                    page.ListItem[partnerSpecificContentFieldId] = Resources.PartnerSpecificContent;
                    page.Update();

                    SPFile welcomeFile = web.GetFile(page.Url);
                    pubWeb.DefaultPage = welcomeFile;
                    pubWeb.Update();

                    page.CheckIn(Resources.CheckInValue);
                }
            }
        }
Esempio n. 4
0
        public static PublishingPage CreatePublishingPage(PublishingWeb CurrentPublishingWeb, string newPageName, PageLayout pageLayout, SPFolder folder, bool doCreateFriendlyUrl)
        {
            PublishingPage publishingPage = null;
            bool           tryNakedToken  = true;

            do
            {
                try
                {
                    if (doCreateFriendlyUrl)
                    {
                        newPageName = GetUniquePageName(newPageName, tryNakedToken, CurrentPublishingWeb, true, folder);
                    }
                    if (!newPageName.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase))
                    {
                        newPageName += ".aspx";
                    }
                    publishingPage = ((folder != null) ? CurrentPublishingWeb.AddPublishingPage(newPageName, pageLayout, folder) : CurrentPublishingWeb.AddPublishingPage(newPageName, pageLayout));
                    if (publishingPage != null && doCreateFriendlyUrl && publishingPage.ListItem.ParentList.ForceCheckout)
                    {
                        publishingPage.CheckIn(string.Empty);
                        publishingPage.CheckOut();
                    }
                }
                catch (SPException ex)
                {
                    if (doCreateFriendlyUrl && (ex.ErrorCode == -2130575306 || ex.ErrorCode == -2130575257))
                    {
                        tryNakedToken = false;
                        goto end_IL_0082;
                    }
                    throw;
                    end_IL_0082 :;
                }
            }while (doCreateFriendlyUrl && publishingPage == null);
            return(publishingPage);
        }
Esempio n. 5
0
 private void EnsurePageCheckOut(PublishingPage page)
 {
     if (page.ListItem.ParentList.ForceCheckout)
     {
         // Only check out if we are forced to do so
         if (page.ListItem.File.CheckOutType == SPFile.SPCheckOutType.None)
         {
             // Only check out if not already checked out
             page.CheckOut();
         }
         else
         {
             this.logger.Warn("Page " + page.Uri.AbsoluteUri + " is already checked out - skipping FolderMaker checkout.");
         }
     }
 }