SharePoint and HTML5 Technical Implementation
Publishing Utilities
public static class PublishingUtilities
{
public static string GetHTML5Master(string aMasterPageFile)
{
string aReturnString = "";
if (aMasterPageFile.EndsWith(PublishingDefinitions.GeneralMasterPageSuffix))
{
aReturnString = aMasterPageFile.Replace(PublishingDefinitions.XHTMLMasterPageSuffix, PublishingDefinitions.HTML5MasterPageSuffix);
}
if (String.IsNullOrEmpty(aReturnString))
{
aReturnString = PublishingDefinitions.DefaultMasterPageFileName;
}
return aReturnString;
}
public static string GetXHTMLMaster(string aMasterPageFile)
{
string aReturnString = "";
if (aMasterPageFile.EndsWith(PublishingDefinitions.GeneralMasterPageSuffix))
{
aReturnString = aMasterPageFile.Replace(PublishingDefinitions.HTML5MasterPageSuffix, PublishingDefinitions.XHTMLMasterPageSuffix);
}
if (String.IsNullOrEmpty(aReturnString))
{
aReturnString = PublishingDefinitions.DefaultMasterPageFileName;
}
return aReturnString;
}
internal static bool IsHTML5Master(string aMasterPageFile)
{
bool aReturn = false;
if (aMasterPageFile.Contains(PublishingDefinitions.HTML5MasterPageSuffix))
{
aReturn = true;
}
return aReturn;
}
public static string GetHTMLOpenTag(PublishingDefinitions.TagTypes aTagType, bool InEditMode)
{
string aTemp = "";
if ((BrowserCheck.IsHTML5CompliantBrowser()) && !InEditMode)
{
switch (aTagType)
{
case PublishingDefinitions.TagTypes.section: aTemp = PublishingDefinitions.HTML5SectionOpen; break;
case PublishingDefinitions.TagTypes.article: aTemp = PublishingDefinitions.HTML5ArticleOpen; break;
case PublishingDefinitions.TagTypes.aside: aTemp = PublishingDefinitions.HTML5ASideOpen; break;
case PublishingDefinitions.TagTypes.footer: aTemp = PublishingDefinitions.HTML5FooterOpen; break;
case PublishingDefinitions.TagTypes.header: aTemp = PublishingDefinitions.HTML5HeaderOpen; break;
case PublishingDefinitions.TagTypes.nav: aTemp = PublishingDefinitions.HTML5NavOpen; break;
default: aTemp = PublishingDefinitions.XHTMLSectionOpen; break;
}
}
else
{
switch (aTagType)
{
case PublishingDefinitions.TagTypes.section: aTemp = PublishingDefinitions.XHTMLSectionOpen; break;
case PublishingDefinitions.TagTypes.article: aTemp = PublishingDefinitions.XHTMLArticleOpen; break;
case PublishingDefinitions.TagTypes.aside: aTemp = PublishingDefinitions.XHTMLASideOpen; break;
case PublishingDefinitions.TagTypes.footer: aTemp = PublishingDefinitions.XHTMLFooterOpen; break;
case PublishingDefinitions.TagTypes.header: aTemp = PublishingDefinitions.XHTMLHeaderOpen; break;
case PublishingDefinitions.TagTypes.nav: aTemp = PublishingDefinitions.XHTMLNavOpen; break;
default: aTemp = PublishingDefinitions.XHTMLSectionOpen; break;
}
}
return aTemp;
}
public static string GetHTMLCloseTag(PublishingDefinitions.TagTypes aTagType, bool IsEditMode)
{
string aTemp = "";
if ((BrowserCheck.IsHTML5CompliantBrowser()) && !IsEditMode)
{
switch (aTagType)
{
case PublishingDefinitions.TagTypes.section: aTemp = PublishingDefinitions.HTML5SectionClose; break;
case PublishingDefinitions.TagTypes.article: aTemp = PublishingDefinitions.HTML5ArticleClose; break;
case PublishingDefinitions.TagTypes.aside: aTemp = PublishingDefinitions.HTML5ASideClose; break;
case PublishingDefinitions.TagTypes.footer: aTemp = PublishingDefinitions.HTML5FooterClose; break;
case PublishingDefinitions.TagTypes.header: aTemp = PublishingDefinitions.HTML5HeaderClose; break;
case PublishingDefinitions.TagTypes.nav: aTemp = PublishingDefinitions.HTML5NavClose; break;
default: aTemp = PublishingDefinitions.HTML5SectionClose; break;
}
}
else
{
switch (aTagType)
{
case PublishingDefinitions.TagTypes.section: aTemp = PublishingDefinitions.XHTMLDivTagClose; break;
case PublishingDefinitions.TagTypes.article: aTemp = PublishingDefinitions.XHTMLDivTagClose; break;
case PublishingDefinitions.TagTypes.aside: aTemp = PublishingDefinitions.XHTMLDivTagClose; break;
case PublishingDefinitions.TagTypes.footer: aTemp = PublishingDefinitions.XHTMLDivTagClose; break;
case PublishingDefinitions.TagTypes.header: aTemp = PublishingDefinitions.XHTMLDivTagClose; break;
case PublishingDefinitions.TagTypes.nav: aTemp = PublishingDefinitions.XHTMLDivTagClose; break;
default: aTemp = PublishingDefinitions.XHTMLDivTagClose; break;
}
}
return aTemp;
}
}
No comments:
Post a Comment