/// <summary> /// Populate the replacement dictionary /// </summary> /// <param name="replacementsDictionary">The replacements dictionary</param> public override void PopulateReplacementDictionary(Dictionary <string, string> replacementsDictionary) { base.PopulateReplacementDictionary(replacementsDictionary); welcomePageType = WelcomePageType.WebPartPage; string selectedWebTemplateId = _webTemplateProperties.WebTemplateInfo.Name; string siteDefinitionName = selectedWebTemplateId.Substring(0, selectedWebTemplateId.IndexOf('#')); string siteDefinitionConfig = selectedWebTemplateId.Substring(selectedWebTemplateId.IndexOf('#') + 1); projectItemName = replacementsDictionary["$rootname$"]; replacementsDictionary["$onet$"] = GetOnetContents(DTEManager.ProjectService, siteDefinitionName, siteDefinitionConfig, _webTemplateProperties.WebTemplateInfo.SetupPath, projectItemName, _webTemplateProperties.Title, replacementsDictionary, out welcomePageType); replacementsDictionary["$siteDefinitionName$"] = siteDefinitionName; replacementsDictionary["$siteDefinitionConfig$"] = siteDefinitionConfig; replacementsDictionary["$siteDefinitionId$"] = _webTemplateProperties.WebTemplateInfo.Id.ToString(); replacementsDictionary["$siteDefinitionCategory$"] = _webTemplateProperties.WebTemplateInfo.DisplayCategory; replacementsDictionary["$webTempTitle$"] = _webTemplateProperties.Title; }
/// <summary> /// Gets the onet contents. /// </summary> /// <param name="projectService">The project service.</param> /// <param name="siteDefinitionName">Name of the site definition.</param> /// <param name="siteDefinitionConfig">The site definition config.</param> /// <param name="setupPath">The setup path.</param> /// <param name="webTemplateName">Name of the web template.</param> /// <param name="webTemplateTitle">The web template title.</param> /// <param name="replacements">The replacements.</param> /// <param name="welcomePageType">Type of the welcome page.</param> /// <returns></returns> private string GetOnetContents(ISharePointProjectService projectService, string siteDefinitionName, string siteDefinitionConfig, string setupPath, string webTemplateName, string webTemplateTitle, IDictionary <string, string> replacements, out WelcomePageType welcomePageType) { string onetContents = String.Empty; welcomePageType = WelcomePageType.WebPartPage; string templatesFolderPath = projectService.SharePointConnection.ExecuteCommand <string, string>(ObjectModelSharePointCommandIds.GetFullSPRootFolderPath, @"TEMPLATE"); string siteDefinitionOnetPath = Path.Combine(templatesFolderPath, String.IsNullOrEmpty(setupPath) ? Path.Combine("SiteTemplates", siteDefinitionName) : setupPath, @"xml\onet.xml"); XElement xProject = XElement.Parse(File.ReadAllText(siteDefinitionOnetPath)); xProject.Descendants("ListTemplates").Remove(); xProject.Descendants("DocumentTemplates").Remove(); xProject.Descendants("ServerEmailFooter").Remove(); xProject.Descendants("Configurations").Descendants("Configuration").Where(xConfig => xConfig.Attribute("ID").Value != siteDefinitionConfig).Remove(); xProject.Descendants("Configurations").Descendants("Configuration").Descendants("Modules").Remove(); xProject.Descendants("Modules").Remove(); xProject.Attribute("Title").Value = webTemplateTitle; XElement xConfiguration = xProject.Descendants("Configurations").Descendants("Configuration").First(); xConfiguration.Attribute("ID").Value = "0"; xConfiguration.Attribute("Name").Value = webTemplateName; XElement xWebFeatures = xConfiguration.Descendants("WebFeatures").First(); xWebFeatures.Add( new XComment(String.Format("{0} Welcome Page", webTemplateTitle)), new XElement("Feature", new XAttribute("ID", replacements["$guid3$"])), new XComment(String.Format("{0} Stamp", webTemplateTitle)), new XElement("Feature", new XAttribute("ID", replacements["$guid2$"]))); onetContents = xProject.ToString(); if (onetContents.IndexOf("00BFEA71-D8FE-4FEC-8DAD-01C19A6E4053", StringComparison.InvariantCultureIgnoreCase) > 0) { welcomePageType = WelcomePageType.WikiPage; } else if (onetContents.IndexOf("94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB", StringComparison.InvariantCultureIgnoreCase) > 0) { welcomePageType = WelcomePageType.PublishingPage; } return(onetContents); }