Exemplo n.º 1
0
        /// <summary>
        /// Returns the metadata value for different types of metadata name.
        /// </summary>
        /// <param name="metaDataType"></param>
        /// <returns></returns>
        private String getMetaData(HtmlMetaDataType metaDataType)
        {
            IPageAssemblyInstruction asmInstr = PageAssemblyInstruction;
            string path     = asmInstr.SectionPath;
            string metaData = String.Empty;

            if (asmInstr != null)
            {
                switch (metaDataType)
                {
                case HtmlMetaDataType.Description:
                    metaData = asmInstr.GetField(PageAssemblyInstructionFields.HTML_MetaDescription);
                    break;

                case HtmlMetaDataType.KeyWords:
                    metaData = asmInstr.GetField(PageAssemblyInstructionFields.HTML_MetaKeywords);
                    break;

                case HtmlMetaDataType.Robots:
                    metaData = asmInstr.GetField(PageAssemblyInstructionFields.HTML_MetaRobots);
                    break;

                case HtmlMetaDataType.ContentLanguage:
                    metaData = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
                    break;

                case HtmlMetaDataType.Coverage:     // Suite(s)
                    metaData = SectionDetailFactory.GetSectionDetail(path).GetWASuites();
                    break;

                case HtmlMetaDataType.Subject:     // Channel(s)
                    metaData = SectionDetailFactory.GetSectionDetail(path).GetWAChannels();
                    break;

                case HtmlMetaDataType.IsPartOf:     // Content group(s)
                    metaData = SectionDetailFactory.GetSectionDetail(path).GetWAContentGroups();
                    break;

                case HtmlMetaDataType.DatePublished:
                    metaData = String.Format("{0:MM/dd/yyyy}", ((BasePageAssemblyInstruction)PageAssemblyInstruction).ContentDates.FirstPublished);
                    break;

                case HtmlMetaDataType.EnglishLinkingPolicy:
                    metaData = ContentDeliveryEngineConfig.PathInformation.EnglishLinkingPolicyPath.Path;
                    break;

                case HtmlMetaDataType.EspanolLinkingPolicy:
                    metaData = ContentDeliveryEngineConfig.PathInformation.EspanolLinkingPolicyPath.Path;
                    break;

                case HtmlMetaDataType.ContentType:
                    metaData = ((BasePageAssemblyInstruction)PageAssemblyInstruction).ContentItemInfo.ContentItemType;
                    metaData = metaData.Replace("rx:", "");
                    break;
                }
            }

            metaData = string.IsNullOrEmpty(metaData) ? "" : metaData.Trim();
            return(metaData);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Every time this method is called, a single metadata element is added to the
        /// head of the page.
        /// </summary>
        /// <param name="htmlHead">The html header control of the page.The head html tag should have runat="server"</param>
        /// <param name="htmlMetaDataType">The name of the metadata element you want to add</param>
        private void addMetaDataItem(HtmlHead htmlHead, HtmlMetaDataType htmlMetaDataType)
        {
            HtmlMeta hm = new HtmlMeta();

            hm.Name    = htmlMetaDataType.ToString().ToLower();
            hm.Content = getMetaData(htmlMetaDataType);

            if (htmlMetaDataType == HtmlMetaDataType.ContentLanguage)
            {
                hm.Name = "content-language";
            }
            else if (htmlMetaDataType == HtmlMetaDataType.ContentType)
            {
                hm.Name = "dcterms.type";
            }
            else if (htmlMetaDataType == HtmlMetaDataType.Coverage)
            {
                hm.Name = "dcterms.coverage";
            }
            else if (htmlMetaDataType == HtmlMetaDataType.Subject)
            {
                hm.Name = "dcterms.subject";
            }
            else if (htmlMetaDataType == HtmlMetaDataType.IsPartOf)
            {
                hm.Name = "dcterms.isPartOf";
            }
            else if (htmlMetaDataType == HtmlMetaDataType.DatePublished)
            {
                hm.Name = "dcterms.issued";
            }
            else if (htmlMetaDataType == HtmlMetaDataType.EnglishLinkingPolicy)
            {
                hm.Name = "english-linking-policy";
            }
            else if (htmlMetaDataType == HtmlMetaDataType.EspanolLinkingPolicy)
            {
                hm.Name = "espanol-linking-policy";
            }
            else if (htmlMetaDataType == HtmlMetaDataType.Robots)
            {
                // If robots content has not been set, do not create robots meta tag
                if (hm.Content == "")
                {
                    return;
                }
                else
                {
                    hm.Name = "robots";
                }
            }

            htmlHead.Controls.Add(hm);
        }