public void AddRegisterTagSource(SPSRegisterableTag tag) { _spsTemplateManagerIO.AddHeader(string.Format("<%@ Register TagPrefix=\"{0}\" TagName=\"{1}\" src=\"{2}\" %>", tag.TagPrefix, tag.TagName, tag.Src)); }
public void AddRegisterTagNamespace(SPSRegisterableTag tag) { if (!_spsTemplateManagerIO.CheckIfTagExist(tag)) { _spsTemplateManagerIO.AddHeader( string.Format("<%@ Register TagPrefix=\"{0}\" Assembly=\"{1}\" namespace=\"{2}\" %>", tag.TagPrefix, tag.Assembly, tag.NameSpace)); } }
/// <summary> /// Occurs after a Feature is activated. /// </summary> /// <param name="properties">An <see cref="T:Microsoft.SharePoint.SPFeatureReceiverProperties"></see> object that represents the properties of the event.</param> public override void FeatureActivated(SPFeatureReceiverProperties properties) { var manager = new SPSTemplateManager(); var tag = new SPSRegisterableTag { TagName = "SPSProfessional", Assembly = "SPSProfessional.SharePoint.Admin.ListTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4031063ddba1c7c7", NameSpace = "SPSProfessional.SharePoint.Admin.ListTools", Src = "", TagPrefix = "SPS" }; manager.AddRegisterTagNamespace(tag); if (manager.RenderingTemplateExists("ListForm")) { string managerOrigine = manager.GetRenderingTemplate("ListForm"); if (managerOrigine.Contains("<SharePoint:ListFieldIterator")) { string managerUpdated = managerOrigine.Replace("<SharePoint:ListFieldIterator", "<SPS:AdminFormFieldsIterator"); manager.AlterRenderingTemplate("ListForm", managerUpdated); manager.Save(string.Format("DefaultTemplates.ascx.{0}", DateTime.Now.ToString("yyyyMMdd.hhmmss"))); } else { throw new Exception("Install is not able to update SharePoint manager file. The ListForm manager is not standard."); } } else { throw new Exception("Install is not able to update SharePoint manager file. The ListForm manager doesn't exist."); } if (manager.RenderingTemplateExists("ViewSelector")) { string managerOrigine = manager.GetRenderingTemplate("ViewSelector"); if (managerOrigine.Contains("<SharePoint:ViewSelectorMenu")) { string managerUpdated = managerOrigine.Replace("<SharePoint:ViewSelectorMenu", "<SPS:AdminViewSelectorMenu"); manager.AlterRenderingTemplate("ViewSelector", managerUpdated); manager.Save(string.Format("DefaultTemplates.ascx.{0}", DateTime.Now.ToString("yyyyMMdd.hhmmss"))); } else { throw new Exception("Install is not able to update SharePoint manager file. The ViewSelector manager is not standard."); } } else { throw new Exception("Install is not able to update SharePoint manager file. The ViewSelector manager doesn't exist."); } }
internal bool CheckIfTagExist(SPSRegisterableTag tag) { foreach (string str in _headers) { if ((str.Contains(tag.TagPrefix) && str.Contains(tag.Assembly)) && str.Contains(tag.NameSpace)) { return(true); } } return(false); }
internal void DeleteTag(SPSRegisterableTag tag) { foreach (string str in _headers) { if ((str.Contains(tag.TagPrefix) && str.Contains(tag.Assembly)) && str.Contains(tag.NameSpace)) { _headers.Remove(str); _contentChanged = true; break; } } }
/// <summary> /// Occurs when a Feature is deactivated. /// </summary> /// <param name="properties">An <see cref="T:Microsoft.SharePoint.SPFeatureReceiverProperties"></see> object that represents the properties of the event.</param> public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { var manager = new SPSTemplateManager(); var tag = new SPSRegisterableTag { TagName = "SPSProfessional", Assembly = "SPSProfessional.SharePoint.Admin.ListTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4031063ddba1c7c7", NameSpace = "SPSProfessional.SharePoint.Admin.ListTools", Src = "", TagPrefix = "SPS" }; manager.RemoveRegisterTagNamespace(tag); if (manager.RenderingTemplateExists("ListForm")) { string managerOrigine = manager.GetRenderingTemplate("ListForm"); if (managerOrigine.Contains("<SPS:AdminFormFieldsIterator")) { string managerUpdated = managerOrigine.Replace("<SPS:AdminFormFieldsIterator", "<SharePoint:ListFieldIterator"); manager.AlterRenderingTemplate("ListForm", managerUpdated); manager.Save(); } } if (manager.RenderingTemplateExists("ViewSelector")) { string managerOrigine = manager.GetRenderingTemplate("ViewSelector"); if (managerOrigine.Contains("<SPS:AdminViewSelectorMenu")) { string managerUpdated = managerOrigine.Replace("<SPS:AdminViewSelectorMenu", "<SharePoint:ViewSelectorMenu"); manager.AlterRenderingTemplate("ViewSelector", managerUpdated); manager.Save(); } } }
public void RemoveRegisterTagNamespace(SPSRegisterableTag tag) { _spsTemplateManagerIO.DeleteTag(tag); }
public bool CheckIfTagNamespaceExist(SPSRegisterableTag tag) { return(_spsTemplateManagerIO.CheckIfTagExist(tag)); }