Example #1
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.OmitTag))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            foreach (var item in element.attributes)
            {
                if (item.name == "k-omit" || item.name == "omittag" || item.name == "omit-tag")
                {
                    element.removeAttribute(item.name);
                    return(new EvaluatorResponse()
                    {
                        OmitTag = true
                    });
                }
            }
            return(null);
        }
Example #2
0
        public static EvaluatorOption GetPageOption(FrontContext context)
        {
            EvaluatorOption renderoption = new EvaluatorOption();

            if (context.Page.Headers.HasValue())
            {
                if (context.Page.HasLayout)
                {
                    renderoption.RenderHeader = false;
                }
                else
                {
                    renderoption.RenderHeader = true;
                }
            }
            else
            {
                renderoption.RenderHeader = false;
            }

            renderoption.OwnerObjectId = context.Page.Id;

            SetOption(renderoption, context.RenderContext);

            return(renderoption);
        }
Example #3
0
        public ConditionRenderTask(Element element, string ConditionText, EvaluatorOption options)
        {
            if (string.IsNullOrWhiteSpace(ConditionText))
            {
                return;
            }

            ConditionText = ConditionText.Trim();
            if (ConditionText.StartsWith("!"))
            {
                ConditionText   = ConditionText.Substring(1);
                this.IsOpposite = true;
            }

            if (ConditionText.ToLower().StartsWith("repeat"))
            {
                this.IsRepeatCondition = true;
                this.ConditionText     = GetConditionText(ConditionText);
            }

            if (FunctionHelper.IsFunction(ConditionText))
            {
                this.IsFunction = true;
                this.function   = FunctionHelper.Parse(ConditionText);
            }
            else
            {
                this.Filter = FilterHelper.GetFilter(ConditionText);
                FilterHelper.CheckValueType(this.Filter);
            }
            string NewElementString = Service.DomService.ReSerializeElement(element);

            this.SubTasks = RenderEvaluator.Evaluate(NewElementString, options);
        }
Example #4
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.Header))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            if (element.tagName == "head" && options.RenderHeader)
            {
                var response = new EvaluatorResponse();
                var result   = new List <IRenderTask>();
                result.Add(new HeaderRenderTask(element));
                response.ContentTask       = result;
                response.OmitTag           = true;
                response.StopNextEvaluator = true;
                return(response);
            }
            return(null);
        }
Example #5
0
        private static EvaluatorOption GetPageOption(FrontContext context)
        {
            EvaluatorOption renderoption = new EvaluatorOption();

            if (context.WebSite != null && context.WebSite.EnableSitePath)
            {
                renderoption.RenderUrl = true;
            }
            else
            {
                renderoption.RenderUrl = false;
            }

            if (context.Page.Headers.HasValue())
            {
                if (context.Page.HasLayout)
                {
                    renderoption.RenderHeader = false;
                }
                else
                {
                    renderoption.RenderHeader = true;
                }
            }
            else
            {
                renderoption.RenderHeader = false;
            }

            //renderoption.RenderHeader = context.Page.Headers.HasValue();

            renderoption.RequireBindingInfo = context.RenderContext.Request.Channel == Data.Context.RequestChannel.InlineDesign;
            renderoption.OwnerObjectId      = context.Page.Id;
            return(renderoption);
        }
Example #6
0
        public static List <IRenderTask> GetLayoutPlan(string NameOrId, RenderContext context)
        {
            var layout = context.WebSite.SiteDb().Layouts.GetByNameOrId(NameOrId);

            if (layout == null)
            {
                return(null);
            }
            List <IRenderTask> renderplans = null;
            EvaluatorOption    options     = new  EvaluatorOption();

            options.RenderHeader  = true;
            options.OwnerObjectId = layout.Id;

            if (context.Request.Channel == RequestChannel.InlineDesign)
            {
                string body = DomService.ApplyKoobooId(layout.Body);
                options.RequireBindingInfo = true;
                renderplans = RenderEvaluator.Evaluate(body, options);
            }
            else
            {
                renderplans = Cache.RenderPlan.GetOrAddRenderPlan(context.WebSite.SiteDb(), layout.Id, () => RenderEvaluator.Evaluate(layout.Body, options));
            }

            return(renderplans);
        }
Example #7
0
        public static EvaluatorOption GetFormOption(RenderContext context, Guid FormId)
        {
            EvaluatorOption option = new EvaluatorOption();

            option.OwnerObjectId = FormId;
            SetOption(option, context);
            return(option);
        }
Example #8
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.Content))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            string attName = null;

            foreach (var item in element.attributes)
            {
                if (item.name == "tal-content" || item.name == "k-content" || item.name == "tal-replace" || item.name == "k-replace")
                {
                    attName = item.name;
                    break;
                }
            }
            if (!string.IsNullOrEmpty(attName))
            {
                var    response = new EvaluatorResponse();
                var    result   = new List <IRenderTask>();
                string value    = element.getAttribute(attName);
                element.removeAttribute(attName);
                result.Add(new ValueRenderTask(value));
                response.ContentTask = result;
                if (attName == "tal-replace" || attName == "k-replace")
                {
                    response.OmitTag = true;
                }

                if (options.RequireBindingInfo)
                {
                    if (response.BindingTask == null)
                    {
                        response.BindingTask = new List <IRenderTask>();
                    }
                    var bindingTask = new BindingRenderTask(value);
                    response.BindingTask.Add(bindingTask);
                    if (response.EndBindingTask == null)
                    {
                        response.EndBindingTask = new List <IRenderTask>();
                    }
                    response.EndBindingTask.Add(bindingTask.BindingEndRenderTask);
                }

                options.HasContentTask = true;
                return(response);
            }
            return(null);
        }
Example #9
0
        public static EvaluatorOption GetLayoutOption(RenderContext context, Guid LayoutId)
        {
            EvaluatorOption options = new EvaluatorOption();

            options.RenderHeader  = true;
            options.OwnerObjectId = LayoutId;

            SetOption(options, context);
            return(options);
        }
Example #10
0
        public EvaluatorOption Clone()
        {
            EvaluatorOption newoption = new EvaluatorOption();

            newoption.RenderHeader       = this.RenderHeader;
            newoption.RenderUrl          = this.RenderUrl;
            newoption.RequireBindingInfo = this.RequireBindingInfo;
            newoption.OwnerObjectId      = this.OwnerObjectId;
            return(newoption);
        }
Example #11
0
        public static EvaluatorOption GetHeaderOption(RenderContext context)
        {
            EvaluatorOption option = new EvaluatorOption();

            SetOption(option, context);
            option.RequireBindingInfo = false;
            option.RenderHeader       = false;
            option.RenderUrl          = false;
            return(option);
        }
Example #12
0
File: Form.cs Project: xhute/Kooboo
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.Form))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            if (ShouldEvaluate(element))
            {
                var response = new EvaluatorResponse();
                List <IRenderTask> result = new List <IRenderTask>();

                Guid   OwnerObjectId = options.OwnerObjectId;
                string KoobooId      = Service.DomService.GetKoobooId(element);
                Guid   FormId        = Kooboo.Data.IDGenerator.GetFormId(OwnerObjectId, KoobooId);

                result.Add(new FormRenderTask(element, OwnerObjectId, FormId, options));

                response.ContentTask       = result;
                response.StopNextEvaluator = true;
                response.OmitTag           = true;

                if (options.RequireBindingInfo)
                {
                    string boundary = Kooboo.Lib.Helper.StringHelper.GetUniqueBoundary();

                    var startbinding = new BindingObjectRenderTask()
                    {
                        ObjectType = "form", Boundary = boundary, NameOrId = FormId.ToString()
                    };
                    List <IRenderTask> bindingstarts = new List <IRenderTask>();
                    bindingstarts.Add(startbinding);
                    response.BindingTask = bindingstarts;

                    var endbinding = new BindingObjectRenderTask()
                    {
                        ObjectType = "form", IsEndBinding = true, Boundary = boundary, NameOrId = FormId.ToString()
                    };

                    List <IRenderTask> bindingends = new List <IRenderTask>();
                    bindingends.Add(endbinding);
                    response.EndBindingTask = bindingends;
                }
                return(response);
            }

            return(null);
        }
Example #13
0
        public EvaluatorOption Clone()
        {
            EvaluatorOption newoption = new EvaluatorOption();

            newoption.RenderHeader            = this.RenderHeader;
            newoption.RenderUrl               = this.RenderUrl;
            newoption.RequireBindingInfo      = this.RequireBindingInfo;
            newoption.OwnerObjectId           = this.OwnerObjectId;
            newoption.EnableImageBrowserCache = this.EnableImageBrowserCache;
            newoption.EnableJsCssBrowserCache = this.EnableJsCssBrowserCache;
            return(newoption);
        }
Example #14
0
        public static EvaluatorOption GetViewOption(RenderContext context, Guid ViewId)
        {
            EvaluatorOption options = new EvaluatorOption();

            SetOption(options, context);

            options.RenderUrl     = true;
            options.RenderHeader  = false;
            options.OwnerObjectId = ViewId;

            return(options);
        }
Example #15
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.Label))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            string LabelName = null;

            foreach (var item in element.attributes)
            {
                var lower = item.name.ToLower();
                if (lower == "tal-label" || lower == "k-label")
                {
                    LabelName = item.name;
                    break;
                }
            }
            if (!string.IsNullOrEmpty(LabelName))
            {
                var    response = new EvaluatorResponse();
                var    result   = new List <IRenderTask>();
                string value    = element.getAttribute(LabelName);
                element.removeAttribute(LabelName);

                if (options.RequireBindingInfo)
                {
                    if (response.BindingTask == null)
                    {
                        response.BindingTask = new List <IRenderTask>();
                    }
                    var traceability = new ComponentTrace(value, "label");
                    var bindingTask  = new BindingRenderTask(traceability);
                    response.BindingTask.Add(bindingTask);
                    if (response.EndBindingTask == null)
                    {
                        response.EndBindingTask = new List <IRenderTask>();
                    }
                    response.EndBindingTask.Add(bindingTask.BindingEndRenderTask);
                }

                result.Add(new LabelRenderTask(value));
                response.ContentTask = result;
                return(response);
            }
            return(null);
        }
Example #16
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.Label))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            string LabelName = null;

            foreach (var item in element.attributes)
            {
                var lower = item.name.ToLower();
                if (lower == "tal-label" || lower == "k-label")
                {
                    LabelName = item.name;
                    break;
                }
            }
            if (!string.IsNullOrEmpty(LabelName))
            {
                var response = new EvaluatorResponse();
                List <IRenderTask> result = new List <IRenderTask>();
                string             value  = element.getAttribute(LabelName);

                if (!options.RequireBindingInfo)
                {
                    element.removeAttribute(LabelName);
                }
                else
                {
                    string koobooid = element.getAttribute("kooboo-id");
                    BindingObjectRenderTask binding = new BindingObjectRenderTask()
                    {
                        ObjectType = "Label", AttributeName = LabelName, BindingValue = value, KoobooId = koobooid
                    };
                    List <IRenderTask> bindings = new List <IRenderTask>();
                    bindings.Add(binding);
                    response.BindingTask = bindings;
                }

                result.Add(new LabelRenderTask(value));
                response.ContentTask = result;
                return(response);
            }
            return(null);
        }
Example #17
0
        public SiteLayoutRenderTask(Element LayoutElement, EvaluatorOption option)
        {
            if (LayoutElement.hasAttribute("id"))
            {
                this.LayoutName = LayoutElement.getAttribute("id");
            }
            else if (LayoutElement.hasAttribute("name"))
            {
                this.LayoutName = LayoutElement.getAttribute("name");
            }

            LoadComponents(LayoutElement, option);
        }
Example #18
0
        public ConditionRenderTask(Element element, string ConditionText, EvaluatorOption options)
        {
            if (ConditionText.ToLower().StartsWith("repeat"))
            {
                this.IsRepeatCondition = true;
                this.ConditionText     = GetConditionText(ConditionText);
            }
            else
            {
                this.Filter = FilterHelper.GetFilter(ConditionText);
            }
            string NewElementString = Service.DomService.ReSerializeElement(element);

            this.SubTasks = RenderEvaluator.Evaluate(NewElementString, options);
        }
Example #19
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.Form))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            if (ShouldEvaluate(element))
            {
                var response = new EvaluatorResponse();
                List <IRenderTask> result = new List <IRenderTask>();

                Guid   OwnerObjectId = options.OwnerObjectId;
                string KoobooId      = Service.DomService.GetKoobooId(element);
                Guid   FormId        = Kooboo.Data.IDGenerator.GetFormId(OwnerObjectId, KoobooId);

                result.Add(new FormRenderTask(element, OwnerObjectId, FormId, options));

                response.ContentTask       = result;
                response.StopNextEvaluator = true;
                response.OmitTag           = true;

                if (options.RequireBindingInfo)
                {
                    if (response.BindingTask == null)
                    {
                        response.BindingTask = new List <IRenderTask>();
                    }
                    var traceability = new ComponentTrace(FormId.ToString(), "innerform");
                    var bindingTask  = new BindingRenderTask(traceability);
                    response.BindingTask.Add(bindingTask);
                    if (response.EndBindingTask == null)
                    {
                        response.EndBindingTask = new List <IRenderTask>();
                    }
                    response.EndBindingTask.Add(bindingTask.BindingEndRenderTask);
                }
                return(response);
            }

            return(null);
        }
Example #20
0
        public FormRenderTask(Element element, Guid OwnerObjectId, Guid FormId, EvaluatorOption evalutionOption)
        {
            this.options = options;

            foreach (var item in element.attributes)
            {
                this.FormAttributes.Add(item.name, item.value);
            }
            this.OwnerObjectId = OwnerObjectId;

            this.OriginalInnerHtml = element.InnerHtml;

            this.FormId = FormId;

            InitOrgTask();
        }
Example #21
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.SiteLayout))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            if (element.tagName == "layout" && (element.hasAttribute("id") || element.hasAttribute("name")))
            {
                var response = new EvaluatorResponse();
                var result   = new List <IRenderTask>();
                result.Add(new SiteLayoutRenderTask(element, options));
                response.ContentTask = result;
                response.OmitTag     = true;

                if (options.RequireBindingInfo)
                {
                    string boundary = Kooboo.Lib.Helper.StringHelper.GetUniqueBoundary();

                    var startbinding = new BindingObjectRenderTask()
                    {
                        ObjectType = "layout", Boundary = boundary, NameOrId = element.id
                    };
                    List <IRenderTask> bindingstarts = new List <IRenderTask>();
                    bindingstarts.Add(startbinding);
                    response.BindingTask = bindingstarts;

                    var endbinding = new BindingObjectRenderTask()
                    {
                        ObjectType = "layout", IsEndBinding = true, Boundary = boundary, NameOrId = element.id
                    };

                    List <IRenderTask> bindingends = new List <IRenderTask>();
                    bindingends.Add(endbinding);
                    response.EndBindingTask = bindingends;
                }
                return(response);
            }

            return(null);
        }
Example #22
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.Component))
            {
                return(null);
            }
            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            if (Components.Manager.IsComponent(element))
            {
                var response = new EvaluatorResponse();
                List <IRenderTask> result = new List <IRenderTask>();
                result.Add(new  ComponentRenderTask(element));
                response.ContentTask       = result;
                response.OmitTag           = true;
                response.StopNextEvaluator = true;

                if (options.RequireBindingInfo)
                {
                    string boundary     = Kooboo.Lib.Helper.StringHelper.GetUniqueBoundary();
                    var    startbinding = new BindingObjectRenderTask()
                    {
                        ObjectType = element.tagName, Boundary = boundary, NameOrId = element.id
                    };
                    List <IRenderTask> bindingstarts = new List <IRenderTask>();
                    bindingstarts.Add(startbinding);
                    response.BindingTask = bindingstarts;

                    var endbinding = new BindingObjectRenderTask()
                    {
                        ObjectType = element.tagName, IsEndBinding = true, Boundary = boundary, NameOrId = element.id
                    };

                    List <IRenderTask> bindingends = new List <IRenderTask>();
                    bindingends.Add(endbinding);
                    response.EndBindingTask = bindingends;
                }
                return(response);
            }

            return(null);
        }
Example #23
0
        private void LoadComponents(Element element, EvaluatorOption option)
        {
            foreach (var item in element.childNodes.item)
            {
                if (item.nodeType == enumNodeType.ELEMENT)
                {
                    Element child = item as Element;

                    if (child.tagName == "position" || child.tagName == "placeholder")
                    {
                        string positionname = child.id;
                        if (string.IsNullOrEmpty(positionname))
                        {
                            positionname = child.getAttribute("name");
                        }

                        if (string.IsNullOrEmpty(positionname))
                        {
                            continue;
                        }
                        List <IRenderTask> ComTask = new List <IRenderTask>();

                        string innerhtml = child.InnerHtml;

                        if (!string.IsNullOrWhiteSpace(innerhtml))
                        {
                            var newoption = option.Clone();
                            newoption.RenderHeader = false;
                            ComTask = RenderEvaluator.Evaluate(innerhtml, option);
                        }

                        if (Components.ContainsKey(positionname))
                        {
                            var current = Components[positionname];
                            current.AddRange(ComTask);
                            Components[positionname] = current;
                        }
                        else
                        {
                            Components[positionname] = ComTask;
                        }
                    }
                }
            }
        }
Example #24
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.Component))
            {
                return(null);
            }
            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            if (Components.Manager.IsComponent(element))
            {
                var response = new EvaluatorResponse();
                var result   = new List <IRenderTask>();
                result.Add(new ComponentRenderTask(element));
                response.ContentTask       = result;
                response.OmitTag           = true;
                response.StopNextEvaluator = true;

                if (options.RequireBindingInfo)
                {
                    if (response.BindingTask == null)
                    {
                        response.BindingTask = new List <IRenderTask>();
                    }
                    var traceability = new ComponentTrace(element.id, element.tagName);
                    var bindingTask  = new BindingRenderTask(traceability, new Dictionary <string, string> {
                        { "scope", "true" }
                    });
                    response.BindingTask.Add(bindingTask);
                    if (response.EndBindingTask == null)
                    {
                        response.EndBindingTask = new List <IRenderTask>();
                    }
                    response.EndBindingTask.Add(bindingTask.BindingEndRenderTask);
                }
                return(response);
            }

            return(null);
        }
Example #25
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.SiteLayout))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            if (element.tagName == "layout" && (element.hasAttribute("id") || element.hasAttribute("name")))
            {
                var response = new EvaluatorResponse();
                var result   = new List <IRenderTask>();
                result.Add(new SiteLayoutRenderTask(element, options));
                response.ContentTask = result;
                response.OmitTag     = true;

                if (options.RequireBindingInfo)
                {
                    if (response.BindingTask == null)
                    {
                        response.BindingTask = new List <IRenderTask>();
                    }
                    var traceability = new ComponentTrace(element.id, element.tagName);
                    var bindingTask  = new BindingRenderTask(traceability, new Dictionary <string, string> {
                        { "scope", "true" }
                    });
                    response.BindingTask.Add(bindingTask);
                    if (response.EndBindingTask == null)
                    {
                        response.EndBindingTask = new List <IRenderTask>();
                    }
                    response.EndBindingTask.Add(bindingTask.BindingEndRenderTask);
                }
                return(response);
            }

            return(null);
        }
Example #26
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.Condition))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            string attName = null;

            foreach (var item in element.attributes)
            {
                if (item.name == "tal-condition" || item.name == "k-if" || item.name == "k-condition")
                {
                    attName = item.name;
                    break;
                }
            }
            if (!string.IsNullOrEmpty(attName))
            {
                string conditiontext = element.getAttribute(attName);
                if (string.IsNullOrEmpty(conditiontext))
                {
                    return(null);
                }
                element.removeAttribute(attName);
                var response = new EvaluatorResponse();
                List <IRenderTask> result = new List <IRenderTask>();
                result.Add(new ConditionRenderTask(element, conditiontext, options));
                response.ContentTask       = result;
                response.StopNextEvaluator = true;
                response.OmitTag           = true;
                return(response);
            }
            return(null);
        }
Example #27
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.OmitTag))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            bool shouldomit = false;

            foreach (var item in element.attributes)
            {
                if (item.name == "k-omitouter" || item.name == "k-omitoutertag")
                {
                    shouldomit = true;
                    break;
                }
            }

            if (shouldomit)
            {
                TagOmitRenderTask task = new TagOmitRenderTask(element, options);

                var response = new EvaluatorResponse();
                List <IRenderTask> result = new List <IRenderTask>();
                result.Add(task);
                response.ContentTask       = result;
                response.OmitTag           = true;
                response.StopNextEvaluator = true;
                return(response);
            }
            else
            {
                return(null);
            }
        }
Example #28
0
        public static void SetOption(EvaluatorOption option, RenderContext context)
        {
            if (context.WebSite != null)
            {
                if (context.WebSite.EnableJsCssBrowerCache)
                {
                    option.EnableJsCssBrowserCache = context.WebSite.EnableJsCssBrowerCache;
                }

                if (context.WebSite.EnableImageBrowserCache && context.WebSite.ImageCacheDays <= 0)
                {
                    option.EnableImageBrowserCache = true;
                }
                else
                {
                    option.EnableImageBrowserCache = false;
                }
            }

            option.RenderUrl          = RenderUrl(context);
            option.RequireBindingInfo = RenderBindingInfo(context);
        }
Example #29
0
        public EvaluatorResponse Evaluate(Node node, EvaluatorOption options)
        {
            if (options.IgnoreEvaluators.HasFlag(EnumEvaluator.PlaceHolder))
            {
                return(null);
            }

            if (node.nodeType != enumNodeType.ELEMENT)
            {
                return(null);
            }
            var element = node as Element;

            //"tal-placeholder", "position", "placeholder"
            string PositionName = null;

            foreach (var item in element.attributes)
            {
                var lower = item.name.ToLower();
                if (lower == "tal-placeholder" || lower == "k-position" || lower == "tal-position" || lower == "k-placeholder")
                {
                    PositionName = item.name;
                    break;
                }
            }

            if (!string.IsNullOrEmpty(PositionName))
            {
                var response = new EvaluatorResponse();
                List <IRenderTask> result        = new List <IRenderTask>();
                string             PositionValue = element.getAttribute(PositionName);
                element.removeAttribute(PositionName);
                result.Add(new PlaceHolderRenderTask(PositionValue));
                response.ContentTask = result;
                return(response);
            }
            return(null);
        }
Example #30
0
        public static List <IRenderTask> GetLayoutPlan(string NameOrId, RenderContext context)
        {
            var layout = context.WebSite.SiteDb().Layouts.GetByNameOrId(NameOrId);

            if (layout == null)
            {
                return(null);
            }
            List <IRenderTask> renderplans = null;

            EvaluatorOption options = RenderOptionHelper.GetLayoutOption(context, layout.Id);

            if (options.RequireBindingInfo)
            {
                string body = DomService.ApplyKoobooId(layout.Body);
                renderplans = RenderEvaluator.Evaluate(body, options);
            }
            else
            {
                renderplans = Cache.RenderPlan.GetOrAddRenderPlan(context.WebSite.SiteDb(), layout.Id, () => RenderEvaluator.Evaluate(layout.Body, options));
            }

            return(renderplans);
        }