Beispiel #1
0
        private string RenderHeaderMetaItem(HeaderRenderItem item, List <HeaderBindings> bindings, RenderContext context)
        {
            if (bindings == null || bindings.Count() == 0)
            {
                return(item.OriginalHtml);
            }

            HeaderBindings finditem = null;

            if (!string.IsNullOrEmpty(item.MetaName))
            {
                finditem = bindings.Find(o => Lib.Helper.StringHelper.IsSameValue(item.MetaName, o.MetaName));
            }
            else if (!string.IsNullOrEmpty(item.HttpEquive))
            {
                finditem = bindings.Find(o => Lib.Helper.StringHelper.IsSameValue(item.HttpEquive, o.HttpEquiv));
            }
            else if (!string.IsNullOrEmpty(item.CharSet))
            {
                finditem = bindings.Find(o => !string.IsNullOrEmpty(o.CharSet));
            }

            if (finditem != null)
            {
                bindings.Remove(finditem);
                return(RenderBindingItem(finditem, context));
            }
            else
            {
                return(item.OriginalHtml);
            }
        }
Beispiel #2
0
        private string RenderBindingItem(HeaderBindings binding, RenderContext context)
        {
            if (binding == null)
            {
                return(null);
            }

            string newcontent = GetBindingContent(binding, context);

            if (newcontent == null)
            {
                return(null);
            }

            if (binding.IsTitle)
            {
                return("<Title>" + newcontent + "</Title>");
            }
            else if (binding.IsCustomHeader)
            {
                return(newcontent);
            }
            else
            {
                string result = "<Meta";

                if (!string.IsNullOrEmpty(binding.MetaName))
                {
                    result += " name=\"" + binding.MetaName + "\"";
                }

                if (!string.IsNullOrEmpty(binding.HttpEquiv))
                {
                    result += " http-equiv=\"" + binding.HttpEquiv + "\"";
                }

                if (!string.IsNullOrEmpty(binding.CharSet))
                {
                    result += " charset=\"" + binding.CharSet + "\"";
                }

                if (!string.IsNullOrEmpty(newcontent))
                {
                    result += " content=\"" + newcontent + "\"";
                }

                result = result + " />";

                return(result);
            }
        }
Beispiel #3
0
 public string GetBindingContent(HeaderBindings binding, RenderContext context)
 {
     return(binding.GetContent(context));
 }
Beispiel #4
0
        public static List <HeaderBindings> GetHeaderBinding(Page page, string culture, bool IsMultilingual = false)
        {
            List <HeaderBindings> bindings = new List <HeaderBindings>();

            var title = page.Headers.GetTitle(culture);

            if (!string.IsNullOrEmpty(title))
            {
                if (IsMultilingual || page.HasLayout || Service.BindingService.IsBinding(title))
                {
                    HeaderBindings titlebinding = new HeaderBindings();
                    titlebinding.IsTitle = true;
                    titlebinding.Content = title;
                    bindings.Add(titlebinding);
                }
            }

            foreach (var item in page.Headers.Metas)
            {
                string metabindingValue = item.GetContent(culture);

                if (!string.IsNullOrEmpty(metabindingValue))
                {
                    if (IsMultilingual || page.HasLayout || Service.BindingService.IsBinding(metabindingValue))
                    {
                        HeaderBindings metabinding = new HeaderBindings();
                        metabinding.MetaName  = item.name;
                        metabinding.Content   = metabindingValue;
                        metabinding.CharSet   = item.charset;
                        metabinding.HttpEquiv = item.httpequiv;
                        bindings.Add(metabinding);
                    }
                }
            }

            string customerHeader = null;

            if (page.HasLayout)
            {
                foreach (var item in page.Headers.Styles)
                {
                    customerHeader += "\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\"" + item + "\" />";
                }
                foreach (var item in page.Headers.Scripts)
                {
                    customerHeader += "\r\n<script type=\"text/javascript\" src=\"" + item + "\"></script>";
                }
            }

            customerHeader += page.Headers.CustomHeader;

            if (!string.IsNullOrEmpty(customerHeader))
            {
                HeaderBindings custombinding = new HeaderBindings();
                custombinding.IsCustomHeader = true;
                custombinding.Content        = customerHeader;
                bindings.Add(custombinding);
            }

            return(bindings);
        }